@netless/telebox-insider 1.0.0-alpha.1 → 1.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ declare type ValConfig = {
15
15
  draggable: Val<RequiredTeleBoxConfig["draggable"], boolean>;
16
16
  ratio: Val<RequiredTeleBoxConfig["ratio"], boolean>;
17
17
  };
18
- declare type ReadonlyValConfig = {
18
+ declare type PropsValConfig = {
19
19
  darkMode: RequiredTeleBoxConfig["darkMode$"];
20
20
  fence: RequiredTeleBoxConfig["fence$"];
21
21
  minimized: RequiredTeleBoxConfig["minimized$"];
@@ -24,6 +24,8 @@ declare type ReadonlyValConfig = {
24
24
  rootRect: RequiredTeleBoxConfig["rootRect$"];
25
25
  managerStageRect: RequiredTeleBoxConfig["managerStageRect$"];
26
26
  collectorRect: RequiredTeleBoxConfig["collectorRect$"];
27
+ };
28
+ declare type MyReadonlyValConfig = {
27
29
  zIndex: Val<RequiredTeleBoxConfig["zIndex"], boolean>;
28
30
  focus: Val<RequiredTeleBoxConfig["focus"], boolean>;
29
31
  $userContent: Val<TeleBoxConfig["content"], boolean>;
@@ -41,11 +43,11 @@ declare type ReadonlyValConfig = {
41
43
  contentRect: Val<TeleBoxRect>;
42
44
  contentStageRect: ReadonlyVal<TeleBoxRect | null>;
43
45
  };
44
- declare type CombinedValEnhancedResult = ReadonlyValEnhancedResult<ReadonlyValConfig> & ValEnhancedResult<ValConfig>;
46
+ declare type CombinedValEnhancedResult = ReadonlyValEnhancedResult<PropsValConfig & MyReadonlyValConfig> & ValEnhancedResult<ValConfig>;
45
47
  export interface TeleBox extends CombinedValEnhancedResult {
46
48
  }
47
49
  export declare class TeleBox {
48
- constructor({ id, title, namespace, visible, width, height, minWidth, minHeight, x, y, resizable, draggable, ratio, focus, zIndex, titleBar, content, footer, styles, highlightStage, darkMode$, fence$, minimized$, maximized$, readonly$, rootRect$, managerStageRect$, stageRatio$, collectorRect$, managerHighlightStage$, }: TeleBoxConfig);
50
+ constructor({ id, title, namespace, visible, width, height, minWidth, minHeight, x, y, resizable, draggable, ratio, focus, zIndex, titleBar, content, footer, styles, highlightStage, darkMode$, fence$, minimized$, maximized$, readonly$, root$, rootRect$, managerStageRect$, stageRatio$, collectorRect$, managerHighlightStage$, }: TeleBoxConfig);
49
51
  readonly id: string;
50
52
  /** ClassName Prefix. For CSS styling. Default "telebox" */
51
53
  readonly namespace: string;
@@ -149,14 +151,6 @@ export declare class TeleBox {
149
151
  * @returns this
150
152
  */
151
153
  protected transform(x: number, y: number, width: number, height: number, skipUpdate?: boolean): void;
152
- /**
153
- * Mount box to a container element.
154
- */
155
- mount(container: HTMLElement): void;
156
- /**
157
- * Unmount box from the container element.
158
- */
159
- unmount(): void;
160
154
  /**
161
155
  * Mount dom to box content.
162
156
  */
@@ -71,6 +71,8 @@ export interface TeleBoxConfig {
71
71
  readonly minimized$: ReadonlyVal<boolean, boolean>;
72
72
  /** Is box readonly */
73
73
  readonly readonly$: ReadonlyVal<boolean, boolean>;
74
+ /** Root element to mount boxes */
75
+ readonly root$: ReadonlyVal<HTMLElement | null>;
74
76
  /** Position and dimension of root element */
75
77
  readonly rootRect$: ReadonlyVal<TeleBoxRect>;
76
78
  /** Position and dimension of stage area */
@@ -7,7 +7,7 @@ import type { TeleBoxRect } from "../TeleBox/typings";
7
7
  export interface TeleBoxCollectorConfig {
8
8
  namespace?: string;
9
9
  styles?: TeleStyles;
10
- root?: HTMLElement;
10
+ root$: ReadonlyVal<HTMLElement | null>;
11
11
  minimized$: Val<boolean>;
12
12
  readonly$: ReadonlyVal<boolean>;
13
13
  darkMode$: ReadonlyVal<boolean>;
@@ -15,18 +15,20 @@ export interface TeleBoxCollectorConfig {
15
15
  }
16
16
  declare type ValConfig = {
17
17
  styles: Val<TeleStyles>;
18
- root: Val<HTMLElement | undefined>;
19
- el: Val<HTMLElement>;
18
+ $collector: Val<HTMLElement>;
20
19
  };
21
- declare type ReadonlyValConfig = {
20
+ declare type PropsValConfig = {
21
+ root: TeleBoxCollectorConfig["root$"];
22
+ };
23
+ declare type MyReadonlyValConfig = {
22
24
  rect: ReadonlyVal<TeleBoxRect | undefined>;
23
25
  visible: ReadonlyVal<boolean>;
24
26
  };
25
- declare type CombinedValEnhancedResult = ValEnhancedResult<ValConfig> & ReadonlyValEnhancedResult<ReadonlyValConfig>;
27
+ declare type CombinedValEnhancedResult = ValEnhancedResult<ValConfig> & ReadonlyValEnhancedResult<PropsValConfig & MyReadonlyValConfig>;
26
28
  export interface TeleBoxCollector extends CombinedValEnhancedResult {
27
29
  }
28
30
  export declare class TeleBoxCollector {
29
- constructor({ minimized$, readonly$, darkMode$, rootRect$, namespace, styles, root, }: TeleBoxCollectorConfig);
31
+ constructor({ minimized$, readonly$, darkMode$, rootRect$, namespace, styles, root$, }: TeleBoxCollectorConfig);
30
32
  readonly namespace: string;
31
33
  protected readonly _sideEffect: SideEffectManager;
32
34
  destroy(): void;
@@ -9,6 +9,7 @@ export interface MaxTitleBarConfig extends DefaultTitleBarConfig {
9
9
  darkMode$: ReadonlyVal<boolean>;
10
10
  boxes$: ReadonlyVal<TeleBox[]>;
11
11
  rootRect$: ReadonlyVal<TeleBoxRect>;
12
+ root$: ReadonlyVal<HTMLElement | null>;
12
13
  }
13
14
  export declare class MaxTitleBar extends DefaultTitleBar {
14
15
  constructor(config: MaxTitleBarConfig);
@@ -12,6 +12,7 @@ export * from "./constants";
12
12
  declare type ReadonlyValConfig = {
13
13
  darkMode: ReadonlyVal<boolean, boolean>;
14
14
  state: ReadonlyVal<TeleBoxState, boolean>;
15
+ root: Val<HTMLElement | null>;
15
16
  rootRect: Val<TeleBoxRect>;
16
17
  stageRect: ReadonlyVal<TeleBoxRect>;
17
18
  };
@@ -65,7 +66,6 @@ export declare class TeleBoxManager {
65
66
  dark_mode: boolean;
66
67
  }, never>;
67
68
  protected _sideEffect: SideEffectManager;
68
- protected root: HTMLElement;
69
69
  readonly namespace: string;
70
70
  /** @deprecated use setMaximized and setMinimized instead */
71
71
  setState(state: TeleBoxState, skipUpdate?: boolean): this;
@@ -77,6 +77,14 @@ export declare class TeleBoxManager {
77
77
  remove(boxOrID: string | TeleBox, skipUpdate?: boolean): ReadonlyTeleBox | undefined;
78
78
  removeTopBox(): ReadonlyTeleBox | undefined;
79
79
  removeAll(skipUpdate?: boolean): ReadonlyTeleBox[];
80
+ /**
81
+ * Mount manager to a container element.
82
+ */
83
+ mount(root: HTMLElement): void;
84
+ /**
85
+ * Unmount manager from the container element.
86
+ */
87
+ unmount(): void;
80
88
  destroy(skipUpdate?: boolean): void;
81
89
  wrapClassName(className: string): string;
82
90
  focusBox(boxOrID: string | TeleBox, skipUpdate?: boolean): void;
@@ -5,7 +5,7 @@ import type { TeleBoxCollector } from "../TeleBoxCollector";
5
5
  import type { TELE_BOX_MANAGER_EVENT } from "./constants";
6
6
  export interface TeleBoxManagerConfig extends Pick<TeleBoxConfig, "namespace"> {
7
7
  /** Element to mount boxes. */
8
- readonly root?: HTMLElement;
8
+ readonly root?: HTMLElement | null;
9
9
  /** Stage area height/with ratio. No ratio if <= 0. Default -1. */
10
10
  readonly stageRatio?: number;
11
11
  /** Where the minimized boxes go. */
@@ -1,10 +1,9 @@
1
1
  import "./style.scss";
2
2
  import type { ReadonlyVal } from "value-enhancer";
3
- import { Val } from "value-enhancer";
4
3
  import type { TeleBoxRect } from "../TeleBox/typings";
5
4
  export interface TeleStageConfig {
6
5
  namespace: string;
7
- root?: HTMLElement | null;
6
+ root$: ReadonlyVal<HTMLElement | null>;
8
7
  rootRect$: ReadonlyVal<TeleBoxRect>;
9
8
  ratio$: ReadonlyVal<number>;
10
9
  highlightStage$: ReadonlyVal<boolean>;
@@ -14,12 +13,9 @@ export declare class TeleStage {
14
13
  readonly namespace: string;
15
14
  readonly stageRect$: ReadonlyVal<TeleBoxRect>;
16
15
  readonly highlightStage$: ReadonlyVal<boolean>;
17
- readonly root$: Val<HTMLElement | null>;
18
16
  $boxStage?: HTMLDivElement;
19
- constructor({ namespace, rootRect$, ratio$, highlightStage$, root, }: TeleStageConfig);
17
+ constructor({ namespace, rootRect$, ratio$, highlightStage$, root$, }: TeleStageConfig);
20
18
  private render;
21
- mount($root: HTMLElement): void;
22
- unmount(): void;
23
19
  destroy(): void;
24
20
  wrapClassName(className: string): string;
25
21
  }
@@ -2,7 +2,7 @@ import "./style.scss";
2
2
  import { SideEffectManager } from "side-effect-manager";
3
3
  import type { TeleBoxState } from "../../TeleBox/typings";
4
4
  import type { TeleTitleBar, TeleTitleBarConfig, TeleTitleBarEvent } from "../typings";
5
- import { Val } from "value-enhancer";
5
+ import type { ReadonlyVal } from "value-enhancer";
6
6
  export declare type DefaultTitleBarButton = TeleTitleBarEvent & {
7
7
  readonly iconClassName: string;
8
8
  readonly isActive?: (state: TeleBoxState) => boolean;
@@ -11,12 +11,10 @@ export interface DefaultTitleBarConfig extends TeleTitleBarConfig {
11
11
  buttons?: ReadonlyArray<DefaultTitleBarButton>;
12
12
  }
13
13
  export declare class DefaultTitleBar implements TeleTitleBar {
14
- constructor({ readonly$, state$, title, buttons, onEvent, onDragStart, namespace, }: DefaultTitleBarConfig);
14
+ constructor({ readonly$, state$, title$, buttons, onEvent, onDragStart, namespace, }: DefaultTitleBarConfig);
15
15
  readonly namespace: string;
16
16
  $titleBar: HTMLElement | undefined;
17
17
  $dragArea: HTMLElement;
18
- get title(): string;
19
- setTitle(title: string): void;
20
18
  render(): HTMLElement;
21
19
  renderDragArea(): HTMLElement;
22
20
  dragHandle(): HTMLElement | undefined;
@@ -25,7 +23,7 @@ export declare class DefaultTitleBar implements TeleTitleBar {
25
23
  onEvent?: TeleTitleBarConfig["onEvent"];
26
24
  onDragStart?: TeleTitleBarConfig["onDragStart"];
27
25
  protected readonly$: TeleTitleBarConfig["readonly$"];
28
- protected title$: Val<string>;
26
+ protected title$: ReadonlyVal<string>;
29
27
  protected buttons: ReadonlyArray<DefaultTitleBarButton>;
30
28
  protected state$: TeleTitleBarConfig["state$"];
31
29
  protected sideEffect: SideEffectManager;
@@ -9,7 +9,7 @@ export declare type TeleTitleBarEvent<U = keyof TeleBoxDelegateEventConfig> = U
9
9
  } : never;
10
10
  export interface TeleTitleBarConfig {
11
11
  readonly$: ReadonlyVal<boolean, boolean>;
12
- title?: string;
12
+ title$: ReadonlyVal<string, boolean>;
13
13
  state$: ReadonlyVal<TeleBoxState, boolean>;
14
14
  namespace?: string;
15
15
  onEvent?: (event: TeleTitleBarEvent) => void;
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .tele-fancy-scrollbar{overscroll-behavior:contain;overflow:auto;overflow-y:scroll;overflow-y:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.tele-fancy-scrollbar::-webkit-scrollbar{height:8px;width:8px}.tele-fancy-scrollbar::-webkit-scrollbar-track{background-color:transparent}.tele-fancy-scrollbar::-webkit-scrollbar-thumb{background-color:rgba(68,78,96,.1);background-color:transparent;border-radius:4px;transition:background-color .4s}.tele-fancy-scrollbar:hover::-webkit-scrollbar-thumb{background-color:rgba(68,78,96,.1)}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:hover{background-color:rgba(68,78,96,.2)}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:active{background-color:rgba(68,78,96,.2)}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:vertical{min-height:50px}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-box{position:absolute;top:0;left:0;z-index:100;transition:width .4s cubic-bezier(.4, .9, .71, 1.02),height .4s cubic-bezier(.55, .82, .63, .95),opacity .6s cubic-bezier(.7, 0, .84, 0),transform .4s ease}.telebox-box-main{position:relative;width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;background:#f9f9fc;box-shadow:0 4px 10px 0 rgba(47,65,146,.15);border-radius:6px;border:1px solid #e3e3ec}.telebox-titlebar-wrap{flex-shrink:0;position:relative;z-index:1}.telebox-content-wrap{flex:1;width:100%;overflow:hidden;display:flex;justify-content:center;align-items:center;position:relative}.telebox-content{width:100%;height:100%;position:relative}.telebox-footer-wrap{flex-shrink:0;display:flex;flex-direction:column}.telebox-footer-wrap::before{content:"";display:block;flex:1}.telebox-resize-handle{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;position:absolute;z-index:2147483647}.telebox-n{width:100%;height:5px;left:0;top:-5px;cursor:n-resize}.telebox-s{width:100%;height:5px;left:0;bottom:-5px;cursor:s-resize}.telebox-w{width:5px;height:100%;left:-5px;top:0;cursor:w-resize}.telebox-e{width:5px;height:100%;right:-5px;top:0;cursor:e-resize}.telebox-nw{width:15px;height:15px;top:-5px;left:-5px;cursor:nw-resize}.telebox-ne{width:15px;height:15px;top:-5px;right:-5px;cursor:ne-resize}.telebox-se{width:15px;height:15px;bottom:-5px;right:-5px;cursor:se-resize}.telebox-sw{width:15px;height:15px;bottom:-5px;left:-5px;cursor:sw-resize}.telebox-track-mask{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;position:fixed;top:0;left:0;z-index:2147483647;width:100%;height:100%;background:rgba(0,0,0,.0001);cursor:move}.telebox-cursor-n{cursor:n-resize}.telebox-cursor-s{cursor:s-resize}.telebox-cursor-w{cursor:w-resize}.telebox-cursor-e{cursor:e-resize}.telebox-cursor-nw{cursor:nw-resize}.telebox-cursor-ne{cursor:ne-resize}.telebox-cursor-se{cursor:se-resize}.telebox-cursor-sw{cursor:sw-resize}.telebox-maximized .telebox-resize-handles,.telebox-no-resize .telebox-resize-handles{display:none}.telebox-maximized{box-shadow:none;transition:none}.telebox-minimized{transition:width 50ms cubic-bezier(.4, .9, .71, 1.02),height 50ms cubic-bezier(.55, .82, .63, .95),opacity .6s cubic-bezier(.7, 0, .84, 0),transform .6s ease;opacity:0;pointer-events:none;user-select:none}.telebox-transforming{will-change:transform;transition:opacity .6s cubic-bezier(.7, 0, .84, 0)}.telebox-readonly .telebox-resize-handle{cursor:initial!important;pointer-events:none!important}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark .telebox-box-main{color:#e9e9e9;background:#212126;border-color:#43434d}.telebox-titlebar{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;box-sizing:border-box;height:26px;display:flex;align-items:center;background:#fff;user-select:none;border-bottom:1px solid #eeeef7;touch-action:manipulation}.telebox-title-area{padding-left:16px;overflow:hidden;position:relative;height:100%;flex:1;display:flex;align-items:center}.telebox-title{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;overflow:hidden;margin:0;padding:0;font-size:14px;font-weight:400;font-family:PingFangSC-Regular,PingFang SC;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;color:#191919}.telebox-drag-area{position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;z-index:10}.telebox-titlebar-btns{padding-right:16px;white-space:nowrap;word-break:keep-all;margin-left:auto;font-size:0}.telebox-titlebar-btn{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;width:22px;height:22px;padding:0;outline:0;border:none;background:0 0;cursor:pointer}.telebox-titlebar-btn~.telebox-titlebar-btn{margin-left:10px}.telebox-titlebar-btn-icon{width:22px;height:22px}.telebox-readonly .telebox-titlebar-btn{cursor:not-allowed}.telebox-titlebar-icon-minimize{background:center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjh2MjhIMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxtYXNrIGlkPSJiIiBmaWxsPSIjZmZmIj4KICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjYSIgLz4KICAgICAgICA8L21hc2s+CiAgICAgICAgPHBhdGggZmlsbD0iI0E3QTdDQSIgZmlsbC1ydWxlPSJub256ZXJvIiBkPSJNOSAxM2gxMHYxLjZIOXoiIG1hc2s9InVybCgjYikiIC8+CiAgICA8L2c+Cjwvc3ZnPgo=")}.telebox-titlebar-icon-maximize{background:center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjh2MjhIMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxtYXNrIGlkPSJiIiBmaWxsPSIjZmZmIj4KICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjYSIgLz4KICAgICAgICA8L21hc2s+CiAgICAgICAgPGcgZmlsbD0iI0E3QTdDQSIgZmlsbC1ydWxlPSJub256ZXJvIiBtYXNrPSJ1cmwoI2IpIj4KICAgICAgICAgICAgPHBhdGgKICAgICAgICAgICAgICAgIGQ9Ik0yMC40ODEgMTcuMWgxLjJ2NC41ODFIMTcuMXYtMS4yaDMuMzgxVjE3LjF6bS0xNC4xOTA1LS4wMDloMS4ydjMuMzgxaDMuMzgwOXYxLjJoLTQuNTgxdi00LjU4MXpNMTcuMSA2LjE5MDVoNC41ODF2NC41ODA5aC0xLjJ2LTMuMzgxSDE3LjF2LTEuMnptLTEwLjcwMDguMTA4N2g0Ljc5ODV2MS4ySDcuNTk5MnYzLjU5ODVoLTEuMlY2LjI5OTJ6IiAvPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+Cg==")}.telebox-titlebar-icon-maximize.is-active{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjZ2MjZIMHoiIC8+CiAgICAgICAgPHBhdGggaWQ9ImMiIGQ9Ik0yNi44NjkgMEwyOCAxLjEzMVYyNi44N0wyNi44NjkgMjhIMS4xM0wwIDI2Ljg3VjEuMTMxTDEuMTMgMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPgogICAgICAgICAgICA8bWFzayBpZD0iYiIgZmlsbD0iI2ZmZiI+CiAgICAgICAgICAgICAgICA8dXNlIHhsaW5rOmhyZWY9IiNhIiAvPgogICAgICAgICAgICA8L21hc2s+CiAgICAgICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIGQ9Ik0tNC42NDI5LTQuNjQyOWgzNS4yODU4djM1LjI4NThILTQuNjQyOXoiIG1hc2s9InVybCgjYikiIC8+CiAgICAgICAgPC9nPgogICAgICAgIDxnPgogICAgICAgICAgICA8bWFzayBpZD0iZCIgZmlsbD0iI2ZmZiI+CiAgICAgICAgICAgICAgICA8dXNlIHhsaW5rOmhyZWY9IiNjIiAvPgogICAgICAgICAgICA8L21hc2s+CiAgICAgICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIGQ9Ik0tMTcuNTE2OCAxNEwxNC0xNy41MTY4IDQ1LjUxNjggMTQgMTQgNDUuNTE2OHoiIG1hc2s9InVybCgjZCkiIC8+CiAgICAgICAgPC9nPgogICAgICAgIDxwYXRoIHN0cm9rZT0iI0E3QTdDQSIgc3Ryb2tlLXdpZHRoPSIxLjIiCiAgICAgICAgICAgIGQ9Ik0xMC4wODg2IDIxLjQ4NjV2LTMuNjk2Nkg2LjM5Mk0yMS4zODU1IDEwLjE4OTVoLTMuNjk2NlY2LjQ5M00yMS40MDIgMTcuNzk4M2gtMy42OTY2djMuNjk2Nk0xMC4yNTAzIDYuMTQ5OHYzLjg5ODVINi4zNTE3IiAvPgogICAgPC9nPgo8L3N2Zz4K")}.telebox-titlebar-icon-close{background:center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyOCAyOCI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZT0iI0E3QTdDQSIgc3Ryb2tlLXdpZHRoPSIxLjQiPgogICAgICAgIDxwYXRoIGQ9Ik04LjM1MyAyMC4zMzIxTDIwLjMzMiA4LjM1M00yMC4zMzIyIDIwLjMzMjFMOC4zNTMgOC4zNTMiIC8+CiAgICA8L2c+Cjwvc3ZnPgo=")}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark .telebox-title{color:#e9e9e9}.telebox-color-scheme-dark .telebox-titlebar{color:#e9e9e9;background:#43434d;border-bottom:none}.telebox-box-stage-container{display:none;position:absolute;z-index:99;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none}.telebox-box-stage-container.is-active{display:flex}.telebox-box-stage-mask{background:rgba(0,0,0,.05)}.telebox-box-stage-frame{flex:1;position:relative}.telebox-box-stage-frame-corner{position:absolute;width:8px;height:8px}.telebox-box-stage-frame-corner.is-0{top:0;left:0}.telebox-box-stage-frame-corner.is-1{top:0;right:0}.telebox-box-stage-frame-corner.is-2{bottom:0;left:0}.telebox-box-stage-frame-corner.is-3{bottom:0;right:0}.telebox-collector{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;visibility:hidden;display:block;position:absolute;z-index:200;width:40px;height:40px;margin:0;padding:0;border:none;outline:0;font-size:0;border-radius:50%;background:#fff;box-shadow:0 2px 6px 0 rgba(47,65,146,.15);cursor:pointer;user-select:none;pointer-events:none;background-repeat:no-repeat;background-size:18px 16px;background-position:center;-webkit-tap-highlight-color:transparent}.telebox-collector-visible{visibility:visible;pointer-events:initial}.telebox-collector-readonly{cursor:not-allowed}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark.telebox-collector{background-color:#43434d}.telebox-max-titlebar{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;display:none;position:absolute;top:0;left:0;z-index:50000}.telebox-max-titlebar .telebox-title{display:none}.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-titles{display:none}.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-title{display:block}.telebox-max-titlebar-maximized{display:flex}.telebox-titles{height:100%;margin:0;overflow-y:hidden;overflow-x:scroll;overflow-x:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.telebox-titles::-webkit-scrollbar{height:8px;width:8px}.telebox-titles::-webkit-scrollbar-track{background-color:transparent}.telebox-titles::-webkit-scrollbar-thumb{background-color:rgba(238,238,247,.8);background-color:transparent;border-radius:4px;transition:background-color .4s}.telebox-titles:hover::-webkit-scrollbar-thumb{background-color:rgba(238,238,247,.8)}.telebox-titles::-webkit-scrollbar-thumb:hover{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:active{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:vertical{min-height:50px}.telebox-titles::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-titles-content{height:100%;display:flex;flex-wrap:nowrap;align-items:center;padding:0}.telebox-titles-tab{height:100%;overflow:hidden;max-width:182px;min-width:50px;padding:0 26px 0 16px;outline:0;font-size:13px;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;text-overflow:ellipsis;white-space:nowrap;word-break:keep-all;border:none;border-right:1px solid #e5e5f0;color:#7b88a0;background:0 0;cursor:pointer;user-select:none}.telebox-titles-tab-focus{color:#357bf6}.telebox-readonly .telebox-titles-tab{cursor:not-allowed}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark.telebox-titlebar{color:#e9e9e9;background:#43434d;border-bottom:none}.telebox-color-scheme-dark .telebox-titles-tab{border-right-color:#7b88a0}.telebox-color-scheme-dark .telebox-title{color:#e9e9e9}
1
+ .tele-fancy-scrollbar{overscroll-behavior:contain;overflow:auto;overflow-y:scroll;overflow-y:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.tele-fancy-scrollbar::-webkit-scrollbar{height:8px;width:8px}.tele-fancy-scrollbar::-webkit-scrollbar-track{background-color:transparent}.tele-fancy-scrollbar::-webkit-scrollbar-thumb{background-color:rgba(68,78,96,.1);background-color:transparent;border-radius:4px;transition:background-color .4s}.tele-fancy-scrollbar:hover::-webkit-scrollbar-thumb{background-color:rgba(68,78,96,.1)}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:hover{background-color:rgba(68,78,96,.2)}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:active{background-color:rgba(68,78,96,.2)}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:vertical{min-height:50px}.tele-fancy-scrollbar::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-box{position:absolute;top:0;left:0;z-index:100;transition:width .4s cubic-bezier(.4, .9, .71, 1.02),height .4s cubic-bezier(.55, .82, .63, .95),opacity .6s cubic-bezier(.7, 0, .84, 0),transform .4s ease}.telebox-box-main{position:relative;width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;background:#f9f9fc;box-shadow:0 4px 10px 0 rgba(47,65,146,.15);border-radius:6px;border:1px solid #e3e3ec}.telebox-titlebar-wrap{flex-shrink:0;position:relative;z-index:1}.telebox-content-wrap{flex:1;width:100%;overflow:hidden;display:flex;justify-content:center;align-items:center;position:relative}.telebox-content{width:100%;height:100%;position:relative}.telebox-footer-wrap{flex-shrink:0;display:flex;flex-direction:column}.telebox-footer-wrap::before{content:"";display:block;flex:1}.telebox-resize-handle{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;position:absolute;z-index:2147483647}.telebox-n{width:100%;height:5px;left:0;top:-5px;cursor:n-resize}.telebox-s{width:100%;height:5px;left:0;bottom:-5px;cursor:s-resize}.telebox-w{width:5px;height:100%;left:-5px;top:0;cursor:w-resize}.telebox-e{width:5px;height:100%;right:-5px;top:0;cursor:e-resize}.telebox-nw{width:15px;height:15px;top:-5px;left:-5px;cursor:nw-resize}.telebox-ne{width:15px;height:15px;top:-5px;right:-5px;cursor:ne-resize}.telebox-se{width:15px;height:15px;bottom:-5px;right:-5px;cursor:se-resize}.telebox-sw{width:15px;height:15px;bottom:-5px;left:-5px;cursor:sw-resize}.telebox-track-mask{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;position:fixed;top:0;left:0;z-index:2147483647;width:100%;height:100%;background:rgba(0,0,0,.0001);cursor:move}.telebox-cursor-n{cursor:n-resize}.telebox-cursor-s{cursor:s-resize}.telebox-cursor-w{cursor:w-resize}.telebox-cursor-e{cursor:e-resize}.telebox-cursor-nw{cursor:nw-resize}.telebox-cursor-ne{cursor:ne-resize}.telebox-cursor-se{cursor:se-resize}.telebox-cursor-sw{cursor:sw-resize}.telebox-maximized .telebox-resize-handles,.telebox-no-resize .telebox-resize-handles{display:none}.telebox-maximized{box-shadow:none;transition:none}.telebox-minimized{transition:width 50ms cubic-bezier(.4, .9, .71, 1.02),height 50ms cubic-bezier(.55, .82, .63, .95),opacity .6s cubic-bezier(.7, 0, .84, 0),transform .6s ease;opacity:0;pointer-events:none;user-select:none}.telebox-transforming{will-change:transform;transition:opacity .6s cubic-bezier(.7, 0, .84, 0)}.telebox-readonly .telebox-resize-handle{cursor:initial!important;pointer-events:none!important}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark .telebox-box-main{color:#e9e9e9;background:#212126;border-color:#43434d}.telebox-titlebar{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;box-sizing:border-box;height:26px;display:flex;align-items:center;background:#fff;user-select:none;border-bottom:1px solid #eeeef7;touch-action:manipulation}.telebox-title-area{padding-left:16px;overflow:hidden;position:relative;height:100%;flex:1;display:flex;align-items:center}.telebox-title{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;overflow:hidden;margin:0;padding:0;font-size:14px;font-weight:400;font-family:PingFangSC-Regular,PingFang SC;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;color:#191919}.telebox-drag-area{position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;z-index:10}.telebox-titlebar-btns{padding-right:16px;white-space:nowrap;word-break:keep-all;margin-left:auto;font-size:0}.telebox-titlebar-btn{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;width:22px;height:22px;padding:0;outline:0;border:none;background:0 0;cursor:pointer}.telebox-titlebar-btn~.telebox-titlebar-btn{margin-left:10px}.telebox-titlebar-btn-icon{width:22px;height:22px}.telebox-readonly .telebox-titlebar-btn{cursor:not-allowed}.telebox-titlebar-icon-minimize{background:center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjh2MjhIMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxtYXNrIGlkPSJiIiBmaWxsPSIjZmZmIj4KICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjYSIgLz4KICAgICAgICA8L21hc2s+CiAgICAgICAgPHBhdGggZmlsbD0iI0E3QTdDQSIgZmlsbC1ydWxlPSJub256ZXJvIiBkPSJNOSAxM2gxMHYxLjZIOXoiIG1hc2s9InVybCgjYikiIC8+CiAgICA8L2c+Cjwvc3ZnPgo=")}.telebox-titlebar-icon-maximize{background:center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjh2MjhIMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxtYXNrIGlkPSJiIiBmaWxsPSIjZmZmIj4KICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjYSIgLz4KICAgICAgICA8L21hc2s+CiAgICAgICAgPGcgZmlsbD0iI0E3QTdDQSIgZmlsbC1ydWxlPSJub256ZXJvIiBtYXNrPSJ1cmwoI2IpIj4KICAgICAgICAgICAgPHBhdGgKICAgICAgICAgICAgICAgIGQ9Ik0yMC40ODEgMTcuMWgxLjJ2NC41ODFIMTcuMXYtMS4yaDMuMzgxVjE3LjF6bS0xNC4xOTA1LS4wMDloMS4ydjMuMzgxaDMuMzgwOXYxLjJoLTQuNTgxdi00LjU4MXpNMTcuMSA2LjE5MDVoNC41ODF2NC41ODA5aC0xLjJ2LTMuMzgxSDE3LjF2LTEuMnptLTEwLjcwMDguMTA4N2g0Ljc5ODV2MS4ySDcuNTk5MnYzLjU5ODVoLTEuMlY2LjI5OTJ6IiAvPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+Cg==")}.telebox-titlebar-icon-maximize.is-active{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjZ2MjZIMHoiIC8+CiAgICAgICAgPHBhdGggaWQ9ImMiIGQ9Ik0yNi44NjkgMEwyOCAxLjEzMVYyNi44N0wyNi44NjkgMjhIMS4xM0wwIDI2Ljg3VjEuMTMxTDEuMTMgMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPgogICAgICAgICAgICA8bWFzayBpZD0iYiIgZmlsbD0iI2ZmZiI+CiAgICAgICAgICAgICAgICA8dXNlIHhsaW5rOmhyZWY9IiNhIiAvPgogICAgICAgICAgICA8L21hc2s+CiAgICAgICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIGQ9Ik0tNC42NDI5LTQuNjQyOWgzNS4yODU4djM1LjI4NThILTQuNjQyOXoiIG1hc2s9InVybCgjYikiIC8+CiAgICAgICAgPC9nPgogICAgICAgIDxnPgogICAgICAgICAgICA8bWFzayBpZD0iZCIgZmlsbD0iI2ZmZiI+CiAgICAgICAgICAgICAgICA8dXNlIHhsaW5rOmhyZWY9IiNjIiAvPgogICAgICAgICAgICA8L21hc2s+CiAgICAgICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIGQ9Ik0tMTcuNTE2OCAxNEwxNC0xNy41MTY4IDQ1LjUxNjggMTQgMTQgNDUuNTE2OHoiIG1hc2s9InVybCgjZCkiIC8+CiAgICAgICAgPC9nPgogICAgICAgIDxwYXRoIHN0cm9rZT0iI0E3QTdDQSIgc3Ryb2tlLXdpZHRoPSIxLjIiCiAgICAgICAgICAgIGQ9Ik0xMC4wODg2IDIxLjQ4NjV2LTMuNjk2Nkg2LjM5Mk0yMS4zODU1IDEwLjE4OTVoLTMuNjk2NlY2LjQ5M00yMS40MDIgMTcuNzk4M2gtMy42OTY2djMuNjk2Nk0xMC4yNTAzIDYuMTQ5OHYzLjg5ODVINi4zNTE3IiAvPgogICAgPC9nPgo8L3N2Zz4K")}.telebox-titlebar-icon-close{background:center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyOCAyOCI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZT0iI0E3QTdDQSIgc3Ryb2tlLXdpZHRoPSIxLjQiPgogICAgICAgIDxwYXRoIGQ9Ik04LjM1MyAyMC4zMzIxTDIwLjMzMiA4LjM1M00yMC4zMzIyIDIwLjMzMjFMOC4zNTMgOC4zNTMiIC8+CiAgICA8L2c+Cjwvc3ZnPgo=")}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark .telebox-title{color:#e9e9e9}.telebox-color-scheme-dark .telebox-titlebar{color:#e9e9e9;background:#43434d;border-bottom:none}.telebox-box-stage-container{display:none;position:absolute;z-index:5110;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none}.telebox-box-stage-container.is-active{display:flex}.telebox-box-stage-mask{background:rgba(0,0,0,.05)}.telebox-box-stage-frame{flex:1;position:relative}.telebox-box-stage-frame-corner{position:absolute;width:8px;height:8px}.telebox-box-stage-frame-corner.is-0{top:0;left:0}.telebox-box-stage-frame-corner.is-1{top:0;right:0}.telebox-box-stage-frame-corner.is-2{bottom:0;left:0}.telebox-box-stage-frame-corner.is-3{bottom:0;right:0}.telebox-collector{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;visibility:hidden;display:block;position:absolute;z-index:5120;width:40px;height:40px;margin:0;padding:0;border:none;outline:0;font-size:0;border-radius:50%;background:#fff;box-shadow:0 2px 6px 0 rgba(47,65,146,.15);cursor:pointer;user-select:none;pointer-events:none;background-repeat:no-repeat;background-size:18px 16px;background-position:center;-webkit-tap-highlight-color:transparent}.telebox-collector-visible{visibility:visible;pointer-events:initial}.telebox-collector-readonly{cursor:not-allowed}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark.telebox-collector{background-color:#43434d}.telebox-max-titlebar{user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;display:none;position:absolute;top:0;left:0;width:100%;z-index:5100;border-top-left-radius:6px;border-top-right-radius:6px}.telebox-max-titlebar .telebox-title{display:none}.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-titles{display:none}.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-title{display:block}.telebox-max-titlebar-maximized{display:flex}.telebox-titles{height:100%;margin:0;overflow-y:hidden;overflow-x:scroll;overflow-x:overlay;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;scrollbar-width:auto}.telebox-titles::-webkit-scrollbar{height:8px;width:8px}.telebox-titles::-webkit-scrollbar-track{background-color:transparent}.telebox-titles::-webkit-scrollbar-thumb{background-color:rgba(238,238,247,.8);background-color:transparent;border-radius:4px;transition:background-color .4s}.telebox-titles:hover::-webkit-scrollbar-thumb{background-color:rgba(238,238,247,.8)}.telebox-titles::-webkit-scrollbar-thumb:hover{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:active{background-color:#eeeef7}.telebox-titles::-webkit-scrollbar-thumb:vertical{min-height:50px}.telebox-titles::-webkit-scrollbar-thumb:horizontal{min-width:50px}.telebox-titles-content{height:100%;display:flex;flex-wrap:nowrap;align-items:center;padding:0}.telebox-titles-tab{height:100%;overflow:hidden;max-width:182px;min-width:150px;padding:0 26px 0 16px;outline:0;font-size:13px;font-family:PingFangSC-Regular,PingFang SC;font-weight:400;text-overflow:ellipsis;white-space:nowrap;word-break:keep-all;border:none;border-right:1px solid #e5e5f0;color:#7b88a0;background:0 0;cursor:pointer;user-select:none}.telebox-titles-tab-focus{color:#357bf6}.telebox-readonly .telebox-titles-tab{cursor:not-allowed}.telebox-color-scheme-dark{color-scheme:dark}.telebox-color-scheme-dark.telebox-titlebar{color:#e9e9e9;background:#43434d;border-bottom:none}.telebox-color-scheme-dark .telebox-titles-tab{border-right-color:#7b88a0}.telebox-color-scheme-dark .telebox-title{color:#e9e9e9}
@@ -1,16 +1,2 @@
1
- "use strict";var e=Object.defineProperty,t=Object.defineProperties,i=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,o=(t,i,s)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s,a=(e,t)=>{for(var i in t||(t={}))r.call(t,i)&&o(e,i,t[i]);if(s)for(var i of s(t))n.call(t,i)&&o(e,i,t[i]);return e};Object.defineProperty(exports,"__esModule",{value:!0}),exports[Symbol.toStringTag]="Module";const h=new WeakMap,l=new WeakMap,c=new WeakMap,d=Symbol("anyProducer"),u=Promise.resolve(),f=Symbol("listenerAdded"),p=Symbol("listenerRemoved"),m=Symbol("metaEventsAllowed");let g=!1;function E(e,t){if("string"!=typeof e&&"symbol"!=typeof e&&"number"!=typeof e)throw new TypeError("`eventName` must be a string, symbol, or number");if(y(e)&&t!==m)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`")}function b(e){if("function"!=typeof e)throw new TypeError("listener must be a function")}function v(e,t){const i=l.get(e);return i.has(t)||i.set(t,new Set),i.get(t)}function x(e,t){const i="string"==typeof t||"symbol"==typeof t||"number"==typeof t?t:d,s=c.get(e);return s.has(i)||s.set(i,new Set),s.get(i)}function _(e,t){t=Array.isArray(t)?t:[t];let i=!1,s=()=>{},r=[];const n={enqueue(e){r.push(e),s()},finish(){i=!0,s()}};for(const o of t)x(e,o).add(n);return{async next(){return r?0===r.length?i?(r=void 0,this.next()):(await new Promise((e=>{s=e})),this.next()):{done:!1,value:await r.shift()}:{done:!0}},async return(i){r=void 0;for(const s of t)x(e,s).delete(n);return s(),arguments.length>0?{done:!0,value:await i}:{done:!0}},[Symbol.asyncIterator](){return this}}}function w(e){if(void 0===e)return $;if(!Array.isArray(e))throw new TypeError("`methodNames` must be an array of strings");for(const t of e)if(!$.includes(t)){if("string"!=typeof t)throw new TypeError("`methodNames` element must be a string");throw new Error(`${t} is not Emittery method`)}return e}const y=e=>e===f||e===p;class T{static mixin(e,t){return t=w(t),i=>{if("function"!=typeof i)throw new TypeError("`target` must be function");for(const e of t)if(void 0!==i.prototype[e])throw new Error(`The property \`${e}\` already exists on \`target\``);Object.defineProperty(i.prototype,e,{enumerable:!1,get:function(){return Object.defineProperty(this,e,{enumerable:!1,value:new T}),this[e]}});const s=t=>function(...i){return this[e][t](...i)};for(const e of t)Object.defineProperty(i.prototype,e,{enumerable:!1,value:s(e)});return i}}static get isDebugEnabled(){if("object"!=typeof process)return g;const{env:e}=process||{env:{}};return"emittery"===e.DEBUG||"*"===e.DEBUG||g}static set isDebugEnabled(e){g=e}constructor(e={}){h.set(this,new Set),l.set(this,new Map),c.set(this,new Map),this.debug=e.debug||{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(e,t,i,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}"symbol"!=typeof i&&"number"!=typeof i||(i=i.toString());const r=new Date,n=`${r.getHours()}:${r.getMinutes()}:${r.getSeconds()}.${r.getMilliseconds()}`;console.log(`[${n}][emittery:${e}][${t}] Event Name: ${i}\n\tdata: ${s}`)})}logIfDebugEnabled(e,t,i){(T.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,i)}on(e,t){b(t),e=Array.isArray(e)?e:[e];for(const i of e)E(i,m),v(this,i).add(t),this.logIfDebugEnabled("subscribe",i,void 0),y(i)||this.emit(f,{eventName:i,listener:t},m);return this.off.bind(this,e,t)}off(e,t){b(t),e=Array.isArray(e)?e:[e];for(const i of e)E(i,m),v(this,i).delete(t),this.logIfDebugEnabled("unsubscribe",i,void 0),y(i)||this.emit(p,{eventName:i,listener:t},m)}once(e){return new Promise((t=>{const i=this.on(e,(e=>{i(),t(e)}))}))}events(e){e=Array.isArray(e)?e:[e];for(const t of e)E(t,m);return _(this,e)}async emit(e,t,i){E(e,i),this.logIfDebugEnabled("emit",e,t),function(e,t,i){const s=c.get(e);if(s.has(t))for(const r of s.get(t))r.enqueue(i);if(s.has(d)){const e=Promise.all([t,i]);for(const t of s.get(d))t.enqueue(e)}}(this,e,t);const s=v(this,e),r=h.get(this),n=[...s],o=y(e)?[]:[...r];await u,await Promise.all([...n.map((async e=>{if(s.has(e))return e(t)})),...o.map((async i=>{if(r.has(i))return i(e,t)}))])}async emitSerial(e,t,i){E(e,i),this.logIfDebugEnabled("emitSerial",e,t);const s=v(this,e),r=h.get(this),n=[...s],o=[...r];await u;for(const a of n)s.has(a)&&await a(t);for(const a of o)r.has(a)&&await a(e,t)}onAny(e){return b(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),h.get(this).add(e),this.emit(f,{listener:e},m),this.offAny.bind(this,e)}anyEvent(){return _(this)}offAny(e){b(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),this.emit(p,{listener:e},m),h.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),"string"==typeof t||"symbol"==typeof t||"number"==typeof t){v(this,t).clear();const e=x(this,t);for(const t of e)t.finish();e.clear()}else{h.get(this).clear();for(const e of l.get(this).values())e.clear();for(const e of c.get(this).values()){for(const t of e)t.finish();e.clear()}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const i of e)if("string"!=typeof i){void 0!==i&&E(i,m),t+=h.get(this).size;for(const e of l.get(this).values())t+=e.size;for(const e of c.get(this).values())t+=e.size}else t+=h.get(this).size+v(this,i).size+x(this,i).size+x(this).size;return t}bindMethods(e,t){if("object"!=typeof e||null===e)throw new TypeError("`target` must be an object");t=w(t);for(const i of t){if(void 0!==e[i])throw new Error(`The property \`${i}\` already exists on \`target\``);Object.defineProperty(e,i,{enumerable:!1,value:this[i].bind(this)})}}}const $=Object.getOwnPropertyNames(T.prototype).filter((e=>"constructor"!==e));Object.defineProperty(T,"listenerAdded",{value:f,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(T,"listenerRemoved",{value:p,writable:!1,enumerable:!0,configurable:!1});var B=T,S=function(){return(S=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */function N(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(i[s[r]]=e[s[r]])}return i}var C=0,L="undefined"!=typeof window&&void 0!==window.requestAnimationFrame?function(e){return window.requestAnimationFrame(e)}:function(e){var t=Date.now(),i=Math.max(0,16.7-(t-C));C=t+i,setTimeout((function(){return e(C)}),i)},z=1/60*1e3,O=!0,A=!1,M=!1,R={delta:0,timestamp:0},D=["read","update","preRender","render","postRender"],X=function(e){return A=e},I=D.reduce((function(e,t){var i,s,r,n,o,a,h,l,c;return e[t]=(i=X,s=[],r=[],n=0,o=!1,a=0,h=new WeakSet,l=new WeakSet,c={cancel:function(e){var t=r.indexOf(e);h.add(e),-1!==t&&r.splice(t,1)},process:function(e){var t,d;if(o=!0,s=(t=[r,s])[0],(r=t[1]).length=0,n=s.length)for(a=0;a<n;a++)(d=s[a])(e),!0!==l.has(d)||h.has(d)||(c.schedule(d),i(!0));o=!1},schedule:function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=!1);var a=i&&o,c=a?s:r;h.delete(e),t&&l.add(e),-1===c.indexOf(e)&&(c.push(e),a&&(n=s.length))}}),e}),{}),k=D.reduce((function(e,t){var i=I[t];return e[t]=function(e,t,s){return void 0===t&&(t=!1),void 0===s&&(s=!1),A||P(),i.schedule(e,t,s),e},e}),{}),V=function(e){return I[e].process(R)},H=function(e){A=!1,R.delta=O?z:Math.max(Math.min(e-R.timestamp,40),1),O||(z=R.delta),R.timestamp=e,M=!0,D.forEach(V),M=!1,A&&(O=!1,L(H))},P=function(){A=!0,O=!0,M||L(H)},j=function(e,t){return function(i){return Math.max(Math.min(i,t),e)}},W=function(e){return e%1?Number(e.toFixed(5)):e},G=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i,Z={test:function(e){return"number"==typeof e},parse:parseFloat,transform:function(e){return e}},Y=S(S({},Z),{transform:j(0,1)}),F=S(S({},Z),{default:1}),U=function(e){return{test:function(t){return"string"==typeof t&&t.endsWith(e)&&1===t.split(" ").length},parse:parseFloat,transform:function(t){return""+t+e}}},q=U("deg"),J=U("%"),Q=U("px"),K=S(S({},J),{parse:function(e){return J.parse(e)/100},transform:function(e){return J.transform(100*e)}}),ee=j(0,255),te=function(e){return void 0!==e.red},ie=function(e){return void 0!==e.hue};var se=function(e){return function(t){if("string"!=typeof t)return t;for(var i={},s=function(e){return e.substring(e.indexOf("(")+1,e.lastIndexOf(")"))}(t).replace(/(,|\/)/g," ").split(/ \s*/),r=0;r<4;r++)i[e[r]]=void 0!==s[r]?parseFloat(s[r]):1;return i}},re=S(S({},Z),{transform:function(e){return Math.round(ee(e))}});function ne(e,t){return e.startsWith(t)&&G.test(e)}var oe,ae={test:function(e){return"string"==typeof e?ne(e,"rgb"):te(e)},parse:se(["red","green","blue","alpha"]),transform:function(e){var t=e.red,i=e.green,s=e.blue,r=e.alpha,n=void 0===r?1:r;return function(e){var t=e.red,i=e.green,s=e.blue,r=e.alpha;return"rgba("+t+", "+i+", "+s+", "+(void 0===r?1:r)+")"}({red:re.transform(t),green:re.transform(i),blue:re.transform(s),alpha:W(Y.transform(n))})}},he={test:function(e){return"string"==typeof e?ne(e,"hsl"):ie(e)},parse:se(["hue","saturation","lightness","alpha"]),transform:function(e){var t=e.hue,i=e.saturation,s=e.lightness,r=e.alpha,n=void 0===r?1:r;return function(e){var t=e.hue,i=e.saturation,s=e.lightness,r=e.alpha;return"hsla("+t+", "+i+", "+s+", "+(void 0===r?1:r)+")"}({hue:Math.round(t),saturation:J.transform(W(i)),lightness:J.transform(W(s)),alpha:W(Y.transform(n))})}},le=S(S({},ae),{test:function(e){return"string"==typeof e&&ne(e,"#")},parse:function(e){var t="",i="",s="";return e.length>4?(t=e.substr(1,2),i=e.substr(3,2),s=e.substr(5,2)):(t=e.substr(1,1),i=e.substr(2,1),s=e.substr(3,1),t+=t,i+=i,s+=s),{red:parseInt(t,16),green:parseInt(i,16),blue:parseInt(s,16),alpha:1}}}),ce={test:function(e){return"string"==typeof e&&G.test(e)||te(e)||ie(e)},parse:function(e){return ae.test(e)?ae.parse(e):he.test(e)?he.parse(e):le.test(e)?le.parse(e):e},transform:function(e){return te(e)?ae.transform(e):ie(e)?he.transform(e):e}},de=function(e){var t=e.onRead,i=e.onRender,s=e.uncachedValues,r=void 0===s?new Set:s,n=e.useCache,o=void 0===n||n;return function(e){void 0===e&&(e={});var s=N(e,[]),n={},a=[],h=!1;function l(e,t){e.startsWith("--")&&(s.hasCSSVariable=!0);var i=n[e];n[e]=t,n[e]!==i&&(-1===a.indexOf(e)&&a.push(e),h||(h=!0,k.render(c.render)))}var c={get:function(e,i){return void 0===i&&(i=!1),!i&&o&&!r.has(e)&&void 0!==n[e]?n[e]:t(e,s)},set:function(e,t){if("string"==typeof e)l(e,t);else for(var i in e)l(i,e[i]);return this},render:function(e){return void 0===e&&(e=!1),(h||!0===e)&&(i(n,s,a),h=!1,a.length=0),this}};return c}},ue=/([a-z])([A-Z])/g,fe=function(e){return e.replace(ue,"$1-$2").toLowerCase()},pe=new Map,me=new Map,ge=["Webkit","Moz","O","ms",""],Ee=ge.length,be="undefined"!=typeof document,ve=function(e,t){return me.set(e,fe(t))},xe=function(e,t){void 0===t&&(t=!1);var i=t?me:pe;return i.has(e)||(be?function(e){oe=oe||document.createElement("div");for(var t=0;t<Ee;t++){var i=ge[t],s=""===i,r=s?e:i+e.charAt(0).toUpperCase()+e.slice(1);if(r in oe.style||s){if(s&&"clipPath"===e&&me.has(e))return;pe.set(e,r),ve(e,(s?"":"-")+fe(r))}}}(e):function(e){ve(e,e)}(e)),i.get(e)||e},_e=["","X","Y","Z"],we=["translate","scale","rotate","skew","transformPerspective"].reduce((function(e,t){return _e.reduce((function(e,i){return e.push(t+i),e}),e)}),["x","y","z"]),ye=we.reduce((function(e,t){return e[t]=!0,e}),{});function Te(e){return!0===ye[e]}function $e(e,t){return we.indexOf(e)-we.indexOf(t)}var Be=new Set(["originX","originY","originZ"]);function Se(e){return Be.has(e)}var Ne=S(S({},Z),{transform:Math.round}),Ce={color:ce,backgroundColor:ce,outlineColor:ce,fill:ce,stroke:ce,borderColor:ce,borderTopColor:ce,borderRightColor:ce,borderBottomColor:ce,borderLeftColor:ce,borderWidth:Q,borderTopWidth:Q,borderRightWidth:Q,borderBottomWidth:Q,borderLeftWidth:Q,borderRadius:Q,radius:Q,borderTopLeftRadius:Q,borderTopRightRadius:Q,borderBottomRightRadius:Q,borderBottomLeftRadius:Q,width:Q,maxWidth:Q,height:Q,maxHeight:Q,size:Q,top:Q,right:Q,bottom:Q,left:Q,padding:Q,paddingTop:Q,paddingRight:Q,paddingBottom:Q,paddingLeft:Q,margin:Q,marginTop:Q,marginRight:Q,marginBottom:Q,marginLeft:Q,rotate:q,rotateX:q,rotateY:q,rotateZ:q,scale:F,scaleX:F,scaleY:F,scaleZ:F,skew:q,skewX:q,skewY:q,distance:Q,translateX:Q,translateY:Q,translateZ:Q,x:Q,y:Q,z:Q,perspective:Q,opacity:Y,originX:K,originY:K,originZ:Q,zIndex:Ne,fillOpacity:Y,strokeOpacity:Y,numOctaves:Ne},Le=function(e){return Ce[e]},ze=function(e,t){return t&&"number"==typeof e?t.transform(e):e},Oe=new Set(["scrollLeft","scrollTop"]),Ae=new Set(["scrollLeft","scrollTop","transform"]),Me={x:"translateX",y:"translateY",z:"translateZ"};function Re(e){return"function"==typeof e}function De(e,t,i,s,r,n,o,a){void 0===t&&(t=!0),void 0===i&&(i={}),void 0===s&&(s={}),void 0===r&&(r={}),void 0===n&&(n=[]),void 0===o&&(o=!1),void 0===a&&(a=!0);var h=!0,l=!1,c=!1;for(var d in e){var u=e[d],f=Le(d),p=ze(u,f);Te(d)?(l=!0,s[d]=p,n.push(d),h&&(f.default&&u!==f.default||!f.default&&0!==u)&&(h=!1)):Se(d)?(r[d]=p,c=!0):Ae.has(d)&&Re(p)||(i[xe(d,o)]=p)}return(l||"function"==typeof e.transform)&&(i.transform=function(e,t,i,s,r,n){void 0===n&&(n=!0);var o="",a=!1;i.sort($e);for(var h=i.length,l=0;l<h;l++){var c=i[l];o+=(Me[c]||c)+"("+t[c]+") ",a="z"===c||a}return!a&&r?o+="translateZ(0)":o=o.trim(),Re(e.transform)?o=e.transform(t,s?"":o):n&&s&&(o="none"),o}(e,s,n,h,t,a)),c&&(i.transformOrigin=(r.originX||"50%")+" "+(r.originY||"50%")+" "+(r.originZ||0)),i}function Xe(e){var t=void 0===e?{}:e,i=t.enableHardwareAcceleration,s=void 0===i||i,r=t.isDashCase,n=void 0===r||r,o=t.allowTransformNone,a=void 0===o||o,h={},l={},c={},d=[];return function(e){return d.length=0,De(e,s,h,l,c,d,n,a),h}}var Ie=de({onRead:function(e,t){var i=t.element,s=t.preparseOutput,r=Le(e);if(Te(e))return r&&r.default||0;if(Oe.has(e))return i[e];var n=window.getComputedStyle(i,null).getPropertyValue(xe(e,!0))||0;return s&&r&&r.test(n)&&r.parse?r.parse(n):n},onRender:function(e,t,i){var s=t.element,r=t.buildStyles,n=t.hasCSSVariable;if(Object.assign(s.style,r(e)),n)for(var o=i.length,a=0;a<o;a++){var h=i[a];h.startsWith("--")&&s.style.setProperty(h,e[h])}-1!==i.indexOf("scrollLeft")&&(s.scrollLeft=e.scrollLeft),-1!==i.indexOf("scrollTop")&&(s.scrollTop=e.scrollTop)},uncachedValues:Oe});var ke=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues"]),Ve=function(e,t){return Q.transform(e*t)},He={x:0,y:0,width:0,height:0};function Pe(e,t,i){return"string"==typeof e?e:Q.transform(t+i*e)}var je={enableHardwareAcceleration:!1,isDashCase:!1};function We(e,t,i,s,r,n){void 0===t&&(t=He),void 0===s&&(s=Xe(je)),void 0===r&&(r={style:{}}),void 0===n&&(n=!0);var o=e.attrX,a=e.attrY,h=e.originX,l=e.originY,c=e.pathLength,d=e.pathSpacing,u=void 0===d?1:d,f=e.pathOffset,p=void 0===f?0:f,m=s(N(e,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]));for(var g in m){if("transform"===g)r.style.transform=m[g];else r[n&&!ke.has(g)?fe(g):g]=m[g]}return(void 0!==h||void 0!==l||m.transform)&&(r.style.transformOrigin=function(e,t,i){return Pe(t,e.x,e.width)+" "+Pe(i,e.y,e.height)}(t,void 0!==h?h:.5,void 0!==l?l:.5)),void 0!==o&&(r.x=o),void 0!==a&&(r.y=a),void 0!==i&&void 0!==c&&(r[n?"stroke-dashoffset":"strokeDashoffset"]=Ve(-p,i),r[n?"stroke-dasharray":"strokeDasharray"]=Ve(c,i)+" "+Ve(u,i)),r}function Ge(e,t,i){void 0===i&&(i=!0);var s={style:{}},r=Xe(je);return function(n){return We(n,e,t,r,s,i)}}var Ze=de({onRead:function(e,t){var i=t.element;if(Te(e=ke.has(e)?e:fe(e))){var s=Le(e);return s&&s.default||0}return i.getAttribute(e)},onRender:function(e,t){var i=t.element,s=(0,t.buildAttrs)(e);for(var r in s)"style"===r?Object.assign(i.style,s.style):i.setAttribute(r,s[r])}}),Ye=de({useCache:!1,onRead:function(e){return"scrollTop"===e?window.pageYOffset:window.pageXOffset},onRender:function(e){var t=e.scrollTop,i=void 0===t?0:t,s=e.scrollLeft,r=void 0===s?0:s;return window.scrollTo(r,i)}}),Fe=new WeakMap,Ue=function(e,t){var i,s,r,n;return e===window?i=Ye(e):!function(e){return e instanceof HTMLElement||"function"==typeof e.click}(e)?function(e){return e instanceof SVGElement||"ownerSVGElement"in e}(e)&&(r=function(e){try{return function(e){return"function"==typeof e.getBBox?e.getBBox():e.getBoundingClientRect()}(e)}catch(t){return{x:0,y:0,width:0,height:0}}}(s=e),n=function(e){return"path"===e.tagName}(s)&&s.getTotalLength?s.getTotalLength():void 0,i=Ze({element:s,buildAttrs:Ge(r,n)})):i=function(e,t){void 0===t&&(t={});var i=t.enableHardwareAcceleration,s=t.allowTransformNone,r=N(t,["enableHardwareAcceleration","allowTransformNone"]);return Ie(S({element:e,buildStyles:Xe({enableHardwareAcceleration:i,allowTransformNone:s}),preparseOutput:!0},r))}(e,t),Fe.set(e,i),i};function qe(e,t){return function(e,t){return Fe.has(e)?Fe.get(e):Ue(e,t)}("string"==typeof e?document.querySelector(e):e,t)}var Je=function(e,t,i,s){var r=i?i.call(s,e,t):void 0;if(void 0!==r)return!!r;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(t),h=0;h<n.length;h++){var l=n[h];if(!a(l))return!1;var c=e[l],d=t[l];if(!1===(r=i?i.call(s,c,d,l):void 0)||void 0===r&&c!==d)return!1}return!0};const Qe="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ke=Qe.length,et=Array(20),tt=()=>{for(let e=0;e<20;e++)et[e]=Qe.charAt(Math.random()*Ke);return et.join("")};function it(e){try{return e()}catch(t){console.error(t)}}class st{constructor(){this.disposers=new Map}addDisposer(e,t=this.genUID()){return this.flush(t),this.disposers.set(t,Array.isArray(e)?()=>e.forEach(it):e),t}add(e,t=this.genUID()){return this.addDisposer(e(),t)}addEventListener(e,t,i,s,r=this.genUID()){return e.addEventListener(t,i,s),this.addDisposer((()=>e.removeEventListener(t,i,s)),r),r}setTimeout(e,t,i=this.genUID()){const s=window.setTimeout((()=>{this.remove(i),e()}),t);return this.addDisposer((()=>window.clearTimeout(s)),i)}setInterval(e,t,i=this.genUID()){const s=window.setInterval(e,t);return this.addDisposer((()=>window.clearInterval(s)),i)}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){const t=this.remove(e);if(t)try{t()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach(it),this.disposers.clear()}genUID(){let e;do{e=tt()}while(this.disposers.has(e));return e}}var rt=Object.defineProperty,nt=Object.defineProperties,ot=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable,ct=(e,t,i)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dt=(e,t,i)=>(ct(e,"symbol"!=typeof t?t+"":t,i),i);class ut{constructor(e){dt(this,"_subscribers"),dt(this,"_bSub"),dt(this,"_bSubDisposer"),this._bSub=e}get size(){return this._subscribers?this._subscribers.size:0}invoke(e,t){this._subscribers&&this._subscribers.forEach((i=>i(e,t)))}add(e){this._bSub&&(!this._subscribers||this._subscribers.size<=0)&&(this._bSubDisposer=this._bSub()),this._subscribers||(this._subscribers=new Set),this._subscribers.add(e)}remove(e){if(this._subscribers&&this._subscribers.delete(e),this._subscribers&&this._subscribers.size<=0&&this._bSubDisposer){const e=this._bSubDisposer;this._bSubDisposer=null,e()}}clear(){if(this._subscribers&&this._subscribers.clear(),this._bSubDisposer){const e=this._bSubDisposer;this._bSubDisposer=null,e()}}destroy(){this.clear()}}class ft{constructor(e,t){let i;if(dt(this,"_subscribers"),dt(this,"_value"),this._value=e,t&&(t.compare&&(this.compare=t.compare),t.beforeSubscribe)){const e=t.beforeSubscribe,s=this._setValue.bind(this);i=()=>e(s)}this._subscribers=new ut(i)}_setValue(e,t){this.compare(e,this._value)||(this._value=e,this._subscribers.invoke(e,t))}get value(){return this._value}reaction(e){return this._subscribers.add(e),()=>{this._subscribers.remove(e)}}subscribe(e,t){const i=this.reaction(e);return e(this._value,t),i}destroy(){this._subscribers.destroy()}unsubscribe(e){this._subscribers.remove(e)}compare(e,t){return e===t}}class pt extends ft{constructor(){super(...arguments),dt(this,"setValue",this._setValue)}}class mt extends ft{constructor(e,t,i={}){var s;super(t(gt(e)),(s=((e,t)=>{for(var i in t||(t={}))ht.call(t,i)&&ct(e,i,t[i]);if(at)for(var i of at(t))lt.call(t,i)&&ct(e,i,t[i]);return e})({},i),nt(s,ot({beforeSubscribe:s=>{let r=gt(e);s(t(r));const n=e.map(((e,i)=>e.reaction(((e,n)=>{r=r.slice(),r[i]=e,s(t(r),n)})))),o=()=>n.forEach((e=>e()));if(i.beforeSubscribe){const e=i.beforeSubscribe(s);if(e)return()=>{o(),e()}}return o}})))),dt(this,"_srcValue"),this._srcValue=()=>t(gt(e))}get value(){if(this._subscribers.size<=0){const e=this._srcValue();return this.compare(e,this._value)?this._value:e}return this._value}}function gt(e){return e.map(Et)}function Et(e){return e.value}function bt(e,t=(e=>e),i={}){return new mt(e,t,i)}function vt(e,t){Object.keys(t).forEach((i=>{!function(e,t,i){Object.defineProperties(e,{[t]:{get:()=>i.value},[`_${t}$`]:{value:i}})}(e,i,t[i])}))}function xt(e,t){Object.keys(t).forEach((i=>{!function(e,t,i){Object.defineProperties(e,{[t]:{get:()=>i.value},[`_${t}$`]:{value:i},[`set${_t(t)}`]:{value:(e,t)=>i.setValue(e,t)}})}(e,i,t[i])}))}function _t(e){return e[0].toUpperCase()+e.slice(1)}var wt,yt,Tt,$t,Bt;exports.TELE_BOX_COLOR_SCHEME=void 0,(wt=exports.TELE_BOX_COLOR_SCHEME||(exports.TELE_BOX_COLOR_SCHEME={})).Light="light",wt.Dark="dark",wt.Auto="auto",exports.TELE_BOX_STATE=void 0,(yt=exports.TELE_BOX_STATE||(exports.TELE_BOX_STATE={})).Normal="normal",yt.Minimized="minimized",yt.Maximized="maximized",exports.TELE_BOX_EVENT=void 0,(Tt=exports.TELE_BOX_EVENT||(exports.TELE_BOX_EVENT={})).DarkMode="dark_mode",Tt.PrefersColorScheme="prefers_color_scheme",Tt.Close="close",Tt.Focus="focus",Tt.Blur="blur",Tt.IntrinsicMove="intrinsic_move",Tt.IntrinsicResize="intrinsic_resize",Tt.ZIndex="z_index",Tt.State="state",Tt.Minimized="minimized",Tt.Maximized="maximized",Tt.Readonly="readonly",Tt.Destroyed="destroyed",exports.TELE_BOX_DELEGATE_EVENT=void 0,($t=exports.TELE_BOX_DELEGATE_EVENT||(exports.TELE_BOX_DELEGATE_EVENT={})).Close="close",$t.Maximize="maximize",$t.Minimize="minimize",exports.TELE_BOX_RESIZE_HANDLE=void 0,(Bt=exports.TELE_BOX_RESIZE_HANDLE||(exports.TELE_BOX_RESIZE_HANDLE={})).North="n",Bt.South="s",Bt.West="w",Bt.East="e",Bt.NorthWest="nw",Bt.NorthEast="ne",Bt.SouthEast="se",Bt.SouthWest="sw";function St(e,t,i){return Math.min(Math.max(e,t),i)}function Nt(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}function Ct(e){return e.touches?e.touches[0]:e}let Lt=1;function zt(){return"New Box "+Lt++}function Ot(e){return Boolean(e)}function At(e){return!e}class Mt{constructor({readonly$:e,state$:t,title:i="",buttons:s,onEvent:r,onDragStart:n,namespace:o="telebox"}){this.sideEffect=new st,this.lastTitleBarClick={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarClick=e=>{var t;if(this.readonly$.value)return;if(0!==e.button)return;if(null==(t=e.target.dataset)?void 0:t.teleTitleBarNoDblClick)return;Nt(e);const i=Date.now();i-this.lastTitleBarClick.timestamp<=500?Math.abs(e.clientX-this.lastTitleBarClick.clientX)<=5&&Math.abs(e.clientY-this.lastTitleBarClick.clientY)<=5&&this.onEvent&&this.onEvent({type:exports.TELE_BOX_DELEGATE_EVENT.Maximize}):this.onDragStart&&this.onDragStart(e),this.lastTitleBarClick.timestamp=i,this.lastTitleBarClick.clientX=e.clientX,this.lastTitleBarClick.clientY=e.clientY},this.lastTitleBarTouch={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarTouch=e=>{var t;if(this.readonly$.value)return;if(null==(t=e.target.dataset)?void 0:t.teleTitleBarNoDblClick)return;Nt(e);const i=Date.now(),{clientX:s=this.lastTitleBarTouch.clientX+100,clientY:r=this.lastTitleBarTouch.clientY+100}=e.touches[0]||{};i-this.lastTitleBarTouch.timestamp<=500?Math.abs(s-this.lastTitleBarTouch.clientX)<=10&&Math.abs(r-this.lastTitleBarTouch.clientY)<=10&&this.onEvent&&this.onEvent({type:exports.TELE_BOX_DELEGATE_EVENT.Maximize}):this.onDragStart&&this.onDragStart(e),this.lastTitleBarTouch.timestamp=i,this.lastTitleBarTouch.clientX=s,this.lastTitleBarTouch.clientY=r},this.readonly$=e,this.state$=t,this.title$=new pt(i),this.onEvent=r,this.onDragStart=n,this.namespace=o,this.buttons=s||[{type:exports.TELE_BOX_DELEGATE_EVENT.Minimize,iconClassName:this.wrapClassName("titlebar-icon-minimize")},{type:exports.TELE_BOX_DELEGATE_EVENT.Maximize,iconClassName:this.wrapClassName("titlebar-icon-maximize"),isActive:e=>e===exports.TELE_BOX_STATE.Maximized},{type:exports.TELE_BOX_DELEGATE_EVENT.Close,iconClassName:this.wrapClassName("titlebar-icon-close")}],this.$dragArea=this.renderDragArea()}get title(){return this.title$.value}setTitle(e){this.title$.setValue(e)}render(){if(!this.$titleBar){this.$titleBar=document.createElement("div"),this.$titleBar.className=this.wrapClassName("titlebar");const e=document.createElement("div");e.className=this.wrapClassName("title-area"),e.dataset.teleBoxHandle="dh";const t=document.createElement("h1");t.className=this.wrapClassName("title"),t.dataset.teleBoxHandle="dh",e.appendChild(t),e.appendChild(this.$dragArea);const i=document.createElement("div");i.className=this.wrapClassName("titlebar-btns"),this.buttons.forEach((({iconClassName:e},t)=>{const s=String(t),r=document.createElement("button");r.className=`${this.wrapClassName("titlebar-btn")} ${e}`,r.dataset.teleTitleBarBtnIndex=s,r.dataset.teleTitleBarNoDblClick="true",i.appendChild(r)})),this.sideEffect.addDisposer(this.title$.subscribe((e=>{t.textContent=e,t.title=e})),"render-title"),this.sideEffect.addDisposer(this.state$.subscribe((e=>{this.buttons.forEach(((t,s)=>{var r;t.isActive&&(null==(r=i.children[s])||r.classList.toggle("is-active",t.isActive(e)))}))})),"render-state-btns"),this.sideEffect.addEventListener(i,"click",(e=>{var t;if(this.readonly$.value)return;const i=e.target,s=Number(null==(t=i.dataset)?void 0:t.teleTitleBarBtnIndex);if(!Number.isNaN(s)&&s<this.buttons.length){Nt(e);const t=this.buttons[s];this.onEvent&&this.onEvent({type:t.type,value:t.value})}}),{},"render-btns-container-click"),this.$titleBar.appendChild(e),this.$titleBar.appendChild(i)}return this.$titleBar}renderDragArea(){const e=document.createElement("div");return e.className=this.wrapClassName("drag-area"),e.dataset.teleBoxHandle="dh",this.sideEffect.addEventListener(e,"mousedown",this.handleTitleBarClick),this.sideEffect.addEventListener(e,"touchstart",this.handleTitleBarTouch,{passive:!0}),e}dragHandle(){return this.$titleBar}wrapClassName(e){return`${this.namespace}-${e}`}destroy(){this.sideEffect.flushAll(),this.$titleBar&&(this.$titleBar=void 0,this.onDragStart=void 0,this.onEvent=void 0)}}var Rt,Dt,Xt=[],It="ResizeObserver loop completed with undelivered notifications.";(Dt=Rt||(Rt={})).BORDER_BOX="border-box",Dt.CONTENT_BOX="content-box",Dt.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box";var kt,Vt=function(e){return Object.freeze(e)},Ht=function(e,t){this.inlineSize=e,this.blockSize=t,Vt(this)},Pt=function(){function e(e,t,i,s){return this.x=e,this.y=t,this.width=i,this.height=s,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,Vt(this)}return e.prototype.toJSON=function(){var e=this;return{x:e.x,y:e.y,top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.width,height:e.height}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),jt=function(e){return e instanceof SVGElement&&"getBBox"in e},Wt=function(e){if(jt(e)){var t=e.getBBox(),i=t.width,s=t.height;return!i&&!s}var r=e,n=r.offsetWidth,o=r.offsetHeight;return!(n||o||e.getClientRects().length)},Gt=function(e){var t,i;if(e instanceof Element)return!0;var s=null===(i=null===(t=e)||void 0===t?void 0:t.ownerDocument)||void 0===i?void 0:i.defaultView;return!!(s&&e instanceof s.Element)},Zt="undefined"!=typeof window?window:{},Yt=new WeakMap,Ft=/auto|scroll/,Ut=/^tb|vertical/,qt=/msie|trident/i.test(Zt.navigator&&Zt.navigator.userAgent),Jt=function(e){return parseFloat(e||"0")},Qt=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=!1),new Ht((i?t:e)||0,(i?e:t)||0)},Kt=Vt({devicePixelContentBoxSize:Qt(),borderBoxSize:Qt(),contentBoxSize:Qt(),contentRect:new Pt(0,0,0,0)}),ei=function(e,t){if(void 0===t&&(t=!1),Yt.has(e)&&!t)return Yt.get(e);if(Wt(e))return Yt.set(e,Kt),Kt;var i=getComputedStyle(e),s=jt(e)&&e.ownerSVGElement&&e.getBBox(),r=!qt&&"border-box"===i.boxSizing,n=Ut.test(i.writingMode||""),o=!s&&Ft.test(i.overflowY||""),a=!s&&Ft.test(i.overflowX||""),h=s?0:Jt(i.paddingTop),l=s?0:Jt(i.paddingRight),c=s?0:Jt(i.paddingBottom),d=s?0:Jt(i.paddingLeft),u=s?0:Jt(i.borderTopWidth),f=s?0:Jt(i.borderRightWidth),p=s?0:Jt(i.borderBottomWidth),m=d+l,g=h+c,E=(s?0:Jt(i.borderLeftWidth))+f,b=u+p,v=a?e.offsetHeight-b-e.clientHeight:0,x=o?e.offsetWidth-E-e.clientWidth:0,_=r?m+E:0,w=r?g+b:0,y=s?s.width:Jt(i.width)-_-x,T=s?s.height:Jt(i.height)-w-v,$=y+m+x+E,B=T+g+v+b,S=Vt({devicePixelContentBoxSize:Qt(Math.round(y*devicePixelRatio),Math.round(T*devicePixelRatio),n),borderBoxSize:Qt($,B,n),contentBoxSize:Qt(y,T,n),contentRect:new Pt(d,h,y,T)});return Yt.set(e,S),S},ti=function(e,t,i){var s=ei(e,i),r=s.borderBoxSize,n=s.contentBoxSize,o=s.devicePixelContentBoxSize;switch(t){case Rt.DEVICE_PIXEL_CONTENT_BOX:return o;case Rt.BORDER_BOX:return r;default:return n}},ii=function(e){var t=ei(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=Vt([t.borderBoxSize]),this.contentBoxSize=Vt([t.contentBoxSize]),this.devicePixelContentBoxSize=Vt([t.devicePixelContentBoxSize])},si=function(e){if(Wt(e))return 1/0;for(var t=0,i=e.parentNode;i;)t+=1,i=i.parentNode;return t},ri=function(){var e=1/0,t=[];Xt.forEach((function(i){if(0!==i.activeTargets.length){var s=[];i.activeTargets.forEach((function(t){var i=new ii(t.target),r=si(t.target);s.push(i),t.lastReportedSize=ti(t.target,t.observedBox),r<e&&(e=r)})),t.push((function(){i.callback.call(i.observer,s,i.observer)})),i.activeTargets.splice(0,i.activeTargets.length)}}));for(var i=0,s=t;i<s.length;i++){(0,s[i])()}return e},ni=function(e){Xt.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(i){i.isActive()&&(si(i.target)>e?t.activeTargets.push(i):t.skippedTargets.push(i))}))}))},oi=function(){var e,t=0;for(ni(t);Xt.some((function(e){return e.activeTargets.length>0}));)t=ri(),ni(t);return Xt.some((function(e){return e.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?e=new ErrorEvent("error",{message:It}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=It),window.dispatchEvent(e)),t>0},ai=[],hi=function(e){if(!kt){var t=0,i=document.createTextNode("");new MutationObserver((function(){return ai.splice(0).forEach((function(e){return e()}))})).observe(i,{characterData:!0}),kt=function(){i.textContent=""+(t?t--:t++)}}ai.push(e),kt()},li=0,ci={attributes:!0,characterData:!0,childList:!0,subtree:!0},di=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],ui=function(e){return void 0===e&&(e=0),Date.now()+e},fi=!1,pi=new(function(){function e(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return e.prototype.run=function(e){var t=this;if(void 0===e&&(e=250),!fi){fi=!0;var i,s=ui(e);i=function(){var i=!1;try{i=oi()}finally{if(fi=!1,e=s-ui(),!li)return;i?t.run(1e3):e>0?t.run(e):t.start()}},hi((function(){requestAnimationFrame(i)}))}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var e=this,t=function(){return e.observer&&e.observer.observe(document.body,ci)};document.body?t():Zt.addEventListener("DOMContentLoaded",t)},e.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),di.forEach((function(t){return Zt.addEventListener(t,e.listener,!0)})))},e.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),di.forEach((function(t){return Zt.removeEventListener(t,e.listener,!0)})),this.stopped=!0)},e}()),mi=function(e){!li&&e>0&&pi.start(),!(li+=e)&&pi.stop()},gi=function(){function e(e,t){this.target=e,this.observedBox=t||Rt.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var e,t=ti(this.target,this.observedBox,!0);return e=this.target,jt(e)||function(e){switch(e.tagName){case"INPUT":if("image"!==e.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(e)||"inline"!==getComputedStyle(e).display||(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),Ei=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},bi=new WeakMap,vi=function(e,t){for(var i=0;i<e.length;i+=1)if(e[i].target===t)return i;return-1},xi=function(){function e(){}return e.connect=function(e,t){var i=new Ei(e,t);bi.set(e,i)},e.observe=function(e,t,i){var s=bi.get(e),r=0===s.observationTargets.length;vi(s.observationTargets,t)<0&&(r&&Xt.push(s),s.observationTargets.push(new gi(t,i&&i.box)),mi(1),pi.schedule())},e.unobserve=function(e,t){var i=bi.get(e),s=vi(i.observationTargets,t),r=1===i.observationTargets.length;s>=0&&(r&&Xt.splice(Xt.indexOf(i),1),i.observationTargets.splice(s,1),mi(-1))},e.disconnect=function(e){var t=this,i=bi.get(e);i.observationTargets.slice().forEach((function(i){return t.unobserve(e,i.target)})),i.activeTargets.splice(0,i.activeTargets.length)},e}(),_i=function(){function e(e){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof e)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");xi.connect(this,e)}return e.prototype.observe=function(e,t){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Gt(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");xi.observe(this,e,t)},e.prototype.unobserve=function(e){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Gt(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");xi.unobserve(this,e)},e.prototype.disconnect=function(){xi.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}();class wi{constructor({namespace:e,rootRect$:t,ratio$:i,highlightStage$:s,root:r=null}){this._sideEffect=new st,this.namespace=e,this.highlightStage$=s,this.root$=new pt(r),this.stageRect$=bt([t,s,i],(([e,t,i])=>{if(!t)return e;if(i<=0||e.width<=0||e.height<=0)return e;const s=e.width*i;if(s===e.height)return e;if(s<e.height)return{x:0,y:(e.height-s)/2,width:e.width,height:s};const r=e.height/i;return{x:(e.width-r)/2,y:0,width:r,height:e.height}}),{compare:Je}),this._sideEffect.addDisposer(bt([this.root$,s]).subscribe((([e,t])=>{var i;e&&t?e.appendChild(this.render()):(null==(i=this.$boxStage)?void 0:i.parentNode)&&this.$boxStage.remove()})))}render(){if(this.$boxStage)return this.$boxStage;const e=document.createElement("div");e.className=this.wrapClassName("box-stage-container");const t=document.createElement("div");t.className=this.wrapClassName("box-stage-mask");const i=document.createElement("div");i.className=this.wrapClassName("box-stage-mask");const s=document.createElement("div");s.className=this.wrapClassName("box-stage-frame");const[r,n,o,a]=["M0 8V0h8v2H2v6H0Z","M8 8V0H0v2h6v6h2Z","M0 0v8h8V6H2V0H0Z","M8 0v8H0V6h6V0h2Z"].map(((e,t)=>{const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("viewBox","0 0 8 8"),i.setAttribute("class",`${this.wrapClassName("box-stage-frame-corner")} is-${t}`);const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d",e),s.setAttribute("fill","#3381FF"),i.appendChild(s),i}));return s.appendChild(r),s.appendChild(o),s.appendChild(n),s.appendChild(a),e.appendChild(t),e.appendChild(s),e.appendChild(i),this._sideEffect.addDisposer(this.highlightStage$.subscribe((t=>{e.classList.toggle("is-active",t)}))),this._sideEffect.addDisposer(bt([this.highlightStage$,this.stageRect$]).subscribe((([s,r])=>{s&&(r.x>0?(e.style.flexDirection="row",t.style.width=`${r.x}px`,t.style.height="",i.style.width=`${r.x}px`,i.style.height=""):r.y>0&&(e.style.flexDirection="column",t.style.width="",t.style.height=`${r.y}px`,i.style.width="",i.style.height=`${r.y}px`))}))),this.$boxStage=e,e}mount(e){this.root$.setValue(e)}unmount(){this.root$.setValue(null)}destroy(){this._sideEffect.flushAll()}wrapClassName(e){return`${this.namespace}-${e}`}}const yi=window.ResizeObserver||_i;class Ti{constructor({id:e=tt(),title:t=zt(),namespace:i="telebox",visible:s=!0,width:r=.5,height:n=.5,minWidth:o=0,minHeight:a=0,x:h=.1,y:l=.1,resizable:c=!0,draggable:d=!0,ratio:u=-1,focus:f=!1,zIndex:p=100,titleBar:m,content:g,footer:E,styles:b,highlightStage:v=null,darkMode$:x,fence$:_,minimized$:w,maximized$:y,readonly$:T,rootRect$:$,managerStageRect$:S,stageRatio$:N,collectorRect$:C,managerHighlightStage$:L}){this.events=new B,this._delegateEvents=new B,this.handleTrackStart=e=>{var t;return null==(t=this._handleTrackStart)?void 0:t.call(this,e)},this._sideEffect=new st,this.id=e,this.namespace=i;const z=new pt(t),O=new pt(s),A=new pt(c),M=new pt(d),R=new pt(u),D=new pt(p),X=new pt(f),I=new pt(g),k=new pt(E),V=new pt(b),H=bt([w,y],(([e,t])=>e?exports.TELE_BOX_STATE.Minimized:t?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal)),P=new pt({width:St(o,0,1),height:St(a,0,1)},{compare:Je}),j=bt([P,S],(([e,t])=>({width:e.width*t.width,height:e.height*t.height})),{compare:Je}),W=new pt({width:r,height:n},{compare:Je});this._sideEffect.addDisposer(P.reaction(((e,t)=>{W.setValue({width:Math.max(r,e.width),height:Math.max(n,e.height)},t)})));const G=new pt({x:h,y:l},{compare:Je}),Z=bt([W,S],(([e,t])=>({width:t.width*e.width,height:t.height*e.height})),{compare:Je}),Y=bt([G,S],(([e,t])=>({x:e.x*t.width+t.x,y:e.y*t.height+t.y})),{compare:Je}),F=new pt(v),U=bt([y,F,L],(([e,t,i])=>null===t?i&&e:t)),q=new pt($.value,{compare:Je}),J=new wi({namespace:i,rootRect$:q,ratio$:N,highlightStage$:U});this._sideEffect.addDisposer((()=>J.destroy()));vt(this,{darkMode:x,fence:_,minimized:w,maximized:y,readonly:T,rootRect:$,managerStageRect:S,collectorRect:C,zIndex:D,focus:X,$userContent:I,$userFooter:k,$userStyles:V,state:H,minSize:P,pxMinSize:j,intrinsicSize:W,intrinsicCoord:G,pxIntrinsicSize:Z,pxIntrinsicCoord:Y,highlightStage:U,boxHighlightStage:F,contentRect:q,contentStageRect:J.stageRect$});xt(this,{title:z,visible:O,resizable:A,draggable:M,ratio:R}),this.titleBar=m||new Mt({readonly$:T,state$:H,title:z.value,namespace:this.namespace,onDragStart:e=>{var t;return null==(t=this._handleTrackStart)?void 0:t.call(this,e)},onEvent:e=>this._delegateEvents.emit(e.type)}),this._sideEffect.addDisposer(R.subscribe((e=>{e>0&&this.transform(Y.value.x,Y.value.y,Z.value.width,Z.value.height,!0)}))),this._sideEffect.addDisposer(_.subscribe((e=>{e&&this.move(Y.value.x,Y.value.y,!0)}))),this.$box=this.render(),J.root$.setValue(this.$content.parentElement);const Q=(e,t)=>{this._sideEffect.addDisposer(e.reaction(((e,i)=>{i||this.events.emit(t,e)})))};Q(x,exports.TELE_BOX_EVENT.DarkMode),Q(T,exports.TELE_BOX_EVENT.Readonly),Q(D,exports.TELE_BOX_EVENT.ZIndex),Q(w,exports.TELE_BOX_EVENT.Minimized),Q(y,exports.TELE_BOX_EVENT.Maximized),Q(H,exports.TELE_BOX_EVENT.State),Q(W,exports.TELE_BOX_EVENT.IntrinsicResize),Q(G,exports.TELE_BOX_EVENT.IntrinsicMove),this._sideEffect.addDisposer(O.reaction(((e,t)=>{t||e||this.events.emit(exports.TELE_BOX_EVENT.Close)}))),this._sideEffect.addDisposer(X.reaction(((e,t)=>{t||this.events.emit(e?exports.TELE_BOX_EVENT.Focus:exports.TELE_BOX_EVENT.Blur)})))}get minWidth(){return this._minSize$.value.width}get minHeight(){return this._minSize$.value.height}setMinWidth(e,t=!1){this._minSize$.setValue({width:e,height:this.minHeight},t)}setMinHeight(e,t=!1){this._minSize$.setValue({width:this.minWidth,height:e},t)}resize(e,t,i=!1){this._intrinsicSize$.setValue({width:Math.max(e,this.minWidth),height:Math.max(t,this.minHeight)},i)}get intrinsicX(){return this._intrinsicCoord$.value.x}get intrinsicY(){return this._intrinsicCoord$.value.y}get intrinsicWidth(){return this._intrinsicSize$.value.width}get intrinsicHeight(){return this._intrinsicSize$.value.height}move(e,t,i=!1){let s,r;const n=this.managerStageRect,o=this.pxIntrinsicSize;if(this.fence)s=St(e,n.x,n.x+n.width-o.width),r=St(t,n.y,n.y+n.height-o.height);else{const i=this.rootRect;s=St(e,i.x-o.width+20,i.x+i.width-20),r=St(t,i.y,i.y+i.height-20)}this._intrinsicCoord$.setValue({x:(s-n.x)/n.width,y:(r-n.y)/n.height},i)}transform(e,t,i,s,r=!1){const n=this.managerStageRect,o=this.rootRect;if(i=Math.max(i,this.pxMinSize.width),s=Math.max(s,this.pxMinSize.height),this.ratio>0){const e=this.ratio*i;t!==this.pxIntrinsicCoord.y&&(t-=e-s),s=e}t<o.y&&(t=o.y,s=this.pxIntrinsicSize.height),this.move(e,t,r),this._intrinsicSize$.setValue({width:i/n.width,height:s/n.height},r)}mount(e){e.appendChild(this.$box)}unmount(){this.$box.parentNode&&this.$box.remove()}mountContent(e){this._$userContent$.setValue(e)}unmountContent(){this._$userContent$.setValue(void 0)}mountFooter(e){this._$userFooter$.setValue(e)}unmountFooter(){this._$userFooter$.setValue(void 0)}getUserStyles(){return this.$userStyles}mountStyles(e){let t;"string"==typeof e?(t=document.createElement("style"),t.textContent=e):t=e,this._$userStyles$.setValue(t)}unmountStyles(){this._$userStyles$.setValue(void 0)}setHighlightStage(e){this._boxHighlightStage$.setValue(e)}render(){if(this.$box)return this.$box;this.$box=document.createElement("div"),this.$box.classList.add(this.wrapClassName("box"));const e=(e,t,i,s=Ot)=>this._sideEffect.add((()=>{const r=this.wrapClassName(i);return t.subscribe((t=>{e.classList.toggle(r,s(t))}))}));e(this.$box,this._readonly$,"readonly"),e(this.$box,this._draggable$,"no-drag",At),e(this.$box,this._resizable$,"no-resize",At),e(this.$box,this._focus$,"blur",At),e(this.$box,this._darkMode$,"color-scheme-dark"),e(this.$box,this._darkMode$,"color-scheme-light",At),this._sideEffect.add((()=>{const e=this.wrapClassName("minimized"),t=this.wrapClassName("maximized"),i="box-maximized-timer";return this._state$.subscribe((s=>{this.$box.classList.toggle(e,s===exports.TELE_BOX_STATE.Minimized),s===exports.TELE_BOX_STATE.Maximized?(this._sideEffect.flush(i),this.$box.classList.toggle(t,!0)):this._sideEffect.setTimeout((()=>{this.$box.classList.toggle(t,!1)}),0,i)}))})),this._sideEffect.addDisposer(this._visible$.subscribe((e=>{this.$box.style.display=e?"block":"none"}))),this._sideEffect.addDisposer(this._zIndex$.subscribe((e=>{this.$box.style.zIndex=String(e)}))),this.$box.dataset.teleBoxID=this.id;const t=qe(this.$box),i=bt([this._maximized$,this._minimized$,this._pxIntrinsicSize$,this._pxIntrinsicCoord$,this._collectorRect$],(([e,t,i,s,r])=>t&&r?{x:r.x+r.width/2,y:r.y+r.height/2,width:i.width+"px",height:i.height+"px",scaleX:r.width/i.width,scaleY:r.height/i.height}:e?{x:0,y:0,width:"100%",height:"100%",scaleX:1,scaleY:1}:{x:s.x,y:s.y,width:i.width+"px",height:i.height+"px",scaleX:1,scaleY:1}),{compare:Je}),s=i.value;this.$box.style.width=s.width,this.$box.style.height=s.height,this.$box.style.transform=`translate(${s.x-10}px,${s.y-10}px)`,this._sideEffect.addDisposer(i.subscribe((e=>{t.set(e)})));const r=document.createElement("div");r.className=this.wrapClassName("box-main"),this.$box.appendChild(r);const n=document.createElement("div");n.className=this.wrapClassName("titlebar-wrap"),n.appendChild(this.titleBar.render()),this.$titleBar=n;const o=document.createElement("div");o.className=this.wrapClassName("content-wrap");const a=document.createElement("div");a.className=this.wrapClassName("content")+" tele-fancy-scrollbar",this.$content=a,this._sideEffect.add((()=>{const e=new yi((e=>{var t;const i=null==(t=e[0])?void 0:t.contentRect;i&&this._contentRect$.setValue({x:i.x,y:i.y,width:i.width,height:i.height})}));return e.observe(a),()=>e.disconnect()})),this._sideEffect.add((()=>{let e;return this._$userStyles$.subscribe((t=>{e&&e.remove(),e=t,t&&o.appendChild(t)}))})),this._sideEffect.add((()=>{let e;return this._$userContent$.subscribe((t=>{e&&e.remove(),e=t,t&&a.appendChild(t)}))})),o.appendChild(a);const h=document.createElement("div");return h.className=this.wrapClassName("footer-wrap"),this.$footer=h,this._sideEffect.add((()=>{let e;return this._$userFooter$.subscribe((t=>{e&&e.remove(),e=t,t&&h.appendChild(t)}))})),r.appendChild(n),r.appendChild(o),r.appendChild(h),this._renderResizeHandlers(),this.$box}_renderResizeHandlers(){const e=document.createElement("div");e.className=this.wrapClassName("resize-handles"),Object.values(exports.TELE_BOX_RESIZE_HANDLE).forEach((t=>{const i=document.createElement("div");i.className=this.wrapClassName(t)+" "+this.wrapClassName("resize-handle"),i.dataset.teleBoxHandle=t,e.appendChild(i)})),this.$box.appendChild(e);const t="handle-tracking-listener",i=this.wrapClassName("transforming");let s,r,n=0,o=0,a=0,h=0,l=0,c=0;const d=e=>{if(this.state!==exports.TELE_BOX_STATE.Normal)return;Nt(e);let{pageX:t,pageY:i}=Ct(e);i<this.rootRect.y&&(i=this.rootRect.y);const s=t-l,d=i-c;let{x:u,y:f}=this.pxIntrinsicCoord,{width:p,height:m}=this.pxIntrinsicSize;switch(r){case exports.TELE_BOX_RESIZE_HANDLE.North:f=o+d,m=h-d;break;case exports.TELE_BOX_RESIZE_HANDLE.South:m=h+d;break;case exports.TELE_BOX_RESIZE_HANDLE.West:u=n+s,p=a-s;break;case exports.TELE_BOX_RESIZE_HANDLE.East:p=a+s;break;case exports.TELE_BOX_RESIZE_HANDLE.NorthWest:u=n+s,f=o+d,p=a-s,m=h-d;break;case exports.TELE_BOX_RESIZE_HANDLE.NorthEast:f=o+d,p=a+s,m=h-d;break;case exports.TELE_BOX_RESIZE_HANDLE.SouthEast:p=a+s,m=h+d;break;case exports.TELE_BOX_RESIZE_HANDLE.SouthWest:u=n+s,p=a-s,m=h+d;break;default:return void this.move(n+s,o+d)}this.transform(u,f,p,m)},u=e=>{r=void 0,s&&(Nt(e),this.$box.classList.toggle(i,!1),this._sideEffect.flush(t),s.remove())},f=e=>{var f;if(this.readonly)return;if(null!=e.button&&0!==e.button)return;if(!this.draggable||r||this.state!==exports.TELE_BOX_STATE.Normal)return;const p=e.target;if(null==(f=p.dataset)?void 0:f.teleBoxHandle){Nt(e),({x:n,y:o}=this.pxIntrinsicCoord),({width:a,height:h}=this.pxIntrinsicSize),({pageX:l,pageY:c}=Ct(e)),r=p.dataset.teleBoxHandle,s||(s=document.createElement("div"));const f=r?this.wrapClassName(`cursor-${r}`):"";s.className=this.wrapClassName("track-mask"+(f?` ${f}`:"")),this.$box.appendChild(s),this.$box.classList.add(i),this._sideEffect.add((()=>(window.addEventListener("mousemove",d),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("mouseup",u),window.addEventListener("touchend",u,{passive:!1}),window.addEventListener("touchcancel",u,{passive:!1}),()=>{window.removeEventListener("mousemove",d),window.removeEventListener("touchmove",d),window.removeEventListener("mouseup",u),window.removeEventListener("touchend",u),window.removeEventListener("touchcancel",u)})),t)}};this._handleTrackStart=f,this._sideEffect.addEventListener(e,"mousedown",f,{},"box-resizeHandles-mousedown"),this._sideEffect.addEventListener(e,"touchstart",f,{passive:!1},"box-resizeHandles-touchstart")}async destroy(){this.$box.remove(),this._sideEffect.flushAll(),this._sideEffect.flushAll(),await this.events.emit(exports.TELE_BOX_EVENT.Destroyed),this.events.clearListeners(),this._delegateEvents.clearListeners()}wrapClassName(e){return`${this.namespace}-${e}`}}var $i;class Bi{constructor({minimized$:e,readonly$:t,darkMode$:i,rootRect$:s,namespace:r="telebox",styles:n={},root:o}){this._sideEffect=new st,this.namespace=r;const a=new pt(void 0),h=e,l=new pt(n),c=new pt(o),d=new pt(document.createElement("button"));xt(this,{styles:l,root:c,el:d});vt(this,{rect:a,visible:h}),d.value.className=this.wrapClassName("collector"),d.value.style.backgroundImage="url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K')",this._sideEffect.addDisposer(d.subscribe((r=>{this._sideEffect.addEventListener(r,"click",(()=>{t.value||e.setValue(!1)}),{},"telebox-collector-click"),this._sideEffect.addDisposer([h.subscribe((e=>{r.classList.toggle(this.wrapClassName("collector-visible"),e)})),t.subscribe((e=>{r.classList.toggle(this.wrapClassName("collector-readonly"),e)})),i.subscribe((e=>{r.classList.toggle(this.wrapClassName("color-scheme-dark"),e),r.classList.toggle(this.wrapClassName("color-scheme-light"),!e)})),l.subscribe((e=>{Object.keys(e).forEach((t=>{const i=e[t];null!=i&&(r.style[t]=i)}))})),c.subscribe((e=>{e&&e.appendChild(r)})),bt([e,s,c]).subscribe((([e,t,i])=>{if(e&&i){const{x:e,y:i,width:s,height:n}=r.getBoundingClientRect();a.setValue({x:e-t.x,y:i-t.y,width:s,height:n})}}))],"telebox-collector-el")})))}destroy(){this._sideEffect.flushAll()}wrapClassName(e){return`${this.namespace}-${e}`}}exports.TELE_BOX_MANAGER_EVENT=void 0,($i=exports.TELE_BOX_MANAGER_EVENT||(exports.TELE_BOX_MANAGER_EVENT={})).Focused="focused",$i.Blurred="blurred",$i.Created="created",$i.Removed="removed",$i.State="state",$i.Maximized="maximized",$i.Minimized="minimized",$i.IntrinsicMove="intrinsic_move",$i.IntrinsicResize="intrinsic_resize",$i.ZIndex="z_index",$i.PrefersColorScheme="prefers_color_scheme",$i.DarkMode="dark_mode";class Si extends Mt{constructor(e){super(e),this.boxes$=e.boxes$,this.rootRect$=e.rootRect$,this.darkMode$=e.darkMode$}focusBox(e){var t;if(!this.focusedBox||this.focusedBox!==e){if(this.$titles&&this.state$.value===exports.TELE_BOX_STATE.Maximized){const{children:i}=this.$titles.firstElementChild;for(let s=i.length-1;s>=0;s-=1){const r=i[s],n=null==(t=r.dataset)?void 0:t.teleBoxID;n&&(e&&n===e.id?r.classList.toggle(this.wrapClassName("titles-tab-focus"),!0):this.focusedBox&&n===this.focusedBox.id&&r.classList.toggle(this.wrapClassName("titles-tab-focus"),!1))}}this.focusedBox=e}}render(){const e=super.render();e.classList.add(this.wrapClassName("max-titlebar")),this.sideEffect.addDisposer([this.rootRect$.subscribe((t=>{const{x:i,y:s,width:r}=t;e.style.transform=`translate(${i}px, ${s}px)`,e.style.width=r+"px"})),this.state$.subscribe((t=>{e.classList.toggle(this.wrapClassName("max-titlebar-maximized"),t===exports.TELE_BOX_STATE.Maximized)})),this.readonly$.subscribe((t=>{e.classList.toggle(this.wrapClassName("readonly"),t)})),this.darkMode$.subscribe((t=>{e.classList.toggle(this.wrapClassName("color-scheme-dark"),t),e.classList.toggle(this.wrapClassName("color-scheme-light"),!t)})),bt([this.state$,this.boxes$]).subscribe((([t,i])=>{t===exports.TELE_BOX_STATE.Maximized&&(e.classList.toggle(this.wrapClassName("max-titlebar-single-title"),1===i.length),1===i.length?this.setTitle(i[0].title):e.replaceChild(this.renderTitles(),e.firstElementChild))}))],"max-render");const t=document.createElement("div");return t.classList.add(this.wrapClassName("titles-area")),e.insertBefore(t,e.firstElementChild),e}destroy(){super.destroy(),this.$titles=void 0,this.focusedBox=void 0}renderTitles(){this.$titles=document.createElement("div"),this.$titles.className=this.wrapClassName("titles"),this.sideEffect.addEventListener(this.$titles,"wheel",(e=>{e.currentTarget.scrollBy({left:e.deltaY>0?250:-250,behavior:"smooth"})}),{passive:!1},"max-render-wheel-titles");const e=document.createElement("div");e.className=this.wrapClassName("titles-content"),this.$titles.appendChild(e);const t=this.boxes$.value.map((t=>{const i=document.createElement("button");return i.className=this.wrapClassName("titles-tab"),i.textContent=t.title,i.dataset.teleBoxID=t.id,i.dataset.teleTitleBarNoDblClick="true",this.focusedBox&&t.id===this.focusedBox.id&&i.classList.add(this.wrapClassName("titles-tab-focus")),e.appendChild(i),t._title$.reaction((e=>i.textContent=e))}));return this.sideEffect.addDisposer((()=>t.forEach((e=>e()))),"max-render-tab-titles"),this.$titles}}const Ni=window.ResizeObserver||_i;exports.DefaultTitleBar=Mt,exports.TeleBox=Ti,exports.TeleBoxCollector=Bi,exports.TeleBoxDragHandleType="dh",exports.TeleBoxManager=class{constructor({root:e=document.body,prefersColorScheme:t=exports.TELE_BOX_COLOR_SCHEME.Light,minimized:i=!1,maximized:s=!1,fence:r=!1,collector:n,namespace:o="telebox",readonly:a=!1,stageRatio:h=-1,highlightStage:l=!0}={}){this.events=new B,this._sideEffect=new st,this.root=e,this.namespace=o;const c=new pt(a),d=new pt(i),u=new pt(s),f=new pt(r),p=new pt(h),m=new pt(l),g=new pt({x:0,y:0,width:window.innerWidth,height:window.innerHeight},{compare:Je});this._sideEffect.add((()=>{const t=new Ni((e=>{this._sideEffect.setTimeout((()=>{var t;const i=null==(t=e[0])?void 0:t.contentRect;i&&g.setValue({x:i.x,y:i.y,width:i.width,height:i.height})}),50,"root-resize-observer")}));return t.observe(e),()=>t.disconnect()})),this.boxes$=new pt([]),this.topBox$=new pt(void 0),this._sideEffect.addDisposer(this.boxes$.subscribe((e=>{if(e.length>0){const t=e.reduce(((e,t)=>e.zIndex>t.zIndex?e:t));this.topBox$.setValue(t)}else this.topBox$.setValue(void 0)})));const E=window.matchMedia("(prefers-color-scheme: dark)"),b=new pt(!1);E&&(b.setValue(E.matches),this._sideEffect.add((()=>{const e=e=>{b.setValue(e.matches)};return E.addEventListener("change",e),()=>E.removeEventListener("change",e)})));const v=new pt(t);this._sideEffect.addDisposer(v.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.PrefersColorScheme,e)})));const x=bt([b,v],(([e,t])=>"auto"===t?e:"dark"===t)),_=bt([d,u],(([e,t])=>e?exports.TELE_BOX_STATE.Minimized:t?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal));this.collector=null!=n?n:new Bi({minimized$:d,readonly$:c,darkMode$:x,namespace:o,root:e,rootRect$:g});const w=new wi({namespace:o,rootRect$:g,ratio$:p,root:e,highlightStage$:m});this._sideEffect.addDisposer((()=>w.destroy()));vt(this,{darkMode:x,state:_,rootRect:g,stageRect:w.stageRect$});xt(this,{prefersColorScheme:v,readonly:c,fence:f,minimized:d,maximized:u,stageRatio:p,highlightStage:m});const y=this.wrapClassName("titlebar-icon-close"),T=e=>{var t;if(c.value)return;const i=e.target;if(i.tagName)for(let s=i;s;s=s.parentElement){if(s.classList&&s.classList.contains(y))return;const e=null==(t=s.dataset)?void 0:t.teleBoxID;if(e){const t=this.getBox(e);if(t)return this.focusBox(t),void this.makeBoxTop(t)}}};this._sideEffect.addEventListener(window,"mousedown",T,!0),this._sideEffect.addEventListener(window,"touchstart",T,!0),this.titleBar=new Si({namespace:this.namespace,boxes$:this.boxes$,darkMode$:x,readonly$:c,state$:_,rootRect$:g,onEvent:e=>{switch(e.type){case exports.TELE_BOX_DELEGATE_EVENT.Maximize:u.setValue(!u.value);break;case exports.TELE_BOX_DELEGATE_EVENT.Minimize:d.setValue(!0);break;case exports.TELE_BOX_EVENT.Close:this.removeTopBox(),this.focusTopBox()}}}),this.root.appendChild(this.titleBar.render()),this._sideEffect.addDisposer([_.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.State,e)})),u.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Maximized,e)})),d.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Minimized,e)})),x.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.DarkMode,e)}))])}get boxes(){return this.boxes$.value}get topBox(){return this.topBox$.value}setState(e,t=!1){switch(e){case exports.TELE_BOX_STATE.Maximized:this.setMinimized(!1,t),this.setMaximized(!0,t);break;case exports.TELE_BOX_STATE.Minimized:this.setMinimized(!0,t),this.setMaximized(!1,t);break;default:this.setMinimized(!1,t),this.setMaximized(!1,t)}return this}create(e={},s=!0){const r=new Ti((n=a(a({zIndex:this.topBox?this.topBox.zIndex+1:100},e),s?this.smartPosition(e):{}),o={namespace:this.namespace,darkMode$:this._darkMode$,maximized$:this._maximized$,minimized$:this._minimized$,fence$:this._fence$,rootRect$:this._rootRect$,managerStageRect$:this._stageRect$,stageRatio$:this._stageRatio$,readonly$:this._readonly$,collectorRect$:this.collector._rect$,managerHighlightStage$:this._highlightStage$},t(n,i(o))));var n,o;return r.mount(this.root),r.focus&&(this.focusBox(r),s&&this.makeBoxTop(r)),this.boxes$.setValue([...this.boxes,r]),this._sideEffect.addDisposer([r._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Maximize,(()=>{this.setMaximized(!this.maximized)})),r._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Minimize,(()=>{this.setMinimized(!0)})),r._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Close,(()=>{this.remove(r),this.focusTopBox()})),r._intrinsicCoord$.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicMove,r)})),r._intrinsicSize$.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicResize,r)})),r._zIndex$.reaction(((e,t)=>{if(this.boxes.length>0){const e=this.boxes.reduce(((e,t)=>e.zIndex>t.zIndex?e:t));this.topBox$.setValue(e)}t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.ZIndex,r)}))]),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Created,r),r}query(e){return e?this.boxes.filter(this.teleBoxMatcher(e)):[...this.boxes]}queryOne(e){return e?this.boxes.find(this.teleBoxMatcher(e)):this.boxes[0]}update(e,t,i=!1){const s=this.boxes.find((t=>t.id===e));if(s)return this.updateBox(s,t,i)}updateAll(e,t=!1){this.boxes.forEach((i=>{this.updateBox(i,e,t)}))}remove(e,t=!1){const i=this.getBoxIndex(e);if(i>=0){const e=this.boxes.slice(),s=e.splice(i,1);return this.boxes$.setValue(e),s.forEach((e=>e.destroy())),t||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,s)),s[0]}}removeTopBox(){if(this.topBox)return this.remove(this.topBox)}removeAll(e=!1){const t=this.boxes$.value;return this.boxes$.setValue([]),t.forEach((e=>e.destroy())),e||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,t)),t}destroy(e=!1){this.events.clearListeners(),this._sideEffect.flushAll(),this.removeAll(e),this.collector.destroy(),this.titleBar.destroy()}wrapClassName(e){return`${this.namespace}-${e}`}focusBox(e,t=!1){const i=this.getBox(e);i&&(this.boxes.forEach((e=>{if(i===e){let e=!1;i.focus||(e=!0,i._focus$.setValue(!0,t)),e&&!t&&this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,i)}else e.focus&&this.blurBox(e,t)})),this.titleBar.focusBox(i))}focusTopBox(){if(this.topBox&&!this.topBox.focus)return this.focusBox(this.topBox)}blurBox(e,t=!1){const i=this.getBox(e);i&&(i.focus&&(i._focus$.setValue(!1,t),t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Blurred,i)),this.titleBar.focusedBox===i&&this.titleBar.focusBox())}blurAll(e=!1){this.boxes.forEach((t=>{t.focus&&(t._focus$.setValue(!1,e),e||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Blurred,t))})),this.titleBar.focusedBox&&this.titleBar.focusBox()}teleBoxMatcher(e){const t=Object.keys(e);return i=>t.every((t=>e[t]===i[t]))}updateBox(e,t,i=!1){var s,r,n,o,a,h;null==t.x&&null==t.y||e._intrinsicCoord$.setValue({x:null!=(s=t.x)?s:e.intrinsicX,y:null!=(r=t.y)?r:e.intrinsicY},i),null==t.width&&null==t.height||e._intrinsicSize$.setValue({width:null!=(n=t.width)?n:e.intrinsicWidth,height:null!=(o=t.height)?o:e.intrinsicHeight},i),null!=t.title&&e._title$.setValue(t.title),null!=t.visible&&e._visible$.setValue(t.visible,i),null!=t.resizable&&e._resizable$.setValue(t.resizable,i),null!=t.draggable&&e._draggable$.setValue(t.draggable,i),null!=t.ratio&&e._ratio$.setValue(t.ratio,i),null!=t.zIndex&&e._zIndex$.setValue(t.zIndex,i),null!=t.content&&e.mountContent(t.content),null!=t.footer&&e.mountFooter(t.footer),null==t.minHeight&&null==t.minWidth||e._minSize$.setValue({width:null!=(a=t.minWidth)?a:e.minWidth,height:null!=(h=t.minHeight)?h:e.minHeight},i)}smartPosition(e){let{x:t,y:i}=e;const{width:s=.5,height:r=.5}=e,n=this.stageRect,o=this.topBox;if(null==t){let e=n.x+20;if(o){const t=o.pxIntrinsicCoord.x+20;t+s*n.width<=n.x+n.width&&(e=t)}t=(e-n.x)/n.width}if(null==i){let e=n.y+20;if(o){const t=o.pxIntrinsicCoord.y+20;t+r*n.height<=n.y+n.height&&(e=t)}i=(e-n.y)/n.height}return{x:t,y:i,width:s,height:r}}makeBoxTop(e,t=!1){this.topBox&&e!==this.topBox&&e._zIndex$.setValue(this.topBox.zIndex+1,t)}getBoxIndex(e){return"string"==typeof e?this.boxes.findIndex((t=>t.id===e)):this.boxes.findIndex((t=>t===e))}getBox(e){return"string"==typeof e?this.boxes.find((t=>t.id===e)):e}};
1
+ "use strict";var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i,n=(e,t)=>{for(var s in t||(t={}))a.call(t,s)&&r(e,s,t[s]);if(i)for(var s of i(t))o.call(t,s)&&r(e,s,t[s]);return e};Object.defineProperty(exports,"__esModule",{value:!0}),exports[Symbol.toStringTag]="Module";var l=require("emittery"),h=require("stylefire"),d=require("shallowequal"),c=require("side-effect-manager"),E=require("value-enhancer"),m=require("@juggle/resize-observer");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x,p,_,g,f,b=u(l),$=u(h),v=u(d);exports.TELE_BOX_COLOR_SCHEME=void 0,(x=exports.TELE_BOX_COLOR_SCHEME||(exports.TELE_BOX_COLOR_SCHEME={})).Light="light",x.Dark="dark",x.Auto="auto",exports.TELE_BOX_STATE=void 0,(p=exports.TELE_BOX_STATE||(exports.TELE_BOX_STATE={})).Normal="normal",p.Minimized="minimized",p.Maximized="maximized",exports.TELE_BOX_EVENT=void 0,(_=exports.TELE_BOX_EVENT||(exports.TELE_BOX_EVENT={})).DarkMode="dark_mode",_.PrefersColorScheme="prefers_color_scheme",_.Close="close",_.Focus="focus",_.Blur="blur",_.IntrinsicMove="intrinsic_move",_.IntrinsicResize="intrinsic_resize",_.ZIndex="z_index",_.State="state",_.Minimized="minimized",_.Maximized="maximized",_.Readonly="readonly",_.Destroyed="destroyed",exports.TELE_BOX_DELEGATE_EVENT=void 0,(g=exports.TELE_BOX_DELEGATE_EVENT||(exports.TELE_BOX_DELEGATE_EVENT={})).Close="close",g.Maximize="maximize",g.Minimize="minimize",exports.TELE_BOX_RESIZE_HANDLE=void 0,(f=exports.TELE_BOX_RESIZE_HANDLE||(exports.TELE_BOX_RESIZE_HANDLE={})).North="n",f.South="s",f.West="w",f.East="e",f.NorthWest="nw",f.NorthEast="ne",f.SouthEast="se",f.SouthWest="sw";function w(e,t,s){return Math.min(Math.max(e,t),s)}function T(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}function B(e){return e.touches?e.touches[0]:e}let N=1;function C(){return"New Box "+N++}function L(e){return Boolean(e)}function y(e){return!e}class z{constructor({readonly$:e,state$:t,title$:s,buttons:i,onEvent:a,onDragStart:o,namespace:r="telebox"}){this.sideEffect=new c.SideEffectManager,this.lastTitleBarClick={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarClick=e=>{var t;if(this.readonly$.value)return;if(0!==e.button)return;if(null==(t=e.target.dataset)?void 0:t.teleTitleBarNoDblClick)return;T(e);const s=Date.now();s-this.lastTitleBarClick.timestamp<=500?Math.abs(e.clientX-this.lastTitleBarClick.clientX)<=5&&Math.abs(e.clientY-this.lastTitleBarClick.clientY)<=5&&this.onEvent&&this.onEvent({type:exports.TELE_BOX_DELEGATE_EVENT.Maximize}):this.onDragStart&&this.onDragStart(e),this.lastTitleBarClick.timestamp=s,this.lastTitleBarClick.clientX=e.clientX,this.lastTitleBarClick.clientY=e.clientY},this.lastTitleBarTouch={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarTouch=e=>{var t;if(this.readonly$.value)return;if(null==(t=e.target.dataset)?void 0:t.teleTitleBarNoDblClick)return;T(e);const s=Date.now(),{clientX:i=this.lastTitleBarTouch.clientX+100,clientY:a=this.lastTitleBarTouch.clientY+100}=e.touches[0]||{};s-this.lastTitleBarTouch.timestamp<=500?Math.abs(i-this.lastTitleBarTouch.clientX)<=10&&Math.abs(a-this.lastTitleBarTouch.clientY)<=10&&this.onEvent&&this.onEvent({type:exports.TELE_BOX_DELEGATE_EVENT.Maximize}):this.onDragStart&&this.onDragStart(e),this.lastTitleBarTouch.timestamp=s,this.lastTitleBarTouch.clientX=i,this.lastTitleBarTouch.clientY=a},this.readonly$=e,this.state$=t,this.title$=s,this.onEvent=a,this.onDragStart=o,this.namespace=r,this.buttons=i||[{type:exports.TELE_BOX_DELEGATE_EVENT.Minimize,iconClassName:this.wrapClassName("titlebar-icon-minimize")},{type:exports.TELE_BOX_DELEGATE_EVENT.Maximize,iconClassName:this.wrapClassName("titlebar-icon-maximize"),isActive:e=>e===exports.TELE_BOX_STATE.Maximized},{type:exports.TELE_BOX_DELEGATE_EVENT.Close,iconClassName:this.wrapClassName("titlebar-icon-close")}],this.$dragArea=this.renderDragArea()}render(){if(!this.$titleBar){this.$titleBar=document.createElement("div"),this.$titleBar.className=this.wrapClassName("titlebar");const e=document.createElement("div");e.className=this.wrapClassName("title-area"),e.dataset.teleBoxHandle="dh";const t=document.createElement("h1");t.className=this.wrapClassName("title"),t.dataset.teleBoxHandle="dh",e.appendChild(t),e.appendChild(this.$dragArea);const s=document.createElement("div");s.className=this.wrapClassName("titlebar-btns"),this.buttons.forEach((({iconClassName:e},t)=>{const i=String(t),a=document.createElement("button");a.className=`${this.wrapClassName("titlebar-btn")} ${e}`,a.dataset.teleTitleBarBtnIndex=i,a.dataset.teleTitleBarNoDblClick="true",s.appendChild(a)})),this.sideEffect.addDisposer(this.title$.subscribe((e=>{t.textContent=e,t.title=e})),"render-title"),this.sideEffect.addDisposer(this.state$.subscribe((e=>{this.buttons.forEach(((t,i)=>{var a;t.isActive&&(null==(a=s.children[i])||a.classList.toggle("is-active",t.isActive(e)))}))})),"render-state-btns"),this.sideEffect.addEventListener(s,"click",(e=>{var t;if(this.readonly$.value)return;const s=e.target,i=Number(null==(t=s.dataset)?void 0:t.teleTitleBarBtnIndex);if(!Number.isNaN(i)&&i<this.buttons.length){T(e);const t=this.buttons[i];this.onEvent&&this.onEvent({type:t.type,value:t.value})}}),{},"render-btns-container-click"),this.$titleBar.appendChild(e),this.$titleBar.appendChild(s)}return this.$titleBar}renderDragArea(){const e=document.createElement("div");return e.className=this.wrapClassName("drag-area"),e.dataset.teleBoxHandle="dh",this.sideEffect.addEventListener(e,"mousedown",this.handleTitleBarClick),this.sideEffect.addEventListener(e,"touchstart",this.handleTitleBarTouch,{passive:!0}),e}dragHandle(){return this.$titleBar}wrapClassName(e){return`${this.namespace}-${e}`}destroy(){this.sideEffect.flushAll(),this.$titleBar&&(this.$titleBar=void 0,this.onDragStart=void 0,this.onEvent=void 0)}}class V{constructor({namespace:e,rootRect$:t,ratio$:s,highlightStage$:i,root$:a}){this._sideEffect=new c.SideEffectManager,this.namespace=e,this.highlightStage$=i,this.stageRect$=E.combine([t,s],(([e,t])=>{if(t<=0||e.width<=0||e.height<=0)return e;const s=e.width*t;if(s===e.height)return e;if(s<e.height)return{x:0,y:(e.height-s)/2,width:e.width,height:s};const i=e.height/t;return{x:(e.width-i)/2,y:0,width:i,height:e.height}}),{compare:v.default}),this._sideEffect.addDisposer(E.combine([a,i]).subscribe((([e,t])=>{var s;e&&t?e.appendChild(this.render()):(null==(s=this.$boxStage)?void 0:s.parentNode)&&this.$boxStage.remove()})))}render(){if(this.$boxStage)return this.$boxStage;const e=document.createElement("div");e.className=this.wrapClassName("box-stage-container");const t=document.createElement("div");t.className=this.wrapClassName("box-stage-mask");const s=document.createElement("div");s.className=this.wrapClassName("box-stage-mask");const i=document.createElement("div");i.className=this.wrapClassName("box-stage-frame");const[a,o,r,n]=["M0 8V0h8v2H2v6H0Z","M8 8V0H0v2h6v6h2Z","M0 0v8h8V6H2V0H0Z","M8 0v8H0V6h6V0h2Z"].map(((e,t)=>{const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("viewBox","0 0 8 8"),s.setAttribute("class",`${this.wrapClassName("box-stage-frame-corner")} is-${t}`);const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),i.setAttribute("fill","#3381FF"),s.appendChild(i),s}));return i.appendChild(a),i.appendChild(r),i.appendChild(o),i.appendChild(n),e.appendChild(t),e.appendChild(i),e.appendChild(s),this._sideEffect.addDisposer(this.highlightStage$.subscribe((t=>{e.classList.toggle("is-active",t)}))),this._sideEffect.addDisposer(E.combine([this.highlightStage$,this.stageRect$]).subscribe((([i,a])=>{i&&(a.x>0?(e.style.flexDirection="row",t.style.width=`${a.x}px`,t.style.height="",s.style.width=`${a.x}px`,s.style.height=""):a.y>0&&(e.style.flexDirection="column",t.style.width="",t.style.height=`${a.y}px`,s.style.width="",s.style.height=`${a.y}px`))}))),this.$boxStage=e,e}destroy(){this._sideEffect.flushAll()}wrapClassName(e){return`${this.namespace}-${e}`}}const S=window.ResizeObserver||m.ResizeObserver;class M{constructor({id:e=c.genUID(),title:t=C(),namespace:s="telebox",visible:i=!0,width:a=.5,height:o=.5,minWidth:r=0,minHeight:n=0,x:l=.1,y:h=.1,resizable:d=!0,draggable:m=!0,ratio:u=-1,focus:x=!1,zIndex:p=100,titleBar:_,content:g,footer:f,styles:$,highlightStage:T=null,darkMode$:B,fence$:N,minimized$:L,maximized$:y,readonly$:S,root$:M,rootRect$:A,managerStageRect$:O,stageRatio$:R,collectorRect$:X,managerHighlightStage$:D}){this.events=new b.default,this._delegateEvents=new b.default,this.handleTrackStart=e=>{var t;return null==(t=this._handleTrackStart)?void 0:t.call(this,e)},this._sideEffect=new c.SideEffectManager,this.id=e,this.namespace=s;const I=new E.ValManager;this._sideEffect.addDisposer((()=>I.destroy()));const k=new E.Val(t),H=new E.Val(i),G=new E.Val(d),Z=new E.Val(m),W=new E.Val(u),Y=new E.Val(p),P=new E.Val(x),j=new E.Val(g),F=new E.Val(f),q=new E.Val($),J=E.combine([L,y],(([e,t])=>e?exports.TELE_BOX_STATE.Minimized:t?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal)),Q=new E.Val({width:w(r,0,1),height:w(n,0,1)},{compare:v.default}),U=E.combine([Q,O],(([e,t])=>({width:e.width*t.width,height:e.height*t.height})),{compare:v.default}),K=new E.Val({width:a,height:o},{compare:v.default});this._sideEffect.addDisposer(Q.reaction(((e,t)=>{K.setValue({width:Math.max(a,e.width),height:Math.max(o,e.height)},t)})));const ee=new E.Val({x:l,y:h},{compare:v.default}),te=E.combine([K,O],(([e,t])=>({width:t.width*e.width,height:t.height*e.height})),{compare:v.default}),se=E.combine([ee,O],(([e,t])=>({x:e.x*t.width+t.x,y:e.y*t.height+t.y})),{compare:v.default}),ie=new E.Val(T),ae=E.combine([y,ie,D],(([e,t,s])=>null===t?s&&e:t)),oe=new E.Val(null),re=new E.Val(A.value,{compare:v.default}),ne=new V({namespace:s,root$:oe,rootRect$:re,ratio$:R,highlightStage$:ae});this._sideEffect.addDisposer((()=>ne.destroy()));const le={darkMode:B,fence:N,minimized:L,maximized:y,readonly:S,rootRect:A,managerStageRect:O,collectorRect:X};E.withReadonlyValueEnhancer(this,le);const he={zIndex:Y,focus:P,$userContent:j,$userFooter:F,$userStyles:q,state:J,minSize:Q,pxMinSize:U,intrinsicSize:K,intrinsicCoord:ee,pxIntrinsicSize:te,pxIntrinsicCoord:se,highlightStage:ae,boxHighlightStage:ie,contentRect:re,contentStageRect:ne.stageRect$};E.withReadonlyValueEnhancer(this,he,I);const de={title:k,visible:H,resizable:G,draggable:Z,ratio:W};E.withValueEnhancer(this,de,I),this.titleBar=_||new z({readonly$:S,state$:J,title$:k,namespace:this.namespace,onDragStart:e=>{var t;return null==(t=this._handleTrackStart)?void 0:t.call(this,e)},onEvent:e=>this._delegateEvents.emit(e.type)}),this._sideEffect.addDisposer(W.subscribe((e=>{e>0&&this.transform(se.value.x,se.value.y,te.value.width,te.value.height,!0)}))),this._sideEffect.addDisposer(N.subscribe((e=>{e&&this.move(se.value.x,se.value.y,!0)}))),this.$box=this.render(),oe.setValue(this.$content.parentElement);const ce=(e,t)=>{this._sideEffect.addDisposer(e.reaction(((e,s)=>{s||this.events.emit(t,e)})))};ce(B,exports.TELE_BOX_EVENT.DarkMode),ce(S,exports.TELE_BOX_EVENT.Readonly),ce(Y,exports.TELE_BOX_EVENT.ZIndex),ce(L,exports.TELE_BOX_EVENT.Minimized),ce(y,exports.TELE_BOX_EVENT.Maximized),ce(J,exports.TELE_BOX_EVENT.State),ce(K,exports.TELE_BOX_EVENT.IntrinsicResize),ce(ee,exports.TELE_BOX_EVENT.IntrinsicMove),this._sideEffect.addDisposer([H.reaction(((e,t)=>{t||e||this.events.emit(exports.TELE_BOX_EVENT.Close)})),P.reaction(((e,t)=>{t||this.events.emit(e?exports.TELE_BOX_EVENT.Focus:exports.TELE_BOX_EVENT.Blur)})),M.subscribe((e=>{e?e.appendChild(this.$box):this.$box.parentNode&&this.$box.remove()}))])}get minWidth(){return this._minSize$.value.width}get minHeight(){return this._minSize$.value.height}setMinWidth(e,t=!1){this._minSize$.setValue({width:e,height:this.minHeight},t)}setMinHeight(e,t=!1){this._minSize$.setValue({width:this.minWidth,height:e},t)}resize(e,t,s=!1){this._intrinsicSize$.setValue({width:Math.max(e,this.minWidth),height:Math.max(t,this.minHeight)},s)}get intrinsicX(){return this._intrinsicCoord$.value.x}get intrinsicY(){return this._intrinsicCoord$.value.y}get intrinsicWidth(){return this._intrinsicSize$.value.width}get intrinsicHeight(){return this._intrinsicSize$.value.height}move(e,t,s=!1){let i,a;const o=this.managerStageRect,r=this.pxIntrinsicSize;if(this.fence)i=w(e,o.x,o.x+o.width-r.width),a=w(t,o.y,o.y+o.height-r.height);else{const s=this.rootRect;i=w(e,0-r.width+20,0+s.width-20),a=w(t,0,0+s.height-20)}this._intrinsicCoord$.setValue({x:(i-o.x)/o.width,y:(a-o.y)/o.height},s)}transform(e,t,s,i,a=!1){const o=this.managerStageRect,r=this.rootRect;if(s=Math.max(s,this.pxMinSize.width),i=Math.max(i,this.pxMinSize.height),this.ratio>0){const e=this.ratio*s;t!==this.pxIntrinsicCoord.y&&(t-=e-i),i=e}t<r.y&&(t=r.y,i=this.pxIntrinsicSize.height),this.move(e,t,a),this._intrinsicSize$.setValue({width:s/o.width,height:i/o.height},a)}mountContent(e){this._$userContent$.setValue(e)}unmountContent(){this._$userContent$.setValue(void 0)}mountFooter(e){this._$userFooter$.setValue(e)}unmountFooter(){this._$userFooter$.setValue(void 0)}getUserStyles(){return this.$userStyles}mountStyles(e){let t;"string"==typeof e?(t=document.createElement("style"),t.textContent=e):t=e,this._$userStyles$.setValue(t)}unmountStyles(){this._$userStyles$.setValue(void 0)}setHighlightStage(e){this._boxHighlightStage$.setValue(e)}render(){if(this.$box)return this.$box;this.$box=document.createElement("div"),this.$box.classList.add(this.wrapClassName("box"));const e=(e,t,s,i=L)=>this._sideEffect.add((()=>{const a=this.wrapClassName(s);return t.subscribe((t=>{e.classList.toggle(a,i(t))}))}));e(this.$box,this._readonly$,"readonly"),e(this.$box,this._draggable$,"no-drag",y),e(this.$box,this._resizable$,"no-resize",y),e(this.$box,this._focus$,"blur",y),e(this.$box,this._darkMode$,"color-scheme-dark"),e(this.$box,this._darkMode$,"color-scheme-light",y),this._sideEffect.add((()=>{const e=this.wrapClassName("minimized"),t=this.wrapClassName("maximized"),s="box-maximized-timer";return this._state$.subscribe((i=>{this.$box.classList.toggle(e,i===exports.TELE_BOX_STATE.Minimized),i===exports.TELE_BOX_STATE.Maximized?(this._sideEffect.flush(s),this.$box.classList.toggle(t,!0)):this._sideEffect.setTimeout((()=>{this.$box.classList.toggle(t,!1)}),0,s)}))})),this._sideEffect.addDisposer(this._visible$.subscribe((e=>{this.$box.style.display=e?"block":"none"}))),this._sideEffect.addDisposer(this._zIndex$.subscribe((e=>{this.$box.style.zIndex=String(e)}))),this.$box.dataset.teleBoxID=this.id;const t=$.default(this.$box),s=E.combine([this._maximized$,this._minimized$,this._pxIntrinsicSize$,this._pxIntrinsicCoord$,this._collectorRect$],(([e,t,s,i,a])=>{const o=e?{x:0,y:0,width:"100%",height:"100%",scaleX:1,scaleY:1}:{x:i.x,y:i.y,width:s.width+"px",height:s.height+"px",scaleX:1,scaleY:1};if(t&&a){const{width:t,height:i}=e?this.rootRect:s;o.x=a.x-t/2+a.width/2,o.y=a.y-i/2+a.height/2,o.scaleX=a.width/t,o.scaleY=a.height/i}return o}),{compare:v.default}),i=s.value;this.$box.style.width=i.width,this.$box.style.height=i.height,this.$box.style.transform=`translate(${i.x-10}px,${i.y-10}px)`,this._sideEffect.addDisposer(s.subscribe((e=>{t.set(e)})));const a=document.createElement("div");a.className=this.wrapClassName("box-main"),this.$box.appendChild(a);const o=document.createElement("div");o.className=this.wrapClassName("titlebar-wrap"),o.appendChild(this.titleBar.render()),this.$titleBar=o;const r=document.createElement("div");r.className=this.wrapClassName("content-wrap");const n=document.createElement("div");n.className=this.wrapClassName("content")+" tele-fancy-scrollbar",this.$content=n,this._sideEffect.add((()=>{const e=new S((()=>{const e=n.getBoundingClientRect();this._contentRect$.setValue({x:e.x,y:e.y,width:e.width,height:e.height})}));return e.observe(n),()=>e.disconnect()})),this._sideEffect.add((()=>{let e;return this._$userStyles$.subscribe((t=>{e&&e.remove(),e=t,t&&r.appendChild(t)}))})),this._sideEffect.add((()=>{let e;return this._$userContent$.subscribe((t=>{e&&e.remove(),e=t,t&&n.appendChild(t)}))})),r.appendChild(n);const l=document.createElement("div");return l.className=this.wrapClassName("footer-wrap"),this.$footer=l,this._sideEffect.add((()=>{let e;return this._$userFooter$.subscribe((t=>{e&&e.remove(),e=t,t&&l.appendChild(t)}))})),a.appendChild(o),a.appendChild(r),a.appendChild(l),this._renderResizeHandlers(),this.$box}_renderResizeHandlers(){const e=document.createElement("div");e.className=this.wrapClassName("resize-handles"),Object.values(exports.TELE_BOX_RESIZE_HANDLE).forEach((t=>{const s=document.createElement("div");s.className=this.wrapClassName(t)+" "+this.wrapClassName("resize-handle"),s.dataset.teleBoxHandle=t,e.appendChild(s)})),this.$box.appendChild(e);const t="handle-tracking-listener",s=this.wrapClassName("transforming");let i,a,o=0,r=0,n=0,l=0,h=0,d=0;const c=e=>{if(this.state!==exports.TELE_BOX_STATE.Normal)return;T(e);let{pageX:t,pageY:s}=B(e);s<this.rootRect.y&&(s=this.rootRect.y);const i=t-h,c=s-d;let{x:E,y:m}=this.pxIntrinsicCoord,{width:u,height:x}=this.pxIntrinsicSize;switch(a){case exports.TELE_BOX_RESIZE_HANDLE.North:m=r+c,x=l-c;break;case exports.TELE_BOX_RESIZE_HANDLE.South:x=l+c;break;case exports.TELE_BOX_RESIZE_HANDLE.West:E=o+i,u=n-i;break;case exports.TELE_BOX_RESIZE_HANDLE.East:u=n+i;break;case exports.TELE_BOX_RESIZE_HANDLE.NorthWest:E=o+i,m=r+c,u=n-i,x=l-c;break;case exports.TELE_BOX_RESIZE_HANDLE.NorthEast:m=r+c,u=n+i,x=l-c;break;case exports.TELE_BOX_RESIZE_HANDLE.SouthEast:u=n+i,x=l+c;break;case exports.TELE_BOX_RESIZE_HANDLE.SouthWest:E=o+i,u=n-i,x=l+c;break;default:return void this.move(o+i,r+c)}this.transform(E,m,u,x)},E=e=>{a=void 0,i&&(T(e),this.$box.classList.toggle(s,!1),this._sideEffect.flush(t),i.remove())},m=e=>{var m;if(this.readonly)return;if(null!=e.button&&0!==e.button)return;if(!this.draggable||a||this.state!==exports.TELE_BOX_STATE.Normal)return;const u=e.target;if(null==(m=u.dataset)?void 0:m.teleBoxHandle){T(e),({x:o,y:r}=this.pxIntrinsicCoord),({width:n,height:l}=this.pxIntrinsicSize),({pageX:h,pageY:d}=B(e)),a=u.dataset.teleBoxHandle,i||(i=document.createElement("div"));const m=a?this.wrapClassName(`cursor-${a}`):"";i.className=this.wrapClassName("track-mask"+(m?` ${m}`:"")),this.$box.appendChild(i),this.$box.classList.add(s),this._sideEffect.add((()=>(window.addEventListener("mousemove",c),window.addEventListener("touchmove",c,{passive:!1}),window.addEventListener("mouseup",E),window.addEventListener("touchend",E,{passive:!1}),window.addEventListener("touchcancel",E,{passive:!1}),()=>{window.removeEventListener("mousemove",c),window.removeEventListener("touchmove",c),window.removeEventListener("mouseup",E),window.removeEventListener("touchend",E),window.removeEventListener("touchcancel",E)})),t)}};this._handleTrackStart=m,this._sideEffect.addEventListener(e,"mousedown",m,{},"box-resizeHandles-mousedown"),this._sideEffect.addEventListener(e,"touchstart",m,{passive:!1},"box-resizeHandles-touchstart")}async destroy(){this.$box.remove(),this._sideEffect.flushAll(),this._sideEffect.flushAll(),await this.events.emit(exports.TELE_BOX_EVENT.Destroyed),this.events.clearListeners(),this._delegateEvents.clearListeners()}wrapClassName(e){return`${this.namespace}-${e}`}}var A;class O{constructor({minimized$:e,readonly$:t,darkMode$:s,rootRect$:i,namespace:a="telebox",styles:o={},root$:r}){this._sideEffect=new c.SideEffectManager,this.namespace=a;const n=new E.ValManager;this._sideEffect.addDisposer((()=>n.destroy()));const l=new E.Val(void 0),h=E.derive(e),d=new E.Val(o),m=new E.Val(document.createElement("button")),u={styles:d,$collector:m};E.withValueEnhancer(this,u,n);const x={root:r};E.withReadonlyValueEnhancer(this,x);const p={rect:l,visible:h};E.withReadonlyValueEnhancer(this,p,n),m.value.className=this.wrapClassName("collector"),m.value.style.backgroundImage="url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K')",this._sideEffect.addDisposer(m.subscribe((a=>{this._sideEffect.addEventListener(a,"click",(()=>{t.value||e.setValue(!1)}),{},"telebox-collector-click"),this._sideEffect.addDisposer([h.subscribe((e=>{a.classList.toggle(this.wrapClassName("collector-visible"),e)})),t.subscribe((e=>{a.classList.toggle(this.wrapClassName("collector-readonly"),e)})),s.subscribe((e=>{a.classList.toggle(this.wrapClassName("color-scheme-dark"),e),a.classList.toggle(this.wrapClassName("color-scheme-light"),!e)})),d.subscribe((e=>{Object.keys(e).forEach((t=>{const s=e[t];null!=s&&(a.style[t]=s)}))})),r.subscribe((e=>{e&&e.appendChild(a)})),E.combine([e,i,r]).subscribe((([e,t,s])=>{if(e&&s){const{x:e,y:s,width:i,height:o}=a.getBoundingClientRect();l.setValue({x:e-t.x,y:s-t.y,width:i,height:o})}}))],"telebox-collector-el")})))}destroy(){this._sideEffect.flushAll()}wrapClassName(e){return`${this.namespace}-${e}`}}exports.TELE_BOX_MANAGER_EVENT=void 0,(A=exports.TELE_BOX_MANAGER_EVENT||(exports.TELE_BOX_MANAGER_EVENT={})).Focused="focused",A.Blurred="blurred",A.Created="created",A.Removed="removed",A.State="state",A.Maximized="maximized",A.Minimized="minimized",A.IntrinsicMove="intrinsic_move",A.IntrinsicResize="intrinsic_resize",A.ZIndex="z_index",A.PrefersColorScheme="prefers_color_scheme",A.DarkMode="dark_mode";class R extends z{constructor(e){super(e),this.boxes$=e.boxes$,this.rootRect$=e.rootRect$,this.darkMode$=e.darkMode$,this.sideEffect.addDisposer(e.root$.subscribe((e=>{var t;e?e.appendChild(this.render()):(null==(t=this.$titleBar)?void 0:t.parentNode)&&this.$titleBar.remove()})))}focusBox(e){var t;if(!this.focusedBox||this.focusedBox!==e){if(this.$titles&&this.state$.value===exports.TELE_BOX_STATE.Maximized){const{children:s}=this.$titles.firstElementChild;for(let i=s.length-1;i>=0;i-=1){const a=s[i],o=null==(t=a.dataset)?void 0:t.teleBoxID;o&&(e&&o===e.id?a.classList.toggle(this.wrapClassName("titles-tab-focus"),!0):this.focusedBox&&o===this.focusedBox.id&&a.classList.toggle(this.wrapClassName("titles-tab-focus"),!1))}}this.focusedBox=e}}render(){if(this.$titleBar)return this.$titleBar;const e=super.render();e.classList.add(this.wrapClassName("max-titlebar")),this.sideEffect.addDisposer([this.state$.subscribe((t=>{e.classList.toggle(this.wrapClassName("max-titlebar-maximized"),t===exports.TELE_BOX_STATE.Maximized)})),this.readonly$.subscribe((t=>{e.classList.toggle(this.wrapClassName("readonly"),t)})),this.darkMode$.subscribe((t=>{e.classList.toggle(this.wrapClassName("color-scheme-dark"),t),e.classList.toggle(this.wrapClassName("color-scheme-light"),!t)})),E.combine([this.state$,this.boxes$]).subscribe((([t,s])=>{t===exports.TELE_BOX_STATE.Maximized&&(e.classList.toggle(this.wrapClassName("max-titlebar-single-title"),1===s.length),1!==s.length&&e.replaceChild(this.renderTitles(),e.firstElementChild))}))],"max-render");const t=document.createElement("div");return t.classList.add(this.wrapClassName("titles-area")),e.insertBefore(t,e.firstElementChild),e}destroy(){super.destroy(),this.$titles=void 0,this.focusedBox=void 0}renderTitles(){this.$titles=document.createElement("div"),this.$titles.className=this.wrapClassName("titles"),this.sideEffect.addEventListener(this.$titles,"wheel",(e=>{e.currentTarget.scrollBy({left:e.deltaY>0?250:-250,behavior:"smooth"})}),{passive:!1},"max-render-wheel-titles");const e=document.createElement("div");e.className=this.wrapClassName("titles-content"),this.$titles.appendChild(e);const t=this.boxes$.value.map((t=>{const s=document.createElement("button");return s.className=this.wrapClassName("titles-tab"),s.textContent=t.title,s.dataset.teleBoxID=t.id,s.dataset.teleTitleBarNoDblClick="true",this.focusedBox&&t.id===this.focusedBox.id&&s.classList.add(this.wrapClassName("titles-tab-focus")),e.appendChild(s),t._title$.reaction((e=>s.textContent=e))}));return this.sideEffect.addDisposer((()=>t.forEach((e=>e()))),"max-render-tab-titles"),this.$titles}}const X=window.ResizeObserver||m.ResizeObserver;exports.DefaultTitleBar=z,exports.TeleBox=M,exports.TeleBoxCollector=O,exports.TeleBoxDragHandleType="dh",exports.TeleBoxManager=class{constructor({root:e=null,prefersColorScheme:t=exports.TELE_BOX_COLOR_SCHEME.Light,minimized:s=!1,maximized:i=!1,fence:a=!1,collector:o,namespace:r="telebox",readonly:n=!1,stageRatio:l=-1,highlightStage:h=!0}={}){this.events=new b.default,this._sideEffect=new c.SideEffectManager,this.namespace=r;const d=new E.ValManager;this._sideEffect.addDisposer((()=>d.destroy()));const m=new E.Val(e),u=new E.Val(n),x=new E.Val(s),p=new E.Val(i),_=new E.Val(a),g=new E.Val(l),f=new E.Val(h),$=new E.Val({x:0,y:0,width:window.innerWidth,height:window.innerHeight},{compare:v.default});this._sideEffect.addDisposer(m.subscribe((e=>{this._sideEffect.add((()=>{if(!e)return()=>{};const t=new X((()=>{const t=e.getBoundingClientRect();$.setValue({x:t.x,y:t.y,width:t.width,height:t.height})}));return t.observe(e),()=>t.disconnect()}),"calc-root-rect")}))),this.boxes$=new E.Val([]),this.topBox$=new E.Val(void 0),this._sideEffect.addDisposer(this.boxes$.subscribe((e=>{if(e.length>0){const t=e.reduce(((e,t)=>e.zIndex>t.zIndex?e:t));this.topBox$.setValue(t)}else this.topBox$.setValue(void 0)})));const w=window.matchMedia("(prefers-color-scheme: dark)"),T=new E.Val(!1);w&&(T.setValue(w.matches),this._sideEffect.add((()=>{const e=e=>{T.setValue(e.matches)};return w.addEventListener("change",e),()=>w.removeEventListener("change",e)})));const B=new E.Val(t);this._sideEffect.addDisposer(B.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.PrefersColorScheme,e)})));const N=E.combine([T,B],(([e,t])=>"auto"===t?e:"dark"===t)),C=E.combine([x,p],(([e,t])=>e?exports.TELE_BOX_STATE.Minimized:t?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal));this.collector=null!=o?o:new O({minimized$:x,readonly$:u,darkMode$:N,namespace:r,root$:m,rootRect$:$});const L=new V({namespace:r,rootRect$:$,ratio$:g,root$:m,highlightStage$:E.combine([f,p,x],(([e,t,s])=>e&&(s||!t)))});this._sideEffect.addDisposer((()=>L.destroy()));const y={darkMode:N,state:C,root:m,rootRect:$,stageRect:L.stageRect$};E.withReadonlyValueEnhancer(this,y,d);const z={prefersColorScheme:B,readonly:u,fence:_,minimized:x,maximized:p,stageRatio:g,highlightStage:f};E.withValueEnhancer(this,z,d);const S=this.wrapClassName("titlebar-icon-close"),M=e=>{var t;if(u.value)return;const s=e.target;if(s.tagName)for(let i=s;i;i=i.parentElement){if(i.classList&&i.classList.contains(S))return;const e=null==(t=i.dataset)?void 0:t.teleBoxID;if(e){const t=this.getBox(e);if(t)return this.focusBox(t),void this.makeBoxTop(t)}}};this._sideEffect.addEventListener(window,"mousedown",M,!0),this._sideEffect.addEventListener(window,"touchstart",M,!0),this.titleBar=new R({namespace:this.namespace,title$:E.derive(this.topBox$,(e=>(null==e?void 0:e.title)||"")),boxes$:this.boxes$,darkMode$:N,readonly$:u,state$:C,root$:m,rootRect$:$,onEvent:e=>{switch(e.type){case exports.TELE_BOX_DELEGATE_EVENT.Maximize:p.setValue(!p.value);break;case exports.TELE_BOX_DELEGATE_EVENT.Minimize:x.setValue(!0);break;case exports.TELE_BOX_EVENT.Close:this.removeTopBox(),this.focusTopBox()}}}),this._sideEffect.addDisposer([C.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.State,e)})),p.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Maximized,e)})),x.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Minimized,e)})),N.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.DarkMode,e)}))])}get boxes(){return this.boxes$.value}get topBox(){return this.topBox$.value}setState(e,t=!1){switch(e){case exports.TELE_BOX_STATE.Maximized:this.setMinimized(!1,t),this.setMaximized(!0,t);break;case exports.TELE_BOX_STATE.Minimized:this.setMinimized(!0,t),this.setMaximized(!1,t);break;default:this.setMinimized(!1,t),this.setMaximized(!1,t)}return this}create(e={},i=!0){const a=new M((o=n(n({zIndex:this.topBox?this.topBox.zIndex+1:100},e),i?this.smartPosition(e):{}),r={namespace:this.namespace,root$:this._root$,darkMode$:this._darkMode$,maximized$:this._maximized$,minimized$:this._minimized$,fence$:this._fence$,rootRect$:this._rootRect$,managerStageRect$:this._stageRect$,stageRatio$:this._stageRatio$,readonly$:this._readonly$,collectorRect$:this.collector._rect$,managerHighlightStage$:this._highlightStage$},t(o,s(r))));var o,r;return a.focus&&(this.focusBox(a),i&&this.makeBoxTop(a)),this.boxes$.setValue([...this.boxes,a]),this._sideEffect.addDisposer([a._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Maximize,(()=>{this.setMaximized(!this.maximized)})),a._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Minimize,(()=>{this.setMinimized(!0)})),a._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Close,(()=>{this.remove(a),this.focusTopBox()})),a._intrinsicCoord$.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicMove,a)})),a._intrinsicSize$.reaction(((e,t)=>{t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicResize,a)})),a._zIndex$.reaction(((e,t)=>{if(this.boxes.length>0){const e=this.boxes.reduce(((e,t)=>e.zIndex>t.zIndex?e:t));this.topBox$.setValue(e)}t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.ZIndex,a)}))]),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Created,a),a}query(e){return e?this.boxes.filter(this.teleBoxMatcher(e)):[...this.boxes]}queryOne(e){return e?this.boxes.find(this.teleBoxMatcher(e)):this.boxes[0]}update(e,t,s=!1){const i=this.boxes.find((t=>t.id===e));if(i)return this.updateBox(i,t,s)}updateAll(e,t=!1){this.boxes.forEach((s=>{this.updateBox(s,e,t)}))}remove(e,t=!1){const s=this.getBoxIndex(e);if(s>=0){const e=this.boxes.slice(),i=e.splice(s,1);return this.boxes$.setValue(e),i.forEach((e=>e.destroy())),t||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,i)),i[0]}}removeTopBox(){if(this.topBox)return this.remove(this.topBox)}removeAll(e=!1){const t=this.boxes$.value;return this.boxes$.setValue([]),t.forEach((e=>e.destroy())),e||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,t)),t}mount(e){this._root$.setValue(e)}unmount(){this._root$.setValue(null)}destroy(e=!1){this.events.clearListeners(),this._sideEffect.flushAll(),this.removeAll(e),this.collector.destroy(),this.titleBar.destroy()}wrapClassName(e){return`${this.namespace}-${e}`}focusBox(e,t=!1){const s=this.getBox(e);s&&(this.boxes.forEach((e=>{if(s===e){let e=!1;s.focus||(e=!0,s._focus$.setValue(!0,t)),e&&!t&&this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,s)}else e.focus&&this.blurBox(e,t)})),this.titleBar.focusBox(s))}focusTopBox(){if(this.topBox&&!this.topBox.focus)return this.focusBox(this.topBox)}blurBox(e,t=!1){const s=this.getBox(e);s&&(s.focus&&(s._focus$.setValue(!1,t),t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Blurred,s)),this.titleBar.focusedBox===s&&this.titleBar.focusBox())}blurAll(e=!1){this.boxes.forEach((t=>{t.focus&&(t._focus$.setValue(!1,e),e||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Blurred,t))})),this.titleBar.focusedBox&&this.titleBar.focusBox()}teleBoxMatcher(e){const t=Object.keys(e);return s=>t.every((t=>e[t]===s[t]))}updateBox(e,t,s=!1){var i,a,o,r,n,l;null==t.x&&null==t.y||e._intrinsicCoord$.setValue({x:null!=(i=t.x)?i:e.intrinsicX,y:null!=(a=t.y)?a:e.intrinsicY},s),null==t.width&&null==t.height||e._intrinsicSize$.setValue({width:null!=(o=t.width)?o:e.intrinsicWidth,height:null!=(r=t.height)?r:e.intrinsicHeight},s),null!=t.title&&e._title$.setValue(t.title),null!=t.visible&&e._visible$.setValue(t.visible,s),null!=t.resizable&&e._resizable$.setValue(t.resizable,s),null!=t.draggable&&e._draggable$.setValue(t.draggable,s),null!=t.ratio&&e._ratio$.setValue(t.ratio,s),null!=t.zIndex&&e._zIndex$.setValue(t.zIndex,s),null!=t.content&&e.mountContent(t.content),null!=t.footer&&e.mountFooter(t.footer),null==t.minHeight&&null==t.minWidth||e._minSize$.setValue({width:null!=(n=t.minWidth)?n:e.minWidth,height:null!=(l=t.minHeight)?l:e.minHeight},s)}smartPosition(e){let{x:t,y:s}=e;const{width:i=.5,height:a=.5}=e,o=this.stageRect,r=this.topBox;if(null==t){let e=o.x+20;if(r){const t=r.pxIntrinsicCoord.x+20;t+i*o.width<=o.x+o.width&&(e=t)}t=(e-o.x)/o.width}if(null==s){let e=o.y+20;if(r){const t=r.pxIntrinsicCoord.y+20;t+a*o.height<=o.y+o.height&&(e=t)}s=(e-o.y)/o.height}return{x:t,y:s,width:i,height:a}}makeBoxTop(e,t=!1){this.topBox&&e!==this.topBox&&e._zIndex$.setValue(this.topBox.zIndex+1,t)}getBoxIndex(e){return"string"==typeof e?this.boxes.findIndex((t=>t.id===e)):this.boxes.findIndex((t=>t===e))}getBox(e){return"string"==typeof e?this.boxes.find((t=>t.id===e)):e}};
16
2
  //# sourceMappingURL=telebox-insider.cjs.js.map