import type { AspectRatio, Flip } from './player'
import type { Subtitle } from './subtitle'

export type Bar = 'loaded' | 'played' | 'hover'

export interface Events {
  'document:click': [event: Event]
  'document:mouseup': [event: Event]
  'document:keydown': [event: Event]
  'document:touchend': [event: Event]
  'document:touchmove': [event: Event]
  'document:mousemove': [event: Event]
  'document:pointerup': [event: Event]
  'document:contextmenu': [event: Event]
  'document:pointermove': [event: Event]
  'document:visibilitychange': [event: Event]
  'document:webkitfullscreenchange': [event: Event]

  'window:resize': [event: Event]
  'window:scroll': [event: Event]
  'window:orientationchange': [event: Event]

  'video:abort': [event: Event]
  'video:canplay': [event: Event]
  'video:canplaythrough': [event: Event]
  'video:complete': [event: Event]
  'video:durationchange': [event: Event]
  'video:emptied': [event: Event]
  'video:encrypted': [event: Event]
  'video:ended': [event: Event]
  'video:error': [error: Error]
  'video:loadeddata': [event: Event]
  'video:loadedmetadata': [event: Event]
  'video:loadstart': [event: Event]
  'video:pause': [event: Event]
  'video:play': [event: Event]
  'video:playing': [event: Event]
  'video:progress': [event: Event]
  'video:ratechange': [event: Event]
  'video:seeked': [event: Event]
  'video:seeking': [event: Event]
  'video:stalled': [event: Event]
  'video:suspend': [event: Event]
  'video:timeupdate': [event: Event]
  'video:volumechange': [event: Event]
  'video:waiting': [event: Event]

  'info': [state: boolean]
  'layer': [state: boolean]
  'loading': [state: boolean]
  'mask': [state: boolean]
  'subtitle': [state: boolean]
  'contextmenu': [state: boolean]
  'control': [state: boolean]
  'setting': [state: boolean]
  'hotkey': [event: KeyboardEvent]

  'destroy': []

  'subtitleOffset': [offset: number]
  'subtitleBeforeUpdate': [cue: VTTCue]
  'subtitleAfterUpdate': [cue: VTTCue]
  'subtitleLoad': [cues: VTTCue[], option: Subtitle]

  'focus': [event: Event]
  'blur': [event: Event]
  'dblclick': [event: Event]
  'click': [event: Event]
  'hover': [state: boolean, event: Event]
  'mousemove': [event: Event]

  'resize': []
  'view': [state: boolean]
  'lock': [state: boolean]
  'aspectRatio': [aspectRatio: AspectRatio]
  'autoHeight': [height: number]
  'autoSize': [size: { width: number, height: number }]
  'ready': []
  'airplay': []
  'raf': []

  'error': [error: Error, reconnectTime: number]
  'flip': [flip: Flip]
  'fullscreen': [state: boolean]
  'fullscreenError': [event: Event]
  'fullscreenWeb': [state: boolean]
  'mini': [state: boolean]
  'pause': []
  'pip': [state: boolean]
  'play': []
  'screenshot': [dataUri: string]
  'seek': [currentTime: number, time: number]
  'restart': [url: string]
  'muted': [state: boolean]
  'setBar': [type: Bar, percentage: number, event?: Event | undefined]
  'keydown': [event: KeyboardEvent]
}
