export interface SelectOption<T = string> {
  value: T;
  label: string;
  hint?: string;
}

export interface MultiSelectOption<T = string> extends SelectOption<T> {
  selected?: boolean;
}

export interface ProgressHandle {
  update(message: string): void;
  stop(message?: string): void;
}

export interface WizardPrompter {
  intro(message: string): void;
  outro(message: string): void;
  note(message: string, title?: string): void;
  log(message: string): void;
  warn(message: string): void;

  text(opts: {
    message: string;
    placeholder?: string;
    defaultValue?: string;
    /** Prefills the input buffer so the user sees the value and can press Enter to accept. */
    initialValue?: string;
    validate?: (value: string) => string | void;
  }): Promise<string>;

  confirm(opts: { message: string; initialValue?: boolean }): Promise<boolean>;

  select<T>(opts: { message: string; options: SelectOption<T>[]; initialValue?: T }): Promise<T>;

  multiselect<T>(opts: {
    message: string;
    options: MultiSelectOption<T>[];
    required?: boolean;
  }): Promise<T[]>;

  groupMultiselect<T>(opts: {
    message: string;
    options: Record<string, MultiSelectOption<T>[]>;
    required?: boolean;
  }): Promise<T[]>;

  spinner(): ProgressHandle;

  separator(): void;
}
