/*
 * @Author: xiejiang
 * @Date: 2024-11-05 10:14:56
 * @LastEditors: xiejiang
 * @LastEditTime: 2025-03-25 15:16:25
 * @Description:
 * Copyright（c）2024 by 好老师教育科技有限公司 All right Reserved.
 */
// Vue
declare module '*.vue' {
  import { DefineComponent } from 'vue'

  const component: DefineComponent<{}, {}, any>
  export default component
}

// markdown-it
declare module 'markdown-it'
declare module 'markdown-it-emoji'
declare module 'markdown-it-deflist'
declare module 'markdown-it-abbr'
declare module 'markdown-it-footnote'
declare module 'markdown-it-ins'
declare module 'markdown-it-mark'
declare module 'markdown-it-task-lists'
declare module 'markdown-it-container'
declare module 'markdown-it-toc-done-right'
declare module '@DatatracCorporation/markdown-it-mermaid'
declare module 'markdown-it-katex'

declare module 'jquery'

// jsx 报错
declare namespace JSX {
  interface IntrinsicElements {
    [elemName: string]: any
  }
}

/* Menu */
declare namespace Menu {
  interface MenuOptions {
    dataRange?: string | null
    icon: string
    menuId: string
    menuLevel: number
    menuName: string
    menuSign: string
    open?: boolean
    orderNum?: number
    parentID?: string
    selected: boolean
    children?: MenuOptions[]
  }
  interface MetaProps {
    title?: string
    activeMenu?: string
    affix?: boolean
    keepAlive?: boolean
  }
}

/* FileType */
declare namespace File {
  type ImageMimeType =
    | 'image/apng'
    | 'image/bmp'
    | 'image/gif'
    | 'image/jpeg'
    | 'image/pjpeg'
    | 'image/png'
    | 'image/svg+xml'
    | 'image/tiff'
    | 'image/webp'
    | 'image/x-icon'

  type ExcelMimeType = 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
}

/* Vite */
declare type Recordable<T = any> = Record<string, T>

declare interface ViteEnv {
  PUBLIC_USER_NODE_ENV: 'development' | 'production' | 'test'
  PUBLIC_GLOB_APP_TITLE: string
  PUBLIC_PORT: number
  PUBLIC_OPEN: boolean
  PUBLIC_REPORT: boolean
  PUBLIC_BUILD_COMPRESS: 'gzip' | 'brotli' | 'gzip,brotli' | 'none'
  PUBLIC_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean
  PUBLIC_DROP_CONSOLE: boolean
  PUBLIC_PUBLIC_PATH: string
  PUBLIC_API_URL: string
  PUBLIC_PROXY: [string, string][]
}

interface ImportMetaEnv extends ViteEnv {
  __: unknown
}

/* __APP_INFO__ */
declare const __APP_INFO__: {
  pkg: {
    name: string
    version: string
    dependencies: Recordable<string>
    devDependencies: Recordable<string>
  }
  lastBuildTime: string
}

/* Generic Tools */
type ObjToKeyValUnion<T> = {
  [K in keyof T]: { key: K; value: T[K] }
}[keyof T]

type ObjToKeyValArray<T> = {
  [K in keyof T]: [K, T[K]]
}[keyof T]

// 可能为null
declare type Nullable<T> = T | null

// 可能为undefined
declare type Voidable<T> = T | undefined

// 可能为null或者undefined
declare type NullableOrUndefined<T> = T | null | undefined

// 将对象中的属性部分变为可选
declare type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
