"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Progress_exports = {};
__export(Progress_exports, {
  default: () => Progress_default
});
module.exports = __toCommonJS(Progress_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_prop_types = require("prop-types");
var import_yoga_system = require("@gympass/yoga-system");
var import_shared = require("../../shared");
const ProgressBar = import_styled_components.default.progress`
  width: 100%;

  border: none;

  ${({
  variant,
  theme: {
    yoga: {
      colors: { [variant]: color },
      components: { progress }
    }
  }
}) => `
  height: ${progress.height}px;

  &&,
  &::-webkit-progress-value,
  &[value]::-webkit-progress-bar,
  &:not(value)::-webkit-progress-bar {
    border-radius: ${progress.border.radius}px;
  }

  &:not(value)::-moz-progress-bar,
  &[value]::-moz-progress-bar {
    border-radius: ${progress.border.radius}px;
  }

  &:not(value)::-webkit-progress-bar {
    background-color: ${progress.backgroundColor.bar};
  }

  &::-webkit-progress-value {
    background-color: ${color};
  }

  &&,
  &:not(value)::-moz-progress-bar {
    background-color: ${progress.backgroundColor.bar};
  }

  &[value]::-moz-progress-bar {
    background-color: ${color};
  }
`}
`;
const Label = import_styled_components.default.label`
  ${({
  theme: {
    yoga: {
      components: { progress },
      colors: { text }
    }
  }
}) => `
  color: ${text.secondary};
  font-size: ${progress.label.font.size}px;
  letter-spacing: normal;
`}
`;
const Wrapper = import_styled_components.default.div`
  display: flex;

  width: 100%;

  ${({
  isNumber = false,
  align = "left",
  theme: {
    yoga: { spacing }
  }
}) => `
    ${isNumber ? `
        ${Label} {
          width: 22px;

          margin-${align === "right" ? "left" : "right"}: ${spacing.xxsmall}px;
        }

        ${ProgressBar} {
          margin: auto;
        }
    ` : `
        flex-direction: column;

        ${Label} {
          max-width: 280px;

          margin-top: ${spacing.xxsmall}px;
        }
      `}

      ${align === "right" ? "align-items: flex-end; text-align: right;" : "align-items: flex-start;"}
      ${isNumber && align === "left" ? "flex-direction: row-reverse;" : ""}
  `}

  ${import_yoga_system.backgroundColor}
  ${import_yoga_system.borders}
  ${import_yoga_system.elevation}
  ${import_yoga_system.positions}
  ${import_yoga_system.display}
  ${import_yoga_system.spacing}
`;
Wrapper.propTypes = {
  align: (0, import_prop_types.oneOf)(["left", "right"]),
  isNumber: import_prop_types.bool
};
const defaultLabel = {
  value: void 0,
  placement: "left"
};
const Progress = import_react.default.forwardRef(
  (_a, ref) => {
    var _b = _a, { label = defaultLabel, max = 1, value, variant = "verve" } = _b, props = __objRest(_b, ["label", "max", "value", "variant"]);
    const isNumber = !/[a-zA-Z]/g.test(label.value);
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Wrapper, __spreadProps(__spreadValues({ isNumber, align: label.placement, ref }, props), { children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProgressBar, { max, value, variant }),
      Object.keys(label).length > 0 && (isNumber || label.value) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { children: label.value })
    ] }));
  }
);
Progress.propTypes = {
  /** Use labels to increase users understanding. If the value is numeric, make
   * sure it has a maximum of 3 characters */
  label: (0, import_prop_types.shape)({
    value: (0, import_shared.charLength)(3, (0, import_prop_types.oneOfType)([import_prop_types.number, import_prop_types.string])),
    placement: (0, import_prop_types.oneOf)(["left", "right"])
  }),
  /** This attribute describes how much work the task indicated by the progress
   * element requires. The max attribute, if present, must have a value greater
   * than zero and be a valid floating point number. The default value is 1. */
  max: import_prop_types.number,
  /** This attribute specifies how much of the task that has been completed. It
   * must be a valid floating point number between 0 and max, or between 0 and 1
   * if max is omitted. If there is no value attribute, the progress bar is
   * indeterminate; this indicates that an activity is ongoing with no
   * indication of how long it is expected to take. */
  value: import_prop_types.number,
  /** style the card following the theme (primary, secondary, vibin, hope,
   * energy, relax, peace, verve, uplift, deepPurple, deep, stamina, dark,
   * medium, light, clear, white) */
  variant: (0, import_prop_types.oneOf)([
    "primary",
    "secondary",
    "vibin",
    "hope",
    "energy",
    "relax",
    "peace",
    "verve",
    "uplift",
    "deepPurple",
    "stamina",
    "dark",
    "medium",
    "deep",
    "light",
    "clear",
    "white"
  ])
};
var Progress_default = Progress;
