"use strict";

exports.__esModule = true;
exports.default = exports.ToastList = exports.ToastIcon = exports.ToastBox = exports.Toast = exports.CloseIcon = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _styledTransitionGroup = _interopRequireDefault(require("styled-transition-group"));
var _reactTransitionGroup = require("react-transition-group");
var _reactDom = _interopRequireDefault(require("react-dom"));
var _polished = require("polished");
var _utils = require("../utils");
var _Text = _interopRequireDefault(require("./Text"));
var _Icon = _interopRequireDefault(require("./Icon"));
var _excluded = ["message", "type", "closeFunc"];
var _templateObject;
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
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); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var portal = document.getElementById("toast") || document.createElement("div");
/* istanbul ignore else */
if (!portal.parent) {
  portal.id = "toast";
  document.body.appendChild(portal);
}
var toastTransitionTime = 300;
var ToastBox = exports.ToastBox = _styledTransitionGroup.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tdisplay: flex;\n\twidth: 390px;\n\tmargin-top: 10px;\n\tpadding: 17px;\n\tborder-radius: 5px;\n\tfont-size: 14px;\n\tcolor: white;\n\tbackground-color: ", ";\n\tz-index: 10000;\n\n\t& > * {\n\t\tmargin-top: auto;\n\t\tmargin-bottom: auto;\n\t}\n\t\n\t&:enter {\n\t\ttransform: translateX(200%);\n\t}\n\t&:enter-active {\n\t\ttransform: translateX(0);\n\t\ttransition: transform ", "ms ease-out;\n\t}\n\t&:exit {\n\t\ttransform-origin: top;\n\t\ttransform: scale(1,1);\n\t}\n\t&:exit ~ & {\n\t\ttransform: translateY(0);\n\t}\n\t&:exit-active {\n\t\ttransform: scale(1, 0.001);\n\t\ttransition: transform ", "ms ease-out;\n\t}\n\t&:exit-active ~ & {\n\t\ttransition: transform ", "ms ease-out;\n\t\ttransform: translateY(-100%);\n\t}\n"])), (0, _utils.getThemeProp)(["colors", "toasts", function (props) {
  return props.type;
}], "#999"), toastTransitionTime, toastTransitionTime, toastTransitionTime);
ToastBox.defaultProps = {
  timeout: toastTransitionTime,
  unmountOnExit: true
};
var ToastIcon = exports.ToastIcon = (0, _styledComponents.default)(_Icon.default).attrs(function (props) {
  return {
    id: (0, _utils.getThemeProp)(["icons", "toast", function (props) {
      return props.type;
    }], "bubble-chat-2")(props)
  };
}).withConfig({
  displayName: "ToastList__ToastIcon",
  componentId: "sc-ux3rdy-0"
})(["font-size:20px;margin-right:16px;stroke-width:2px;"]);
var CloseIcon = exports.CloseIcon = (0, _styledComponents.default)(_Icon.default).attrs(function (props) {
  return {
    id: (0, _utils.getThemeProp)(["icons", "close"], "close")(props)
  };
}).withConfig({
  displayName: "ToastList__CloseIcon",
  componentId: "sc-ux3rdy-1"
})(["position:absolute;top:8px;right:8px;font-size:10px;padding:2px;border-radius:2px;stroke-width:2px;&:hover{background-color:", ";}"], (0, _utils.getThemeProp)(["colors", "toasts", function (props) {
  return props.type;
}], "#999999", function (color) {
  return (0, _polished.shade)(0.3, color);
}));
var Toast = exports.Toast = function Toast(_ref) {
  var _ref$message = _ref.message,
    message = _ref$message === void 0 ? "[No message]" : _ref$message,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? "" : _ref$type,
    closeFunc = _ref.closeFunc,
    props = _objectWithoutProperties(_ref, _excluded);
  return /*#__PURE__*/_react.default.createElement(ToastBox, {
    type: type,
    in: props.in
  }, /*#__PURE__*/_react.default.createElement(ToastIcon, {
    type: type
  }), /*#__PURE__*/_react.default.createElement(_Text.default, {
    message: message
  }), closeFunc ? /*#__PURE__*/_react.default.createElement(CloseIcon, {
    onClick: closeFunc,
    type: type
  }) : null);
};
var ListWrapper = (0, _styledComponents.default)(_reactTransitionGroup.TransitionGroup).withConfig({
  displayName: "ToastList__ListWrapper",
  componentId: "sc-ux3rdy-2"
})(["position:absolute;top:40px;right:16px;display:flex;flex-direction:column;"]);
var ToastList = exports.ToastList = function ToastList(_ref2) {
  var toasts = _ref2.toasts;
  return _reactDom.default.createPortal(/*#__PURE__*/_react.default.createElement(ListWrapper, null, toasts.map(function (props, idx) {
    return /*#__PURE__*/_react.default.createElement(Toast, _extends({
      key: "toast" + idx
    }, props));
  })), portal);
};
var _default = ToastList;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(portal, "portal", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(toastTransitionTime, "toastTransitionTime", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ToastBox, "ToastBox", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ToastIcon, "ToastIcon", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(CloseIcon, "CloseIcon", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(Toast, "Toast", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ListWrapper, "ListWrapper", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ToastList, "ToastList", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/ToastList.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(portal, "portal", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(toastTransitionTime, "toastTransitionTime", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ToastBox, "ToastBox", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ToastIcon, "ToastIcon", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(CloseIcon, "CloseIcon", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(Toast, "Toast", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ListWrapper, "ListWrapper", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(ToastList, "ToastList", "/home/vsts/work/1/s/src/components/ToastList.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/ToastList.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();