import _extends from "@babel/runtime/helpers/esm/extends";
import React, { forwardRef } from "react";
import { formatHours, formatNumber } from "../../utils";
import { Tooltip } from "../Tooltip";
import { Typography } from "../Typography/Typography";
export const DisplayHours = /*#__PURE__*/forwardRef((_ref, ref) => {
  let {
    value,
    variant = "Body 2",
    thousandSeparator = ",",
    decimalSeparator = ".",
    trimZeroMinutes = false,
    trimDecimals = true,
    decimalSpaces = 2,
    format = "long",
    disableTooltip = false,
    className,
    withLeadingZero,
    as = "span",
    ...rest
  } = _ref;
  const numberValue = +String(value).replaceAll(thousandSeparator, "").replace(decimalSeparator, ".");
  const formattedValue = formatNumber(numberValue, thousandSeparator, decimalSeparator, trimDecimals, decimalSpaces, "short");
  const formattedLongValue = formatHours(numberValue, withLeadingZero, trimZeroMinutes);
  const showShortVersion = numberValue > 1000;
  if (format === "short" && showShortVersion) {
    return /*#__PURE__*/React.createElement(Tooltip, {
      title: formattedLongValue,
      disable: disableTooltip
    }, /*#__PURE__*/React.createElement(Typography, _extends({
      as: as,
      variant: variant,
      className: className,
      ref: ref
    }, rest), formattedValue));
  }
  return /*#__PURE__*/React.createElement(Typography, _extends({
    as: as,
    variant: variant,
    className: className,
    ref: ref
  }, rest), formattedLongValue);
});
DisplayHours.displayName = "DisplayHours";
//# sourceMappingURL=DisplayHours.js.map