import { jsxs, jsx } from 'react/jsx-runtime';
import { forwardRef, useId, isValidElement } from 'react';
import { c as cx } from './index-De1g9FRV.js';
import { S as SvgCheckCircle } from './check_circle-CM0ukqXv.js';
import { S as SvgError } from './error-DR_wWdYY.js';
import { F as FieldLabel } from './FieldLabel-1g9Y_K44.js';
import { F as Flex } from './Flex-WyyZm1bf.js';
import { w as warnDeprecatedErrorUsage } from './utils-CM48ODEJ.js';
import { I as Icon } from './Icon-DuIlne4x.js';
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-DMDdfIah.js';
import { H as Helper } from './Helper-B_FIOlhy.js';

import './ProgressBar.css';const bar = "_bar_1lj98_23";
const indeterminate = "_indeterminate_1lj98_1";
const success = "_success_1lj98_66";
const error = "_error_1lj98_52";
const styles = {
	"progress-bar": "_progress-bar_1lj98_2",
	"bar-container": "_bar-container_1lj98_23",
	bar: bar,
	"check-icon": "_check-icon_1lj98_49",
	"error-icon": "_error-icon_1lj98_52",
	indeterminate: indeterminate,
	success: success,
	error: error
};

const ProgressBar = forwardRef(
  (props, ref) => {
    const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
    const {
      className,
      style,
      value,
      children,
      indeterminate,
      errorAriaLive,
      description,
      warning,
      error = false,
      max = 100,
      ...mainProps
    } = componentProps;
    const styleCombined = {
      ...style,
      ...layoutStyles
    };
    warnDeprecatedErrorUsage("ProgressBar", error);
    const errorMessages = typeof error === "boolean" || error === void 0 ? void 0 : error;
    const labelUid = useId();
    const isSuccess = typeof value !== "undefined" && +value >= +max;
    if ("label" in props && !!props.label) {
      const { label, labelProps, ...rest } = mainProps;
      const ProgressBarClassNames2 = cx(
        [styles["progress-bar"]],
        className,
        {
          [styles[`error`]]: error,
          [styles[`success`]]: isSuccess
        }
      );
      return /* @__PURE__ */ jsxs(
        "div",
        {
          className: ProgressBarClassNames2,
          "data-anv": "progress-bar",
          style: styleCombined,
          ref,
          children: [
            /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
              /* @__PURE__ */ jsx(FieldLabel, { id: labelUid, ...labelProps, children: label }),
              isSuccess && !error ? /* @__PURE__ */ jsx(Icon, { className: styles["check-icon"], svg: SvgCheckCircle }) : null,
              error ? /* @__PURE__ */ jsx(Icon, { className: styles["error-icon"], svg: SvgError }) : null
            ] }),
            /* @__PURE__ */ jsx("div", { className: styles["bar-container"], children: /* @__PURE__ */ jsx(
              "progress",
              {
                "aria-labelledby": labelUid,
                className: styles["bar"],
                value,
                max,
                ...rest
              }
            ) }),
            errorMessages || warning || description ? /* @__PURE__ */ jsx(
              Helper,
              {
                error: typeof errorMessages === "string" || Array.isArray(errorMessages) ? errorMessages : void 0,
                warning,
                errorMessage: isValidElement(errorMessages) ? errorMessages : void 0,
                description
              }
            ) : null
          ]
        }
      );
    }
    const ProgressBarClassNames = cx([styles["progress-bar"]], className, {
      [styles[`error`]]: error,
      [styles[`success`]]: isSuccess
    });
    return /* @__PURE__ */ jsxs(
      "div",
      {
        className: ProgressBarClassNames,
        "data-anv": "progress-bar",
        style: styleCombined,
        ref,
        children: [
          /* @__PURE__ */ jsx("div", { className: styles["bar-container"], children: /* @__PURE__ */ jsx(
            "progress",
            {
              className: styles["bar"],
              max,
              value,
              ...mainProps
            }
          ) }),
          errorMessages || warning || description ? /* @__PURE__ */ jsx(
            Helper,
            {
              error: typeof errorMessages === "string" || Array.isArray(errorMessages) ? errorMessages : void 0,
              warning,
              errorMessage: isValidElement(errorMessages) ? errorMessages : void 0,
              description
            }
          ) : null
        ]
      }
    );
  }
);
ProgressBar.displayName = "ProgressBar";

export { ProgressBar as P };
//# sourceMappingURL=ProgressBar-Cygv2ii1.js.map
