"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _classnames = _interopRequireDefault(require("classnames"));
var _constants = require("../../constants");
var _Icon = _interopRequireDefault(require("../Icon"));
var _Button = _interopRequireDefault(require("../Button"));
var _intentIconMap = require("../intentIconMap");
var _OnDarkContext = _interopRequireDefault(require("../OnDarkContext"));
var _useAutoClose = require("./useAutoClose");
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.

const Toast = _ref => {
  let {
    baseClassName = `${_constants.CLS_PREFIX}toast`,
    className,
    message,
    intent,
    accent,
    icon = intent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
      name: _intentIconMap.intentIconMap[intent]
    }),
    onClose,
    closable = true,
    autoClosable,
    autoCloseTimeout,
    innerRef,
    groupKey,
    ...props
  } = _ref;
  (0, _useAutoClose.useAutoClose)({
    autoClosable,
    autoCloseTimeout,
    onClose
  });
  const result = /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    tabIndex: 0,
    className: (0, _classnames.default)(baseClassName, intent && `${baseClassName}--${intent}`, accent && `${baseClassName}--accent`, className),
    ...props,
    ref: innerRef,
    children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${baseClassName}__icon`,
      children: _Icon.default.create(icon, {
        intent
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${baseClassName}__content`,
      children: message
    }), closable && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${baseClassName}__action`,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
        ghost: true,
        icon: {
          name: 'cross-mark',
          size: '12'
        },
        className: `${baseClassName}__close`,
        onClick: onClose
      })
    })]
  });
  if (accent) {
    return result;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_OnDarkContext.default.Provider, {
    value: true,
    children: result
  });
};
var _default = exports.default = Toast;