@netless/telebox-insider 0.2.0 → 0.2.4
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.
- package/dist/TeleBox/constants.d.ts +2 -0
- package/dist/TeleBox/index.d.ts +40 -69
- package/dist/TeleBox/typings.d.ts +2 -0
- package/dist/TeleBoxManager/constants.d.ts +2 -0
- package/dist/TeleBoxManager/index.d.ts +14 -23
- package/dist/TeleBoxManager/typings.d.ts +2 -0
- package/dist/telebox-insider.cjs.js +2 -2
- package/dist/telebox-insider.cjs.js.map +1 -1
- package/dist/telebox-insider.es.js +2 -2
- package/dist/telebox-insider.es.js.map +1 -1
- package/package.json +4 -3
- package/src/TeleBox/constants.ts +2 -0
- package/src/TeleBox/index.ts +194 -315
- package/src/TeleBox/typings.ts +2 -0
- package/src/TeleBoxManager/constants.ts +2 -0
- package/src/TeleBoxManager/index.ts +100 -130
- package/src/TeleBoxManager/typings.ts +2 -0
- package/dist/Val/CombinedVal.d.ts +0 -11
- package/dist/Val/ComputedVal.d.ts +0 -7
- package/dist/Val/Val.d.ts +0 -15
- package/dist/Val/index.d.ts +0 -3
- package/src/Val/CombinedVal.ts +0 -39
- package/src/Val/ComputedVal.ts +0 -28
- package/src/Val/Val.ts +0 -73
- package/src/Val/index.ts +0 -3
package/dist/TeleBox/index.d.ts
CHANGED
|
@@ -1,80 +1,63 @@
|
|
|
1
1
|
import "./style.scss";
|
|
2
|
+
import { SideEffectManager } from "side-effect-manager";
|
|
3
|
+
import { Val, ValEnhancedResult, ValSideEffectBinder } from "value-enhancer";
|
|
2
4
|
import { TeleTitleBar } from "../TeleTitleBar";
|
|
3
5
|
import type { TeleBoxConfig, TeleBoxRect, TeleBoxEvents, TeleBoxState, TeleBoxDelegateEvents, TeleBoxCoord, TeleBoxSize } from "./typings";
|
|
4
|
-
import { SideEffectManager } from "side-effect-manager";
|
|
5
|
-
import { Val } from "../Val";
|
|
6
6
|
export * from "./constants";
|
|
7
7
|
export * from "./typings";
|
|
8
|
+
declare type ValConfig = {
|
|
9
|
+
containerRect: Val<TeleBoxRect, boolean>;
|
|
10
|
+
collectorRect: Val<TeleBoxRect | undefined, boolean>;
|
|
11
|
+
/** Box title. Default empty. */
|
|
12
|
+
title: Val<string, boolean>;
|
|
13
|
+
/** Is box visible */
|
|
14
|
+
visible: Val<boolean, boolean>;
|
|
15
|
+
/** Is box readonly */
|
|
16
|
+
readonly: Val<boolean, boolean>;
|
|
17
|
+
/** Able to resize box window */
|
|
18
|
+
resizable: Val<boolean, boolean>;
|
|
19
|
+
/** Able to drag box window */
|
|
20
|
+
draggable: Val<boolean, boolean>;
|
|
21
|
+
/** Restrict box to always be within the containing area. */
|
|
22
|
+
fence: Val<boolean, boolean>;
|
|
23
|
+
/** Fixed width/height ratio for box window. */
|
|
24
|
+
fixRatio: Val<boolean, boolean>;
|
|
25
|
+
focus: Val<boolean, boolean>;
|
|
26
|
+
zIndex: Val<number, boolean>;
|
|
27
|
+
/** Is box minimized. Default false. */
|
|
28
|
+
minimized: Val<boolean, boolean>;
|
|
29
|
+
/** Is box maximized. Default false. */
|
|
30
|
+
maximized: Val<boolean, boolean>;
|
|
31
|
+
$userContent: Val<HTMLElement | undefined>;
|
|
32
|
+
$userFooter: Val<HTMLElement | undefined>;
|
|
33
|
+
$userStyles: Val<HTMLStyleElement | undefined>;
|
|
34
|
+
};
|
|
35
|
+
export interface TeleBox extends ValEnhancedResult<ValConfig> {
|
|
36
|
+
}
|
|
8
37
|
export declare class TeleBox {
|
|
9
38
|
constructor({ id, title, visible, width, height, minWidth, minHeight, x, y, minimized, maximized, readonly, resizable, draggable, fence, fixRatio, focus, zIndex, namespace, titleBar, content, footer, styles, containerRect, collectorRect, }?: TeleBoxConfig);
|
|
10
39
|
readonly id: string;
|
|
11
|
-
/**
|
|
40
|
+
/** ClassName Prefix. For CSS styling. Default "telebox" */
|
|
12
41
|
readonly namespace: string;
|
|
13
42
|
readonly events: TeleBoxEvents;
|
|
14
43
|
readonly _delegateEvents: TeleBoxDelegateEvents;
|
|
15
44
|
protected _sideEffect: SideEffectManager;
|
|
45
|
+
protected _valSideEffectBinder: ValSideEffectBinder;
|
|
16
46
|
titleBar: TeleTitleBar;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/** Box title. Default empty. */
|
|
25
|
-
get title(): string;
|
|
26
|
-
/**
|
|
27
|
-
* Update box title.
|
|
28
|
-
* @param title new box title
|
|
29
|
-
* @returns this
|
|
30
|
-
*/
|
|
31
|
-
setTitle(title: string): this;
|
|
32
|
-
protected _visible: Val<boolean, boolean>;
|
|
33
|
-
get visible(): boolean;
|
|
34
|
-
setVisible(visible: boolean, skipUpdate?: boolean): this;
|
|
35
|
-
protected _readonly: Val<boolean, boolean>;
|
|
36
|
-
/** Is box readonly */
|
|
37
|
-
get readonly(): boolean;
|
|
38
|
-
setReadonly(readonly: boolean, skipUpdate?: boolean): this;
|
|
39
|
-
protected _resizable: Val<boolean, boolean>;
|
|
40
|
-
/** Able to resize box window */
|
|
41
|
-
get resizable(): boolean;
|
|
42
|
-
setResizable(resizable: boolean, skipUpdate?: boolean): this;
|
|
43
|
-
protected _draggable: Val<boolean, boolean>;
|
|
44
|
-
/** Able to drag box window */
|
|
45
|
-
get draggable(): boolean;
|
|
46
|
-
setDraggable(draggable: boolean, skipUpdate?: boolean): this;
|
|
47
|
-
protected _fence: Val<boolean, boolean>;
|
|
48
|
-
/** Restrict box to always be within the containing area. */
|
|
49
|
-
get fence(): boolean;
|
|
50
|
-
setFence(fence: boolean, skipUpdate?: boolean): this;
|
|
51
|
-
protected _fixRatio: Val<boolean, boolean>;
|
|
52
|
-
/** Fixed width/height ratio for box window. */
|
|
53
|
-
get fixRatio(): boolean;
|
|
54
|
-
setFixRatio(fixRatio: boolean, skipUpdate?: boolean): this;
|
|
55
|
-
protected _focus: Val<boolean, boolean>;
|
|
56
|
-
get focus(): boolean;
|
|
57
|
-
setFocus(focus: boolean, skipUpdate?: boolean): this;
|
|
58
|
-
protected _zIndex: Val<number, boolean>;
|
|
59
|
-
get zIndex(): number;
|
|
60
|
-
setZIndex(zIndex: number, skipUpdate?: boolean): this;
|
|
61
|
-
protected _minimized: Val<boolean, boolean>;
|
|
62
|
-
get minimized(): boolean;
|
|
63
|
-
setMinimized(minimized: boolean, skipUpdate?: boolean): this;
|
|
64
|
-
protected _maximized: Val<boolean, boolean>;
|
|
65
|
-
get maximized(): boolean;
|
|
66
|
-
setMaximized(maximized: boolean, skipUpdate?: boolean): this;
|
|
67
|
-
protected _state: Val<TeleBoxState, boolean>;
|
|
68
|
-
/** Is box maximized. Default false. */
|
|
47
|
+
_minSize$: Val<TeleBoxSize, boolean>;
|
|
48
|
+
_size$: Val<TeleBoxSize, boolean>;
|
|
49
|
+
_intrinsicSize$: Val<TeleBoxSize, boolean>;
|
|
50
|
+
_visualSize$: Val<TeleBoxSize, boolean>;
|
|
51
|
+
_coord$: Val<TeleBoxCoord, boolean>;
|
|
52
|
+
_intrinsicCoord$: Val<TeleBoxCoord, boolean>;
|
|
53
|
+
_state$: Val<TeleBoxState, boolean>;
|
|
69
54
|
get state(): TeleBoxState;
|
|
70
55
|
/** @deprecated use setMaximized and setMinimized instead */
|
|
71
56
|
setState(state: TeleBoxState, skipUpdate?: boolean): this;
|
|
72
|
-
protected _minSize: Val<TeleBoxSize, boolean>;
|
|
73
57
|
/** Minimum box width relative to container element. 0~1. Default 0. */
|
|
74
58
|
get minWidth(): number;
|
|
75
59
|
/** Minimum box height relative to container element. 0~1. Default 0. */
|
|
76
60
|
get minHeight(): number;
|
|
77
|
-
setMinSize(size: TeleBoxSize, skipUpdate?: boolean): this;
|
|
78
61
|
/**
|
|
79
62
|
* @param minWidth Minimum box width relative to container element. 0~1.
|
|
80
63
|
* @returns this
|
|
@@ -85,12 +68,10 @@ export declare class TeleBox {
|
|
|
85
68
|
* @returns this
|
|
86
69
|
*/
|
|
87
70
|
setMinHeight(minHeight: number, skipUpdate?: boolean): this;
|
|
88
|
-
protected _intrinsicSize: Val<TeleBoxSize, boolean>;
|
|
89
71
|
/** Intrinsic box width relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.5. */
|
|
90
72
|
get intrinsicWidth(): number;
|
|
91
73
|
/** Intrinsic box height relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.5. */
|
|
92
74
|
get intrinsicHeight(): number;
|
|
93
|
-
setIntrinsicSize(size: TeleBoxSize, skipUpdate?: boolean): this;
|
|
94
75
|
/**
|
|
95
76
|
* Resize box.
|
|
96
77
|
* @param width Box width relative to container element. 0~1.
|
|
@@ -99,7 +80,6 @@ export declare class TeleBox {
|
|
|
99
80
|
* @returns this
|
|
100
81
|
*/
|
|
101
82
|
resize(width: number, height: number, skipUpdate?: boolean): this;
|
|
102
|
-
protected _size: Val<TeleBoxSize, boolean>;
|
|
103
83
|
/** Box width relative to container element. 0~1. Default 0.5. */
|
|
104
84
|
get width(): number;
|
|
105
85
|
/** Box height relative to container element. 0~1. Default 0.5. */
|
|
@@ -108,17 +88,14 @@ export declare class TeleBox {
|
|
|
108
88
|
get absoluteWidth(): number;
|
|
109
89
|
/** Box height in pixels. */
|
|
110
90
|
get absoluteHeight(): number;
|
|
111
|
-
protected _visualSize: Val<TeleBoxSize, boolean>;
|
|
112
91
|
/** Actual rendered box width relative to container element. 0~1. Default 0.5. */
|
|
113
92
|
get visualWidth(): number;
|
|
114
93
|
/** Actual rendered box height relative to container element. 0~1. Default 0.5. */
|
|
115
94
|
get visualHeight(): number;
|
|
116
|
-
protected _intrinsicCoord: Val<TeleBoxCoord, boolean>;
|
|
117
95
|
/** Intrinsic box x position relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.1. */
|
|
118
96
|
get intrinsicX(): number;
|
|
119
97
|
/** Intrinsic box y position relative to container element(without counting the effect of maximization or minimization). 0~1. Default 0.1. */
|
|
120
98
|
get intrinsicY(): number;
|
|
121
|
-
setIntrinsicCoord(coord: TeleBoxCoord, skipUpdate?: boolean): this;
|
|
122
99
|
/**
|
|
123
100
|
* Move box position.
|
|
124
101
|
* @param x x position relative to container element. 0~1.
|
|
@@ -127,7 +104,6 @@ export declare class TeleBox {
|
|
|
127
104
|
* @returns this
|
|
128
105
|
*/
|
|
129
106
|
move(x: number, y: number, skipUpdate?: boolean): this;
|
|
130
|
-
protected _coord: Val<TeleBoxCoord, boolean>;
|
|
131
107
|
/** Box x position relative to container element. 0~1. Default 0.1. */
|
|
132
108
|
get x(): number;
|
|
133
109
|
/** Box y position relative to container element. 0~1. Default 0.1. */
|
|
@@ -142,8 +118,6 @@ export declare class TeleBox {
|
|
|
142
118
|
* @returns this
|
|
143
119
|
*/
|
|
144
120
|
transform(x: number, y: number, width: number, height: number, skipUpdate?: boolean): this;
|
|
145
|
-
protected _$userContent: Val<HTMLElement | undefined>;
|
|
146
|
-
get $userContent(): HTMLElement | undefined;
|
|
147
121
|
/**
|
|
148
122
|
* Mount box to a container element.
|
|
149
123
|
*/
|
|
@@ -160,8 +134,6 @@ export declare class TeleBox {
|
|
|
160
134
|
* Unmount content from the box.
|
|
161
135
|
*/
|
|
162
136
|
unmountContent(): this;
|
|
163
|
-
protected _$userFooter: Val<HTMLElement | undefined>;
|
|
164
|
-
get $userFooter(): HTMLElement | undefined;
|
|
165
137
|
/**
|
|
166
138
|
* Mount dom to box Footer.
|
|
167
139
|
*/
|
|
@@ -170,7 +142,6 @@ export declare class TeleBox {
|
|
|
170
142
|
* Unmount Footer from the box.
|
|
171
143
|
*/
|
|
172
144
|
unmountFooter(): this;
|
|
173
|
-
protected _$userStyles: Val<HTMLStyleElement | undefined>;
|
|
174
145
|
getUserStyles(): HTMLStyleElement | undefined;
|
|
175
146
|
mountStyles(styles: string | HTMLStyleElement): this;
|
|
176
147
|
unmountStyles(): this;
|
|
@@ -3,10 +3,20 @@ import { TeleBoxCollector } from "../TeleBoxCollector";
|
|
|
3
3
|
import { ReadonlyTeleBox, TeleBox } from "../TeleBox";
|
|
4
4
|
import type { TeleBoxManagerConfig, TeleBoxManagerCreateConfig, TeleBoxManagerEvents, TeleBoxManagerQueryConfig, TeleBoxManagerUpdateConfig } from "./typings";
|
|
5
5
|
import { MaxTitleBar } from "./MaxTitleBar";
|
|
6
|
-
import { Val } from "../Val";
|
|
7
6
|
import { SideEffectManager } from "side-effect-manager";
|
|
7
|
+
import { Val, ValEnhancedResult } from "value-enhancer";
|
|
8
8
|
export * from "./typings";
|
|
9
9
|
export * from "./constants";
|
|
10
|
+
declare type ValConfig = {
|
|
11
|
+
containerRect: Val<TeleBoxRect, boolean>;
|
|
12
|
+
collector: Val<TeleBoxCollector | null>;
|
|
13
|
+
readonly: Val<boolean, boolean>;
|
|
14
|
+
minimized: Val<boolean, boolean>;
|
|
15
|
+
maximized: Val<boolean, boolean>;
|
|
16
|
+
fence: Val<boolean, boolean>;
|
|
17
|
+
};
|
|
18
|
+
export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {
|
|
19
|
+
}
|
|
10
20
|
export declare class TeleBoxManager {
|
|
11
21
|
constructor({ root, minimized, maximized, fence, containerRect, collector, namespace, zIndex, readonly, }?: TeleBoxManagerConfig);
|
|
12
22
|
readonly events: TeleBoxManagerEvents;
|
|
@@ -14,27 +24,10 @@ export declare class TeleBoxManager {
|
|
|
14
24
|
protected root: HTMLElement;
|
|
15
25
|
readonly namespace: string;
|
|
16
26
|
zIndex: number;
|
|
17
|
-
|
|
18
|
-
get collector(): TeleBoxCollector | null;
|
|
19
|
-
setCollector(collector: TeleBoxCollector): void;
|
|
20
|
-
protected _readonly: Val<boolean, boolean>;
|
|
21
|
-
/** Is box readonly */
|
|
22
|
-
get readonly(): boolean;
|
|
23
|
-
setReadonly(readonly: boolean, skipUpdate?: boolean): this;
|
|
24
|
-
protected _minimized: Val<boolean, boolean>;
|
|
25
|
-
get minimized(): boolean;
|
|
26
|
-
setMinimized(minimized: boolean, skipUpdate?: boolean): this;
|
|
27
|
-
protected _maximized: Val<boolean, boolean>;
|
|
28
|
-
get maximized(): boolean;
|
|
29
|
-
setMaximized(maximized: boolean, skipUpdate?: boolean): this;
|
|
30
|
-
protected _state: Val<TeleBoxState, boolean>;
|
|
27
|
+
_state$: Val<TeleBoxState, boolean>;
|
|
31
28
|
get state(): TeleBoxState;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setFence(fence: boolean, skipUpdate?: boolean): this;
|
|
35
|
-
protected _containerRect: Val<TeleBoxRect, boolean>;
|
|
36
|
-
get containerRect(): TeleBoxRect;
|
|
37
|
-
setContainerRect(rect: TeleBoxRect, skipUpdate?: boolean): this;
|
|
29
|
+
/** @deprecated use setMaximized and setMinimized instead */
|
|
30
|
+
setState(state: TeleBoxState, skipUpdate?: boolean): this;
|
|
38
31
|
create(config?: TeleBoxManagerCreateConfig): ReadonlyTeleBox;
|
|
39
32
|
query(config?: TeleBoxManagerQueryConfig): ReadonlyTeleBox[];
|
|
40
33
|
queryOne(config?: TeleBoxManagerQueryConfig): ReadonlyTeleBox | undefined;
|
|
@@ -43,8 +36,6 @@ export declare class TeleBoxManager {
|
|
|
43
36
|
remove(boxID: string, skipUpdate?: boolean): ReadonlyTeleBox | undefined;
|
|
44
37
|
removeAll(skipUpdate?: boolean): ReadonlyTeleBox[];
|
|
45
38
|
destroy(skipUpdate?: boolean): void;
|
|
46
|
-
/** @deprecated use setMaximized and setMinimized instead */
|
|
47
|
-
setState(state: TeleBoxState, skipUpdate?: boolean): this;
|
|
48
39
|
wrapClassName(className: string): string;
|
|
49
40
|
protected maxTitleBar: MaxTitleBar;
|
|
50
41
|
protected _focusedBox: TeleBox | undefined;
|
|
@@ -20,6 +20,8 @@ export declare type TeleBoxManagerEventConfig = CheckTeleBoxManagerConfig<{
|
|
|
20
20
|
created: [ReadonlyTeleBox];
|
|
21
21
|
removed: [ReadonlyTeleBox[]];
|
|
22
22
|
state: [TeleBoxState];
|
|
23
|
+
maximized: [boolean];
|
|
24
|
+
minimized: [boolean];
|
|
23
25
|
move: [ReadonlyTeleBox];
|
|
24
26
|
resize: [ReadonlyTeleBox];
|
|
25
27
|
intrinsic_move: [ReadonlyTeleBox];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
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;Object.defineProperty(exports,"__esModule",{value:!0}),exports[Symbol.toStringTag]="Module";var a=require("react");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=l(a),c={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,i="~";function s(){}function r(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function n(e,t,s,n,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new r(s,n||e,o),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),a.prototype.eventNames=function(){var e,s,r=[];if(0===this._eventsCount)return r;for(s in e=this._events)t.call(e,s)&&r.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},a.prototype.listeners=function(e){var t=i?i+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,n=s.length,o=new Array(n);r<n;r++)o[r]=s[r].fn;return o},a.prototype.listenerCount=function(e){var t=i?i+e:e,s=this._events[t];return s?s.fn?1:s.length:0},a.prototype.emit=function(e,t,s,r,n,o){var a=i?i+e:e;if(!this._events[a])return!1;var l,h,c=this._events[a],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,s),!0;case 4:return c.fn.call(c.context,t,s,r),!0;case 5:return c.fn.call(c.context,t,s,r,n),!0;case 6:return c.fn.call(c.context,t,s,r,n,o),!0}for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var u,f=c.length;for(h=0;h<f;h++)switch(c[h].once&&this.removeListener(e,c[h].fn,void 0,!0),d){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,t);break;case 3:c[h].fn.call(c[h].context,t,s);break;case 4:c[h].fn.call(c[h].context,t,s,r);break;default:if(!l)for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c[h].fn.apply(c[h].context,l)}}return!0},a.prototype.on=function(e,t,i){return n(this,e,t,i,!1)},a.prototype.once=function(e,t,i){return n(this,e,t,i,!0)},a.prototype.removeListener=function(e,t,s,r){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return o(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||r&&!a.once||s&&a.context!==s||o(this,n);else{for(var l=0,h=[],c=a.length;l<c;l++)(a[l].fn!==t||r&&!a[l].once||s&&a[l].context!==s)&&h.push(a[l]);h.length?this._events[n]=1===h.length?h[0]:h:o(this,n)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&o(this,t)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,e.exports=a}(c);var d=c.exports,u=function(){return(u=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
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */function f(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(i[s[r]]=t[s[r]])}return i}var m=0,E="undefined"!=typeof window&&void 0!==window.requestAnimationFrame?function(t){return window.requestAnimationFrame(t)}:function(t){var e=Date.now(),i=Math.max(0,16.7-(e-m));m=e+i,setTimeout((function(){return t(m)}),i)},p=1/60*1e3,_=!0,v=!1,x=!1,g={delta:0,timestamp:0},b=["read","update","preRender","render","postRender"],T=function(t){return v=t},y=b.reduce((function(t,e){var i,s,r,n,o,a,h,l,c;return t[e]=(i=T,s=[],r=[],n=0,o=!1,a=0,h=new WeakSet,l=new WeakSet,c={cancel:function(t){var e=r.indexOf(t);h.add(t),-1!==e&&r.splice(e,1)},process:function(t){var e,d;if(o=!0,s=(e=[r,s])[0],(r=e[1]).length=0,n=s.length)for(a=0;a<n;a++)(d=s[a])(t),!0!==l.has(d)||h.has(d)||(c.schedule(d),i(!0));o=!1},schedule:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=!1);var a=i&&o,c=a?s:r;h.delete(t),e&&l.add(t),-1===c.indexOf(t)&&(c.push(t),a&&(n=s.length))}}),t}),{}),w=b.reduce((function(t,e){var i=y[e];return t[e]=function(t,e,s){return void 0===e&&(e=!1),void 0===s&&(s=!1),v||L(),i.schedule(t,e,s),t},t}),{}),B=function(t){return y[t].process(g)},z=function(t){v=!1,g.delta=_?p:Math.max(Math.min(t-g.timestamp,40),1),_||(p=g.delta),g.timestamp=t,x=!0,b.forEach(B),x=!1,v&&(_=!1,E(z))},L=function(){v=!0,_=!0,x||E(z)},C=function(){return(C=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},N=function(t,e){return function(i){return Math.max(Math.min(i,e),t)}},R=function(t){return t%1?Number(t.toFixed(5)):t},O=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i,S={test:function(t){return"number"==typeof t},parse:parseFloat,transform:function(t){return t}},$=C(C({},S),{transform:N(0,1)}),A=C(C({},S),{default:1}),M=function(t){return{test:function(e){return"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length},parse:parseFloat,transform:function(e){return""+e+t}}},V=M("deg"),X=M("%"),I=M("px"),k=C(C({},X),{parse:function(t){return X.parse(t)/100},transform:function(t){return X.transform(100*t)}}),D=N(0,255),H=function(t){return void 0!==t.red},W=function(t){return void 0!==t.hue};var j=function(t){return function(e){if("string"!=typeof e)return e;for(var i={},s=function(t){return t.substring(t.indexOf("(")+1,t.lastIndexOf(")"))}(e).replace(/(,|\/)/g," ").split(/ \s*/),r=0;r<4;r++)i[t[r]]=void 0!==s[r]?parseFloat(s[r]):1;return i}},G=C(C({},S),{transform:function(t){return Math.round(D(t))}});function F(t,e){return t.startsWith(e)&&O.test(t)}var Z,P={test:function(t){return"string"==typeof t?F(t,"rgb"):H(t)},parse:j(["red","green","blue","alpha"]),transform:function(t){var e=t.red,i=t.green,s=t.blue,r=t.alpha,n=void 0===r?1:r;return function(t){var e=t.red,i=t.green,s=t.blue,r=t.alpha;return"rgba("+e+", "+i+", "+s+", "+(void 0===r?1:r)+")"}({red:G.transform(e),green:G.transform(i),blue:G.transform(s),alpha:R($.transform(n))})}},Y={test:function(t){return"string"==typeof t?F(t,"hsl"):W(t)},parse:j(["hue","saturation","lightness","alpha"]),transform:function(t){var e=t.hue,i=t.saturation,s=t.lightness,r=t.alpha,n=void 0===r?1:r;return function(t){var e=t.hue,i=t.saturation,s=t.lightness,r=t.alpha;return"hsla("+e+", "+i+", "+s+", "+(void 0===r?1:r)+")"}({hue:Math.round(e),saturation:X.transform(R(i)),lightness:X.transform(R(s)),alpha:R($.transform(n))})}},q=C(C({},P),{test:function(t){return"string"==typeof t&&F(t,"#")},parse:function(t){var e="",i="",s="";return t.length>4?(e=t.substr(1,2),i=t.substr(3,2),s=t.substr(5,2)):(e=t.substr(1,1),i=t.substr(2,1),s=t.substr(3,1),e+=e,i+=i,s+=s),{red:parseInt(e,16),green:parseInt(i,16),blue:parseInt(s,16),alpha:1}}}),U={test:function(t){return"string"==typeof t&&O.test(t)||H(t)||W(t)},parse:function(t){return P.test(t)?P.parse(t):Y.test(t)?Y.parse(t):q.test(t)?q.parse(t):t},transform:function(t){return H(t)?P.transform(t):W(t)?Y.transform(t):t}},J=function(t){var e=t.onRead,i=t.onRender,s=t.uncachedValues,r=void 0===s?new Set:s,n=t.useCache,o=void 0===n||n;return function(t){void 0===t&&(t={});var s=f(t,[]),n={},a=[],h=!1;function l(t,e){t.startsWith("--")&&(s.hasCSSVariable=!0);var i=n[t];n[t]=e,n[t]!==i&&(-1===a.indexOf(t)&&a.push(t),h||(h=!0,w.render(c.render)))}var c={get:function(t,i){return void 0===i&&(i=!1),!i&&o&&!r.has(t)&&void 0!==n[t]?n[t]:e(t,s)},set:function(t,e){if("string"==typeof t)l(t,e);else for(var i in t)l(i,t[i]);return this},render:function(t){return void 0===t&&(t=!1),(h||!0===t)&&(i(n,s,a),h=!1,a.length=0),this}};return c}},Q=/([a-z])([A-Z])/g,K=function(t){return t.replace(Q,"$1-$2").toLowerCase()},tt=new Map,et=new Map,it=["Webkit","Moz","O","ms",""],st=it.length,rt="undefined"!=typeof document,nt=function(t,e){return et.set(t,K(e))},ot=function(t,e){void 0===e&&(e=!1);var i=e?et:tt;return i.has(t)||(rt?function(t){Z=Z||document.createElement("div");for(var e=0;e<st;e++){var i=it[e],s=""===i,r=s?t:i+t.charAt(0).toUpperCase()+t.slice(1);if(r in Z.style||s){if(s&&"clipPath"===t&&et.has(t))return;tt.set(t,r),nt(t,(s?"":"-")+K(r))}}}(t):function(t){nt(t,t)}(t)),i.get(t)||t},at=["","X","Y","Z"],ht=["translate","scale","rotate","skew","transformPerspective"].reduce((function(t,e){return at.reduce((function(t,i){return t.push(e+i),t}),t)}),["x","y","z"]),lt=ht.reduce((function(t,e){return t[e]=!0,t}),{});function ct(t){return!0===lt[t]}function dt(t,e){return ht.indexOf(t)-ht.indexOf(e)}var ut=new Set(["originX","originY","originZ"]);function ft(t){return ut.has(t)}var mt=u(u({},S),{transform:Math.round}),Et={color:U,backgroundColor:U,outlineColor:U,fill:U,stroke:U,borderColor:U,borderTopColor:U,borderRightColor:U,borderBottomColor:U,borderLeftColor:U,borderWidth:I,borderTopWidth:I,borderRightWidth:I,borderBottomWidth:I,borderLeftWidth:I,borderRadius:I,radius:I,borderTopLeftRadius:I,borderTopRightRadius:I,borderBottomRightRadius:I,borderBottomLeftRadius:I,width:I,maxWidth:I,height:I,maxHeight:I,size:I,top:I,right:I,bottom:I,left:I,padding:I,paddingTop:I,paddingRight:I,paddingBottom:I,paddingLeft:I,margin:I,marginTop:I,marginRight:I,marginBottom:I,marginLeft:I,rotate:V,rotateX:V,rotateY:V,rotateZ:V,scale:A,scaleX:A,scaleY:A,scaleZ:A,skew:V,skewX:V,skewY:V,distance:I,translateX:I,translateY:I,translateZ:I,x:I,y:I,z:I,perspective:I,opacity:$,originX:k,originY:k,originZ:I,zIndex:mt,fillOpacity:$,strokeOpacity:$,numOctaves:mt},pt=function(t){return Et[t]},_t=function(t,e){return e&&"number"==typeof t?e.transform(t):t},vt=new Set(["scrollLeft","scrollTop"]),xt=new Set(["scrollLeft","scrollTop","transform"]),gt={x:"translateX",y:"translateY",z:"translateZ"};function bt(t){return"function"==typeof t}function Tt(t,e,i,s,r,n,o,a){void 0===e&&(e=!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 t){var u=t[d],f=pt(d),m=_t(u,f);ct(d)?(l=!0,s[d]=m,n.push(d),h&&(f.default&&u!==f.default||!f.default&&0!==u)&&(h=!1)):ft(d)?(r[d]=m,c=!0):xt.has(d)&&bt(m)||(i[ot(d,o)]=m)}return(l||"function"==typeof t.transform)&&(i.transform=function(t,e,i,s,r,n){void 0===n&&(n=!0);var o="",a=!1;i.sort(dt);for(var h=i.length,l=0;l<h;l++){var c=i[l];o+=(gt[c]||c)+"("+e[c]+") ",a="z"===c||a}return!a&&r?o+="translateZ(0)":o=o.trim(),bt(t.transform)?o=t.transform(e,s?"":o):n&&s&&(o="none"),o}(t,s,n,h,e,a)),c&&(i.transformOrigin=(r.originX||"50%")+" "+(r.originY||"50%")+" "+(r.originZ||0)),i}function yt(t){var e=void 0===t?{}:t,i=e.enableHardwareAcceleration,s=void 0===i||i,r=e.isDashCase,n=void 0===r||r,o=e.allowTransformNone,a=void 0===o||o,h={},l={},c={},d=[];return function(t){return d.length=0,Tt(t,s,h,l,c,d,n,a),h}}var wt=J({onRead:function(t,e){var i=e.element,s=e.preparseOutput,r=pt(t);if(ct(t))return r&&r.default||0;if(vt.has(t))return i[t];var n=window.getComputedStyle(i,null).getPropertyValue(ot(t,!0))||0;return s&&r&&r.test(n)&&r.parse?r.parse(n):n},onRender:function(t,e,i){var s=e.element,r=e.buildStyles,n=e.hasCSSVariable;if(Object.assign(s.style,r(t)),n)for(var o=i.length,a=0;a<o;a++){var h=i[a];h.startsWith("--")&&s.style.setProperty(h,t[h])}-1!==i.indexOf("scrollLeft")&&(s.scrollLeft=t.scrollLeft),-1!==i.indexOf("scrollTop")&&(s.scrollTop=t.scrollTop)},uncachedValues:vt});var Bt=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues"]),zt=function(t,e){return I.transform(t*e)},Lt={x:0,y:0,width:0,height:0};function Ct(t,e,i){return"string"==typeof t?t:I.transform(e+i*t)}var Nt={enableHardwareAcceleration:!1,isDashCase:!1};function Rt(t,e,i,s,r,n){void 0===e&&(e=Lt),void 0===s&&(s=yt(Nt)),void 0===r&&(r={style:{}}),void 0===n&&(n=!0);var o=t.attrX,a=t.attrY,h=t.originX,l=t.originY,c=t.pathLength,d=t.pathSpacing,u=void 0===d?1:d,m=t.pathOffset,E=void 0===m?0:m,p=s(f(t,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]));for(var _ in p){if("transform"===_)r.style.transform=p[_];else r[n&&!Bt.has(_)?K(_):_]=p[_]}return(void 0!==h||void 0!==l||p.transform)&&(r.style.transformOrigin=function(t,e,i){return Ct(e,t.x,t.width)+" "+Ct(i,t.y,t.height)}(e,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"]=zt(-E,i),r[n?"stroke-dasharray":"strokeDasharray"]=zt(c,i)+" "+zt(u,i)),r}function Ot(t,e,i){void 0===i&&(i=!0);var s={style:{}},r=yt(Nt);return function(n){return Rt(n,t,e,r,s,i)}}var St=J({onRead:function(t,e){var i=e.element;if(ct(t=Bt.has(t)?t:K(t))){var s=pt(t);return s&&s.default||0}return i.getAttribute(t)},onRender:function(t,e){var i=e.element,s=(0,e.buildAttrs)(t);for(var r in s)"style"===r?Object.assign(i.style,s.style):i.setAttribute(r,s[r])}}),$t=J({useCache:!1,onRead:function(t){return"scrollTop"===t?window.pageYOffset:window.pageXOffset},onRender:function(t){var e=t.scrollTop,i=void 0===e?0:e,s=t.scrollLeft,r=void 0===s?0:s;return window.scrollTo(r,i)}}),At=new WeakMap,Mt=function(t,e){var i,s,r,n;return t===window?i=$t(t):!function(t){return t instanceof HTMLElement||"function"==typeof t.click}(t)?function(t){return t instanceof SVGElement||"ownerSVGElement"in t}(t)&&(r=function(t){try{return function(t){return"function"==typeof t.getBBox?t.getBBox():t.getBoundingClientRect()}(t)}catch(e){return{x:0,y:0,width:0,height:0}}}(s=t),n=function(t){return"path"===t.tagName}(s)&&s.getTotalLength?s.getTotalLength():void 0,i=St({element:s,buildAttrs:Ot(r,n)})):i=function(t,e){void 0===e&&(e={});var i=e.enableHardwareAcceleration,s=e.allowTransformNone,r=f(e,["enableHardwareAcceleration","allowTransformNone"]);return wt(u({element:t,buildStyles:yt({enableHardwareAcceleration:i,allowTransformNone:s}),preparseOutput:!0},r))}(t,e),At.set(t,i),i};function Vt(t,e){return function(t,e){return At.has(t)?At.get(t):Mt(t,e)}("string"==typeof t?document.querySelector(t):t,e)}var Xt,It,kt,Dt,Ht=function(t,e,i,s){var r=i?i.call(s,t,e):void 0;if(void 0!==r)return!!r;if(t===e)return!0;if("object"!=typeof t||!t||"object"!=typeof e||!e)return!1;var n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(e),h=0;h<n.length;h++){var l=n[h];if(!a(l))return!1;var c=t[l],d=e[l];if(!1===(r=i?i.call(s,c,d,l):void 0)||void 0===r&&c!==d)return!1}return!0};class Wt{constructor(){this.disposers=new Map,this.disposerIDGenCount=-1}add(t,e=this.genDisposerID()){return this.flush(e),this.disposers.set(e,t()),e}addEventListener(t,e,i,s,r=this.genDisposerID()){return this.add((()=>(t.addEventListener(e,i,s),()=>t.removeEventListener(e,i,s))),r),r}setTimeout(t,e,i=this.genDisposerID()){return this.add((()=>{const s=window.setTimeout((()=>{this.remove(i),t()}),e);return()=>window.clearTimeout(s)}),i)}setInterval(t,e,i=this.genDisposerID()){return this.add((()=>{const i=window.setInterval(t,e);return()=>window.clearInterval(i)}),i)}remove(t){const e=this.disposers.get(t);return this.disposers.delete(t),e}flush(t){const e=this.remove(t);if(e)try{e()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach((t=>{try{t()}catch(e){console.error(e)}})),this.disposers.clear()}genDisposerID(){const{MAX_SAFE_INTEGER:t=9007199254740991}=Number;return this.disposerIDGenCount=(this.disposerIDGenCount+1)%t,`disposer-${this.disposerIDGenCount}`}}exports.TELE_BOX_STATE=void 0,(Xt=exports.TELE_BOX_STATE||(exports.TELE_BOX_STATE={})).Normal="normal",Xt.Minimized="minimized",Xt.Maximized="maximized",exports.TELE_BOX_EVENT=void 0,(It=exports.TELE_BOX_EVENT||(exports.TELE_BOX_EVENT={})).Close="close",It.Focus="focus",It.Blur="blur",It.Move="move",It.Resize="resize",It.IntrinsicMove="intrinsic_move",It.IntrinsicResize="intrinsic_resize",It.VisualResize="visual_resize",It.State="state",It.Readonly="readonly",It.Destroyed="destroyed",exports.TELE_BOX_DELEGATE_EVENT=void 0,(kt=exports.TELE_BOX_DELEGATE_EVENT||(exports.TELE_BOX_DELEGATE_EVENT={})).Close="close",kt.Maximize="maximize",kt.Minimize="minimize",exports.TELE_BOX_RESIZE_HANDLE=void 0,(Dt=exports.TELE_BOX_RESIZE_HANDLE||(exports.TELE_BOX_RESIZE_HANDLE={})).North="n",Dt.South="s",Dt.West="w",Dt.East="e",Dt.NorthWest="nw",Dt.NorthEast="ne",Dt.SouthEast="se",Dt.SouthWest="sw";function jt(t,e,i){return Math.min(Math.max(t,e),i)}function Gt(t){t.stopPropagation(),t.cancelable&&t.preventDefault()}function Ft(t){return t.touches?t.touches[0]:t}function Zt(){return Date.now().toString().slice(6)+Math.random().toString().slice(2,8)}let Pt=1;function Yt(){return"New Box "+Pt++}function qt(t){return Boolean(t)}function Ut(t){return!t}class Jt{constructor({readonly:t=!1,title:e,buttons:i,onEvent:s,onDragStart:r,namespace:n="telebox",state:o=exports.TELE_BOX_STATE.Normal}={}){this.$btns=[],this.sideEffect=new Wt,this.lastTitleBarClick=0,this.handleTitleBarClick=t=>{var e;if(this.readonly)return;if(null!=t.button&&0!==t.button)return;if(null==(e=t.target.dataset)?void 0:e.teleTitleBarNoDblClick)return;Gt(t);const i=Date.now();i-this.lastTitleBarClick<=500?this.onEvent&&this.onEvent({type:exports.TELE_BOX_DELEGATE_EVENT.Maximize}):this.onDragStart&&this.onDragStart(t),this.lastTitleBarClick=i},this.readonly=t,this.onEvent=s,this.onDragStart=r,this.namespace=n,this.title=e,this.state=o,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:t=>t===exports.TELE_BOX_STATE.Maximized},{type:exports.TELE_BOX_DELEGATE_EVENT.Close,iconClassName:this.wrapClassName("titlebar-icon-close")}]}setTitle(t){this.title=t,this.$title&&(this.$title.textContent=t,this.$title.title=t)}setState(t){this.state!==t&&(this.state=t,this.buttons.forEach(((e,i)=>{e.isActive&&this.$btns[i].classList.toggle("is-active",e.isActive(t))})))}setReadonly(t){this.readonly!==t&&(this.readonly=t)}render(){if(!this.$titleBar){this.$titleBar=document.createElement("div"),this.$titleBar.className=this.wrapClassName("titlebar"),this.$titleBar.dataset.teleBoxHandle="dh",this.sideEffect.addEventListener(this.$titleBar,"mousedown",this.handleTitleBarClick),this.sideEffect.addEventListener(this.$titleBar,"touchstart",this.handleTitleBarClick,{passive:!0}),this.$title=document.createElement("h1"),this.$title.className=this.wrapClassName("title"),this.$title.dataset.teleBoxHandle="dh",this.title&&(this.$title.textContent=this.title,this.$title.title=this.title);const t=document.createElement("div");t.className=this.wrapClassName("titlebar-btns"),this.buttons.forEach((({iconClassName:e,isActive:i},s)=>{const r=String(s),n=document.createElement("button");n.className=`${this.wrapClassName("titlebar-btn")} ${e}`,n.dataset.teleTitleBarBtnIndex=r,n.dataset.teleTitleBarNoDblClick="true",i&&n.classList.toggle("is-active",i(this.state)),this.$btns.push(n),t.appendChild(n)})),this.sideEffect.addEventListener(t,"click",(t=>{var e;if(this.readonly)return;const i=t.target,s=Number(null==(e=i.dataset)?void 0:e.teleTitleBarBtnIndex);if(!Number.isNaN(s)&&s<this.buttons.length){Gt(t);const e=this.buttons[s];this.onEvent&&this.onEvent({type:e.type,value:e.value})}})),this.$titleBar.appendChild(this.$title),this.$titleBar.appendChild(t)}return this.$titleBar}dragHandle(){return this.$titleBar}wrapClassName(t){return`${this.namespace}-${t}`}destroy(){this.sideEffect.flushAll(),this.$titleBar&&(this.$titleBar=void 0,this.$title=void 0,this.$btns.length=0,this.onDragStart=void 0,this.onEvent=void 0)}}class Qt{constructor(t,e){this._value=t,"function"==typeof e&&(this.compare=e)}get value(){return this._value}setValue(t,e){this.compare(t,this._value)||(this._value=t,this._subscribers&&this._subscribers.forEach((i=>i(t,e))))}reaction(t){return this._subscribers||(this._subscribers=new Set),this._subscribers.add(t),()=>{this._subscribers&&this._subscribers.delete(t)}}subscribe(t,e){const i=this.reaction(t);return t(this._value,e),i}destroy(){this._subscribers&&this._subscribers.clear()}compare(t,e){return t===e}}class Kt extends Qt{constructor(t,e,i){const s=t.map((t=>t.value));super(e(s),i),this._values=s,this._disposers=t.map(((t,i)=>t.reaction(((t,s)=>{this._values[i]=t,super.setValue(e(this._values),s)}))))}destroy(){this._disposers.forEach((t=>t())),super.destroy()}}class te{constructor({id:t=Zt(),title:e=Yt(),visible:i=!0,width:s=.5,height:r=.5,minWidth:n=0,minHeight:o=0,x:a=.1,y:h=.1,minimized:l=!1,maximized:c=!1,readonly:u=!1,resizable:f=!0,draggable:m=!0,fence:E=!0,fixRatio:p=!1,focus:_=!1,zIndex:v=100,namespace:x="telebox",titleBar:g,content:b,footer:T,styles:y,containerRect:w={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collectorRect:B}={}){this._renderSideEffect=new Wt,this.handleTrackStart=t=>{var e;return null==(e=this._handleTrackStart)?void 0:e.call(this,t)},this._sideEffect=new Wt,this.id=t,this.namespace=x,this.events=new d,this._delegateEvents=new d,this._containerRect=new Qt(w,Ht),this._collectorRect=new Qt(B,Ht),this._title=new Qt(e),this._visible=new Qt(i),this._visible.reaction(((t,e)=>{e||t||this.events.emit(exports.TELE_BOX_EVENT.Close)})),this._readonly=new Qt(u),this._readonly.reaction(((t,e)=>{e||this.events.emit(exports.TELE_BOX_EVENT.Readonly,t)})),this._resizable=new Qt(f),this._draggable=new Qt(m),this._fence=new Qt(E),this._fixRatio=new Qt(p),this._zIndex=new Qt(v),this._focus=new Qt(_),this._focus.reaction(((t,e)=>{e||this.events.emit(t?exports.TELE_BOX_EVENT.Focus:exports.TELE_BOX_EVENT.Blur)})),this._minimized=new Qt(l),this._maximized=new Qt(c),this._state=new Kt([this._minimized,this._maximized],(([t,e])=>t?exports.TELE_BOX_STATE.Minimized:e?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal)),this._state.reaction(((t,e)=>{e||this.events.emit(exports.TELE_BOX_EVENT.State,t)})),this._minSize=new Qt({width:jt(n,0,1),height:jt(o,0,1)},Ht),this._intrinsicSize=new Qt({width:jt(s,this._minSize.value.width,1),height:jt(r,this._minSize.value.height,1)},Ht),this._minSize.reaction(((t,e)=>{this._intrinsicSize.setValue({width:jt(s,t.width,1),height:jt(r,t.height,1)},e)})),this._intrinsicSize.reaction(((t,e)=>{e||this.events.emit(exports.TELE_BOX_EVENT.IntrinsicResize,t)})),this._size=new Kt([this._intrinsicSize,this._maximized],(([t,e])=>e?{width:1,height:1}:t),Ht),this._size.reaction(((t,e)=>{e||this.events.emit(exports.TELE_BOX_EVENT.Resize,t)})),this._visualSize=new Kt([this._size,this._minimized,this._containerRect,this._collectorRect],(([t,e,i,s])=>e&&s?{width:s.width/t.width/i.width,height:s.height/t.height/i.height}:t),Ht),this._visualSize.reaction(((t,e)=>{e||this.events.emit(exports.TELE_BOX_EVENT.VisualResize,t)})),this._intrinsicCoord=new Qt({x:jt(a,0,1),y:jt(h,0,1)},Ht),this._intrinsicCoord.reaction(((t,e)=>{e||this.events.emit(exports.TELE_BOX_EVENT.IntrinsicMove,t)})),this._coord=new Kt([this._intrinsicCoord,this._intrinsicSize,this._containerRect,this._collectorRect,this._minimized,this._maximized],(([t,e,i,s,r,n])=>r&&s?n?{x:(s.x+s.width/2)/i.width-.5,y:(s.y+s.height/2)/i.height-.5}:{x:(s.x+s.width/2)/i.width-e.width/2,y:(s.y+s.height/2)/i.height-e.height/2}:n?{x:0,y:0}:t),Ht),this._coord.reaction(((t,e)=>{e||this.events.emit(exports.TELE_BOX_EVENT.Move,t)})),this.titleBar=g||new Jt({readonly:this.readonly,title:this.title,namespace:this.namespace,onDragStart:t=>{var e;return null==(e=this._handleTrackStart)?void 0:e.call(this,t)},onEvent:t=>{if(this._delegateEvents.listeners.length>0)this._delegateEvents.emit(t.type);else switch(t.type){case exports.TELE_BOX_DELEGATE_EVENT.Maximize:this._maximized.setValue(!this._maximized);break;case exports.TELE_BOX_DELEGATE_EVENT.Minimize:this._minimized.setValue(!0);break;case exports.TELE_BOX_DELEGATE_EVENT.Close:this._visible.setValue(!1);break;default:console.error("Unsupported titleBar event:",t)}}}),this._readonly.reaction((t=>{this.titleBar.setReadonly(t)})),this._$userContent=new Qt(b),this._$userFooter=new Qt(T),this._$userStyles=new Qt(y),this.fixRatio&&this.transform(this.x,this.y,this.width,this.height,!0),this.$box=this.render()}get containerRect(){return this._containerRect.value}setContainerRect(t,e=!1){return this._containerRect.setValue(t,e),this}get collectorRect(){return this._collectorRect.value}setCollectorRect(t,e=!1){return this._collectorRect.setValue(t,e),this}get title(){return this._title.value}setTitle(t){return this._title.setValue(t),this}get visible(){return this._visible.value}setVisible(t,e=!1){return this._visible.setValue(t,e),this}get readonly(){return this._readonly.value}setReadonly(t,e=!1){return this._readonly.setValue(t,e),this}get resizable(){return this._resizable.value}setResizable(t,e=!1){return this._resizable.setValue(t,e),this}get draggable(){return this._draggable.value}setDraggable(t,e=!1){return this._draggable.setValue(t,e),this}get fence(){return this._fence.value}setFence(t,e=!1){return this._fence.setValue(t,e),this}get fixRatio(){return this._fixRatio.value}setFixRatio(t,e=!1){return this._fixRatio.setValue(t,e),this}get focus(){return this._focus.value}setFocus(t,e=!1){return this._focus.setValue(t,e),this}get zIndex(){return this._zIndex.value}setZIndex(t,e=!1){return this._zIndex.setValue(t,e),this}get minimized(){return this._minimized.value}setMinimized(t,e=!1){return this._minimized.setValue(t,e),this}get maximized(){return this._maximized.value}setMaximized(t,e=!1){return this._maximized.setValue(t,e),this}get state(){return this._state.value}setState(t,e=!1){switch(t){case exports.TELE_BOX_STATE.Maximized:this.setMinimized(!1,e),this.setMaximized(!0,e);break;case exports.TELE_BOX_STATE.Minimized:this.setMinimized(!0,e),this.setMaximized(!1,e);break;default:this.setMinimized(!1,e),this.setMaximized(!1,e)}return this}get minWidth(){return this._minSize.value.width}get minHeight(){return this._minSize.value.height}setMinSize(t,e=!1){return this._minSize.setValue(t,e),this}setMinWidth(t,e=!1){return this._minSize.setValue({width:t,height:this.minHeight},e),this}setMinHeight(t,e=!1){return this._minSize.setValue({width:this.minWidth,height:t},e),this}get intrinsicWidth(){return this._intrinsicSize.value.width}get intrinsicHeight(){return this._intrinsicSize.value.height}setIntrinsicSize(t,e=!1){return this._intrinsicSize.setValue(t,e),this}resize(t,e,i=!1){return this._intrinsicSize.setValue({width:t,height:e},i),this}get width(){return this._size.value.width}get height(){return this._size.value.height}get absoluteWidth(){return this.width*this.containerRect.width}get absoluteHeight(){return this.height*this.containerRect.height}get visualWidth(){return this._visualSize.value.width}get visualHeight(){return this._visualSize.value.height}get intrinsicX(){return this._intrinsicCoord.value.x}get intrinsicY(){return this._intrinsicCoord.value.y}setIntrinsicCoord(t,e=!1){return this._intrinsicCoord.setValue(t,e),this}move(t,e,i=!1){return this._intrinsicCoord.setValue({x:t,y:e},i),this}get x(){return this._coord.value.x}get y(){return this._coord.value.y}transform(t,e,i,s,r=!1){if(this.fixRatio){const t=this.intrinsicHeight/this.intrinsicWidth*i;e!==this.intrinsicY&&(e-=t-s),s=t}return e<0&&(e=0,s>this.intrinsicHeight&&(s=this.intrinsicHeight)),this.setIntrinsicCoord({x:i>=this.minWidth?t:this.intrinsicX,y:s>=this.minHeight?e:this.intrinsicY},r),this.setIntrinsicSize({width:jt(i,this.minWidth,1),height:jt(s,this.minHeight,1)},r),this}get $userContent(){return this._$userContent.value}mount(t){return t.appendChild(this.render()),this}unmount(){return this.$box&&this.$box.remove(),this}mountContent(t){return this._$userContent.setValue(t),this}unmountContent(){return this._$userContent.setValue(void 0),this}get $userFooter(){return this._$userFooter.value}mountFooter(t){return this._$userFooter.setValue(t),this}unmountFooter(){return this._$userFooter.setValue(void 0),this}getUserStyles(){return this._$userStyles.value}mountStyles(t){let e;return"string"==typeof t?(e=document.createElement("style"),e.textContent=t):e=t,this._$userStyles.setValue(e),this}unmountStyles(){return this._$userStyles.setValue(void 0),this}render(t){if(t){if(t===this.$box)return this.$box;this.$box=t}else{if(this.$box)return this.$box;this.$box=document.createElement("div")}this._renderSideEffect.flushAll(),this.$box.classList.add(this.wrapClassName("box"));const e=(t,e,i,s=qt)=>this._renderSideEffect.add((()=>{const r=this.wrapClassName(i);return e.subscribe((e=>{t.classList.toggle(r,s(e))}))}));e(this.$box,this._readonly,"readonly"),e(this.$box,this._draggable,"no-drag",Ut),e(this.$box,this._resizable,"no-resize",Ut),e(this.$box,this._focus,"blur",Ut),this._renderSideEffect.add((()=>{const t=this.wrapClassName("minimized"),e=this.wrapClassName("maximized"),i="box-maximized-timer";return this._state.subscribe((s=>{this.$box.classList.toggle(t,s===exports.TELE_BOX_STATE.Minimized),s===exports.TELE_BOX_STATE.Maximized?(this._renderSideEffect.flush(i),this.$box.classList.toggle(e,!0)):this._renderSideEffect.setTimeout((()=>{this.$box.classList.toggle(e,!1)}),0,i)}))})),this._renderSideEffect.add((()=>this._visible.subscribe((t=>{this.$box.style.display=t?"block":"none"})))),this._renderSideEffect.add((()=>this._zIndex.subscribe((t=>{this.$box.style.zIndex=String(t)}))));const i=Vt(this.$box);this.$box.dataset.teleBoxID=this.id,this.$box.style.width=this.absoluteWidth+"px",this.$box.style.height=this.absoluteHeight+"px";const s=this.x*this.containerRect.width+this.containerRect.x,r=this.y*this.containerRect.height+this.containerRect.y;this.$box.style.transform=`translate(${s-10}px,${r-10}px)`,this._renderSideEffect.add((()=>{const t=new Kt([this._coord,this._size,this._minimized,this._containerRect,this._collectorRect],(([t,e,i,s,r])=>{const n=e.width*s.width,o=e.height*s.height;return{width:n,height:o,x:t.x*s.width,y:t.y*s.height,scaleX:i&&r?r.width/n:1,scaleY:i&&r?r.height/o:1}}),Ht);return t.subscribe((t=>{i.set(t)})),()=>{t.destroy()}})),i.set({x:s,y:r});const n=document.createElement("div");n.className=this.wrapClassName("box-main"),this.$box.appendChild(n);const o=document.createElement("div");o.className=this.wrapClassName("titlebar-wrap"),o.appendChild(this.titleBar.render());const a=document.createElement("div");a.className=this.wrapClassName("content-wrap");const h=document.createElement("div");h.className=this.wrapClassName("content")+" tele-fancy-scrollbar",this.$content=h,this._renderSideEffect.add((()=>{let t;return this._$userStyles.subscribe((e=>{t&&t.remove(),t=e,e&&h.appendChild(e)}))})),this._renderSideEffect.add((()=>{let t;return this._$userContent.subscribe((e=>{t&&t.remove(),t=e,e&&h.appendChild(e)}))})),a.appendChild(h);const l=document.createElement("div");return l.className=this.wrapClassName("footer-wrap"),this.$footer=l,this._renderSideEffect.add((()=>{let t;return this._$userFooter.subscribe((e=>{t&&t.remove(),t=e,e&&h.appendChild(e)}))})),n.appendChild(o),n.appendChild(a),n.appendChild(l),this._renderResizeHandlers(),this.$box}_renderResizeHandlers(){const t=document.createElement("div");t.className=this.wrapClassName("resize-handles"),Object.values(exports.TELE_BOX_RESIZE_HANDLE).forEach((e=>{const i=document.createElement("div");i.className=this.wrapClassName(e)+" "+this.wrapClassName("resize-handle"),i.dataset.teleBoxHandle=e,t.appendChild(i)})),this.$box.appendChild(t);const e="handle-tracking-listener",i=this.wrapClassName("transforming");let s,r,n=0,o=0,a=0,h=0,l=0,c=0;const d=t=>{if(this.state!==exports.TELE_BOX_STATE.Normal)return;Gt(t);let{pageX:e,pageY:i}=Ft(t);i<0&&(i=0);const s=(e-l)/this.containerRect.width,d=(i-c)/this.containerRect.height;switch(r){case exports.TELE_BOX_RESIZE_HANDLE.North:this.transform(this.x,o+d,this.width,h-d);break;case exports.TELE_BOX_RESIZE_HANDLE.South:this.transform(this.x,this.y,this.width,h+d);break;case exports.TELE_BOX_RESIZE_HANDLE.West:this.transform(n+s,this.y,a-s,this.height);break;case exports.TELE_BOX_RESIZE_HANDLE.East:this.transform(this.x,this.y,a+s,this.height);break;case exports.TELE_BOX_RESIZE_HANDLE.NorthWest:this.transform(n+s,o+d,a-s,h-d);break;case exports.TELE_BOX_RESIZE_HANDLE.NorthEast:this.transform(this.x,o+d,a+s,h-d);break;case exports.TELE_BOX_RESIZE_HANDLE.SouthEast:this.transform(this.x,this.y,a+s,h+d);break;case exports.TELE_BOX_RESIZE_HANDLE.SouthWest:this.transform(n+s,this.y,a-s,h+d);break;default:if(this._fence)this.move(jt(n+s,0,1-this.width),jt(o+d,0,1-this.height));else{const t=20/this.containerRect.width,e=20/this.containerRect.height;this.move(jt(n+s,t-this.width,1-t),jt(o+d,0,1-e))}}},u=t=>{r=void 0,s&&(Gt(t),this.$box.classList.toggle(i,!1),this._sideEffect.flush(e),s.remove())},f=t=>{var f;if(this.readonly)return;if(null!=t.button&&0!==t.button)return;if(!this.draggable||r||this.state!==exports.TELE_BOX_STATE.Normal)return;const m=t.target;if(null==(f=m.dataset)?void 0:f.teleBoxHandle){Gt(t),n=this.x,o=this.y,a=this.width,h=this.height,({pageX:l,pageY:c}=Ft(t)),r=m.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)})),e)}};this._handleTrackStart=f,this._sideEffect.addEventListener(t,"mousedown",f,{},"box-resizeHandles-mousedown"),this._sideEffect.addEventListener(t,"touchstart",f,{passive:!1},"box-resizeHandles-touchstart")}destroy(){this.$box.remove(),this.events.emit(exports.TELE_BOX_EVENT.Destroyed),this._sideEffect.flushAll(),this._renderSideEffect.flushAll(),this.events.removeAllListeners(),this._delegateEvents.removeAllListeners(),Object.keys(this).forEach((t=>{const e=this[t];e instanceof Qt&&e.destroy()}))}wrapClassName(t){return`${this.namespace}-${t}`}}const ee=(t,e)=>{const i=a.useRef(!0);a.useEffect((()=>{if(!i.current)return t();i.current=!1}),e)};var ie;class se{constructor({visible:t=!0,readonly:e=!1,namespace:i="telebox",styles:s={},onClick:r}={}){this.handleCollectorClick=()=>{!this._readonly&&this.onClick&&this.onClick()},this._visible=Boolean(t),this._readonly=Boolean(e),this.namespace=i,this.styles=s,this.onClick=r}get visible(){return this._visible}get readonly(){return this._readonly}mount(t){return t.appendChild(this.render()),this}unmount(){return this.$collector&&this.$collector.remove(),this}setVisible(t){return this._visible!==t&&(this._visible=t,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-visible"),t)),this}setReadonly(t){return this._readonly!==t&&(this._readonly=t,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-readonly"),t)),this}setStyles(t){if(Object.assign(this.styles,t),this.$collector){const e=this.$collector;Object.keys(t).forEach((i=>{const s=t[i];null!=s&&(e.style[i]=s)}))}return this}render(){if(!this.$collector){this.$collector=document.createElement("button"),this.$collector.className=this.wrapClassName("collector"),this.$collector.addEventListener("click",this.handleCollectorClick),this._visible&&this.$collector.classList.add(this.wrapClassName("collector-visible")),this._readonly&&this.$collector.classList.add(this.wrapClassName("collector-readonly"));const t=document.createElement("img");t.draggable=!1,t.className=this.wrapClassName("collector-icon"),t.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K",this.$collector.appendChild(t),this.setStyles(this.styles)}return this.$collector}destroy(){this.$collector&&(this.$collector.removeEventListener("click",this.handleCollectorClick),this.$collector.remove(),this.$collector=void 0),this.onClick=void 0}wrapClassName(t){return`${this.namespace}-${t}`}}exports.TELE_BOX_MANAGER_EVENT=void 0,(ie=exports.TELE_BOX_MANAGER_EVENT||(exports.TELE_BOX_MANAGER_EVENT={})).Focused="focused",ie.Created="created",ie.Removed="removed",ie.State="state",ie.Move="move",ie.Resize="resize",ie.IntrinsicMove="intrinsic_move",ie.IntrinsicResize="intrinsic_resize",ie.VisualResize="visual_resize";class re extends Jt{constructor(t){super(t),this.boxes=t.boxes,this.focusedBox=t.focusedBox,this.containerRect=t.containerRect}focusBox(t){var e;if(t||(t=this.boxes[this.boxes.length-1]),!this.focusedBox||this.focusedBox!==t){if(this.$titles&&this.state===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==(e=r.dataset)?void 0:e.teleBoxID;n&&(t&&n===t.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=t}}setContainerRect(t){if(this.containerRect=t,this.$titleBar){const{x:e,y:i,width:s}=t;this.$titleBar.style.transform=`translate(${e}px, ${i}px)`,this.$titleBar.style.width=s+"px"}}setBoxes(t){this.boxes=t,this.updateTitles()}setState(t){super.setState(t),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),t===exports.TELE_BOX_STATE.Maximized),this.updateTitles()}setReadonly(t){super.setReadonly(t),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("readonly"),this.readonly)}render(){const t=super.render(),{x:e,y:i,width:s}=this.containerRect;return t.style.transform=`translate(${e}px, ${i}px)`,t.style.width=s+"px",t.classList.add(this.wrapClassName("max-titlebar")),t.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===exports.TELE_BOX_STATE.Maximized),t.classList.toggle(this.wrapClassName("readonly"),this.readonly),this.updateTitles(),t}destroy(){super.destroy(),this.$titles=void 0,this.boxes.length=0,this.focusedBox=void 0}updateTitles(){this.$titleBar&&this.state===exports.TELE_BOX_STATE.Maximized&&(1===this.boxes.length?this.$title&&(this.$title.textContent=this.boxes[0].title,this.$titleBar.replaceChild(this.$title,this.$titleBar.firstElementChild)):this.$titleBar.replaceChild(this.renderTitles(),this.$titleBar.firstElementChild))}renderTitles(){this.$titles=document.createElement("div"),this.$titles.className=this.wrapClassName("titles"),this.$titles.addEventListener("wheel",(t=>{t.currentTarget.scrollBy({left:t.deltaY>0?250:-250,behavior:"smooth"})}),{passive:!1});const t=document.createElement("div");return t.className=this.wrapClassName("titles-content"),this.$titles.appendChild(t),this.boxes.forEach((e=>{const i=document.createElement("button");i.className=this.wrapClassName("titles-tab"),i.textContent=e.title,i.dataset.teleBoxID=e.id,i.dataset.teleTitleBarNoDblClick="true",this.focusedBox&&e.id===this.focusedBox.id&&i.classList.add(this.wrapClassName("titles-tab-focus")),t.appendChild(i)})),this.$titles}}exports.DefaultTitleBar=Jt,exports.TeleBox=te,exports.TeleBoxCollector=se,exports.TeleBoxDragHandleType="dh",exports.TeleBoxManager=class{constructor({root:t=document.body,minimized:e=!1,maximized:i=!1,fence:s=!0,containerRect:r={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collector:n,namespace:o="telebox",zIndex:a=100,readonly:h=!1}={}){this.events=new d,this.boxes=[],this._sideEffect=new Wt,this.root=t,this.namespace=o,this.zIndex=a,this._readonly=new Qt(h),this._readonly.reaction(((t,e)=>{this.boxes.forEach((i=>i.setReadonly(t,e)))})),this._minimized=new Qt(e),this._maximized=new Qt(i),this._maximized.reaction(((t,e)=>{this.boxes.forEach((i=>i.setMaximized(t,e)))})),this._state=new Kt([this._minimized,this._maximized],(([t,e])=>t?exports.TELE_BOX_STATE.Minimized:e?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal)),this._state.reaction(((t,e)=>{this.maxTitleBar.setState(t),e||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.State,t)})),this._fence=new Qt(s),this._fence.subscribe(((t,e)=>{this.boxes.forEach((i=>i.setFence(t,e)))})),this._containerRect=new Qt(r,Ht),this._containerRect.reaction(((t,e)=>{this.boxes.forEach((i=>i.setContainerRect(t,e))),this.maxTitleBar.setContainerRect(t)})),this._collector=new Qt(null===n?null:n||new se({visible:e,readonly:h,namespace:o}).mount(t)),this._collector.subscribe((t=>{t&&(t.setVisible(this.minimized),t.setReadonly(this.readonly),this._sideEffect.add((()=>(t.onClick=()=>{this.readonly||this.setMinimized(!1)},()=>t.destroy())),"collect-onClick"))})),this._readonly.subscribe((t=>{var e;return null==(e=this.collector)?void 0:e.setReadonly(t)})),this._minimized.subscribe(((t,e)=>{var i,s;if(null==(i=this.collector)||i.setVisible(t),t&&(null==(s=this.collector)?void 0:s.$collector)){const{x:t,y:e,width:i,height:s}=this.collector.$collector.getBoundingClientRect(),r=this.root.getBoundingClientRect();this.boxes.forEach((n=>{n.setCollectorRect({x:t-r.x,y:e-r.y,width:i,height:s},!0)}))}this.boxes.forEach((i=>i.setMinimized(t,e)))}));const l=t=>{var e;if(this.readonly)return;const i=t.target;if(i.tagName)for(let s=i;s;s=s.parentElement){const t=null==(e=s.dataset)?void 0:e.teleBoxID;if(t){const e=this.boxes.find((e=>e.id===t));if(e)return void this.focusBox({focus:!0,box:e})}}};this._sideEffect.addEventListener(window,"mousedown",l,!0),this._sideEffect.addEventListener(window,"touchstart",l,!0),this.maxTitleBar=new re({readonly:this.readonly,namespace:this.namespace,state:this.state,boxes:this.boxes,focusedBox:this._focusedBox,containerRect:this.containerRect,onEvent:t=>{var e;switch(t.type){case exports.TELE_BOX_DELEGATE_EVENT.Maximize:this.setMaximized(!this.maximized);break;case exports.TELE_BOX_DELEGATE_EVENT.Minimize:this.setMinimized(!0);break;case exports.TELE_BOX_EVENT.Close:{const t=null!=(e=this._focusedBox)?e:this.boxes[this.boxes.length-1];t&&this.remove(t.id);break}}}}),this._readonly.subscribe((t=>this.maxTitleBar.setReadonly(t))),this.root.appendChild(this.maxTitleBar.render())}get collector(){return this._collector.value}setCollector(t){this._collector.setValue(t)}get readonly(){return this._readonly.value}setReadonly(t,e=!1){return this._readonly.setValue(t,e),this}get minimized(){return this._minimized.value}setMinimized(t,e=!1){return this._minimized.setValue(t,e),this}get maximized(){return this._maximized.value}setMaximized(t,e=!1){return this._maximized.setValue(t,e),this}get state(){return this._state.value}get fence(){return this._fence.value}setFence(t,e=!1){return this._fence.setValue(t,e),this}get containerRect(){return this._containerRect.value}setContainerRect(t,e=!1){return this._containerRect.setValue(t,e),this}create(t){const e=new te(this.wrapCreateConfig(t));return e.mount(this.root),this.boxes.push(e),e.focus&&this.focusBox({focus:!0,box:e,increaseZIndex:!1}),this.maxTitleBar.setBoxes(this.boxes),e._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Maximize,(()=>{this.setMaximized(!this.maximized)})),e._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Minimize,(()=>{this.setMinimized(!0)})),e._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Close,(()=>{this.focusBox({focus:!1,box:e}),this.remove(e.id)})),e.events.on(exports.TELE_BOX_EVENT.Move,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Move,e)})),e.events.on(exports.TELE_BOX_EVENT.Resize,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Resize,e)})),e.events.on(exports.TELE_BOX_EVENT.IntrinsicMove,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicMove,e)})),e.events.on(exports.TELE_BOX_EVENT.IntrinsicResize,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicResize,e)})),e.events.on(exports.TELE_BOX_EVENT.VisualResize,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.VisualResize,e)})),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Created,e),e}query(t){return t?this.boxes.filter(this.teleBoxMatcher(t)):[...this.boxes]}queryOne(t){return t?this.boxes.find(this.teleBoxMatcher(t)):this.boxes[0]}update(t,e,i=!1){const s=this.boxes.find((e=>e.id===t));if(s)return this.updateBox(s,e,i)}updateAll(t,e=!1){this.boxes.forEach((i=>{this.updateBox(i,t,e)}))}remove(t,e=!1){const i=this.boxes.findIndex((e=>e.id===t));if(i>=0){const t=this.boxes.splice(i,1);this.maxTitleBar.setBoxes(this.boxes);const s=t[0];return this.focusBox({focus:!1,box:s}),s.destroy(),this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),e||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,t),s}}removeAll(t=!1){if(this._focusedBox){const e=this._focusedBox;this._focusedBox=void 0,t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,void 0,e)}const e=this.boxes.splice(0,this.boxes.length);return this.maxTitleBar.setBoxes(this.boxes),e.forEach((t=>t.destroy())),this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,e),e}destroy(t=!1){this.events.removeAllListeners(),this._sideEffect.flushAll(),this._focusedBox=void 0,this.removeAll(t),Object.keys(this).forEach((t=>{const e=this[t];e instanceof Qt&&e.destroy()}))}setState(t,e=!1){switch(t){case exports.TELE_BOX_STATE.Maximized:this.setMinimized(!1,e),this.setMaximized(!0,e);break;case exports.TELE_BOX_STATE.Minimized:this.setMinimized(!0,e),this.setMaximized(!1,e);break;default:this.setMinimized(!1,e),this.setMaximized(!1,e)}return this}wrapClassName(t){return`${this.namespace}-${t}`}teleBoxMatcher(t){const e=Object.keys(t);return i=>e.every((e=>t[e]===i[e]))}updateBox(t,e,i=!1){null==e.x&&null==e.y||t.move(null==e.x?t.x:e.x,null==e.y?t.y:e.y,i),null==e.width&&null==e.height||t.resize(null==e.width?t.width:e.width,null==e.height?t.height:e.height,i),null!=e.title&&(t.setTitle(e.title),this.maxTitleBar.updateTitles()),null!=e.visible&&t.setVisible(e.visible,i),null!=e.minHeight&&t.setMinHeight(e.minHeight,i),null!=e.minWidth&&t.setMinWidth(e.minWidth,i),null!=e.resizable&&t.setResizable(e.resizable),null!=e.draggable&&t.setDraggable(e.draggable),null!=e.fixRatio&&t.setFixRatio(e.fixRatio,i),null!=e.focus&&this.focusBox({focus:e.focus,box:t,skipUpdate:i}),null!=e.content&&t.mountContent(e.content),null!=e.footer&&t.mountFooter(e.footer)}focusBox({focus:t,box:e,skipUpdate:i=!1,increaseZIndex:s=!0}){if(e.setFocus(t,i),e.focus){if(this._focusedBox!==e){const t=this._focusedBox;this._focusedBox&&this._focusedBox.setFocus(!1,i),this._focusedBox=e,s&&e.setZIndex(++this.zIndex),i||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,e,t)}}else this._focusedBox===e&&(this._focusedBox=void 0,i||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,void 0,e));this.maxTitleBar.focusBox(this._focusedBox)}getInitialPosition(t,e){const i=this.boxes.length>0&&this.boxes.reduce(((t,e)=>t.zIndex>e.zIndex?t:e));let s=20,r=20;return i&&(s=i.x*this.containerRect.width+20,r=i.y*this.containerRect.height+20,(s>this.containerRect.width-t*this.containerRect.width||r>this.containerRect.height-e*this.containerRect.height)&&(s=20,r=20)),{x:s/this.containerRect.width,y:r/this.containerRect.height}}wrapCreateConfig(t={}){let{x:a,y:h}=t;const{width:l=.5,height:c=.5}=t;if(null==a||null==h){const t=this.getInitialPosition(l,c);null==a&&(a=t.x),null==h&&(h=t.y)}return d=((t,e)=>{for(var i in e||(e={}))r.call(e,i)&&o(t,i,e[i]);if(s)for(var i of s(e))n.call(e,i)&&o(t,i,e[i]);return t})({},t),u={x:a,y:h,width:l,height:c,maximized:this.maximized,minimized:this.minimized,fence:this.fence,zIndex:this.zIndex,namespace:this.namespace,containerRect:this.containerRect,readonly:this.readonly},e(d,i(u));var d,u}},exports.TeleBoxReact=t=>{const[e]=a.useState((()=>new te(t)));return ee((()=>{null!=t.minWidth&&e.setMinWidth(t.minWidth)}),[e,t.minWidth]),ee((()=>{null!=t.minHeight&&e.setMinHeight(t.minHeight)}),[e,t.minHeight]),ee((()=>{var i,s;e.resize(null!=(i=t.width)?i:e.width,null!=(s=t.height)?s:e.height,!0)}),[e,t.width,t.height]),ee((()=>{var i,s;e.move(null!=(i=t.x)?i:e.x,null!=(s=t.y)?s:e.y,!0)}),[e,t.x,t.y]),ee((()=>{null!=t.title&&e.setTitle(t.title)}),[e,t.title]),ee((()=>{null!=t.visible&&e.setVisible(t.visible)}),[e,t.visible]),ee((()=>{null!=t.state&&e.setState(t.state,!0)}),[e,t.state]),ee((()=>{null!=t.draggable&&e.setDraggable(t.draggable)}),[e,t.draggable]),ee((()=>{null!=t.resizable&&e.setResizable(t.resizable)}),[e,t.resizable]),ee((()=>{null!=t.fence&&e.setFence(t.fence)}),[e,t.fence]),ee((()=>{null!=t.containerRect&&e.setContainerRect(t.containerRect)}),[e,t.containerRect]),ee((()=>{null!=t.fixRatio&&e.setFixRatio(t.fixRatio)}),[e,t.fixRatio]),a.useEffect((()=>{if(t.onResize)return e.events.on(exports.TELE_BOX_EVENT.Resize,t.onResize),()=>{e.events.off(exports.TELE_BOX_EVENT.Resize,t.onResize)}}),[e,t.onResize]),a.useEffect((()=>{if(t.onMove)return e.events.on(exports.TELE_BOX_EVENT.Move,t.onMove),()=>{e.events.off(exports.TELE_BOX_EVENT.Move,t.onMove)}}),[e,t.onMove]),a.useEffect((()=>{if(t.onClose)return e.events.on(exports.TELE_BOX_EVENT.Close,t.onClose),()=>{e.events.off(exports.TELE_BOX_EVENT.Close,t.onClose)}}),[e,t.onClose]),a.useEffect((()=>{if(t.onFocus)return e.events.on(exports.TELE_BOX_EVENT.Focus,t.onFocus),()=>{e.events.off(exports.TELE_BOX_EVENT.Focus,t.onFocus)}}),[e,t.onFocus]),a.useEffect((()=>{if(t.onBlur)return e.events.on(exports.TELE_BOX_EVENT.Blur,t.onBlur),()=>{e.events.off(exports.TELE_BOX_EVENT.Blur,t.onBlur)}}),[e,t.onBlur]),a.useEffect((()=>{if(t.onStateChanged)return e.events.on(exports.TELE_BOX_EVENT.State,t.onStateChanged),()=>{e.events.off(exports.TELE_BOX_EVENT.State,t.onStateChanged)}}),[e,t.onStateChanged]),l.default.createElement("div",{ref:t=>t&&e.render(t),className:e.wrapClassName("box")})};
|
|
15
|
+
***************************************************************************** */function f(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 E=0,m="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-E));E=t+i,setTimeout((function(){return e(E)}),i)},p=1/60*1e3,v=!0,x=!1,_=!1,b={delta:0,timestamp:0},g=["read","update","preRender","render","postRender"],T=function(e){return x=e},y=g.reduce((function(e,t){var i,s,r,n,o,a,l,h,c;return e[t]=(i=T,s=[],r=[],n=0,o=!1,a=0,l=new WeakSet,h=new WeakSet,c={cancel:function(e){var t=r.indexOf(e);l.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!==h.has(d)||l.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;l.delete(e),t&&h.add(e),-1===c.indexOf(e)&&(c.push(e),a&&(n=s.length))}}),e}),{}),w=g.reduce((function(e,t){var i=y[t];return e[t]=function(e,t,s){return void 0===t&&(t=!1),void 0===s&&(s=!1),x||N(),i.schedule(e,t,s),e},e}),{}),B=function(e){return y[e].process(b)},L=function(e){x=!1,b.delta=v?p:Math.max(Math.min(e-b.timestamp,40),1),v||(p=b.delta),b.timestamp=e,_=!0,g.forEach(B),_=!1,x&&(v=!1,m(L))},N=function(){x=!0,v=!0,_||m(L)},C=function(){return(C=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)},$=function(e,t){return function(i){return Math.max(Math.min(i,t),e)}},O=function(e){return e%1?Number(e.toFixed(5)):e},z=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i,R={test:function(e){return"number"==typeof e},parse:parseFloat,transform:function(e){return e}},S=C(C({},R),{transform:$(0,1)}),A=C(C({},R),{default:1}),M=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}}},X=M("deg"),V=M("%"),k=M("px"),I=C(C({},V),{parse:function(e){return V.parse(e)/100},transform:function(e){return V.transform(100*e)}}),D=$(0,255),H=function(e){return void 0!==e.red},W=function(e){return void 0!==e.hue};var j=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}},G=C(C({},R),{transform:function(e){return Math.round(D(e))}});function Z(e,t){return e.startsWith(t)&&z.test(e)}var F,P={test:function(e){return"string"==typeof e?Z(e,"rgb"):H(e)},parse:j(["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:G.transform(t),green:G.transform(i),blue:G.transform(s),alpha:O(S.transform(n))})}},Y={test:function(e){return"string"==typeof e?Z(e,"hsl"):W(e)},parse:j(["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:V.transform(O(i)),lightness:V.transform(O(s)),alpha:O(S.transform(n))})}},q=C(C({},P),{test:function(e){return"string"==typeof e&&Z(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}}}),U={test:function(e){return"string"==typeof e&&z.test(e)||H(e)||W(e)},parse:function(e){return P.test(e)?P.parse(e):Y.test(e)?Y.parse(e):q.test(e)?q.parse(e):e},transform:function(e){return H(e)?P.transform(e):W(e)?Y.transform(e):e}},J=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=f(e,[]),n={},a=[],l=!1;function h(e,t){e.startsWith("--")&&(s.hasCSSVariable=!0);var i=n[e];n[e]=t,n[e]!==i&&(-1===a.indexOf(e)&&a.push(e),l||(l=!0,w.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)h(e,t);else for(var i in e)h(i,e[i]);return this},render:function(e){return void 0===e&&(e=!1),(l||!0===e)&&(i(n,s,a),l=!1,a.length=0),this}};return c}},Q=/([a-z])([A-Z])/g,K=function(e){return e.replace(Q,"$1-$2").toLowerCase()},ee=new Map,te=new Map,ie=["Webkit","Moz","O","ms",""],se=ie.length,re="undefined"!=typeof document,ne=function(e,t){return te.set(e,K(t))},oe=function(e,t){void 0===t&&(t=!1);var i=t?te:ee;return i.has(e)||(re?function(e){F=F||document.createElement("div");for(var t=0;t<se;t++){var i=ie[t],s=""===i,r=s?e:i+e.charAt(0).toUpperCase()+e.slice(1);if(r in F.style||s){if(s&&"clipPath"===e&&te.has(e))return;ee.set(e,r),ne(e,(s?"":"-")+K(r))}}}(e):function(e){ne(e,e)}(e)),i.get(e)||e},ae=["","X","Y","Z"],le=["translate","scale","rotate","skew","transformPerspective"].reduce((function(e,t){return ae.reduce((function(e,i){return e.push(t+i),e}),e)}),["x","y","z"]),he=le.reduce((function(e,t){return e[t]=!0,e}),{});function ce(e){return!0===he[e]}function de(e,t){return le.indexOf(e)-le.indexOf(t)}var ue=new Set(["originX","originY","originZ"]);function fe(e){return ue.has(e)}var Ee=u(u({},R),{transform:Math.round}),me={color:U,backgroundColor:U,outlineColor:U,fill:U,stroke:U,borderColor:U,borderTopColor:U,borderRightColor:U,borderBottomColor:U,borderLeftColor:U,borderWidth:k,borderTopWidth:k,borderRightWidth:k,borderBottomWidth:k,borderLeftWidth:k,borderRadius:k,radius:k,borderTopLeftRadius:k,borderTopRightRadius:k,borderBottomRightRadius:k,borderBottomLeftRadius:k,width:k,maxWidth:k,height:k,maxHeight:k,size:k,top:k,right:k,bottom:k,left:k,padding:k,paddingTop:k,paddingRight:k,paddingBottom:k,paddingLeft:k,margin:k,marginTop:k,marginRight:k,marginBottom:k,marginLeft:k,rotate:X,rotateX:X,rotateY:X,rotateZ:X,scale:A,scaleX:A,scaleY:A,scaleZ:A,skew:X,skewX:X,skewY:X,distance:k,translateX:k,translateY:k,translateZ:k,x:k,y:k,z:k,perspective:k,opacity:S,originX:I,originY:I,originZ:k,zIndex:Ee,fillOpacity:S,strokeOpacity:S,numOctaves:Ee},pe=function(e){return me[e]},ve=function(e,t){return t&&"number"==typeof e?t.transform(e):e},xe=new Set(["scrollLeft","scrollTop"]),_e=new Set(["scrollLeft","scrollTop","transform"]),be={x:"translateX",y:"translateY",z:"translateZ"};function ge(e){return"function"==typeof e}function Te(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 l=!0,h=!1,c=!1;for(var d in e){var u=e[d],f=pe(d),E=ve(u,f);ce(d)?(h=!0,s[d]=E,n.push(d),l&&(f.default&&u!==f.default||!f.default&&0!==u)&&(l=!1)):fe(d)?(r[d]=E,c=!0):_e.has(d)&&ge(E)||(i[oe(d,o)]=E)}return(h||"function"==typeof e.transform)&&(i.transform=function(e,t,i,s,r,n){void 0===n&&(n=!0);var o="",a=!1;i.sort(de);for(var l=i.length,h=0;h<l;h++){var c=i[h];o+=(be[c]||c)+"("+t[c]+") ",a="z"===c||a}return!a&&r?o+="translateZ(0)":o=o.trim(),ge(e.transform)?o=e.transform(t,s?"":o):n&&s&&(o="none"),o}(e,s,n,l,t,a)),c&&(i.transformOrigin=(r.originX||"50%")+" "+(r.originY||"50%")+" "+(r.originZ||0)),i}function ye(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,l={},h={},c={},d=[];return function(e){return d.length=0,Te(e,s,l,h,c,d,n,a),l}}var we=J({onRead:function(e,t){var i=t.element,s=t.preparseOutput,r=pe(e);if(ce(e))return r&&r.default||0;if(xe.has(e))return i[e];var n=window.getComputedStyle(i,null).getPropertyValue(oe(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 l=i[a];l.startsWith("--")&&s.style.setProperty(l,e[l])}-1!==i.indexOf("scrollLeft")&&(s.scrollLeft=e.scrollLeft),-1!==i.indexOf("scrollTop")&&(s.scrollTop=e.scrollTop)},uncachedValues:xe});var Be=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues"]),Le=function(e,t){return k.transform(e*t)},Ne={x:0,y:0,width:0,height:0};function Ce(e,t,i){return"string"==typeof e?e:k.transform(t+i*e)}var $e={enableHardwareAcceleration:!1,isDashCase:!1};function Oe(e,t,i,s,r,n){void 0===t&&(t=Ne),void 0===s&&(s=ye($e)),void 0===r&&(r={style:{}}),void 0===n&&(n=!0);var o=e.attrX,a=e.attrY,l=e.originX,h=e.originY,c=e.pathLength,d=e.pathSpacing,u=void 0===d?1:d,E=e.pathOffset,m=void 0===E?0:E,p=s(f(e,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]));for(var v in p){if("transform"===v)r.style.transform=p[v];else r[n&&!Be.has(v)?K(v):v]=p[v]}return(void 0!==l||void 0!==h||p.transform)&&(r.style.transformOrigin=function(e,t,i){return Ce(t,e.x,e.width)+" "+Ce(i,e.y,e.height)}(t,void 0!==l?l:.5,void 0!==h?h:.5)),void 0!==o&&(r.x=o),void 0!==a&&(r.y=a),void 0!==i&&void 0!==c&&(r[n?"stroke-dashoffset":"strokeDashoffset"]=Le(-m,i),r[n?"stroke-dasharray":"strokeDasharray"]=Le(c,i)+" "+Le(u,i)),r}function ze(e,t,i){void 0===i&&(i=!0);var s={style:{}},r=ye($e);return function(n){return Oe(n,e,t,r,s,i)}}var Re=J({onRead:function(e,t){var i=t.element;if(ce(e=Be.has(e)?e:K(e))){var s=pe(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])}}),Se=J({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)}}),Ae=new WeakMap,Me=function(e,t){var i,s,r,n;return e===window?i=Se(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=Re({element:s,buildAttrs:ze(r,n)})):i=function(e,t){void 0===t&&(t={});var i=t.enableHardwareAcceleration,s=t.allowTransformNone,r=f(t,["enableHardwareAcceleration","allowTransformNone"]);return we(u({element:e,buildStyles:ye({enableHardwareAcceleration:i,allowTransformNone:s}),preparseOutput:!0},r))}(e,t),Ae.set(e,i),i};function Xe(e,t){return function(e,t){return Ae.has(e)?Ae.get(e):Me(e,t)}("string"==typeof e?document.querySelector(e):e,t)}var Ve=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),l=0;l<n.length;l++){var h=n[l];if(!a(h))return!1;var c=e[h],d=t[h];if(!1===(r=i?i.call(s,c,d,h):void 0)||void 0===r&&c!==d)return!1}return!0};const ke="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ie=ke.length,De=Array(20),He=()=>{for(let e=0;e<20;e++)De[e]=ke.charAt(Math.random()*Ie);return De.join("")};class We{constructor(){this.disposers=new Map}add(e,t=He()){return this.flush(t),this.disposers.set(t,e()),t}addDisposer(e,t=He()){return this.flush(t),this.disposers.set(t,e),t}addEventListener(e,t,i,s,r=He()){return this.add((()=>(e.addEventListener(t,i,s),()=>e.removeEventListener(t,i,s))),r),r}setTimeout(e,t,i=He()){return this.add((()=>{const s=window.setTimeout((()=>{this.remove(i),e()}),t);return()=>window.clearTimeout(s)}),i)}setInterval(e,t,i=He()){return this.add((()=>{const i=window.setInterval(e,t);return()=>window.clearInterval(i)}),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((e=>{try{e()}catch(t){console.error(t)}})),this.disposers.clear()}}var je=Object.defineProperty,Ge=("undefined"!=typeof require&&require,(e,t,i)=>{return n=i,(r="symbol"!=typeof t?t+"":t)in(s=e)?je(s,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[r]=n,i;var s,r,n});class Ze{constructor(e,t){Ge(this,"_value"),Ge(this,"_beforeDestroys"),Ge(this,"_subscribers"),this._value=e,t&&(this.compare=t)}get value(){return this._value}setValue(e,t){if(!this.compare(e,this._value)){const i=this._value;this._value=e,this._subscribers&&this._subscribers.forEach((s=>s(e,i,t)))}}reaction(e){return this._subscribers||(this._subscribers=new Set),this._subscribers.add(e),()=>{this._subscribers&&this._subscribers.delete(e)}}subscribe(e,t){const i=this.reaction(e);return e(this._value,void 0,t),i}derive(e,t,i){const s=new Ze(e(this.value,void 0,i),t),r=this.reaction(((t,i,r)=>{s.setValue(e(t,i,r))}));return s.addBeforeDestroy(r),s}destroy(){this._beforeDestroys&&(this._beforeDestroys.forEach((e=>e())),this._beforeDestroys.clear()),this._subscribers&&this._subscribers.clear()}addBeforeDestroy(e){return this._beforeDestroys||(this._beforeDestroys=new Set),this._beforeDestroys.add(e),()=>{this._beforeDestroys&&this._beforeDestroys.delete(e)}}compare(e,t){return e===t}}function Fe(e,t){Object.keys(t).forEach((i=>{!function(e,t,i){var s;Object.defineProperties(e,{[t]:{get:()=>i.value},[`_${t}$`]:{value:i},[`set${s=t,s[0].toUpperCase()+s.slice(1)}`]:{value:(e,t)=>i.setValue(e,t)}})}(e,i,t[i])}))}function Pe(e){const t=t=>{const i=e.addDisposer((()=>{t.destroy()}));return t.addBeforeDestroy((()=>{e.remove(i)})),t};return{bindSideEffect:t,combine:(e,i,s,r)=>t(function(e,t,i,s){let r=e.map((e=>e.value));const n=new Ze(t(r,void 0,s),i);return e.forEach(((e,i)=>{const s=e.reaction(((e,s)=>{const o=r.slice();o[i]=e;const a=r;r=o,n.setValue(t(o,a,s),s)}));n.addBeforeDestroy(s)})),n}(e,i,s,r)),createVal:(e,i)=>t(new Ze(e,i))}}var Ye,qe,Ue,Je;exports.TELE_BOX_STATE=void 0,(Ye=exports.TELE_BOX_STATE||(exports.TELE_BOX_STATE={})).Normal="normal",Ye.Minimized="minimized",Ye.Maximized="maximized",exports.TELE_BOX_EVENT=void 0,(qe=exports.TELE_BOX_EVENT||(exports.TELE_BOX_EVENT={})).Close="close",qe.Focus="focus",qe.Blur="blur",qe.Move="move",qe.Resize="resize",qe.IntrinsicMove="intrinsic_move",qe.IntrinsicResize="intrinsic_resize",qe.VisualResize="visual_resize",qe.State="state",qe.Minimized="minimized",qe.Maximized="maximized",qe.Readonly="readonly",qe.Destroyed="destroyed",exports.TELE_BOX_DELEGATE_EVENT=void 0,(Ue=exports.TELE_BOX_DELEGATE_EVENT||(exports.TELE_BOX_DELEGATE_EVENT={})).Close="close",Ue.Maximize="maximize",Ue.Minimize="minimize",exports.TELE_BOX_RESIZE_HANDLE=void 0,(Je=exports.TELE_BOX_RESIZE_HANDLE||(exports.TELE_BOX_RESIZE_HANDLE={})).North="n",Je.South="s",Je.West="w",Je.East="e",Je.NorthWest="nw",Je.NorthEast="ne",Je.SouthEast="se",Je.SouthWest="sw";function Qe(e,t,i){return Math.min(Math.max(e,t),i)}function Ke(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}function et(e){return e.touches?e.touches[0]:e}function tt(){return Date.now().toString().slice(6)+Math.random().toString().slice(2,8)}let it=1;function st(){return"New Box "+it++}function rt(e){return Boolean(e)}function nt(e){return!e}class ot{constructor({readonly:e=!1,title:t,buttons:i,onEvent:s,onDragStart:r,namespace:n="telebox",state:o=exports.TELE_BOX_STATE.Normal}={}){this.$btns=[],this.sideEffect=new We,this.lastTitleBarClick=0,this.handleTitleBarClick=e=>{var t;if(this.readonly)return;if(null!=e.button&&0!==e.button)return;if(null==(t=e.target.dataset)?void 0:t.teleTitleBarNoDblClick)return;Ke(e);const i=Date.now();i-this.lastTitleBarClick<=500?this.onEvent&&this.onEvent({type:exports.TELE_BOX_DELEGATE_EVENT.Maximize}):this.onDragStart&&this.onDragStart(e),this.lastTitleBarClick=i},this.readonly=e,this.onEvent=s,this.onDragStart=r,this.namespace=n,this.title=t,this.state=o,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")}]}setTitle(e){this.title=e,this.$title&&(this.$title.textContent=e,this.$title.title=e)}setState(e){this.state!==e&&(this.state=e,this.buttons.forEach(((t,i)=>{t.isActive&&this.$btns[i].classList.toggle("is-active",t.isActive(e))})))}setReadonly(e){this.readonly!==e&&(this.readonly=e)}render(){if(!this.$titleBar){this.$titleBar=document.createElement("div"),this.$titleBar.className=this.wrapClassName("titlebar"),this.$titleBar.dataset.teleBoxHandle="dh",this.sideEffect.addEventListener(this.$titleBar,"mousedown",this.handleTitleBarClick),this.sideEffect.addEventListener(this.$titleBar,"touchstart",this.handleTitleBarClick,{passive:!0}),this.$title=document.createElement("h1"),this.$title.className=this.wrapClassName("title"),this.$title.dataset.teleBoxHandle="dh",this.title&&(this.$title.textContent=this.title,this.$title.title=this.title);const e=document.createElement("div");e.className=this.wrapClassName("titlebar-btns"),this.buttons.forEach((({iconClassName:t,isActive:i},s)=>{const r=String(s),n=document.createElement("button");n.className=`${this.wrapClassName("titlebar-btn")} ${t}`,n.dataset.teleTitleBarBtnIndex=r,n.dataset.teleTitleBarNoDblClick="true",i&&n.classList.toggle("is-active",i(this.state)),this.$btns.push(n),e.appendChild(n)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const i=e.target,s=Number(null==(t=i.dataset)?void 0:t.teleTitleBarBtnIndex);if(!Number.isNaN(s)&&s<this.buttons.length){Ke(e);const t=this.buttons[s];this.onEvent&&this.onEvent({type:t.type,value:t.value})}})),this.$titleBar.appendChild(this.$title),this.$titleBar.appendChild(e)}return this.$titleBar}dragHandle(){return this.$titleBar}wrapClassName(e){return`${this.namespace}-${e}`}destroy(){this.sideEffect.flushAll(),this.$titleBar&&(this.$titleBar=void 0,this.$title=void 0,this.$btns.length=0,this.onDragStart=void 0,this.onEvent=void 0)}}class at{constructor({id:e=tt(),title:t=st(),visible:i=!0,width:s=.5,height:r=.5,minWidth:n=0,minHeight:o=0,x:a=.1,y:l=.1,minimized:h=!1,maximized:c=!1,readonly:u=!1,resizable:f=!0,draggable:E=!0,fence:m=!0,fixRatio:p=!1,focus:v=!1,zIndex:x=100,namespace:_="telebox",titleBar:b,content:g,footer:T,styles:y,containerRect:w={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collectorRect:B}={}){this._renderSideEffect=new We,this.handleTrackStart=e=>{var t;return null==(t=this._handleTrackStart)?void 0:t.call(this,e)},this._sideEffect=new We,this._valSideEffectBinder=Pe(this._sideEffect);const{combine:L,createVal:N}=this._valSideEffectBinder;this.id=e,this.namespace=_,this.events=new d,this._delegateEvents=new d;const C=N(w,Ve),$=N(B,Ve),O=N(t),z=N(i);z.reaction(((e,t,i)=>{i||e||this.events.emit(exports.TELE_BOX_EVENT.Close)}));const R=N(u);R.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.Readonly,e)}));const S=N(f),A=N(E),M=N(m),X=N(p),V=N(x),k=N(v);k.reaction(((e,t,i)=>{i||this.events.emit(e?exports.TELE_BOX_EVENT.Focus:exports.TELE_BOX_EVENT.Blur)}));const I=N(h);I.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.Minimized,e)}));const D=N(c);D.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.Maximized,e)}));const H=L([I,D],(([e,t])=>e?exports.TELE_BOX_STATE.Minimized:t?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal));H.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.State,e)}));const W=N({width:Qe(n,0,1),height:Qe(o,0,1)},Ve),j=N({width:Qe(s,W.value.width,1),height:Qe(r,W.value.height,1)},Ve);W.reaction(((e,t,i)=>{j.setValue({width:Qe(s,e.width,1),height:Qe(r,e.height,1)},i)})),j.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.IntrinsicResize,e)}));const G=L([j,D],(([e,t])=>t?{width:1,height:1}:e),Ve);G.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.Resize,e)}));const Z=L([G,I,C,$],(([e,t,i,s])=>t&&s?{width:s.width/e.width/i.width,height:s.height/e.height/i.height}:e),Ve);Z.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.VisualResize,e)}));const F=N({x:Qe(a,0,1),y:Qe(l,0,1)},Ve);F.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.IntrinsicMove,e)}));const P=L([F,j,C,$,I,D],(([e,t,i,s,r,n])=>r&&s?n?{x:(s.x+s.width/2)/i.width-.5,y:(s.y+s.height/2)/i.height-.5}:{x:(s.x+s.width/2)/i.width-t.width/2,y:(s.y+s.height/2)/i.height-t.height/2}:n?{x:0,y:0}:e),Ve);P.reaction(((e,t,i)=>{i||this.events.emit(exports.TELE_BOX_EVENT.Move,e)})),this.titleBar=b||new ot({readonly:R.value,title:O.value,namespace:this.namespace,onDragStart:e=>{var t;return null==(t=this._handleTrackStart)?void 0:t.call(this,e)},onEvent:e=>{if(this._delegateEvents.listeners.length>0)this._delegateEvents.emit(e.type);else switch(e.type){case exports.TELE_BOX_DELEGATE_EVENT.Maximize:D.setValue(!D.value);break;case exports.TELE_BOX_DELEGATE_EVENT.Minimize:I.setValue(!0);break;case exports.TELE_BOX_DELEGATE_EVENT.Close:z.setValue(!1);break;default:console.error("Unsupported titleBar event:",e)}}}),R.reaction((e=>{this.titleBar.setReadonly(e)}));const Y=N(g),q=N(T),U=N(y);Fe(this,{containerRect:C,collectorRect:$,title:O,visible:z,readonly:R,resizable:S,draggable:A,fence:M,fixRatio:X,focus:k,zIndex:V,minimized:I,maximized:D,$userContent:Y,$userFooter:q,$userStyles:U}),this._state$=H,this._minSize$=W,this._size$=G,this._intrinsicSize$=j,this._visualSize$=Z,this._coord$=P,this._intrinsicCoord$=F,this.fixRatio&&this.transform(P.value.x,P.value.y,G.value.width,G.value.height,!0),this.$box=this.render()}get state(){return this._state$.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}get minWidth(){return this._minSize$.value.width}get minHeight(){return this._minSize$.value.height}setMinWidth(e,t=!1){return this._minSize$.setValue({width:e,height:this.minHeight},t),this}setMinHeight(e,t=!1){return this._minSize$.setValue({width:this.minWidth,height:e},t),this}get intrinsicWidth(){return this._intrinsicSize$.value.width}get intrinsicHeight(){return this._intrinsicSize$.value.height}resize(e,t,i=!1){return this._intrinsicSize$.setValue({width:e,height:t},i),this}get width(){return this._size$.value.width}get height(){return this._size$.value.height}get absoluteWidth(){return this.width*this.containerRect.width}get absoluteHeight(){return this.height*this.containerRect.height}get visualWidth(){return this._visualSize$.value.width}get visualHeight(){return this._visualSize$.value.height}get intrinsicX(){return this._intrinsicCoord$.value.x}get intrinsicY(){return this._intrinsicCoord$.value.y}move(e,t,i=!1){return this._intrinsicCoord$.setValue({x:e,y:t},i),this}get x(){return this._coord$.value.x}get y(){return this._coord$.value.y}transform(e,t,i,s,r=!1){if(this.fixRatio){const e=this.intrinsicHeight/this.intrinsicWidth*i;t!==this.intrinsicY&&(t-=e-s),s=e}return t<0&&(t=0,s>this.intrinsicHeight&&(s=this.intrinsicHeight)),this._intrinsicCoord$.setValue({x:i>=this.minWidth?e:this.intrinsicX,y:s>=this.minHeight?t:this.intrinsicY},r),this._intrinsicSize$.setValue({width:Qe(i,this.minWidth,1),height:Qe(s,this.minHeight,1)},r),this}mount(e){return e.appendChild(this.render()),this}unmount(){return this.$box&&this.$box.remove(),this}mountContent(e){return this.set$userContent(e),this}unmountContent(){return this.set$userContent(void 0),this}mountFooter(e){return this.set$userFooter(e),this}unmountFooter(){return this.set$userFooter(void 0),this}getUserStyles(){return this.$userStyles}mountStyles(e){let t;return"string"==typeof e?(t=document.createElement("style"),t.textContent=e):t=e,this.set$userStyles(t),this}unmountStyles(){return this.set$userStyles(void 0),this}render(e){if(e){if(e===this.$box)return this.$box;this.$box=e}else{if(this.$box)return this.$box;this.$box=document.createElement("div")}this._renderSideEffect.flushAll(),this.$box.classList.add(this.wrapClassName("box"));const t=(e,t,i,s=rt)=>this._renderSideEffect.add((()=>{const r=this.wrapClassName(i);return t.subscribe((t=>{e.classList.toggle(r,s(t))}))}));t(this.$box,this._readonly$,"readonly"),t(this.$box,this._draggable$,"no-drag",nt),t(this.$box,this._resizable$,"no-resize",nt),t(this.$box,this._focus$,"blur",nt),this._renderSideEffect.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._renderSideEffect.flush(i),this.$box.classList.toggle(t,!0)):this._renderSideEffect.setTimeout((()=>{this.$box.classList.toggle(t,!1)}),0,i)}))})),this._renderSideEffect.add((()=>this._visible$.subscribe((e=>{this.$box.style.display=e?"block":"none"})))),this._renderSideEffect.add((()=>this._zIndex$.subscribe((e=>{this.$box.style.zIndex=String(e)}))));const i=Xe(this.$box);this.$box.dataset.teleBoxID=this.id,this.$box.style.width=this.absoluteWidth+"px",this.$box.style.height=this.absoluteHeight+"px";const s=this.x*this.containerRect.width+this.containerRect.x,r=this.y*this.containerRect.height+this.containerRect.y;this.$box.style.transform=`translate(${s-10}px,${r-10}px)`,this._valSideEffectBinder.combine([this._coord$,this._size$,this._minimized$,this._containerRect$,this._collectorRect$],(([e,t,i,s,r])=>{const n=t.width*s.width,o=t.height*s.height;return{width:n,height:o,x:e.x*s.width,y:e.y*s.height,scaleX:i&&r?r.width/n:1,scaleY:i&&r?r.height/o:1}}),Ve).subscribe((e=>{i.set(e)})),i.set({x:s,y:r});const n=document.createElement("div");n.className=this.wrapClassName("box-main"),this.$box.appendChild(n);const o=document.createElement("div");o.className=this.wrapClassName("titlebar-wrap"),o.appendChild(this.titleBar.render());const a=document.createElement("div");a.className=this.wrapClassName("content-wrap");const l=document.createElement("div");l.className=this.wrapClassName("content")+" tele-fancy-scrollbar",this.$content=l,this._renderSideEffect.add((()=>{let e;return this._$userStyles$.subscribe((t=>{e&&e.remove(),e=t,t&&l.appendChild(t)}))})),this._renderSideEffect.add((()=>{let e;return this._$userContent$.subscribe((t=>{e&&e.remove(),e=t,t&&l.appendChild(t)}))})),a.appendChild(l);const h=document.createElement("div");return h.className=this.wrapClassName("footer-wrap"),this.$footer=h,this._renderSideEffect.add((()=>{let e;return this._$userFooter$.subscribe((t=>{e&&e.remove(),e=t,t&&h.appendChild(t)}))})),n.appendChild(o),n.appendChild(a),n.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,l=0,h=0,c=0;const d=e=>{if(this.state!==exports.TELE_BOX_STATE.Normal)return;Ke(e);let{pageX:t,pageY:i}=et(e);i<0&&(i=0);const s=(t-h)/this.containerRect.width,d=(i-c)/this.containerRect.height;switch(r){case exports.TELE_BOX_RESIZE_HANDLE.North:this.transform(this.x,o+d,this.width,l-d);break;case exports.TELE_BOX_RESIZE_HANDLE.South:this.transform(this.x,this.y,this.width,l+d);break;case exports.TELE_BOX_RESIZE_HANDLE.West:this.transform(n+s,this.y,a-s,this.height);break;case exports.TELE_BOX_RESIZE_HANDLE.East:this.transform(this.x,this.y,a+s,this.height);break;case exports.TELE_BOX_RESIZE_HANDLE.NorthWest:this.transform(n+s,o+d,a-s,l-d);break;case exports.TELE_BOX_RESIZE_HANDLE.NorthEast:this.transform(this.x,o+d,a+s,l-d);break;case exports.TELE_BOX_RESIZE_HANDLE.SouthEast:this.transform(this.x,this.y,a+s,l+d);break;case exports.TELE_BOX_RESIZE_HANDLE.SouthWest:this.transform(n+s,this.y,a-s,l+d);break;default:if(this.fence)this.move(Qe(n+s,0,1-this.width),Qe(o+d,0,1-this.height));else{const e=20/this.containerRect.width,t=20/this.containerRect.height;this.move(Qe(n+s,e-this.width,1-e),Qe(o+d,0,1-t))}}},u=e=>{r=void 0,s&&(Ke(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 E=e.target;if(null==(f=E.dataset)?void 0:f.teleBoxHandle){Ke(e),n=this.x,o=this.y,a=this.width,l=this.height,({pageX:h,pageY:c}=et(e)),r=E.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")}destroy(){this.$box.remove(),this.events.emit(exports.TELE_BOX_EVENT.Destroyed),this._sideEffect.flushAll(),this._renderSideEffect.flushAll(),this.events.removeAllListeners(),this._delegateEvents.removeAllListeners()}wrapClassName(e){return`${this.namespace}-${e}`}}const lt=(e,t)=>{const i=a.useRef(!0);a.useEffect((()=>{if(!i.current)return e();i.current=!1}),t)};var ht;class ct{constructor({visible:e=!0,readonly:t=!1,namespace:i="telebox",styles:s={},onClick:r}={}){this.handleCollectorClick=()=>{!this._readonly&&this.onClick&&this.onClick()},this._visible=Boolean(e),this._readonly=Boolean(t),this.namespace=i,this.styles=s,this.onClick=r}get visible(){return this._visible}get readonly(){return this._readonly}mount(e){return e.appendChild(this.render()),this}unmount(){return this.$collector&&this.$collector.remove(),this}setVisible(e){return this._visible!==e&&(this._visible=e,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-visible"),e)),this}setReadonly(e){return this._readonly!==e&&(this._readonly=e,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-readonly"),e)),this}setStyles(e){if(Object.assign(this.styles,e),this.$collector){const t=this.$collector;Object.keys(e).forEach((i=>{const s=e[i];null!=s&&(t.style[i]=s)}))}return this}render(){if(!this.$collector){this.$collector=document.createElement("button"),this.$collector.className=this.wrapClassName("collector"),this.$collector.addEventListener("click",this.handleCollectorClick),this._visible&&this.$collector.classList.add(this.wrapClassName("collector-visible")),this._readonly&&this.$collector.classList.add(this.wrapClassName("collector-readonly"));const e=document.createElement("img");e.draggable=!1,e.className=this.wrapClassName("collector-icon"),e.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K",this.$collector.appendChild(e),this.setStyles(this.styles)}return this.$collector}destroy(){this.$collector&&(this.$collector.removeEventListener("click",this.handleCollectorClick),this.$collector.remove(),this.$collector=void 0),this.onClick=void 0}wrapClassName(e){return`${this.namespace}-${e}`}}exports.TELE_BOX_MANAGER_EVENT=void 0,(ht=exports.TELE_BOX_MANAGER_EVENT||(exports.TELE_BOX_MANAGER_EVENT={})).Focused="focused",ht.Created="created",ht.Removed="removed",ht.State="state",ht.Maximized="maximized",ht.Minimized="minimized",ht.Move="move",ht.Resize="resize",ht.IntrinsicMove="intrinsic_move",ht.IntrinsicResize="intrinsic_resize",ht.VisualResize="visual_resize";class dt extends ot{constructor(e){super(e),this.boxes=e.boxes,this.focusedBox=e.focusedBox,this.containerRect=e.containerRect}focusBox(e){var t;if(e||(e=this.boxes[this.boxes.length-1]),!this.focusedBox||this.focusedBox!==e){if(this.$titles&&this.state===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}}setContainerRect(e){if(this.containerRect=e,this.$titleBar){const{x:t,y:i,width:s}=e;this.$titleBar.style.transform=`translate(${t}px, ${i}px)`,this.$titleBar.style.width=s+"px"}}setBoxes(e){this.boxes=e,this.updateTitles()}setState(e){super.setState(e),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),e===exports.TELE_BOX_STATE.Maximized),this.updateTitles()}setReadonly(e){super.setReadonly(e),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("readonly"),this.readonly)}render(){const e=super.render(),{x:t,y:i,width:s}=this.containerRect;return e.style.transform=`translate(${t}px, ${i}px)`,e.style.width=s+"px",e.classList.add(this.wrapClassName("max-titlebar")),e.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===exports.TELE_BOX_STATE.Maximized),e.classList.toggle(this.wrapClassName("readonly"),this.readonly),this.updateTitles(),e}destroy(){super.destroy(),this.$titles=void 0,this.boxes.length=0,this.focusedBox=void 0}updateTitles(){this.$titleBar&&this.state===exports.TELE_BOX_STATE.Maximized&&(1===this.boxes.length?this.$title&&(this.$title.textContent=this.boxes[0].title,this.$titleBar.replaceChild(this.$title,this.$titleBar.firstElementChild)):this.$titleBar.replaceChild(this.renderTitles(),this.$titleBar.firstElementChild))}renderTitles(){this.$titles=document.createElement("div"),this.$titles.className=this.wrapClassName("titles"),this.$titles.addEventListener("wheel",(e=>{e.currentTarget.scrollBy({left:e.deltaY>0?250:-250,behavior:"smooth"})}),{passive:!1});const e=document.createElement("div");return e.className=this.wrapClassName("titles-content"),this.$titles.appendChild(e),this.boxes.forEach((t=>{const i=document.createElement("button");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)})),this.$titles}}exports.DefaultTitleBar=ot,exports.TeleBox=at,exports.TeleBoxCollector=ct,exports.TeleBoxDragHandleType="dh",exports.TeleBoxManager=class{constructor({root:e=document.body,minimized:t=!1,maximized:i=!1,fence:s=!0,containerRect:r={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collector:n,namespace:o="telebox",zIndex:a=100,readonly:l=!1}={}){this.events=new d,this.boxes=[],this._sideEffect=new We;const{combine:h,createVal:c}=Pe(this._sideEffect);this.root=e,this.namespace=o,this.zIndex=a;const u=c(l);u.reaction(((e,t,i)=>{this.boxes.forEach((t=>t.setReadonly(e,i)))}));const f=c(t),E=c(i);E.reaction(((e,t,i)=>{this.boxes.forEach((t=>t.setMaximized(e,i))),i||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Maximized,e)}));const m=h([f,E],(([e,t])=>e?exports.TELE_BOX_STATE.Minimized:t?exports.TELE_BOX_STATE.Maximized:exports.TELE_BOX_STATE.Normal));m.reaction(((e,t,i)=>{this.maxTitleBar.setState(e),i||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.State,e)}));const p=c(s);p.subscribe(((e,t,i)=>{this.boxes.forEach((t=>t.setFence(e,i)))}));const v=c(r,Ve);v.reaction(((e,t,i)=>{this.boxes.forEach((t=>t.setContainerRect(e,i))),this.maxTitleBar.setContainerRect(e)}));const x=c(null===n?null:n||new ct({visible:t,readonly:l,namespace:o}).mount(e));x.subscribe((e=>{e&&(e.setVisible(f.value),e.setReadonly(u.value),this._sideEffect.add((()=>(e.onClick=()=>{u.value||f.setValue(!1)},()=>e.destroy())),"collect-onClick"))})),u.subscribe((e=>{var t;return null==(t=x.value)?void 0:t.setReadonly(e)})),f.subscribe(((e,t,i)=>{var s,r;if(null==(s=x.value)||s.setVisible(e),e&&(null==(r=x.value)?void 0:r.$collector)){const{x:e,y:t,width:i,height:s}=x.value.$collector.getBoundingClientRect(),r=this.root.getBoundingClientRect();this.boxes.forEach((n=>{n.setCollectorRect({x:e-r.x,y:t-r.y,width:i,height:s},!0)}))}this.boxes.forEach((t=>t.setMinimized(e,i))),i||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Minimized,e)}));const _=e=>{var t;if(u.value)return;const i=e.target;if(i.tagName)for(let s=i;s;s=s.parentElement){const e=null==(t=s.dataset)?void 0:t.teleBoxID;if(e){const t=this.boxes.find((t=>t.id===e));if(t)return void this.focusBox({focus:!0,box:t})}}};this._sideEffect.addEventListener(window,"mousedown",_,!0),this._sideEffect.addEventListener(window,"touchstart",_,!0),this.maxTitleBar=new dt({readonly:u.value,namespace:this.namespace,state:m.value,boxes:this.boxes,focusedBox:this._focusedBox,containerRect:v.value,onEvent:e=>{var t;switch(e.type){case exports.TELE_BOX_DELEGATE_EVENT.Maximize:E.setValue(!E.value);break;case exports.TELE_BOX_DELEGATE_EVENT.Minimize:f.setValue(!0);break;case exports.TELE_BOX_EVENT.Close:{const e=null!=(t=this._focusedBox)?t:this.boxes[this.boxes.length-1];e&&this.remove(e.id);break}}}}),u.subscribe((e=>this.maxTitleBar.setReadonly(e)));Fe(this,{containerRect:v,collector:x,readonly:u,fence:p,minimized:f,maximized:E}),this._state$=m,this.root.appendChild(this.maxTitleBar.render())}get state(){return this._state$.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){const t=new at(this.wrapCreateConfig(e));return t.mount(this.root),this.boxes.push(t),t.focus&&this.focusBox({focus:!0,box:t,increaseZIndex:!1}),this.maxTitleBar.setBoxes(this.boxes),t._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Maximize,(()=>{this.setMaximized(!this.maximized)})),t._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Minimize,(()=>{this.setMinimized(!0)})),t._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Close,(()=>{this.focusBox({focus:!1,box:t}),this.remove(t.id)})),t.events.on(exports.TELE_BOX_EVENT.Move,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Move,t)})),t.events.on(exports.TELE_BOX_EVENT.Resize,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Resize,t)})),t.events.on(exports.TELE_BOX_EVENT.IntrinsicMove,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicMove,t)})),t.events.on(exports.TELE_BOX_EVENT.IntrinsicResize,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicResize,t)})),t.events.on(exports.TELE_BOX_EVENT.VisualResize,(()=>{this.events.emit(exports.TELE_BOX_MANAGER_EVENT.VisualResize,t)})),this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Created,t),t}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.boxes.findIndex((t=>t.id===e));if(i>=0){const e=this.boxes.splice(i,1);this.maxTitleBar.setBoxes(this.boxes);const s=e[0];return this.focusBox({focus:!1,box:s}),s.destroy(),this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),t||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,e),s}}removeAll(e=!1){if(this._focusedBox){const t=this._focusedBox;this._focusedBox=void 0,e||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,void 0,t)}const t=this.boxes.splice(0,this.boxes.length);return this.maxTitleBar.setBoxes(this.boxes),t.forEach((e=>e.destroy())),this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),e||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed,t),t}destroy(e=!1){this.events.removeAllListeners(),this._sideEffect.flushAll(),this._focusedBox=void 0,this.removeAll(e),Object.keys(this).forEach((e=>{const t=this[e];t instanceof Ze&&t.destroy()}))}wrapClassName(e){return`${this.namespace}-${e}`}teleBoxMatcher(e){const t=Object.keys(e);return i=>t.every((t=>e[t]===i[t]))}updateBox(e,t,i=!1){null==t.x&&null==t.y||e.move(null==t.x?e.intrinsicX:t.x,null==t.y?e.intrinsicY:t.y,i),null==t.width&&null==t.height||e.resize(null==t.width?e.intrinsicWidth:t.width,null==t.height?e.intrinsicHeight:t.height,i),null!=t.title&&(e.setTitle(t.title),this.maxTitleBar.updateTitles()),null!=t.visible&&e.setVisible(t.visible,i),null!=t.minHeight&&e.setMinHeight(t.minHeight,i),null!=t.minWidth&&e.setMinWidth(t.minWidth,i),null!=t.resizable&&e.setResizable(t.resizable),null!=t.draggable&&e.setDraggable(t.draggable),null!=t.fixRatio&&e.setFixRatio(t.fixRatio,i),null!=t.focus&&this.focusBox({focus:t.focus,box:e,skipUpdate:i}),null!=t.content&&e.mountContent(t.content),null!=t.footer&&e.mountFooter(t.footer)}focusBox({focus:e,box:t,skipUpdate:i=!1,increaseZIndex:s=!0}){if(t.setFocus(e,i),t.focus){if(this._focusedBox!==t){const e=this._focusedBox;this._focusedBox&&this._focusedBox.setFocus(!1,i),this._focusedBox=t,s&&t.setZIndex(++this.zIndex),i||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,t,e)}}else this._focusedBox===t&&(this._focusedBox=void 0,i||this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused,void 0,t));this.maxTitleBar.focusBox(this._focusedBox)}getInitialPosition(e,t){const i=this.boxes.length>0&&this.boxes.reduce(((e,t)=>e.zIndex>t.zIndex?e:t));let s=20,r=20;return i&&(s=i.intrinsicX*this.containerRect.width+20,r=i.intrinsicY*this.containerRect.height+20,(s>this.containerRect.width-e*this.containerRect.width||r>this.containerRect.height-t*this.containerRect.height)&&(s=20,r=20)),{x:s/this.containerRect.width,y:r/this.containerRect.height}}wrapCreateConfig(e={}){let{x:a,y:l}=e;const{width:h=.5,height:c=.5}=e;if(null==a||null==l){const e=this.getInitialPosition(h,c);null==a&&(a=e.x),null==l&&(l=e.y)}return d=((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})({},e),u={x:a,y:l,width:h,height:c,maximized:this.maximized,minimized:this.minimized,fence:this.fence,zIndex:this.zIndex,namespace:this.namespace,containerRect:this.containerRect,readonly:this.readonly},t(d,i(u));var d,u}},exports.TeleBoxReact=e=>{const[t]=a.useState((()=>new at(e)));return lt((()=>{null!=e.minWidth&&t.setMinWidth(e.minWidth)}),[t,e.minWidth]),lt((()=>{null!=e.minHeight&&t.setMinHeight(e.minHeight)}),[t,e.minHeight]),lt((()=>{var i,s;t.resize(null!=(i=e.width)?i:t.width,null!=(s=e.height)?s:t.height,!0)}),[t,e.width,e.height]),lt((()=>{var i,s;t.move(null!=(i=e.x)?i:t.x,null!=(s=e.y)?s:t.y,!0)}),[t,e.x,e.y]),lt((()=>{null!=e.title&&t.setTitle(e.title)}),[t,e.title]),lt((()=>{null!=e.visible&&t.setVisible(e.visible)}),[t,e.visible]),lt((()=>{null!=e.state&&t.setState(e.state,!0)}),[t,e.state]),lt((()=>{null!=e.draggable&&t.setDraggable(e.draggable)}),[t,e.draggable]),lt((()=>{null!=e.resizable&&t.setResizable(e.resizable)}),[t,e.resizable]),lt((()=>{null!=e.fence&&t.setFence(e.fence)}),[t,e.fence]),lt((()=>{null!=e.containerRect&&t.setContainerRect(e.containerRect)}),[t,e.containerRect]),lt((()=>{null!=e.fixRatio&&t.setFixRatio(e.fixRatio)}),[t,e.fixRatio]),a.useEffect((()=>{if(e.onResize)return t.events.on(exports.TELE_BOX_EVENT.Resize,e.onResize),()=>{t.events.off(exports.TELE_BOX_EVENT.Resize,e.onResize)}}),[t,e.onResize]),a.useEffect((()=>{if(e.onMove)return t.events.on(exports.TELE_BOX_EVENT.Move,e.onMove),()=>{t.events.off(exports.TELE_BOX_EVENT.Move,e.onMove)}}),[t,e.onMove]),a.useEffect((()=>{if(e.onClose)return t.events.on(exports.TELE_BOX_EVENT.Close,e.onClose),()=>{t.events.off(exports.TELE_BOX_EVENT.Close,e.onClose)}}),[t,e.onClose]),a.useEffect((()=>{if(e.onFocus)return t.events.on(exports.TELE_BOX_EVENT.Focus,e.onFocus),()=>{t.events.off(exports.TELE_BOX_EVENT.Focus,e.onFocus)}}),[t,e.onFocus]),a.useEffect((()=>{if(e.onBlur)return t.events.on(exports.TELE_BOX_EVENT.Blur,e.onBlur),()=>{t.events.off(exports.TELE_BOX_EVENT.Blur,e.onBlur)}}),[t,e.onBlur]),a.useEffect((()=>{if(e.onStateChanged)return t.events.on(exports.TELE_BOX_EVENT.State,e.onStateChanged),()=>{t.events.off(exports.TELE_BOX_EVENT.State,e.onStateChanged)}}),[t,e.onStateChanged]),h.default.createElement("div",{ref:e=>e&&t.render(e),className:t.wrapClassName("box")})};
|
|
16
16
|
//# sourceMappingURL=telebox-insider.cjs.js.map
|