export interface IFluidPlayer {
    domRef: DomRef;
    version: string;
    homepage: string;
    destructors: ((this: IFluidPlayer) => void)[];
    init: (this: IFluidPlayer, playerTarget: HTMLVideoElement | string, options: unknown) => void;
    getCurrentVideoDuration: () => number;
    getCurrentTime: () => number;
    toggleLoader: (showLoader?: boolean) => void;
    sendRequest: (
        url: unknown,
        withCredentials: unknown,
        timeout: unknown,
        functionReadyStateChange: unknown
    ) => void;
    displayOptions: DisplayOptions;
    sendRequestAsync: (
        url: unknown,
        withCredentials: unknown,
        timeout: unknown
    ) => Promise<unknown>;
    announceLocalError: (code: unknown, msg: unknown) => void;
    debugMessage: (...msg: unknown[]) => void;
    onMainVideoEnded: (event: unknown) => void;
    isCurrentlyPlayingAd: unknown;
    autoplayAfterAd: boolean;
    mainVideoDuration: unknown;
    adKeytimePlay: (keyTime: unknown) => void;
    timer: number | null;
    switchToMainVideo: () => void;
    playPauseToggle: () => void;
    displaySuggestedVideos: () => void;
    mainVideoCurrentTime: unknown;
    getCurrentSrc: () => null | string;
    getCurrentSrcType: () => null | string;
    onRecentWaiting: () => void;
    recentWaiting: boolean;
    onFluidPlayerPause: () => void;
    checkShouldDisplayVolumeBar: () => boolean;
    getMobileOs: () => { userOS: string };
    generateCustomControlTags: (options: unknown) => CustomControls;
    detectLiveStream: () => void;
    isLiveStream: () => boolean;
    showLiveIndicator: () => void;
    currentVideoDuration: number;
    controlPlayPauseToggle: () => void;
    playPauseAnimationToggle: (play: any) => void;
    isSwitchingSource: boolean;
    contolProgressbarUpdate: () => void;
    controlDurationUpdate: () => void;
    formatTime: (time: number) => void;
    hlsPlayer: false | HLSPlayer;
    contolVolumebarUpdate: () => void;
    latestVolume: number;
    fluidStorage: { fluidMute?: boolean; fluidVolume?: unknown };
    muteToggle: () => void;
    checkFullscreenSupport: () =>
        | false
        | {
              goFullscreen: string;
              exitFullscreen: string;
              isFullscreen: string;
          };
    fullscreenOff: (
        fullscreenButton: unknown[],
        menuOptionFullscreen: null
    ) => void;
    fullscreenMode: boolean;
    fullscreenOn: (
        fullscreenButton: unknown,
        menuOptionFullscreen: unknown
    ) => void;
    fullscreenToggle: () => void;
    findClosestParent: (el: unknown, selector: unknown) => null;
    getTranslateX: (el: unknown) => number;
    getEventOffsetX: (evt: unknown, el: unknown) => number;
    getEventOffsetY: (evt: unknown, el: unknown) => number;
    onProgressbarMouseDown: (event: unknown) => void;
    onVolumeBarMouseDown: () => void;
    findRoll: (roll: unknown) => string[] | undefined;
    onKeyboardVolumeChange: (direction: unknown) => void;
    onKeyboardSeekPosition: (keyCode: unknown) => void;
    getNewCurrentTimeValueByKeyCode: (
        keyCode: unknown,
        currentTime: unknown,
        duration: unknown
    ) => unknown;
    handleMouseleave: (event: unknown) => void;
    handleMouseenterForKeyboard: () => void;
    keyboardControl: () => void;
    handleWindowClick: (event: unknown) => void;
    initialPlay: () => void;
    setCustomControls: () => void;
    createTimePositionPreview: () => void;
    setCustomContextMenu: () => void;
    setDefaultLayout: () => void;
    initSkipControls: () => void;
    handleOrientationChange: () => void;
    initSkipAnimationElements: () => void;
    initDoubleTapSkip: () => void;
    skipRelative: (timeOffset: number) => void;
    checkIfVolumebarIsRendered: () => boolean;
    setLayout: () => void;
    handleFullscreen: () => void;
    setupPlayerWrapper: () => HTMLDivElement;
    onErrorDetection: () => void;
    createVideoSourceSwitch: (initialLoad?: boolean) => void;
    openCloseVideoSourceSwitch: () => void;
    setVideoSource: (url: unknown) => false | undefined;
    setCurrentTimeAndPlay: (
        newCurrentTime: unknown,
        shouldPlay: unknown
    ) => void;
    initTitle: () => void;
    hasTitle: () => unknown;
    hideTitle: () => void;
    showTitle: () => void;
    initLogo: () => void;
    initHtmlOnPauseBlock: () => void;
    initPlayButton: () => void;
    mainVideoReady: () => void;
    userActivityChecker: () => void;
    hasControlBar: () => boolean;
    isControlBarVisible: () => boolean;
    setVideoPreload: () => void;
    hideControlBar: () => void;
    showControlBar: (event: unknown) => void;
    linkControlBarUserActivity: () => void;
    initMute: () => void;
    initLoop: () => void;
    setBuffering: () => void;
    createPlaybackList: () => void;
    openCloseVideoPlaybackRate: () => void;
    createDownload: () => void;
    theatreToggle: () => void;
    defaultTheatre: () => void;
    posterImage: () => void;
    nextSource: () => null | undefined;
    inIframe: () => boolean;
    setPersistentSettings: (ignoreMute?: boolean) => false | undefined;
    play: () => true | undefined;
    pause: () => boolean;
    skipTo: (time: unknown) => void;
    setPlaybackSpeed: (speed: unknown) => void;
    setVolume: (passedVolume: unknown) => void;
    isCurrentlyPlayingVideo: (instance: HTMLVideoElement) => boolean;
    setHtmlOnPauseBlock: (passedHtml: unknown) => false | undefined;
    toggleControlBar: (show: unknown) => void;
    on: (eventCall: unknown, callback: unknown) => void;
    toggleLogo: (logo: unknown) => false | undefined;
    trackEvent: (
        el: unknown,
        evt: unknown,
        sel: unknown,
        handler: unknown
    ) => void;
    registerListener: (
        el: unknown,
        evt: unknown,
        sel: unknown,
        handler: unknown
    ) => void;
    copyEvents: (topLevelEl: unknown) => void;
    resetDisplayMode: (
        displayTarget: "fullScreen" | "theaterMode" | "miniPlayer"
    ) => void;
    destroy: () => void;
    setCTAFromVast: (titleCtaElement: HTMLElement, tmpOptions: unknown) => void;
    getClickThroughUrlFromLinear: (linear: HTMLElement) => unknown;
    getVastAdTagUriFromWrapper: (xmlResponse: HTMLElement) => unknown;
    hasInLine: (xmlResponse: HTMLElement) => number | false;
    hasVastAdTagUri: (xmlResponse: HTMLElement) => number | false;
    getClickThroughUrlFromNonLinear: (nonLinear: HTMLElement) => string;
    getTrackingFromLinear: (
        linear: HTMLElement
    ) => never[] | HTMLCollectionOf<Element>;
    getDurationFromLinear: (linear: HTMLElement) => unknown;
    getDurationFromNonLinear: (tag: HTMLElement) => number;
    getDimensionFromNonLinear: (tag: HTMLElement) => {
        width: null;
        height: null;
    };
    getCreativeTypeFromStaticResources: (tag: HTMLElement) => string;
    getMediaFilesFromLinear: (
        linear: HTMLElement
    ) => HTMLCollectionOf<Element> | never[];
    getStaticResourcesFromNonLinear: (linear: HTMLElement) => unknown[];
    extractNodeDataByTagName: (
        parentNode: HTMLElement,
        tagName: string
    ) => string | null;
    extractNodeData: (parentNode: HTMLElement) => string;
    getAdParametersFromLinear: (linear: HTMLElement) => string | null;
    getMediaFileListFromLinear: (linear: HTMLElement) => unknown[];
    getIconClickThroughFromLinear: (linear: HTMLElement) => string;
    getStaticResourceFromNonLinear: (linear: HTMLElement) => string | undefined;
    registerTrackingEvents: (
        creativeLinear: unknown,
        tmpOptions: unknown
    ) => void;
    registerClickTracking: (
        clickTrackingTag: unknown,
        tmpOptions: unknown
    ) => void;
    registerViewableImpressionEvents: (
        viewableImpressionTags: unknown,
        tmpOptions: unknown
    ) => void;
    registerImpressionEvents: (
        impressionTags: unknown,
        tmpOptions: unknown
    ) => void;
    registerErrorEvents: (errorTags: unknown, tmpOptions: unknown) => void;
    announceError: (code: unknown) => void;
    getClickTrackingEvents: (linear: unknown) => string[] | undefined;
    getNonLinearClickTrackingEvents: (
        nonLinear: unknown
    ) => string[] | undefined;
    callUris: (uris: unknown) => void;
    recalculateAdDimensions: () => void;
    prepareVast: (roll: unknown) => void;
    playMainVideoWhenVastFails: (errorCode: unknown) => void;
    switchPlayerToVastMode: () => void;
    processVastWithRetries: (vastObj: unknown) => void;
    processUrl: (
        vastTag: unknown,
        callBack: unknown,
        rollListId: unknown
    ) => void;
    resolveVastTag: (
        vastTag: unknown,
        numberOfRedirects: unknown,
        tmpOptions: unknown,
        callback: unknown,
        rollListId: unknown
    ) => any;
    setVastList: () => void;
    onVastAdEnded: (event: unknown) => void;
    vastLogoBehaviour: (vastPlaying: unknown) => void;
    deleteVastAdElements: () => void;
    renderLinearAd: (ad: unknown, backupTheVideoTime: unknown) => void;
    playRoll: (adList: unknown) => void;
    backupMainVideoContentTime: (rollListId: unknown) => void;
    getSupportedMediaFileObject: (mediaFiles: unknown) => unknown;
    getMediaFileTypeSupportLevel: (
        mediaType: unknown
    ) => "maybe" | "probably" | "no" | null;
    scheduleTrackingEvent: (currentTime: unknown, duration: unknown) => void;
    trackSingleEvent: (eventType: unknown, eventSubType: unknown) => void;
    completeNonLinearStatic: (ad: unknown) => void;
    createNonLinearStatic: (ad: unknown) => void;
    createVpaidNonLinearBoard: (ad: unknown) => void;
    createNonLinearBoard: (ad: unknown) => void;
    createBoard: (ad: unknown) => void;
    closeNonLinear: (adId: unknown) => void;
    rollGroupContainsLinear: (groupedRolls: unknown) => boolean;
    rollGroupContainsNonlinear: (groupedRolls: unknown) => boolean;
    preRollFail: () => void;
    preRollSuccess: () => void;
    preRollAdsPlay: () => void;
    preRoll: (event: unknown) => void;
    createAdMarker: (adListId: unknown, time: unknown) => void;
    hideAdMarker: (adListId: unknown) => void;
    showAdMarkers: () => void;
    hideAdMarkers: () => void;
    midRoll: (event: unknown) => void;
    postRoll: (event: unknown) => void;
    onPauseRoll: (event: unknown) => void;
    hasValidOnPauseAd: () => unknown;
    toggleOnPauseAd: () => void;
    trackingOnPauseNonLinearAd: (ad: unknown, status: unknown) => void;
    getLinearAdsFromKeyTime: (keyTimeLinearObj: unknown) => unknown[];
    adTimer: () => void;
    scheduleTask: (task: {
        time: number;
        rollListId: unknown;
        loadVast: unknown;
    }) => void;
    scheduleOnDemandRolls: () => void;
    getNextAdPod: () => unknown;
    checkForNextAd: () => void;
    addSkipButton: () => void;
    addAdCountdown: () => void;
    decreaseAdCountdown: () => void;
    removeAdCountdown: () => void;
    toggleAdCountdown: (showing: unknown) => void;
    addAdPlayingText: (textToShow: unknown) => void;
    positionTextElements: (adListData: unknown) => void;
    removeAdPlayingText: () => void;
    addCTAButton: (landingPage: string) => unknown;
    createAndAppendCTAButton: (
        adCTAText: string,
        displayUrl: string,
        trackingUrl: string
    ) => void;
    removeCTAButton: () => void;
    decreaseSkipOffset: () => void;
    pressSkipButton: () => void;
    removeSkipButton: () => void;
    addClickthroughLayer: () => void;
    removeClickthrough: () => void;
    isTimer: unknown;
    vrROTATION_POSITION: number;
    vrROTATION_SPEED: number;
    vrMode: boolean;
    vrPanorama: null;
    vrViewer: null;
    vpaidTimer: null;
    vpaidAdUnit: null;
    vastOptions: null;
    videoPlayerId: string;
    originalSrc: string | null;
    firstPlayLaunched: boolean;
    suppressClickthrough: boolean;
    timelinePreviewData: unknown[];
    timerPool: Record<string, unknown>;
    rollsById: Record<string, unknown>;
    adPool: Record<string, unknown>;
    adGroupedByRolls: Record<string, unknown>;
    onPauseRollAdPods: unknown[];
    currentOnPauseRollAd: string;
    preRollAdsResolved: boolean;
    preRollAdPods: unknown[];
    preRollAdPodsLength: number;
    preRollVastResolved: number;
    temporaryAdPods: unknown[];
    availableRolls: ["preRoll", "midRoll", "postRoll", "onPauseRoll"];
    supportedNonLinearAd: ["300x250", "468x60", "728x90"];
    nonLinearDuration: number;
    supportedStaticTypes: ["image/gif", "image/jpeg", "image/png"];
    inactivityTimeout: null;
    isUserActive: null;
    nonLinearVerticalAlign: "bottom";
    vpaidNonLinearCloseButton: boolean;
    showTimeOnHover: boolean;
    initialAnimationSet: boolean;
    theatreMode: boolean;
    theatreModeAdvanced: boolean;
    originalWidth: number;
    originalHeight: number;
    dashPlayer: boolean;
    dashScriptLoaded: boolean;
    hlsScriptLoaded: boolean;
    isPlayingMedia: boolean;
    isLoading: boolean;
    isInIframe: boolean;
    mainVideoReadyState: boolean;
    xmlCollection: unknown[];
    inLineFound: null;
    fluidPseudoPause: boolean;
    mobileInfo: { userOS: string };
    events: Record<string, unknown>;
    timeSkipOffsetAmount: number;
    currentMediaSourceType: "source";
}

export interface DomRef {
    player: null | HTMLVideoElement;
    wrapper?: null | HTMLDivElement;
}

export interface DisplayOptions {
    onBeforeXMLHttpRequestOpen: (request: XMLHttpRequest) => void;
    onBeforeXMLHttpRequest: (request: XMLHttpRequest) => void;
    debug: boolean;
    layoutControls: ILayoutControls;
    suggestedVideos: { configUrl: null };
    vastOptions: IVastOptions;
    captions: ICaptions;
    hls: IHLSOptions;
    modules: {
        configureHls: (options: unknown) => typeof options;
        onBeforeInitHls: (hls: unknown) => unknown;
        onAfterInitHls: (hls: unknown) => unknown;
        configureDash: (options: unknown) => typeof options;
        onBeforeInitDash: (dash: unknown) => void;
        onAfterInitDash: (dash: unknown) => void;
    };
}

interface ILayoutControls {
    mediaType: string | null;
    primaryColor: boolean;
    posterImage: boolean;
    posterImageSize: "contain";
    adProgressColor: string;
    playButtonShowing: boolean;
    playPauseAnimation: boolean;
    closeButtonCaption: "Close"; // Remove?
    fillToContainer: boolean;
    autoPlay: boolean;
    preload: "auto";
    mute: boolean;
    loop: null;
    keyboardControl: boolean;
    allowDownload: boolean;
    playbackRateEnabled: boolean;
    subtitlesEnabled: boolean;
    subtitlesOnByDefault: boolean;
    showCardBoardView: boolean;
    showCardBoardJoystick: boolean;
    allowTheatre: boolean;
    doubleclickFullscreen: boolean;
    autoRotateFullScreen: boolean;
    theatreSettings: ITheatreOptions;
    theatreAdvanced: {
        theatreElement: null;
    };
    title: null;
    logo: ILogoOptions;
    controlBar: {
        autoHide: false;
        autoHideTimeout: 3;
        animated: true;
        playbackRates: ["x2", "x1.5", "x1", "x0.5"];
    };
    timelinePreview: {
        spriteImage: false;
        spriteRelativePath: false;
    };
    htmlOnPauseBlock: {
        html: null;
        height: null;
        width: null;
    };
    layout: "default"; //options: 'default', '<custom>'
    playerInitCallback: () => void;
    persistentSettings: {
        volume: true;
        quality: true;
        speed: true;
        theatre: true;
    };
    controlForwardBackward: {
        show: false;
        doubleTapMobile: true;
    };
    contextMenu: {
        controls: true;
        links: [];
    };
    miniPlayer: {
        enabled: true;
        width: 400;
        height: 225;
        widthMobile: 50;
        placeholderText: "Playing in Miniplayer";
        position: "bottom right";
        autoToggle: false;
    };
    roundedCorners: 0;
}

interface ITheatreOptions {
    width: "100%";
    height: "60%";
    marginTop: number;
    horizontalAlign: "center";
    keepPosition: boolean;
}

interface ILogoOptions {
    imageUrl: null;
    position: "top left";
    clickUrl: null;
    opacity: 1;
    mouseOverImageUrl: null;
    imageMargin: "2px";
    hideWithControls: false;
    showOverAds: false;
}

interface ICaptions {
    play: "Play";
    pause: "Pause";
    mute: "Mute";
    unmute: "Unmute";
    fullscreen: "Fullscreen";
    subtitles: "Subtitles";
    exitFullscreen: "Exit Fullscreen";
}

interface IVastOptions {
    adList: Record<string, unknown>;
    skipButtonCaption: "Skip ad in [seconds]";
    skipButtonClickCaption: 'Skip Ad <span class="skip_button_icon"></span>';
    adText: null;
    adTextPosition: "top left";
    adCTAText: "Visit now!";
    adCTATextPosition: "bottom right";
    adCTATextVast: boolean;
    adClickable: boolean;
    vastTimeout: number;
    showProgressbarMarkers: boolean;
    allowVPAID: boolean;
    showPlayButton: boolean;
    maxAllowedVastTagRedirects: number;
    vpaidTimeout: number;

    vastAdvanced: {
        vastLoadedCallback: () => void;
        noVastVideoCallback: () => void;
        vastVideoSkippedCallback: () => void;
        vastVideoEndedCallback: () => void;
    };
}

interface CustomControls {
    loader: HTMLDivElement;
    root: HTMLDivElement;
    leftContainer: HTMLDivElement;
    playPause: HTMLDivElement;
    skipBack: HTMLDivElement;
    skipForward: HTMLDivElement;
    progressContainer: HTMLDivElement;
    progressWrapper: HTMLDivElement;
    progressCurrent: HTMLDivElement;
    progress_current_marker: HTMLDivElement;
    bufferedIndicator: HTMLDivElement;
    adMarkers: HTMLDivElement;
    rightContainer: HTMLDivElement;
    fullscreen: HTMLDivElement;
    miniPlayer: HTMLDivElement;
    theatre: HTMLDivElement;
    cardboard: HTMLDivElement;
    subtitles: HTMLDivElement;
    videoSource: HTMLDivElement;
    playbackRate: HTMLDivElement;
    download: HTMLDivElement;
    volumeContainer: HTMLDivElement;
    volume: HTMLDivElement;
    volumeCurrent: HTMLDivElement;
    volumeCurrentPos: HTMLDivElement;
    mute: HTMLDivElement;
    durationContainer: HTMLDivElement;
    duration: HTMLDivElement;
    live_indicator: HTMLDivElement;
}

interface IHLSOptions {
    overrideNative: boolean;
}

interface HLSPlayer {
    levels: { details: { live: unknown } }[];
}
