"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var responsiveField_exports = {};
__export(responsiveField_exports, {
  default: () => responsiveField,
  getContrastBackgroundColor: () => getContrastBackgroundColor,
  getContrastBorderColor: () => getContrastBorderColor,
  getContrastColor: () => getContrastColor,
  getShapeBorderRadius: () => getShapeBorderRadius,
  getSizeHeight: () => getSizeHeight,
  getSizeHorizontalPadding: () => getSizeHorizontalPadding
});
module.exports = __toCommonJS(responsiveField_exports);
var import_colorToString = require("../../../../../utils/colorToString");
var import_FormContext = require("../../../context/FormContext");
var import_responsive_style = require("../../../../../utils/responsive-style");
function getSizeHeight(size) {
  switch (size) {
    case import_FormContext.Sizes.SMALL:
      return 30;
    case import_FormContext.Sizes.MEDIUM:
      return 38;
    case import_FormContext.Sizes.LARGE:
      return 48;
    default:
      throw new Error(`Invalid form size "${size}"`);
  }
}
function getSizeHorizontalPadding(size) {
  switch (size) {
    case import_FormContext.Sizes.SMALL:
      return 8;
    case import_FormContext.Sizes.MEDIUM:
      return 12;
    case import_FormContext.Sizes.LARGE:
      return 16;
    default:
      throw new Error(`Invalid form size "${size}"`);
  }
}
function getSizeVerticalPadding(size) {
  switch (size) {
    case import_FormContext.Sizes.SMALL:
      return 3;
    case import_FormContext.Sizes.MEDIUM:
      return 7;
    case import_FormContext.Sizes.LARGE:
      return 11;
    default:
      throw new Error(`Invalid form size "${size}"`);
  }
}
function getShapeBorderRadius(shape) {
  switch (shape) {
    case import_FormContext.Shapes.SQUARE:
      return 0;
    case import_FormContext.Shapes.ROUNDED:
      return 4;
    case import_FormContext.Shapes.PILL:
      return 500;
    default:
      throw new Error(`Invalid form shape "${shape}"`);
  }
}
function getContrastBorderColor(contrast, error) {
  switch (contrast) {
    case import_FormContext.Contrasts.LIGHT:
      return error ? "rgba(255, 0, 0, 0.7)" : "rgba(0, 0, 0, 0.25)";
    case import_FormContext.Contrasts.DARK:
      return error ? "rgba(255, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.6)";
    default:
      throw new Error(`Invalid form contrast "${contrast}"`);
  }
}
function getContrastBackgroundColor(contrast) {
  switch (contrast) {
    case import_FormContext.Contrasts.LIGHT:
      return "white";
    case import_FormContext.Contrasts.DARK:
      return "rgba(0, 0, 0, 0.7)";
    default:
      throw new Error(`Invalid form contrast "${contrast}"`);
  }
}
function getContrastColor(contrast) {
  switch (contrast) {
    case import_FormContext.Contrasts.LIGHT:
      return "rgba(0, 0, 0, 0.95)";
    case import_FormContext.Contrasts.DARK:
      return "white";
    default:
      throw new Error(`Invalid form contrast "${contrast}"`);
  }
}
function getContrastPlaceholderColor(contrast) {
  switch (contrast) {
    case import_FormContext.Contrasts.LIGHT:
      return "rgba(0, 0, 0, 0.3)";
    case import_FormContext.Contrasts.DARK:
      return "rgba(255,255,255,0.3)";
    default:
      throw new Error(`Invalid form contrast "${contrast}"`);
  }
}
function responsiveField(props) {
  return {
    display: "block",
    width: "100%",
    outline: "none",
    borderWidth: 1,
    borderStyle: "solid",
    transition: "border-color 200ms",
    ...(0, import_responsive_style.useResponsiveStyle)(
      [props.shape, props.size, props.contrast, props.brandColor],
      ([
        shape = import_FormContext.Shapes.ROUNDED,
        size = import_FormContext.Sizes.MEDIUM,
        contrast = import_FormContext.Contrasts.LIGHT,
        brandColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 }
      ]) => ({
        padding: `${getSizeVerticalPadding(size)}px ${getSizeHorizontalPadding(size)}px`,
        borderRadius: getShapeBorderRadius(shape),
        borderColor: getContrastBorderColor(contrast, props.error),
        color: getContrastColor(contrast),
        backgroundColor: getContrastBackgroundColor(contrast),
        ":focus, :focus-within": {
          borderColor: (0, import_colorToString.colorToString)(brandColor)
        },
        "::placeholder": {
          color: getContrastPlaceholderColor(contrast)
        }
      })
    )
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getContrastBackgroundColor,
  getContrastBorderColor,
  getContrastColor,
  getShapeBorderRadius,
  getSizeHeight,
  getSizeHorizontalPadding
});
//# sourceMappingURL=responsiveField.js.map