var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { cn } from "@utils";
import { progressContainerVariants, progressTrackVariants, progressBarVariants, progressTextVariants, progressValueTextVariants, progressCircularVariants, progressCircularTrackVariants, progressCircularProgressVariants, progressCircularTextVariants } from "./progressVariants";
export var EColors;
(function (EColors) {
    EColors["PRIMARY"] = "primary";
    EColors["SECONDARY"] = "secondary";
    EColors["SUCCESS"] = "success";
    EColors["WARNING"] = "warning";
    EColors["ERROR"] = "error";
})(EColors || (EColors = {}));
export var EValuePositions;
(function (EValuePositions) {
    EValuePositions["TOP"] = "top";
    EValuePositions["RIGHT"] = "right";
    EValuePositions["BOTTOM"] = "bottom";
    EValuePositions["INLINE"] = "inline";
})(EValuePositions || (EValuePositions = {}));
/**
 * Progress component for displaying progress bars in linear or circular variants.
 */
export const Progress = React.forwardRef((_a, ref) => {
    var { className, color = "primary", variant = "linear", size = "md", value = 0, valuePosition = "inline", showPercentage = false, striped = false, animate = false } = _a, props = __rest(_a, ["className", "color", "variant", "size", "value", "valuePosition", "showPercentage", "striped", "animate"]);
    const percentage = value >= 0 ? (value > 99 ? 100 : value) : 0;
    const percentageText = value < 10 ? `0${percentage}%` : `${percentage}%`;
    const CircularProgress = () => {
        // Clamp percentage between 0 and 100
        const validPercentage = Math.max(0, Math.min(value, 100));
        // Define size dimensions based on `size` prop
        const dimensions = {
            md: { size: 56, strokeWidth: 7 },
            lg: { size: 80, strokeWidth: 10 }
        };
        const { size: diameter, strokeWidth } = dimensions[size];
        const radius = (diameter - strokeWidth) / 2;
        const circumference = 2 * Math.PI * radius;
        const offset = circumference - (validPercentage / 100) * circumference;
        return (_jsxs("svg", { width: diameter, height: diameter, role: "progressbar", "aria-valuenow": validPercentage, "aria-valuemin": 0, "aria-valuemax": 100, "aria-live": "polite", tabIndex: 0, className: cn(progressCircularVariants({ size }), className), children: [_jsx("circle", { className: cn(progressCircularTrackVariants({ color })), cx: diameter / 2, cy: diameter / 2, r: radius, fill: "transparent", strokeWidth: strokeWidth }), _jsx("circle", { cx: diameter / 2, cy: diameter / 2, r: radius, fill: "transparent", strokeWidth: strokeWidth, strokeDasharray: circumference, strokeDashoffset: offset, strokeLinecap: "round", className: cn(progressCircularProgressVariants({ color })), style: { transition: "stroke-dashoffset 0.5s ease" } }), showPercentage && (_jsx("text", { className: cn(progressCircularTextVariants({ size })), x: "50%", y: "50%", textAnchor: "middle", dy: ".3em", children: `${validPercentage}%` }))] }));
    };
    return variant === "linear" ? (_jsxs("div", Object.assign({ className: cn(progressContainerVariants(), className), ref: ref }, props, { children: [_jsx("div", { className: cn(progressTrackVariants()), role: "progressbar", "aria-valuenow": value, "aria-valuemin": 0, "aria-valuemax": 100, "aria-live": "polite", tabIndex: 0, children: percentage > 0 && (_jsx("div", { style: { width: `${percentage}%` }, className: cn(progressBarVariants({
                        color,
                        striped,
                        animate
                    })), children: showPercentage && valuePosition !== EValuePositions.RIGHT && (_jsx("span", { className: cn(progressTextVariants({
                            position: valuePosition,
                            color
                        }), "text"), children: percentageText })) })) }), showPercentage && valuePosition === EValuePositions.RIGHT && (_jsx("span", { className: cn(progressValueTextVariants()), children: percentageText }))] }))) : variant === "circular" ? (_jsx(CircularProgress, {})) : null;
});
Progress.displayName = "Progress";
//# sourceMappingURL=progress.js.map