"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModalFooter = exports.ModalBody = exports.ModalHeader = exports.Close = exports.Dialog = exports.DialogContainer = exports.Backdrop = exports.Root = void 0;

var _index = require("../styles/index.js");

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

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(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; }

function getSizeStyles($size) {
  var styles = {
    maxWidth: '100%',
    width: null
  };

  if (typeof $size === 'number') {
    styles.width = "".concat($size, "px");
  } else if (_constants.SIZE.hasOwnProperty($size)) {
    styles.width = _constants.SIZE_WIDTHS[$size];
  } else if (typeof $size === 'string') {
    styles.width = $size;
  }

  if ($size === _constants.SIZE.full) {
    styles.alignSelf = 'stretch';
  }

  return styles;
}

var Root = (0, _index.styled)('div', function (props) {
  var $isOpen = props.$isOpen;
  return {
    position: 'fixed',
    overflow: 'auto',
    right: 0,
    bottom: 0,
    top: 0,
    left: 0,
    pointerEvents: $isOpen ? 'auto' : 'none'
  };
});
exports.Root = Root;
Root.displayName = "Root";
var Backdrop = (0, _index.styled)('div', function (props) {
  var $animate = props.$animate,
      $isOpen = props.$isOpen,
      $isVisible = props.$isVisible,
      $theme = props.$theme;
  return _objectSpread({
    position: 'fixed',
    right: 0,
    bottom: 0,
    top: 0,
    left: 0,
    backgroundColor: 'rgba(0, 0, 0, 0.5)',
    // Remove grey highlight
    WebkitTapHighlightColor: 'transparent',
    // Disable scroll capabilities.
    touchAction: 'none',
    opacity: $isVisible && $isOpen ? 1 : 0
  }, $animate ? {
    transitionProperty: 'opacity',
    transitionDuration: $theme.animation.timing400,
    transitionTimingFunction: $theme.animation.easeOutCurve
  } : null);
});
exports.Backdrop = Backdrop;
Backdrop.displayName = "Backdrop";
var DialogContainer = (0, _index.styled)('div', function (props) {
  return {
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
    width: '100%',
    minHeight: '100%',
    pointerEvents: 'none',
    userSelect: 'none'
  };
});
exports.DialogContainer = DialogContainer;
DialogContainer.displayName = "DialogContainer";
var Dialog = (0, _index.styled)('div', function (props) {
  var $animate = props.$animate,
      $isOpen = props.$isOpen,
      $isVisible = props.$isVisible,
      $size = props.$size,
      $theme = props.$theme;
  return _objectSpread({
    position: 'relative',
    backgroundColor: $theme.colors.backgroundAlt,
    borderTopLeftRadius: $theme.borders.surfaceBorderRadius,
    borderTopRightRadius: $theme.borders.surfaceBorderRadius,
    borderBottomRightRadius: $theme.borders.surfaceBorderRadius,
    borderBottomLeftRadius: $theme.borders.surfaceBorderRadius,
    marginLeft: $theme.sizing.scale600,
    marginTop: $theme.sizing.scale600,
    marginRight: $theme.sizing.scale600,
    marginBottom: $theme.sizing.scale600,
    textAlign: 'left'
  }, getSizeStyles($size), {
    // Animation
    opacity: $isVisible && $isOpen ? 1 : 0,
    transform: $isVisible ? 'translateY(0)' : 'translateY(20px)'
  }, $animate ? {
    transitionProperty: 'opacity, transform',
    transitionDuration: $theme.animation.timing400,
    transitionTimingFunction: $theme.animation.easeOutCurve
  } : null, {
    // Reset interactivity properties set by container
    userSelect: 'text',
    pointerEvents: $isOpen ? 'all' : 'none',
    // We move focus to the modal, but we don't want the blue outline style
    ':focus': {
      outline: 'none'
    }
  });
});
exports.Dialog = Dialog;
Dialog.displayName = "Dialog";
var Close = (0, _index.styled)('button', function (props) {
  var $theme = props.$theme;
  return {
    // Reset button styles
    border: 0,
    background: 'transparent',
    outline: 0,
    paddingLeft: 0,
    paddingTop: 0,
    paddingRight: 0,
    paddingBottom: 0,
    // Positioning
    position: 'absolute',
    top: $theme.sizing.scale500,
    right: $theme.sizing.scale500,
    width: $theme.sizing.scale800,
    height: $theme.sizing.scale800,
    display: 'flex',
    justifyContent: 'center',
    alignItems: 'center',
    cursor: 'pointer',
    color: $theme.colors.mono700,
    transitionProperty: 'color',
    transitionDuration: $theme.animation.timing100,
    ':hover': {
      color: $theme.colors.mono800
    }
  };
});
exports.Close = Close;
Close.displayName = "Close";
var ModalHeader = (0, _index.styled)('div', function (_ref) {
  var $theme = _ref.$theme;
  return _objectSpread({}, $theme.typography.font500, {
    color: $theme.colors.foreground,
    marginTop: $theme.sizing.scale900,
    marginBottom: $theme.sizing.scale600,
    marginLeft: $theme.sizing.scale800,
    // Slightly more margin than left side to leave room for close button
    marginRight: $theme.sizing.scale900
  });
});
exports.ModalHeader = ModalHeader;
ModalHeader.displayName = "ModalHeader";
var ModalBody = (0, _index.styled)('div', function (_ref2) {
  var $theme = _ref2.$theme;
  return _objectSpread({}, $theme.typography.font300, {
    color: $theme.colors.foregroundAlt,
    marginTop: $theme.sizing.scale600,
    marginLeft: $theme.sizing.scale800,
    marginRight: $theme.sizing.scale800,
    marginBottom: $theme.sizing.scale700
  });
});
exports.ModalBody = ModalBody;
ModalBody.displayName = "ModalBody";
var ModalFooter = (0, _index.styled)('div', function (_ref3) {
  var $theme = _ref3.$theme;
  return _objectSpread({}, $theme.typography.font300, {
    marginTop: $theme.sizing.scale700,
    marginLeft: $theme.sizing.scale800,
    marginRight: $theme.sizing.scale800,
    paddingTop: $theme.sizing.scale500,
    paddingBottom: $theme.sizing.scale500,
    textAlign: 'right',
    borderTopWidth: '1px',
    borderTopStyle: 'solid',
    borderTopColor: $theme.colors.mono400
  });
});
exports.ModalFooter = ModalFooter;
ModalFooter.displayName = "ModalFooter";