import { UIApi } from './api';
import { CompileModeConfig, ToolBox, MockPanel, ApplicationType, DebugAccountInfo, DebugTenant } from '../../../types/commonData';
export { CompileModeConfig } from '../../../types/commonData';
export interface NavigationConf {
    navigationBarBackgroundColor?: string;
    navigationBarTextStyle?: 'black' | 'white';
    navigationBarTitleText?: string;
    transparentTitle?: 'none' | 'always' | 'auto';
    navigationStyle?: 'default' | 'custom';
}
export interface AppWindowConf extends NavigationConf {
    backgroundColor?: string;
    backgroundTextStyle?: 'dark' | 'light';
    backgroundColorTop?: string;
    backgroundColorBottom?: string;
    enablePullDownRefresh?: boolean;
    onReachBottomDistance?: number;
}
export interface TabBarListProps {
    pagePath: string;
    text: string;
    iconPath?: string;
    selectedIconPath?: string;
    badgeText?: string;
    redDot?: boolean;
}
export interface AppConfig {
    pages: string[];
    entryPagePath: string;
    global: {
        window: AppWindowConf;
    };
    page: {
        [k: string]: {
            window: AppWindowConf & {
                usingComponents: {
                    [k: string]: string;
                };
            };
        };
    };
    tabBar?: {
        color?: string;
        selectedColor?: string;
        backgroundColor?: string;
        borderStyle?: 'black' | 'white';
        position?: 'bottom' | 'top';
        PCMode?: string;
        list: TabBarListProps[];
    };
    debug: false;
    networkTimeout: {
        request: number;
        uploadFile: number;
        connectSocket: number;
        downloadFile: number;
    };
    appId: string;
    extAppid: string;
    customClose: false;
    ext: {
        defaultPages: {
            sidebarMode: string;
            PCMode: string;
        };
    };
    navigateToMiniProgramAppIdList: string[];
    permission: {};
    ttLaunchApp: {};
}
interface EventParam<I, O> {
    input: I;
    output: O extends void ? I : O;
}
export interface OpenPageInfo {
    path: string;
    query: {
        [k: string]: any;
    };
    webviewId: number;
    type: 'documentReady';
    openType: 'appLaunch' | 'navigateTo' | 'redirectTo' | 'navigateBack' | 'switchTab' | 'reLaunch' | 'openSchema';
    device: SimulatorConfig['device'];
    extraInfo: Record<string, unknown>;
}
export interface PageParam {
    base: AppWindowConf | false;
    info: OpenPageInfo;
    tabBar: AppConfig['tabBar'] | false;
    isDevtools?: boolean;
}
export type PageAction = {
    type: 'remove' | 'hide';
    id: number;
} | {
    type: 'create' | 'show';
    data: PageParam;
    extra?: any;
} | {
    type: 'initBg';
    data: BgInitData;
};
export type ToastIcon = 'success' | 'loading' | 'info' | 'error' | 'warning' | 'none';
export interface ShowRichTextParam {
    content?: string;
    placeholder?: string;
    userModelSelect?: object;
    avatar?: string;
    at?: {}[];
    picture?: string[];
    showEmoji?: boolean;
    enablesReturnKey?: boolean;
    show?: boolean;
}
export interface OnRichTextSelectRes {
    content: string;
    userModelSelect?: string;
    at?: {}[];
    picture?: string[];
}
export type OperateAudioType = 'play' | 'pause' | 'stop' | 'seek' | 'destroy';
export interface OperateAudioParam {
    audioId: number;
    operationType?: OperateAudioType;
    currentTime?: number;
}
export interface InnerAudioContext {
    audioId: number;
    src: string;
    startTime: number;
    autoplay: boolean;
    loop: boolean;
    obeyMuteSwitch: boolean;
    duration: number;
    currentTime: number;
    paused: boolean;
    buffered: number;
    volume: number;
}
export interface InnerAudioParam {
    operate: OperateAudioParam;
    context: InnerAudioContext;
}
export interface RecordParam {
    operate: 'start' | 'pause' | 'resume' | 'stop';
    options?: {
        duration: number;
        sampleRate: number;
        numberOfChannels: number;
        encodeBitRate: number;
        format: string;
        frameSize: number;
    };
}
export interface EffectParam {
    iframe: HTMLIFrameElement;
    id: number;
}
export type ShowPickerView = UIApi.showPickerView | UIApi.showMultiPickerView | UIApi.showDatePickerView | UIApi.showRegionPickerView;
export interface EventMap {
    [UIApi.navigateBack]: EventParam<PageAction[], void>;
    [UIApi.navigateTo]: EventParam<PageAction[], EffectParam>;
    [UIApi.switchTab]: EventParam<PageAction[], EffectParam | null>;
    [UIApi.redirectTo]: EventParam<[PageAction, PageAction], EffectParam>;
    [UIApi.reLaunch]: EventParam<PageAction[], EffectParam>;
    appLaunch: EventParam<PageAction[], [EffectParam, EffectParam]>;
    [UIApi.setNavigationBarTitle]: EventParam<{
        title: string;
    }, void>;
    [UIApi.setNavigationBarColor]: EventParam<{
        frontColor: string;
        backgroundColor: string;
        textStyle?: 'black' | 'white';
    }, void>;
    [UIApi.showTabBar]: EventParam<{
        animation: boolean;
    }, void>;
    [UIApi.hideTabBar]: EventParam<{
        animation: boolean;
    }, void>;
    [UIApi.setTabBarItem]: EventParam<{
        index: number;
        text: string;
        iconPath: string;
        selectedIconPath: string;
    }, void>;
    [UIApi.setTabBarStyle]: EventParam<{
        color: string;
        selectedColor: string;
        backgroundColor: string;
        borderStyle: 'black' | 'white';
    }, void>;
    [UIApi.showTabBarRedDot]: EventParam<{
        index: number;
    }, void>;
    [UIApi.hideTabBarRedDot]: EventParam<{
        index: number;
    }, void>;
    [UIApi.setTabBarBadge]: EventParam<{
        index: number;
        text: string;
    }, void>;
    [UIApi.removeTabBarBadge]: EventParam<{
        index: number;
    }, void>;
    [UIApi.showToast]: EventParam<{
        title: string;
        icon: ToastIcon;
        duration: number;
        mask: boolean;
    }, void>;
    [UIApi.hideToast]: EventParam<{}, void>;
    [UIApi.showActionSheet]: EventParam<{
        itemList: string[];
        callbackId: number;
    }, void>;
    [UIApi.showPrompt]: EventParam<{
        title?: string;
        placeholder?: string;
        maxLength?: number;
        confirmText?: string;
        cancelText?: string;
        callbackId: number;
    }, void>;
    [UIApi.showModal]: EventParam<{
        title?: string;
        content?: string;
        confirmText?: string;
        showCancel?: boolean;
        cancelText?: string;
        callbackId: number;
    }, void>;
    [UIApi.insertHTMLWebView]: EventParam<{
        position?: {
            left: number;
            top: number;
            width: number;
            height: number;
        };
        progressBarColor?: string;
        htmlId: number;
        callbackId: number;
    }, void>;
    [UIApi.updateHTMLWebView]: EventParam<{
        htmlId?: number;
        src?: string;
    }, void>;
    [UIApi.removeHTMLWebView]: EventParam<{
        htmlId?: number;
    }, void>;
    [UIApi.showPickerView]: EventParam<{
        show: boolean;
        array?: string[] | string[][];
        current?: number | number[] | string | string[];
        callbackId: number;
        rangeKey?: string;
        range?: {
            start: string;
            end: string;
        };
        mode?: string;
        fields?: string;
        customItem?: string;
        ev?: ShowPickerView;
        webviewId?: number;
    }, void>;
    [UIApi.updateMultiPickerView]: EventParam<{
        column: number;
        array: string[];
        current: string;
        callbackId: number;
    }, void>;
    [UIApi.previewImage]: EventParam<{
        urls: string[];
        header?: {};
        current?: string;
    }, void>;
    [UIApi.openSchema]: EventParam<PageAction[], EffectParam>;
    [UIApi.openSetting]: EventParam<{
        callbackId: number;
    }, void>;
    [UIApi.exitMiniProgram]: EventParam<void, void>;
    [UIApi.showRichText]: EventParam<ShowRichTextParam, void>;
    [UIApi.operateAudio]: EventParam<InnerAudioParam, void>;
    [UIApi.emitReload]: EventParam<void, void>;
    [UIApi.startCompass]: EventParam<void, void>;
    [UIApi.stopCompass]: EventParam<void, void>;
    [UIApi.enableAccelerometer]: EventParam<{
        enable: boolean;
    }, void>;
    [UIApi.operateRecorder]: EventParam<RecordParam, void>;
    [UIApi.showShareMenu]: EventParam<void, void>;
    [UIApi.hideShareMenu]: EventParam<void, void>;
    [UIApi.showDebugger]: EventParam<void, void>;
    [UIApi.hideDebugger]: EventParam<void, void>;
    [UIApi.sessionExpired]: EventParam<void, void>;
    appIDChange: EventParam<{}, void>;
    login: EventParam<{}, void>;
    logout: EventParam<{}, void>;
    updateSimulatorConfig: EventParam<Partial<SimulatorConfig> & {
        isReload?: boolean;
    }, void>;
    refresh: EventParam<null | void, InitData>;
    recompile: EventParam<{}, {}>;
    appLoading: EventParam<{}, void>;
    updateNetwork: EventParam<{
        value: string;
    }, void>;
    windowReload: EventParam<void, void>;
    beforeCompile: EventParam<void, void>;
    compileStart: EventParam<{
        type: string;
        date: number;
    }, void>;
    compileEnd: EventParam<{
        date: number;
    }, void>;
    compileErr: EventParam<{
        msg: string;
        date: number;
    }, void>;
    refreshFinish: EventParam<{}, void>;
    debuggerInit: EventParam<{}, void>;
    debuggerWaiting: EventParam<{
        mobileDebugUrl: string;
    }, void>;
    debuggerStarting: EventParam<{}, void>;
    debuggerRunning: EventParam<{}, void>;
    debuggerOver: EventParam<{}, void>;
    debuggerError: EventParam<{}, void>;
    debuggerVersionInvalid: EventParam<{}, void>;
    performanceInit: EventParam<{}, void>;
    performanceWaiting: EventParam<{
        mobileDebugUrl: string;
    }, void>;
    performanceConnecting: EventParam<{}, void>;
    performanceRunning: EventParam<{}, void>;
    performanceEnd: EventParam<{}, void>;
    performanceClose: EventParam<{}, void>;
    performanceVersionInvalid: EventParam<{}, void>;
    performanceError: EventParam<{}, void>;
}
export interface ExecMap {
    refresh: [];
    appLaunch: [];
    appIDChange: [];
    login: [];
    logout: [];
    [UIApi.navigateBack]: [number] | [];
    [UIApi.navigateTo]: [string];
    [UIApi.redirectTo]: [string];
    [UIApi.reLaunch]: [string];
    [UIApi.switchTab]: [string];
    [UIApi.openSchema]: [string];
    recompile: [];
    [UIApi.showActionSheet]: [EventMap[UIApi.showActionSheet]['input']];
    [UIApi.showToast]: [EventMap[UIApi.showToast]['input']];
    [UIApi.sessionExpired]: [EventMap[UIApi.sessionExpired]['input']];
    updateSimulatorConfig: [EventMap['updateSimulatorConfig']['input']];
    updateNetwork: [EventMap['updateNetwork']['input']];
    getAppConfig: [];
    getSimulatorConfig: [];
    windowReload: [];
    beforeCompile: [];
    compileStart: [EventMap['compileStart']['input']];
    compileEnd: [EventMap['compileEnd']['input']];
    compileErr: [EventMap['compileErr']['input']];
    pageStack: [];
    debuggerInit: [EventMap['debuggerInit']];
    debuggerWaiting: [EventMap['debuggerWaiting']];
    debuggerStarting: [EventMap['debuggerInit']];
    debuggerRunning: [EventMap['debuggerRunning']];
    debuggerOver: [EventMap['debuggerOver']];
    debuggerError: [EventMap['debuggerError']];
    debuggerVersionInvalid: [EventMap['debuggerVersionInvalid']];
    showDebugger: [EventMap['showDebugger']];
    hideDebugger: [EventMap['hideDebugger']];
    performanceInit: [EventMap['performanceInit']];
    performanceWaiting: [EventMap['performanceWaiting']];
    performanceConnecting: [EventMap['performanceConnecting']];
    performanceRunning: [EventMap['performanceRunning']];
    performanceEnd: [EventMap['performanceEnd']];
    performanceClose: [EventMap['performanceClose']];
    performanceVersionInvalid: [EventMap['performanceVersionInvalid']];
    performanceError: [EventMap['performanceError']];
}
type ConfList<D> = {
    name: string;
    value: D;
}[];
export interface Device {
    width: number;
    height: number;
    dpr: number;
    name: string;
    system: string;
    platform: string;
    userAgent: string;
    statusBarHeight?: number;
    showNotch?: boolean;
    showHomeIndicator?: boolean;
    safeArea?: {
        right: number;
        top: number;
        left: number;
        bottom: number;
        width: number;
        height: number;
    };
    windowWidth?: number;
    windowHeight?: number;
}
export type Orientation = 'portrait' | 'landscape';
export interface SimulatorConfig {
    network: number;
    networkList: ConfList<SimulatorConfig['network']>;
    device: Device;
    customDevice: {
        name: string;
        value: Device;
    };
    deviceList: ConfList<SimulatorConfig['device']>;
    scale: number;
    scaleList: ConfList<SimulatorConfig['scale']>;
    scene: number;
    sceneList: ConfList<SimulatorConfig['scene']>;
    autoRefresh: boolean;
    toolBox: ToolBox;
    onUserCaptureScreen: boolean;
    compileModeConfig: CompileModeConfig;
    updateReady: boolean;
    mockPanel: MockPanel;
    isRotate: boolean;
    orientation: Orientation;
    allowRotation: boolean;
    enableWebviewSafeDomain: boolean;
    darkMode: 'dark' | 'light';
    debugAccountInfo: DebugAccountInfo;
    appID: string;
    applicationType: ApplicationType;
    debugTenantList: DebugTenant[];
}
export interface InitData {
    appConfig: AppConfig;
    simulatorConfig: Partial<SimulatorConfig>;
    appState: {};
    compileInfo: {
        pathId: string;
        port: number;
        extraInfo?: {
            autoTestFlag: boolean;
        };
    };
}
export interface BgInitData {
    appConfig: AppConfig;
    storage: any;
    systemInfo: {
        systemEnv: string;
        projectHash: string;
        isDevtools?: boolean;
        headless?: boolean;
        device: Device;
        network: number;
        language?: string;
        sdkVersion?: string;
        orientation?: 'landscape' | 'portrait';
    };
    launchOption: {
        scene: number;
        path: string;
        query: Record<string, number | string>;
    };
    extraInfo?: {
        runningSpace: string;
        mockPanel: MockPanel;
    };
}
