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

const DEFAULT_HTML: string | null = "<textarea data-c42-sms-input placeholder=\"Write an SMS…\"></textarea>\n  <div class=\"c42-sms-editor-status\">\n    <span data-c42-sms-counter></span>\n    <span data-c42-sms-segments></span>\n    <span data-c42-sms-encoding></span>\n    <!-- emoji affordance bottom-right (picker drops below) -->\n    <span class=\"c42-sms-editor-emoji\">\n      <button data-c42-sms-trigger aria-label=\"Emoji\">🙂</button>\n      <div data-c42-sms-picker hidden></div>\n    </span>\n  </div>\n  <!-- optional live preview (filled with the escaped message text) -->\n  <div data-c42-sms-preview></div>";

export interface SmsEditorProps extends Partial<SmsEditorOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `smseditor:change` — detail: `{ text, encoding, length, segments, remaining, overLimit }` */
  onChange?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function SmsEditor(props: SmsEditorProps) {
  const { as, className, children, onChange, value, maxLength, maxSegments, emojis, renderPicker, ...rest } = props;
  const options = { value, maxLength, maxSegments, emojis, renderPicker } as SmsEditorOptions;

  return (
    <C42
      controller={SmsEditorController}
      options={options}
      deps={[value, maxLength, maxSegments, emojis, renderPicker]}
      events={{
        'smseditor:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-sms-editor': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
