import { ToastActionElement, ToastProps } from "./Toast.js";
import { ReactNode } from "react";

//#region src/components/Toaster/useToast.d.ts

/**
 * Extended toast configuration with additional properties for the toast system.
 *
 * Combines base ToastProps with specific fields needed for toast management
 * including unique identification and content elements.
 *
 * @example
 * ```tsx
 * const toast: ToasterToast = {
 *   id: '1',
 *   variant: 'success',
 *   title: 'Success!',
 *   description: 'Your action completed successfully.',
 *   action: <ToastAction altText="View details">View</ToastAction>
 * };
 * ```
 */
type ToasterToast = ToastProps & {
  /** Unique identifier for the toast instance */
  id: string;
  /** Optional title text or React element */
  title?: ReactNode;
  /** Optional description text or React element */
  description?: ReactNode;
  /** Optional action button element */
  action?: ToastActionElement;
};
/**
 * Action types for toast state management using reducer pattern.
 *
 * Defines all possible actions that can be performed on the toast state,
 * enabling predictable state updates and better debugging.
 */
declare enum ActionTypes {
  /** Add a new toast to the display queue */
  ADD_TOAST = "ADD_TOAST",
  /** Update properties of an existing toast */
  UPDATE_TOAST = "UPDATE_TOAST",
  /** Mark a toast as dismissed (triggers exit animation) */
  DISMISS_TOAST = "DISMISS_TOAST",
  /** Completely remove a toast from memory */
  REMOVE_TOAST = "REMOVE_TOAST",
}
type Action = {
  type: ActionTypes.ADD_TOAST;
  toast: ToasterToast;
} | {
  type: ActionTypes.UPDATE_TOAST;
  toast: Partial<ToasterToast>;
} | {
  type: ActionTypes.DISMISS_TOAST;
  toastId?: ToasterToast['id'];
} | {
  type: ActionTypes.REMOVE_TOAST;
  toastId?: ToasterToast['id'];
};
type State = {
  toasts: ToasterToast[];
};
/**
 * Toast state reducer function that handles all toast state transitions.
 *
 * Implements predictable state updates using the reducer pattern, ensuring
 * consistent behavior across all toast operations.
 *
 * ## State Management
 * - **ADD_TOAST**: Adds new toast and enforces limit by removing excess toasts
 * - **UPDATE_TOAST**: Updates existing toast properties while preserving identity
 * - **DISMISS_TOAST**: Marks toasts as closed and schedules removal
 * - **REMOVE_TOAST**: Permanently removes toasts from state
 *
 * ## Side Effects
 * The DISMISS_TOAST action includes side effects for scheduling toast removal,
 * which could be extracted but is kept here for simplicity.
 *
 * @param state - Current toast state
 * @param action - Action to perform on the state
 * @returns Updated toast state
 *
 * @example
 * ```tsx
 * // Add a new toast
 * const newState = reducer(state, {
 *   type: ActionTypes.ADD_TOAST,
 *   toast: { id: '1', title: 'Hello', variant: 'default' }
 * });
 *
 * // Dismiss a specific toast
 * const dismissedState = reducer(state, {
 *   type: ActionTypes.DISMISS_TOAST,
 *   toastId: '1'
 * });
 * ```
 */
declare const reducer: (state: State, action: Action) => State;
/**
 * Toast configuration type for creating new toasts.
 * Omits the 'id' field as it's automatically generated.
 */
type Toast = Omit<ToasterToast, 'id'>;
/**
 * Creates and displays a new toast notification.
 *
 * This is the primary function for showing toast notifications to users.
 * It automatically generates unique IDs, handles state updates, and provides
 * control functions for managing the toast lifecycle.
 *
 * ## Features
 * - **Automatic ID Generation**: Each toast gets a unique identifier
 * - **State Management**: Integrates with global toast state
 * - **Lifecycle Control**: Returns functions to update or dismiss the toast
 * - **Auto-dismiss**: Automatically closes when user dismisses
 *
 * ## Return Value
 * Returns an object with control functions:
 * - `id`: Unique identifier for the toast
 * - `dismiss()`: Function to manually dismiss the toast
 * - `update()`: Function to update toast properties
 *
 * @param props - Toast configuration (title, description, variant, etc.)
 * @returns Object with toast ID and control functions
 *
 * @example
 * ```tsx
 * // Basic success toast
 * const { dismiss } = toast({
 *   title: 'Success!',
 *   description: 'Your file was uploaded successfully.',
 *   variant: 'success'
 * });
 *
 * // Error toast with retry action
 * const errorToast = toast({
 *   title: 'Upload Failed',
 *   description: 'Could not upload file. Please try again.',
 *   variant: 'error',
 *   action: <ToastAction altText="Retry upload">Retry</ToastAction>
 * });
 *
 * // Update toast content dynamically
 * errorToast.update({
 *   title: 'Retrying...',
 *   description: 'Please wait while we retry the upload.',
 *   variant: 'default'
 * });
 *
 * // Manually dismiss toast
 * setTimeout(() => errorToast.dismiss(), 5000);
 * ```
 */
declare const toast: ({
  ...props
}: Toast) => {
  id: string;
  dismiss: () => void;
  update: (props: ToasterToast) => void;
};
/**
 * React hook for managing toast notifications.
 *
 * Provides access to the global toast state and functions for creating and
 * managing toast notifications. This hook connects components to the toast
 * system and ensures reactive updates when toasts change.
 *
 * ## Features
 * - **State Synchronization**: Automatically updates when toast state changes
 * - **Toast Creation**: Provides the `toast()` function for creating notifications
 * - **Batch Dismissal**: Can dismiss all toasts or specific toasts by ID
 * - **Memory Management**: Handles proper cleanup of listeners
 *
 * ## Return Value
 * - `toasts`: Array of current toast objects
 * - `toast()`: Function to create new toast notifications
 * - `dismiss()`: Function to dismiss toasts (all or by ID)
 *
 * @returns Toast state and control functions
 *
 * @example
 * ```tsx
 * function NotificationButton() {
 *   const { toast, toasts, dismiss } = useToast();
 *
 *   const showSuccess = () => {
 *     toast({
 *       title: 'Success!',
 *       description: 'Operation completed successfully.',
 *       variant: 'success'
 *     });
 *   };
 *
 *   const clearAll = () => {
 *     dismiss(); // Dismisses all toasts
 *   };
 *
 *   return (
 *     <div>
 *       <button onClick={showSuccess}>Show Success</button>
 *       <button onClick={clearAll}>Clear All ({toasts.length})</button>
 *     </div>
 *   );
 * }
 *
 * // Usage in a form component
 * function ContactForm() {
 *   const { toast } = useToast();
 *
 *   const handleSubmit = async (data) => {
 *     try {
 *       await submitForm(data);
 *       toast({
 *         title: 'Form Submitted',
 *         description: 'We\'ll get back to you soon!',
 *         variant: 'success'
 *       });
 *     } catch (error) {
 *       toast({
 *         title: 'Submission Failed',
 *         description: 'Please check your connection and try again.',
 *         variant: 'error',
 *         action: <ToastAction altText="Retry">Retry</ToastAction>
 *       });
 *     }
 *   };
 *
 *   // ... form JSX
 * }
 * ```
 *
 * ## Usage Notes
 * - Must be used within a component tree that includes `<Toaster />`
 * - Toast state is global - changes affect all components using this hook
 * - Toasts are automatically cleaned up after the configured delay
 * - Consider UX best practices: don't overwhelm users with too many toasts
 */
declare const useToast: () => {
  toast: ({
    ...props
  }: Toast) => {
    id: string;
    dismiss: () => void;
    update: (props: ToasterToast) => void;
  };
  dismiss: (toastId?: string) => void;
  toasts: ToasterToast[];
};
//#endregion
export { reducer, toast, useToast };
//# sourceMappingURL=useToast.d.ts.map