/*
Copyright 2021 Q-CTRL. All rights reserved.

Licensed under the Q-CTRL Terms of service (the "License"). Unauthorized
copying or use of this file, via any medium, is strictly prohibited.
Proprietary and confidential. You may not use this file except in compliance
with the License. You may obtain a copy of the License at

     https://q-ctrl.com/terms

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS. See the
License for the specific language.
*/
var _require = require("../../utilities/convertColors"),
    flattenColorPalette = _require.flattenColorPalette,
    getRGB = _require.getRGB; // Components


module.exports = function (_ref) {
  var addComponents = _ref.addComponents,
      theme = _ref.theme;
  var colors = flattenColorPalette(theme("colors"));
  var colorPrimary = colors.primary;
  var colorDanger = colors.danger;
  var inputBase = {
    ".input": {
      boxShadow: theme("boxShadow.inner-sm"),
      borderRadius: theme("borderRadius.sm"),
      backgroundColor: theme("colors.white"),
      width: theme("width.full"),
      padding: theme("borderSquash.md"),
      letterSpacing: theme("letterSpacing.loose"),
      color: theme("colors.gray.700"),
      outline: theme("boxShadow.none"),
      borderWidth: theme("borderWidth.DEFAULT"),
      borderColor: theme("colors.gray.200"),
      transition: "".concat(theme("transitionDuration.200"), " ease-in-out"),
      tansitionProperties: theme("transitionProperty.colors"),
      "&.input-danger": {
        borderColor: colorDanger
      },
      "&:hover": {
        borderColor: theme("colors.gray.400")
      },
      "&:focus": {
        "--tw-ring-opacity": "0.35",
        "--tw-ring-color": "rgba(".concat(getRGB(theme("colors.violet.300")), ", var(--tw-ring-opacity))"),
        "--tw-ring-offset-width": "0px",
        "--tw-ring-offset-shadow": "var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)",
        "--tw-ring-shadow": "var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)",
        "box-shadow": "var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000)",
        borderColor: theme("colors.primary.DEFAULT")
      },
      "&::placeholder": {
        color: theme("colors.gray.400"),
        letterSpacing: theme("letterSpacing.loose")
      },
      "&[type='number']": {
        "-moz-appearance": "textfield",
        "&::-webkit-inner-spin-button, &::-webkit-outer-spin-button": {
          "-webkit-appearance": "none",
          margin: 0
        }
      },
      "&:disabled": {
        backgroundColor: theme("colors.gray.0"),
        borderColor: theme("colors.gray.DEFAULT"),
        color: theme("colors.gray.300"),
        boxShadow: theme("boxShadow.none"),
        "&::placeholder": {
          color: theme("colors.gray.300")
        }
      }
    }
  };
  var paddingXs = theme("borderSquash.xs");
  var paddingSm = theme("borderSquash.sm");
  var paddingMd = theme("borderSquash.md");
  var paddingLg = theme("borderSquash.lg");
  var paddingXl = theme("borderSquash.xl");
  var inputSizes = {
    ".input-xs": {
      padding: paddingXs,
      fontSize: theme("fontSize.2xs"),
      lineHeight: theme("lineHeight.4"),
      borderRadius: theme("borderRadius.xs"),
      "&::placeholder": {
        lineHeight: theme("lineHeight.4"),
        fontSize: theme("fontSize.2xs")
      }
    },
    ".input-sm": {
      padding: paddingSm,
      fontSize: theme("fontSize.xs"),
      lineHeight: theme("lineHeight.5"),
      borderRadius: theme("borderRadius.xs"),
      "&::placeholder": {
        fontSize: theme("fontSize.xs"),
        lineHeight: theme("lineHeight.5")
      }
    },
    ".input-md": {
      padding: paddingMd,
      fontSize: theme("fontSize.base"),
      lineHeight: theme("lineHeight.6"),
      borderRadius: theme("borderRadius.sm"),
      "&::placeholder": {
        fontSize: theme("fontSize.base"),
        lineHeight: theme("lineHeight.6")
      }
    },
    ".input-lg": {
      padding: paddingLg,
      fontSize: theme("fontSize.base"),
      lineHeight: theme("lineHeight.6"),
      borderRadius: theme("borderRadius.DEFAULT"),
      "&::placeholder": {
        fontSize: theme("fontSize.base"),
        lineHeight: theme("lineHeight.6")
      }
    },
    ".input-xl": {
      padding: paddingXl,
      fontSize: theme("fontSize.lg"),
      lineHeight: theme("lineHeight.8"),
      borderRadius: theme("borderRadius.md"),
      "&::placeholder": {
        fontSize: theme("fontSize.lg"),
        lineHeight: theme("lineHeight.8")
      }
    }
  };
  addComponents([inputBase, inputSizes], {
    variants: ["responsive"]
  });
};