import { RenderFrameOptions } from "../preview/FrameController.js";
import { ReactiveController, ReactiveControllerHost } from "lit";

//#region src/gui/PlaybackController.d.ts
interface PlaybackHost extends HTMLElement, ReactiveControllerHost {
  currentTimeMs: number;
  durationMs: number;
  endTimeMs: number;
  /** Centralized frame controller (present on EFTimegroup) */
  frameController?: {
    renderFrame(timeMs: number, options?: RenderFrameOptions): Promise<void>;
    abort(): void;
  };
  renderAudio?(fromMs: number, toMs: number): Promise<AudioBuffer>;
  waitForMediaDurations?(signal?: AbortSignal): Promise<void>;
  saveTimeToLocalStorage?(time: number): void;
  loadTimeFromLocalStorage?(): number | undefined;
  requestUpdate(property?: string): void;
  updateComplete: Promise<boolean>;
  playing: boolean;
  loop: boolean;
  play(): void;
  pause(): void;
  playbackController?: PlaybackController;
  parentTimegroup?: any;
  rootTimegroup?: any;
}
type PlaybackControllerUpdateEvent = {
  property: "playing" | "loop" | "currentTimeMs";
  value: boolean | number;
};
/**
 * Manages playback state and audio-driven timing for root temporal elements
 *
 * Created automatically when a temporal element becomes a root (no parent timegroup)
 * Provides playback contexts (playing, loop, currentTimeMs, durationMs) to descendants
 * Handles:
 * - Audio-driven playback with Web Audio API
 * - Seek and frame rendering throttling
 * - Time state management with pending seek handling
 * - Playback loop behavior
 *
 * Works with any temporal element (timegroups or standalone media) via PlaybackHost interface
 */
declare class PlaybackController implements ReactiveController {
  #private;
  constructor(host: PlaybackHost);
  get currentTime(): number;
  set currentTime(time: number);
  get playing(): boolean;
  setPlaying(value: boolean): void;
  get loop(): boolean;
  setLoop(value: boolean): void;
  get currentTimeMs(): number;
  setCurrentTimeMs(value: number): void;
  play(): void;
  pause(): void;
  hostConnected(): void;
  hostDisconnected(): void;
  hostUpdated(): void;
  suspendSelfRender(): void;
  resumeSelfRender(): void;
  /**
   * Run frame rendering via FrameController, or directly on the host if it
   * implements FrameRenderable (standalone media element without a Timegroup).
   */
  runThrottledFrameTask(): Promise<void>;
  addListener(listener: (event: PlaybackControllerUpdateEvent) => void): void;
  removeListener(listener: (event: PlaybackControllerUpdateEvent) => void): void;
  remove(): void;
  setPendingAudioContext(context: AudioContext): void;
  private maybeLoopPlayback;
  private stopPlayback;
  private startPlayback;
}
//#endregion
export { PlaybackController };
//# sourceMappingURL=PlaybackController.d.ts.map