"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 }; }
const ModalOfferInfo = _ref => {
  let {
    children,
    description,
    included = [],
    name,
    visible: propVisible,
    onClose
  } = _ref;
  const {
    translate
  } = (0, _locale.useLocale)();
  const [visible, setVisible] = (0, _react.useState)(propVisible);
  (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