// #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 { DomServiceLocator } from '../../../../Dom/Dom';
import { Listen } from '../../../../Events/Decorators/ListenDecorator';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { FileUploadView } from '../../../Types/FileUploadView';
import { KeyName } from '../../../Types/Key';
import { CustomElement } from '../../Abstracts/CustomElement';
import { FileUploadElement } from './FileUploadElement';
import { fileUploadItemElementTemplate } from './FileUploadItemElementTemplate';
import { fileUploadItemElementJoyStyle } from './Themes/FileUploadItemElement.Joy';
import { fileUploadItemElementRetroStyle } from './Themes/FileUploadItemElement.Retro';
import { fileUploadItemElementCosmopolitanStyle } from './Themes/FileUploadItemElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * File Upload Item - A subcomponent that represents a single file within a file upload list.
 *
 * @description
 * The FileUploadItem component is used as part of the FileUpload workflow to display and manage an individual file.
 * It typically shows details such as the file name, size, type, and upload progress. Users can interact with each
 * FileUploadItem to remove files, retry failed uploads, or view upload status indicators.
 *
 * This component improves clarity and usability by breaking down the upload process into manageable units,
 * making it easier for users to track the status of each file independently.
 *
 * @element mosaik-file-upload-item
 * @category Input
 *
 * @slot label - The slot for custom label content (e.g., file name or description).
 * @slot actions - The slot for custom action content (e.g., remove or retry buttons).
 *
 * @example
 * ```html
 * <mosaik-file-upload-item>
 *   <span>example.pdf</span>
 *   <button>Remove</button>
 * </mosaik-file-upload-item>
 * ```
 *
 * @public
 */
let FileUploadItemElement = class FileUploadItemElement extends Themeable(CustomElement) {
    // #region Fields
    _file;
    _view;
    _controlled;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._file = null;
        this._view = FileUploadView.List;
        this._controlled = false;
    }
    // #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-file-upload-item';
    }
    /**
     * Gets or sets the `file` property.
     *
     */
    get file() {
        return this._file;
    }
    set file(value) {
        if (this._file !== value) {
            this._file = value;
            this.requestUpdate('file');
        }
    }
    /**
     * Gets or sets the `view` property.
     *
     * @public
     * @attr
     */
    get view() {
        return this._view;
    }
    set view(value) {
        if (this._view !== value) {
            this._view = value;
            this.requestUpdate('view');
        }
    }
    /**
     * Gets or sets the `controlled` property.
     *
     * @public
     * @attr
     */
    get controlled() {
        return this._controlled;
    }
    set controlled(value) {
        if (this._controlled !== value) {
            this._controlled = value;
            this.requestUpdate('controlled');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @internal
     * @template
     */
    onSave(e) {
        e.preventDefault();
        if (this._file) {
            const parent = DomServiceLocator.current.findAncestor(this, FileUploadElement.is, { strict: true });
            void parent.save(this._file);
        }
    }
    /**
     * @internal
     * @template
     */
    onDelete(e) {
        e.preventDefault();
        if (this._file) {
            const parent = DomServiceLocator.current.findAncestor(this, FileUploadElement.is, { strict: true });
            parent.delete(this._file);
        }
    }
    /**
     * @protected
     */
    onKeyDown(e) {
        if (e.key === KeyName.Delete) {
            e.preventDefault();
            if (this._file) {
                const parent = DomServiceLocator.current.findAncestor(this, FileUploadElement.is, { strict: true });
                parent.delete(this._file);
            }
        }
    }
};
__decorate([
    Property({ type: Object }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], FileUploadItemElement.prototype, "file", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], FileUploadItemElement.prototype, "view", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], FileUploadItemElement.prototype, "controlled", null);
__decorate([
    Listen('keydown'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [KeyboardEvent]),
    __metadata("design:returntype", void 0)
], FileUploadItemElement.prototype, "onKeyDown", null);
FileUploadItemElement = __decorate([
    Component({
        selector: 'mosaik-file-upload-item',
        template: fileUploadItemElementTemplate,
        themes: {
            joy: fileUploadItemElementJoyStyle,
            retro: fileUploadItemElementRetroStyle,
            cosmopolitan: fileUploadItemElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], FileUploadItemElement);
export { FileUploadItemElement };
//# sourceMappingURL=FileUploadItemElement.js.map