"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Welcome = void 0;
var _dataSources = require("@mirai/data-sources");
var _locale = require("@mirai/locale");
var _ui = require("@mirai/ui");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _Welcome = require("./Welcome.l10n");
var style = _interopRequireWildcard(require("./Welcome.module.css"));
var _helpers = require("../../../helpers");
var _Chat = require("../../Chat.constants");
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 Welcome = _ref => {
  let {
    settings,
    onInputMode
  } = _ref;
  const {
    isMobile
  } = (0, _ui.useDevice)();
  const {
    translate
  } = (0, _locale.useLocale)();
  const {
    value: {
      session: {
        firstName
      } = {}
    } = {}
  } = (0, _dataSources.useStore)();
  const {
    twilio: {
      active,
      whatsappNumber
    } = {}
  } = settings || {};
  const isWhatsappActive = active && whatsappNumber;
  const titleProps = {
    brand: true,
    headline: true,
    level: 2
  };
  const handleWhatsapp = () => {
    window.open("https://api.whatsapp.com/send?phone=".concat(encodeURIComponent(whatsappNumber)), '_blank');
    onInputMode(_Chat.INPUT_MODE.WHATSAPP);
  };
  return /*#__PURE__*/_react.default.createElement(_ui.View, {
    wide: true,
    className: style.container
  }, /*#__PURE__*/_react.default.createElement(_ui.View, null, /*#__PURE__*/_react.default.createElement(_ui.Text, _extends({}, titleProps, {
    bold: true,
    className: style.title
  }), "\u2726 ".concat(translate(_Welcome.L10N.LABEL_HI), " ").concat(firstName ? ", ".concat(firstName) : '')), /*#__PURE__*/_react.default.createElement(_ui.Text, _extends({}, titleProps, {
    bold: true,
    className: style.title
  }), translate(_Welcome.L10N.LABEL_HOW_HELP))), /*#__PURE__*/_react.default.createElement(_ui.View, {
    row: !isMobile,
    className: (0, _ui.styles)(style.inputsMode, !!isWhatsappActive && style.whatsapp)
  }, /*#__PURE__*/_react.default.createElement(_ui.Pressable, {
    onPress: () => onInputMode(_Chat.INPUT_MODE.TEXT)
  }, /*#__PURE__*/_react.default.createElement(_ui.Icon, {
    value: _helpers.ICON.MESSAGE,
    headline: true,
    level: 1
  }), /*#__PURE__*/_react.default.createElement(_ui.Text, {
    bold: true
  }, translate(_Welcome.L10N.LABEL_MODE_TEXT_TITLE)), /*#__PURE__*/_react.default.createElement(_ui.Text, {
    small: true
  }, translate(_Welcome.L10N.LABEL_MODE_TEXT_DESCRIPTION))), /*#__PURE__*/_react.default.createElement(_ui.Pressable, {
    onPress: () => onInputMode(_Chat.INPUT_MODE.AUDIO)
  }, /*#__PURE__*/_react.default.createElement(_ui.Icon, {
    value: _helpers.ICON.PHONE,
    headline: true,
    level: 1
  }), /*#__PURE__*/_react.default.createElement(_ui.Text, {
    bold: true
  }, translate(_Welcome.L10N.LABEL_MODE_AUDIO_TITLE)), /*#__PURE__*/_react.default.createElement(_ui.Text, {
    small: true
  }, translate(_Welcome.L10N.LABEL_MODE_AUDIO_DESCRIPTION))), isWhatsappActive && /*#__PURE__*/_react.default.createElement(_ui.Pressable, {
    onPress: handleWhatsapp
  }, /*#__PURE__*/_react.default.createElement(_ui.Icon, {
    value: _helpers.ICON.WHATSAPP,
    headline: true,
    level: 1
  }), /*#__PURE__*/_react.default.createElement(_ui.Text, {
    bold: true
  }, translate(_Welcome.L10N.LABEL_MODE_WHATSAPP_TITLE)), /*#__PURE__*/_react.default.createElement(_ui.Text, {
    small: true
  }, translate(_Welcome.L10N.LABEL_MODE_WHATSAPP_DESCRIPTION)))));
};
exports.Welcome = Welcome;
Welcome.displayName = 'Mirai:Core:Chat.Welcome';
Welcome.propTypes = {
  settings: _propTypes.default.shape({
    twilio: _propTypes.default.shape({
      active: _propTypes.default.bool,
      whatsappNumber: _propTypes.default.string
    })
  }),
  onInputMode: _propTypes.default.func
};
//# sourceMappingURL=Welcome.js.map