/**
 * Toast Context
 * Toast context definition - separated for Fast Refresh compatibility
 */

import { createContext } from "react";

export type ToastOptions = {
  variant?: "success" | "error" | "warning" | "info";
  title?: string;
  description?: string;
  durationMs?: number;  // 0 = 不自动关闭（需要手动关闭）
  id?: string;          // 自定义 id（你想手动控制唯一性时用）
  /** 指定"去重/合并"的键；不填则用 variant|title|description 自动生成 */
  mergeKey?: string;
};

export type ToastContextValue = {
  show: (opts: ToastOptions) => void;
  success: (msg: string, opts?: Partial<ToastOptions>) => void;
  error: (msg: string, opts?: Partial<ToastOptions>) => void;
  warning: (msg: string, opts?: Partial<ToastOptions>) => void;
  info: (msg: string, opts?: Partial<ToastOptions>) => void;
  remove: (id: string) => void;
};

export const ToastContext = createContext<ToastContextValue | null>(null);

