// Type definitions for the Moyan SEE JavaScript SDK 1.0.0
// Moyan SEE · a Moyan AI Product — https://see.moyanai.app

export declare const VERSION: string;

export type MeetingMode = "video" | "audio";

export interface Meeting {
  id: string;
  title: string;
  agenda: string | null;
  room_code: string;
  scheduled_at: string;
  duration_minutes: number;
  mode: MeetingMode;
  created_at: string;
  join_url: string;
}

export interface CreateMeetingInput {
  title: string;
  agenda?: string;
  /** ISO 8601 string or epoch milliseconds. Defaults to now. */
  scheduled_at?: string | number;
  /** 5–1440. Defaults to 30. */
  duration_minutes?: number;
  /** Custom room code, up to 12 characters. */
  room_code?: string;
  /** "audio" for a voice call, "video" (default) for a video meeting. */
  mode?: MeetingMode;
}

export interface UsageReportInput {
  /** Meeting length in minutes (0–1440). */
  minutes: number;
  /** Number of people who attended (0–1000). */
  participants: number;
  /** Optional room code for your own bookkeeping. */
  room_code?: string;
  /**
   * Stream quality, which sets the billing weight:
   * audio 1x, hd 4x, fullhd 8x, 2k 16x. Defaults to "hd".
   */
  quality?: "audio" | "hd" | "fullhd" | "2k";
  /** True when the meeting was recorded (adds the recording weight). */
  recording?: boolean;
}

export interface UsageSnapshot {
  calls: { limit: number; used: number; remaining: number };
  participantMinutes: { limit: number; used: number; remaining: number };
}

export declare class MoyanSeeError extends Error {
  status: number;
  body: unknown;
}

export interface ClientOptions {
  /** Server-side only. Create keys at https://see.moyanai.app/developers */
  apiKey: string;
  baseUrl?: string;
  fetch?: typeof fetch;
  timeoutMs?: number;
}

export interface MoyanSeeClient {
  meetings: {
    create(input: CreateMeetingInput): Promise<Meeting>;
    list(): Promise<Meeting[]>;
  };
  usage: {
    report(
      input: UsageReportInput,
    ): Promise<
      UsageSnapshot & {
        participant_minutes_reported: number;
        participant_minutes_charged: number;
        participant_minutes_recorded: number;
        estimated_cost_usd: number;
        quality: "audio" | "hd" | "fullhd" | "2k";
        recording: boolean;
      }
    >;
    get(): Promise<UsageSnapshot>;
  };
  createAudioCall(input: Omit<CreateMeetingInput, "mode">): Promise<Meeting>;
  request(method: string, path: string, body?: unknown): Promise<any>;
}

export declare function createClient(options: ClientOptions): MoyanSeeClient;

/** Design customisation applied inside the meeting room. */
export interface MeetingTheme {
  /** Base colour scheme. */
  theme?: "dark" | "light";
  /** Primary / action colour, any CSS colour (e.g. "#ff6a00"). */
  accent?: string;
  /** Page background colour. */
  bg?: string;
  /** Panel / card surface colour. */
  surface?: string;
  /** Main text colour. */
  text?: string;
  /** Corner radius in px (0–48). */
  radius?: number;
  /** Font family stack. */
  font?: string;
}

export interface JoinOptions {
  mode?: MeetingMode;
  baseUrl?: string;
  theme?: MeetingTheme;
}

export declare function joinUrl(roomCode: string, options?: JoinOptions): string;

export interface EmbedOptions extends JoinOptions {
  container: Element | string;
  roomCode: string;
  height?: string;
  width?: string;
  allowFullScreen?: boolean;
  /** CSS class applied to the iframe. */
  className?: string;
  /** Inline styles merged onto the iframe. */
  style?: Partial<CSSStyleDeclaration>;
  /** Iframe corner radius, defaults to "16px". */
  borderRadius?: string;
}

export declare function embedMeeting(options: EmbedOptions): {
  iframe: HTMLIFrameElement;
  destroy: () => void;
};

export declare function openMeeting(roomCode: string, options?: JoinOptions): Window | null;
