"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModalOfferInfo = void 0;
var _locale = require("@mirai/locale");
var _ui = require("@mirai/ui");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireWildcard(require("react"));
var style = _interopRequireWildcard(require("./ModalOfferInfo.module.css"));
var _Item = require("../../Item.l10n");
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 _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
const ModalOfferInfo = _ref => {
  let children = _ref.children,
    description = _ref.description,
    _ref$included = _ref.included,
    included = _ref$included === void 0 ? [] : _ref$included,
    name = _ref.name,
    propVisible = _ref.visible,
    onClose = _ref.onClose;
  const _useLocale = (0, _locale.useLocale)(),
    translate = _useLocale.translate;
  const _useState = (0, _react.useState)(propVisible),
    _useState2 = _slicedToArray(_useState, 2),
    visible = _useState2[0],
    setVisible = _useState2[1];
  (0, _react.useEffect)(() => {
    setVisible(propVisible);
  }, [propVisible]);
  const handleClose = () => {
    setVisible(false);
    setTimeout(onClose, 300);
  };
  const textProps = {
    action: true
  };
  return /*#__PURE__*/_react.default.createElement(_ui.Modal, {
    visible,
    fit: true,
    title: name,
    visible: visible,
    onClose: handleClose,
    onOverflow: handleClose,
    className: style.modal
  }, /*#__PURE__*/_react.default.createElement(_ui.View, {
    className: style.content
  }, description && /*#__PURE__*/_react.default.createElement(_ui.View, {
    className: style.section
  }, /*#__PURE__*/_react.default.createElement(_ui.Text, {
    bold: true,
    upperCase: true
  }, translate(_Item.L10N.LABEL_DESCRIPTION)), /*#__PURE__*/_react.default.createElement(_ui.Text, textProps, description)), included.length > 0 && /*#__PURE__*/_react.default.createElement(_ui.View, {
    className: [style.section, style.included]
  }, /*#__PURE__*/_react.default.createElement(_ui.Text, {
    bold: true,
    upperCase: true
  }, translate(_Item.L10N.LABEL_WHATS_INCLUDED)), included.map((item, index) => /*#__PURE__*/_react.default.createElement(_ui.View, {
    key: index,
    row: true,
    className: style.row
  }, /*#__PURE__*/_react.default.createElement(_ui.Text, {
    small: true
  }, "\u2022"), /*#__PURE__*/_react.default.createElement(_ui.Text, textProps, item)))), children));
};
exports.ModalOfferInfo = ModalOfferInfo;
ModalOfferInfo.displayName = 'Mirai:Core:Rates:Item:ModalOfferInfo';
ModalOfferInfo.propTypes = {
  availableBoards: _propTypes.default.array,
  children: _propTypes.default.node,
  included: _propTypes.default.arrayOf(_propTypes.default.string),
  description: _propTypes.default.string,
  name: _propTypes.default.string,
  visible: _propTypes.default.bool,
  onClose: _propTypes.default.func.isRequired
};
//# sourceMappingURL=ModalOfferInfo.js.map