// AUTO-GENERATED by scripts/generate-wrappers.mjs — do not edit by hand.
// Source: packages/core/manifest.json (component "toast").
import type { ElementType, ReactNode } from 'react';
import { Toaster as ToasterController, type ToasterOptions } from '@42/core/toast';
import { C42 } from '../C42';

const DEFAULT_HTML: string | null = null;

export interface ToasterProps extends Partial<ToasterOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `toast:show` — detail: `(no detail)` */
  onShow?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `toast:dismiss` — detail: `{ id: string }` */
  onDismiss?: (detail: { id: string }, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function Toaster(props: ToasterProps) {
  const { as, className, children, onShow, onDismiss, position, duration, max, ...rest } = props;
  const options = { position, duration, max } as ToasterOptions;

  return (
    <C42
      controller={ToasterController}
      options={options}
      deps={[position, duration, max]}
      events={{
        'toast:show': onShow,
        'toast:dismiss': onDismiss,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-toast-region': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
