// #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 { Emit } from '../../../../Events/Decorators/EmitDecorator';
import { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { dropZoneElementTemplate } from './DropZoneElementTemplate';
import { dropZoneElementJoyStyle } from './Themes/DropZoneElement.Joy';
import { dropZoneElementRetroStyle } from './Themes/DropZoneElement.Retro';
import { dropZoneElementCosmopolitanStyle } from './Themes/DropZoneElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * The `{@link DropZoneElement}` element.
 *
 * @fires dataTransferd - Fired when data is transferred to the drop zone.
 *
 * @public
 */
let DropZoneElement = class DropZoneElement extends Themeable(Disableable(Appearanceable(Variantable(CustomElement)))) {
    // #region Fields
    _dataTransferd;
    _dragSubscription;
    _dragOverSubscription;
    _dragStartSubscription;
    _dragEndSubscription;
    _dragEnterSubscription;
    _dragLeaveSubscription;
    _dropSubscription;
    _isDragging;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._dragSubscription = null;
        this._dragOverSubscription = null;
        this._dragStartSubscription = null;
        this._dragEndSubscription = null;
        this._dragEnterSubscription = null;
        this._dragLeaveSubscription = null;
        this._dropSubscription = null;
        this._isDragging = false;
        this._dataTransferd = new HTMLElementEventEmitter(this, 'dataTransferd');
    }
    // #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-drop-zone';
    }
    /**
     * Returns the `{@link isDragging}` property.
     *
     * @public
     * @readonly
     * @attr
     */
    get isDragging() {
        return this._isDragging;
    }
    set isDragging(value) {
        if (this._isDragging !== value) {
            this._isDragging = value;
            this.requestUpdate('isDragging');
        }
    }
    /**
     * Called when the data is transferred to the drop zone.
     * Provides reference to `{@link IEventDetail}` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get dataTransferd() {
        return this._dataTransferd;
    }
    // #endregion
    // #region Methods
    /**
     * @public
     * @override
     */
    connectedCallback() {
        super.connectedCallback();
        this._dragSubscription = this.on('drag', (e) => this.onDragDrop(e));
        this._dragOverSubscription = this.on('dragover', (e) => this.onDragDrop(e));
        this._dragStartSubscription = this.on('dragstart', (e) => this.onDragDrop(e));
        this._dragEndSubscription = this.on('dragend', (e) => this.onDragDrop(e));
        this._dragEnterSubscription = this.on('dragenter', (e) => this.onDragDrop(e));
        this._dragLeaveSubscription = this.on('dragleave', (e) => this.onDragDrop(e));
        this._dropSubscription = this.on('drop', (e) => this.onDragDrop(e));
    }
    disconnectedCallback() {
        super.disconnectedCallback();
        this._dragSubscription?.dispose();
        this._dragOverSubscription?.dispose();
        this._dragStartSubscription?.dispose();
        this._dragEndSubscription?.dispose();
        this._dragEnterSubscription?.dispose();
        this._dragLeaveSubscription?.dispose();
        this._dropSubscription?.dispose();
    }
    /**
     * Emits the {@link dataTransferd} event.
     *
     * @protected
     */
    onDataTransferd(args) {
        this._dataTransferd.emit(args);
    }
    /**
     * @protected
     */
    onDragDrop(event) {
        event.preventDefault();
        event.stopPropagation();
        if (this.disabled) {
            // TODO: handle disabled state
        }
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], DropZoneElement.prototype, "isDragging", null);
__decorate([
    Emit({ eventName: 'dataTransferd' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], DropZoneElement.prototype, "dataTransferd", null);
DropZoneElement = __decorate([
    Component({
        selector: 'mosaik-drop-zone',
        template: dropZoneElementTemplate,
        themes: {
            joy: dropZoneElementJoyStyle,
            retro: dropZoneElementRetroStyle,
            cosmopolitan: dropZoneElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], DropZoneElement);
export { DropZoneElement };
//# sourceMappingURL=DropZoneElement.js.map