@netless/telebox-insider 0.3.0-beta.1 → 0.3.0-beta.11

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.
@@ -1,34 +1,14 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports[Symbol.toStringTag] = "Module";
23
- var fancyScrollbar = ".tele-fancy-scrollbar {\n overscroll-behavior: contain;\n overflow: auto;\n overflow-y: scroll;\n overflow-y: overlay;\n -webkit-overflow-scrolling: touch;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n scrollbar-width: auto;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar {\n height: 8px;\n width: 8px;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-track {\n background-color: transparent;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb {\n background-color: rgba(68, 78, 96, 0.1);\n background-color: transparent;\n border-radius: 4px;\n transition: background-color 0.4s;\n}\n.tele-fancy-scrollbar:hover::-webkit-scrollbar-thumb {\n background-color: rgba(68, 78, 96, 0.1);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:hover {\n background-color: rgba(68, 78, 96, 0.2);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:active {\n background-color: rgba(68, 78, 96, 0.2);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:vertical {\n min-height: 50px;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:horizontal {\n min-width: 50px;\n}";
24
- var style$3 = '.telebox-box {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 100;\n transition: width 0.4s cubic-bezier(0.4, 0.9, 0.71, 1.02), height 0.4s cubic-bezier(0.55, 0.82, 0.63, 0.95), opacity 0.6s cubic-bezier(0.7, 0, 0.84, 0), transform 0.4s ease;\n}\n\n.telebox-box-main {\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background: #f9f9fc;\n box-shadow: 0px 4px 10px 0px rgba(47, 65, 146, 0.15);\n border-radius: 6px;\n border: 1px solid #e3e3ec;\n}\n\n.telebox-titlebar-wrap {\n flex-shrink: 0;\n position: relative;\n z-index: 1;\n}\n\n.telebox-content-wrap {\n flex: 1;\n width: 100%;\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.telebox-content {\n width: 100%;\n height: 100%;\n position: relative;\n}\n\n.telebox-footer-wrap {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n}\n\n.telebox-footer-wrap::before {\n content: "";\n display: block;\n flex: 1;\n}\n\n.telebox-resize-handle {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n position: absolute;\n z-index: 2147483647;\n}\n\n.telebox-n {\n width: 100%;\n height: 5px;\n left: 0;\n top: -5px;\n cursor: n-resize;\n}\n\n.telebox-s {\n width: 100%;\n height: 5px;\n left: 0;\n bottom: -5px;\n cursor: s-resize;\n}\n\n.telebox-w {\n width: 5px;\n height: 100%;\n left: -5px;\n top: 0;\n cursor: w-resize;\n}\n\n.telebox-e {\n width: 5px;\n height: 100%;\n right: -5px;\n top: 0;\n cursor: e-resize;\n}\n\n.telebox-nw {\n width: 15px;\n height: 15px;\n top: -5px;\n left: -5px;\n cursor: nw-resize;\n}\n\n.telebox-ne {\n width: 15px;\n height: 15px;\n top: -5px;\n right: -5px;\n cursor: ne-resize;\n}\n\n.telebox-se {\n width: 15px;\n height: 15px;\n bottom: -5px;\n right: -5px;\n cursor: se-resize;\n}\n\n.telebox-sw {\n width: 15px;\n height: 15px;\n bottom: -5px;\n left: -5px;\n cursor: sw-resize;\n}\n\n.telebox-track-mask {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 2147483647;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.0001);\n cursor: move;\n}\n\n.telebox-cursor-n {\n cursor: n-resize;\n}\n\n.telebox-cursor-s {\n cursor: s-resize;\n}\n\n.telebox-cursor-w {\n cursor: w-resize;\n}\n\n.telebox-cursor-e {\n cursor: e-resize;\n}\n\n.telebox-cursor-nw {\n cursor: nw-resize;\n}\n\n.telebox-cursor-ne {\n cursor: ne-resize;\n}\n\n.telebox-cursor-se {\n cursor: se-resize;\n}\n\n.telebox-cursor-sw {\n cursor: sw-resize;\n}\n\n.telebox-maximized .telebox-resize-handles,\n.telebox-no-resize .telebox-resize-handles {\n display: none;\n}\n\n.telebox-maximized {\n box-shadow: none;\n transition: none;\n}\n\n.telebox-minimized {\n transition: width 0.05s cubic-bezier(0.4, 0.9, 0.71, 1.02), height 0.05s cubic-bezier(0.55, 0.82, 0.63, 0.95), opacity 0.6s cubic-bezier(0.7, 0, 0.84, 0), transform 0.6s ease;\n opacity: 0;\n pointer-events: none;\n user-select: none;\n}\n\n.telebox-transforming {\n will-change: transform;\n transition: opacity 0.6s cubic-bezier(0.7, 0, 0.84, 0);\n}\n\n.telebox-readonly .telebox-resize-handle {\n cursor: initial !important;\n pointer-events: none !important;\n}\n\n.telebox-color-scheme-dark {\n color-scheme: dark;\n}\n\n.telebox-color-scheme-dark .telebox-box-main {\n color: #e9e9e9;\n background: #212126;\n border-color: #43434d;\n}';
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ var fancyScrollbar = "";
4
+ var style$4 = "";
25
5
  var eventemitter3 = { exports: {} };
26
6
  (function(module) {
27
7
  var has = Object.prototype.hasOwnProperty, prefix = "~";
28
8
  function Events() {
29
9
  }
30
10
  if (Object.create) {
31
- Events.prototype = Object.create(null);
11
+ Events.prototype = /* @__PURE__ */ Object.create(null);
32
12
  if (!new Events().__proto__)
33
13
  prefix = false;
34
14
  }
@@ -214,8 +194,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
214
194
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
215
195
  PERFORMANCE OF THIS SOFTWARE.
216
196
  ***************************************************************************** */
217
- var __assign$1 = function() {
218
- __assign$1 = Object.assign || function __assign2(t2) {
197
+ var __assign = function() {
198
+ __assign = Object.assign || function __assign2(t2) {
219
199
  for (var s2, i2 = 1, n = arguments.length; i2 < n; i2++) {
220
200
  s2 = arguments[i2];
221
201
  for (var p in s2)
@@ -224,7 +204,7 @@ var __assign$1 = function() {
224
204
  }
225
205
  return t2;
226
206
  };
227
- return __assign$1.apply(this, arguments);
207
+ return __assign.apply(this, arguments);
228
208
  };
229
209
  function __rest(s2, e2) {
230
210
  var t2 = {};
@@ -255,8 +235,8 @@ var createStep = function(setRunNextFrame) {
255
235
  var numThisFrame = 0;
256
236
  var isProcessing2 = false;
257
237
  var i2 = 0;
258
- var cancelled = new WeakSet();
259
- var toKeepAlive = new WeakSet();
238
+ var cancelled = /* @__PURE__ */ new WeakSet();
239
+ var toKeepAlive = /* @__PURE__ */ new WeakSet();
260
240
  var renderStep = {
261
241
  cancel: function(process) {
262
242
  var indexOfCallback = processToRunNextFrame.indexOf(process);
@@ -361,32 +341,6 @@ var startLoop = function() {
361
341
  if (!isProcessing)
362
342
  onNextFrame(processFrame);
363
343
  };
364
- /*! *****************************************************************************
365
- Copyright (c) Microsoft Corporation.
366
-
367
- Permission to use, copy, modify, and/or distribute this software for any
368
- purpose with or without fee is hereby granted.
369
-
370
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
371
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
372
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
373
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
374
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
375
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
376
- PERFORMANCE OF THIS SOFTWARE.
377
- ***************************************************************************** */
378
- var __assign = function() {
379
- __assign = Object.assign || function __assign2(t2) {
380
- for (var s2, i2 = 1, n = arguments.length; i2 < n; i2++) {
381
- s2 = arguments[i2];
382
- for (var p in s2)
383
- if (Object.prototype.hasOwnProperty.call(s2, p))
384
- t2[p] = s2[p];
385
- }
386
- return t2;
387
- };
388
- return __assign.apply(this, arguments);
389
- };
390
344
  var clamp$1 = function(min, max) {
391
345
  return function(v) {
392
346
  return Math.max(Math.min(v, max), min);
@@ -544,7 +498,7 @@ var color = {
544
498
  }
545
499
  };
546
500
  var createStyler = function(_a) {
547
- var onRead2 = _a.onRead, onRender2 = _a.onRender, _b = _a.uncachedValues, uncachedValues = _b === void 0 ? new Set() : _b, _c = _a.useCache, useCache = _c === void 0 ? true : _c;
501
+ var onRead2 = _a.onRead, onRender2 = _a.onRender, _b = _a.uncachedValues, uncachedValues = _b === void 0 ? /* @__PURE__ */ new Set() : _b, _c = _a.useCache, useCache = _c === void 0 ? true : _c;
548
502
  return function(_a2) {
549
503
  if (_a2 === void 0) {
550
504
  _a2 = {};
@@ -627,7 +581,7 @@ var testPrefix = function(key) {
627
581
  return;
628
582
  }
629
583
  camelCache.set(key, prefixedPropertyName);
630
- setDashPrefix(key, "" + (noPrefix ? "" : "-") + camelToDash(prefixedPropertyName));
584
+ setDashPrefix(key, (noPrefix ? "" : "-") + camelToDash(prefixedPropertyName));
631
585
  }
632
586
  }
633
587
  };
@@ -666,7 +620,7 @@ var transformOriginProps = /* @__PURE__ */ new Set(["originX", "originY", "origi
666
620
  function isTransformOriginProp(key) {
667
621
  return transformOriginProps.has(key);
668
622
  }
669
- var int = /* @__PURE__ */ __assign$1(/* @__PURE__ */ __assign$1({}, number), { transform: Math.round });
623
+ var int = /* @__PURE__ */ __assign(/* @__PURE__ */ __assign({}, number), { transform: Math.round });
670
624
  var valueTypes = {
671
625
  color,
672
626
  backgroundColor: color,
@@ -885,7 +839,7 @@ function createCssStyler(element, _a) {
885
839
  _a = {};
886
840
  }
887
841
  var enableHardwareAcceleration = _a.enableHardwareAcceleration, allowTransformNone = _a.allowTransformNone, props = __rest(_a, ["enableHardwareAcceleration", "allowTransformNone"]);
888
- return cssStyler(__assign$1({ element, buildStyles: createStyleBuilder({
842
+ return cssStyler(__assign({ element, buildStyles: createStyleBuilder({
889
843
  enableHardwareAcceleration,
890
844
  allowTransformNone
891
845
  }), preparseOutput: true }, props));
@@ -1075,7 +1029,7 @@ const e$1 = "!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop
1075
1029
  };
1076
1030
  class o {
1077
1031
  constructor() {
1078
- this.disposers = new Map();
1032
+ this.disposers = /* @__PURE__ */ new Map();
1079
1033
  }
1080
1034
  add(e2, s2 = r$1()) {
1081
1035
  return this.flush(s2), this.disposers.set(s2, e2()), s2;
@@ -1123,9 +1077,9 @@ class o {
1123
1077
  }), this.disposers.clear();
1124
1078
  }
1125
1079
  }
1126
- var e = Object.defineProperty, s = (typeof require != "undefined" && require, (s2, r2, t2) => (((s3, r3, t3) => {
1080
+ var e = Object.defineProperty, s = ("undefined" != typeof require && require, (s2, r2, t2) => (((s3, r3, t3) => {
1127
1081
  r3 in s3 ? e(s3, r3, { enumerable: true, configurable: true, writable: true, value: t3 }) : s3[r3] = t3;
1128
- })(s2, typeof r2 != "symbol" ? r2 + "" : r2, t2), t2));
1082
+ })(s2, "symbol" != typeof r2 ? r2 + "" : r2, t2), t2));
1129
1083
  class r {
1130
1084
  constructor(e2, r2) {
1131
1085
  s(this, "_value"), s(this, "_beforeDestroys"), s(this, "_subscribers"), this._value = e2, r2 && (this.compare = r2);
@@ -1140,7 +1094,7 @@ class r {
1140
1094
  }
1141
1095
  }
1142
1096
  reaction(e2) {
1143
- return this._subscribers || (this._subscribers = new Set()), this._subscribers.add(e2), () => {
1097
+ return this._subscribers || (this._subscribers = /* @__PURE__ */ new Set()), this._subscribers.add(e2), () => {
1144
1098
  this._subscribers && this._subscribers.delete(e2);
1145
1099
  };
1146
1100
  }
@@ -1158,7 +1112,7 @@ class r {
1158
1112
  this._beforeDestroys && (this._beforeDestroys.forEach((e2) => e2()), this._beforeDestroys.clear()), this._subscribers && this._subscribers.clear();
1159
1113
  }
1160
1114
  addBeforeDestroy(e2) {
1161
- return this._beforeDestroys || (this._beforeDestroys = new Set()), this._beforeDestroys.add(e2), () => {
1115
+ return this._beforeDestroys || (this._beforeDestroys = /* @__PURE__ */ new Set()), this._beforeDestroys.add(e2), () => {
1162
1116
  this._beforeDestroys && this._beforeDestroys.delete(e2);
1163
1117
  };
1164
1118
  }
@@ -1199,21 +1153,20 @@ function c(e2) {
1199
1153
  };
1200
1154
  return { bindSideEffect: s2, combine: (e3, r2, i2, o2) => s2(t(e3, r2, i2, o2)), createVal: (e3, t2) => s2(new r(e3, t2)) };
1201
1155
  }
1202
- var style$2 = '.telebox-titlebar {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n box-sizing: border-box;\n height: 26px;\n display: flex;\n align-items: center;\n background: #fff;\n user-select: none;\n border-bottom: 1px solid #eeeef7;\n touch-action: manipulation;\n}\n\n.telebox-title-area {\n padding-left: 16px;\n overflow: hidden;\n position: relative;\n height: 100%;\n flex: 1;\n display: flex;\n align-items: center;\n}\n\n.telebox-title {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n overflow: hidden;\n margin: 0;\n padding: 0;\n font-size: 14px;\n font-weight: 400;\n font-family: PingFangSC-Regular, PingFang SC;\n white-space: nowrap;\n word-break: keep-all;\n text-overflow: ellipsis;\n color: #191919;\n}\n\n.telebox-drag-area {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n margin: auto;\n z-index: 10;\n}\n\n.telebox-titlebar-btns {\n position: absolute;\n right: 16px;\n white-space: nowrap;\n word-break: keep-all;\n margin-left: auto;\n font-size: 0;\n z-index: 10;\n}\n\n.telebox-titlebar-btn {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n width: 22px;\n height: 22px;\n padding: 0;\n outline: none;\n border: none;\n background: transparent;\n cursor: pointer;\n}\n\n.telebox-titlebar-btn ~ .telebox-titlebar-btn {\n margin-left: 10px;\n}\n\n.telebox-titlebar-btn-icon {\n width: 22px;\n height: 22px;\n}\n\n.telebox-readonly .telebox-titlebar-btn {\n cursor: not-allowed;\n}\n\n.telebox-titlebar-icon-minimize {\n background: center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjh2MjhIMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxtYXNrIGlkPSJiIiBmaWxsPSIjZmZmIj4KICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjYSIgLz4KICAgICAgICA8L21hc2s+CiAgICAgICAgPHBhdGggZmlsbD0iI0E3QTdDQSIgZmlsbC1ydWxlPSJub256ZXJvIiBkPSJNOSAxM2gxMHYxLjZIOXoiIG1hc2s9InVybCgjYikiIC8+CiAgICA8L2c+Cjwvc3ZnPgo=");\n}\n\n.telebox-titlebar-icon-maximize {\n background: center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjh2MjhIMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxtYXNrIGlkPSJiIiBmaWxsPSIjZmZmIj4KICAgICAgICAgICAgPHVzZSB4bGluazpocmVmPSIjYSIgLz4KICAgICAgICA8L21hc2s+CiAgICAgICAgPGcgZmlsbD0iI0E3QTdDQSIgZmlsbC1ydWxlPSJub256ZXJvIiBtYXNrPSJ1cmwoI2IpIj4KICAgICAgICAgICAgPHBhdGgKICAgICAgICAgICAgICAgIGQ9Ik0yMC40ODEgMTcuMWgxLjJ2NC41ODFIMTcuMXYtMS4yaDMuMzgxVjE3LjF6bS0xNC4xOTA1LS4wMDloMS4ydjMuMzgxaDMuMzgwOXYxLjJoLTQuNTgxdi00LjU4MXpNMTcuMSA2LjE5MDVoNC41ODF2NC41ODA5aC0xLjJ2LTMuMzgxSDE3LjF2LTEuMnptLTEwLjcwMDguMTA4N2g0Ljc5ODV2MS4ySDcuNTk5MnYzLjU5ODVoLTEuMlY2LjI5OTJ6IiAvPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+Cg==");\n}\n\n.telebox-titlebar-icon-maximize.is-active {\n background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMjggMjgiPgogICAgPGRlZnM+CiAgICAgICAgPHBhdGggaWQ9ImEiIGQ9Ik0wIDBoMjZ2MjZIMHoiIC8+CiAgICAgICAgPHBhdGggaWQ9ImMiIGQ9Ik0yNi44NjkgMEwyOCAxLjEzMVYyNi44N0wyNi44NjkgMjhIMS4xM0wwIDI2Ljg3VjEuMTMxTDEuMTMgMHoiIC8+CiAgICA8L2RlZnM+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPgogICAgICAgICAgICA8bWFzayBpZD0iYiIgZmlsbD0iI2ZmZiI+CiAgICAgICAgICAgICAgICA8dXNlIHhsaW5rOmhyZWY9IiNhIiAvPgogICAgICAgICAgICA8L21hc2s+CiAgICAgICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIGQ9Ik0tNC42NDI5LTQuNjQyOWgzNS4yODU4djM1LjI4NThILTQuNjQyOXoiIG1hc2s9InVybCgjYikiIC8+CiAgICAgICAgPC9nPgogICAgICAgIDxnPgogICAgICAgICAgICA8bWFzayBpZD0iZCIgZmlsbD0iI2ZmZiI+CiAgICAgICAgICAgICAgICA8dXNlIHhsaW5rOmhyZWY9IiNjIiAvPgogICAgICAgICAgICA8L21hc2s+CiAgICAgICAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIGQ9Ik0tMTcuNTE2OCAxNEwxNC0xNy41MTY4IDQ1LjUxNjggMTQgMTQgNDUuNTE2OHoiIG1hc2s9InVybCgjZCkiIC8+CiAgICAgICAgPC9nPgogICAgICAgIDxwYXRoIHN0cm9rZT0iI0E3QTdDQSIgc3Ryb2tlLXdpZHRoPSIxLjIiCiAgICAgICAgICAgIGQ9Ik0xMC4wODg2IDIxLjQ4NjV2LTMuNjk2Nkg2LjM5Mk0yMS4zODU1IDEwLjE4OTVoLTMuNjk2NlY2LjQ5M00yMS40MDIgMTcuNzk4M2gtMy42OTY2djMuNjk2Nk0xMC4yNTAzIDYuMTQ5OHYzLjg5ODVINi4zNTE3IiAvPgogICAgPC9nPgo8L3N2Zz4K");\n}\n\n.telebox-titlebar-icon-close {\n background: center/cover no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyOCAyOCI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZT0iI0E3QTdDQSIgc3Ryb2tlLXdpZHRoPSIxLjQiPgogICAgICAgIDxwYXRoIGQ9Ik04LjM1MyAyMC4zMzIxTDIwLjMzMiA4LjM1M00yMC4zMzIyIDIwLjMzMjFMOC4zNTMgOC4zNTMiIC8+CiAgICA8L2c+Cjwvc3ZnPgo=");\n}\n\n.telebox-color-scheme-dark {\n color-scheme: dark;\n}\n\n.telebox-color-scheme-dark .telebox-title {\n color: #e9e9e9;\n}\n\n.telebox-color-scheme-dark .telebox-titlebar {\n color: #e9e9e9;\n background: #43434d;\n border-bottom: none;\n}';
1203
- exports.TELE_BOX_COLOR_SCHEME = void 0;
1204
- (function(TELE_BOX_COLOR_SCHEME2) {
1156
+ var style$3 = "";
1157
+ var TELE_BOX_COLOR_SCHEME = /* @__PURE__ */ ((TELE_BOX_COLOR_SCHEME2) => {
1205
1158
  TELE_BOX_COLOR_SCHEME2["Light"] = "light";
1206
1159
  TELE_BOX_COLOR_SCHEME2["Dark"] = "dark";
1207
1160
  TELE_BOX_COLOR_SCHEME2["Auto"] = "auto";
1208
- })(exports.TELE_BOX_COLOR_SCHEME || (exports.TELE_BOX_COLOR_SCHEME = {}));
1209
- exports.TELE_BOX_STATE = void 0;
1210
- (function(TELE_BOX_STATE2) {
1161
+ return TELE_BOX_COLOR_SCHEME2;
1162
+ })(TELE_BOX_COLOR_SCHEME || {});
1163
+ var TELE_BOX_STATE = /* @__PURE__ */ ((TELE_BOX_STATE2) => {
1211
1164
  TELE_BOX_STATE2["Normal"] = "normal";
1212
1165
  TELE_BOX_STATE2["Minimized"] = "minimized";
1213
1166
  TELE_BOX_STATE2["Maximized"] = "maximized";
1214
- })(exports.TELE_BOX_STATE || (exports.TELE_BOX_STATE = {}));
1215
- exports.TELE_BOX_EVENT = void 0;
1216
- (function(TELE_BOX_EVENT2) {
1167
+ return TELE_BOX_STATE2;
1168
+ })(TELE_BOX_STATE || {});
1169
+ var TELE_BOX_EVENT = /* @__PURE__ */ ((TELE_BOX_EVENT2) => {
1217
1170
  TELE_BOX_EVENT2["DarkMode"] = "dark_mode";
1218
1171
  TELE_BOX_EVENT2["PrefersColorScheme"] = "prefers_color_scheme";
1219
1172
  TELE_BOX_EVENT2["Close"] = "close";
@@ -1232,15 +1185,15 @@ exports.TELE_BOX_EVENT = void 0;
1232
1185
  TELE_BOX_EVENT2["Destroyed"] = "destroyed";
1233
1186
  TELE_BOX_EVENT2["BoxStatus"] = "box_status";
1234
1187
  TELE_BOX_EVENT2["LastNotMinimizedBoxStatus"] = "last_not_minimized_box_status";
1235
- })(exports.TELE_BOX_EVENT || (exports.TELE_BOX_EVENT = {}));
1236
- exports.TELE_BOX_DELEGATE_EVENT = void 0;
1237
- (function(TELE_BOX_DELEGATE_EVENT2) {
1188
+ return TELE_BOX_EVENT2;
1189
+ })(TELE_BOX_EVENT || {});
1190
+ var TELE_BOX_DELEGATE_EVENT = /* @__PURE__ */ ((TELE_BOX_DELEGATE_EVENT2) => {
1238
1191
  TELE_BOX_DELEGATE_EVENT2["Close"] = "close";
1239
1192
  TELE_BOX_DELEGATE_EVENT2["Maximize"] = "maximize";
1240
1193
  TELE_BOX_DELEGATE_EVENT2["Minimize"] = "minimize";
1241
- })(exports.TELE_BOX_DELEGATE_EVENT || (exports.TELE_BOX_DELEGATE_EVENT = {}));
1242
- exports.TELE_BOX_RESIZE_HANDLE = void 0;
1243
- (function(TELE_BOX_RESIZE_HANDLE2) {
1194
+ return TELE_BOX_DELEGATE_EVENT2;
1195
+ })(TELE_BOX_DELEGATE_EVENT || {});
1196
+ var TELE_BOX_RESIZE_HANDLE = /* @__PURE__ */ ((TELE_BOX_RESIZE_HANDLE2) => {
1244
1197
  TELE_BOX_RESIZE_HANDLE2["North"] = "n";
1245
1198
  TELE_BOX_RESIZE_HANDLE2["South"] = "s";
1246
1199
  TELE_BOX_RESIZE_HANDLE2["West"] = "w";
@@ -1249,7 +1202,8 @@ exports.TELE_BOX_RESIZE_HANDLE = void 0;
1249
1202
  TELE_BOX_RESIZE_HANDLE2["NorthEast"] = "ne";
1250
1203
  TELE_BOX_RESIZE_HANDLE2["SouthEast"] = "se";
1251
1204
  TELE_BOX_RESIZE_HANDLE2["SouthWest"] = "sw";
1252
- })(exports.TELE_BOX_RESIZE_HANDLE || (exports.TELE_BOX_RESIZE_HANDLE = {}));
1205
+ return TELE_BOX_RESIZE_HANDLE2;
1206
+ })(TELE_BOX_RESIZE_HANDLE || {});
1253
1207
  const TeleBoxDragHandleType = "dh";
1254
1208
  function clamp(value, min, max) {
1255
1209
  return Math.min(Math.max(value, min), max);
@@ -1284,7 +1238,7 @@ class DefaultTitleBar {
1284
1238
  onEvent,
1285
1239
  onDragStart,
1286
1240
  namespace = "telebox",
1287
- state = exports.TELE_BOX_STATE.Normal,
1241
+ state = TELE_BOX_STATE.Normal,
1288
1242
  boxStatus
1289
1243
  } = {}) {
1290
1244
  this.$btns = [];
@@ -1310,7 +1264,7 @@ class DefaultTitleBar {
1310
1264
  if (now - this.lastTitleBarClick.timestamp <= 500) {
1311
1265
  if (Math.abs(ev.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(ev.clientY - this.lastTitleBarClick.clientY) <= 5) {
1312
1266
  if (this.onEvent) {
1313
- this.onEvent({ type: exports.TELE_BOX_DELEGATE_EVENT.Maximize });
1267
+ this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1314
1268
  }
1315
1269
  }
1316
1270
  } else if (this.onDragStart) {
@@ -1342,7 +1296,7 @@ class DefaultTitleBar {
1342
1296
  if (now - this.lastTitleBarTouch.timestamp <= 500) {
1343
1297
  if (Math.abs(clientX - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(clientY - this.lastTitleBarTouch.clientY) <= 10) {
1344
1298
  if (this.onEvent) {
1345
- this.onEvent({ type: exports.TELE_BOX_DELEGATE_EVENT.Maximize });
1299
+ this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
1346
1300
  }
1347
1301
  }
1348
1302
  } else if (this.onDragStart) {
@@ -1361,16 +1315,16 @@ class DefaultTitleBar {
1361
1315
  this.boxStatus = boxStatus;
1362
1316
  this.buttons = buttons || [
1363
1317
  {
1364
- type: exports.TELE_BOX_DELEGATE_EVENT.Minimize,
1318
+ type: TELE_BOX_DELEGATE_EVENT.Minimize,
1365
1319
  iconClassName: this.wrapClassName("titlebar-icon-minimize")
1366
1320
  },
1367
1321
  {
1368
- type: exports.TELE_BOX_DELEGATE_EVENT.Maximize,
1322
+ type: TELE_BOX_DELEGATE_EVENT.Maximize,
1369
1323
  iconClassName: this.wrapClassName("titlebar-icon-maximize"),
1370
- isActive: (state2) => state2 === exports.TELE_BOX_STATE.Maximized
1324
+ isActive: (state2) => state2 === TELE_BOX_STATE.Maximized
1371
1325
  },
1372
1326
  {
1373
- type: exports.TELE_BOX_DELEGATE_EVENT.Close,
1327
+ type: TELE_BOX_DELEGATE_EVENT.Close,
1374
1328
  iconClassName: this.wrapClassName("titlebar-icon-close")
1375
1329
  }
1376
1330
  ];
@@ -1388,7 +1342,10 @@ class DefaultTitleBar {
1388
1342
  this.state = state;
1389
1343
  this.buttons.forEach((btn, i2) => {
1390
1344
  if (btn.isActive) {
1391
- this.$btns[i2].classList.toggle("is-active", btn.isActive(state));
1345
+ this.$btns[i2].classList.toggle(
1346
+ "is-active",
1347
+ btn.isActive(state)
1348
+ );
1392
1349
  }
1393
1350
  });
1394
1351
  }
@@ -1399,7 +1356,10 @@ class DefaultTitleBar {
1399
1356
  if (boxStatus) {
1400
1357
  this.buttons.forEach((btn, i2) => {
1401
1358
  if (btn.isActive) {
1402
- this.$btns[i2].classList.toggle("is-active", btn.isActive(boxStatus));
1359
+ this.$btns[i2].classList.toggle(
1360
+ "is-active",
1361
+ btn.isActive(boxStatus)
1362
+ );
1403
1363
  }
1404
1364
  });
1405
1365
  }
@@ -1431,7 +1391,9 @@ class DefaultTitleBar {
1431
1391
  this.buttons.forEach(({ iconClassName, isActive }, i2) => {
1432
1392
  const teleTitleBarBtnIndex = String(i2);
1433
1393
  const $btn = document.createElement("button");
1434
- $btn.className = `${this.wrapClassName("titlebar-btn")} ${iconClassName}`;
1394
+ $btn.className = `${this.wrapClassName(
1395
+ "titlebar-btn"
1396
+ )} ${iconClassName}`;
1435
1397
  $btn.dataset.teleTitleBarBtnIndex = teleTitleBarBtnIndex;
1436
1398
  $btn.dataset.teleTitleBarNoDblClick = "true";
1437
1399
  if (isActive) {
@@ -1440,24 +1402,30 @@ class DefaultTitleBar {
1440
1402
  this.$btns.push($btn);
1441
1403
  $buttonsContainer.appendChild($btn);
1442
1404
  });
1443
- this.sideEffect.addEventListener($buttonsContainer, "click", (ev) => {
1444
- var _a;
1445
- if (this.readonly) {
1446
- return;
1447
- }
1448
- const target = ev.target;
1449
- const teleTitleBarBtnIndex = Number((_a = target.dataset) == null ? void 0 : _a.teleTitleBarBtnIndex);
1450
- if (!Number.isNaN(teleTitleBarBtnIndex) && teleTitleBarBtnIndex < this.buttons.length) {
1451
- preventEvent(ev);
1452
- const btn = this.buttons[teleTitleBarBtnIndex];
1453
- if (this.onEvent) {
1454
- this.onEvent({
1455
- type: btn.type,
1456
- value: btn.value
1457
- });
1405
+ this.sideEffect.addEventListener(
1406
+ $buttonsContainer,
1407
+ "click",
1408
+ (ev) => {
1409
+ var _a;
1410
+ if (this.readonly) {
1411
+ return;
1412
+ }
1413
+ const target = ev.target;
1414
+ const teleTitleBarBtnIndex = Number(
1415
+ (_a = target.dataset) == null ? void 0 : _a.teleTitleBarBtnIndex
1416
+ );
1417
+ if (!Number.isNaN(teleTitleBarBtnIndex) && teleTitleBarBtnIndex < this.buttons.length) {
1418
+ preventEvent(ev);
1419
+ const btn = this.buttons[teleTitleBarBtnIndex];
1420
+ if (this.onEvent) {
1421
+ this.onEvent({
1422
+ type: btn.type,
1423
+ value: btn.value
1424
+ });
1425
+ }
1458
1426
  }
1459
1427
  }
1460
- });
1428
+ );
1461
1429
  this.$titleBar.appendChild($titleArea);
1462
1430
  this.$titleBar.appendChild($buttonsContainer);
1463
1431
  }
@@ -1467,8 +1435,17 @@ class DefaultTitleBar {
1467
1435
  const $dragArea = document.createElement("div");
1468
1436
  $dragArea.className = this.wrapClassName("drag-area");
1469
1437
  $dragArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
1470
- this.sideEffect.addEventListener($dragArea, "mousedown", this.handleTitleBarClick);
1471
- this.sideEffect.addEventListener($dragArea, "touchstart", this.handleTitleBarTouch, { passive: true });
1438
+ this.sideEffect.addEventListener(
1439
+ $dragArea,
1440
+ "mousedown",
1441
+ this.handleTitleBarClick
1442
+ );
1443
+ this.sideEffect.addEventListener(
1444
+ $dragArea,
1445
+ "touchstart",
1446
+ this.handleTitleBarTouch,
1447
+ { passive: true }
1448
+ );
1472
1449
  return $dragArea;
1473
1450
  }
1474
1451
  dragHandle() {
@@ -1492,7 +1469,7 @@ class TeleBox {
1492
1469
  constructor({
1493
1470
  id = genUniqueKey(),
1494
1471
  title = getBoxDefaultName(),
1495
- prefersColorScheme = exports.TELE_BOX_COLOR_SCHEME.Light,
1472
+ prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
1496
1473
  darkMode,
1497
1474
  visible = true,
1498
1475
  width = 0.5,
@@ -1539,38 +1516,53 @@ class TeleBox {
1539
1516
  this._delegateEvents = new EventEmitter();
1540
1517
  const boxStatus$ = createVal(boxStatus);
1541
1518
  const lastNotMinimizedBoxStatus$ = createVal(lastNotMinimizedBoxStatus);
1542
- const prefersColorScheme$ = createVal(prefersColorScheme);
1519
+ const prefersColorScheme$ = createVal(
1520
+ prefersColorScheme
1521
+ );
1543
1522
  prefersColorScheme$.reaction((prefersColorScheme2, _, skipUpdate) => {
1544
1523
  if (!skipUpdate) {
1545
- this.events.emit(exports.TELE_BOX_EVENT.PrefersColorScheme, prefersColorScheme2);
1524
+ this.events.emit(
1525
+ TELE_BOX_EVENT.PrefersColorScheme,
1526
+ prefersColorScheme2
1527
+ );
1546
1528
  }
1547
1529
  });
1548
1530
  const darkMode$ = createVal(Boolean(darkMode));
1549
1531
  if (darkMode == null) {
1550
- prefersColorScheme$.subscribe((prefersColorScheme2, _, skipUpdate) => {
1551
- this._sideEffect.add(() => {
1552
- if (prefersColorScheme2 === "auto") {
1553
- const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
1554
- if (prefersDark) {
1555
- darkMode$.setValue(prefersDark.matches, skipUpdate);
1556
- const handler = (evt) => {
1557
- darkMode$.setValue(evt.matches, skipUpdate);
1558
- };
1559
- prefersDark.addListener(handler);
1560
- return () => prefersDark.removeListener(handler);
1532
+ prefersColorScheme$.subscribe(
1533
+ (prefersColorScheme2, _, skipUpdate) => {
1534
+ this._sideEffect.add(() => {
1535
+ if (prefersColorScheme2 === "auto") {
1536
+ const prefersDark = window.matchMedia(
1537
+ "(prefers-color-scheme: dark)"
1538
+ );
1539
+ if (prefersDark) {
1540
+ darkMode$.setValue(
1541
+ prefersDark.matches,
1542
+ skipUpdate
1543
+ );
1544
+ const handler = (evt) => {
1545
+ darkMode$.setValue(evt.matches, skipUpdate);
1546
+ };
1547
+ prefersDark.addListener(handler);
1548
+ return () => prefersDark.removeListener(handler);
1549
+ } else {
1550
+ return noop;
1551
+ }
1561
1552
  } else {
1553
+ darkMode$.setValue(
1554
+ prefersColorScheme2 === "dark",
1555
+ skipUpdate
1556
+ );
1562
1557
  return noop;
1563
1558
  }
1564
- } else {
1565
- darkMode$.setValue(prefersColorScheme2 === "dark", skipUpdate);
1566
- return noop;
1567
- }
1568
- }, "prefers-color-scheme");
1569
- });
1559
+ }, "prefers-color-scheme");
1560
+ }
1561
+ );
1570
1562
  }
1571
1563
  darkMode$.reaction((darkMode2, _, skipUpdate) => {
1572
1564
  if (!skipUpdate) {
1573
- this.events.emit(exports.TELE_BOX_EVENT.DarkMode, darkMode2);
1565
+ this.events.emit(TELE_BOX_EVENT.DarkMode, darkMode2);
1574
1566
  }
1575
1567
  });
1576
1568
  const containerRect$ = createVal(containerRect, shallowequal);
@@ -1584,13 +1576,13 @@ class TeleBox {
1584
1576
  const visible$ = createVal(visible);
1585
1577
  visible$.reaction((visible2, _, skipUpdate) => {
1586
1578
  if (!skipUpdate && !visible2) {
1587
- this.events.emit(exports.TELE_BOX_EVENT.Close);
1579
+ this.events.emit(TELE_BOX_EVENT.Close);
1588
1580
  }
1589
1581
  });
1590
1582
  const readonly$ = createVal(readonly);
1591
1583
  readonly$.reaction((readonly2, _, skipUpdate) => {
1592
1584
  if (!skipUpdate) {
1593
- this.events.emit(exports.TELE_BOX_EVENT.Readonly, readonly2);
1585
+ this.events.emit(TELE_BOX_EVENT.Readonly, readonly2);
1594
1586
  }
1595
1587
  });
1596
1588
  const resizable$ = createVal(resizable);
@@ -1600,122 +1592,151 @@ class TeleBox {
1600
1592
  const zIndex$ = createVal(zIndex);
1601
1593
  zIndex$.reaction((zIndex2, _, skipUpdate) => {
1602
1594
  if (!skipUpdate) {
1603
- this.events.emit(exports.TELE_BOX_EVENT.ZIndex, zIndex2);
1595
+ this.events.emit(TELE_BOX_EVENT.ZIndex, zIndex2);
1604
1596
  }
1605
1597
  });
1606
1598
  const focus$ = createVal(focus);
1607
1599
  focus$.reaction((focus2, _, skipUpdate) => {
1608
1600
  if (!skipUpdate) {
1609
- this.events.emit(focus2 ? exports.TELE_BOX_EVENT.Focus : exports.TELE_BOX_EVENT.Blur);
1601
+ this.events.emit(
1602
+ focus2 ? TELE_BOX_EVENT.Focus : TELE_BOX_EVENT.Blur
1603
+ );
1610
1604
  }
1611
1605
  });
1612
1606
  const minimized$ = createVal(minimized);
1613
1607
  minimized$.reaction((minimized2, _, skipUpdate) => {
1614
1608
  if (!skipUpdate) {
1615
- this.events.emit(exports.TELE_BOX_EVENT.Minimized, minimized2);
1609
+ this.events.emit(TELE_BOX_EVENT.Minimized, minimized2);
1616
1610
  }
1617
1611
  });
1618
1612
  const maximized$ = createVal(maximized);
1619
1613
  maximized$.reaction((maximized2, _, skipUpdate) => {
1620
1614
  if (!skipUpdate) {
1621
- this.events.emit(exports.TELE_BOX_EVENT.Maximized, maximized2);
1615
+ this.events.emit(TELE_BOX_EVENT.Maximized, maximized2);
1622
1616
  }
1623
1617
  });
1624
- const state$ = combine([minimized$, maximized$, boxStatus$], ([minimized2, maximized2, boxStatus2]) => minimized2 ? exports.TELE_BOX_STATE.Minimized : maximized2 ? exports.TELE_BOX_STATE.Maximized : !boxStatus2 ? exports.TELE_BOX_STATE.Normal : boxStatus2);
1618
+ const state$ = combine(
1619
+ [minimized$, maximized$, boxStatus$],
1620
+ ([minimized2, maximized2, boxStatus2]) => minimized2 ? TELE_BOX_STATE.Minimized : maximized2 ? TELE_BOX_STATE.Maximized : !boxStatus2 ? TELE_BOX_STATE.Normal : boxStatus2
1621
+ );
1625
1622
  state$.reaction((state, _, skipUpdate) => {
1626
1623
  if (!skipUpdate) {
1627
- this.events.emit(exports.TELE_BOX_EVENT.State, state);
1624
+ this.events.emit(TELE_BOX_EVENT.State, state);
1628
1625
  }
1629
1626
  });
1630
- const minSize$ = createVal({
1631
- width: clamp(minWidth, 0, 1),
1632
- height: clamp(minHeight, 0, 1)
1633
- }, shallowequal);
1634
- const intrinsicSize$ = createVal({
1635
- width: clamp(width, minSize$.value.width, 1),
1636
- height: clamp(height, minSize$.value.height, 1)
1637
- }, shallowequal);
1627
+ const minSize$ = createVal(
1628
+ {
1629
+ width: clamp(minWidth, 0, 1),
1630
+ height: clamp(minHeight, 0, 1)
1631
+ },
1632
+ shallowequal
1633
+ );
1634
+ const intrinsicSize$ = createVal(
1635
+ {
1636
+ width: clamp(width, minSize$.value.width, 1),
1637
+ height: clamp(height, minSize$.value.height, 1)
1638
+ },
1639
+ shallowequal
1640
+ );
1638
1641
  minSize$.reaction((minSize, _, skipUpdate) => {
1639
- intrinsicSize$.setValue({
1640
- width: clamp(width, minSize.width, 1),
1641
- height: clamp(height, minSize.height, 1)
1642
- }, skipUpdate);
1642
+ intrinsicSize$.setValue(
1643
+ {
1644
+ width: clamp(width, minSize.width, 1),
1645
+ height: clamp(height, minSize.height, 1)
1646
+ },
1647
+ skipUpdate
1648
+ );
1643
1649
  });
1644
1650
  intrinsicSize$.reaction((size, _, skipUpdate) => {
1645
1651
  if (!skipUpdate) {
1646
- this.events.emit(exports.TELE_BOX_EVENT.IntrinsicResize, size);
1652
+ this.events.emit(TELE_BOX_EVENT.IntrinsicResize, size);
1647
1653
  }
1648
1654
  });
1649
- const size$ = combine([intrinsicSize$, maximized$, boxStatus$], ([intrinsicSize, maximized2, boxStatus2]) => {
1650
- if (maximized2 || boxStatus2 === exports.TELE_BOX_STATE.Maximized) {
1651
- return { width: 1, height: 1 };
1652
- }
1653
- return intrinsicSize;
1654
- }, shallowequal);
1655
+ const size$ = combine(
1656
+ [intrinsicSize$, maximized$, boxStatus$],
1657
+ ([intrinsicSize, maximized2, boxStatus2]) => {
1658
+ if (maximized2 || boxStatus2 === TELE_BOX_STATE.Maximized) {
1659
+ return { width: 1, height: 1 };
1660
+ }
1661
+ return intrinsicSize;
1662
+ },
1663
+ shallowequal
1664
+ );
1655
1665
  size$.reaction((size, _, skipUpdate) => {
1656
1666
  if (!skipUpdate) {
1657
- this.events.emit(exports.TELE_BOX_EVENT.Resize, size);
1667
+ this.events.emit(TELE_BOX_EVENT.Resize, size);
1658
1668
  }
1659
1669
  });
1660
- const visualSize$ = combine([size$, minimized$, containerRect$, collectorRect$, boxStatus$], ([size, minimized2, containerRect2, collectorRect2, boxStatus2]) => {
1661
- if ((minimized2 || boxStatus2 === exports.TELE_BOX_STATE.Minimized) && collectorRect2) {
1662
- return {
1663
- width: collectorRect2.width / size.width / containerRect2.width,
1664
- height: collectorRect2.height / size.height / containerRect2.height
1665
- };
1666
- }
1667
- return size;
1668
- }, shallowequal);
1670
+ const visualSize$ = combine(
1671
+ [size$, minimized$, containerRect$, collectorRect$, boxStatus$],
1672
+ ([size, minimized2, containerRect2, collectorRect2, boxStatus2]) => {
1673
+ if ((minimized2 || boxStatus2 === TELE_BOX_STATE.Minimized) && collectorRect2) {
1674
+ return {
1675
+ width: collectorRect2.width / size.width / containerRect2.width,
1676
+ height: collectorRect2.height / size.height / containerRect2.height
1677
+ };
1678
+ }
1679
+ return size;
1680
+ },
1681
+ shallowequal
1682
+ );
1669
1683
  visualSize$.reaction((size, _, skipUpdate) => {
1670
1684
  if (!skipUpdate) {
1671
- this.events.emit(exports.TELE_BOX_EVENT.VisualResize, size);
1685
+ this.events.emit(TELE_BOX_EVENT.VisualResize, size);
1672
1686
  }
1673
1687
  });
1674
- const intrinsicCoord$ = createVal({ x: clamp(x, 0, 1), y: clamp(y, 0, 1) }, shallowequal);
1688
+ const intrinsicCoord$ = createVal(
1689
+ { x: clamp(x, 0, 1), y: clamp(y, 0, 1) },
1690
+ shallowequal
1691
+ );
1675
1692
  intrinsicCoord$.reaction((coord, _, skipUpdate) => {
1676
1693
  if (!skipUpdate) {
1677
- this.events.emit(exports.TELE_BOX_EVENT.IntrinsicMove, coord);
1678
- }
1679
- });
1680
- const coord$ = combine([
1681
- intrinsicCoord$,
1682
- intrinsicSize$,
1683
- containerRect$,
1684
- collectorRect$,
1685
- minimized$,
1686
- maximized$,
1687
- boxStatus$,
1688
- lastNotMinimizedBoxStatus$
1689
- ], ([
1690
- intrinsicCoord,
1691
- intrinsicSize,
1692
- containerRect2,
1693
- collectorRect2,
1694
- minimized2,
1695
- maximized2,
1696
- boxStatus2,
1697
- lastNotMinimizedBoxStatus2
1698
- ]) => {
1699
- if ((minimized2 || boxStatus2 === exports.TELE_BOX_STATE.Minimized) && collectorRect2) {
1700
- if (maximized2 || lastNotMinimizedBoxStatus2 === exports.TELE_BOX_STATE.Maximized) {
1694
+ this.events.emit(TELE_BOX_EVENT.IntrinsicMove, coord);
1695
+ }
1696
+ });
1697
+ const coord$ = combine(
1698
+ [
1699
+ intrinsicCoord$,
1700
+ intrinsicSize$,
1701
+ containerRect$,
1702
+ collectorRect$,
1703
+ minimized$,
1704
+ maximized$,
1705
+ boxStatus$,
1706
+ lastNotMinimizedBoxStatus$
1707
+ ],
1708
+ ([
1709
+ intrinsicCoord,
1710
+ intrinsicSize,
1711
+ containerRect2,
1712
+ collectorRect2,
1713
+ minimized2,
1714
+ maximized2,
1715
+ boxStatus2,
1716
+ lastNotMinimizedBoxStatus2
1717
+ ]) => {
1718
+ if ((minimized2 || boxStatus2 === TELE_BOX_STATE.Minimized) && collectorRect2) {
1719
+ if (maximized2 || lastNotMinimizedBoxStatus2 === TELE_BOX_STATE.Maximized) {
1720
+ return {
1721
+ x: (collectorRect2.x + collectorRect2.width / 2) / containerRect2.width - 1 / 2,
1722
+ y: (collectorRect2.y + collectorRect2.height / 2) / containerRect2.height - 1 / 2
1723
+ };
1724
+ }
1701
1725
  return {
1702
- x: (collectorRect2.x + collectorRect2.width / 2) / containerRect2.width - 1 / 2,
1703
- y: (collectorRect2.y + collectorRect2.height / 2) / containerRect2.height - 1 / 2
1726
+ x: (collectorRect2.x + collectorRect2.width / 2) / containerRect2.width - intrinsicSize.width / 2,
1727
+ y: (collectorRect2.y + collectorRect2.height / 2) / containerRect2.height - intrinsicSize.height / 2
1704
1728
  };
1705
1729
  }
1706
- return {
1707
- x: (collectorRect2.x + collectorRect2.width / 2) / containerRect2.width - intrinsicSize.width / 2,
1708
- y: (collectorRect2.y + collectorRect2.height / 2) / containerRect2.height - intrinsicSize.height / 2
1709
- };
1710
- }
1711
- if (maximized2 || boxStatus2 === exports.TELE_BOX_STATE.Maximized) {
1712
- return { x: 0, y: 0 };
1713
- }
1714
- return intrinsicCoord;
1715
- }, shallowequal);
1730
+ if (maximized2 || boxStatus2 === TELE_BOX_STATE.Maximized) {
1731
+ return { x: 0, y: 0 };
1732
+ }
1733
+ return intrinsicCoord;
1734
+ },
1735
+ shallowequal
1736
+ );
1716
1737
  coord$.reaction((coord, _, skipUpdate) => {
1717
1738
  if (!skipUpdate) {
1718
- this.events.emit(exports.TELE_BOX_EVENT.Move, coord);
1739
+ this.events.emit(TELE_BOX_EVENT.Move, coord);
1719
1740
  }
1720
1741
  });
1721
1742
  this.titleBar = titleBar || new DefaultTitleBar({
@@ -1732,24 +1753,27 @@ class TeleBox {
1732
1753
  this._delegateEvents.emit(event.type);
1733
1754
  } else {
1734
1755
  switch (event.type) {
1735
- case exports.TELE_BOX_DELEGATE_EVENT.Maximize: {
1756
+ case TELE_BOX_DELEGATE_EVENT.Maximize: {
1736
1757
  if (!boxStatus$.value) {
1737
1758
  maximized$.setValue(!maximized$.value);
1738
1759
  }
1739
1760
  break;
1740
1761
  }
1741
- case exports.TELE_BOX_DELEGATE_EVENT.Minimize: {
1762
+ case TELE_BOX_DELEGATE_EVENT.Minimize: {
1742
1763
  if (!boxStatus$.value) {
1743
1764
  minimized$.setValue(true);
1744
1765
  }
1745
1766
  break;
1746
1767
  }
1747
- case exports.TELE_BOX_DELEGATE_EVENT.Close: {
1768
+ case TELE_BOX_DELEGATE_EVENT.Close: {
1748
1769
  visible$.setValue(false);
1749
1770
  break;
1750
1771
  }
1751
1772
  default: {
1752
- console.error("Unsupported titleBar event:", event);
1773
+ console.error(
1774
+ "Unsupported titleBar event:",
1775
+ event
1776
+ );
1753
1777
  break;
1754
1778
  }
1755
1779
  }
@@ -1796,7 +1820,13 @@ class TeleBox {
1796
1820
  this._boxStatus$ = boxStatus$;
1797
1821
  this._lastNotMinimizedBoxStatus$ = lastNotMinimizedBoxStatus$;
1798
1822
  if (this.fixRatio) {
1799
- this.transform(coord$.value.x, coord$.value.y, size$.value.width, size$.value.height, true);
1823
+ this.transform(
1824
+ coord$.value.x,
1825
+ coord$.value.y,
1826
+ size$.value.width,
1827
+ size$.value.height,
1828
+ true
1829
+ );
1800
1830
  }
1801
1831
  this.$box = this.render();
1802
1832
  }
@@ -1817,12 +1847,12 @@ class TeleBox {
1817
1847
  }
1818
1848
  setState(state, skipUpdate = false) {
1819
1849
  switch (state) {
1820
- case exports.TELE_BOX_STATE.Maximized: {
1850
+ case TELE_BOX_STATE.Maximized: {
1821
1851
  this.setMinimized(false, skipUpdate);
1822
1852
  this.setMaximized(true, skipUpdate);
1823
1853
  break;
1824
1854
  }
1825
- case exports.TELE_BOX_STATE.Minimized: {
1855
+ case TELE_BOX_STATE.Minimized: {
1826
1856
  this.setMinimized(true, skipUpdate);
1827
1857
  this.setMaximized(false, skipUpdate);
1828
1858
  break;
@@ -1836,8 +1866,8 @@ class TeleBox {
1836
1866
  return this;
1837
1867
  }
1838
1868
  setBoxStatus(boxStatus, skipUpdate = false) {
1839
- if (boxStatus === exports.TELE_BOX_STATE.Minimized) {
1840
- if (this._boxStatus$.value && this._boxStatus$.value !== exports.TELE_BOX_STATE.Minimized) {
1869
+ if (boxStatus === TELE_BOX_STATE.Minimized) {
1870
+ if (this._boxStatus$.value && this._boxStatus$.value !== TELE_BOX_STATE.Minimized) {
1841
1871
  this.setLastNotMinimizedBoxStatus(this._boxStatus$.value, skipUpdate);
1842
1872
  }
1843
1873
  } else {
@@ -1845,14 +1875,14 @@ class TeleBox {
1845
1875
  }
1846
1876
  this._boxStatus$.setValue(boxStatus, skipUpdate);
1847
1877
  if (!skipUpdate) {
1848
- this.events.emit(exports.TELE_BOX_EVENT.BoxStatus, { id: this.id, boxStatus });
1878
+ this.events.emit(TELE_BOX_EVENT.BoxStatus, { id: this.id, boxStatus });
1849
1879
  }
1850
1880
  return this;
1851
1881
  }
1852
1882
  setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate = false) {
1853
1883
  this._lastNotMinimizedBoxStatus$.setValue(lastNotMinimizedBoxStatus, skipUpdate);
1854
1884
  if (!skipUpdate) {
1855
- this.events.emit(exports.TELE_BOX_EVENT.LastNotMinimizedBoxStatus, { id: this.id, lastNotMinimizedBoxStatus });
1885
+ this.events.emit(TELE_BOX_EVENT.LastNotMinimizedBoxStatus, { id: this.id, lastNotMinimizedBoxStatus });
1856
1886
  }
1857
1887
  return this;
1858
1888
  }
@@ -1863,11 +1893,17 @@ class TeleBox {
1863
1893
  return this._minSize$.value.height;
1864
1894
  }
1865
1895
  setMinWidth(minWidth, skipUpdate = false) {
1866
- this._minSize$.setValue({ width: minWidth, height: this.minHeight }, skipUpdate);
1896
+ this._minSize$.setValue(
1897
+ { width: minWidth, height: this.minHeight },
1898
+ skipUpdate
1899
+ );
1867
1900
  return this;
1868
1901
  }
1869
1902
  setMinHeight(minHeight, skipUpdate = false) {
1870
- this._minSize$.setValue({ width: this.minWidth, height: minHeight }, skipUpdate);
1903
+ this._minSize$.setValue(
1904
+ { width: this.minWidth, height: minHeight },
1905
+ skipUpdate
1906
+ );
1871
1907
  return this;
1872
1908
  }
1873
1909
  get intrinsicWidth() {
@@ -1928,14 +1964,20 @@ class TeleBox {
1928
1964
  height = this.intrinsicHeight;
1929
1965
  }
1930
1966
  }
1931
- this._intrinsicCoord$.setValue({
1932
- x: width >= this.minWidth ? x : this.intrinsicX,
1933
- y: height >= this.minHeight ? y : this.intrinsicY
1934
- }, skipUpdate);
1935
- this._intrinsicSize$.setValue({
1936
- width: clamp(width, this.minWidth, 1),
1937
- height: clamp(height, this.minHeight, 1)
1938
- }, skipUpdate);
1967
+ this._intrinsicCoord$.setValue(
1968
+ {
1969
+ x: width >= this.minWidth ? x : this.intrinsicX,
1970
+ y: height >= this.minHeight ? y : this.intrinsicY
1971
+ },
1972
+ skipUpdate
1973
+ );
1974
+ this._intrinsicSize$.setValue(
1975
+ {
1976
+ width: clamp(width, this.minWidth, 1),
1977
+ height: clamp(height, this.minHeight, 1)
1978
+ },
1979
+ skipUpdate
1980
+ );
1939
1981
  return this;
1940
1982
  }
1941
1983
  mount(container) {
@@ -2011,33 +2053,52 @@ class TeleBox {
2011
2053
  bindClassName(this.$box, this._resizable$, "no-resize", isFalsy);
2012
2054
  bindClassName(this.$box, this._focus$, "blur", isFalsy);
2013
2055
  bindClassName(this.$box, this._darkMode$, "color-scheme-dark");
2014
- bindClassName(this.$box, this._darkMode$, "color-scheme-light", isFalsy);
2056
+ bindClassName(
2057
+ this.$box,
2058
+ this._darkMode$,
2059
+ "color-scheme-light",
2060
+ isFalsy
2061
+ );
2015
2062
  this._renderSideEffect.add(() => {
2016
2063
  const minimizedClassName = this.wrapClassName("minimized");
2017
2064
  const maximizedClassName = this.wrapClassName("maximized");
2018
2065
  const MAXIMIZED_TIMER_ID = "box-maximized-timer";
2019
2066
  return this._state$.subscribe((state) => {
2020
- this.$box.classList.toggle(minimizedClassName, state === exports.TELE_BOX_STATE.Minimized);
2021
- if (state === exports.TELE_BOX_STATE.Maximized) {
2067
+ this.$box.classList.toggle(
2068
+ minimizedClassName,
2069
+ state === TELE_BOX_STATE.Minimized
2070
+ );
2071
+ if (state === TELE_BOX_STATE.Maximized) {
2022
2072
  this._renderSideEffect.flush(MAXIMIZED_TIMER_ID);
2023
2073
  this.$box.classList.toggle(maximizedClassName, true);
2024
2074
  } else {
2025
- this._renderSideEffect.setTimeout(() => {
2026
- this.$box.classList.toggle(maximizedClassName, false);
2027
- }, 0, MAXIMIZED_TIMER_ID);
2075
+ this._renderSideEffect.setTimeout(
2076
+ () => {
2077
+ this.$box.classList.toggle(
2078
+ maximizedClassName,
2079
+ false
2080
+ );
2081
+ },
2082
+ 0,
2083
+ MAXIMIZED_TIMER_ID
2084
+ );
2028
2085
  }
2029
2086
  });
2030
2087
  });
2031
- this._renderSideEffect.add(() => this._visible$.subscribe((visible) => {
2032
- if (visible) {
2033
- this.$box.style.removeProperty("display");
2034
- } else {
2035
- this.$box.style.display = "none";
2036
- }
2037
- }));
2038
- this._renderSideEffect.add(() => this._zIndex$.subscribe((zIndex) => {
2039
- this.$box.style.zIndex = String(zIndex);
2040
- }));
2088
+ this._renderSideEffect.add(
2089
+ () => this._visible$.subscribe((visible) => {
2090
+ if (visible) {
2091
+ this.$box.style.removeProperty("display");
2092
+ } else {
2093
+ this.$box.style.display = "none";
2094
+ }
2095
+ })
2096
+ );
2097
+ this._renderSideEffect.add(
2098
+ () => this._zIndex$.subscribe((zIndex) => {
2099
+ this.$box.style.zIndex = String(zIndex);
2100
+ })
2101
+ );
2041
2102
  const boxStyler = index(this.$box);
2042
2103
  this.$box.dataset.teleBoxID = this.id;
2043
2104
  this.$box.style.width = this.absoluteWidth + "px";
@@ -2045,25 +2106,29 @@ class TeleBox {
2045
2106
  const translateX = this.x * this.containerRect.width + this.containerRect.x;
2046
2107
  const translateY = this.y * this.containerRect.height + this.containerRect.y;
2047
2108
  this.$box.style.transform = `translate(${translateX - 10}px,${translateY - 10}px)`;
2048
- this._valSideEffectBinder.combine([
2049
- this._coord$,
2050
- this._size$,
2051
- this._minimized$,
2052
- this._containerRect$,
2053
- this._collectorRect$,
2054
- this._boxStatus$
2055
- ], ([coord, size, minimized, containerRect, collectorRect, boxStatus]) => {
2056
- const absoluteWidth = size.width * containerRect.width;
2057
- const absoluteHeight = size.height * containerRect.height;
2058
- return {
2059
- width: absoluteWidth + ((minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? 1 : 0),
2060
- height: absoluteHeight + ((minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? 1 : 0),
2061
- x: coord.x * containerRect.width,
2062
- y: coord.y * containerRect.height,
2063
- scaleX: (minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? collectorRect.width / absoluteWidth : 1,
2064
- scaleY: (minimized || boxStatus === exports.TELE_BOX_STATE.Minimized) && collectorRect ? collectorRect.height / absoluteHeight : 1
2065
- };
2066
- }, shallowequal).subscribe((styles) => {
2109
+ this._valSideEffectBinder.combine(
2110
+ [
2111
+ this._coord$,
2112
+ this._size$,
2113
+ this._minimized$,
2114
+ this._containerRect$,
2115
+ this._collectorRect$,
2116
+ this._boxStatus$
2117
+ ],
2118
+ ([coord, size, minimized, containerRect, collectorRect, boxStatus]) => {
2119
+ const absoluteWidth = size.width * containerRect.width;
2120
+ const absoluteHeight = size.height * containerRect.height;
2121
+ return {
2122
+ width: absoluteWidth + ((minimized || boxStatus === TELE_BOX_STATE.Minimized) && collectorRect ? 1 : 0),
2123
+ height: absoluteHeight + ((minimized || boxStatus === TELE_BOX_STATE.Minimized) && collectorRect ? 1 : 0),
2124
+ x: coord.x * containerRect.width,
2125
+ y: coord.y * containerRect.height,
2126
+ scaleX: (minimized || boxStatus === TELE_BOX_STATE.Minimized) && collectorRect ? collectorRect.width / absoluteWidth : 1,
2127
+ scaleY: (minimized || boxStatus === TELE_BOX_STATE.Minimized) && collectorRect ? collectorRect.height / absoluteHeight : 1
2128
+ };
2129
+ },
2130
+ shallowequal
2131
+ ).subscribe((styles) => {
2067
2132
  boxStyler.set(styles);
2068
2133
  });
2069
2134
  boxStyler.set({ x: translateX, y: translateY });
@@ -2128,7 +2193,7 @@ class TeleBox {
2128
2193
  _renderResizeHandlers() {
2129
2194
  const $resizeHandles = document.createElement("div");
2130
2195
  $resizeHandles.className = this.wrapClassName("resize-handles");
2131
- Object.values(exports.TELE_BOX_RESIZE_HANDLE).forEach((handleType) => {
2196
+ Object.values(TELE_BOX_RESIZE_HANDLE).forEach((handleType) => {
2132
2197
  const $handle = document.createElement("div");
2133
2198
  $handle.className = this.wrapClassName(handleType) + " " + this.wrapClassName("resize-handle");
2134
2199
  $handle.dataset.teleBoxHandle = handleType;
@@ -2146,7 +2211,7 @@ class TeleBox {
2146
2211
  let trackStartPageY = 0;
2147
2212
  let trackingHandle;
2148
2213
  const handleTracking = (ev) => {
2149
- if (this.state !== exports.TELE_BOX_STATE.Normal) {
2214
+ if (this.state !== TELE_BOX_STATE.Normal) {
2150
2215
  return;
2151
2216
  }
2152
2217
  preventEvent(ev);
@@ -2157,45 +2222,95 @@ class TeleBox {
2157
2222
  const offsetX = (pageX - trackStartPageX) / this.containerRect.width;
2158
2223
  const offsetY = (pageY - trackStartPageY) / this.containerRect.height;
2159
2224
  switch (trackingHandle) {
2160
- case exports.TELE_BOX_RESIZE_HANDLE.North: {
2161
- this.transform(this.x, trackStartY + offsetY, this.width, trackStartHeight - offsetY);
2225
+ case TELE_BOX_RESIZE_HANDLE.North: {
2226
+ this.transform(
2227
+ this.x,
2228
+ trackStartY + offsetY,
2229
+ this.width,
2230
+ trackStartHeight - offsetY
2231
+ );
2162
2232
  break;
2163
2233
  }
2164
- case exports.TELE_BOX_RESIZE_HANDLE.South: {
2165
- this.transform(this.x, this.y, this.width, trackStartHeight + offsetY);
2234
+ case TELE_BOX_RESIZE_HANDLE.South: {
2235
+ this.transform(
2236
+ this.x,
2237
+ this.y,
2238
+ this.width,
2239
+ trackStartHeight + offsetY
2240
+ );
2166
2241
  break;
2167
2242
  }
2168
- case exports.TELE_BOX_RESIZE_HANDLE.West: {
2169
- this.transform(trackStartX + offsetX, this.y, trackStartWidth - offsetX, this.height);
2243
+ case TELE_BOX_RESIZE_HANDLE.West: {
2244
+ this.transform(
2245
+ trackStartX + offsetX,
2246
+ this.y,
2247
+ trackStartWidth - offsetX,
2248
+ this.height
2249
+ );
2170
2250
  break;
2171
2251
  }
2172
- case exports.TELE_BOX_RESIZE_HANDLE.East: {
2173
- this.transform(this.x, this.y, trackStartWidth + offsetX, this.height);
2252
+ case TELE_BOX_RESIZE_HANDLE.East: {
2253
+ this.transform(
2254
+ this.x,
2255
+ this.y,
2256
+ trackStartWidth + offsetX,
2257
+ this.height
2258
+ );
2174
2259
  break;
2175
2260
  }
2176
- case exports.TELE_BOX_RESIZE_HANDLE.NorthWest: {
2177
- this.transform(trackStartX + offsetX, trackStartY + offsetY, trackStartWidth - offsetX, trackStartHeight - offsetY);
2261
+ case TELE_BOX_RESIZE_HANDLE.NorthWest: {
2262
+ this.transform(
2263
+ trackStartX + offsetX,
2264
+ trackStartY + offsetY,
2265
+ trackStartWidth - offsetX,
2266
+ trackStartHeight - offsetY
2267
+ );
2178
2268
  break;
2179
2269
  }
2180
- case exports.TELE_BOX_RESIZE_HANDLE.NorthEast: {
2181
- this.transform(this.x, trackStartY + offsetY, trackStartWidth + offsetX, trackStartHeight - offsetY);
2270
+ case TELE_BOX_RESIZE_HANDLE.NorthEast: {
2271
+ this.transform(
2272
+ this.x,
2273
+ trackStartY + offsetY,
2274
+ trackStartWidth + offsetX,
2275
+ trackStartHeight - offsetY
2276
+ );
2182
2277
  break;
2183
2278
  }
2184
- case exports.TELE_BOX_RESIZE_HANDLE.SouthEast: {
2185
- this.transform(this.x, this.y, trackStartWidth + offsetX, trackStartHeight + offsetY);
2279
+ case TELE_BOX_RESIZE_HANDLE.SouthEast: {
2280
+ this.transform(
2281
+ this.x,
2282
+ this.y,
2283
+ trackStartWidth + offsetX,
2284
+ trackStartHeight + offsetY
2285
+ );
2186
2286
  break;
2187
2287
  }
2188
- case exports.TELE_BOX_RESIZE_HANDLE.SouthWest: {
2189
- this.transform(trackStartX + offsetX, this.y, trackStartWidth - offsetX, trackStartHeight + offsetY);
2288
+ case TELE_BOX_RESIZE_HANDLE.SouthWest: {
2289
+ this.transform(
2290
+ trackStartX + offsetX,
2291
+ this.y,
2292
+ trackStartWidth - offsetX,
2293
+ trackStartHeight + offsetY
2294
+ );
2190
2295
  break;
2191
2296
  }
2192
2297
  default: {
2193
2298
  if (this.fence) {
2194
- this.move(clamp(trackStartX + offsetX, 0, 1 - this.width), clamp(trackStartY + offsetY, 0, 1 - this.height));
2299
+ this.move(
2300
+ clamp(trackStartX + offsetX, 0, 1 - this.width),
2301
+ clamp(trackStartY + offsetY, 0, 1 - this.height)
2302
+ );
2195
2303
  } else {
2196
2304
  const xOverflowOffset = 20 / this.containerRect.width;
2197
2305
  const yOverflowOffset = 20 / this.containerRect.height;
2198
- this.move(clamp(trackStartX + offsetX, xOverflowOffset - this.width, 1 - xOverflowOffset), clamp(trackStartY + offsetY, 0, 1 - yOverflowOffset));
2306
+ this.move(
2307
+ clamp(
2308
+ trackStartX + offsetX,
2309
+ xOverflowOffset - this.width,
2310
+ 1 - xOverflowOffset
2311
+ ),
2312
+ clamp(trackStartY + offsetY, 0, 1 - yOverflowOffset)
2313
+ );
2199
2314
  }
2200
2315
  break;
2201
2316
  }
@@ -2219,7 +2334,7 @@ class TeleBox {
2219
2334
  if (ev.button != null && ev.button !== 0) {
2220
2335
  return;
2221
2336
  }
2222
- if (!this.draggable || trackingHandle || this.state !== exports.TELE_BOX_STATE.Normal) {
2337
+ if (!this.draggable || trackingHandle || this.state !== TELE_BOX_STATE.Normal) {
2223
2338
  return;
2224
2339
  }
2225
2340
  const target = ev.target;
@@ -2235,7 +2350,9 @@ class TeleBox {
2235
2350
  $trackMask = document.createElement("div");
2236
2351
  }
2237
2352
  const cursor = trackingHandle ? this.wrapClassName(`cursor-${trackingHandle}`) : "";
2238
- $trackMask.className = this.wrapClassName(`track-mask${cursor ? ` ${cursor}` : ""}`);
2353
+ $trackMask.className = this.wrapClassName(
2354
+ `track-mask${cursor ? ` ${cursor}` : ""}`
2355
+ );
2239
2356
  this.$box.appendChild($trackMask);
2240
2357
  this.$box.classList.add(transformingClassName);
2241
2358
  this._sideEffect.add(() => {
@@ -2255,18 +2372,33 @@ class TeleBox {
2255
2372
  window.removeEventListener("touchmove", handleTracking);
2256
2373
  window.removeEventListener("mouseup", handleTrackEnd);
2257
2374
  window.removeEventListener("touchend", handleTrackEnd);
2258
- window.removeEventListener("touchcancel", handleTrackEnd);
2375
+ window.removeEventListener(
2376
+ "touchcancel",
2377
+ handleTrackEnd
2378
+ );
2259
2379
  };
2260
2380
  }, TRACKING_DISPOSER_ID);
2261
2381
  }
2262
2382
  };
2263
2383
  this._handleTrackStart = handleTrackStart;
2264
- this._sideEffect.addEventListener($resizeHandles, "mousedown", handleTrackStart, {}, "box-resizeHandles-mousedown");
2265
- this._sideEffect.addEventListener($resizeHandles, "touchstart", handleTrackStart, { passive: false }, "box-resizeHandles-touchstart");
2384
+ this._sideEffect.addEventListener(
2385
+ $resizeHandles,
2386
+ "mousedown",
2387
+ handleTrackStart,
2388
+ {},
2389
+ "box-resizeHandles-mousedown"
2390
+ );
2391
+ this._sideEffect.addEventListener(
2392
+ $resizeHandles,
2393
+ "touchstart",
2394
+ handleTrackStart,
2395
+ { passive: false },
2396
+ "box-resizeHandles-touchstart"
2397
+ );
2266
2398
  }
2267
2399
  destroy() {
2268
2400
  this.$box.remove();
2269
- this.events.emit(exports.TELE_BOX_EVENT.Destroyed);
2401
+ this.events.emit(TELE_BOX_EVENT.Destroyed);
2270
2402
  this._sideEffect.flushAll();
2271
2403
  this._renderSideEffect.flushAll();
2272
2404
  this.events.removeAllListeners();
@@ -2279,7 +2411,7 @@ class TeleBox {
2279
2411
  function noop() {
2280
2412
  return;
2281
2413
  }
2282
- var style$1 = ".telebox-collector {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n visibility: hidden;\n display: block;\n position: absolute;\n z-index: 200;\n width: 40px;\n height: 40px;\n margin: 0;\n padding: 0;\n border: none;\n outline: none;\n font-size: 0;\n border-radius: 50%;\n background: #fff;\n box-shadow: 0px 2px 6px 0px rgba(47, 65, 146, 0.15);\n cursor: pointer;\n user-select: none;\n pointer-events: none;\n background-repeat: no-repeat;\n background-size: 18px 16px;\n background-position: center;\n -webkit-tap-highlight-color: transparent;\n}\n\n.telebox-collector-visible {\n visibility: visible;\n pointer-events: initial;\n}\n\n.telebox-collector-readonly {\n cursor: not-allowed;\n}\n\n.telebox-color-scheme-dark {\n color-scheme: dark;\n}\n\n.telebox-color-scheme-dark.telebox-collector {\n background-color: #43434d;\n}";
2414
+ var style$2 = "";
2283
2415
  var collectorSVG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K";
2284
2416
  class TeleBoxCollector {
2285
2417
  constructor({
@@ -2288,8 +2420,10 @@ class TeleBoxCollector {
2288
2420
  darkMode = false,
2289
2421
  namespace = "telebox",
2290
2422
  styles = {},
2291
- onClick
2292
- } = {}) {
2423
+ onClick,
2424
+ getBoxesStatus
2425
+ }) {
2426
+ this.$appMenuContainer = document.createElement("div");
2293
2427
  this.handleCollectorClick = () => {
2294
2428
  if (!this._readonly && this.onClick) {
2295
2429
  this.onClick();
@@ -2301,6 +2435,11 @@ class TeleBoxCollector {
2301
2435
  this.namespace = namespace;
2302
2436
  this.styles = styles;
2303
2437
  this.onClick = onClick;
2438
+ this.getBoxesStatus = getBoxesStatus;
2439
+ }
2440
+ get boxesStatus() {
2441
+ var _a;
2442
+ return (_a = this.getBoxesStatus) == null ? void 0 : _a.call(this);
2304
2443
  }
2305
2444
  get visible() {
2306
2445
  return this._visible;
@@ -2321,11 +2460,29 @@ class TeleBoxCollector {
2321
2460
  }
2322
2461
  return this;
2323
2462
  }
2463
+ hasMinimizedBox() {
2464
+ const boxesStatus = this.boxesStatus;
2465
+ if (boxesStatus) {
2466
+ for (const status of boxesStatus.values()) {
2467
+ if (status === TELE_BOX_STATE.Minimized) {
2468
+ return true;
2469
+ }
2470
+ }
2471
+ }
2472
+ return false;
2473
+ }
2474
+ updateBoxesStatus() {
2475
+ const hasMinimizedBox = this.hasMinimizedBox();
2476
+ this.setVisible(hasMinimizedBox);
2477
+ }
2324
2478
  setVisible(visible) {
2325
2479
  if (this._visible !== visible) {
2326
2480
  this._visible = visible;
2327
2481
  if (this.$collector) {
2328
- this.$collector.classList.toggle(this.wrapClassName("collector-visible"), visible);
2482
+ this.$collector.classList.toggle(
2483
+ this.wrapClassName("collector-visible"),
2484
+ visible
2485
+ );
2329
2486
  }
2330
2487
  }
2331
2488
  return this;
@@ -2334,7 +2491,10 @@ class TeleBoxCollector {
2334
2491
  if (this._readonly !== readonly) {
2335
2492
  this._readonly = readonly;
2336
2493
  if (this.$collector) {
2337
- this.$collector.classList.toggle(this.wrapClassName("collector-readonly"), readonly);
2494
+ this.$collector.classList.toggle(
2495
+ this.wrapClassName("collector-readonly"),
2496
+ readonly
2497
+ );
2338
2498
  }
2339
2499
  }
2340
2500
  return this;
@@ -2343,8 +2503,14 @@ class TeleBoxCollector {
2343
2503
  if (this._darkMode !== darkMode) {
2344
2504
  this._darkMode = darkMode;
2345
2505
  if (this.$collector) {
2346
- this.$collector.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
2347
- this.$collector.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
2506
+ this.$collector.classList.toggle(
2507
+ this.wrapClassName("color-scheme-dark"),
2508
+ darkMode
2509
+ );
2510
+ this.$collector.classList.toggle(
2511
+ this.wrapClassName("color-scheme-light"),
2512
+ !darkMode
2513
+ );
2348
2514
  }
2349
2515
  }
2350
2516
  return this;
@@ -2367,21 +2533,37 @@ class TeleBoxCollector {
2367
2533
  this.$collector = document.createElement("button");
2368
2534
  this.$collector.className = this.wrapClassName("collector");
2369
2535
  this.$collector.style.backgroundImage = `url('${collectorSVG}')`;
2370
- this.$collector.addEventListener("click", this.handleCollectorClick);
2536
+ this.$collector.addEventListener(
2537
+ "click",
2538
+ this.handleCollectorClick
2539
+ );
2371
2540
  if (this._visible) {
2372
- this.$collector.classList.add(this.wrapClassName("collector-visible"));
2541
+ this.$collector.classList.add(
2542
+ this.wrapClassName("collector-visible")
2543
+ );
2373
2544
  }
2374
2545
  if (this._readonly) {
2375
- this.$collector.classList.add(this.wrapClassName("collector-readonly"));
2376
- }
2377
- this.$collector.classList.add(this.wrapClassName(this._darkMode ? "color-scheme-dark" : "color-scheme-light"));
2546
+ this.$collector.classList.add(
2547
+ this.wrapClassName("collector-readonly")
2548
+ );
2549
+ }
2550
+ this.$collector.classList.add(
2551
+ this.wrapClassName(
2552
+ this._darkMode ? "color-scheme-dark" : "color-scheme-light"
2553
+ )
2554
+ );
2555
+ this.$appMenuContainer.classList.add(this.wrapClassName("collector-shadow"));
2556
+ this.$collector.append(this.$appMenuContainer);
2378
2557
  this.setStyles(this.styles);
2379
2558
  }
2380
2559
  return this.$collector;
2381
2560
  }
2382
2561
  destroy() {
2383
2562
  if (this.$collector) {
2384
- this.$collector.removeEventListener("click", this.handleCollectorClick);
2563
+ this.$collector.removeEventListener(
2564
+ "click",
2565
+ this.handleCollectorClick
2566
+ );
2385
2567
  this.$collector.remove();
2386
2568
  this.$collector = void 0;
2387
2569
  }
@@ -2391,8 +2573,7 @@ class TeleBoxCollector {
2391
2573
  return `${this.namespace}-${className}`;
2392
2574
  }
2393
2575
  }
2394
- exports.TELE_BOX_MANAGER_EVENT = void 0;
2395
- (function(TELE_BOX_MANAGER_EVENT2) {
2576
+ var TELE_BOX_MANAGER_EVENT = /* @__PURE__ */ ((TELE_BOX_MANAGER_EVENT2) => {
2396
2577
  TELE_BOX_MANAGER_EVENT2["Focused"] = "focused";
2397
2578
  TELE_BOX_MANAGER_EVENT2["Blurred"] = "blurred";
2398
2579
  TELE_BOX_MANAGER_EVENT2["Created"] = "created";
@@ -2410,8 +2591,9 @@ exports.TELE_BOX_MANAGER_EVENT = void 0;
2410
2591
  TELE_BOX_MANAGER_EVENT2["DarkMode"] = "dark_mode";
2411
2592
  TELE_BOX_MANAGER_EVENT2["BoxStatus"] = "box_status";
2412
2593
  TELE_BOX_MANAGER_EVENT2["LastNotMinimizedBoxStatus"] = "last_not_minimized_box_status";
2413
- })(exports.TELE_BOX_MANAGER_EVENT || (exports.TELE_BOX_MANAGER_EVENT = {}));
2414
- var style = ".telebox-max-titlebar {\n user-select: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n display: none;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 50000;\n}\n.telebox-max-titlebar .telebox-title {\n display: none;\n}\n.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-titles {\n display: none;\n}\n.telebox-max-titlebar.telebox-max-titlebar-single-title .telebox-title {\n display: block;\n}\n.telebox-max-titlebar-maximized {\n display: flex;\n}\n.telebox-titles {\n height: 100%;\n margin: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n overflow-x: overlay;\n -webkit-overflow-scrolling: touch;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n scrollbar-width: auto;\n}\n.telebox-titles::-webkit-scrollbar {\n height: 8px;\n width: 8px;\n}\n.telebox-titles::-webkit-scrollbar-track {\n background-color: transparent;\n}\n.telebox-titles::-webkit-scrollbar-thumb {\n background-color: rgba(238, 238, 247, 0.8);\n background-color: transparent;\n border-radius: 4px;\n transition: background-color 0.4s;\n}\n.telebox-titles:hover::-webkit-scrollbar-thumb {\n background-color: rgba(238, 238, 247, 0.8);\n}\n.telebox-titles::-webkit-scrollbar-thumb:hover {\n background-color: #eeeef7;\n}\n.telebox-titles::-webkit-scrollbar-thumb:active {\n background-color: #eeeef7;\n}\n.telebox-titles::-webkit-scrollbar-thumb:vertical {\n min-height: 50px;\n}\n.telebox-titles::-webkit-scrollbar-thumb:horizontal {\n min-width: 50px;\n}\n.telebox-titles-content {\n height: 100%;\n display: flex;\n flex-wrap: nowrap;\n align-items: center;\n padding: 0;\n}\n.telebox-titles-tab {\n height: 100%;\n overflow: hidden;\n max-width: 182px;\n min-width: 50px;\n padding: 0 26px 0 16px;\n outline: none;\n font-size: 13px;\n font-family: PingFangSC-Regular, PingFang SC;\n font-weight: 400;\n text-overflow: ellipsis;\n white-space: nowrap;\n word-break: keep-all;\n border: none;\n border-right: 1px solid #e5e5f0;\n color: #7b88a0;\n background: transparent;\n cursor: pointer;\n user-select: none;\n}\n.telebox-titles-tab-focus {\n color: #357bf6;\n}\n.telebox-readonly .telebox-titles-tab {\n cursor: not-allowed;\n}\n.telebox-color-scheme-dark {\n color-scheme: dark;\n}\n.telebox-color-scheme-dark.telebox-titlebar {\n color: #e9e9e9;\n background: #43434d;\n border-bottom: none;\n}\n.telebox-color-scheme-dark .telebox-titles-tab {\n border-right-color: #7b88a0;\n}\n.telebox-color-scheme-dark .telebox-title {\n color: #e9e9e9;\n}";
2594
+ return TELE_BOX_MANAGER_EVENT2;
2595
+ })(TELE_BOX_MANAGER_EVENT || {});
2596
+ var style$1 = "";
2415
2597
  class MaxTitleBar extends DefaultTitleBar {
2416
2598
  constructor(config) {
2417
2599
  super(config);
@@ -2419,20 +2601,30 @@ class MaxTitleBar extends DefaultTitleBar {
2419
2601
  this.focusedBox = config.focusedBox;
2420
2602
  this.containerRect = config.containerRect;
2421
2603
  this.darkMode = config.darkMode;
2422
- this.boxesStatus = config.boxesStatus;
2604
+ this.getBoxesStatus = config.getBoxesStatus;
2605
+ }
2606
+ get boxesStatus() {
2607
+ var _a;
2608
+ return (_a = this.getBoxesStatus) == null ? void 0 : _a.call(this);
2423
2609
  }
2424
2610
  hasMaximizedBoxInStatus() {
2425
- if (!this.boxesStatus || this.boxesStatus.size === 0) {
2426
- return false;
2611
+ if (this.getBoxesStatus) {
2612
+ const boxesStatus = this.getBoxesStatus();
2613
+ if (boxesStatus.size) {
2614
+ const hasMaximizedBox = [...boxesStatus.values()].find((state) => state === TELE_BOX_STATE.Maximized);
2615
+ return !!hasMaximizedBox;
2616
+ }
2427
2617
  }
2428
- const hasMaximizedBox = [...this.boxesStatus.values()].find((state) => state === exports.TELE_BOX_STATE.Maximized);
2429
- return !!hasMaximizedBox;
2618
+ return false;
2430
2619
  }
2431
2620
  get MaximizedBoxes() {
2432
- if (!this.boxesStatus || this.boxesStatus.size === 0) {
2433
- return [];
2621
+ if (this.getBoxesStatus) {
2622
+ const boxesStatus = this.getBoxesStatus();
2623
+ if (boxesStatus) {
2624
+ return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized);
2625
+ }
2434
2626
  }
2435
- return this.boxes.filter((box) => this.boxesStatus && this.boxesStatus.get(box.id) === exports.TELE_BOX_STATE.Maximized);
2627
+ return [];
2436
2628
  }
2437
2629
  focusBox(box) {
2438
2630
  var _a, _b;
@@ -2441,15 +2633,21 @@ class MaxTitleBar extends DefaultTitleBar {
2441
2633
  }
2442
2634
  if (this.$titles) {
2443
2635
  const { children } = this.$titles.firstElementChild;
2444
- if (this.state === exports.TELE_BOX_STATE.Maximized && !this.hasMaximizedBoxInStatus()) {
2636
+ if (this.state === TELE_BOX_STATE.Maximized && !this.hasMaximizedBoxInStatus()) {
2445
2637
  for (let i2 = children.length - 1; i2 >= 0; i2 -= 1) {
2446
2638
  const $tab = children[i2];
2447
2639
  const id = (_a = $tab.dataset) == null ? void 0 : _a.teleBoxID;
2448
2640
  if (id) {
2449
2641
  if (box && id === box.id) {
2450
- $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), true);
2642
+ $tab.classList.toggle(
2643
+ this.wrapClassName("titles-tab-focus"),
2644
+ true
2645
+ );
2451
2646
  } else if (this.focusedBox && id === this.focusedBox.id) {
2452
- $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), false);
2647
+ $tab.classList.toggle(
2648
+ this.wrapClassName("titles-tab-focus"),
2649
+ false
2650
+ );
2453
2651
  }
2454
2652
  }
2455
2653
  }
@@ -2459,9 +2657,15 @@ class MaxTitleBar extends DefaultTitleBar {
2459
2657
  const id = (_b = $tab.dataset) == null ? void 0 : _b.teleBoxID;
2460
2658
  if (id) {
2461
2659
  if (box && id === box.id) {
2462
- $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), true);
2660
+ $tab.classList.toggle(
2661
+ this.wrapClassName("titles-tab-focus"),
2662
+ true
2663
+ );
2463
2664
  } else if (this.focusedBox && id === this.focusedBox.id) {
2464
- $tab.classList.toggle(this.wrapClassName("titles-tab-focus"), false);
2665
+ $tab.classList.toggle(
2666
+ this.wrapClassName("titles-tab-focus"),
2667
+ false
2668
+ );
2465
2669
  }
2466
2670
  }
2467
2671
  }
@@ -2477,42 +2681,59 @@ class MaxTitleBar extends DefaultTitleBar {
2477
2681
  this.$titleBar.style.width = width + "px";
2478
2682
  }
2479
2683
  }
2480
- setBoxesStatus(boxesStatus) {
2481
- this.boxesStatus = boxesStatus;
2684
+ updateBoxesStatus() {
2482
2685
  if (this.hasMaximizedBoxInStatus()) {
2483
- this.setBoxStatus(exports.TELE_BOX_STATE.Maximized);
2686
+ this.setBoxStatus(TELE_BOX_STATE.Maximized);
2484
2687
  }
2485
2688
  if (this.$titleBar) {
2486
- this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), this.state === exports.TELE_BOX_STATE.Maximized && this.boxes.length > 0 || this.hasMaximizedBoxInStatus());
2689
+ this.$titleBar.classList.toggle(
2690
+ this.wrapClassName("max-titlebar-maximized"),
2691
+ this.state === TELE_BOX_STATE.Maximized && this.boxes.length > 0 || this.hasMaximizedBoxInStatus()
2692
+ );
2487
2693
  }
2488
2694
  this.updateTitles();
2489
2695
  }
2490
2696
  setBoxes(boxes) {
2491
2697
  this.boxes = boxes;
2492
2698
  if (this.$titleBar) {
2493
- this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), this.state === exports.TELE_BOX_STATE.Maximized && boxes.length > 0 || this.hasMaximizedBoxInStatus());
2699
+ this.$titleBar.classList.toggle(
2700
+ this.wrapClassName("max-titlebar-maximized"),
2701
+ this.state === TELE_BOX_STATE.Maximized && boxes.length > 0 || this.hasMaximizedBoxInStatus()
2702
+ );
2494
2703
  }
2495
2704
  this.updateTitles();
2496
2705
  }
2497
2706
  setState(state) {
2498
2707
  super.setState(state);
2499
2708
  if (this.$titleBar) {
2500
- this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), state === exports.TELE_BOX_STATE.Maximized && this.boxes.length > 0 || this.hasMaximizedBoxInStatus());
2709
+ this.$titleBar.classList.toggle(
2710
+ this.wrapClassName("max-titlebar-maximized"),
2711
+ state === TELE_BOX_STATE.Maximized && this.boxes.length > 0 || this.hasMaximizedBoxInStatus()
2712
+ );
2501
2713
  }
2502
2714
  this.updateTitles();
2503
2715
  }
2504
2716
  setReadonly(readonly) {
2505
2717
  super.setReadonly(readonly);
2506
2718
  if (this.$titleBar) {
2507
- this.$titleBar.classList.toggle(this.wrapClassName("readonly"), this.readonly);
2719
+ this.$titleBar.classList.toggle(
2720
+ this.wrapClassName("readonly"),
2721
+ this.readonly
2722
+ );
2508
2723
  }
2509
2724
  }
2510
2725
  setDarkMode(darkMode) {
2511
2726
  if (darkMode !== this.darkMode) {
2512
2727
  this.darkMode = darkMode;
2513
2728
  if (this.$titleBar) {
2514
- this.$titleBar.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
2515
- this.$titleBar.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
2729
+ this.$titleBar.classList.toggle(
2730
+ this.wrapClassName("color-scheme-dark"),
2731
+ darkMode
2732
+ );
2733
+ this.$titleBar.classList.toggle(
2734
+ this.wrapClassName("color-scheme-light"),
2735
+ !darkMode
2736
+ );
2516
2737
  }
2517
2738
  }
2518
2739
  }
@@ -2522,9 +2743,19 @@ class MaxTitleBar extends DefaultTitleBar {
2522
2743
  $titleBar.style.transform = `translate(${x}px, ${y}px)`;
2523
2744
  $titleBar.style.width = width + "px";
2524
2745
  $titleBar.classList.add(this.wrapClassName("max-titlebar"));
2525
- $titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), this.state === exports.TELE_BOX_STATE.Maximized && this.boxes.length > 0);
2526
- $titleBar.classList.toggle(this.wrapClassName("readonly"), this.readonly);
2527
- $titleBar.classList.add(this.wrapClassName(this.darkMode ? "color-scheme-dark" : "color-scheme-light"));
2746
+ $titleBar.classList.toggle(
2747
+ this.wrapClassName("max-titlebar-maximized"),
2748
+ this.state === TELE_BOX_STATE.Maximized && this.boxes.length > 0
2749
+ );
2750
+ $titleBar.classList.toggle(
2751
+ this.wrapClassName("readonly"),
2752
+ this.readonly
2753
+ );
2754
+ $titleBar.classList.add(
2755
+ this.wrapClassName(
2756
+ this.darkMode ? "color-scheme-dark" : "color-scheme-light"
2757
+ )
2758
+ );
2528
2759
  const $titlesArea = document.createElement("div");
2529
2760
  $titlesArea.classList.add(this.wrapClassName("titles-area"));
2530
2761
  $titleBar.insertBefore($titlesArea, $titleBar.firstElementChild);
@@ -2538,24 +2769,34 @@ class MaxTitleBar extends DefaultTitleBar {
2538
2769
  this.focusedBox = void 0;
2539
2770
  }
2540
2771
  updateTitles() {
2541
- if (this.$titleBar && (this.state === exports.TELE_BOX_STATE.Maximized || this.hasMaximizedBoxInStatus())) {
2542
- this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-single-title"), this.boxes.length === 1 || this.hasMaximizedBoxInStatus() && this.MaximizedBoxes.length === 1);
2772
+ if (this.$titleBar && (this.state === TELE_BOX_STATE.Maximized || this.hasMaximizedBoxInStatus())) {
2773
+ this.$titleBar.classList.toggle(
2774
+ this.wrapClassName("max-titlebar-single-title"),
2775
+ this.boxes.length === 1 || this.hasMaximizedBoxInStatus() && this.MaximizedBoxes.length === 1
2776
+ );
2543
2777
  if (this.boxes.length === 1 || this.hasMaximizedBoxInStatus() && this.MaximizedBoxes.length === 1) {
2544
2778
  this.setTitle(this.boxes[0].title);
2545
2779
  } else {
2546
- this.$titleBar.replaceChild(this.renderTitles(), this.$titleBar.firstElementChild);
2780
+ this.$titleBar.replaceChild(
2781
+ this.renderTitles(),
2782
+ this.$titleBar.firstElementChild
2783
+ );
2547
2784
  }
2548
2785
  }
2549
2786
  }
2550
2787
  renderTitles() {
2551
2788
  this.$titles = document.createElement("div");
2552
2789
  this.$titles.className = this.wrapClassName("titles");
2553
- this.$titles.addEventListener("wheel", (ev) => {
2554
- ev.currentTarget.scrollBy({
2555
- left: ev.deltaY > 0 ? 250 : -250,
2556
- behavior: "smooth"
2557
- });
2558
- }, { passive: false });
2790
+ this.$titles.addEventListener(
2791
+ "wheel",
2792
+ (ev) => {
2793
+ ev.currentTarget.scrollBy({
2794
+ left: ev.deltaY > 0 ? 250 : -250,
2795
+ behavior: "smooth"
2796
+ });
2797
+ },
2798
+ { passive: false }
2799
+ );
2559
2800
  const $content = document.createElement("div");
2560
2801
  $content.className = this.wrapClassName("titles-content");
2561
2802
  this.$titles.appendChild($content);
@@ -2573,10 +2814,130 @@ class MaxTitleBar extends DefaultTitleBar {
2573
2814
  return this.$titles;
2574
2815
  }
2575
2816
  }
2817
+ var style = "";
2818
+ class AppMenu {
2819
+ constructor(props) {
2820
+ this.namespace = "telebox-app-menu";
2821
+ this.badge = document.createElement("div");
2822
+ this.menuView = document.createElement("div");
2823
+ this.containerClickHandler = () => {
2824
+ if (this.manager.readonly) {
2825
+ return;
2826
+ }
2827
+ const isShowMenuView = getComputedStyle(this.menuView).display === "flex";
2828
+ if (isShowMenuView) {
2829
+ this.menuView.style.display = "none";
2830
+ } else {
2831
+ this.menuView.style.display = "flex";
2832
+ }
2833
+ };
2834
+ this.menuViewClickHandler = (e2) => {
2835
+ e2.stopPropagation();
2836
+ e2.stopImmediatePropagation();
2837
+ const target = e2.target;
2838
+ const id = target.getAttribute(`data-${this.c("app-id")}`);
2839
+ if (id) {
2840
+ const lastNotMinimizedBoxStatus = this.manager.getLastNotMinimizedBoxStatus(id) || TELE_BOX_STATE.Normal;
2841
+ const zIndex = (lastNotMinimizedBoxStatus === TELE_BOX_STATE.Maximized ? this.manager.getMaxMaximizedBoxZIndex() : this.manager.getMaxNormalBoxZIndex()) + 1;
2842
+ this.manager.setBox(id, {
2843
+ status: lastNotMinimizedBoxStatus,
2844
+ zIndex
2845
+ }, false, () => {
2846
+ this.manager.focusBox(id);
2847
+ });
2848
+ return;
2849
+ }
2850
+ };
2851
+ this.updatePrefersColorSchemeHandler = () => {
2852
+ this.container.classList.remove(this.theme);
2853
+ this.theme = this.manager.prefersColorScheme;
2854
+ this.container.classList.add(this.theme);
2855
+ };
2856
+ this.appMenuChange = () => {
2857
+ const minimizedBoxesStatus = this.manager.getMinimizedBoxesStatus();
2858
+ this.render(minimizedBoxesStatus);
2859
+ };
2860
+ this.container = props.container;
2861
+ this.manager = props.manager;
2862
+ this.theme = props.theme;
2863
+ this.getBoxesStatus = props.getBoxesStatus;
2864
+ this.init();
2865
+ }
2866
+ get boxesStatus() {
2867
+ var _a;
2868
+ return ((_a = this.getBoxesStatus) == null ? void 0 : _a.call(this)) || /* @__PURE__ */ new Map();
2869
+ }
2870
+ get minimizedBoxesStatus() {
2871
+ const arr = [];
2872
+ this.boxesStatus.forEach((status) => {
2873
+ if (status === TELE_BOX_STATE.Minimized) {
2874
+ arr.push(status);
2875
+ }
2876
+ });
2877
+ return arr;
2878
+ }
2879
+ c(className) {
2880
+ return `${this.namespace}-${className}`;
2881
+ }
2882
+ setContainer(container) {
2883
+ if (this.container) {
2884
+ this.container.remove();
2885
+ }
2886
+ this.container = container;
2887
+ this.init();
2888
+ }
2889
+ createDefaultAppMenu() {
2890
+ this.badge.classList.add(this.c("app-menu-badge"));
2891
+ this.menuView.classList.add(this.c("app-menu-tooltip"));
2892
+ this.container.classList.add(this.c("app-menu-container"), this.theme);
2893
+ this.menuView.addEventListener("click", this.menuViewClickHandler);
2894
+ this.container.append(this.badge, this.menuView);
2895
+ }
2896
+ async init() {
2897
+ this.createDefaultAppMenu();
2898
+ this.appMenuChange();
2899
+ }
2900
+ createMinimizedItem(appId) {
2901
+ const appItem = document.createElement("div");
2902
+ appItem.classList.add(this.c("app-menu-item"));
2903
+ appItem.setAttribute(`data-${this.c("app-id")}`, appId);
2904
+ const titleDiv = document.createElement("div");
2905
+ titleDiv.classList.add(this.c("app-menu-item-title"));
2906
+ const app = this.manager.getBox(appId);
2907
+ titleDiv.innerText = (app == null ? void 0 : app.title) || appId;
2908
+ appItem.appendChild(titleDiv);
2909
+ return appItem;
2910
+ }
2911
+ renderMenuView(minimizedBoxesStatus) {
2912
+ const items = [];
2913
+ minimizedBoxesStatus.forEach((_, appId) => {
2914
+ items.push(this.createMinimizedItem(appId));
2915
+ });
2916
+ this.menuView.append(...items);
2917
+ }
2918
+ render(minimizedBoxesStatus) {
2919
+ this.menuView.style.display = "none";
2920
+ this.badge.innerText = "";
2921
+ this.menuView.innerHTML = "";
2922
+ if (minimizedBoxesStatus.size === 0) {
2923
+ this.container.style.display = "none";
2924
+ } else {
2925
+ this.badge.innerText = minimizedBoxesStatus.size.toString();
2926
+ this.renderMenuView(minimizedBoxesStatus);
2927
+ this.container.style.display = "block";
2928
+ }
2929
+ }
2930
+ destroy() {
2931
+ this.badge.remove();
2932
+ this.menuView.removeEventListener("click", this.menuViewClickHandler);
2933
+ this.menuView.remove();
2934
+ this.container.remove();
2935
+ }
2936
+ }
2576
2937
  class TeleBoxManager {
2577
2938
  constructor({
2578
2939
  root = document.body,
2579
- prefersColorScheme = exports.TELE_BOX_COLOR_SCHEME.Light,
2940
+ prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
2580
2941
  minimized = false,
2581
2942
  maximized = false,
2582
2943
  fence = true,
@@ -2588,28 +2949,35 @@ class TeleBoxManager {
2588
2949
  },
2589
2950
  collector,
2590
2951
  namespace = "telebox",
2591
- readonly = false
2952
+ readonly = false,
2953
+ useBoxesStatus = false
2592
2954
  } = {}) {
2593
2955
  this.events = new EventEmitter();
2594
2956
  this._sideEffect = new o();
2957
+ this.useBoxesStatus = useBoxesStatus;
2595
2958
  const { combine, createVal } = c(this._sideEffect);
2596
2959
  this.root = root;
2597
2960
  this.namespace = namespace;
2598
2961
  this.boxes$ = createVal([]);
2599
2962
  this.topBox$ = this.boxes$.derive((boxes) => {
2600
2963
  if (boxes.length > 0) {
2964
+ let currentTopBox = void 0;
2601
2965
  const topBox = boxes.reduce((topBox2, box) => {
2602
- if (box.boxStatus && box.boxStatus === exports.TELE_BOX_STATE.Minimized) {
2966
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
2967
+ return topBox2;
2968
+ }
2969
+ if (!topBox2) {
2970
+ topBox2 = box;
2603
2971
  return topBox2;
2604
2972
  }
2605
2973
  return topBox2.zIndex > box.zIndex ? topBox2 : box;
2606
- });
2974
+ }, currentTopBox);
2607
2975
  return topBox;
2608
2976
  }
2609
2977
  return;
2610
2978
  });
2611
- this.boxesStatus$ = new Map();
2612
- this.lastNotMinimizedBoxesStatus$ = new Map();
2979
+ this.boxesStatus$ = /* @__PURE__ */ new Map();
2980
+ this.lastNotMinimizedBoxesStatus$ = /* @__PURE__ */ new Map();
2613
2981
  const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
2614
2982
  const prefersDark$ = createVal(false);
2615
2983
  if (prefersDark) {
@@ -2624,16 +2992,24 @@ class TeleBoxManager {
2624
2992
  }
2625
2993
  const prefersColorScheme$ = createVal(prefersColorScheme);
2626
2994
  prefersColorScheme$.reaction((prefersColorScheme2, _, skipUpdate) => {
2627
- this.boxes.forEach((box) => box.setPrefersColorScheme(prefersColorScheme2, skipUpdate));
2995
+ this.boxes.forEach(
2996
+ (box) => box.setPrefersColorScheme(prefersColorScheme2, skipUpdate)
2997
+ );
2628
2998
  if (!skipUpdate) {
2629
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.PrefersColorScheme, prefersColorScheme2);
2999
+ this.events.emit(
3000
+ TELE_BOX_MANAGER_EVENT.PrefersColorScheme,
3001
+ prefersColorScheme2
3002
+ );
2630
3003
  }
2631
3004
  });
2632
- this._darkMode$ = combine([prefersDark$, prefersColorScheme$], ([prefersDark2, prefersColorScheme2]) => prefersColorScheme2 === "auto" ? prefersDark2 : prefersColorScheme2 === "dark");
3005
+ this._darkMode$ = combine(
3006
+ [prefersDark$, prefersColorScheme$],
3007
+ ([prefersDark2, prefersColorScheme2]) => prefersColorScheme2 === "auto" ? prefersDark2 : prefersColorScheme2 === "dark"
3008
+ );
2633
3009
  this._darkMode$.reaction((darkMode, _, skipUpdate) => {
2634
3010
  this.boxes.forEach((box) => box.setDarkMode(darkMode, skipUpdate));
2635
3011
  if (!skipUpdate) {
2636
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.DarkMode, darkMode);
3012
+ this.events.emit(TELE_BOX_MANAGER_EVENT.DarkMode, darkMode);
2637
3013
  }
2638
3014
  });
2639
3015
  const readonly$ = createVal(readonly);
@@ -2643,16 +3019,21 @@ class TeleBoxManager {
2643
3019
  const minimized$ = createVal(minimized);
2644
3020
  const maximized$ = createVal(maximized);
2645
3021
  maximized$.reaction((maximized2, _, skipUpdate) => {
2646
- this.boxes.forEach((box) => box.setMaximized(maximized2, skipUpdate));
3022
+ this.boxes.forEach(
3023
+ (box) => box.setMaximized(maximized2, skipUpdate)
3024
+ );
2647
3025
  if (!skipUpdate) {
2648
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Maximized, maximized2);
3026
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Maximized, maximized2);
2649
3027
  }
2650
3028
  });
2651
- const state$ = combine([minimized$, maximized$], ([minimized2, maximized2]) => minimized2 ? exports.TELE_BOX_STATE.Minimized : maximized2 ? exports.TELE_BOX_STATE.Maximized : exports.TELE_BOX_STATE.Normal);
3029
+ const state$ = combine(
3030
+ [minimized$, maximized$],
3031
+ ([minimized2, maximized2]) => minimized2 ? TELE_BOX_STATE.Minimized : maximized2 ? TELE_BOX_STATE.Maximized : TELE_BOX_STATE.Normal
3032
+ );
2652
3033
  state$.reaction((state, _, skipUpdate) => {
2653
3034
  this.maxTitleBar.setState(state);
2654
3035
  if (!skipUpdate) {
2655
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.State, state);
3036
+ this.events.emit(TELE_BOX_MANAGER_EVENT.State, state);
2656
3037
  }
2657
3038
  });
2658
3039
  const fence$ = createVal(fence);
@@ -2661,43 +3042,49 @@ class TeleBoxManager {
2661
3042
  });
2662
3043
  const containerRect$ = createVal(containerRect, shallowequal);
2663
3044
  containerRect$.reaction((containerRect2, _, skipUpdate) => {
2664
- this.boxes.forEach((box) => box.setContainerRect(containerRect2, skipUpdate));
3045
+ this.boxes.forEach(
3046
+ (box) => box.setContainerRect(containerRect2, skipUpdate)
3047
+ );
2665
3048
  this.maxTitleBar.setContainerRect(containerRect2);
2666
3049
  });
2667
- const collector$ = createVal(collector === null ? null : collector || new TeleBoxCollector({
2668
- visible: minimized,
2669
- readonly,
2670
- namespace
2671
- }).mount(root));
3050
+ const collector$ = createVal(
3051
+ collector === null ? null : collector || new TeleBoxCollector({
3052
+ visible: minimized,
3053
+ readonly,
3054
+ namespace
3055
+ }).mount(root)
3056
+ );
2672
3057
  collector$.subscribe((collector2) => {
2673
3058
  if (collector2) {
2674
3059
  collector2.setVisible(minimized$.value);
2675
3060
  collector2.setReadonly(readonly$.value);
2676
3061
  collector2.setDarkMode(this._darkMode$.value);
3062
+ if (this.useBoxesStatus && this.appMenu) {
3063
+ this.appMenu.setContainer(collector2.$appMenuContainer);
3064
+ }
2677
3065
  this._sideEffect.add(() => {
3066
+ collector2.getBoxesStatus = () => {
3067
+ return this.boxesStatus$;
3068
+ };
2678
3069
  collector2.onClick = () => {
2679
3070
  if (!readonly$.value) {
2680
- if (this.hasMinimizedBox()) {
2681
- this.getAllMinimizedBoxes().forEach((box) => {
2682
- const lastNotMinimizedBoxStatus = box.lastNotMinimizedBoxStatus;
2683
- if (lastNotMinimizedBoxStatus) {
2684
- this.setBoxStatus(box.id, lastNotMinimizedBoxStatus);
2685
- } else {
2686
- this.setBoxStatus(box.id, exports.TELE_BOX_STATE.Normal);
2687
- }
2688
- });
3071
+ if (!this.useBoxesStatus) {
3072
+ minimized$.setValue(false);
3073
+ } else if (this.useBoxesStatus && this.appMenu) {
3074
+ this.appMenu.containerClickHandler();
2689
3075
  }
2690
- minimized$.setValue(false);
2691
3076
  }
2692
3077
  };
2693
3078
  return () => collector2.destroy();
2694
3079
  }, "collect-onClick");
2695
3080
  }
2696
3081
  });
2697
- readonly$.subscribe((readonly2) => {
2698
- var _a;
2699
- return (_a = collector$.value) == null ? void 0 : _a.setReadonly(readonly2);
2700
- });
3082
+ readonly$.subscribe(
3083
+ (readonly2) => {
3084
+ var _a;
3085
+ return (_a = collector$.value) == null ? void 0 : _a.setReadonly(readonly2);
3086
+ }
3087
+ );
2701
3088
  this._darkMode$.subscribe((darkMode) => {
2702
3089
  var _a;
2703
3090
  (_a = collector$.value) == null ? void 0 : _a.setDarkMode(darkMode);
@@ -2716,23 +3103,31 @@ class TeleBoxManager {
2716
3103
  }
2717
3104
  return;
2718
3105
  };
2719
- const collectorRect$ = createVal(minimized$.value ? this._calcCollectorRect() : void 0);
3106
+ this._setCollectorRect = (collectorRect) => {
3107
+ var _a;
3108
+ if ((_a = collector$.value) == null ? void 0 : _a.$collector) {
3109
+ collectorRect$.setValue(collectorRect);
3110
+ }
3111
+ };
3112
+ const collectorRect$ = createVal(
3113
+ minimized$.value ? this._calcCollectorRect() : void 0
3114
+ );
2720
3115
  collectorRect$.subscribe((collectorRect, _, skipUpdate) => {
2721
3116
  this.boxes.forEach((box) => {
2722
3117
  box.setCollectorRect(collectorRect, skipUpdate);
2723
3118
  });
2724
3119
  });
2725
3120
  minimized$.subscribe((minimized2, _, skipUpdate) => {
2726
- var _a, _b;
3121
+ var _a;
2727
3122
  (_a = collector$.value) == null ? void 0 : _a.setVisible(minimized2);
2728
3123
  if (minimized2) {
2729
- if ((_b = collector$.value) == null ? void 0 : _b.$collector) {
2730
- collectorRect$.setValue(this._calcCollectorRect());
2731
- }
3124
+ this._setCollectorRect(this._calcCollectorRect());
2732
3125
  }
2733
- this.boxes.forEach((box) => box.setMinimized(minimized2, skipUpdate));
3126
+ this.boxes.forEach(
3127
+ (box) => box.setMinimized(minimized2, skipUpdate)
3128
+ );
2734
3129
  if (!skipUpdate) {
2735
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Minimized, minimized2);
3130
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Minimized, minimized2);
2736
3131
  }
2737
3132
  });
2738
3133
  const closeBtnClassName = this.wrapClassName("titlebar-icon-close");
@@ -2753,17 +3148,44 @@ class TeleBoxManager {
2753
3148
  if (id) {
2754
3149
  const box = this.getBox(id);
2755
3150
  if (box) {
2756
- this.focusBox(box);
2757
- if (box.boxStatus && box.boxStatus !== exports.TELE_BOX_STATE.Maximized || !box.boxStatus) {
3151
+ if (!this.useBoxesStatus) {
2758
3152
  this.makeBoxTop(box);
3153
+ } else {
3154
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3155
+ const maxNormalBoxZIndex = this.getMaxNormalBoxZIndex();
3156
+ if (maxNormalBoxZIndex > box.zIndex) {
3157
+ this.setBox(box, {
3158
+ zIndex: maxNormalBoxZIndex + 1
3159
+ }, false);
3160
+ }
3161
+ } else if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3162
+ const maxMaximizedBoxZIndex = this.getMaxMaximizedBoxZIndex();
3163
+ if (maxMaximizedBoxZIndex > box.zIndex) {
3164
+ this.setBox(box, {
3165
+ zIndex: maxMaximizedBoxZIndex + 1
3166
+ }, false);
3167
+ }
3168
+ this.makeMaximizedTopBoxFocus();
3169
+ }
2759
3170
  }
3171
+ this.focusBox(box);
2760
3172
  return;
2761
3173
  }
2762
3174
  }
2763
3175
  }
2764
3176
  };
2765
- this._sideEffect.addEventListener(window, "mousedown", checkFocusBox, true);
2766
- this._sideEffect.addEventListener(window, "touchstart", checkFocusBox, true);
3177
+ this._sideEffect.addEventListener(
3178
+ window,
3179
+ "mousedown",
3180
+ checkFocusBox,
3181
+ true
3182
+ );
3183
+ this._sideEffect.addEventListener(
3184
+ window,
3185
+ "touchstart",
3186
+ checkFocusBox,
3187
+ true
3188
+ );
2767
3189
  this.maxTitleBar = new MaxTitleBar({
2768
3190
  darkMode: this.darkMode,
2769
3191
  readonly: readonly$.value,
@@ -2771,32 +3193,85 @@ class TeleBoxManager {
2771
3193
  state: state$.value,
2772
3194
  boxes: this.boxes$.value,
2773
3195
  containerRect: containerRect$.value,
2774
- boxesStatus: this.boxesStatus$,
3196
+ getBoxesStatus: () => {
3197
+ return this.boxesStatus$;
3198
+ },
2775
3199
  onEvent: (event) => {
2776
- var _a, _b, _c;
2777
3200
  switch (event.type) {
2778
- case exports.TELE_BOX_DELEGATE_EVENT.Maximize: {
2779
- if (this.hasBoxesStatus() && ((_a = this.maxTitleBar.focusedBox) == null ? void 0 : _a.id)) {
2780
- this.setBoxStatus(this.maxTitleBar.focusedBox.id, exports.TELE_BOX_STATE.Normal);
2781
- this.makeMaximizedTopBoxFocus();
3201
+ case TELE_BOX_DELEGATE_EVENT.Maximize: {
3202
+ if (this.hasBoxesStatus()) {
3203
+ let targetBox = this.maxTitleBar.focusedBox;
3204
+ if (!targetBox) {
3205
+ targetBox = this.getMaximizedTopBox();
3206
+ }
3207
+ if (targetBox == null ? void 0 : targetBox.id) {
3208
+ const box = this.getBox(targetBox.id);
3209
+ if (box) {
3210
+ this.setBox(box, {
3211
+ status: TELE_BOX_STATE.Normal,
3212
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3213
+ }, false, () => {
3214
+ this.makeMaximizedTopBoxFocus();
3215
+ });
3216
+ }
3217
+ }
2782
3218
  } else {
2783
3219
  maximized$.setValue(!maximized$.value);
2784
3220
  }
2785
3221
  break;
2786
3222
  }
2787
- case exports.TELE_BOX_DELEGATE_EVENT.Minimize: {
2788
- if (this.hasBoxesStatus() && ((_b = this.maxTitleBar.focusedBox) == null ? void 0 : _b.id)) {
2789
- this.setBoxStatus(this.maxTitleBar.focusedBox.id, exports.TELE_BOX_STATE.Minimized);
2790
- this.makeMaximizedTopBoxFocus();
3223
+ case TELE_BOX_DELEGATE_EVENT.Minimize: {
3224
+ if (this.hasBoxesStatus()) {
3225
+ let targetBox = this.maxTitleBar.focusedBox;
3226
+ if (!targetBox) {
3227
+ targetBox = this.getMaximizedTopBox();
3228
+ }
3229
+ if (targetBox == null ? void 0 : targetBox.id) {
3230
+ const box = this.getBox(targetBox.id);
3231
+ if (box) {
3232
+ let isFocusChanged = false;
3233
+ if (box.focus) {
3234
+ this.blurBox(box);
3235
+ isFocusChanged = true;
3236
+ }
3237
+ this.setBox(box, {
3238
+ status: TELE_BOX_STATE.Minimized,
3239
+ zIndex: -1
3240
+ }, false);
3241
+ if (isFocusChanged) {
3242
+ this.focusTopBox();
3243
+ } else {
3244
+ this.makeMaximizedTopBoxFocus();
3245
+ }
3246
+ }
3247
+ }
2791
3248
  } else {
2792
3249
  minimized$.setValue(true);
2793
3250
  }
2794
3251
  break;
2795
3252
  }
2796
- case exports.TELE_BOX_EVENT.Close: {
2797
- if (this.hasBoxesStatus() && ((_c = this.maxTitleBar.focusedBox) == null ? void 0 : _c.id)) {
2798
- this.remove(this.maxTitleBar.focusedBox.id);
2799
- this.makeMaximizedTopBoxFocus();
3253
+ case TELE_BOX_EVENT.Close: {
3254
+ if (this.hasBoxesStatus()) {
3255
+ let targetBox = this.maxTitleBar.focusedBox;
3256
+ if (!targetBox) {
3257
+ targetBox = this.getMaximizedTopBox();
3258
+ }
3259
+ if (targetBox == null ? void 0 : targetBox.id) {
3260
+ const box = this.getBox(targetBox.id);
3261
+ if (box) {
3262
+ let isFocusChanged = false;
3263
+ if (box.focus) {
3264
+ this.blurBox(box);
3265
+ isFocusChanged = true;
3266
+ }
3267
+ this.remove(box, false);
3268
+ if (isFocusChanged) {
3269
+ this.focusTopBox();
3270
+ } else {
3271
+ this.makeMaximizedTopBoxFocus();
3272
+ }
3273
+ }
3274
+ }
2800
3275
  } else {
2801
3276
  this.removeTopBox();
2802
3277
  this.focusTopBox();
@@ -2806,7 +3281,9 @@ class TeleBoxManager {
2806
3281
  }
2807
3282
  }
2808
3283
  });
2809
- readonly$.subscribe((readonly2) => this.maxTitleBar.setReadonly(readonly2));
3284
+ readonly$.subscribe(
3285
+ (readonly2) => this.maxTitleBar.setReadonly(readonly2)
3286
+ );
2810
3287
  this._darkMode$.subscribe((darkMode) => {
2811
3288
  this.maxTitleBar.setDarkMode(darkMode);
2812
3289
  });
@@ -2826,6 +3303,9 @@ class TeleBoxManager {
2826
3303
  i(this, valConfig);
2827
3304
  this._state$ = state$;
2828
3305
  this.root.appendChild(this.maxTitleBar.render());
3306
+ if (useBoxesStatus) {
3307
+ this.appMenu = this.createMinimizedAppMenu();
3308
+ }
2829
3309
  }
2830
3310
  get boxes() {
2831
3311
  return this.boxes$.value;
@@ -2841,12 +3321,12 @@ class TeleBoxManager {
2841
3321
  }
2842
3322
  setState(state, skipUpdate = false) {
2843
3323
  switch (state) {
2844
- case exports.TELE_BOX_STATE.Maximized: {
3324
+ case TELE_BOX_STATE.Maximized: {
2845
3325
  this.setMinimized(false, skipUpdate);
2846
3326
  this.setMaximized(true, skipUpdate);
2847
3327
  break;
2848
3328
  }
2849
- case exports.TELE_BOX_STATE.Minimized: {
3329
+ case TELE_BOX_STATE.Minimized: {
2850
3330
  this.setMinimized(true, skipUpdate);
2851
3331
  this.setMaximized(false, skipUpdate);
2852
3332
  break;
@@ -2860,92 +3340,270 @@ class TeleBoxManager {
2860
3340
  return this;
2861
3341
  }
2862
3342
  setBoxStatus(boxId, boxStatus, skipUpdate = false) {
2863
- const boxesStatus = this.boxesStatus$;
2864
3343
  if (boxStatus) {
2865
- const oldBoxStatus = boxesStatus.get(boxId);
2866
- boxesStatus.set(boxId, boxStatus);
2867
- if (boxStatus === exports.TELE_BOX_STATE.Minimized && oldBoxStatus !== exports.TELE_BOX_STATE.Minimized) {
3344
+ const oldBoxStatus = this.boxesStatus$.get(boxId);
3345
+ this.boxesStatus$.set(boxId, boxStatus);
3346
+ if (boxStatus === TELE_BOX_STATE.Minimized && oldBoxStatus !== TELE_BOX_STATE.Minimized) {
2868
3347
  this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
2869
- } else if (oldBoxStatus === exports.TELE_BOX_STATE.Minimized && boxStatus !== exports.TELE_BOX_STATE.Minimized) {
3348
+ } else if (oldBoxStatus === TELE_BOX_STATE.Minimized && boxStatus !== TELE_BOX_STATE.Minimized) {
2870
3349
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
2871
3350
  }
2872
3351
  } else {
2873
- boxesStatus.delete(boxId);
3352
+ this.boxesStatus$.delete(boxId);
2874
3353
  this.setLastNotMinimizedBoxStatus(boxId, void 0, skipUpdate);
2875
3354
  }
2876
- this.setBoxesStatus(boxesStatus, skipUpdate);
2877
3355
  if (!skipUpdate) {
2878
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus });
3356
+ this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus });
2879
3357
  }
2880
3358
  }
3359
+ getBoxStatus(boxId) {
3360
+ return this.boxesStatus$.get(boxId);
3361
+ }
3362
+ get boxesStatus() {
3363
+ return this.boxesStatus$;
3364
+ }
3365
+ get lastNotMinimizedBoxesStatus() {
3366
+ return this.lastNotMinimizedBoxesStatus$;
3367
+ }
2881
3368
  setBoxesStatus(boxesStatus, skipUpdate = false) {
2882
- var _a, _b, _c, _d;
2883
- let topBox;
2884
- const topBoxId = (_a = this.topBox) == null ? void 0 : _a.id;
2885
- let hasMinimizedBox = false;
3369
+ this.boxesStatus$ = boxesStatus;
3370
+ this.effectBoxesStatusChange(skipUpdate);
3371
+ }
3372
+ getBoxesStatus() {
3373
+ return this.boxesStatus$;
3374
+ }
3375
+ effectBoxStatusChange() {
3376
+ if (!this.useBoxesStatus) {
3377
+ return;
3378
+ }
3379
+ if (this.collector) {
3380
+ this.collector.updateBoxesStatus();
3381
+ if (this.hasMinimizedBox()) {
3382
+ this._setCollectorRect(this._calcCollectorRect());
3383
+ }
3384
+ }
3385
+ if (this.appMenu) {
3386
+ this.appMenu.appMenuChange();
3387
+ }
3388
+ if (this.maxTitleBar) {
3389
+ this.maxTitleBar.updateBoxesStatus();
3390
+ }
3391
+ }
3392
+ effectBoxesStatusTimerFunc(skipUpdate) {
3393
+ if (!this.useBoxesStatus) {
3394
+ return;
3395
+ }
3396
+ let newTopBox;
3397
+ const curTopBox = this.topBox;
2886
3398
  this.boxes.forEach((box) => {
2887
- var _a2;
2888
- const boxStatus = boxesStatus.get(box.id);
3399
+ var _a;
3400
+ const boxStatus = this.boxesStatus$.get(box.id);
2889
3401
  if (boxStatus) {
2890
- if (boxStatus !== exports.TELE_BOX_STATE.Minimized && box.zIndex > ((_a2 = topBox == null ? void 0 : topBox.zIndex) != null ? _a2 : 0)) {
2891
- topBox = box;
3402
+ if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > ((_a = newTopBox == null ? void 0 : newTopBox.zIndex) != null ? _a : 0)) {
3403
+ newTopBox = box;
2892
3404
  }
2893
3405
  box.setBoxStatus(boxStatus, skipUpdate);
2894
- if (boxStatus === exports.TELE_BOX_STATE.Minimized) {
2895
- hasMinimizedBox = true;
2896
- }
2897
3406
  }
2898
3407
  });
2899
- if (hasMinimizedBox) {
2900
- (_b = this.collector) == null ? void 0 : _b.setVisible(true);
2901
- if ((_c = this.collector) == null ? void 0 : _c.$collector) {
2902
- this.setCollectorRect(this._calcCollectorRect());
3408
+ this.effectBoxStatusChange();
3409
+ if (newTopBox && curTopBox !== newTopBox) {
3410
+ this.topBox$.setValue(newTopBox);
3411
+ }
3412
+ if (!newTopBox && curTopBox) {
3413
+ this.topBox$.setValue(void 0);
3414
+ }
3415
+ }
3416
+ async effectBoxesStatusChange(skipUpdate = false) {
3417
+ var _a, _b;
3418
+ if (!this.useBoxesStatus) {
3419
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
3420
+ clearTimeout(this.effectBoxesStatusTimer.timer);
3421
+ if (this.effectBoxesStatusTimer.resolve) {
3422
+ this.effectBoxesStatusTimer.resolve(!!((_a = this.effectBoxesStatusTimer) == null ? void 0 : _a.skipUpdate));
3423
+ }
2903
3424
  }
2904
- } else {
2905
- (_d = this.collector) == null ? void 0 : _d.setVisible(false);
3425
+ this.effectBoxesStatusTimer = void 0;
3426
+ return;
2906
3427
  }
2907
- if (topBox && topBoxId !== topBox.id) {
2908
- this.makeBoxTop(topBox, skipUpdate);
2909
- this.focusTopBox();
2910
- this.topBox$.setValue(topBox);
3428
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
3429
+ if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
3430
+ clearTimeout(this.effectBoxesStatusTimer.timer);
3431
+ if (this.effectBoxesStatusTimer.resolve) {
3432
+ this.effectBoxesStatusTimer.resolve(!!((_b = this.effectBoxesStatusTimer) == null ? void 0 : _b.skipUpdate));
3433
+ }
3434
+ this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
3435
+ } else {
3436
+ return;
3437
+ }
2911
3438
  }
2912
- if (this.maxTitleBar) {
2913
- this.maxTitleBar.setBoxesStatus(boxesStatus);
3439
+ if (!this.effectBoxesStatusTimer) {
3440
+ this.effectBoxesStatusTimer = {
3441
+ skipUpdate,
3442
+ timer: void 0,
3443
+ resolve: void 0
3444
+ };
3445
+ }
3446
+ if (this.effectBoxesStatusTimer) {
3447
+ const _skipUpdate = await new Promise((resolve) => {
3448
+ this.effectBoxesStatusTimer.resolve = resolve;
3449
+ this.effectBoxesStatusTimer.timer = setTimeout(() => {
3450
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
3451
+ this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate);
3452
+ }
3453
+ }, 100);
3454
+ });
3455
+ this.effectBoxesStatusTimerFunc(_skipUpdate);
3456
+ this.effectBoxesStatusTimer = void 0;
2914
3457
  }
2915
3458
  }
2916
3459
  hasBoxesStatus() {
3460
+ if (!this.useBoxesStatus) {
3461
+ return false;
3462
+ }
2917
3463
  return this.boxesStatus$.size > 0;
2918
3464
  }
2919
3465
  hasMinimizedBox() {
2920
- return this.boxes.some((box) => box.boxStatus && box.boxStatus === exports.TELE_BOX_STATE.Minimized);
3466
+ if (!this.useBoxesStatus) {
3467
+ return false;
3468
+ }
3469
+ return this.boxes.some((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
3470
+ }
3471
+ getMinimizedBoxesStatus() {
3472
+ const minimizedBoxes = /* @__PURE__ */ new Map();
3473
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
3474
+ if (boxStatus === TELE_BOX_STATE.Minimized) {
3475
+ minimizedBoxes.set(boxId, boxStatus);
3476
+ }
3477
+ });
3478
+ return minimizedBoxes;
3479
+ }
3480
+ getNotMinimizedBoxesStatus() {
3481
+ const notMinimizedBoxes = /* @__PURE__ */ new Map();
3482
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
3483
+ if (boxStatus !== TELE_BOX_STATE.Minimized) {
3484
+ notMinimizedBoxes.set(boxId, boxStatus);
3485
+ }
3486
+ });
3487
+ return notMinimizedBoxes;
3488
+ }
3489
+ getAllMaximizedBoxesStatus() {
3490
+ const maximizedBoxes = /* @__PURE__ */ new Map();
3491
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
3492
+ if (boxStatus === TELE_BOX_STATE.Maximized) {
3493
+ maximizedBoxes.set(boxId, boxStatus);
3494
+ }
3495
+ });
3496
+ return maximizedBoxes;
3497
+ }
3498
+ getAllNormalBoxesStatus() {
3499
+ const normalBoxes = /* @__PURE__ */ new Map();
3500
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
3501
+ if (boxStatus === TELE_BOX_STATE.Normal) {
3502
+ normalBoxes.set(boxId, boxStatus);
3503
+ }
3504
+ });
3505
+ return normalBoxes;
3506
+ }
3507
+ getLastNotMinimizedBoxStatus(boxId) {
3508
+ return this.lastNotMinimizedBoxesStatus$.get(boxId);
2921
3509
  }
2922
3510
  setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus, skipUpdate = false) {
2923
- const boxesStatus = this.lastNotMinimizedBoxesStatus$;
2924
3511
  if (lastNotMinimizedBoxStatus) {
2925
- boxesStatus.set(boxId, lastNotMinimizedBoxStatus);
3512
+ this.lastNotMinimizedBoxesStatus$.set(boxId, lastNotMinimizedBoxStatus);
2926
3513
  } else {
2927
- boxesStatus.delete(boxId);
3514
+ this.lastNotMinimizedBoxesStatus$.delete(boxId);
2928
3515
  }
2929
- this.setLastNotMinimizedBoxesStatus(boxesStatus, skipUpdate);
2930
3516
  if (!skipUpdate) {
2931
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, { id: boxId, boxStatus: lastNotMinimizedBoxStatus });
3517
+ this.events.emit(TELE_BOX_MANAGER_EVENT.LastNotMinimizedBoxStatus, { id: boxId, boxStatus: lastNotMinimizedBoxStatus });
2932
3518
  }
2933
3519
  }
2934
3520
  setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus, skipUpdate = false) {
3521
+ this.lastNotMinimizedBoxesStatus$ = lastNotMinimizedBoxesStatus;
3522
+ this.effectLastNotMinimizedBoxStatusChange(skipUpdate);
3523
+ }
3524
+ async effectLastNotMinimizedBoxStatusChange(skipUpdate = false) {
3525
+ var _a, _b;
3526
+ if (!this.useBoxesStatus) {
3527
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
3528
+ clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3529
+ if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3530
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_a = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _a.skipUpdate));
3531
+ }
3532
+ }
3533
+ this.effectLastNotMinimizedBoxStatusTimer = void 0;
3534
+ return;
3535
+ }
3536
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
3537
+ clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
3538
+ if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
3539
+ if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3540
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((_b = this.effectLastNotMinimizedBoxStatusTimer) == null ? void 0 : _b.skipUpdate));
3541
+ }
3542
+ this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
3543
+ } else {
3544
+ return;
3545
+ }
3546
+ }
3547
+ if (!this.effectLastNotMinimizedBoxStatusTimer) {
3548
+ this.effectLastNotMinimizedBoxStatusTimer = {
3549
+ skipUpdate,
3550
+ timer: void 0,
3551
+ resolve: void 0
3552
+ };
3553
+ }
3554
+ if (this.effectLastNotMinimizedBoxStatusTimer) {
3555
+ const _skipUpdate = await new Promise((resolve) => {
3556
+ this.effectLastNotMinimizedBoxStatusTimer.resolve = resolve;
3557
+ this.effectLastNotMinimizedBoxStatusTimer.timer = setTimeout(() => {
3558
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
3559
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate);
3560
+ }
3561
+ }, 100);
3562
+ });
3563
+ this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate);
3564
+ this.effectLastNotMinimizedBoxStatusTimer = void 0;
3565
+ }
3566
+ }
3567
+ effectLastNotMinimizedBoxStatusFunc(skipUpdate = false) {
3568
+ if (!this.useBoxesStatus) {
3569
+ return;
3570
+ }
2935
3571
  this.boxes.forEach((box) => {
2936
- const boxStatus = lastNotMinimizedBoxesStatus.get(box.id);
3572
+ const boxStatus = this.lastNotMinimizedBoxesStatus$.get(box.id);
2937
3573
  if (boxStatus) {
2938
3574
  box.setLastNotMinimizedBoxStatus(boxStatus, skipUpdate);
2939
3575
  }
2940
3576
  });
2941
3577
  }
2942
- getAllMinimizedBoxes() {
2943
- return this.boxes.filter((box) => box.boxStatus && box.boxStatus === exports.TELE_BOX_STATE.Minimized);
3578
+ getUnabledBoxesStatusZIndex() {
3579
+ return this.topBox ? this.topBox.zIndex : 99;
3580
+ }
3581
+ getMaxMaximizedBoxZIndex() {
3582
+ if (!this.useBoxesStatus) {
3583
+ return this.getUnabledBoxesStatusZIndex();
3584
+ }
3585
+ return this.boxes.reduce((maxZIndex, box) => {
3586
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
3587
+ return Math.max(maxZIndex, box.zIndex);
3588
+ }
3589
+ return maxZIndex;
3590
+ }, 99);
3591
+ }
3592
+ getMaxNormalBoxZIndex() {
3593
+ if (!this.useBoxesStatus) {
3594
+ return this.getUnabledBoxesStatusZIndex();
3595
+ }
3596
+ return this.boxes.reduce((maxZIndex, box) => {
3597
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
3598
+ return Math.max(maxZIndex, box.zIndex);
3599
+ }
3600
+ return maxZIndex;
3601
+ }, 299);
2944
3602
  }
2945
3603
  create(config = {}, smartPosition = true) {
2946
- const box = new TeleBox(__spreadProps(__spreadValues({
2947
- zIndex: this.topBox ? this.topBox.zIndex + 1 : 100
2948
- }, smartPosition ? this.smartPosition(config) : config), {
3604
+ const box = new TeleBox({
3605
+ zIndex: this.getMaxNormalBoxZIndex() + 1,
3606
+ ...smartPosition ? this.smartPosition(config) : config,
2949
3607
  darkMode: this.darkMode,
2950
3608
  prefersColorScheme: this.prefersColorScheme,
2951
3609
  maximized: this.maximized,
@@ -2955,92 +3613,110 @@ class TeleBoxManager {
2955
3613
  containerRect: this.containerRect,
2956
3614
  readonly: this.readonly,
2957
3615
  collectorRect: this.collectorRect
2958
- }));
3616
+ });
2959
3617
  box.mount(this.root);
3618
+ this.boxes$.setValue([...this.boxes, box]);
3619
+ if (box.boxStatus && this.useBoxesStatus) {
3620
+ this.setBox(box, {
3621
+ status: box.boxStatus,
3622
+ lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
3623
+ }, true);
3624
+ }
2960
3625
  if (box.focus) {
2961
3626
  this.focusBox(box);
2962
3627
  if (smartPosition) {
2963
3628
  this.makeBoxTop(box);
2964
3629
  }
2965
3630
  }
2966
- this.boxes$.setValue([...this.boxes, box]);
2967
- if (box.boxStatus) {
2968
- this.setBoxStatus(box.id, box.boxStatus, true);
2969
- }
2970
- if (box._lastNotMinimizedBoxStatus$.value) {
2971
- this.setLastNotMinimizedBoxStatus(box.id, box._lastNotMinimizedBoxStatus$.value, true);
2972
- }
2973
- box._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Maximize, () => {
2974
- if (box.boxStatus) {
2975
- if (box.boxStatus === exports.TELE_BOX_STATE.Maximized) {
2976
- this.setBoxStatus(box.id, exports.TELE_BOX_STATE.Normal);
3631
+ box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
3632
+ if (this.useBoxesStatus && box.boxStatus) {
3633
+ if (box.boxStatus === TELE_BOX_STATE.Maximized) {
3634
+ this.setBox(box.id, {
3635
+ status: TELE_BOX_STATE.Normal,
3636
+ zIndex: this.getMaxNormalBoxZIndex() + 1
3637
+ }, false);
2977
3638
  } else {
2978
- this.boxes.forEach((box2) => {
2979
- if (box2.boxStatus === exports.TELE_BOX_STATE.Normal) {
2980
- this.setBoxStatus(box2.id, exports.TELE_BOX_STATE.Maximized);
3639
+ [...this.boxes].filter((box2) => box2.boxStatus === TELE_BOX_STATE.Normal).sort((a, b) => a.zIndex - b.zIndex).forEach((box2) => {
3640
+ if (box2.boxStatus === TELE_BOX_STATE.Normal) {
3641
+ this.setBox(box2.id, {
3642
+ status: TELE_BOX_STATE.Maximized,
3643
+ zIndex: this.getMaxMaximizedBoxZIndex() + 1
3644
+ }, false);
2981
3645
  }
2982
3646
  });
3647
+ this.makeMaximizedTopBoxFocus();
2983
3648
  }
2984
- this.makeMaximizedTopBoxFocus();
2985
3649
  } else {
2986
3650
  this.setMaximized(!this.maximized);
2987
3651
  }
2988
3652
  });
2989
- box._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Minimize, () => {
2990
- if (box.boxStatus) {
2991
- const oldBoxStatus = box.boxStatus;
2992
- this.setBoxStatus(box.id, exports.TELE_BOX_STATE.Minimized);
2993
- if (oldBoxStatus === exports.TELE_BOX_STATE.Maximized) {
2994
- this.makeMaximizedTopBoxFocus();
3653
+ box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
3654
+ if (box.boxStatus && this.useBoxesStatus) {
3655
+ if (box.focus) {
3656
+ this.blurBox(box);
2995
3657
  }
3658
+ this.setBox(box, {
3659
+ status: TELE_BOX_STATE.Minimized,
3660
+ zIndex: -1
3661
+ }, false, () => {
3662
+ this.focusTopBox();
3663
+ });
2996
3664
  } else {
2997
3665
  this.setMinimized(true);
2998
3666
  }
2999
3667
  });
3000
- box._delegateEvents.on(exports.TELE_BOX_DELEGATE_EVENT.Close, () => {
3668
+ box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
3669
+ if (this.useBoxesStatus && box.focus) {
3670
+ this.blurBox(box);
3671
+ }
3001
3672
  this.remove(box);
3002
3673
  this.focusTopBox();
3003
3674
  });
3004
3675
  box._coord$.reaction((_, __, skipUpdate) => {
3005
3676
  if (!skipUpdate) {
3006
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Move, box);
3677
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Move, box);
3007
3678
  }
3008
3679
  });
3009
3680
  box._size$.reaction((_, __, skipUpdate) => {
3010
3681
  if (!skipUpdate) {
3011
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Resize, box);
3682
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Resize, box);
3012
3683
  }
3013
3684
  });
3014
3685
  box._intrinsicCoord$.reaction((_, __, skipUpdate) => {
3015
3686
  if (!skipUpdate) {
3016
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicMove, box);
3687
+ this.events.emit(TELE_BOX_MANAGER_EVENT.IntrinsicMove, box);
3017
3688
  }
3018
3689
  });
3019
3690
  box._intrinsicSize$.reaction((_, __, skipUpdate) => {
3020
3691
  if (!skipUpdate) {
3021
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.IntrinsicResize, box);
3692
+ this.events.emit(TELE_BOX_MANAGER_EVENT.IntrinsicResize, box);
3022
3693
  }
3023
3694
  });
3024
3695
  box._visualSize$.reaction((_, __, skipUpdate) => {
3025
3696
  if (!skipUpdate) {
3026
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.VisualResize, box);
3697
+ this.events.emit(TELE_BOX_MANAGER_EVENT.VisualResize, box);
3027
3698
  }
3028
3699
  });
3029
3700
  box._zIndex$.reaction((_, __, skipUpdate) => {
3030
3701
  if (this.boxes.length > 0) {
3702
+ let currentTopBox = void 0;
3031
3703
  const topBox = this.boxes.reduce((topBox2, box2) => {
3032
- if (box2.boxStatus && box2.boxStatus === exports.TELE_BOX_STATE.Minimized) {
3704
+ if (box2.boxStatus && box2.boxStatus === TELE_BOX_STATE.Minimized) {
3705
+ return topBox2;
3706
+ }
3707
+ if (!topBox2) {
3708
+ topBox2 = box2;
3033
3709
  return topBox2;
3034
3710
  }
3035
3711
  return topBox2.zIndex > box2.zIndex ? topBox2 : box2;
3036
- });
3712
+ }, currentTopBox);
3037
3713
  this.topBox$.setValue(topBox);
3038
3714
  }
3039
3715
  if (!skipUpdate) {
3040
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.ZIndex, box);
3716
+ this.events.emit(TELE_BOX_MANAGER_EVENT.ZIndex, box);
3041
3717
  }
3042
3718
  });
3043
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Created, box);
3719
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Created, box);
3044
3720
  return box;
3045
3721
  }
3046
3722
  query(config) {
@@ -3060,24 +3736,45 @@ class TeleBoxManager {
3060
3736
  this.updateBox(box, config, skipUpdate);
3061
3737
  });
3062
3738
  }
3063
- remove(boxOrID, skipUpdate = false) {
3739
+ setBox(boxOrID, options, skipUpdate = false, effectFunc) {
3064
3740
  const box = this.getBox(boxOrID);
3065
3741
  if (box) {
3066
- this.setBoxStatus(box.id, void 0, skipUpdate);
3067
- this.setLastNotMinimizedBoxStatus(box.id, void 0, skipUpdate);
3742
+ const { status, zIndex, lastNotMinimizedBoxStatus } = options;
3743
+ if (status) {
3744
+ this.setBoxStatus(box.id, status, skipUpdate);
3745
+ box.setBoxStatus(status, skipUpdate);
3746
+ this.effectBoxStatusChange();
3747
+ }
3748
+ if (zIndex) {
3749
+ box.setZIndex(zIndex, skipUpdate);
3750
+ }
3751
+ if (lastNotMinimizedBoxStatus) {
3752
+ this.setLastNotMinimizedBoxStatus(box.id, lastNotMinimizedBoxStatus, skipUpdate);
3753
+ box.setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate);
3754
+ }
3755
+ effectFunc && effectFunc();
3068
3756
  }
3757
+ }
3758
+ remove(boxOrID, skipUpdate = false, effectFunc) {
3759
+ const box = this.getBox(boxOrID);
3069
3760
  const index2 = this.getBoxIndex(boxOrID);
3070
3761
  if (index2 >= 0) {
3071
3762
  const boxes = this.boxes.slice();
3072
3763
  const deletedBoxes = boxes.splice(index2, 1);
3073
3764
  this.boxes$.setValue(boxes);
3074
3765
  deletedBoxes.forEach((box2) => box2.destroy());
3766
+ if (box && this.useBoxesStatus) {
3767
+ this.setBoxStatus(box.id, void 0, skipUpdate);
3768
+ this.setLastNotMinimizedBoxStatus(box.id, void 0, skipUpdate);
3769
+ this.effectBoxStatusChange();
3770
+ effectFunc && effectFunc();
3771
+ }
3075
3772
  if (!skipUpdate) {
3076
3773
  if (this.boxes.length <= 0) {
3077
3774
  this.setMaximized(false);
3078
3775
  this.setMinimized(false);
3079
3776
  }
3080
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
3777
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
3081
3778
  }
3082
3779
  return deletedBoxes[0];
3083
3780
  }
@@ -3100,7 +3797,7 @@ class TeleBoxManager {
3100
3797
  this.setMaximized(false);
3101
3798
  this.setMinimized(false);
3102
3799
  }
3103
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
3800
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
3104
3801
  }
3105
3802
  return deletedBoxes;
3106
3803
  }
@@ -3129,16 +3826,19 @@ class TeleBoxManager {
3129
3826
  targetBox.setFocus(true, skipUpdate);
3130
3827
  }
3131
3828
  if (focusChanged && !skipUpdate) {
3132
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Focused, targetBox);
3829
+ this.events.emit(
3830
+ TELE_BOX_MANAGER_EVENT.Focused,
3831
+ targetBox
3832
+ );
3133
3833
  }
3134
3834
  } else if (box.focus) {
3135
3835
  this.blurBox(box, skipUpdate);
3136
3836
  }
3137
3837
  });
3138
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3139
- this.makeMaximizedBoxFocus(targetBox);
3140
- } else {
3838
+ if (!this.useBoxesStatus) {
3141
3839
  this.maxTitleBar.focusBox(targetBox);
3840
+ } else if (this.useBoxesStatus && this.maxTitleBar.hasMaximizedBoxInStatus()) {
3841
+ this.makeMaximizedTopBoxFocus();
3142
3842
  }
3143
3843
  }
3144
3844
  }
@@ -3153,15 +3853,11 @@ class TeleBoxManager {
3153
3853
  if (targetBox.focus) {
3154
3854
  targetBox.setFocus(false, skipUpdate);
3155
3855
  if (!skipUpdate) {
3156
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Blurred, targetBox);
3856
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, targetBox);
3157
3857
  }
3158
3858
  }
3159
3859
  if (this.maxTitleBar.focusedBox === targetBox) {
3160
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3161
- this.makeMaximizedTopBoxFocus();
3162
- } else {
3163
- this.maxTitleBar.focusBox();
3164
- }
3860
+ this.maxTitleBar.focusBox();
3165
3861
  }
3166
3862
  }
3167
3863
  }
@@ -3170,16 +3866,12 @@ class TeleBoxManager {
3170
3866
  if (box.focus) {
3171
3867
  box.setFocus(false, skipUpdate);
3172
3868
  if (!skipUpdate) {
3173
- this.events.emit(exports.TELE_BOX_MANAGER_EVENT.Blurred, box);
3869
+ this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, box);
3174
3870
  }
3175
3871
  }
3176
3872
  });
3177
3873
  if (this.maxTitleBar.focusedBox) {
3178
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3179
- this.makeMaximizedBoxBlur();
3180
- } else {
3181
- this.maxTitleBar.focusBox();
3182
- }
3874
+ this.maxTitleBar.focusBox();
3183
3875
  }
3184
3876
  }
3185
3877
  teleBoxMatcher(config) {
@@ -3188,10 +3880,18 @@ class TeleBoxManager {
3188
3880
  }
3189
3881
  updateBox(box, config, skipUpdate = false) {
3190
3882
  if (config.x != null || config.y != null) {
3191
- box.move(config.x == null ? box.intrinsicX : config.x, config.y == null ? box.intrinsicY : config.y, skipUpdate);
3883
+ box.move(
3884
+ config.x == null ? box.intrinsicX : config.x,
3885
+ config.y == null ? box.intrinsicY : config.y,
3886
+ skipUpdate
3887
+ );
3192
3888
  }
3193
3889
  if (config.width != null || config.height != null) {
3194
- box.resize(config.width == null ? box.intrinsicWidth : config.width, config.height == null ? box.intrinsicHeight : config.height, skipUpdate);
3890
+ box.resize(
3891
+ config.width == null ? box.intrinsicWidth : config.width,
3892
+ config.height == null ? box.intrinsicHeight : config.height,
3893
+ skipUpdate
3894
+ );
3195
3895
  }
3196
3896
  if (config.title != null) {
3197
3897
  box.setTitle(config.title);
@@ -3224,11 +3924,11 @@ class TeleBoxManager {
3224
3924
  if (config.footer != null) {
3225
3925
  box.mountFooter(config.footer);
3226
3926
  }
3227
- if (config.boxStatus) {
3228
- this.setBoxStatus(box.id, config.boxStatus, skipUpdate);
3229
- }
3230
- if (config.lastNotMinimizedBoxStatus) {
3231
- this.setLastNotMinimizedBoxStatus(box.id, config.lastNotMinimizedBoxStatus, skipUpdate);
3927
+ if (this.useBoxesStatus && (config.boxStatus || config.lastNotMinimizedBoxStatus)) {
3928
+ this.setBox(box, {
3929
+ status: config.boxStatus,
3930
+ lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
3931
+ }, skipUpdate);
3232
3932
  }
3233
3933
  }
3234
3934
  smartPosition(config = {}) {
@@ -3241,6 +3941,10 @@ class TeleBoxManager {
3241
3941
  if (vx > this.containerRect.width - width * this.containerRect.width) {
3242
3942
  vx = 20;
3243
3943
  }
3944
+ } else if (this.hasMinimizedBox()) {
3945
+ vx = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxX, box) => {
3946
+ return Math.max(maxX, box.intrinsicX * this.containerRect.width + 20);
3947
+ }, vx);
3244
3948
  }
3245
3949
  x = vx / this.containerRect.width;
3246
3950
  }
@@ -3251,22 +3955,27 @@ class TeleBoxManager {
3251
3955
  if (vy > this.containerRect.height - height * this.containerRect.height) {
3252
3956
  vy = 20;
3253
3957
  }
3958
+ } else if (this.hasMinimizedBox()) {
3959
+ vy = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxY, box) => {
3960
+ return Math.max(maxY, box.intrinsicY * this.containerRect.height + 20);
3961
+ }, vy);
3254
3962
  }
3255
3963
  y = vy / this.containerRect.height;
3256
3964
  }
3257
- return __spreadProps(__spreadValues({}, config), { x, y, width, height });
3965
+ return { ...config, x, y, width, height };
3258
3966
  }
3259
3967
  makeBoxTop(box, skipUpdate = false) {
3260
- if (this.topBox) {
3968
+ if (!this.useBoxesStatus && this.topBox) {
3261
3969
  if (box !== this.topBox) {
3262
- const currentBoxZIndex = box.zIndex;
3263
- const addZIndex = this.topBox.zIndex + 1 - box.zIndex;
3264
3970
  box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
3265
- this.makeTopBoxEffect(box.id, addZIndex, currentBoxZIndex, skipUpdate);
3266
3971
  }
3267
- }
3972
+ } else if (this.useBoxesStatus)
3973
+ ;
3268
3974
  }
3269
- makeMaximizedTopBoxFocus() {
3975
+ getMaximizedTopBox() {
3976
+ if (!this.useBoxesStatus) {
3977
+ return void 0;
3978
+ }
3270
3979
  let maximizedBox;
3271
3980
  if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
3272
3981
  maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
@@ -3275,45 +3984,15 @@ class TeleBoxManager {
3275
3984
  }
3276
3985
  return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
3277
3986
  });
3278
- if (maximizedBox) {
3279
- this.maxTitleBar.focusBox(maximizedBox);
3280
- }
3281
- }
3282
- }
3283
- makeTopBoxEffect(boxId, addZIndex, currentZIndex, skipUpdate = false) {
3284
- if (this.hasBoxesStatus() && this.hasMinimizedBox()) {
3285
- this.boxes.forEach((b) => {
3286
- if (b.boxStatus && b.id !== boxId && b.zIndex >= currentZIndex) {
3287
- b.setZIndex(b.zIndex + addZIndex, skipUpdate);
3288
- }
3289
- });
3290
3987
  }
3988
+ return maximizedBox;
3291
3989
  }
3292
- makeMaximizedBoxFocus(maximizedBox, skipUpdate = false) {
3293
- if (this.maxTitleBar.hasMaximizedBoxInStatus() && this.maxTitleBar.MaximizedBoxes.find((box) => box.id === maximizedBox.id)) {
3294
- const currentZIndex = maximizedBox.zIndex;
3295
- const currentMaximizedTopBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, box) => {
3296
- if (!topBox) {
3297
- return box;
3298
- }
3299
- return topBox.zIndex > box.zIndex ? topBox : box;
3300
- });
3301
- if (currentMaximizedTopBox !== maximizedBox) {
3302
- const addZIndex = currentMaximizedTopBox.zIndex - currentZIndex + 1;
3303
- this.boxes.forEach((box) => {
3304
- if (this.maxTitleBar.MaximizedBoxes.find((b) => b.id === box.id && b.id !== maximizedBox.id)) {
3305
- return;
3306
- }
3307
- if (box.zIndex >= currentZIndex) {
3308
- box.setZIndex(box.zIndex + addZIndex, skipUpdate);
3309
- }
3310
- });
3311
- }
3312
- this.maxTitleBar.focusBox(maximizedBox);
3990
+ makeMaximizedTopBoxFocus() {
3991
+ if (!this.useBoxesStatus) {
3992
+ return;
3313
3993
  }
3314
- }
3315
- makeMaximizedBoxBlur() {
3316
- this.maxTitleBar.focusBox();
3994
+ const maximizedBox = this.getMaximizedTopBox();
3995
+ this.maxTitleBar.focusBox(maximizedBox);
3317
3996
  }
3318
3997
  getBoxIndex(boxOrID) {
3319
3998
  return typeof boxOrID === "string" ? this.boxes.findIndex((box) => box.id === boxOrID) : this.boxes.findIndex((box) => box === boxOrID);
@@ -3321,8 +4000,28 @@ class TeleBoxManager {
3321
4000
  getBox(boxOrID) {
3322
4001
  return typeof boxOrID === "string" ? this.boxes.find((box) => box.id === boxOrID) : boxOrID;
3323
4002
  }
4003
+ createMinimizedAppMenu() {
4004
+ var _a, _b;
4005
+ if ((_a = this.collector) == null ? void 0 : _a.$appMenuContainer) {
4006
+ return new AppMenu({
4007
+ manager: this,
4008
+ container: (_b = this.collector) == null ? void 0 : _b.$appMenuContainer,
4009
+ theme: this.prefersColorScheme ? "dark" : "light",
4010
+ getBoxesStatus: () => {
4011
+ return this.boxesStatus$;
4012
+ }
4013
+ });
4014
+ }
4015
+ return;
4016
+ }
3324
4017
  }
3325
4018
  exports.DefaultTitleBar = DefaultTitleBar;
4019
+ exports.TELE_BOX_COLOR_SCHEME = TELE_BOX_COLOR_SCHEME;
4020
+ exports.TELE_BOX_DELEGATE_EVENT = TELE_BOX_DELEGATE_EVENT;
4021
+ exports.TELE_BOX_EVENT = TELE_BOX_EVENT;
4022
+ exports.TELE_BOX_MANAGER_EVENT = TELE_BOX_MANAGER_EVENT;
4023
+ exports.TELE_BOX_RESIZE_HANDLE = TELE_BOX_RESIZE_HANDLE;
4024
+ exports.TELE_BOX_STATE = TELE_BOX_STATE;
3326
4025
  exports.TeleBox = TeleBox;
3327
4026
  exports.TeleBoxCollector = TeleBoxCollector;
3328
4027
  exports.TeleBoxDragHandleType = TeleBoxDragHandleType;