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

const DEFAULT_HTML: string | null = "<div data-c42-progress-track>\n    <div data-c42-progress-indicator></div>\n  </div>\n  <span data-c42-progress-label></span>";

export interface ProgressProps extends Partial<ProgressOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `progress:change` — detail: `{ value, min, max, percent, indeterminate }` */
  onChange?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function Progress(props: ProgressProps) {
  const { as, className, children, onChange, value, min, max, indeterminate, label, ...rest } = props;
  const options = { value, min, max, indeterminate, label } as ProgressOptions;

  return (
    <C42
      controller={ProgressController}
      options={options}
      deps={[value, min, max, indeterminate, label]}
      events={{
        'progress:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-progress': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
