import { URLPattern } from "urlpattern-polyfill";
import type { DurableServiceWorkerRegistration } from "./container";
import { FetchFn } from "./execute-fetch";
export type RouterSourceEnum = "network" | "cache" | "fetch-event" | "race-network-and-fetch-handler";
export type RunningStatusEnum = "running" | "stopped";
export type RouterSourceBehaviorEnum = "finish-with-success" | "continue-discarding-latter-results";
export interface URLPatternInit {
    baseURL?: string;
    username?: string;
    password?: string;
    protocol?: string;
    hostname?: string;
    port?: string;
    pathname?: string;
    search?: string;
    hash?: string;
}
export interface RouterSource {
    type: RouterSourceEnum;
    behaviorEnum?: RouterSourceBehaviorEnum;
}
export interface RouterRaceNetworkAndFetchHandlerSource extends RouterSource {
    type: "race-network-and-fetch-handler";
    tag?: string;
}
export interface RouterNetworkSource extends RouterSource {
    type: "network";
    updatedCacheName?: string;
    cacheErrorResponse?: boolean;
}
export interface RouterCacheSource extends RouterSource {
    type: "cache";
    cacheName?: string;
    request?: RequestInfo;
}
export interface RouterFetchEventSource extends RouterSource {
    type: "fetch-event";
    id?: string;
    tag?: string;
}
export interface RouterURLPatternCondition {
    urlPattern: URLPattern | string | URLPatternInit;
}
export interface RouterRequestMethodCondition {
    requestMethod: string;
}
export interface RouterRequestModeCondition {
    requestMode: RequestMode;
}
export interface RouterRequestDestinationCondition {
    requestDestination: RequestDestination;
}
export type RouterRequestCondition = RouterRequestMethodCondition | RouterRequestModeCondition | RouterRequestDestinationCondition;
export interface RouterTimeCondition {
    timeFrom?: number;
    timeTo?: number;
}
export interface RouterAndCondition {
    and: RouterCondition[];
}
export interface RouterNotCondition {
    not: RouterCondition;
}
export interface RouterRunningStatusCondition {
    runningStatus: RunningStatusEnum;
}
export interface RouterOrCondition {
    or: RouterCondition[];
}
export type RouterCondition = RouterURLPatternCondition | RouterRequestCondition | RouterTimeCondition | RouterRunningStatusCondition | RouterAndCondition | RouterOrCondition | RouterNotCondition;
export type RouterRuleSource = RouterNetworkSource | RouterSource | RouterCacheSource | RouterFetchEventSource | RouterRaceNetworkAndFetchHandlerSource | RouterSourceEnum;
export interface RouterRule {
    condition: RouterCondition | RouterCondition[];
    source: RouterRuleSource | RouterRuleSource[];
}
export type AddRoutesOptions = RouterRule | RouterRule[];
export declare function isRouterURLPatternCondition(condition: RouterCondition): condition is RouterURLPatternCondition;
export declare function isRouterRequestMethodCondition(condition: RouterCondition): condition is RouterRequestMethodCondition;
export declare function isRouterRequestModeCondition(condition: RouterCondition): condition is RouterRequestModeCondition;
export declare function isRouterRequestDestinationCondition(condition: RouterCondition): condition is RouterRequestDestinationCondition;
export declare function isRouterCacheSource(source: RouterRuleSource): source is RouterCacheSource;
export declare function isRouterRequestCondition(condition: RouterCondition): condition is RouterRequestCondition;
export declare function isRouterTimeCondition(condition: RouterCondition): condition is RouterTimeCondition;
export declare function isRouterRunningStatusCondition(condition: RouterCondition): condition is RouterRunningStatusCondition;
export declare function isRouterAndCondition(condition: RouterCondition): condition is RouterAndCondition;
export declare function isRouterOrCondition(condition: RouterCondition): condition is RouterOrCondition;
export declare function isRouterNotCondition(condition: RouterCondition): condition is RouterNotCondition;
export declare function isRouterSourceObject(source: RouterRuleSource): source is RouterSource;
export declare function isRouterSourceType<T extends RouterSourceEnum>(source: RouterRuleSource, type: T): source is RouterRuleSource & {
    type: T;
} | T;
export declare function isRouterNetworkSource(source: RouterRuleSource): source is RouterNetworkSource;
export declare function getServiceWorkerRoutesStore(serviceWorkerId?: string): import("../../data").KeyValueStore<RouterRule>;
export declare function addRoutes(rules: AddRoutesOptions): Promise<void>;
export declare function listRoutes(serviceWorkerId?: string): Promise<RouterRule[]>;
export interface RouteMatchConditionOptions {
    baseURL: string;
}
export declare function isRouteMatchCondition({ baseURL }: RouteMatchConditionOptions, route: RouterRule, input: RequestInfo | URL, init?: RequestInit): boolean;
export declare function createRouter(serviceWorkers: DurableServiceWorkerRegistration[]): Promise<FetchFn>;
