text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports["default"] = exports.BOTTOM_RIGHT = exports.TOP_RIGHT = exports.TOP_LEFT = void 0;
  
  var _react = _interopRequireDefault(require("react"));
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _airbnbPropTypes = require("airbnb-prop-types");
  
  var _reactWithStyles = require("react-with-styles");
  
  var _defaultPhrases = require("../defaultPhrases");
  
  var _getPhrasePropTypes = _interopRequireDefault(require("../utils/getPhrasePropTypes"));
  
  var _baseClass = _interopRequireWildcard(require("../utils/baseClass"));
  
  var _KeyboardShortcutRow = _interopRequireDefault(require("./KeyboardShortcutRow"));
  
  var _CloseButton = _interopRequireDefault(require("./CloseButton"));
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  
  function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function () { function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); } return _getPrototypeOf; }(); return _getPrototypeOf(o); }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function () { function _setPrototypeOf(o, p) { o.__proto__ = p; return o; } return _setPrototypeOf; }(); return _setPrototypeOf(o, p); }
  
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  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; }
  
  var TOP_LEFT = 'top-left';
  exports.TOP_LEFT = TOP_LEFT;
  var TOP_RIGHT = 'top-right';
  exports.TOP_RIGHT = TOP_RIGHT;
  var BOTTOM_RIGHT = 'bottom-right';
  exports.BOTTOM_RIGHT = BOTTOM_RIGHT;
  var propTypes = (0, _airbnbPropTypes.forbidExtraProps)(_objectSpread({}, _reactWithStyles.withStylesPropTypes, {
    block: _propTypes["default"].bool,
    buttonLocation: _propTypes["default"].oneOf([TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT]),
    showKeyboardShortcutsPanel: _propTypes["default"].bool,
    openKeyboardShortcutsPanel: _propTypes["default"].func,
    closeKeyboardShortcutsPanel: _propTypes["default"].func,
    phrases: _propTypes["default"].shape((0, _getPhrasePropTypes["default"])(_defaultPhrases.DayPickerKeyboardShortcutsPhrases))
  }));
  var defaultProps = {
    block: false,
    buttonLocation: BOTTOM_RIGHT,
    showKeyboardShortcutsPanel: false,
    openKeyboardShortcutsPanel: function () {
      function openKeyboardShortcutsPanel() {}
  
      return openKeyboardShortcutsPanel;
    }(),
    closeKeyboardShortcutsPanel: function () {
      function closeKeyboardShortcutsPanel() {}
  
      return closeKeyboardShortcutsPanel;
    }(),
    phrases: _defaultPhrases.DayPickerKeyboardShortcutsPhrases
  };
  
  function getKeyboardShortcuts(phrases) {
    return [{
      unicode: '↵',
      label: phrases.enterKey,
      action: phrases.selectFocusedDate
    }, {
      unicode: '←/→',
      label: phrases.leftArrowRightArrow,
      action: phrases.moveFocusByOneDay
    }, {
      unicode: '↑/↓',
      label: phrases.upArrowDownArrow,
      action: phrases.moveFocusByOneWeek
    }, {
      unicode: 'PgUp/PgDn',
      label: phrases.pageUpPageDown,
      action: phrases.moveFocusByOneMonth
    }, {
      unicode: 'Home/End',
      label: phrases.homeEnd,
      action: phrases.moveFocustoStartAndEndOfWeek
    }, {
      unicode: 'Esc',
      label: phrases.escape,
      action: phrases.returnFocusToInput
    }, {
      unicode: '?',
      label: phrases.questionMark,
      action: phrases.openThisPanel
    }];
  }
  /** @extends React.Component */
  
  
  var DayPickerKeyboardShortcuts =
  /*#__PURE__*/
  function (_BaseClass) {
    _inherits(DayPickerKeyboardShortcuts, _BaseClass);
  
    function DayPickerKeyboardShortcuts() {
      var _getPrototypeOf2;
  
      var _this;
  
      _classCallCheck(this, DayPickerKeyboardShortcuts);
  
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(DayPickerKeyboardShortcuts)).call.apply(_getPrototypeOf2, [this].concat(args)));
      var phrases = _this.props.phrases;
      _this.keyboardShortcuts = getKeyboardShortcuts(phrases);
      _this.onShowKeyboardShortcutsButtonClick = _this.onShowKeyboardShortcutsButtonClick.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this.setShowKeyboardShortcutsButtonRef = _this.setShowKeyboardShortcutsButtonRef.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this.setHideKeyboardShortcutsButtonRef = _this.setHideKeyboardShortcutsButtonRef.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this.handleFocus = _this.handleFocus.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this.onKeyDown = _this.onKeyDown.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      return _this;
    }
  
    _createClass(DayPickerKeyboardShortcuts, [{
      key: "componentWillReceiveProps",
      value: function () {
        function componentWillReceiveProps(nextProps) {
          var phrases = this.props.phrases;
  
          if (nextProps.phrases !== phrases) {
            this.keyboardShortcuts = getKeyboardShortcuts(nextProps.phrases);
          }
        }
  
        return componentWillReceiveProps;
      }()
    }, {
      key: "componentDidUpdate",
      value: function () {
        function componentDidUpdate() {
          this.handleFocus();
        }
  
        return componentDidUpdate;
      }()
    }, {
      key: "onKeyDown",
      value: function () {
        function onKeyDown(e) {
          e.stopPropagation();
          var closeKeyboardShortcutsPanel = this.props.closeKeyboardShortcutsPanel; // Because the close button is the only focusable element inside of the panel, this
          // amounts to a very basic focus trap. The user can exit the panel by "pressing" the
          // close button or hitting escape
  
          switch (e.key) {
            case 'Enter':
            case ' ':
            case 'Spacebar': // for older browsers
  
            case 'Escape':
              closeKeyboardShortcutsPanel();
              break;
            // do nothing - this allows the up and down arrows continue their
            // default behavior of scrolling the content of the Keyboard Shortcuts Panel
            // which is needed when only a single month is shown for instance.
  
            case 'ArrowUp':
            case 'ArrowDown':
              break;
            // completely block the rest of the keys that have functionality outside of this panel
  
            case 'Tab':
            case 'Home':
            case 'End':
            case 'PageUp':
            case 'PageDown':
            case 'ArrowLeft':
            case 'ArrowRight':
              e.preventDefault();
              break;
  
            default:
              break;
          }
        }
  
        return onKeyDown;
      }()
    }, {
      key: "onShowKeyboardShortcutsButtonClick",
      value: function () {
        function onShowKeyboardShortcutsButtonClick() {
          var _this2 = this;
  
          var openKeyboardShortcutsPanel = this.props.openKeyboardShortcutsPanel; // we want to return focus to this button after closing the keyboard shortcuts panel
  
          openKeyboardShortcutsPanel(function () {
            _this2.showKeyboardShortcutsButton.focus();
          });
        }
  
        return onShowKeyboardShortcutsButtonClick;
      }()
    }, {
      key: "setShowKeyboardShortcutsButtonRef",
      value: function () {
        function setShowKeyboardShortcutsButtonRef(ref) {
          this.showKeyboardShortcutsButton = ref;
        }
  
        return setShowKeyboardShortcutsButtonRef;
      }()
    }, {
      key: "setHideKeyboardShortcutsButtonRef",
      value: function () {
        function setHideKeyboardShortcutsButtonRef(ref) {
          this.hideKeyboardShortcutsButton = ref;
        }
  
        return setHideKeyboardShortcutsButtonRef;
      }()
    }, {
      key: "handleFocus",
      value: function () {
        function handleFocus() {
          if (this.hideKeyboardShortcutsButton) {
            // automatically move focus into the dialog by moving
            // to the only interactive element, the hide button
            this.hideKeyboardShortcutsButton.focus();
          }
        }
  
        return handleFocus;
      }()
    }, {
      key: "render",
      value: function () {
        function render() {
          var _this3 = this;
  
          var _this$props = this.props,
              block = _this$props.block,
              buttonLocation = _this$props.buttonLocation,
              showKeyboardShortcutsPanel = _this$props.showKeyboardShortcutsPanel,
              closeKeyboardShortcutsPanel = _this$props.closeKeyboardShortcutsPanel,
              styles = _this$props.styles,
              phrases = _this$props.phrases;
          var toggleButtonText = showKeyboardShortcutsPanel ? phrases.hideKeyboardShortcutsPanel : phrases.showKeyboardShortcutsPanel;
          var bottomRight = buttonLocation === BOTTOM_RIGHT;
          var topRight = buttonLocation === TOP_RIGHT;
          var topLeft = buttonLocation === TOP_LEFT;
          return _react["default"].createElement("div", null, _react["default"].createElement("button", _extends({
            ref: this.setShowKeyboardShortcutsButtonRef
          }, (0, _reactWithStyles.css)(styles.DayPickerKeyboardShortcuts_buttonReset, styles.DayPickerKeyboardShortcuts_show, bottomRight && styles.DayPickerKeyboardShortcuts_show__bottomRight, topRight && styles.DayPickerKeyboardShortcuts_show__topRight, topLeft && styles.DayPickerKeyboardShortcuts_show__topLeft), {
            type: "button",
            "aria-label": toggleButtonText,
            onClick: this.onShowKeyboardShortcutsButtonClick,
            onKeyDown: function () {
              function onKeyDown(e) {
                if (e.key === 'Enter') {
                  e.preventDefault();
                } else if (e.key === 'Space') {
                  _this3.onShowKeyboardShortcutsButtonClick(e);
                }
              }
  
              return onKeyDown;
            }(),
            onMouseUp: function () {
              function onMouseUp(e) {
                e.currentTarget.blur();
              }
  
              return onMouseUp;
            }()
          }), _react["default"].createElement("span", (0, _reactWithStyles.css)(styles.DayPickerKeyboardShortcuts_showSpan, bottomRight && styles.DayPickerKeyboardShortcuts_showSpan__bottomRight, topRight && styles.DayPickerKeyboardShortcuts_showSpan__topRight, topLeft && styles.DayPickerKeyboardShortcuts_showSpan__topLeft), "?")), showKeyboardShortcutsPanel && _react["default"].createElement("div", _extends({}, (0, _reactWithStyles.css)(styles.DayPickerKeyboardShortcuts_panel), {
            role: "dialog",
            "aria-labelledby": "DayPickerKeyboardShortcuts_title",
            "aria-describedby": "DayPickerKeyboardShortcuts_description"
          }), _react["default"].createElement("div", _extends({}, (0, _reactWithStyles.css)(styles.DayPickerKeyboardShortcuts_title), {
            id: "DayPickerKeyboardShortcuts_title"
          }), phrases.keyboardShortcuts), _react["default"].createElement("button", _extends({
            ref: this.setHideKeyboardShortcutsButtonRef
          }, (0, _reactWithStyles.css)(styles.DayPickerKeyboardShortcuts_buttonReset, styles.DayPickerKeyboardShortcuts_close), {
            type: "button",
            tabIndex: "0",
            "aria-label": phrases.hideKeyboardShortcutsPanel,
            onClick: closeKeyboardShortcutsPanel,
            onKeyDown: this.onKeyDown
          }), _react["default"].createElement(_CloseButton["default"], (0, _reactWithStyles.css)(styles.DayPickerKeyboardShortcuts_closeSvg))), _react["default"].createElement("ul", _extends({}, (0, _reactWithStyles.css)(styles.DayPickerKeyboardShortcuts_list), {
            id: "DayPickerKeyboardShortcuts_description"
          }), this.keyboardShortcuts.map(function (_ref) {
            var unicode = _ref.unicode,
                label = _ref.label,
                action = _ref.action;
            return _react["default"].createElement(_KeyboardShortcutRow["default"], {
              key: label,
              unicode: unicode,
              label: label,
              action: action,
              block: block
            });
          }))));
        }
  
        return render;
      }()
    }]);
  
    return DayPickerKeyboardShortcuts;
  }(_baseClass["default"]);
  
  DayPickerKeyboardShortcuts.propTypes = propTypes;
  DayPickerKeyboardShortcuts.defaultProps = defaultProps;
  
  var _default = (0, _reactWithStyles.withStyles)(function (_ref2) {
    var _ref2$reactDates = _ref2.reactDates,
        color = _ref2$reactDates.color,
        font = _ref2$reactDates.font,
        zIndex = _ref2$reactDates.zIndex;
    return {
      DayPickerKeyboardShortcuts_buttonReset: {
        background: 'none',
        border: 0,
        borderRadius: 0,
        color: 'inherit',
        font: 'inherit',
        lineHeight: 'normal',
        overflow: 'visible',
        padding: 0,
        cursor: 'pointer',
        fontSize: font.size,
        ':active': {
          outline: 'none'
        }
      },
      DayPickerKeyboardShortcuts_show: {
        width: 22,
        position: 'absolute',
        zIndex: zIndex + 2
      },
      DayPickerKeyboardShortcuts_show__bottomRight: {
        borderTop: '26px solid transparent',
        borderRight: "33px solid ".concat(color.core.primary),
        bottom: 0,
        right: 0,
        ':hover': {
          borderRight: "33px solid ".concat(color.core.primary_dark)
        }
      },
      DayPickerKeyboardShortcuts_show__topRight: {
        borderBottom: '26px solid transparent',
        borderRight: "33px solid ".concat(color.core.primary),
        top: 0,
        right: 0,
        ':hover': {
          borderRight: "33px solid ".concat(color.core.primary_dark)
        }
      },
      DayPickerKeyboardShortcuts_show__topLeft: {
        borderBottom: '26px solid transparent',
        borderLeft: "33px solid ".concat(color.core.primary),
        top: 0,
        left: 0,
        ':hover': {
          borderLeft: "33px solid ".concat(color.core.primary_dark)
        }
      },
      DayPickerKeyboardShortcuts_showSpan: {
        color: color.core.white,
        position: 'absolute'
      },
      DayPickerKeyboardShortcuts_showSpan__bottomRight: {
        bottom: 0,
        right: -28
      },
      DayPickerKeyboardShortcuts_showSpan__topRight: {
        top: 1,
        right: -28
      },
      DayPickerKeyboardShortcuts_showSpan__topLeft: {
        top: 1,
        left: -28
      },
      DayPickerKeyboardShortcuts_panel: {
        overflow: 'auto',
        background: color.background,
        border: "1px solid ".concat(color.core.border),
        borderRadius: 2,
        position: 'absolute',
        top: 0,
        bottom: 0,
        right: 0,
        left: 0,
        zIndex: zIndex + 2,
        padding: 22,
        margin: 33
      },
      DayPickerKeyboardShortcuts_title: {
        fontSize: 16,
        fontWeight: 'bold',
        margin: 0
      },
      DayPickerKeyboardShortcuts_list: {
        listStyle: 'none',
        padding: 0,
        fontSize: font.size
      },
      DayPickerKeyboardShortcuts_close: {
        position: 'absolute',
        right: 22,
        top: 22,
        zIndex: zIndex + 2,
        ':active': {
          outline: 'none'
        }
      },
      DayPickerKeyboardShortcuts_closeSvg: {
        height: 15,
        width: 15,
        fill: color.core.grayLighter,
        ':hover': {
          fill: color.core.grayLight
        },
        ':focus': {
          fill: color.core.grayLight
        }
      }
    };
  }, {
    pureComponent: _baseClass.pureComponentAvailable
  })(DayPickerKeyboardShortcuts);
  
  exports["default"] = _default;