import { SilentRequest } from '@azure/msal-browser';

/**
 * A Hook to define an event handler with an always-stable function identity.
 * @param handler
 * @returns
 * @see https://github.com/facebook/react/issues/14099#issuecomment-440013892
 * @see https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md#internal-implementation
 */
declare function useEventCallback<T extends (...args: any[]) => any>(handler: T): T;

declare enum TokenType {
    id = "id",
    access = "access"
}
interface IGetTokenOptions {
    tokenType?: TokenType;
    requestConfigs?: SilentRequest;
}
type GetToken = (opts?: IGetTokenOptions) => Promise<string | undefined>;
declare class RequestInProgressError extends Error {
    constructor();
}

declare const useFetchWithStatus: <T>(input: string | URL | globalThis.Request, init?: RequestInit) => {
    isLoading: boolean;
    _fetch: (payload?: RequestInit, getTokenOpts?: IGetTokenOptions) => Promise<T>;
};

declare const useFetchWithToken: (tokenRequestConfigs?: SilentRequest) => (input: string | URL | globalThis.Request, init?: RequestInit, getTokenOpts?: IGetTokenOptions) => Promise<Response>;

declare const useGetToken: (defaultRequestConfigs?: SilentRequest) => GetToken;

declare const sleep: (ms: number) => Promise<unknown>;

declare const getResponseData: <T>(response: Response) => Promise<T>;

export { type GetToken, type IGetTokenOptions, RequestInProgressError, TokenType, getResponseData, sleep, useEventCallback, useFetchWithStatus, useFetchWithToken, useGetToken };
