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

const DEFAULT_HTML: string | null = "<img data-c42-viewer-image src=\"photo.jpg\" />\n  <button data-c42-viewer-zoom-in>+</button>\n  <button data-c42-viewer-zoom-out>−</button>\n  <button data-c42-viewer-expand>⛶</button>";

export interface ImageViewerProps extends Partial<ImageViewerOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `image-viewer:zoom` — detail: `(no detail)` */
  onZoom?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function ImageViewer(props: ImageViewerProps) {
  const { as, className, children, onZoom, minZoom, maxZoom, expanded, ...rest } = props;
  const options = { minZoom, maxZoom, expanded } as ImageViewerOptions;

  return (
    <C42
      controller={ImageViewerController}
      options={options}
      deps={[minZoom, maxZoom, expanded]}
      events={{
        'image-viewer:zoom': onZoom,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-image-viewer': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
