// #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 '../../../Behaviors/Disableable';
import { Labelable } from '../../../Behaviors/Labelable';
import { Orientable } from '../../../Behaviors/Orientable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { MeterRange } from '../../../Types/MeterRange';
import { MeterScale } from '../../../Types/MeterScale';
import { TextElement } from '../../Primitives/Text/TextElement';
import { RangeBaseElement } from '../Abstracts/RangeBaseElement';
import { meterBarElementTemplate } from './MeterBarElementTemplate';
import { meterBarElementJoyStyle } from './Themes/MeterBarElement.Joy';
import { meterBarElementMemphisStyle } from './Themes/MeterBarElement.Memphis';
import { meterBarElementCosmopolitanStyle } from './Themes/MeterBarElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
/**
 * MeterBar - A horizontal or vertical gauge for displaying numeric measurements within defined ranges.
 *
 * @description
 * The MeterBar component provides visual representation of measurements with contextual coloring
 * based on optimum, low, and high thresholds. Supports both continuous and segmented display modes,
 * making it ideal for showing performance metrics, resource usage, battery levels, and other
 * quantitative data where visual ranges matter. Features smooth transitions, accessibility support,
 * and flexible styling options for diverse use cases.
 *
 * @name MeterBar
 * @element mosaik-meter-bar
 * @category Ranges
 *
 * @slot hint - Secondary text content area for additional meter information or status
 * @slot label - Text label content area for meter description or value display
 *
 * @csspart bar - Main meter bar container element
 * @csspart fill - Filled portion of the meter indicating current value in continuous mode
 * @csspart hint - Hint text styling container for additional information
 * @csspart label - Text label styling container for meter information
 * @csspart marker - Position indicator showing current value in segmented mode
 * @csspart segment - Individual segment element representing a specific range (low/optimum/high)
 * @csspart segments - Container for individual range segments in segmented mode
 *
 * @cssprop {String} --meter-bar-fill-color-high - Fill color for high range values (above high threshold)
 * @cssprop {String} --meter-bar-fill-color-low - Fill color for low range values (below low threshold)
 * @cssprop {String} --meter-bar-fill-color-optimum - Fill color for optimum range values (between low and high)
 * @cssprop {String} --meter-bar-font-family - The bar font family CSS custom property.
 * @cssprop {String} --meter-bar-font-letter-spacing - The bar font letter spacing CSS custom property.
 * @cssprop {String} --meter-bar-font-line-height - The bar font line height CSS custom property.
 * @cssprop {String} --meter-bar-font-size - The bar font size CSS custom property.
 * @cssprop {String} --meter-bar-font-text-decoration - The bar font text decoration CSS custom property.
 * @cssprop {String} --meter-bar-font-text-transform - The bar font text transform CSS custom property.
 * @cssprop {String} --meter-bar-font-weight - The bar font weight CSS custom property.
 * @cssprop {String} --meter-bar-gap - The bar gap CSS custom property.
 * @cssprop {String} --meter-bar-marker-color - Color of the marker indicator in segmented mode
 * @cssprop {String} --meter-bar-padding-bottom - The bar padding bottom CSS custom property.
 * @cssprop {String} --meter-bar-padding-left - The bar padding left CSS custom property.
 * @cssprop {String} --meter-bar-padding-right - The bar padding right CSS custom property.
 * @cssprop {String} --meter-bar-padding-top - The bar padding top CSS custom property.
 * @cssprop {String} --meter-bar-shadow - The bar shadow CSS custom property.
 * @cssprop {String} --meter-bar-shadow-blur - The bar shadow blur CSS custom property.
 * @cssprop {String} --meter-bar-shadow-color - The bar shadow color CSS custom property.
 * @cssprop {String} --meter-bar-shadow-offset-x - The bar shadow offset x CSS custom property.
 * @cssprop {String} --meter-bar-shadow-offset-y - The bar shadow offset y CSS custom property.
 * @cssprop {String} --meter-bar-shadow-spread - The bar shadow spread CSS custom property.
 * @cssprop {String} --meter-bar-transition-duration - The bar transition duration CSS custom property.
 * @cssprop {String} --meter-bar-transition-mode - The bar transition mode CSS custom property.
 * @cssprop {String} --meter-bar-transition-property - The bar transition property CSS custom property.
 * @cssprop {String} --meter-bar-translate - The bar translate CSS custom property.
 *
 * @fires rangeValueChanged {RangeValueChangedEvent} - Fired when the meter value changes
 *
 * @dependency mosaik-text - The Text element.
 *
 * @example
 * Basic meter with continuous scale:
 * ```html
 * <mosaik-meter-bar
 *   min="0"
 *   max="100"
 *   value="65"
 *   low="30"
 *   high="80"
 *   optimum="50">
 *   <span slot="label">CPU Usage</span>
 * </mosaik-meter-bar>
 * ```
 *
 * @example
 * Meter with segmented scale showing battery level:
 * ```html
 * <mosaik-meter-bar
 *   min="0"
 *   max="100"
 *   value="25"
 *   low="20"
 *   high="80"
 *   optimum="50"
 *   scale="segmented"
 *   variant="warning">
 *   <span slot="label">Battery Level</span>
 * </mosaik-meter-bar>
 * ```
 *
 * @example
 * Vertical meter for temperature monitoring:
 * ```html
 * <mosaik-meter-bar
 *   min="0"
 *   max="100"
 *   value="85"
 *   low="20"
 *   high="75"
 *   optimum="50"
 *   orientation="vertical"
 *   thickness="8">
 *   <span slot="label">Temperature (°C)</span>
 * </mosaik-meter-bar>
 * ```
 *
 * @example
 * Disk space usage meter:
 * ```html
 * <mosaik-meter-bar
 *   min="0"
 *   max="500"
 *   value="420"
 *   low="100"
 *   high="450"
 *   optimum="250"
 *   variant="error">
 *   <span slot="label">Disk Space (GB)</span>
 *   <span slot="hint">420 GB used of 500 GB</span>
 * </mosaik-meter-bar>
 * ```
 *
 * @public
 */
let MeterBarElement = class MeterBarElement extends Themeable(Variantable(Orientable(Disableable(Labelable(RangeBaseElement))))) {
    // #region Fields
    _thickness;
    _high;
    _low;
    _optimum;
    _range;
    _scale;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._thickness = 4;
        this._high = 0;
        this._low = 0;
        this._optimum = 0;
        this._range = MeterRange.Normal;
        this._scale = MeterScale.Continuous;
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-meter-bar';
    }
    /**
     * Gets or sets the thickness property.
     *
     * @public
     * @attr
     */
    get thickness() {
        return this._thickness;
    }
    set thickness(value) {
        if (this._thickness !== value) {
            this._thickness = value;
            this.requestUpdate('thickness');
        }
    }
    /**
     * Gets or sets the `high` property.
     *
     * @public
     * @attr
     */
    get high() {
        return this._high;
    }
    set high(value) {
        if (this._high !== value) {
            this._high = value;
            this.requestUpdate('high');
        }
    }
    /**
     * Gets or sets the `low` property.
     *
     * @public
     * @attr
     */
    get low() {
        return this._low;
    }
    set low(value) {
        if (this._low !== value) {
            this._low = value;
            this.requestUpdate('low');
        }
    }
    /**
     * Gets or sets the `optimum` property.
     *
     * @public
     * @attr
     */
    get optimum() {
        return this._optimum;
    }
    set optimum(value) {
        if (this._optimum !== value) {
            this._optimum = value;
            this.requestUpdate('optimum');
        }
    }
    /**
     * Gets or sets the `range` property.
     *
     * @public
     * @readonly
     * @attr
     */
    get range() {
        return this._range;
    }
    set range(value) {
        if (this._range !== value) {
            this._range = value;
            this.requestUpdate('range');
        }
    }
    /**
     * Gets or sets the `scale` property.
     * Determines how the meter scale is visually represented.
     * - `continuous`: Single continuous bar with color based on current range (default).
     * - `segmented`: Visible segments for low, optimum, and high zones with a marker for the current value.
     *
     * @public
     * @attr
     */
    get scale() {
        return this._scale;
    }
    set scale(value) {
        if (this._scale !== value) {
            this._scale = value;
            this.requestUpdate('scale');
        }
    }
    /**
     * Gets the percentage of the current value within the range (0-100).
     *
     * @public
     * @readonly
     */
    get percent() {
        if (this.max <= this.min) {
            return 0;
        }
        return ((this.value - this.min) / (this.max - this.min)) * 100;
    }
    /**
     * Gets the segments for the segmented scale mode.
     * Returns an array of segments representing low, optimum, and high zones.
     *
     * @public
     * @readonly
     */
    get segments() {
        const totalRange = this.max - this.min;
        if (totalRange <= 0) {
            return [];
        }
        const segments = [];
        // Low segment: min to low
        const lowWidth = ((this.low - this.min) / totalRange) * 100;
        if (lowWidth > 0) {
            segments.push({
                range: MeterRange.Low,
                width: lowWidth
            });
        }
        // Optimum segment: low to high
        const optimumWidth = ((this.high - this.low) / totalRange) * 100;
        if (optimumWidth > 0) {
            segments.push({
                range: MeterRange.Optimum,
                width: optimumWidth
            });
        }
        // High segment: high to max
        const highWidth = ((this.max - this.high) / totalRange) * 100;
        if (highWidth > 0) {
            segments.push({
                range: MeterRange.High,
                width: highWidth
            });
        }
        return segments;
    }
    // #endregion
    // #region Methods
    onPropertyChanged() {
        let range = MeterRange.Normal;
        if (this.value < this.low) {
            range = MeterRange.Low;
        }
        else if (this.value >= this.high) {
            range = MeterRange.High;
        }
        else if (this.value >= this.optimum) {
            range = MeterRange.Optimum;
        }
        this.range = range;
    }
};
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterBarElement.prototype, "thickness", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterBarElement.prototype, "high", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterBarElement.prototype, "low", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], MeterBarElement.prototype, "optimum", null);
__decorate([
    Attribute({ type: MeterRange }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], MeterBarElement.prototype, "range", null);
__decorate([
    Attribute({ type: MeterScale }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], MeterBarElement.prototype, "scale", null);
__decorate([
    Watch('value'),
    Watch('min'),
    Watch('max'),
    Watch('low'),
    Watch('high'),
    Watch('optimum'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], MeterBarElement.prototype, "onPropertyChanged", null);
MeterBarElement = __decorate([
    Component({
        selector: 'mosaik-meter-bar',
        template: meterBarElementTemplate,
        themes: {
            joy: meterBarElementJoyStyle,
            memphis: meterBarElementMemphisStyle,
            cosmopolitan: meterBarElementCosmopolitanStyle
        },
        host: {
            role: 'meter'
        },
        imports: [
            TextElement
        ]
    }),
    __metadata("design:paramtypes", [])
], MeterBarElement);
export { MeterBarElement };
//# sourceMappingURL=MeterBarElement.js.map