// #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 { CssTime } from '@breadstone/mosaik-themes';
import { Orientable } from '../../../Behaviors/Orientable';
import { Reversible } from '../../../Behaviors/Reversible';
import { Slottable } from '../../../Behaviors/Slottable';
import { Themeable } from '../../../Behaviors/Themeable';
import { InlineStyleController } from '../../../Controllers/InlineStyleController';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { marqueeElementTemplate } from './MarqueeElementTemplate';
import { marqueeElementCosmopolitanStyle } from './Themes/MarqueeElement.Cosmopolitan';
import { marqueeElementJoyStyle } from './Themes/MarqueeElement.Joy';
import { marqueeElementMemphisStyle } from './Themes/MarqueeElement.Memphis';
// #endregion
/**
 * Marquee - A component for scrolling text or images horizontally or vertically.
 *
 * @description
 * The Marquee component enables scrolling of text or images across a web page. It can be configured to scroll content
 * either horizontally or vertically, providing a dynamic and attention-grabbing effect. Marquees are often used to
 * highlight important information or create visual interest.
 *
 * @element mosaik-marquee
 * @category Primitives
 *
 * @slot  - The default slot.
 *
 * @csspart overlay - The overlay part.
 * @csspart track - The track part.
 *
 * @cssprop {String} --marquee-direction - The direction CSS custom property.
 * @cssprop {String} --marquee-font-family - The font family CSS custom property.
 * @cssprop {String} --marquee-font-letter-spacing - The font letter spacing CSS custom property.
 * @cssprop {String} --marquee-font-line-height - The font line height CSS custom property.
 * @cssprop {String} --marquee-font-size - The font size CSS custom property.
 * @cssprop {String} --marquee-font-text-decoration - The font text decoration CSS custom property.
 * @cssprop {String} --marquee-font-text-transform - The font text transform CSS custom property.
 * @cssprop {String} --marquee-font-weight - The font weight CSS custom property.
 * @cssprop {String} --marquee-gap - The gap CSS custom property.
 * @cssprop {String} --marquee-padding-bottom - The padding bottom CSS custom property.
 * @cssprop {String} --marquee-padding-left - The padding left CSS custom property.
 * @cssprop {String} --marquee-padding-right - The padding right CSS custom property.
 * @cssprop {String} --marquee-padding-top - The padding top CSS custom property.
 * @cssprop {String} --marquee-shadow - The shadow CSS custom property.
 * @cssprop {String} --marquee-shadow-blur - The shadow blur CSS custom property.
 * @cssprop {String} --marquee-shadow-color - The shadow color CSS custom property.
 * @cssprop {String} --marquee-shadow-offset-x - The shadow offset x CSS custom property.
 * @cssprop {String} --marquee-shadow-offset-y - The shadow offset y CSS custom property.
 * @cssprop {String} --marquee-shadow-spread - The shadow spread CSS custom property.
 * @cssprop {String} --marquee-speed - The speed CSS custom property.
 * @cssprop {String} --marquee-transition-duration - The transition duration CSS custom property.
 * @cssprop {String} --marquee-transition-mode - The transition mode CSS custom property.
 * @cssprop {String} --marquee-transition-property - The transition property CSS custom property.
 * @cssprop {String} --marquee-translate - The translate CSS custom property.
 *
 * @example
 * ```html
 * <mosaik-marquee orientation="horizontal">
 *   <div>Scrolling text or images</div>
 * </mosaik-marquee>
 * ```
 *
 * @public
 */
let MarqueeElement = class MarqueeElement extends Themeable(Reversible(Orientable(Slottable(CustomElement)))) {
    // #region Fields
    _inlineStyleController;
    _speed;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._speed = '80000ms';
        this._inlineStyleController = new InlineStyleController(this);
        this._inlineStyleController.set('marquee-speed', '80000ms');
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-marquee';
    }
    /**
     * Gets or sets the `speed` property.
     *
     * @public
     * @attr
     */
    get speed() {
        return this._speed;
    }
    set speed(value) {
        if (this._speed !== value) {
            this._speed = value;
            this._inlineStyleController.set('marquee-speed', `${value}`);
            this.requestUpdate('speed');
        }
    }
    // #endregion
    // #region Methods
    /**
     * Called when the slot content changes.
     * Clones the slotted content into the duplicate group for seamless infinite scrolling.
     *
     * @param slotName - The name of the slot that changed.
     *
     * @public
     * @override
     */
    onSlotChanges(slotName) {
        super.onSlotChanges(slotName);
        this.duplicateContent();
    }
    /**
     * Duplicates the slotted content into the clone container
     * to achieve a seamless infinite marquee loop.
     *
     * @private
     */
    duplicateContent() {
        const clone = this.renderRoot.querySelector('.clone');
        if (!clone) {
            return;
        }
        const elements = this.getSlotAssignments('');
        clone.replaceChildren();
        for (const element of elements) {
            clone.appendChild(element.cloneNode(true));
        }
    }
};
__decorate([
    Attribute({
        type: String,
        converter: {
            toAttribute: (value) => typeof value === 'number' ? `${value}ms` : value?.toString() ?? ''
        }
    }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], MarqueeElement.prototype, "speed", null);
MarqueeElement = __decorate([
    Component({
        selector: 'mosaik-marquee',
        template: marqueeElementTemplate,
        themes: {
            joy: marqueeElementJoyStyle,
            memphis: marqueeElementMemphisStyle,
            cosmopolitan: marqueeElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], MarqueeElement);
export { MarqueeElement };
//# sourceMappingURL=MarqueeElement.js.map