"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Context = void 0;
var _locale = require("@mirai/locale");
var _ui = require("@mirai/ui");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var style = _interopRequireWildcard(require("./Input.module.css"));
var _helpers = require("../../../helpers");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const ICON_PROPS = {
  className: style.icon
};
const TEXT_PROPS = {
  action: true,
  medium: true
};
const Context = _ref => {
  let {
    bookingId,
    checkIn,
    checkOut,
    adults,
    childrenAges = []
  } = _ref;
  const {
    isMobile
  } = (0, _ui.useDevice)();
  const {
    dateFormat
  } = (0, _locale.useLocale)();
  const dateFormatCompact = {
    day: 'numeric',
    month: 'short',
    weekday: !isMobile ? 'short' : undefined
  };
  return bookingId || !!checkIn || adults > 0 ? /*#__PURE__*/_react.default.createElement(_ui.View, {
    row: true,
    className: style.context
  }, bookingId && /*#__PURE__*/_react.default.createElement(_ui.View, {
    row: true,
    className: style.field
  }, /*#__PURE__*/_react.default.createElement(_ui.Icon, _extends({}, ICON_PROPS, {
    value: _helpers.ICON.ASSIGNMENT
  })), /*#__PURE__*/_react.default.createElement(_ui.Text, TEXT_PROPS, bookingId)), !!checkIn && /*#__PURE__*/_react.default.createElement(_ui.View, {
    row: true,
    className: style.field
  }, /*#__PURE__*/_react.default.createElement(_ui.Icon, _extends({}, ICON_PROPS, {
    value: _helpers.ICON.CALENDAR
  })), /*#__PURE__*/_react.default.createElement(_ui.Text, TEXT_PROPS, dateFormat((0, _locale.parseDate)(checkIn), dateFormatCompact)), checkOut && /*#__PURE__*/_react.default.createElement(_ui.Text, TEXT_PROPS, " \u2014 ".concat(dateFormat((0, _locale.parseDate)(checkOut), dateFormatCompact)))), adults > 0 && /*#__PURE__*/_react.default.createElement(_ui.View, {
    row: true,
    className: style.field
  }, /*#__PURE__*/_react.default.createElement(_ui.Icon, _extends({}, ICON_PROPS, {
    value: _helpers.ICON.PEOPLE
  })), /*#__PURE__*/_react.default.createElement(_ui.Text, TEXT_PROPS, adults, " ", childrenAges.length ? "+ ".concat(childrenAges.length) : ''))) : null;
};
exports.Context = Context;
Context.propTypes = {
  bookingId: _propTypes.default.string,
  checkIn: _propTypes.default.string,
  checkOut: _propTypes.default.string,
  adults: _propTypes.default.number,
  childrenAges: _propTypes.default.arrayOf(_propTypes.default.number)
};
//# sourceMappingURL=Input.Context.js.map