"use strict";

exports.__esModule = true;
exports.StatusToastFromConfig = void 0;
var _react = _interopRequireWildcard(require("react"));
var _designSystem = require("@wix/design-system");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/StatusToastFromConfig/StatusToastFromConfig.tsx";
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); }
const TOAST_TYPE_TO_STATUS = {
  STANDARD: 'info',
  PREMIUM: 'info',
  SUCCESS: 'success',
  WARNING: 'warning',
  ERROR: 'error'
};
const StatusToastFromConfig = ({
  config,
  onClose,
  dataHook,
  messageDataHook,
  actionDataHook
}) => {
  const action = (0, _react.useMemo)(() => {
    var _config$action;
    if (!((_config$action = config.action) != null && _config$action.text)) {
      return undefined;
    }
    const handleClick = () => {
      var _config$action2, _config$action3;
      (_config$action2 = config.action) == null || _config$action2.onClick == null || _config$action2.onClick();
      if ((_config$action3 = config.action) != null && _config$action3.removeToastOnClick) {
        onClose();
      }
    };
    return /*#__PURE__*/_react.default.createElement(_designSystem.StatusToast.Action, {
      dataHook: actionDataHook,
      onClick: handleClick,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 41,
        columnNumber: 7
      }
    }, config.action.text);
  }, [config, onClose, actionDataHook]);
  return /*#__PURE__*/_react.default.createElement(_designSystem.StatusToast, {
    key: config.biName ?? config.message,
    dataHook: dataHook,
    status: TOAST_TYPE_TO_STATUS[config.type ?? 'STANDARD'],
    dismissible: true,
    onDismiss: onClose,
    action: action,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 48,
      columnNumber: 5
    }
  }, messageDataHook ? /*#__PURE__*/_react.default.createElement("span", {
    "data-hook": messageDataHook,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 57,
      columnNumber: 9
    }
  }, config.message) : config.message);
};
exports.StatusToastFromConfig = StatusToastFromConfig;
//# sourceMappingURL=StatusToastFromConfig.js.map