import * as react from 'react';
import { ReactElement } from 'react';
import { RouteObject } from 'react-router-dom';

declare class RouterUtil {
    routes: RoutesType;
    onRouteBefore?: OnRouteBeforeType;
    onRouteMount?: OnRouteMountType;
    onRouteUnMount?: OnRouteUnMountType;
    suspense: JSX.Element;
    constructor(option: RouterPropsType);
    createClientRoutes(routes: RoutesType): RouteObject[];
    private deleteSelfProperty;
    private lazyLoad;
}

interface MetaType {
    [propName: string]: any;
}
interface FunctionalImportType {
    (): any;
}
type ReactElementType = JSX.Element;
type Merge<T, U, X = Pick<U, Exclude<keyof U, keyof T & keyof U>>> = Pick<T & X, keyof T | keyof X>;
type RoutesItemType<T extends MetaType = MetaType> = Merge<{
    path?: string;
    redirect?: string;
    component?: FunctionalImportType;
    meta?: T;
    children?: RoutesItemType[];
    element?: JSX.Element | React.ReactNode | null;
}, RouteObject>;
type RoutesType<T extends MetaType = MetaType> = RoutesItemType<T>[];
type OnRouteBeforeResType = string | undefined;
interface OnRouteBeforeType {
    (payload: {
        pathname: string;
        meta: MetaType;
    }): OnRouteBeforeResType | Promise<OnRouteBeforeResType>;
}
type OnRouteMountType = (meta: MetaType) => void;
type OnRouteUnMountType = (meta: MetaType) => void;
interface RouterPropsType {
    routes: RoutesType;
    onRouteBefore?: OnRouteBeforeType;
    onRouteMount?: OnRouteMountType;
    onRouteUnMount?: OnRouteUnMountType;
    suspense?: ReactElementType;
    render?: (children: ReactElement | null) => ReactElement;
}
interface RouterType {
    (payload: RouterPropsType): JSX.Element;
}

declare function CreateRoutes({ routes, onRouteBefore, onRouteMount, suspense, render }: RouterPropsType): ReactElement<any, string | react.JSXElementConstructor<any>> | null;

export { CreateRoutes, type FunctionalImportType, type Merge, type MetaType, type OnRouteBeforeResType, type OnRouteBeforeType, type OnRouteMountType, type OnRouteUnMountType, type ReactElementType, type RouterPropsType, type RouterType, RouterUtil, type RoutesItemType, type RoutesType };
