"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.placeholderNormalization = exports.StyledWrapper = exports.StyledTypography = exports.StyledSelect = exports.StyledInput = exports.StyledCountryCode = exports.StyledBox = void 0;
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _ = require("../../..");
var _Select = require("../Select");
var _NormalizedElements = _interopRequireDefault(require("../../../common/NormalizedElements"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var hasError = function hasError(error) {
  return error && error !== '';
};
var background = (0, _styledComponents.css)(["background-color:", ";"], function (p) {
  return p.disabled && p.$variant !== 'quiet' ? p.theme.color.disabledBackground : p.theme.color.inputBackground;
});
var hoverBorderStyles = (0, _styledComponents.css)(["", ""], function (p) {
  return p.$disabled ? '' : "\n      &:hover {\n        border-color: ".concat(p.theme.color.inputBorderHover, ";\n      }\n");
});
var borderStyles = (0, _styledComponents.css)(["border:solid;border-color:", ";border-width:", ";&:focus{border-width:1px;}position:relative;", ""], function (p) {
  if (hasError(p.$error)) return p.theme.color.inputBorderError;
  if (p.$success) return p.theme.color.inputBorderSuccess;
  return p.theme.color.inputBorder;
}, function (p) {
  return p.$variant === 'quiet' ? '0 0 2px 0' : '1px';
}, function (p) {
  return p.$disabled && p.$variant === 'quiet' ? "border-color: ".concat(p.theme.color.disabledBackground, ";") : '';
});
var placeholderNormalization = exports.placeholderNormalization = (0, _styledComponents.css)(["&::placeholder{color:", ";line-height:inherit;opacity:1;}", ";&:disabled::placeholder{color:", ";}"], function (p) {
  return p.$variant === 'quiet' ? p.theme.color.cta : p.theme.color.label;
}, function (p) {
  return p.$variant === 'quiet' ? "&:focus::placeholder { color: ".concat(p.theme.color.disabledText, "}") : '';
}, function (p) {
  return p.theme.color.disabledText;
});
var StyledSelect = exports.StyledSelect = _Select.Select ? (0, _styledComponents.default)(_Select.Select).withConfig({
  displayName: "Phonestyled__StyledSelect",
  componentId: "sc-1o1oim0-0"
})(["max-width:50px;& *{border:none;}"]) : _Select.Select;
var StyledCountryCode = exports.StyledCountryCode = (0, _styledComponents.default)(_.Flexbox).withConfig({
  displayName: "Phonestyled__StyledCountryCode",
  componentId: "sc-1o1oim0-1"
})(["cursor:", ";background-color:", ";"], function (_ref) {
  var disabled = _ref.disabled;
  return disabled ? 'not-allowed' : 'auto';
}, function (_ref2) {
  var theme = _ref2.theme,
    disabled = _ref2.disabled;
  return disabled ? theme.color.disabledBackground : theme.color.card;
});
var StyledInput = exports.StyledInput = (0, _styledComponents.default)(_NormalizedElements.default.Input).withConfig({
  displayName: "Phonestyled__StyledInput",
  componentId: "sc-1o1oim0-2"
})(["border:0;outline:none;color:", ";width:100%;height:100%;padding:0 ", "px;margin:0;box-sizing:border-box;line-height:inherit;", " ", " ", " ", " ", ""], function (_ref3) {
  var theme = _ref3.theme;
  return theme.color.text;
}, function (p) {
  return p.theme.spacing.unit(p.$variant === 'quiet' ? 0 : 2);
}, background, placeholderNormalization, function (p) {
  return p.$variant === 'quiet' ? "color: ".concat(p.theme.color.cta, "; \n         &:disabled {\n           color: ").concat(p.theme.color.disabledText, ";\n         }\n         font-size: 28px; \n         font-weight: bold;\n         &:focus {\n           padding-left: ").concat(p.theme.spacing.unit(2), "px;\n           padding-right: ").concat(p.theme.spacing.unit(0), "px;\n         }") : '';
}, function (p) {
  return p.type === 'search' && " \n    &[type=\"search\"] {\n      -webkit-appearance: textfield;\n    }\n    ";
}, function (p) {
  return p.disabled && "\n      cursor: not-allowed;\n      ";
});
var StyledWrapper = exports.StyledWrapper = (0, _styledComponents.default)(_.Flexbox).withConfig({
  displayName: "Phonestyled__StyledWrapper",
  componentId: "sc-1o1oim0-3"
})(["position:relative;height:", "px;padding:", "px 0;background:", ";border-radius:", ";", " ", " ", ""], function (p) {
  return p.$size === 's' ? p.theme.spacing.unit(8) : p.theme.spacing.unit(10);
}, function (p) {
  return p.theme.spacing.unit(p.$variant === 'quiet' ? 1 : 0);
}, function (p) {
  return p.$disabled ? p.theme.color.disabledBackground : p.theme.color.card;
}, function (p) {
  return p.theme.borderRadius4;
}, borderStyles, hoverBorderStyles, function (_ref4) {
  var $focused = _ref4.$focused,
    theme = _ref4.theme;
  return $focused ? "border-color: ".concat(theme.color.borderActive, ";") : '';
});
var StyledBox = exports.StyledBox = (0, _styledComponents.default)(_.Box).withConfig({
  displayName: "Phonestyled__StyledBox",
  componentId: "sc-1o1oim0-4"
})(["cursor:pointer;background:", ";", ""], function (p) {
  return p.focused ? p.theme.color.background : p.theme.color.card;
}, function (p) {
  return !p.isKeyboardNavigation ? "\n&: hover {\n  background: ".concat(p.theme.color.background, ";\n  }\n") : '';
});
var StyledTypography = exports.StyledTypography = (0, _styledComponents.default)(_.Typography).withConfig({
  displayName: "Phonestyled__StyledTypography",
  componentId: "sc-1o1oim0-5"
})(["width:inherit;"]);