"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ToastNotification = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _context = require("../../context");
var _core = require("../../core");
var _icons = require("../icons");
var _layout = require("../layout");
var _typography = require("../typography");
var _jsxRuntime = require("react/jsx-runtime");
const toastColorVariants = {
  neutral: {
    background: "turquoise-150",
    stroke: "turquoise-850"
  },
  error: {
    background: "error-100",
    stroke: "error-850"
  },
  info: {
    background: "info-100",
    stroke: "info-850"
  },
  success: {
    background: "success-100",
    stroke: "success-850"
  },
  warning: {
    background: "warning-100",
    stroke: "warning-850"
  }
};
const ToastNotification = ({
  message,
  variant = "neutral",
  icon
}) => {
  const colors = toastColorVariants[variant];
  const {
    themeType
  } = (0, _context.useIOThemeContext)();
  const dynamicStyle = (0, _react.useMemo)(() => {
    const borderColor = themeType === "dark" ? (0, _core.hexToRgba)(_core.IOColors[colors.stroke], 0.25) : (0, _core.hexToRgba)(_core.IOColors[colors.stroke], 0.5);

    /* Remove border entirely when dark mode is enabled */
    const borderWidth = themeType === "dark" ? 0 : 1;
    return {
      backgroundColor: _core.IOColors[colors.background],
      borderColor,
      borderWidth
    };
  }, [colors, themeType]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
    style: [styles.toast, dynamicStyle],
    accessible: true,
    accessibilityRole: "alert",
    accessibilityLabel: message,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.ButtonText, {
      color: colors.stroke,
      style: styles.content,
      children: message
    }), icon && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.HSpacer, {
        size: 16
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
        name: icon,
        size: 24,
        color: colors.stroke
      })]
    })]
  });
};
exports.ToastNotification = ToastNotification;
const styles = _reactNative.StyleSheet.create({
  toast: {
    borderRadius: _core.IOAlertRadius,
    borderCurve: "continuous",
    padding: 16,
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "space-between"
  },
  content: {
    flexShrink: 1,
    paddingVertical: 2
  }
});
//# sourceMappingURL=ToastNotification.js.map