"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StyledRoot = exports.StyledPhoneInputRoot = exports.StyledFlagContainer = exports.StyledDialCode = exports.StyledCountrySelectDropdownNameColumn = exports.StyledCountrySelectDropdownListItemElement = exports.StyledCountrySelectDropdownListItem = exports.StyledCountrySelectDropdownFlagColumn = exports.StyledCountrySelectDropdownDialcodeColumn = exports.StyledCountrySelectDropdownContainer = exports.StyledCountrySelectContainer = void 0;

var React = _interopRequireWildcard(require("react"));

var _constants = require("./constants");

var _styles = require("../styles");

var _menu = require("../menu");

var _select = require("../select");

var _defaultProps = _interopRequireDefault(require("../select/default-props"));

var _excluded = ["item"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// The root element of the PhoneInputNext
var StyledPhoneInputRoot = (0, _styles.styled)('div', {
  display: 'flex'
});
exports.StyledPhoneInputRoot = StyledPhoneInputRoot;
StyledPhoneInputRoot.displayName = "StyledPhoneInputRoot";
var StyledFlagContainer = (0, _styles.styled)('span', function (_ref) {
  var _sizeToFont;

  var _ref$$size = _ref.$size,
      $size = _ref$$size === void 0 ? _constants.SIZE.default : _ref$$size,
      sizing = _ref.$theme.sizing;
  var sizeToFont = (_sizeToFont = {}, _defineProperty(_sizeToFont, _constants.SIZE.mini, sizing.scale700), _defineProperty(_sizeToFont, _constants.SIZE.compact, sizing.scale800), _defineProperty(_sizeToFont, _constants.SIZE.default, sizing.scale900), _defineProperty(_sizeToFont, _constants.SIZE.large, sizing.scale1000), _sizeToFont);
  return {
    fontSize: sizeToFont[$size]
  };
}); // An override component for the Select's Root styled element

exports.StyledFlagContainer = StyledFlagContainer;
StyledFlagContainer.displayName = "StyledFlagContainer";
var StyledRoot = (0, _styles.withStyle)(_select.StyledRoot, function (props) {
  var _sizeToWidth;

  // hard coded widths for the flag dropdown anchor
  var sizeToWidth = (_sizeToWidth = {}, _defineProperty(_sizeToWidth, _constants.SIZE.mini, '50px'), _defineProperty(_sizeToWidth, _constants.SIZE.compact, '60px'), _defineProperty(_sizeToWidth, _constants.SIZE.default, '70px'), _defineProperty(_sizeToWidth, _constants.SIZE.large, '80px'), _sizeToWidth);
  return {
    width: sizeToWidth[props.$size || _constants.SIZE.default],
    display: 'inline-block'
  };
});
exports.StyledRoot = StyledRoot;
StyledRoot.displayName = "StyledRoot";
var StyledDialCode = (0, _styles.styled)('div', function (_ref2) {
  var _ref3;

  var _ref2$$theme = _ref2.$theme,
      direction = _ref2$$theme.direction,
      sizing = _ref2$$theme.sizing;
  var marginDir = direction === 'rtl' ? 'marginRight' : 'marginLeft';
  return _ref3 = {}, _defineProperty(_ref3, marginDir, sizing.scale100), _defineProperty(_ref3, "display", 'flex'), _defineProperty(_ref3, "alignItems", 'center'), _ref3;
});
exports.StyledDialCode = StyledDialCode;
StyledDialCode.displayName = "StyledDialCode";
var StyledCountrySelectContainer = (0, _styles.styled)('div', {
  display: 'flex',
  alignItems: 'center'
});
exports.StyledCountrySelectContainer = StyledCountrySelectContainer;
StyledCountrySelectContainer.displayName = "StyledCountrySelectContainer";
var StyledCountrySelectDropdownContainer = (0, _styles.withStyle)(_menu.StyledList, function (props) {
  var _props$$height = props.$height,
      $height = _props$$height === void 0 ? _defaultProps.default.maxDropdownHeight : _props$$height;
  return {
    height: $height,
    paddingTop: 0,
    paddingBottom: 0
  };
});
exports.StyledCountrySelectDropdownContainer = StyledCountrySelectDropdownContainer;
StyledCountrySelectDropdownContainer.displayName = "StyledCountrySelectDropdownContainer";
var StyledCountrySelectDropdownListItemElement = (0, _styles.withStyle)(_select.StyledDropdownListItem, {
  paddingTop: 0,
  paddingBottom: 0,
  paddingLeft: 0,
  paddingRight: 0,
  display: 'flex',
  alignItems: 'center',
  height: '42px'
});
exports.StyledCountrySelectDropdownListItemElement = StyledCountrySelectDropdownListItemElement;
StyledCountrySelectDropdownListItemElement.displayName = "StyledCountrySelectDropdownListItemElement";
var StyledCountrySelectDropdownListItem = (0, _styles.withWrapper)(StyledCountrySelectDropdownListItemElement, function (Styled) {
  return function StyledCountrySelectDropdownListItem(_ref4) {
    var item = _ref4.item,
        restProps = _objectWithoutProperties(_ref4, _excluded);

    return /*#__PURE__*/React.createElement(Styled, restProps);
  };
});
exports.StyledCountrySelectDropdownListItem = StyledCountrySelectDropdownListItem;
var StyledCountrySelectDropdownFlagColumn = (0, _styles.styled)('div', function (_ref5) {
  var _ref6;

  var _ref5$$theme = _ref5.$theme,
      direction = _ref5$$theme.direction,
      sizing = _ref5$$theme.sizing;
  var paddingDir = direction === 'rtl' ? 'paddingRight' : 'paddingLeft';
  return _ref6 = {}, _defineProperty(_ref6, paddingDir, sizing.scale600), _defineProperty(_ref6, "display", 'flex'), _defineProperty(_ref6, "alignItems", 'center'), _ref6;
});
exports.StyledCountrySelectDropdownFlagColumn = StyledCountrySelectDropdownFlagColumn;
StyledCountrySelectDropdownFlagColumn.displayName = "StyledCountrySelectDropdownFlagColumn";
var StyledCountrySelectDropdownNameColumn = (0, _styles.styled)('div', function (_ref7) {
  var _ref7$$theme = _ref7.$theme,
      direction = _ref7$$theme.direction,
      sizing = _ref7$$theme.sizing;
  var paddingDir = direction === 'rtl' ? 'paddingRight' : 'paddingLeft';
  return _defineProperty({}, paddingDir, sizing.scale600);
});
exports.StyledCountrySelectDropdownNameColumn = StyledCountrySelectDropdownNameColumn;
StyledCountrySelectDropdownNameColumn.displayName = "StyledCountrySelectDropdownNameColumn";
var StyledCountrySelectDropdownDialcodeColumn = (0, _styles.styled)('div', function (_ref9) {
  var _ref10;

  var _ref9$$theme = _ref9.$theme,
      direction = _ref9$$theme.direction,
      sizing = _ref9$$theme.sizing;
  var paddingDir = direction === 'rtl' ? 'paddingLeft' : 'paddingRight';
  var marginDir = direction === 'rtl' ? 'marginRight' : 'marginLeft';
  return _ref10 = {}, _defineProperty(_ref10, paddingDir, sizing.scale600), _defineProperty(_ref10, marginDir, 'auto'), _ref10;
});
exports.StyledCountrySelectDropdownDialcodeColumn = StyledCountrySelectDropdownDialcodeColumn;
StyledCountrySelectDropdownDialcodeColumn.displayName = "StyledCountrySelectDropdownDialcodeColumn";