"use strict";

import { useMemo } from "react";
import { StyleSheet, View } from "react-native";
import { useIOThemeContext } from "../../context";
import { IOAlertRadius, IOColors, hexToRgba } from "../../core";
import { Icon } from "../icons";
import { HSpacer } from "../layout";
import { ButtonText } from "../typography";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "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
  } = useIOThemeContext();
  const dynamicStyle = useMemo(() => {
    const borderColor = themeType === "dark" ? hexToRgba(IOColors[colors.stroke], 0.25) : hexToRgba(IOColors[colors.stroke], 0.5);

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