import type { Ref } from 'vue';
import type { RouteMeta } from 'vue-router';

type $MouseEvent = MouseEvent & {
  myTarget?: $BubbleHTMLElement;
};

type $FocusEvent = FocusEvent & {
  myTarget?: $BubbleHTMLElement;
};

declare global {
  type TextAlignType = 'center' | 'end' | 'justify' | 'left' | 'match-parent' | 'right' | 'start';

  /** 无限滚动 */
  type $InfiniteScrollHTMLElement = HTMLElement & {
    /** 用于记录某个高度下是否触发了一次,防止重复触发 */
    triggerRecord?: Record<number, boolean>;
  };

  /** 触发Bubble弹出框的元素 */
  type $BubbleHTMLElement = HTMLElement & {
    /** 关闭弹出框 */
    hideBubble?: () => void;
    /** 弹出框的显示隐藏状态 */
    bubbleVisible?: Ref<boolean>;
    /** 是否在Focus事件中已经触发过 emit('clickfocus') */
    myIsFocusEmit?: boolean;
  };

  /** 触发Bubble弹出框的事件 */
  type $BubbleEvent = $FocusEvent | $MouseEvent;

  /** 安装应用事件 */
  type $BeforeinstallpromptEvent = Event & {
    prompt?: () => unknown;
  };

  type $TabbarRecordRaw = {
    path: string;
    fullPath: string;
    name: string;
    meta: RouteMeta;
  };
}
