import type { AppType, AppTypeEnum, FrameworkOption, SDKInfo } from '../../../types/commonData';
import css from 'css';
import { ApiItem } from '../../../common/bridge/types';
import { Param } from '../webClient/preload/ttTypes';
import { InitData } from './ui';
import { ProjectStorage } from '../../../types/storage';
import { GadgetPlatform, GadgetPCMode } from '../../../types/upload';
import { FileList } from './sdk';
import { ServerApiMap as BaseApiMap } from '../../../common/baseSdk/api';
export declare enum TransferApi {
    preloadFiles = "preloadFiles",
    getFileContent = "getFileContent",
    getFilePath = "getFilePath",
    compile = "compile",
    login = "login",
    checkSession = "checkSession",
    updateStorage = "updateStorage",
    getStorage = "getStorage",
    getFrameworkOption = "getFrameworkOption",
    sendStorageMessage = "sendStorageMessage",
    saveFile = "saveFile",
    getUserInfo = "getUserInfo",
    openExternalUrl = "openExternalUrl",
    gadgetPageLifeCycle = "gadgetPageLifeCycle",
    gadgetPagePerformance = "gadgetPagePerformance",
    findPageFrameBindData = "findPageFrameBindData",
    analyzeCSS = "analyzeCSS",
    getStaticPort = "getStaticPort",
    removeDirectory = "removeDirectory",
    getProjectName = "getProjectName",
    getProjectDetail = "getProjectDetail",
    changeAppId = "changeAppId",
    switchCompile = "switchCompile",
    updateSdk = "updateSdk",
    previewApp = "previewApp",
    debugApp = "debugApp",
    stopDebugApp = "stopDebugApp",
    getAppVersion = "getAppVersion",
    uploadApp = "uploadApp",
    switchProject = "switchProject",
    getClipboardData = "getClipboardData",
    eventTrack = "eventTrack",
    getDebugTenantList = "getDebugTenantList",
    switchDebugTenant = "switchDebugTenant",
    getDebugAccount = "getDebugAccount",
    getAppDataFromPartition = "getAppDataFromPartition",
    setAppDataFromPartition = "setAppDataFromPartition",
    startPerformance = "startPerformance",
    stopPerformance = "stopPerformance"
}
export declare enum UIApi {
    navigateTo = "navigateTo",
    navigateBack = "navigateBack",
    redirectTo = "redirectTo",
    reLaunch = "reLaunch",
    switchTab = "switchTab",
    setNavigationBarTitle = "setNavigationBarTitle",
    setNavigationBarColor = "setNavigationBarColor",
    showToast = "showToast",
    hideToast = "hideToast",
    showTabBar = "showTabBar",
    hideTabBar = "hideTabBar",
    showTabBarRedDot = "showTabBarRedDot",
    hideTabBarRedDot = "hideTabBarRedDot",
    setTabBarBadge = "setTabBarBadge",
    removeTabBarBadge = "removeTabBarBadge",
    setTabBarItem = "setTabBarItem",
    setTabBarStyle = "setTabBarStyle",
    showActionSheet = "showActionSheet",
    showPrompt = "showPrompt",
    showModal = "showModal",
    insertHTMLWebView = "insertHTMLWebView",
    removeHTMLWebView = "removeHTMLWebView",
    updateHTMLWebView = "updateHTMLWebView",
    showPickerView = "showPickerView",
    showMultiPickerView = "showMultiPickerView",
    showDatePickerView = "showDatePickerView",
    showRegionPickerView = "showRegionPickerView",
    previewImage = "previewImage",
    openSchema = "openSchema",
    updateMultiPickerView = "updateMultiPickerView",
    openSetting = "openSetting",
    exitMiniProgram = "exitMiniProgram",
    showRichText = "showRichText",
    operateAudio = "operateAudio",
    emitReload = "emitReload",
    startCompass = "startCompass",
    stopCompass = "stopCompass",
    enableAccelerometer = "enableAccelerometer",
    operateRecorder = "operateRecorder",
    showShareMenu = "showShareMenu",
    hideShareMenu = "hideShareMenu",
    showDebugger = "showDebugger",
    hideDebugger = "hideDebugger",
    transferMessage = "transferMessage",
    sessionExpired = "sessionExpired",
    setPageOrientation = "setPageOrientation"
}
export declare enum StorageApi {
    getStorage = "getStorage",
    getStorageSync = "getStorageSync",
    setStorage = "setStorage",
    setStorageSync = "setStorageSync",
    removeStorage = "removeStorage",
    removeStorageSync = "removeStorageSync",
    clearStorage = "clearStorage",
    clearStorageSync = "clearStorageSync",
    getStorageInfo = "getStorageInfo",
    getStorageInfoSync = "getStorageInfoSync"
}
export declare enum WebviewApi {
    startPullDownRefresh = "startPullDownRefresh",
    stopPullDownRefresh = "stopPullDownRefresh"
}
export type NetworkType = 'request' | 'uploadFile' | 'connectSocket' | 'downloadFile';
export type NetworkTimeout = {
    [key in NetworkType]: number;
};
export interface WebviewApiMap {
    [TransferApi.preloadFiles]: ApiItem<{
        sources: string[];
        cachedFilePaths: string[];
    }, FileList[], {}>;
    [TransferApi.getFileContent]: ApiItem<{
        src: string;
    }, {
        content: string;
    }, {}>;
    [TransferApi.getFilePath]: ApiItem<{
        name: string;
    }, {
        content: string;
    }, {}>;
    windowReload: ApiItem<{}, {}, {}>;
    [TransferApi.findPageFrameBindData]: ApiItem<{
        path: string;
    }, string[], {}>;
    [TransferApi.analyzeCSS]: ApiItem<{
        path: string;
    }, css.Stylesheet | undefined, {}>;
}
export interface UIApiMap {
    [UIApi.openSchema]: ApiItem<Param<'openSchema'>, void, string>;
    [UIApi.navigateTo]: ApiItem<Param<'navigateTo'>, void, string>;
    [UIApi.navigateBack]: ApiItem<Param<'navigateBack'>, void, string>;
    [UIApi.redirectTo]: ApiItem<Param<'redirectTo'>, void, string>;
    [UIApi.reLaunch]: ApiItem<Param<'reLaunch'>, void, string>;
    [UIApi.switchTab]: ApiItem<Param<'switchTab'>, void, string>;
    [UIApi.setNavigationBarTitle]: ApiItem<Param<'setNavigationBarTitle'>, void, string>;
    [UIApi.setNavigationBarColor]: ApiItem<Param<'setNavigationBarColor'>, void, string>;
    [UIApi.showToast]: ApiItem<Param<'showToast'>, void, string>;
    [UIApi.hideToast]: ApiItem<Param<'hideToast'>, void, string>;
    [UIApi.showTabBar]: ApiItem<Param<'showTabBar'>, void, string>;
    [UIApi.hideTabBar]: ApiItem<Param<'hideTabBar'>, void, string>;
    [UIApi.showTabBarRedDot]: ApiItem<Param<'showTabBarRedDot'>, void, string>;
    [UIApi.hideTabBarRedDot]: ApiItem<Param<'hideTabBarRedDot'>, void, string>;
    [UIApi.setTabBarBadge]: ApiItem<Param<'setTabBarBadge'>, void, string>;
    [UIApi.removeTabBarBadge]: ApiItem<Param<'removeTabBarBadge'>, void, string>;
    [UIApi.setTabBarItem]: ApiItem<Param<'setTabBarItem'>, void, string>;
    [UIApi.setTabBarStyle]: ApiItem<Param<'setTabBarStyle'>, void, string>;
    [UIApi.showActionSheet]: ApiItem<Param<'showActionSheet'>, {
        tapIndex: number;
    }, string>;
    [UIApi.showModal]: ApiItem<Param<'showModal'>, {
        confirm: boolean;
        cancel: boolean;
    }, string>;
    [UIApi.showPrompt]: ApiItem<Param<'showPrompt'>, {
        confirm: boolean;
        cancel: boolean;
        inputValue: string;
    }, string>;
    [UIApi.openSetting]: ApiItem<Param<'openSetting'>, {
        callbackId: number;
        authSetting: object;
    }, string>;
    [UIApi.exitMiniProgram]: ApiItem<Param<'exitMiniProgram'>, void, string>;
    [UIApi.showRichText]: ApiItem<Param<'showRichText'>, {}, string>;
    [UIApi.operateAudio]: ApiItem<Param<'operateAudio'>, void, string>;
    [UIApi.emitReload]: ApiItem<Param<'emitReload'>, void, string>;
    [UIApi.startCompass]: ApiItem<Param<'startCompass'>, void, string>;
    [UIApi.stopCompass]: ApiItem<Param<'stopCompass'>, void, string>;
    [UIApi.enableAccelerometer]: ApiItem<Param<'enableAccelerometer'>, void, string>;
    [UIApi.operateRecorder]: ApiItem<Param<'operateRecorder'>, void, string>;
    [UIApi.showShareMenu]: ApiItem<Param<'showShareMenu'>, void, string>;
    [UIApi.hideShareMenu]: ApiItem<Param<'hideShareMenu'>, void, string>;
    [UIApi.showDebugger]: ApiItem<Param<'showDebugger'>, void, string>;
    [UIApi.hideDebugger]: ApiItem<Param<'hideDebugger'>, void, string>;
    [UIApi.transferMessage]: ApiItem<{
        channel: string;
        data: object;
    }, void, string>;
    [UIApi.sessionExpired]: ApiItem<Param<'sessionExpired'>, void, void>;
}
type UpdateStorageKey = 'appData' | 'simulatorConfig' | 'cookies';
export type UpdateStorageParam<T extends UpdateStorageKey = UpdateStorageKey> = {
    key: T;
    data: Partial<ProjectStorage[T]>;
    root?: boolean;
};
interface BgNodeApiMap {
    [TransferApi.updateStorage]: ApiItem<UpdateStorageParam, {}, string>;
    [TransferApi.sendStorageMessage]: ApiItem<({
        key: string;
        value: string;
        type: 'change' | 'new' | 'remove' | 'clear';
    } | {
        id: number;
        type: 'transfer';
        entries: Array<any> | undefined;
    }) & {
        sessionId: string;
    }, {}, string>;
    [TransferApi.getStorage]: ApiItem<{
        key: keyof ProjectStorage;
    }, Partial<ProjectStorage[keyof ProjectStorage]>, string>;
    [TransferApi.getFrameworkOption]: ApiItem<{}, FrameworkOption, string>;
    [TransferApi.getStaticPort]: ApiItem<{}, {
        port: number;
    }, string>;
    [TransferApi.getProjectName]: ApiItem<{}, {
        projectName: string;
    }, {}>;
    [TransferApi.getProjectDetail]: ApiItem<{}, {
        appId: string;
        projectName: string;
        compilePath: string;
        targetPath: string;
        codeSize: number;
        projectEditable: boolean;
        lastPreview?: {
            time?: number;
        };
        lastUpload?: {
            time?: number;
            version?: string;
        };
        sdkList?: SDKInfo[];
        sdkVersion?: string;
        sdkPath?: string;
        useNPM?: boolean;
        compileType?: string;
        pluginRoot?: string;
        enableWebviewSafeDomain?: boolean;
        needSubPackage?: boolean;
    }, {}>;
    [TransferApi.changeAppId]: ApiItem<{
        appType: AppType;
        appId: string;
    }, {}, {}>;
    [TransferApi.switchCompile]: ApiItem<{
        useUpgrade: boolean;
        minimumVersion: string;
    }, {}, {}>;
    [TransferApi.updateSdk]: ApiItem<{
        version: string;
    }, void, {}>;
    toggleWatch: ApiItem<{
        watch: boolean;
    }, {
        watch: boolean;
    }, {}>;
    getMockAPI: ApiItem<{}, {
        [k: string]: any[];
    }, {}>;
    [TransferApi.previewApp]: ApiItem<{
        platform: GadgetPlatform;
        mode?: GadgetPCMode;
        watch?: boolean;
        debug?: boolean;
        traceId?: string;
    }, undefined | {
        url?: string;
        warnMsgs?: string[];
    }, {}>;
    [TransferApi.startPerformance]: ApiItem<{
        platform?: GadgetPlatform;
        mode?: GadgetPCMode;
        traceId?: string;
        appType: AppTypeEnum;
    }, undefined | {}, {}>;
    [TransferApi.stopPerformance]: ApiItem<{}, undefined | {}, {}>;
    [TransferApi.debugApp]: ApiItem<{
        platform?: GadgetPlatform;
        mode?: GadgetPCMode;
        traceId?: string;
        appType: AppTypeEnum;
    }, undefined | {}, {}>;
    [TransferApi.stopDebugApp]: ApiItem<{}, undefined | {}, {}>;
    [TransferApi.getAppVersion]: ApiItem<{}, undefined | {
        [k: string]: string;
    }, {}>;
    [TransferApi.uploadApp]: ApiItem<{
        platform: GadgetPlatform;
        version?: string;
        description: string;
        type?: 'gadget-nav' | 'gadget-plugin';
        traceId?: string;
    }, undefined | {
        url: string;
    }, {}>;
    [TransferApi.switchProject]: ApiItem<{
        compilePath: string;
    }, void, {}>;
}
interface NodeApiMap extends BgNodeApiMap {
    compile: ApiItem<{}, {}, {}>;
    watchFile: ApiItem<{}, {}, {}>;
    openExternalUrl: ApiItem<{
        schema: string;
    }, {}, string>;
    removeDirectory: ApiItem<{
        type: string[];
    }, {}, {}>;
}
export interface BgApiMap extends WebviewApiMap, UIApiMap, BgNodeApiMap {
}
export interface ServerApiMap extends WebviewApiMap, NodeApiMap, BaseApiMap {
    getInitData: ApiItem<{}, InitData, {}>;
}
export type AppApiMap = WebviewApiMap & BgApiMap & ServerApiMap;
export {};
