import { jsx } from "react/jsx-runtime";
import { colorToString } from "../../../../../../utils/colorToString";
import { useFormContext, Sizes, Contrasts } from "../../../../context/FormContext";
import { cx } from "@emotion/css";
import { useStyle } from "../../../../../../../runtimes/react/use-style";
import {
  useResponsiveStyle,
  useResponsiveTextStyle
} from "../../../../../../utils/responsive-style";
function getSizeHeight(size) {
  switch (size) {
    case Sizes.SMALL:
      return 14;
    case Sizes.MEDIUM:
      return 18;
    case Sizes.LARGE:
      return 22;
    default:
      throw new Error(`Invalid form size "${size}"`);
  }
}
function getContrastColor(contrast) {
  switch (contrast) {
    case Contrasts.LIGHT:
      return "rgba(0, 0, 0, 0.8)";
    case Contrasts.DARK:
      return "rgba(255, 255, 255, 0.95)";
    default:
      throw new Error(`Invalid form contrast "${contrast}"`);
  }
}
function Label({
  as,
  className,
  ...restOfProps
}) {
  const Component = as ?? "label";
  const { contrast, size, labelTextStyle, labelTextColor } = useFormContext();
  return /* @__PURE__ */ jsx(
    Component,
    {
      ...restOfProps,
      className: cx(
        useStyle({ display: "block", margin: "0 0 0.25em 0" }),
        useStyle(useResponsiveTextStyle(labelTextStyle)),
        useStyle(
          useResponsiveStyle(
            [size, contrast, labelTextColor],
            ([size2 = Sizes.MEDIUM, contrast2 = Contrasts.LIGHT, textColor]) => ({
              minHeight: getSizeHeight(size2),
              color: textColor == null ? getContrastColor(contrast2) : colorToString(textColor)
            })
          )
        ),
        className
      )
    }
  );
}
export {
  Label as default,
  getSizeHeight
};
//# sourceMappingURL=index.js.map