import type { HttpRequestMethod, HttpRequestType, HttpResponseType } from '../enums/PlayerExports';
import type { HttpHeaders } from './PlayerConfig';
export type StreamDataType = ArrayBuffer | string;
export type HttpRequestBody = ArrayBuffer | ArrayBufferView | Blob | FormData | string | Document | URLSearchParams;
export interface StreamResponse<T> {
    done: boolean;
    value?: T;
}
export interface HttpRequest {
    method: HttpRequestMethod;
    url: string;
    headers: HttpHeaders;
    body?: HttpRequestBody;
    responseType: HttpResponseType;
    credentials: 'omit' | 'same-origin' | 'include';
}
export interface HttpResponseTiming {
    sendTimestamp?: number;
    openedTimestamp?: number;
    headersReceivedTimestamp?: number;
    progressTimestamp?: number;
    doneTimestamp?: number;
}
export interface RequestProgress {
    loadedBytes: number;
    totalBytes: number;
    url?: string;
    elapsedTime?: number;
    segmentDuration?: number;
    responseTiming?: HttpResponseTiming;
}
export interface HttpResponse<ResponseBody extends HttpResponseBody> {
    request: HttpRequest;
    url: string;
    headers: HttpHeaders;
    status: number;
    statusText: string;
    body?: ResponseBody;
    length?: number;
    timeToFirstByte?: number;
    elapsedTime?: number;
}
export interface Stream<T extends StreamDataType> {
    read(): Promise<StreamResponse<T>>;
    getType(): string;
}
export interface RequestController<T extends HttpResponseBody> {
    cancel(): void;
    setProgressListener(listener: (requestProgress: RequestProgress) => void): void;
    getResponse(): Promise<HttpResponse<T>>;
}
export type HttpResponseBody = string | ArrayBuffer | Blob | object | Document | Stream<StreamDataType>;
export interface NetworkConfig {
    preprocessHttpRequest?: (type: HttpRequestType, request: HttpRequest) => Promise<HttpRequest>;
    sendHttpRequest?: <T extends HttpResponseBody>(type: HttpRequestType, request: HttpRequest) => RequestController<T> | undefined | null;
    retryHttpRequest?: <T extends HttpResponseBody>(type: HttpRequestType, response: HttpResponse<T>, retry: number) => Promise<HttpRequest>;
    preprocessHttpResponse?: <T extends HttpResponseBody>(type: HttpRequestType, response: HttpResponse<T>) => Promise<HttpResponse<T>>;
}
