// #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 { Disableable } from '../Controls/Behaviors/Disableable';
import { CustomElement } from '../Controls/Components/Abstracts/CustomElement';
import { Attribute } from '../Controls/Decorators/AttributeDecorator';
import { Component } from '../Controls/Decorators/ComponentDecorator';
import { Property } from '../Controls/Decorators/PropertyDecorator';
import { routerLinkElementStyle } from './RouterLinkElementStyle';
import { routerLinkElementTemplate } from './RouterLinkElementTemplate';
// #endregion
/**
 * The `{@link RouterLinkElement}` element.
 *
 * @public
 */
let RouterLinkElement = class RouterLinkElement extends Disableable(CustomElement) {
    // #region Fields
    _href;
    _target;
    _query;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._href = '';
        this._target = '';
        this._query = {};
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-router-link';
    }
    /**
     * Gets or sets the `href` property.
     *
     * @public
     * @attr
     */
    get href() {
        return this.toString();
    }
    set href(value) {
        if (this._href !== value) {
            this._href = value;
            this.requestUpdate('href');
        }
    }
    /**
     * Gets or sets the `query` property.
     *
     * @public
     */
    get query() {
        return this._query;
    }
    set query(value) {
        if (this._query !== value) {
            this._query = value;
            this.requestUpdate('query');
        }
    }
    /**
     * Gets or sets the `target` property.
     *
     * @public
     * @attr
     */
    get target() {
        return this._target;
    }
    set target(value) {
        if (this._target !== value) {
            this._target = value;
            this.requestUpdate('target');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @override
     */
    toString() {
        return this.buildUrl();
    }
    /**
     * @private
     */
    buildUrl() {
        const url = new URL(this._href, window.location.origin);
        Object.keys(this.query).forEach((key) => {
            const value = this._query[key] ?? '';
            url.searchParams.append(key, value);
        });
        return url.toString();
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], RouterLinkElement.prototype, "href", null);
__decorate([
    Property({ type: Object }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], RouterLinkElement.prototype, "query", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], RouterLinkElement.prototype, "target", null);
RouterLinkElement = __decorate([
    Component({
        selector: 'mosaik-router-link',
        template: routerLinkElementTemplate,
        styles: routerLinkElementStyle,
        host: {
            role: 'link'
        }
    }),
    __metadata("design:paramtypes", [])
], RouterLinkElement);
export { RouterLinkElement };
//# sourceMappingURL=RouterLinkElement.js.map