@sepveneto/dao 0.1.9 → 0.2.0

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.
Files changed (66) hide show
  1. package/dist/app/Application.d.ts +2 -2
  2. package/dist/assets/Assets.d.ts +4 -4
  3. package/dist/assets/loader/Loader.d.ts +2 -2
  4. package/dist/dao.cjs +1 -1
  5. package/dist/dao.cjs.map +1 -1
  6. package/dist/dao.js +1941 -1686
  7. package/dist/dao.js.map +1 -1
  8. package/dist/events/FederatedEvent.d.ts +2 -2
  9. package/dist/events/FederatedEventMap.d.ts +2 -2
  10. package/dist/main.d.ts +5 -5
  11. package/dist/maths/Bounds.d.ts +6 -3
  12. package/dist/maths/Matrix.d.ts +6 -10
  13. package/dist/maths/Point.d.ts +1 -1
  14. package/dist/maths/getLocalBounds.d.ts +4 -0
  15. package/dist/maths/index.d.ts +2 -2
  16. package/dist/maths/shapes/Polygon.d.ts +5 -2
  17. package/dist/maths/shapes/Rectangle.d.ts +3 -1
  18. package/dist/maths/utils.d.ts +17 -0
  19. package/dist/renderer/CanvasPool.d.ts +2 -2
  20. package/dist/renderer/RenderPipe.d.ts +1 -1
  21. package/dist/renderer/index.d.ts +15 -15
  22. package/dist/renderer/texture/RenderTexture.d.ts +1 -1
  23. package/dist/renderer/texture/Texture.d.ts +1 -1
  24. package/dist/renderer/texture/TextureSource.d.ts +3 -3
  25. package/dist/scene/ViewContainer.d.ts +3 -3
  26. package/dist/scene/batcher/Batcher.d.ts +1 -1
  27. package/dist/scene/batcher/BatcherPipe.d.ts +6 -6
  28. package/dist/scene/container/Container.d.ts +20 -20
  29. package/dist/scene/container/RenderGroup.d.ts +3 -3
  30. package/dist/scene/container/__tests__/DummyEffect.d.ts +1 -1
  31. package/dist/scene/container/__tests__/DummyView.d.ts +1 -1
  32. package/dist/scene/container/mixins/childrenHelperMixin.d.ts +1 -1
  33. package/dist/scene/container/mixins/effectMixin.d.ts +3 -3
  34. package/dist/scene/container/mixins/measureMixin.d.ts +1 -1
  35. package/dist/scene/graphics/Graphics.d.ts +7 -2
  36. package/dist/scene/graphics/GraphicsContext.d.ts +18 -32
  37. package/dist/scene/graphics/GraphicsPipe.d.ts +2 -2
  38. package/dist/scene/graphics/__tests__/Graphics.Bounds.test.d.ts +1 -0
  39. package/dist/scene/graphics/__tests__/Graphics.test.d.ts +1 -0
  40. package/dist/scene/graphics/__tests__/bounds.test.d.ts +1 -0
  41. package/dist/scene/graphics/path/GraphicsPath.d.ts +2 -2
  42. package/dist/scene/graphics/path/ShapePath.d.ts +5 -3
  43. package/dist/scene/graphics/utils/FillTypes.d.ts +28 -0
  44. package/dist/scene/graphics/utils/convertInputToStyle.d.ts +15 -0
  45. package/dist/scene/graphics/utils/getMaxMiterRatio.d.ts +11 -0
  46. package/dist/scene/index.d.ts +1 -1
  47. package/dist/scene/mask/StencilMask.d.ts +2 -2
  48. package/dist/scene/mask/StencilMaskPipe.d.ts +1 -1
  49. package/dist/scene/sprite/Sprite.d.ts +2 -2
  50. package/dist/scene/sprite/SpritePipe.d.ts +1 -1
  51. package/dist/scene/text/Text.d.ts +4 -4
  52. package/dist/scene/text/TextPipe.d.ts +3 -3
  53. package/dist/scene/text/TextStyle.d.ts +3 -3
  54. package/dist/scene/text/TextSystem.d.ts +1 -1
  55. package/dist/scene/text/utils.d.ts +18 -18
  56. package/dist/system/CanvasContextSystem.d.ts +1 -1
  57. package/dist/system/EventSystem.d.ts +10 -5
  58. package/dist/system/ExtractSystem.d.ts +2 -2
  59. package/dist/system/ViewSystem.d.ts +2 -2
  60. package/dist/ticker/Ticker.d.ts +243 -243
  61. package/dist/ticker/TickerListener.d.ts +5 -5
  62. package/dist/utils/color.d.ts +8 -0
  63. package/dist/utils/index.d.ts +0 -1
  64. package/dist/utils/pool/Pool.d.ts +17 -0
  65. package/dist/utils/pool/PoolGroup.d.ts +6 -0
  66. package/package.json +20 -26
package/dist/dao.js CHANGED
@@ -1,513 +1,384 @@
1
- var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJSMin = (n, j) => () => (j || n((j = { exports: {} }).exports, j), j.exports), __copyProps = (n, P, I, L) => {
2
- if (P && typeof P == "object" || typeof P == "function") for (var R = __getOwnPropNames(P), z = 0, B = R.length, V; z < B; z++) V = R[z], !__hasOwnProp.call(n, V) && V !== I && __defProp(n, V, {
3
- get: ((n) => P[n]).bind(null, V),
4
- enumerable: !(L = __getOwnPropDesc(P, V)) || L.enumerable
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
5
6
  });
6
- return n;
7
- }, __toESM = (M, N, F) => (F = M == null ? {} : __create(__getProtoOf(M)), __copyProps(N || !M || !M.__esModule ? __defProp(F, "default", {
8
- value: M,
7
+ return e;
8
+ }, c = (/* @__PURE__ */ ((n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
9
+ value: n,
9
10
  enumerable: !0
10
- }) : F, M));
11
- const PI_2 = Math.PI * 2;
12
- var Matrix = class n {
13
- constructor(n = 1, j = 0, M = 0, N = 1, P = 0, F = 0) {
14
- this.a = n, this.b = j, this.c = M, this.d = N, this.tx = P, this.ty = F;
15
- }
16
- static append(j, M) {
17
- return new n(M.a * j.a + M.b * j.c, M.a * j.b + M.b * j.d, M.c * j.a + M.d * j.c, M.c * j.b + M.d * j.d, M.tx * j.a + M.ty * j.c + j.tx, M.tx * j.b + M.ty * j.d + j.ty);
18
- }
19
- apply(n) {
20
- let { x: j, y: M } = n;
21
- return new Vector2(j * this.a + M * this.c + this.tx, j * this.b + M * this.d + this.ty);
11
+ }) : a, n)))((/* @__PURE__ */ o(((e, t) => {
12
+ var n = Object.prototype.hasOwnProperty, r = "~";
13
+ function i() {}
14
+ Object.create && (i.prototype = Object.create(null), new i().__proto__ || (r = !1));
15
+ function a(e, t, n) {
16
+ this.fn = e, this.context = t, this.once = n || !1;
17
+ }
18
+ function o(e, t, n, i, o) {
19
+ if (typeof n != "function") throw TypeError("The listener must be a function");
20
+ var s = new a(n, i || e, o), c = r ? r + t : t;
21
+ return e._events[c] ? e._events[c].fn ? e._events[c] = [e._events[c], s] : e._events[c].push(s) : (e._events[c] = s, e._eventsCount++), e;
22
+ }
23
+ function s(e, t) {
24
+ --e._eventsCount === 0 ? e._events = new i() : delete e._events[t];
25
+ }
26
+ function c() {
27
+ this._events = new i(), this._eventsCount = 0;
28
+ }
29
+ c.prototype.eventNames = function() {
30
+ var e = [], t, i;
31
+ if (this._eventsCount === 0) return e;
32
+ for (i in t = this._events) n.call(t, i) && e.push(r ? i.slice(1) : i);
33
+ return Object.getOwnPropertySymbols ? e.concat(Object.getOwnPropertySymbols(t)) : e;
34
+ }, c.prototype.listeners = function(e) {
35
+ var t = r ? r + e : e, n = this._events[t];
36
+ if (!n) return [];
37
+ if (n.fn) return [n.fn];
38
+ for (var i = 0, a = n.length, o = Array(a); i < a; i++) o[i] = n[i].fn;
39
+ return o;
40
+ }, c.prototype.listenerCount = function(e) {
41
+ var t = r ? r + e : e, n = this._events[t];
42
+ return n ? n.fn ? 1 : n.length : 0;
43
+ }, c.prototype.emit = function(e, t, n, i, a, o) {
44
+ var s = r ? r + e : e;
45
+ if (!this._events[s]) return !1;
46
+ var c = this._events[s], l = arguments.length, u, d;
47
+ if (c.fn) {
48
+ switch (c.once && this.removeListener(e, c.fn, void 0, !0), l) {
49
+ case 1: return c.fn.call(c.context), !0;
50
+ case 2: return c.fn.call(c.context, t), !0;
51
+ case 3: return c.fn.call(c.context, t, n), !0;
52
+ case 4: return c.fn.call(c.context, t, n, i), !0;
53
+ case 5: return c.fn.call(c.context, t, n, i, a), !0;
54
+ case 6: return c.fn.call(c.context, t, n, i, a, o), !0;
55
+ }
56
+ for (d = 1, u = Array(l - 1); d < l; d++) u[d - 1] = arguments[d];
57
+ c.fn.apply(c.context, u);
58
+ } else {
59
+ var f = c.length, p;
60
+ for (d = 0; d < f; d++) switch (c[d].once && this.removeListener(e, c[d].fn, void 0, !0), l) {
61
+ case 1:
62
+ c[d].fn.call(c[d].context);
63
+ break;
64
+ case 2:
65
+ c[d].fn.call(c[d].context, t);
66
+ break;
67
+ case 3:
68
+ c[d].fn.call(c[d].context, t, n);
69
+ break;
70
+ case 4:
71
+ c[d].fn.call(c[d].context, t, n, i);
72
+ break;
73
+ default:
74
+ if (!u) for (p = 1, u = Array(l - 1); p < l; p++) u[p - 1] = arguments[p];
75
+ c[d].fn.apply(c[d].context, u);
76
+ }
77
+ }
78
+ return !0;
79
+ }, c.prototype.on = function(e, t, n) {
80
+ return o(this, e, t, n, !1);
81
+ }, c.prototype.once = function(e, t, n) {
82
+ return o(this, e, t, n, !0);
83
+ }, c.prototype.removeListener = function(e, t, n, i) {
84
+ var a = r ? r + e : e;
85
+ if (!this._events[a]) return this;
86
+ if (!t) return s(this, a), this;
87
+ var o = this._events[a];
88
+ if (o.fn) o.fn === t && (!i || o.once) && (!n || o.context === n) && s(this, a);
89
+ else {
90
+ for (var c = 0, l = [], u = o.length; c < u; c++) (o[c].fn !== t || i && !o[c].once || n && o[c].context !== n) && l.push(o[c]);
91
+ l.length ? this._events[a] = l.length === 1 ? l[0] : l : s(this, a);
92
+ }
93
+ return this;
94
+ }, c.prototype.removeAllListeners = function(e) {
95
+ var t;
96
+ return e ? (t = r ? r + e : e, this._events[t] && s(this, t)) : (this._events = new i(), this._eventsCount = 0), this;
97
+ }, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = r, c.EventEmitter = c, t !== void 0 && (t.exports = c);
98
+ })))(), 1)).default;
99
+ //#endregion
100
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
101
+ function l(e) {
102
+ "@babel/helpers - typeof";
103
+ return l = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
104
+ return typeof e;
105
+ } : function(e) {
106
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
107
+ }, l(e);
108
+ }
109
+ //#endregion
110
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
111
+ function u(e, t) {
112
+ if (l(e) != "object" || !e) return e;
113
+ var n = e[Symbol.toPrimitive];
114
+ if (n !== void 0) {
115
+ var r = n.call(e, t || "default");
116
+ if (l(r) != "object") return r;
117
+ throw TypeError("@@toPrimitive must return a primitive value.");
118
+ }
119
+ return (t === "string" ? String : Number)(e);
120
+ }
121
+ //#endregion
122
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
123
+ function d(e) {
124
+ var t = u(e, "string");
125
+ return l(t) == "symbol" ? t : t + "";
126
+ }
127
+ //#endregion
128
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
129
+ function f(e, t, n) {
130
+ return (t = d(t)) in e ? Object.defineProperty(e, t, {
131
+ value: n,
132
+ enumerable: !0,
133
+ configurable: !0,
134
+ writable: !0
135
+ }) : e[t] = n, e;
136
+ }
137
+ //#endregion
138
+ //#region lib/scene/batcher/BatcherPipe.ts
139
+ var p = class {
140
+ constructor() {
141
+ f(this, "renderPipeId", "batch"), f(this, "elements", []);
22
142
  }
23
- translate(n, j) {
24
- return this.tx += n, this.ty += j, this;
143
+ }, m = class {
144
+ constructor(e) {
145
+ f(this, "_renderer", void 0), f(this, "_activeBatch", void 0), this._renderer = e;
25
146
  }
26
- rotate(n) {
27
- let j = Math.cos(n), M = Math.sin(n), N = this.a, P = this.c, F = this.tx;
28
- return this.a = N * j - this.b * M, this.b = N * M + this.b * j, this.c = P * j - this.d * M, this.d = P * M + this.d * j, this.tx = F * j - this.ty * M, this.ty = F * M + this.ty * j, this;
147
+ get batch() {
148
+ return this._activeBatch;
29
149
  }
30
- scale(n, j) {
31
- return this.a *= n, this.d *= j, this.c *= n, this.b *= j, this.tx *= n, this.ty *= j, this;
150
+ buildStart() {
151
+ this._activeBatch = new h();
32
152
  }
33
- appendFrom(n, j) {
34
- let M = n.a, N = n.b, P = n.c, F = n.d, I = n.tx, L = n.ty, R = j.a, z = j.b, B = j.c, V = j.d, H = j.tx, U = j.ty;
35
- this.a = M * R + N * B, this.b = M * z + N * V, this.c = P * R + F * B, this.d = P * z + F * V, this.tx = I * R + L * B + H, this.ty = I * z + L * V + U;
153
+ buildEnd(e) {
154
+ this.break(e);
36
155
  }
37
- set(n, j, M, N, P, F) {
38
- this.a = n, this.b = j, this.c = M, this.d = N, this.tx = P, this.ty = F;
156
+ break(e) {
157
+ this._activeBatch.build(e);
39
158
  }
40
- applyInverse(n, j) {
41
- j = j || new Vector2();
42
- let M = this.a, N = this.b, P = this.c, F = this.d, I = this.tx, L = this.ty, R = 1 / (M * F + P * -N), z = n.x, B = n.y;
43
- return j.x = F * R * z + -P * R * B + (L * P - I * F) * R, j.y = M * R * B + -N * R * z + (-L * M + I * N) * R, j;
159
+ addToBatch(e, t) {
160
+ this._activeBatch.add({
161
+ ...e,
162
+ getColor: () => e.renderable.groupColorAlpha
163
+ });
44
164
  }
45
- copyFrom(n) {
46
- return this.a = n.a, this.b = n.b, this.c = n.c, this.d = n.d, this.tx = n.tx, this.ty = n.ty, this;
165
+ execute(e) {
166
+ let t = e.elements;
167
+ if (!t || !t.length) return;
168
+ let n = this._renderer.canvasContext, r = n.activeConext;
169
+ for (let e = 0; e < t.length; e++) {
170
+ let i = t[e], a = i.roundPixels, o = (i.getColor() >>> 24 & 255) / 255;
171
+ if (o <= 0) continue;
172
+ r.globalAlpha = o, n.setContextTransform(i.transform, a === 1);
173
+ let s = i.bounds, c = i.texture, l = c.frame, u = c.source._resolution || 1, d = l.x * u, f = l.y * u, p = l.width * u, m = l.height * u, h = s.minX, g = s.minY, _ = s.maxX - s.minX, v = s.maxY - s.minY, y = h, b = g, x = _, S = v;
174
+ r.drawImage(c.source.resource, d, f, p, m, y, b, x, S);
175
+ }
47
176
  }
48
- decompose(n) {
49
- let j = this.a, M = this.b, N = this.c, P = this.d, F = n.pivot, I = -Math.atan2(-N, P), L = Math.atan2(M, j), R = Math.abs(I + L);
50
- return R < 1e-5 || Math.abs(PI_2 - R) < 1e-5 ? (n.rotation = L, n.skew.x = n.skew.y = 0) : (n.rotation = 0, n.skew.x = I, n.skew.y = L), n.scale.x = Math.sqrt(j * j + M * M), n.scale.y = Math.sqrt(N * N + P * P), n.position.x = this.tx + F.x * j + F.y * N, n.position.y = this.ty + F.x * M + F.y * P, n;
177
+ destroy() {
178
+ var e;
179
+ this._renderer = null, (e = this._activeBatch) == null || e.destroy(), this._activeBatch = null;
51
180
  }
52
- clone() {
53
- let j = new n();
54
- return j.a = this.a, j.b = this.b, j.c = this.c, j.d = this.d, j.tx = this.tx, j.ty = this.ty, j;
181
+ };
182
+ f(m, "desc", { name: "batch" });
183
+ //#endregion
184
+ //#region lib/scene/batcher/Batcher.ts
185
+ var h = class {
186
+ constructor() {
187
+ f(this, "renderPipeId", "batch"), f(this, "elements", []), f(this, "elementSize", 0);
55
188
  }
56
- }, Rectangle = class n {
57
- constructor(n = 0, j = 0, M = 0, N = 0) {
58
- this.type = "rectangle", this.x = n, this.y = j, this.width = M, this.height = N;
189
+ add(e) {
190
+ this.elements[this.elementSize++] = e;
59
191
  }
60
- getBounds() {
61
- let j = new n();
62
- return j.copyFrom(this), j;
192
+ build(e) {
193
+ let t = new p(), n = this.elements;
194
+ if (n[0]) {
195
+ for (let e = 0; e < n.length; e++) {
196
+ let r = n[e];
197
+ this.elements[e] = null, t.elements.push(r);
198
+ }
199
+ e.add(t);
200
+ }
63
201
  }
64
- copyFrom(n) {
65
- return this.x = n.x, this.y = n.y, this.width = n.width, this.height = n.height, this;
202
+ destroy() {
203
+ this.elements = null;
66
204
  }
67
- contains(n, j) {
68
- return this.width <= 0 || this.height <= 0 ? !1 : n >= this.x && n < this.x + this.width && j >= this.y && j < this.y + this.height;
205
+ }, g = Math.PI * 2, _ = class e {
206
+ constructor(e = 1, t = 0, n = 0, r = 1, i = 0, a = 0) {
207
+ f(this, "a", void 0), f(this, "b", void 0), f(this, "c", void 0), f(this, "d", void 0), f(this, "tx", void 0), f(this, "ty", void 0), this.a = e, this.b = t, this.c = n, this.d = r, this.tx = i, this.ty = a;
69
208
  }
70
- }, Vector2 = class {
71
- constructor(n = 0, j = 0) {
72
- this.x = n, this.y = j;
209
+ static get IDENTITY() {
210
+ return v.identity();
73
211
  }
74
- set(n, j) {
75
- j == null ? this.x = this.y = n : (this.x = n, this.y = j);
212
+ static append(t, n) {
213
+ return new e(n.a * t.a + n.b * t.c, n.a * t.b + n.b * t.d, n.c * t.a + n.d * t.c, n.c * t.b + n.d * t.d, n.tx * t.a + n.ty * t.c + t.tx, n.tx * t.b + n.ty * t.d + t.ty);
76
214
  }
77
- copyFrom(n) {
78
- return this.set(n.x, n.y), this;
215
+ identity() {
216
+ return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this;
79
217
  }
80
- };
81
- function nextPow2(n) {
82
- return n += n === 0 ? 1 : 0, --n, n |= n >>> 1, n |= n >>> 2, n |= n >>> 4, n |= n >>> 8, n |= n >>> 16, n + 1;
83
- }
84
- var FederatedEvent = class {
85
- constructor(n) {
86
- this.global = new Vector2(), this.screen = new Vector2(), this.system = n;
218
+ apply(e, t) {
219
+ t || (t = new b());
220
+ let { x: n, y: r } = e;
221
+ return t.x = n * this.a + r * this.c + this.tx, t.y = n * this.b + r * this.d + this.ty, t;
87
222
  }
88
- getLocalPosition(n, j) {
89
- return n.worldTransform.applyInverse(j || this.global);
223
+ translate(e, t) {
224
+ return this.tx += e, this.ty += t, this;
90
225
  }
91
- composedPath() {
92
- return (!this.path || this.path[this.path.length - 1] !== this.target) && (this.path = this.target ? this.system.propagationPath(this.target) : []), this.path;
226
+ rotate(e) {
227
+ let t = Math.cos(e), n = Math.sin(e), r = this.a, i = this.c, a = this.tx;
228
+ return this.a = r * t - this.b * n, this.b = r * n + this.b * t, this.c = i * t - this.d * n, this.d = i * n + this.d * t, this.tx = a * t - this.ty * n, this.ty = a * n + this.ty * t, this;
93
229
  }
94
- }, _EventSystem, PROPAGATION_LIMIT = 2048, EventSystem = class {
95
- constructor(n) {
96
- this.domElement = null, this.rootTarget = null, this.resolution = 1, this._allInteractiveElements = [], this._hitElements = [], this._isPointerMoveEvent = !1, this.mappingState = { trackingData: {} }, this.renderer = n, this.resolution = n.resolution, this._rootPointerEvent = new FederatedEvent(null), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
230
+ scale(e, t) {
231
+ return this.a *= e, this.d *= t, this.c *= e, this.b *= t, this.tx *= e, this.ty *= t, this;
97
232
  }
98
- get pointer() {
99
- return this._rootPointerEvent;
233
+ appendFrom(e, t) {
234
+ let n = e.a, r = e.b, i = e.c, a = e.d, o = e.tx, s = e.ty, c = t.a, l = t.b, u = t.c, d = t.d, f = t.tx, p = t.ty;
235
+ return this.a = n * c + r * u, this.b = n * l + r * d, this.c = i * c + a * u, this.d = i * l + a * d, this.tx = o * c + s * u + f, this.ty = o * l + s * d + p, this;
100
236
  }
101
- trackingData(n) {
102
- return this.mappingState.trackingData[n] || (this.mappingState.trackingData[n] = {
103
- pressTargetsByButton: {},
104
- clicksByButton: {},
105
- overTargets: null
106
- }), this.mappingState.trackingData[n];
237
+ set(e, t, n, r, i, a) {
238
+ this.a = e, this.b = t, this.c = n, this.d = r, this.tx = i, this.ty = a;
107
239
  }
108
- init() {
109
- let n = this.renderer.canvas;
110
- this.setTargetElement(n);
111
- }
112
- setTargetElement(n) {
113
- this._removeEvents(), this.domElement = n, this._addEvents();
114
- }
115
- dispatchEvent(n, j) {
116
- if (!n.target) return;
117
- let M = n.composedPath();
118
- for (let N = 0; N < M.length - 1; ++N) n.currentTarget = M[N], this._notifyTarget(n, j);
119
- n.currentTarget = n.target, this._notifyTarget(n, j);
120
- }
121
- _notifyTarget(n, j) {
122
- j != null || (j = n.type);
123
- let M = n.currentTarget._events[j];
124
- if (M) if ("fn" in M) M.once && n.target.removeListener(j, M.fn, void 0, !0), M.fn.call(M.context, n);
125
- else for (let N = 0; N < M.length; ++N) {
126
- let P = M[N];
127
- P.once && n.target.removeListener(j, P.fn, void 0, !0), P.fn.call(P.context, n);
128
- }
240
+ applyInverse(e, t) {
241
+ t = t || new b();
242
+ let n = this.a, r = this.b, i = this.c, a = this.d, o = this.tx, s = this.ty, c = 1 / (n * a + i * -r), l = e.x, u = e.y;
243
+ return t.x = a * c * l + -i * c * u + (s * i - o * a) * c, t.y = n * c * u + -r * c * l + (-s * n + o * r) * c, t;
129
244
  }
130
- propagationPath(n) {
131
- let j = [n];
132
- for (let M = 0; M < PROPAGATION_LIMIT && (n !== this.rootTarget || n.parent); ++M) {
133
- if (!n.parent) throw Error("Cannot find propagation path to disconnected target");
134
- j.push(n.parent), n = n.parent;
135
- }
136
- return j.reverse(), j;
245
+ copyFrom(e) {
246
+ return this.a = e.a, this.b = e.b, this.c = e.c, this.d = e.d, this.tx = e.tx, this.ty = e.ty, this;
137
247
  }
138
- _removeEvents() {
139
- let n = this.domElement;
140
- n && (globalThis.document.removeEventListener("pointermove", this._onPointerMove, !0), n.removeEventListener("pointerdown", this._onPointerDown, !0), n.removeEventListener("pointerleave", this._onPointerOverOut, !0), n.removeEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.removeEventListener("pointerup", this._onPointerUp, !0));
248
+ decompose(e) {
249
+ let t = this.a, n = this.b, r = this.c, i = this.d, a = e.pivot, o = -Math.atan2(-r, i), s = Math.atan2(n, t), c = Math.abs(o + s);
250
+ return c < 1e-5 || Math.abs(g - c) < 1e-5 ? (e.rotation = s, e.skew.x = e.skew.y = 0) : (e.rotation = 0, e.skew.x = o, e.skew.y = s), e.scale.x = Math.sqrt(t * t + n * n), e.scale.y = Math.sqrt(r * r + i * i), e.position.x = this.tx + a.x * t + a.y * r, e.position.y = this.ty + a.x * n + a.y * i, e;
141
251
  }
142
- _addEvents() {
143
- let n = this.domElement;
144
- if (!n) return;
145
- let j = n.style;
146
- j && (j.touchAction = "none"), globalThis.document.addEventListener("pointermove", this._onPointerMove, !0), n.addEventListener("pointerdown", this._onPointerDown, !0), n.addEventListener("pointerleave", this._onPointerOverOut, !0), n.addEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.addEventListener("pointerup", this._onPointerUp, !0);
147
- }
148
- _onPointerMove(n) {
149
- var j;
150
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
151
- this._isPointerMoveEvent = !0, this._allInteractiveElements.length = 0, this._hitElements.length = 0;
152
- let M = this._bootstrapEvent(this._rootPointerEvent, n), N = this.createPointEvent(M);
153
- this._isPointerMoveEvent = !1;
154
- let P = this.trackingData(n.pointerId), F = findMountedTarget(P.overTargets);
155
- if (((j = P.overTargets) == null ? void 0 : j.length) > 0 && F !== N.target) {
156
- let n = this.createPointEvent(M, "pointerout", F);
157
- this.dispatchEvent(n, "pointerout");
158
- let j = N.composedPath();
159
- if (!j.includes(F)) {
160
- let n = this.createPointEvent(M, "pointerleave", F);
161
- for (; n.target && !j.includes(n.target);) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
162
- }
163
- }
164
- if (F !== N.target) {
165
- let n = "pointerover", j = this.clonePointEvent(N, n);
166
- this.dispatchEvent(j, n);
167
- let M = F == null ? void 0 : F.parent;
168
- for (; M && M !== this.rootTarget.parent && M !== N.target;) M = M.parent;
169
- if (!M || M === this.rootTarget.parent) {
170
- let n = this.clonePointEvent(N, "pointerenter");
171
- for (; n.target && n.target !== F && n.target !== this.rootTarget.parent;) n.currentTarget = n.target, this._notifyTarget(n), n.target = n.target.parent;
172
- }
173
- }
174
- this.dispatchEvent(N, "pointermove");
175
- let I = this._allInteractiveElements;
176
- for (let n = I.length - 1; n >= 0; --n) N.currentTarget = I[n], this._notifyTarget(N, "globalpointermove");
177
- this._allInteractiveElements.length = 0, this._hitElements.length = 0, P.overTargets = N.composedPath();
178
- }
179
- _onPointerDown(n) {
180
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
181
- let j = this._bootstrapEvent(this._rootPointerEvent, n), M = this.createPointEvent(j);
182
- this.dispatchEvent(M, "pointerdown");
183
- let N = this.trackingData(n.pointerId);
184
- N.pressTargetsByButton[n.button] = M.composedPath();
252
+ clone() {
253
+ let t = new e();
254
+ return t.a = this.a, t.b = this.b, t.c = this.c, t.d = this.d, t.tx = this.tx, t.ty = this.ty, t;
185
255
  }
186
- _onPointerOverOut(n) {
187
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
188
- let j = this._bootstrapEvent(this._rootPointerEvent, n), M = this.createPointEvent(j);
189
- this.dispatchEvent(M, "pointerout");
256
+ }, v = new _(), y = class e {
257
+ constructor(e = 0, t = 0, n = 0, r = 0) {
258
+ f(this, "x", void 0), f(this, "y", void 0), f(this, "width", void 0), f(this, "height", void 0), f(this, "type", "rectangle"), this.x = e, this.y = t, this.width = n, this.height = r;
190
259
  }
191
- _onPointerUp(n) {
192
- if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
193
- let j = n.target;
194
- n.composedPath && n.composedPath().length > 1 && (j = n.composedPath()[0]);
195
- let M = this._bootstrapEvent(this._rootPointerEvent, n), N = j === this.domElement ? "" : "outside", P = this.createPointEvent(M);
196
- this.dispatchEvent(P, `pointerup${N}`);
260
+ getBounds() {
261
+ let t = new e();
262
+ return t.copyFrom(this), t;
197
263
  }
198
- _isInteractive(n) {
199
- return n === "static";
264
+ copyFrom(e) {
265
+ return this.x = e.x, this.y = e.y, this.width = e.width, this.height = e.height, this;
200
266
  }
201
- _bootstrapEvent(n, j) {
202
- return n.nativeEvent = j, this.mapPositionToPoint(n.screen, j.clientX, j.clientY), n.global.copyFrom(n.screen), j.type === "pointerleave" ? n.type = "pointerout" : n.type = j.type, n;
267
+ strokeContains(e, t, n, r = .5) {
268
+ let { width: i, height: a } = this;
269
+ if (i <= 0 || a <= 0) return !1;
270
+ let o = this.x, s = this.y, c = n * (1 - r), l = n - c, u = o - c, d = o + i + c, f = s - c, p = s + a + c, m = o + l, h = o + i - l, g = s + l, _ = s + a - l;
271
+ return e >= u && e <= d && t >= f && t <= p && !(e > m && e < h && t > g && t < _);
203
272
  }
204
- createPointEvent(n, j, M) {
205
- var N;
206
- let P = new FederatedEvent(this);
207
- return P.global.copyFrom(n.global), P.screen.copyFrom(n.screen), P.nativeEvent = n.nativeEvent, P.target = (N = M == null ? this.hitTest(P.global.x, P.global.y) : M) == null ? this._hitElements[0] : N, j && (P.type = j), P;
273
+ contains(e, t) {
274
+ return this.width <= 0 || this.height <= 0 ? !1 : e >= this.x && e < this.x + this.width && t >= this.y && t < this.y + this.height;
208
275
  }
209
- clonePointEvent(n, j) {
210
- let M = new FederatedEvent(this);
211
- return M.nativeEvent = n.nativeEvent, M.global = n.global, M.type = j == null ? n.type : j, M.path = n.composedPath().slice(), M.target = n.target, M;
276
+ }, b = class {
277
+ constructor(e = 0, t = 0) {
278
+ f(this, "x", void 0), f(this, "y", void 0), this.x = e, this.y = t;
212
279
  }
213
- mapPositionToPoint(n, j, M) {
214
- let N = this.domElement, P = N.isConnected ? N.getBoundingClientRect() : {
215
- x: 0,
216
- y: 0,
217
- width: N.width,
218
- height: N.height,
219
- left: 0,
220
- top: 0
221
- }, F = 1 / this.resolution;
222
- return n.x = (j - P.left) * (N.width / P.width) * F, n.y = (M - P.top) * (N.height / P.height) * F, n;
223
- }
224
- hitTest(n, j) {
225
- let M = this._isPointerMoveEvent, N = this[M ? "hitTestMoveRecursive" : "hitTestRecursive"](this.rootTarget, this.rootTarget.eventMode, new Vector2(n, j));
226
- return N && N[0];
227
- }
228
- _interactivePrune(n) {
229
- return !n || !n.visible || !n.renderable || !n.measurable || n.eventMode === "none";
230
- }
231
- hitTestMoveRecursive(n, j, M) {
232
- let N = !1;
233
- if (this._interactivePrune(n)) return;
234
- let P = n.children;
235
- if (P && P.length > 0) for (let F = P.length - 1; F >= 0; --F) {
236
- let I = P[F], L = this.hitTestMoveRecursive(I, this._isInteractive(j) ? j : I.eventMode, M);
237
- if (L) {
238
- if (L.length > 0 && !L[L.length - 1].parent) continue;
239
- let j = this._isInteractive(n.eventMode);
240
- (L.length > 0 || j) && (j && this._allInteractiveElements.push(n), L.push(n)), this._hitElements.length === 0 && (this._hitElements = L), N = !0;
241
- }
242
- }
243
- let F = this._isInteractive(j), I = this._isInteractive(n.eventMode);
244
- if (I && this._allInteractiveElements.push(n), !(this._hitElements.length > 0)) {
245
- if (N) return this._hitElements;
246
- if (F && this.hitTestFn(n, M)) return I ? [n] : [];
247
- }
280
+ set(e, t) {
281
+ t == null ? this.x = this.y = e : (this.x = e, this.y = t);
248
282
  }
249
- hitTestRecursive(n, j, M) {
250
- if (this._interactivePrune(n)) return;
251
- let N = n.children;
252
- for (let P = N.length - 1; P >= 0; P--) {
253
- let F = N[P], I = this.hitTestRecursive(F, this._isInteractive(j) ? j : F.eventMode, M);
254
- if (I) {
255
- let j = this._isInteractive(n.eventMode);
256
- return (I.length > 0 || j) && I.push(n), I;
257
- }
258
- }
259
- let P = this._isInteractive(j), F = this._isInteractive(n.eventMode);
260
- return P && this.hitTestFn(n, M) ? F ? [n] : [] : null;
261
- }
262
- hitTestFn(n, j) {
263
- if (n.hitArea) return !0;
264
- if (n.containsPoint) {
265
- let M = n.worldTransform.applyInverse(j);
266
- return n.containsPoint(M);
267
- }
268
- return !1;
283
+ copyFrom(e) {
284
+ return this.set(e.x, e.y), this;
269
285
  }
270
286
  };
271
- _EventSystem = EventSystem, _EventSystem.desc = { name: "events" };
272
- function findMountedTarget(n) {
273
- if (!n) return;
274
- let j = n[0];
275
- for (let M = 1; M < n.length && n[M].parent === j; ++M) j = n[M];
276
- return j;
287
+ function x(e) {
288
+ return e += +(e === 0), --e, e |= e >>> 1, e |= e >>> 2, e |= e >>> 4, e |= e >>> 8, e |= e >>> 16, e + 1;
277
289
  }
278
- function clearList(n, j) {
279
- j || (j = 0);
280
- for (let M = j; M < n.length && n[M]; ++M) n[M] = null;
281
- }
282
- function assignWithIgnore(n, j, M = {}) {
283
- for (let N in j) !M[N] && j[N] !== void 0 && (n[N] = j[N]);
284
- }
285
- var InstructionSet = class {
286
- constructor() {
287
- this.instructions = [], this.instructionSize = 0;
288
- }
289
- reset() {
290
- this.instructionSize = 0;
291
- }
292
- add(n) {
293
- this.instructions[this.instructionSize++] = n;
290
+ //#endregion
291
+ //#region lib/maths/const.ts
292
+ var S = 180 / Math.PI, ee = Math.PI / 180, C = class {
293
+ constructor(e, t, n) {
294
+ f(this, "_x", void 0), f(this, "_y", void 0), f(this, "_observer", void 0), this._x = t || 0, this._y = n || 0, this._observer = e;
294
295
  }
295
- }, RenderGroup = class {
296
- constructor(n) {
297
- this.worldTransform = new Matrix(), this.localTransform = new Matrix(), this.root = null, this.instructionSet = new InstructionSet(), this.structureDidChange = !0, this.renderGroupParent = null, this.renderGroupChildren = [], this.childrenToUpdate = Object.create(null), this.childrenRenderablesToUpdate = {
298
- list: [],
299
- index: 0
300
- }, this._onRenderContainers = [], this.init(n);
301
- }
302
- init(n) {
303
- this.root = n;
304
- let j = n.children;
305
- for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
306
- }
307
- addChild(n) {
308
- if (this.structureDidChange = !0, n.parentRenderGroup = this, n.parent === this.root ? n.relativeRenderGroupDepth = 1 : n.relativeRenderGroupDepth = n.parent.relativeRenderGroupDepth + 1, n.didChange = !0, this.onChildUpdate(n), n.renderGroup) {
309
- this.addRenderGroupChild(n.renderGroup);
310
- return;
311
- }
312
- n._onRender && this.addOnRender(n);
313
- let j = n.children;
314
- for (let n = 0; n < j.length; ++n) this.addChild(j[n]);
296
+ set(e = 0, t = e) {
297
+ return (this._x !== e || this._y !== t) && (this._x = e, this._y = t, this._observer._onUpdate(this)), this;
315
298
  }
316
- removeChild(n) {
317
- if (this.structureDidChange = !0, n.parentRenderGroup = null, n.renderGroup) {
318
- this._removeRenderGroupChild(n.renderGroup);
319
- return;
320
- }
321
- let j = n.children;
322
- for (let n = 0; n < j.length; ++n) this.removeChild(j[n]);
299
+ get x() {
300
+ return this._x;
323
301
  }
324
- removeChildren(n) {
325
- for (let j = 0; j < n.length; ++j) this.removeChild(n[j]);
302
+ set x(e) {
303
+ this._x !== e && (this._x = e, this._observer._onUpdate(this));
326
304
  }
327
- addRenderGroupChild(n) {
328
- n.renderGroupParent && n.renderGroupParent._removeRenderGroupChild(n), n.renderGroupParent = this, this.renderGroupChildren.push(n);
305
+ get y() {
306
+ return this._y;
329
307
  }
330
- _removeRenderGroupChild(n) {
331
- let j = this.renderGroupChildren.indexOf(n);
332
- j > -1 && this.renderGroupChildren.splice(j, 1), n.renderGroupParent = null;
308
+ set y(e) {
309
+ this._y !== e && (this._y = e, this._observer._onUpdate(this));
333
310
  }
334
- addOnRender(n) {
335
- this._onRenderContainers.push(n);
311
+ copyFrom(e) {
312
+ return (this.x !== e.x || this.y !== e.y) && (this._x = e.x, this._y = e.y, this._observer._onUpdate(this)), this;
336
313
  }
337
- removeOnRender(n) {
338
- this._onRenderContainers.splice(this._onRenderContainers.indexOf(n), 1);
314
+ toVector2() {
315
+ return new b(this.x, this.y);
339
316
  }
340
- runOnRender(n) {
341
- for (let j = 0; j < this._onRenderContainers.length; ++j) this._onRenderContainers[j]._onRender(n);
317
+ }, te = class {
318
+ constructor(e) {
319
+ f(this, "_classType", void 0), f(this, "_pool", []), f(this, "_index", 0), f(this, "_count", 0), this._classType = e;
342
320
  }
343
- onChildViewUpdate(n) {
344
- this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++] = n;
321
+ get(e) {
322
+ var t;
323
+ let n;
324
+ return this._index > 0 ? n = this._pool[--this._index] : (n = new this._classType(), this._count++), (t = n.init) == null || t.call(n, e), n;
345
325
  }
346
- onChildUpdate(n) {
347
- let j = this.childrenToUpdate[n.relativeRenderGroupDepth];
348
- j || (j = this.childrenToUpdate[n.relativeRenderGroupDepth] = {
349
- index: 0,
350
- list: []
351
- }), j.list[j.index++] = n;
326
+ return(e) {
327
+ var t;
328
+ (t = e.reset) == null || t.call(e), this._pool[this._index++] = e;
352
329
  }
353
- updateRenderable(n) {
354
- n.globalDisplayStatus < 7 || (this.instructionSet.renderPipes[n.renderPipeId].updateRenderable(n), n.didViewUpdate = !1);
330
+ clear() {
331
+ if (this._pool.length > 0 && this._pool[0].destroy) for (let e = 0; e < this._index; ++e) this._pool[e].destroy();
332
+ this._pool.length = 0, this._count = 0, this._index = 0;
355
333
  }
356
- destroy() {
357
- this.root = null, this.childrenRenderablesToUpdate = null, this.childrenToUpdate = null, this._onRenderContainers = null, this.renderGroupChildren = null, this.instructionSet = null;
334
+ }, ne = new class {
335
+ constructor() {
336
+ f(this, "_poolsByClass", /* @__PURE__ */ new Map());
358
337
  }
359
- }, uidCache = { default: -1 };
360
- function uid(n = "default") {
361
- return uidCache[n] === void 0 && (uidCache[n] = -1), ++uidCache[n];
362
- }
363
- function updateBounds(n, j, M) {
364
- let { width: N, height: P } = M.orig;
365
- n.minX = -j.x * N, n.minY = -j.y * P, n.maxX = n.minX + N, n.maxY = n.minY + P;
366
- }
367
- function applyMixins(n, ...j) {
368
- for (let M of j) Object.defineProperties(n.prototype, Object.getOwnPropertyDescriptors(M));
369
- }
370
- var ObservablePoint = class {
371
- constructor(n, j, M) {
372
- this._x = j || 0, this._y = M || 0, this._observer = n;
338
+ getPool(e) {
339
+ return this._poolsByClass.has(e) || this._poolsByClass.set(e, new te(e)), this._poolsByClass.get(e);
373
340
  }
374
- set(n = 0, j = n) {
375
- return (this._x !== n || this._y !== j) && (this._x = n, this._y = j, this._observer._onUpdate(this)), this;
341
+ }(), w = class e {
342
+ constructor(e = Infinity, t = Infinity, n = -Infinity, r = -Infinity) {
343
+ f(this, "minX", Infinity), f(this, "minY", Infinity), f(this, "maxX", -Infinity), f(this, "maxY", -Infinity), f(this, "matrix", new _()), f(this, "_rectangle", void 0), this.minX = e, this.minY = t, this.maxX = n, this.maxY = r;
376
344
  }
377
345
  get x() {
378
- return this._x;
346
+ return this.minX;
379
347
  }
380
- set x(n) {
381
- this._x !== n && (this._x = n, this._observer._onUpdate(this));
348
+ set x(e) {
349
+ let t = this.maxX - this.minX;
350
+ this.minX = e, this.maxX = e + t;
382
351
  }
383
352
  get y() {
384
- return this._y;
385
- }
386
- set y(n) {
387
- this._y !== n && (this._y = n, this._observer._onUpdate(this));
388
- }
389
- copyFrom(n) {
390
- return (this.x !== n.x || this.y !== n.y) && (this._x = n.x, this._y = n.y, this._observer._onUpdate(this)), this;
353
+ return this.minY;
391
354
  }
392
- toVector2() {
393
- return new Vector2(this.x, this.y);
394
- }
395
- };
396
- const RAD_TO_DEG = 180 / Math.PI, DEG_TO_RAD = Math.PI / 180;
397
- var eventemitter3_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((n, j) => {
398
- var M = Object.prototype.hasOwnProperty, N = "~";
399
- function P() {}
400
- Object.create && (P.prototype = Object.create(null), new P().__proto__ || (N = !1));
401
- function F(n, j, M) {
402
- this.fn = n, this.context = j, this.once = M || !1;
403
- }
404
- function I(n, j, M, P, I) {
405
- if (typeof M != "function") throw TypeError("The listener must be a function");
406
- var L = new F(M, P || n, I), R = N ? N + j : j;
407
- return n._events[R] ? n._events[R].fn ? n._events[R] = [n._events[R], L] : n._events[R].push(L) : (n._events[R] = L, n._eventsCount++), n;
408
- }
409
- function L(n, j) {
410
- --n._eventsCount === 0 ? n._events = new P() : delete n._events[j];
411
- }
412
- function R() {
413
- this._events = new P(), this._eventsCount = 0;
414
- }
415
- R.prototype.eventNames = function() {
416
- var n = [], j, P;
417
- if (this._eventsCount === 0) return n;
418
- for (P in j = this._events) M.call(j, P) && n.push(N ? P.slice(1) : P);
419
- return Object.getOwnPropertySymbols ? n.concat(Object.getOwnPropertySymbols(j)) : n;
420
- }, R.prototype.listeners = function(n) {
421
- var j = N ? N + n : n, M = this._events[j];
422
- if (!M) return [];
423
- if (M.fn) return [M.fn];
424
- for (var P = 0, F = M.length, I = Array(F); P < F; P++) I[P] = M[P].fn;
425
- return I;
426
- }, R.prototype.listenerCount = function(n) {
427
- var j = N ? N + n : n, M = this._events[j];
428
- return M ? M.fn ? 1 : M.length : 0;
429
- }, R.prototype.emit = function(n, j, M, P, F, I) {
430
- var L = N ? N + n : n;
431
- if (!this._events[L]) return !1;
432
- var R = this._events[L], z = arguments.length, B, V;
433
- if (R.fn) {
434
- switch (R.once && this.removeListener(n, R.fn, void 0, !0), z) {
435
- case 1: return R.fn.call(R.context), !0;
436
- case 2: return R.fn.call(R.context, j), !0;
437
- case 3: return R.fn.call(R.context, j, M), !0;
438
- case 4: return R.fn.call(R.context, j, M, P), !0;
439
- case 5: return R.fn.call(R.context, j, M, P, F), !0;
440
- case 6: return R.fn.call(R.context, j, M, P, F, I), !0;
441
- }
442
- for (V = 1, B = Array(z - 1); V < z; V++) B[V - 1] = arguments[V];
443
- R.fn.apply(R.context, B);
444
- } else {
445
- var H = R.length, U;
446
- for (V = 0; V < H; V++) switch (R[V].once && this.removeListener(n, R[V].fn, void 0, !0), z) {
447
- case 1:
448
- R[V].fn.call(R[V].context);
449
- break;
450
- case 2:
451
- R[V].fn.call(R[V].context, j);
452
- break;
453
- case 3:
454
- R[V].fn.call(R[V].context, j, M);
455
- break;
456
- case 4:
457
- R[V].fn.call(R[V].context, j, M, P);
458
- break;
459
- default:
460
- if (!B) for (U = 1, B = Array(z - 1); U < z; U++) B[U - 1] = arguments[U];
461
- R[V].fn.apply(R[V].context, B);
462
- }
463
- }
464
- return !0;
465
- }, R.prototype.on = function(n, j, M) {
466
- return I(this, n, j, M, !1);
467
- }, R.prototype.once = function(n, j, M) {
468
- return I(this, n, j, M, !0);
469
- }, R.prototype.removeListener = function(n, j, M, P) {
470
- var F = N ? N + n : n;
471
- if (!this._events[F]) return this;
472
- if (!j) return L(this, F), this;
473
- var I = this._events[F];
474
- if (I.fn) I.fn === j && (!P || I.once) && (!M || I.context === M) && L(this, F);
475
- else {
476
- for (var R = 0, z = [], B = I.length; R < B; R++) (I[R].fn !== j || P && !I[R].once || M && I[R].context !== M) && z.push(I[R]);
477
- z.length ? this._events[F] = z.length === 1 ? z[0] : z : L(this, F);
478
- }
479
- return this;
480
- }, R.prototype.removeAllListeners = function(n) {
481
- var j;
482
- return n ? (j = N ? N + n : n, this._events[j] && L(this, j)) : (this._events = new P(), this._eventsCount = 0), this;
483
- }, R.prototype.off = R.prototype.removeListener, R.prototype.addListener = R.prototype.on, R.prefixed = N, R.EventEmitter = R, j !== void 0 && (j.exports = R);
484
- })))(), 1)).default, Bounds = class n {
485
- constructor(n = Infinity, j = Infinity, M = -Infinity, N = -Infinity) {
486
- this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity, this.matrix = new Matrix(), this.minX = n, this.minY = j, this.maxX = M, this.maxY = N;
355
+ set y(e) {
356
+ let t = this.maxY - this.minY;
357
+ this.minY = e, this.maxY = e + t;
487
358
  }
488
359
  clone() {
489
- return new n(this.minX, this.minY, this.maxX, this.maxY);
360
+ return new e(this.minX, this.minY, this.maxX, this.maxY);
490
361
  }
491
362
  isEmpty() {
492
363
  return this.minX >= this.maxX || this.minY >= this.maxY;
493
364
  }
494
365
  clear() {
495
- this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity;
366
+ return this.minX = Infinity, this.minY = Infinity, this.maxX = -Infinity, this.maxY = -Infinity, this;
496
367
  }
497
- pad(n, j = n) {
498
- return this.minX -= n, this.maxX += n, this.minY -= j, this.maxY += j, this;
368
+ pad(e, t = e) {
369
+ return this.minX -= e, this.maxX += e, this.minY -= t, this.maxY += t, this;
499
370
  }
500
371
  get width() {
501
372
  return this.maxX - this.minX;
502
373
  }
503
- set width(n) {
504
- this.maxX = this.minX + n;
374
+ set width(e) {
375
+ this.maxX = this.minX + e;
505
376
  }
506
377
  get height() {
507
378
  return this.maxY - this.minY;
508
379
  }
509
- set height(n) {
510
- this.maxY = this.minY + n;
380
+ set height(e) {
381
+ this.maxY = this.minY + e;
511
382
  }
512
383
  get left() {
513
384
  return this.minX;
@@ -524,509 +395,491 @@ var eventemitter3_default = (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJS
524
395
  get isValid() {
525
396
  return this.minX + this.minY !== Infinity;
526
397
  }
527
- set(n, j, M, N) {
528
- this.minX = n, this.minY = j, this.maxX = M, this.maxY = N;
398
+ set(e, t, n, r) {
399
+ this.minX = e, this.minY = t, this.maxX = n, this.maxY = r;
529
400
  }
530
- addBounds(n, j) {
531
- this.addFrame(n.minX, n.minY, n.maxX, n.maxY, j);
401
+ addBounds(e, t) {
402
+ this.addFrame(e.minX, e.minY, e.maxX, e.maxY, t);
532
403
  }
533
- addRect(n, j) {
534
- this.addFrame(n.x, n.y, n.width + n.x, n.height + n.y, j);
404
+ addRect(e, t) {
405
+ this.addFrame(e.x, e.y, e.width + e.x, e.height + e.y, t);
535
406
  }
536
- addFrame(n, j, M, N, P) {
537
- P || (P = this.matrix);
538
- let F = P.a, I = P.b, L = P.c, R = P.d, z = P.tx, B = P.ty;
539
- updateMinMax(F * n + L * j + z, I * n + R * j + B, this), updateMinMax(F * M + L * j + z, I * M + R * j + B, this), updateMinMax(F * n + L * N + z, I * n + R * N + B, this), updateMinMax(F * M + L * N + z, I * M + R * N + B, this);
407
+ addFrame(e, t, n, r, i) {
408
+ i || (i = this.matrix);
409
+ let a = i.a, o = i.b, s = i.c, c = i.d, l = i.tx, u = i.ty, d = this.minX, f = this.minY, p = this.maxX, m = this.maxY, h = a * e + s * t + l, g = o * e + c * t + u;
410
+ h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), h = a * n + s * t + l, g = o * n + c * t + u, h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), h = a * e + s * r + l, g = o * e + c * r + u, h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), h = a * n + s * r + l, g = o * n + c * r + u, h < d && (d = h), g < f && (f = g), h > p && (p = h), g > m && (m = g), this.minX = d, this.minY = f, this.maxX = p, this.maxY = m;
540
411
  }
541
412
  get rectangle() {
542
- this._rectangle || (this._rectangle = new Rectangle());
543
- let n = this._rectangle;
544
- return this.minX > this.maxX || this.minY > this.maxY ? (n.x = 0, n.y = 0, n.width = 0, n.height = 0) : (n.x = this.minX, n.y = this.minY, n.width = this.maxX - this.minX, n.height = this.maxY - this.minY), n;
545
- }
546
- addBoundsMask(n) {
547
- this.minX = this.minX > n.minX ? this.minX : n.minX, this.minY = this.minY > n.minY ? this.minY : n.minY, this.maxX = this.maxX < n.maxX ? this.maxX : n.maxX, this.maxY = this.maxY < n.maxY ? this.maxY : n.maxY;
548
- }
549
- };
550
- function updateMinMax(n, j, M) {
551
- n < M.minX && (M.minX = n), n > M.maxX && (M.maxX = n), j < M.minY && (M.minY = j), j > M.maxY && (M.maxY = j);
413
+ this._rectangle || (this._rectangle = new y());
414
+ let e = this._rectangle;
415
+ return this.minX > this.maxX || this.minY > this.maxY ? (e.x = 0, e.y = 0, e.width = 0, e.height = 0) : (e.x = this.minX, e.y = this.minY, e.width = this.maxX - this.minX, e.height = this.maxY - this.minY), e;
416
+ }
417
+ addBoundsMask(e) {
418
+ this.minX = this.minX > e.minX ? this.minX : e.minX, this.minY = this.minY > e.minY ? this.minY : e.minY, this.maxX = this.maxX < e.maxX ? this.maxX : e.maxX, this.maxY = this.maxY < e.maxY ? this.maxY : e.maxY;
419
+ }
420
+ containsPoint(e, t) {
421
+ return this.minX <= e && e <= this.maxX && this.minY <= t && t <= this.maxY;
422
+ }
423
+ }, T = ne.getPool(_), re = ne.getPool(w);
424
+ function ie(e, t, n, r, i, a) {
425
+ let o = e - n, s = t - r, c = i - n, l = a - r, u = o * c + s * l, d = c * c + l * l, f = -1;
426
+ d !== 0 && (f = u / d);
427
+ let p, m;
428
+ f < 0 ? (p = n, m = r) : f > 1 ? (p = i, m = a) : (p = n + f * c, m = r + f * l);
429
+ let h = e - p, g = t - m;
430
+ return h * h + g * g;
431
+ }
432
+ //#endregion
433
+ //#region lib/utils/uid.ts
434
+ var E = { default: -1 };
435
+ function D(e = "default") {
436
+ return E[e] === void 0 && (E[e] = -1), ++E[e];
437
+ }
438
+ //#endregion
439
+ //#region lib/utils/index.ts
440
+ function ae(e, t, n) {
441
+ let { width: r, height: i } = n.orig;
442
+ e.minX = -t.x * r, e.minY = -t.y * i, e.maxX = e.minX + r, e.maxY = e.minY + i;
552
443
  }
553
- function getLocalBounds(n, j, M) {
554
- return j.clear(), M || (M = new Matrix()), _getLocalBounds(n, j, M, n, !0), j.isValid || j.set(0, 0, 0, 0), j;
444
+ function oe(e, ...t) {
445
+ for (let n of t) Object.defineProperties(e.prototype, Object.getOwnPropertyDescriptors(n));
555
446
  }
556
- function _getLocalBounds(n, j, M, N, P) {
557
- let F = new Matrix();
558
- if (P) F.copyFrom(M);
447
+ //#endregion
448
+ //#region lib/scene/container/mixins/childrenHelperMixin.ts
449
+ var se = { removeChildren(e = 0, t) {
450
+ let n = t == null ? this.children.length : t, r = n - e, i = [];
451
+ if (r > 0 && r <= n) {
452
+ for (let t = n - 1; t >= e; --t) {
453
+ let e = this.children[t];
454
+ e && (i.push(e), e.parent = null);
455
+ }
456
+ ce(this.children, e, n);
457
+ let t = this.renderGroup || this.parentRenderGroup;
458
+ return t && t.removeChildren(i), i.length > 0 && this._didViewChangeTick++, i;
459
+ } else if (r === 0 && this.children.length === 0) return i;
460
+ throw Error("removeChildren: numeric values are outside the acceptable range.");
461
+ } };
462
+ function ce(e, t, n) {
463
+ let r = e.length, i;
464
+ if (t >= r || n === 0) return;
465
+ n = t + n > r ? r - t : n;
466
+ let a = r - n;
467
+ for (i = t; i < a; ++i) e[i] = e[i + n];
468
+ e.length = a;
469
+ }
470
+ //#endregion
471
+ //#region lib/maths/getLocalBounds.ts
472
+ function O(e, t, n) {
473
+ return t.clear(), n || (n = new _()), le(e, t, n, e, !0), t.isValid || t.set(0, 0, 0, 0), t;
474
+ }
475
+ function le(e, t, n, r, i) {
476
+ let a;
477
+ if (i) a = T.get(), a.copyFrom(n);
559
478
  else {
560
- if (!n.visible || !n.measurable) return;
561
- n.updateLocalTransform(), F.appendFrom(n.localTransform, M);
479
+ if (!e.visible || !e.measurable) return;
480
+ e.updateLocalTransform(), a = T.get(), a.appendFrom(e.localTransform, n);
562
481
  }
563
- let I = j, L = !!n.effects.length;
564
- if (L && (j = new Bounds()), n.boundsArea) j.addRect(n.boundsArea, F);
482
+ let o = t, s = !!e.effects.length;
483
+ if (s && (t = re.get().clear()), e.boundsArea) t.addRect(e.boundsArea, a);
565
484
  else {
566
- n.renderPipeId && (j.matrix = F, j.addBounds(n.bounds));
567
- let M = n.children;
568
- for (let n = 0; n < M.length; n++) _getLocalBounds(M[n], j, F, N, !1);
569
- if (L) {
570
- for (let M = 0; M < n.effects.length; ++M) {
571
- var R, z;
572
- (R = (z = n.effects[M]).addLocalBounds) == null || R.call(z, j, N);
485
+ e.renderPipeId && (t.matrix = a, t.addBounds(e.bounds));
486
+ let n = e.children;
487
+ for (let e = 0; e < n.length; e++) le(n[e], t, a, r, !1);
488
+ if (s) {
489
+ for (let n = 0; n < e.effects.length; ++n) {
490
+ var c, l;
491
+ (c = (l = e.effects[n]).addLocalBounds) == null || c.call(l, t, r);
573
492
  }
574
- I.addBounds(j, new Matrix());
493
+ o.addBounds(t, _.IDENTITY), re.return(t);
575
494
  }
576
495
  }
577
- return j;
496
+ T.return(a);
578
497
  }
579
- var StencilMask = class {
580
- constructor(n) {
581
- this.pipe = "stencilMask", this.mask = n, n.includeInBuild = !1, n.measurable = !1;
582
- }
583
- addLocalBounds(n, j) {
584
- let M = new Bounds();
498
+ //#endregion
499
+ //#region lib/scene/mask/StencilMask.ts
500
+ var ue = class {
501
+ constructor(e) {
502
+ f(this, "pipe", "stencilMask"), f(this, "mask", void 0), this.mask = e, e.includeInBuild = !1, e.measurable = !1;
503
+ }
504
+ addLocalBounds(e, t) {
505
+ let n = new w();
585
506
  this.mask.measurable = !0;
586
- let N = getMatrixRelativeToParent(this.mask, j);
587
- getLocalBounds(this.mask, M, N), this.mask.measurable = !1, n.addBoundsMask(M);
507
+ let r = de(this.mask, t);
508
+ O(this.mask, n, r), this.mask.measurable = !1, e.addBoundsMask(n);
588
509
  }
589
510
  };
590
- function getMatrixRelativeToParent(n, j, M) {
591
- return M || (M = new Matrix()), n === j ? M : (M = getMatrixRelativeToParent(n.parent, j, M), n.updateLocalTransform(), Matrix.append(M, n.localTransform));
511
+ function de(e, t, n) {
512
+ return n || (n = new _()), e === t ? n : (n = de(e.parent, t, n), e.updateLocalTransform(), _.append(n, e.localTransform));
592
513
  }
593
- const effectMixin = {
514
+ //#endregion
515
+ //#region lib/scene/container/mixins/effectMixin.ts
516
+ var fe = {
594
517
  effects: [],
595
518
  _maskEffect: null,
596
- addEffect(n) {
597
- this.effects.push(n), this._updateIsSimple();
519
+ addEffect(e) {
520
+ this.effects.push(e), this._updateIsSimple();
598
521
  },
599
- removeEffect(n) {
600
- let j = this.effects.indexOf(n);
601
- j === -1 && this.effects.splice(j, 1), this._updateIsSimple();
522
+ removeEffect(e) {
523
+ let t = this.effects.indexOf(e);
524
+ t === -1 && this.effects.splice(t, 1), this._updateIsSimple();
602
525
  },
603
- set mask(n) {
604
- let j = this._maskEffect;
605
- n !== (j == null ? void 0 : j.mask) && (j && (this.removeEffect(j), this._maskEffect = null), n != null && (this._maskEffect = new StencilMask(n), this.addEffect(this._maskEffect)));
526
+ set mask(e) {
527
+ let t = this._maskEffect;
528
+ e !== (t == null ? void 0 : t.mask) && (t && (this.removeEffect(t), this._maskEffect = null), e != null && (this._maskEffect = new ue(e), this.addEffect(this._maskEffect)));
606
529
  },
607
530
  get mask() {
608
- var n;
609
- return (n = this._maskEffect) == null ? void 0 : n.mask;
531
+ var e;
532
+ return (e = this._maskEffect) == null ? void 0 : e.mask;
610
533
  }
611
- }, sortMixin = {
612
- _zIndex: 0,
613
- sortableChildren: !1,
614
- sortDirty: !1
615
- }, measureMixin = {
534
+ }, pe = {
616
535
  _localBoundsCacheData: null,
617
- _setWidth(n, j) {
618
- let M = Math.sign(this.scale.x) || 1;
619
- j === 0 ? this.scale.x = M : this.scale.x = n / j * M;
536
+ _setWidth(e, t) {
537
+ let n = Math.sign(this.scale.x) || 1;
538
+ t === 0 ? this.scale.x = n : this.scale.x = e / t * n;
620
539
  },
621
- _setHeight(n, j) {
622
- let M = Math.sign(this.scale.y) || 1;
623
- j === 0 ? this.scale.y = M : this.scale.y = n / j * M;
540
+ _setHeight(e, t) {
541
+ let n = Math.sign(this.scale.y) || 1;
542
+ t === 0 ? this.scale.y = n : this.scale.y = e / t * n;
624
543
  },
625
544
  getLocalBounds() {
626
545
  this._localBoundsCacheData || (this._localBoundsCacheData = {
627
546
  data: [],
628
547
  index: 1,
629
548
  didChange: !1,
630
- localBounds: new Bounds()
549
+ localBounds: new w()
631
550
  });
632
- let n = this._localBoundsCacheData;
633
- return n.index = 1, n.didChange = !1, n.data[0] !== this._didViewChangeTick && (n.didChange = !0, n.data[0] = this._didViewChangeTick), checkChildrenDidChange(this, n), n.didChange && getLocalBounds(this, n.localBounds), n.localBounds;
551
+ let e = this._localBoundsCacheData;
552
+ return e.index = 1, e.didChange = !1, e.data[0] !== this._didViewChangeTick && (e.didChange = !0, e.data[0] = this._didViewChangeTick), me(this, e), e.didChange && O(this, e.localBounds), e.localBounds;
634
553
  }
635
554
  };
636
- function checkChildrenDidChange(n, j) {
637
- let M = n.children;
638
- for (let n = 0; n < M.length; ++n) {
639
- let N = M[n], P = N.uid, F = (N._didViewChangeTick & 65535) << 16 | N._didContainerChangeTick & 65535, I = j.index;
640
- (j.data[I] !== P || j.data[I + 1] !== F) && (j.data[I] = P, j.data[I + 1] = F, j.didChange = !0), j.index += 2, N.children.length && checkChildrenDidChange(N, j);
555
+ function me(e, t) {
556
+ let n = e.children;
557
+ for (let e = 0; e < n.length; ++e) {
558
+ let r = n[e], i = r.uid, a = (r._didViewChangeTick & 65535) << 16 | r._didContainerChangeTick & 65535, o = t.index;
559
+ (t.data[o] !== i || t.data[o + 1] !== a) && (t.data[o] = i, t.data[o + 1] = a, t.didChange = !0), t.index += 2, r.children.length && me(r, t);
641
560
  }
642
- return j.didChange;
561
+ return t.didChange;
643
562
  }
644
- const childrenHelperMixin = { removeChildren(n = 0, j) {
645
- let M = j == null ? this.children.length : j, N = M - n, P = [];
646
- if (N > 0 && N <= M) {
647
- for (let j = M - 1; j >= n; --j) {
648
- let n = this.children[j];
649
- n && (P.push(n), n.parent = null);
563
+ //#endregion
564
+ //#region lib/scene/container/mixins/sortMixin.ts
565
+ var he = {
566
+ _zIndex: 0,
567
+ sortableChildren: !1,
568
+ sortDirty: !1
569
+ }, ge = class {
570
+ constructor() {
571
+ f(this, "instructions", []), f(this, "instructionSize", 0), f(this, "renderPipes", void 0);
572
+ }
573
+ reset() {
574
+ this.instructionSize = 0;
575
+ }
576
+ add(e) {
577
+ this.instructions[this.instructionSize++] = e;
578
+ }
579
+ }, _e = class {
580
+ constructor(e) {
581
+ f(this, "worldTransform", new _()), f(this, "localTransform", new _()), f(this, "root", null), f(this, "instructionSet", new ge()), f(this, "structureDidChange", !0), f(this, "renderGroupParent", null), f(this, "renderGroupChildren", []), f(this, "childrenToUpdate", Object.create(null)), f(this, "childrenRenderablesToUpdate", {
582
+ list: [],
583
+ index: 0
584
+ }), f(this, "_onRenderContainers", []), this.init(e);
585
+ }
586
+ init(e) {
587
+ this.root = e;
588
+ let t = e.children;
589
+ for (let e = 0; e < t.length; ++e) this.addChild(t[e]);
590
+ }
591
+ addChild(e) {
592
+ if (this.structureDidChange = !0, e.parentRenderGroup = this, e.parent === this.root ? e.relativeRenderGroupDepth = 1 : e.relativeRenderGroupDepth = e.parent.relativeRenderGroupDepth + 1, e.didChange = !0, this.onChildUpdate(e), e.renderGroup) {
593
+ this.addRenderGroupChild(e.renderGroup);
594
+ return;
650
595
  }
651
- removeItems(this.children, n, M);
652
- let j = this.renderGroup || this.parentRenderGroup;
653
- return j && j.removeChildren(P), P.length > 0 && this._didViewChangeTick++, P;
654
- } else if (N === 0 && this.children.length === 0) return P;
655
- throw Error("removeChildren: numeric values are outside the acceptable range.");
656
- } };
657
- function removeItems(n, j, M) {
658
- let N = n.length, P;
659
- if (j >= N || M === 0) return;
660
- M = j + M > N ? N - j : M;
661
- let F = N - M;
662
- for (P = j; P < F; ++P) n[P] = n[P + M];
663
- n.length = F;
596
+ e._onRender && this.addOnRender(e);
597
+ let t = e.children;
598
+ for (let e = 0; e < t.length; ++e) this.addChild(t[e]);
599
+ }
600
+ removeChild(e) {
601
+ if (this.structureDidChange = !0, e.parentRenderGroup = null, e.renderGroup) {
602
+ this._removeRenderGroupChild(e.renderGroup);
603
+ return;
604
+ }
605
+ let t = e.children;
606
+ for (let e = 0; e < t.length; ++e) this.removeChild(t[e]);
607
+ }
608
+ removeChildren(e) {
609
+ for (let t = 0; t < e.length; ++t) this.removeChild(e[t]);
610
+ }
611
+ addRenderGroupChild(e) {
612
+ e.renderGroupParent && e.renderGroupParent._removeRenderGroupChild(e), e.renderGroupParent = this, this.renderGroupChildren.push(e);
613
+ }
614
+ _removeRenderGroupChild(e) {
615
+ let t = this.renderGroupChildren.indexOf(e);
616
+ t > -1 && this.renderGroupChildren.splice(t, 1), e.renderGroupParent = null;
617
+ }
618
+ addOnRender(e) {
619
+ this._onRenderContainers.push(e);
620
+ }
621
+ removeOnRender(e) {
622
+ this._onRenderContainers.splice(this._onRenderContainers.indexOf(e), 1);
623
+ }
624
+ runOnRender(e) {
625
+ for (let t = 0; t < this._onRenderContainers.length; ++t) this._onRenderContainers[t]._onRender(e);
626
+ }
627
+ onChildViewUpdate(e) {
628
+ this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++] = e;
629
+ }
630
+ onChildUpdate(e) {
631
+ let t = this.childrenToUpdate[e.relativeRenderGroupDepth];
632
+ t || (t = this.childrenToUpdate[e.relativeRenderGroupDepth] = {
633
+ index: 0,
634
+ list: []
635
+ }), t.list[t.index++] = e;
636
+ }
637
+ updateRenderable(e) {
638
+ e.globalDisplayStatus < 7 || (this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e), e.didViewUpdate = !1);
639
+ }
640
+ destroy() {
641
+ this.root = null, this.childrenRenderablesToUpdate = null, this.childrenToUpdate = null, this._onRenderContainers = null, this.renderGroupChildren = null, this.instructionSet = null;
642
+ }
643
+ };
644
+ //#endregion
645
+ //#region lib/scene/container/utils.ts
646
+ function ve(e, t) {
647
+ t || (t = 0);
648
+ for (let n = t; n < e.length && e[n]; ++n) e[n] = null;
649
+ }
650
+ function ye(e, t, n = {}) {
651
+ for (let r in t) !n[r] && t[r] !== void 0 && (e[r] = t[r]);
664
652
  }
665
- const UPDATE_COLOR = 1, UPDATE_BLEND = 2, UPDATE_VISIBLE = 4, UPDATE_TRANSFORM = 8;
666
- var defaultSkew = new ObservablePoint(null), defaultOrigin = new ObservablePoint(null), defaultScale = new ObservablePoint(null, 1, 1), defaultPivot = new ObservablePoint(null), Container = class extends eventemitter3_default {
667
- constructor(n = {}) {
668
- var j, M;
669
- super(), this.uid = uid("renderable"), this.destroyed = !1, this.renderGroup = null, this.parentRenderGroup = null, this.parent = null, this.eventMode = "passive", this.hitArea = null, this._position = new ObservablePoint(this, 0, 0), this.includeInBuild = !0, this.didChange = !1, this.didViewUpdate = !1, this.isSimple = !0, this.measurable = !0, this.relativeRenderGroupDepth = 0, this._didViewChangeTick = 0, this._didContainerChangeTick = 0, this._localTransformUpdateTick = 0, this._updateFlags = 15, this.localDisplayStatus = 7, this.globalDisplayStatus = 7, this.children = [], this.localTransform = new Matrix(), this.relativeGroupTransform = new Matrix(), this.groupTransform = this.relativeGroupTransform, this._rotation = 0, this._cx = 1, this._sx = 0, this._cy = 0, this._sy = 1, this._skew = defaultSkew, this._scale = defaultScale, this._origin = defaultOrigin, this._pivot = defaultPivot, this.localAlpha = 1, this.groupColor = 16777215, this.localColor = 16777215, this.groupAlpha = 1, this.groupColorAlpha = 4294967295, assignWithIgnore(this, n, {
653
+ //#endregion
654
+ //#region lib/scene/container/Container.ts
655
+ var be = 1, xe = 2, Se = 4, Ce = 8, k = new C(null), A = new C(null), j = new C(null, 1, 1), M = new C(null), N = class extends c {
656
+ constructor(e = {}) {
657
+ var t, n;
658
+ super(), f(this, "uid", D("renderable")), f(this, "label", void 0), f(this, "destroyed", !1), f(this, "renderGroup", null), f(this, "parentRenderGroup", null), f(this, "parent", null), f(this, "eventMode", "passive"), f(this, "hitArea", null), f(this, "boundsArea", void 0), f(this, "_position", new C(this, 0, 0)), f(this, "includeInBuild", !0), f(this, "renderPipeId", void 0), f(this, "didChange", !1), f(this, "didViewUpdate", !1), f(this, "isSimple", !0), f(this, "measurable", !0), f(this, "relativeRenderGroupDepth", 0), f(this, "_didViewChangeTick", 0), f(this, "_didContainerChangeTick", 0), f(this, "_localTransformUpdateTick", 0), f(this, "_updateFlags", 15), f(this, "localDisplayStatus", 7), f(this, "globalDisplayStatus", 7), f(this, "children", []), f(this, "localTransform", new _()), f(this, "relativeGroupTransform", new _()), f(this, "groupTransform", this.relativeGroupTransform), f(this, "_rotation", 0), f(this, "_worldTransform", void 0), f(this, "_cx", 1), f(this, "_sx", 0), f(this, "_cy", 0), f(this, "_sy", 1), f(this, "_skew", k), f(this, "_scale", j), f(this, "_origin", A), f(this, "_pivot", M), f(this, "localAlpha", 1), f(this, "groupColor", 16777215), f(this, "localColor", 16777215), f(this, "groupAlpha", 1), f(this, "groupColorAlpha", 4294967295), ye(this, e, {
670
659
  children: !0,
671
660
  parent: !0,
672
661
  effects: !0
673
- }), (j = n.children) == null || j.forEach((n) => this.addChild(n)), (M = n.parent) == null || M.addChild(this), this.effects = [];
662
+ }), (t = e.children) == null || t.forEach((e) => this.addChild(e)), (n = e.parent) == null || n.addChild(this), this.effects = [];
674
663
  }
675
664
  get renderable() {
676
665
  return !!(this.localDisplayStatus & 1);
677
666
  }
678
- set renderable(n) {
679
- let j = n ? 1 : 0;
680
- (this.localDisplayStatus & 1) !== j && (this._updateFlags |= 4, this.localDisplayStatus ^= 1, this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._onUpdate());
667
+ set renderable(e) {
668
+ let t = +!!e;
669
+ (this.localDisplayStatus & 1) !== t && (this._updateFlags |= 4, this.localDisplayStatus ^= 1, this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._onUpdate());
681
670
  }
682
671
  get visible() {
683
672
  return !!(this.localDisplayStatus & 2);
684
673
  }
685
- set visible(n) {
686
- let j = n ? 2 : 0;
687
- (this.localDisplayStatus & 2) !== j && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 2, this._onUpdate(), this.emit("visibleChanged", n));
674
+ set visible(e) {
675
+ let t = e ? 2 : 0;
676
+ (this.localDisplayStatus & 2) !== t && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0), this._updateFlags |= 4, this.localDisplayStatus ^= 2, this._onUpdate(), this.emit("visibleChanged", e));
688
677
  }
689
678
  get isRenderGroup() {
690
679
  return !!this.renderGroup;
691
680
  }
692
- set isRenderGroup(n) {
693
- !!this.renderGroup !== n && (n ? this.enableRenderGroup() : this.disableRenderGroup());
681
+ set isRenderGroup(e) {
682
+ !!this.renderGroup !== e && (e ? this.enableRenderGroup() : this.disableRenderGroup());
694
683
  }
695
684
  get zIndex() {
696
685
  return this._zIndex;
697
686
  }
698
- set zIndex(n) {
699
- n !== this._zIndex && (this._zIndex = n, this.depthOfChildModified());
687
+ set zIndex(e) {
688
+ e !== this._zIndex && (this._zIndex = e, this.depthOfChildModified());
700
689
  }
701
690
  _updateIsSimple() {
702
- this.isSimple = !this.renderGroup && this.effects.length == 0;
691
+ this.isSimple = !this.renderGroup && this.effects.length === 0;
703
692
  }
704
693
  sortChildren() {
705
- this.sortDirty && (this.sortDirty = !1, this.children.sort(sortChildren));
694
+ this.sortDirty && (this.sortDirty = !1, this.children.sort(Te));
706
695
  }
707
696
  depthOfChildModified() {
708
697
  this.parent && (this.parent.sortableChildren = !0, this.parent.sortDirty = !0), this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0);
709
698
  }
710
699
  enableRenderGroup() {
711
700
  if (this.renderGroup) return;
712
- let n = this.parentRenderGroup;
713
- n == null || n.removeChild(this), this.renderGroup = new RenderGroup(this), this.groupTransform = new Matrix(), n == null || n.addChild(this), this._updateIsSimple();
701
+ let e = this.parentRenderGroup;
702
+ e == null || e.removeChild(this), this.renderGroup = new _e(this), this.groupTransform = _.IDENTITY, e == null || e.addChild(this), this._updateIsSimple();
714
703
  }
715
704
  disableRenderGroup() {
716
705
  if (!this.renderGroup) return;
717
- let n = this.parentRenderGroup;
718
- n == null || n.removeChild(this), this.renderGroup = null, this.groupTransform = this.relativeGroupTransform, n == null || n.addChild(this), this._updateIsSimple();
706
+ let e = this.parentRenderGroup;
707
+ e == null || e.removeChild(this), this.renderGroup = null, this.groupTransform = this.relativeGroupTransform, e == null || e.addChild(this), this._updateIsSimple();
719
708
  }
720
- collectRenderables(n, j) {
721
- this.globalDisplayStatus < 7 || !this.includeInBuild || (this.sortableChildren && this.sortChildren(), this.isSimple ? this.collectRenderableSimple(n, j) : this.renderGroup || this.collectRenderablesWithEffects(n, j));
709
+ collectRenderables(e, t) {
710
+ this.globalDisplayStatus < 7 || !this.includeInBuild || (this.sortableChildren && this.sortChildren(), this.isSimple ? this.collectRenderableSimple(e, t) : this.renderGroup || this.collectRenderablesWithEffects(e, t));
722
711
  }
723
- collectRenderablesWithEffects(n, j) {
724
- for (let M = 0; M < this.effects.length; ++M) {
725
- let N = this.effects[M];
726
- n[N.pipe].push(N, j);
712
+ collectRenderablesWithEffects(e, t) {
713
+ for (let n = 0; n < this.effects.length; ++n) {
714
+ let r = this.effects[n];
715
+ e[r.pipe].push(r, t);
727
716
  }
728
- this.collectRenderableSimple(n, j);
729
- for (let M = 0; M < this.effects.length; ++M) {
730
- let N = this.effects[M];
731
- n[N.pipe].pop(N, j);
717
+ this.collectRenderableSimple(e, t);
718
+ for (let n = 0; n < this.effects.length; ++n) {
719
+ let r = this.effects[n];
720
+ e[r.pipe].pop(r, t);
732
721
  }
733
722
  }
734
- collectRenderableSimple(n, j) {
735
- let M = this.children;
736
- for (let N = 0; N < M.length; ++N) M[N].collectRenderables(n, j);
723
+ collectRenderableSimple(e, t) {
724
+ let n = this.children;
725
+ for (let r = 0; r < n.length; ++r) n[r].collectRenderables(e, t);
737
726
  }
738
- setFromMatrix(n) {
739
- n.decompose(this);
727
+ setFromMatrix(e) {
728
+ e.decompose(this);
740
729
  }
741
730
  _updateSkew() {
742
- let n = this.rotation, j = this.skew;
743
- this._cx = Math.cos(n + j.y), this._sx = Math.sin(n + j.y), this._cy = -Math.sin(n - j.x), this._sy = Math.cos(n - j.x);
731
+ let e = this.rotation, t = this.skew;
732
+ this._cx = Math.cos(e + t.y), this._sx = Math.sin(e + t.y), this._cy = -Math.sin(e - t.x), this._sy = Math.cos(e - t.x);
744
733
  }
745
734
  updateLocalTransform() {
746
- let n = this._didContainerChangeTick;
747
- if (this._localTransformUpdateTick === n) return;
748
- this._localTransformUpdateTick = n, this._updateSkew();
749
- let j = this.position, M = this.localTransform, N = this._scale.x, P = this._scale.y, F = -this._origin.x, I = -this._origin.y, L = this._pivot.x, R = this._pivot.y;
750
- M.a = this._cx * N, M.b = this._sx * N, M.c = this._cy * P, M.d = this._sy * P, M.tx = j.x - (L * M.a + R * M.c) + (F * M.a + I * M.c) - F, M.ty = j.y - (L * M.b + R * M.d) + (F * M.b + I * M.d) - I;
735
+ let e = this._didContainerChangeTick;
736
+ if (this._localTransformUpdateTick === e) return;
737
+ this._localTransformUpdateTick = e, this._updateSkew();
738
+ let t = this.position, n = this.localTransform, r = this._scale.x, i = this._scale.y, a = -this._origin.x, o = -this._origin.y, s = this._pivot.x, c = this._pivot.y;
739
+ n.a = this._cx * r, n.b = this._sx * r, n.c = this._cy * i, n.d = this._sy * i, n.tx = t.x - (s * n.a + c * n.c) + (a * n.a + o * n.c) - a, n.ty = t.y - (s * n.b + c * n.d) + (a * n.b + o * n.d) - o;
751
740
  }
752
741
  get alpha() {
753
742
  return this.localAlpha;
754
743
  }
755
- set alpha(n) {
756
- n !== this.localAlpha && (this.localAlpha = n, this._updateFlags |= 1, this._onUpdate());
744
+ set alpha(e) {
745
+ e !== this.localAlpha && (this.localAlpha = e, this._updateFlags |= 1, this._onUpdate());
757
746
  }
758
747
  get root() {
759
- let n = this.parent, j = this.parent;
760
- for (; n;) n.parent || (j = n), n = n.parent;
761
- return j;
748
+ let e = this.parent, t = this.parent;
749
+ for (; e;) e.parent || (t = e), e = e.parent;
750
+ return t;
762
751
  }
763
752
  get worldTransform() {
764
- return this._worldTransform || (this._worldTransform = new Matrix()), this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform), this._worldTransform;
753
+ return this._worldTransform || (this._worldTransform = new _()), this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform), this._worldTransform;
765
754
  }
766
755
  get x() {
767
756
  return this._position.x;
768
757
  }
769
- set x(n) {
770
- this._position.x = n;
758
+ set x(e) {
759
+ this._position.x = e;
771
760
  }
772
761
  get position() {
773
762
  return this._position;
774
763
  }
775
- set position(n) {
776
- this._position.copyFrom(n);
764
+ set position(e) {
765
+ this._position.copyFrom(e);
777
766
  }
778
767
  get y() {
779
768
  return this._position.y;
780
769
  }
781
- set y(n) {
782
- this._position.y = n;
770
+ set y(e) {
771
+ this._position.y = e;
783
772
  }
784
773
  get rotation() {
785
774
  return this._rotation;
786
775
  }
787
- set rotation(n) {
788
- this._rotation !== n && (this._rotation = n, this._onUpdate(this._skew));
776
+ set rotation(e) {
777
+ this._rotation !== e && (this._rotation = e, this._onUpdate(this._skew));
789
778
  }
790
779
  get angle() {
791
- return this.rotation * RAD_TO_DEG;
780
+ return this.rotation * S;
792
781
  }
793
- set angle(n) {
794
- this.rotation = n * DEG_TO_RAD;
782
+ set angle(e) {
783
+ this.rotation = e * ee;
795
784
  }
796
785
  get skew() {
797
- return this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew;
786
+ return this._skew === k && (this._skew = new C(this, 0, 0)), this._skew;
798
787
  }
799
- set skew(n) {
800
- this._skew === defaultSkew && (this._skew = new ObservablePoint(this, 0, 0)), this._skew.copyFrom(n);
788
+ set skew(e) {
789
+ this._skew === k && (this._skew = new C(this, 0, 0)), this._skew.copyFrom(e);
801
790
  }
802
791
  get scale() {
803
- return this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale;
792
+ return this._scale === j && (this._scale = new C(this, 1, 1)), this._scale;
804
793
  }
805
- set scale(n) {
806
- this._scale === defaultScale && (this._scale = new ObservablePoint(this, 1, 1)), this._scale.copyFrom(n);
794
+ set scale(e) {
795
+ this._scale === j && (this._scale = new C(this, 1, 1)), this._scale.copyFrom(e);
807
796
  }
808
797
  get pivot() {
809
- return this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot;
798
+ return this._pivot === M && (this._pivot = new C(this, 0, 0)), this._pivot;
810
799
  }
811
- set pivot(n) {
812
- this._pivot === defaultPivot && (this._pivot = new ObservablePoint(this, 0, 0)), this._pivot.copyFrom(n);
800
+ set pivot(e) {
801
+ this._pivot === M && (this._pivot = new C(this, 0, 0)), this._pivot.copyFrom(e);
813
802
  }
814
803
  get origin() {
815
- return this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), this._origin;
804
+ return this._origin === A && (this._origin = new C(this, 0, 0)), this._origin;
816
805
  }
817
- set origin(n) {
818
- this._origin === defaultOrigin && (this._origin = new ObservablePoint(this, 0, 0)), typeof n == "number" ? this._origin.set(n) : this._origin.copyFrom(n);
806
+ set origin(e) {
807
+ this._origin === A && (this._origin = new C(this, 0, 0)), typeof e == "number" ? this._origin.set(e) : this._origin.copyFrom(e);
819
808
  }
820
809
  get width() {
821
810
  return Math.abs(this.scale.x * this.getLocalBounds().width);
822
811
  }
823
- set width(n) {}
812
+ set width(e) {}
824
813
  get height() {
825
814
  return Math.abs(this.scale.y * this.getLocalBounds().height);
826
815
  }
827
- set height(n) {}
828
- addChild(...n) {
829
- if (n.length > 1) {
830
- for (let j = 0; j < n.length; ++j) this.addChild(n[j]);
831
- return n[0];
816
+ set height(e) {}
817
+ addChild(...e) {
818
+ if (e.length > 1) {
819
+ for (let t = 0; t < e.length; ++t) this.addChild(e[t]);
820
+ return e[0];
832
821
  }
833
- let j = n[0], M = this.renderGroup || this.parentRenderGroup;
834
- return j.parent === this ? (this.children.splice(this.children.indexOf(j), 1), this.children.push(j), M && (M.structureDidChange = !0), j) : (this.sortableChildren && (this.sortDirty = !0), j.parent && j.parent.removeChild(j), this.children.push(j), this.sortableChildren && (this.sortDirty = !0), j.parent = this, j.didChange = !0, j._updateFlags = 7, M && M.addChild(j), this._didViewChangeTick++, j._zIndex != 0 && j.depthOfChildModified(), j);
822
+ let t = e[0], n = this.renderGroup || this.parentRenderGroup;
823
+ return t.parent === this ? (this.children.splice(this.children.indexOf(t), 1), this.children.push(t), n && (n.structureDidChange = !0), t) : (this.sortableChildren && (this.sortDirty = !0), t.parent && t.parent.removeChild(t), this.children.push(t), this.sortableChildren && (this.sortDirty = !0), t.parent = this, t.didChange = !0, t._updateFlags = 7, n && n.addChild(t), this._didViewChangeTick++, t._zIndex !== 0 && t.depthOfChildModified(), t);
835
824
  }
836
- removeChild(...n) {
837
- if (n.length > 1) {
838
- for (let j = 0; j < n.length; ++j) this.removeChild(n[j]);
839
- return n[0];
825
+ removeChild(...e) {
826
+ if (e.length > 1) {
827
+ for (let t = 0; t < e.length; ++t) this.removeChild(e[t]);
828
+ return e[0];
840
829
  }
841
- let j = n[0];
842
- if (!j) return j;
843
- let M = this.children.indexOf(j);
844
- return M > -1 && (this._didViewChangeTick++, this.children.splice(M, 1), this.renderGroup ? this.renderGroup.removeChild(j) : this.parentRenderGroup && this.parentRenderGroup.removeChild(j), j.parent = null), j;
830
+ let t = e[0];
831
+ if (!t) return t;
832
+ let n = this.children.indexOf(t);
833
+ return n > -1 && (this._didViewChangeTick++, this.children.splice(n, 1), this.renderGroup ? this.renderGroup.removeChild(t) : this.parentRenderGroup && this.parentRenderGroup.removeChild(t), t.parent = null), t;
845
834
  }
846
- _onUpdate(n) {
847
- n && n === this._skew && this._updateSkew(), this._didContainerChangeTick++, !this.didChange && (this.didChange = !0, this.parentRenderGroup && this.parentRenderGroup.onChildUpdate(this));
835
+ _onUpdate(e) {
836
+ e && e === this._skew && this._updateSkew(), this._didContainerChangeTick++, !this.didChange && (this.didChange = !0, this.parentRenderGroup && this.parentRenderGroup.onChildUpdate(this));
848
837
  }
849
- toGlobal(n, j) {
850
- return this.getGlobalTransform(j).apply(n);
838
+ toGlobal(e, t, n) {
839
+ let r = this.getGlobalTransform(T.get(), n);
840
+ return t = r.apply(e, t), T.return(r), t;
851
841
  }
852
- toLocal(n, j, M) {
853
- let N;
854
- return j && (N = j.toGlobal(n)), N = this.getGlobalTransform(M).applyInverse(n), N;
842
+ toLocal(e, t, n, r) {
843
+ t && (e = t.toGlobal(e, n, r));
844
+ let i = this.getGlobalTransform(T.get(), r);
845
+ return n = i.applyInverse(e, n), T.return(i), n;
855
846
  }
856
- getGlobalTransform(n = !1) {
857
- if (n) return this.worldTransform.clone();
847
+ getGlobalTransform(e = new _(), t = !1) {
848
+ if (t) return this.worldTransform.clone();
858
849
  this.updateLocalTransform();
859
- let j = new Matrix(), M = updateTransformBackwards(this, j);
860
- return j.appendFrom(this.localTransform, M), j;
850
+ let n = we(this, T.get().identity());
851
+ return e.appendFrom(this.localTransform, n), T.return(n), e;
861
852
  }
862
- getGlobalPosition(n = !1) {
863
- return this.parent ? this.parent.toGlobal(this._position, n) : this._position.toVector2();
853
+ getGlobalPosition(e = new b(), t = !1) {
854
+ return this.parent ? this.parent.toGlobal(this._position, e, t) : (e.x = this._position.x, e.y = this._position.y), e;
864
855
  }
865
- destroy(n = !1) {
866
- var j, M;
856
+ destroy(e = !1) {
857
+ var t, n;
867
858
  if (this.destroyed) return;
868
859
  this.destroyed = !0;
869
- let N;
870
- if (this.children.length && (N = this.removeChildren(0, this.children.length)), (j = this.parent) == null || j.removeChild(this), this.parent = null, this._maskEffect = null, this.effects = null, this._position = null, this._scale = null, this._pivot = null, this._origin = null, this._skew = null, (typeof n == "boolean" ? n : n != null && n.children) && N) for (let j = 0; j < N.length; ++j) N[j].destroy(n);
871
- (M = this.renderGroup) == null || M.destroy(), this.renderGroup = null;
860
+ let r;
861
+ if (this.children.length && (r = this.removeChildren(0, this.children.length)), (t = this.parent) == null || t.removeChild(this), this.parent = null, this._maskEffect = null, this.effects = null, this._position = null, this._scale = null, this._pivot = null, this._origin = null, this._skew = null, (typeof e == "boolean" ? e : e != null && e.children) && r) for (let t = 0; t < r.length; ++t) r[t].destroy(e);
862
+ (n = this.renderGroup) == null || n.destroy(), this.renderGroup = null;
872
863
  }
873
864
  };
874
- function updateTransformBackwards(n, j) {
875
- let M = n.parent;
876
- if (M) {
877
- updateTransformBackwards(M, j), M.updateLocalTransform();
878
- let n = Matrix.append(j, M.localTransform);
879
- j.copyFrom(n);
880
- }
881
- return j;
865
+ function we(e, t) {
866
+ let n = e.parent;
867
+ if (n) {
868
+ we(n, t), n.updateLocalTransform();
869
+ let e = _.append(t, n.localTransform);
870
+ t.copyFrom(e);
871
+ }
872
+ return t;
882
873
  }
883
- function sortChildren(n, j) {
884
- return n._zIndex - j._zIndex;
874
+ function Te(e, t) {
875
+ return e._zIndex - t._zIndex;
885
876
  }
886
- applyMixins(Container, sortMixin, effectMixin, measureMixin, childrenHelperMixin);
887
- var UPDATE_BLEND_COLOR_VISIBLE = 7;
888
- function updateRenderGroupTransform(n, j = !1) {
889
- let M = n.root;
890
- n.worldTransform.copyFrom(M.localTransform);
891
- let N = n.childrenToUpdate;
892
- for (let j in N) {
893
- let M = Number(j), P = N[M], F = P.list, I = P.index;
894
- for (let j = 0; j < I; ++j) {
895
- let N = F[j];
896
- N.parentRenderGroup === n && N.relativeRenderGroupDepth === M && updateTransform(N, 0);
897
- }
898
- clearList(F, I), P.index = 0;
899
- }
900
- if (j) for (let M = 0; M < n.renderGroupChildren.length; ++M) updateRenderGroupTransform(n.renderGroupChildren[M], j);
901
- }
902
- function updateTransform(n, j) {
903
- n.didChange = !1;
904
- let M = n.parent, N = n.localTransform;
905
- n.updateLocalTransform(), M && (j |= n._updateFlags, n.relativeGroupTransform.appendFrom(N, M.relativeGroupTransform), j & UPDATE_BLEND_COLOR_VISIBLE && updateBlendColorVisible(n, M, j));
906
- let P = n.children;
907
- for (let n = 0; n < P.length; n++) updateTransform(P[n], j);
908
- }
909
- function updateBlendColorVisible(n, j, M) {
910
- if (M & 1) {
911
- n.groupColor = j.groupColor;
912
- let M = n.localAlpha * j.groupAlpha;
913
- M = M < 0 ? 0 : M > 1 ? 1 : M, n.groupAlpha = M, n.groupColorAlpha = n.groupColor + ((M * 255 | 0) << 24);
914
- }
915
- M & 4 && (n.globalDisplayStatus = n.localDisplayStatus & j.globalDisplayStatus), n._updateFlags = 0;
916
- }
917
- function validateRenderables(n, j) {
918
- let { list: M, index: N } = n.childrenRenderablesToUpdate, P = !1;
919
- for (let n = 0; n < N; ++n) {
920
- let N = M[n];
921
- if (P = j[N.renderPipeId].validateRenderable(N), P) break;
922
- }
923
- return n.structureDidChange = P, P;
924
- }
925
- var _RenderGroupSystem, RenderGroupSystem = class {
926
- constructor(n) {
927
- this.renderer = n;
928
- }
929
- _updateRenderGroup(n) {
930
- let j = this.renderer, M = j.renderPipes;
931
- n.runOnRender(j), n.instructionSet.renderPipes = M, n.structureDidChange ? clearList(n.childrenRenderablesToUpdate.list, 0) : validateRenderables(n, M), updateRenderGroupTransform(n), n.structureDidChange && (n.structureDidChange = !1, this._buildInstructions(n, j)), n.childrenRenderablesToUpdate.index = 0;
932
- }
933
- render({ container: n, transform: j }) {
934
- let M = this.renderer;
935
- j && n.renderGroup.localTransform.copyFrom(j), M.canvasContext.globalTransform = j ? n.renderGroup.localTransform : n.renderGroup.worldTransform, this._updateRenderGroup(n.renderGroup), executeInstructions(n.renderGroup, M.renderPipes);
936
- }
937
- _buildInstructions(n, j) {
938
- let M = j.renderPipes, N = n.root;
939
- n.instructionSet.reset(), N.sortableChildren && N.sortChildren(), M.batch.buildStart(), N.collectRenderablesWithEffects(M, n.instructionSet), M.batch.buildEnd(n.instructionSet);
940
- }
941
- };
942
- _RenderGroupSystem = RenderGroupSystem, _RenderGroupSystem.desc = { name: "renderGroup" };
943
- function executeInstructions(n, j) {
944
- let { instructionSet: M } = n, N = M.instructions;
945
- for (let n = 0; n < M.instructionSize; n++) {
946
- let M = N[n];
947
- j[M.renderPipeId].execute(M);
948
- }
949
- }
950
- var _SpritePipe, SpritePipe = class {
951
- constructor(n) {
952
- this._renderer = n;
953
- }
954
- addRenderable(n, j) {
955
- let M = this._getRuntimeSprite(n);
956
- n.didViewUpdate && this._updateBatchableSprite(n, M), this._renderer.renderPipes.batch.addToBatch(M, j);
957
- }
958
- _updateBatchableSprite(n, j) {
959
- j.texture = n._texture, j.bounds = n.bounds;
960
- }
961
- validateRenderable(n) {
962
- return this._getRuntimeSprite(n).texture._source.uid !== n._texture._source.uid;
963
- }
964
- _getRuntimeSprite(n) {
965
- return n._runtimeData[this._renderer.uid] || this._initCacheSprite(n);
966
- }
967
- _initCacheSprite(n) {
968
- let j = {
969
- renderable: n,
970
- texture: n.texture,
971
- transform: n.relativeGroupTransform,
972
- bounds: n.bounds,
973
- roundPixels: this._renderer._roundPixels | n._roundPixels,
974
- destroy: function() {
975
- this.renderable = null, this.texture = null, this.transform = null, this.bounds = null;
976
- }
977
- };
978
- return n._runtimeData[this._renderer.uid] = j, j;
979
- }
980
- destroy() {
981
- this._renderer = null;
982
- }
983
- };
984
- _SpritePipe = SpritePipe, _SpritePipe.desc = { name: "sprite" };
985
- var _TextPipe, TextPipe = class {
986
- constructor(n) {
987
- this._renderer = n;
988
- }
989
- addRenderable(n, j) {
990
- let M = this._getRuntimeText(n);
991
- if (n._didTextUpdate) {
992
- let j = n._autoResolution ? this._renderer.resolution : n.resolution;
993
- (M.currentKey !== n.styleKey || n._resolution !== j) && this._updateRuntimeText(n), n._didTextUpdate = !1, updateBounds(M.bounds, n._anchor, M.texture);
994
- }
995
- this._renderer.renderPipes.batch.addToBatch(M, j);
996
- }
997
- validateRenderable(n) {
998
- let j = this._getRuntimeText(n), M = n.styleKey;
999
- return j.currentKey === M ? n._didTextUpdate : !0;
1000
- }
1001
- initCacheText(n) {
1002
- let j = {
1003
- currentKey: "--",
1004
- transform: n.relativeGroupTransform,
1005
- bounds: n.bounds,
1006
- roundPixels: this._renderer._roundPixels | n._roundPixels,
1007
- renderable: n,
1008
- texture: null,
1009
- destroy: function() {
1010
- this.renderable = null, this.texture = null, this.bounds = null;
1011
- }
1012
- };
1013
- return n._runtimeData[this._renderer.uid] = j, j;
1014
- }
1015
- _getRuntimeText(n) {
1016
- return n._runtimeData[this._renderer.uid] || this.initCacheText(n);
1017
- }
1018
- _updateRuntimeText(n) {
1019
- let j = this._getRuntimeText(n);
1020
- j.texture, n._resolution = n._autoResolution ? this._renderer.resolution : n.resolution, j.texture = this._renderer.text.getManagedTexture(n), j.currentKey = n.styleKey;
1021
- }
1022
- destroy() {
1023
- this._renderer = null;
1024
- }
1025
- };
1026
- _TextPipe = TextPipe, _TextPipe.desc = { name: "text" };
1027
- var ViewContainer = class extends Container {
1028
- constructor(...n) {
1029
- super(...n), this._runtimeData = Object.create(null), this._roundPixels = 0, this._bounds = new Bounds(0, 1, 0, 0), this._boundsDirty = !0;
877
+ oe(N, he, fe, pe, se);
878
+ //#endregion
879
+ //#region lib/scene/ViewContainer.ts
880
+ var P = class extends N {
881
+ constructor(...e) {
882
+ super(...e), f(this, "_runtimeData", Object.create(null)), f(this, "_resolution", void 0), f(this, "_roundPixels", 0), f(this, "_bounds", new w(0, 1, 0, 0)), f(this, "_boundsDirty", !0);
1030
883
  }
1031
884
  get bounds() {
1032
885
  return this._boundsDirty ? (this.updateBounds(), this._boundsDirty = !1, this._bounds) : this._bounds;
@@ -1034,32 +887,32 @@ var ViewContainer = class extends Container {
1034
887
  onViewUpdate() {
1035
888
  if (this._didViewChangeTick++, this._boundsDirty = !0, this.didViewUpdate) return;
1036
889
  this.didViewUpdate = !0;
1037
- let n = this.renderGroup || this.parentRenderGroup;
1038
- n && n.onChildViewUpdate(this);
890
+ let e = this.renderGroup || this.parentRenderGroup;
891
+ e && e.onChildViewUpdate(this);
1039
892
  }
1040
- collectRenderableSimple(n, j) {
1041
- let M = n[this.renderPipeId];
1042
- M && M.addRenderable && M.addRenderable(this, j), this.didViewUpdate = !1;
1043
- let N = this.children;
1044
- for (let M = 0; M < N.length; ++M) N[M].collectRenderables(n, j);
893
+ collectRenderableSimple(e, t) {
894
+ let n = e[this.renderPipeId];
895
+ n && n.addRenderable && n.addRenderable(this, t), this.didViewUpdate = !1;
896
+ let r = this.children;
897
+ for (let n = 0; n < r.length; ++n) r[n].collectRenderables(e, t);
1045
898
  }
1046
- containsPoint(n) {
1047
- let j = this.bounds, { x: M, y: N } = n;
1048
- return M > j.minX && M < j.maxX && N > j.minY && N < j.maxY;
899
+ containsPoint(e) {
900
+ let t = this.bounds, { x: n, y: r } = e;
901
+ return n > t.minX && n < t.maxX && r > t.minY && r < t.maxY;
1049
902
  }
1050
903
  get roundPixels() {
1051
904
  return !!this._roundPixels;
1052
905
  }
1053
- set roundPixels(n) {
1054
- this._roundPixels = n ? 1 : 0;
906
+ set roundPixels(e) {
907
+ this._roundPixels = +!!e;
1055
908
  }
1056
- destroy(n = !1) {
1057
- for (let n in this._runtimeData) this._runtimeData[n].destroy();
1058
- this._runtimeData = Object.create(null), this.onViewUpdate(), super.destroy(n), this._bounds = null;
909
+ destroy(e = !1) {
910
+ for (let e in this._runtimeData) this._runtimeData[e].destroy();
911
+ this._runtimeData = Object.create(null), this.onViewUpdate(), super.destroy(e), this._bounds = null;
1059
912
  }
1060
- }, Polygon = class {
913
+ }, Ee = class {
1061
914
  constructor() {
1062
- this.points = [], this.type = "polygon";
915
+ f(this, "points", []), f(this, "closePath", void 0), f(this, "type", "polygon");
1063
916
  }
1064
917
  construction() {}
1065
918
  get lastX() {
@@ -1068,171 +921,153 @@ var ViewContainer = class extends Container {
1068
921
  get lastY() {
1069
922
  return this.points[this.points.length - 1];
1070
923
  }
1071
- getBounds() {
1072
- let n = new Rectangle(), j = this.points, M = Infinity, N = Infinity, P = -Infinity, F = -Infinity;
1073
- for (let n = 0; n < j.length; n += 2) {
1074
- let I = j[n], L = j[n + 1];
1075
- M = Math.min(M, I), N = Math.min(N, L), P = Math.max(P, I), F = Math.max(F, L);
924
+ strokeContains(e, t, n, r = .5) {
925
+ let i = n * n, a = i * (1 - r), o = i - a, { points: s } = this, c = s.length - (this.closePath ? 0 : 2);
926
+ for (let n = 0; n < c; n += 2) {
927
+ let r = s[n], i = s[n + 1], c = s[(n + 2) % s.length], l = s[(n + 3) % s.length];
928
+ if (ie(e, t, r, i, c, l) <= (Math.sign((c - r) * (t - i) - (l - i) * (e - r)) < 0 ? o : a)) return !0;
1076
929
  }
1077
- return n.x = M, n.width = P - M, n.y = N, n.height = F - N, n;
930
+ return !1;
1078
931
  }
1079
- }, RECURSION_LIMIT = 8, FLT_EPSILON = 1.1920929e-7, PATH_DISTANCE_EPSILON = 1, curveAngleToleranceEpsilon = .01, mAngleTolerance = 0, mCuspLimit = 0;
1080
- function buildAdaptiveBezier(n, j, M, N, P, F, I, L, R, z) {
1081
- let B = (PATH_DISTANCE_EPSILON - Math.min(.99, Math.max(0, z == null ? .5 : z))) / 1;
1082
- return B *= B, begin(j, M, N, P, F, I, L, R, n, B), n;
932
+ contains(e, t) {
933
+ let n = !1, r = this.points.length / 2;
934
+ for (let i = 0, a = r - 1; i < r; a = i++) {
935
+ let r = this.points[i * 2], o = this.points[i * 2 + 1], s = this.points[a * 2], c = this.points[a * 2 + 1];
936
+ o > t != c > t && e < (s - r) * ((t - o) / (c - o)) + r && (n = !n);
937
+ }
938
+ return n;
939
+ }
940
+ getBounds(e) {
941
+ e || (e = new y());
942
+ let t = this.points, n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
943
+ for (let e = 0; e < t.length; e += 2) {
944
+ let o = t[e], s = t[e + 1];
945
+ n = o < n ? o : n, r = s < r ? s : r, i = o > i ? o : i, a = s > a ? s : a;
946
+ }
947
+ return e.x = n, e.width = i - n, e.y = r, e.height = a - r, e;
948
+ }
949
+ }, De = 8, F = 1.1920929e-7, Oe = 1;
950
+ function ke(e, t, n, r, i, a, o, s, c, l) {
951
+ let u = (Oe - Math.min(.99, Math.max(0, l == null ? .5 : l))) / 1;
952
+ return u *= u, Ae(t, n, r, i, a, o, s, c, e, u), e;
1083
953
  }
1084
- function begin(n, j, M, N, P, F, I, L, R, z) {
1085
- recursive(n, j, M, N, P, F, I, L, R, z, 0), R.push(I, L);
954
+ function Ae(e, t, n, r, i, a, o, s, c, l) {
955
+ I(e, t, n, r, i, a, o, s, c, l, 0), c.push(o, s);
1086
956
  }
1087
- function recursive(n, j, M, N, P, F, I, L, R, z, B) {
1088
- if (B > RECURSION_LIMIT) return;
1089
- let V = Math.PI, H = (n + M) / 2, U = (j + N) / 2, W = (M + P) / 2, G = (N + F) / 2, K = (P + I) / 2, q = (F + L) / 2, J = (H + W) / 2, Y = (U + G) / 2, X = (W + K) / 2, Z = (G + q) / 2, Q = (J + X) / 2, $ = (Y + Z) / 2;
1090
- if (B > 0) {
1091
- let B = I - n, H = L - j, U = Math.abs((M - I) * H - (N - L) * B), W = Math.abs((P - I) * H - (F - L) * B), G, K;
1092
- if (U > FLT_EPSILON && W > FLT_EPSILON) {
1093
- if ((U + W) * (U + W) <= z * (B * B + H * H)) {
1094
- if (mAngleTolerance < curveAngleToleranceEpsilon) {
1095
- R.push(Q, $);
1096
- return;
1097
- }
1098
- let z = Math.atan2(F - N, P - M);
1099
- if (G = Math.abs(z - Math.atan2(N - j, M - n)), K = Math.abs(Math.atan2(L - F, I - P) - z), G >= V && (G = 2 * V - G), K >= V && (K = 2 * V - K), G + K < mAngleTolerance) {
1100
- R.push(Q, $);
1101
- return;
1102
- }
1103
- if (mCuspLimit !== 0) {
1104
- if (G > mCuspLimit) {
1105
- R.push(M, N);
1106
- return;
1107
- }
1108
- if (K > mCuspLimit) {
1109
- R.push(P, F);
1110
- return;
1111
- }
1112
- }
957
+ function I(e, t, n, r, i, a, o, s, c, l, u) {
958
+ if (u > De) return;
959
+ let d = (e + n) / 2, f = (t + r) / 2, p = (n + i) / 2, m = (r + a) / 2, h = (i + o) / 2, g = (a + s) / 2, _ = (d + p) / 2, v = (f + m) / 2, y = (p + h) / 2, b = (m + g) / 2, x = (_ + y) / 2, S = (v + b) / 2;
960
+ if (u > 0) {
961
+ let u = o - e, d = s - t, f = Math.abs((n - o) * d - (r - s) * u), p = Math.abs((i - o) * d - (a - s) * u);
962
+ if (f > F && p > F) {
963
+ if ((f + p) * (f + p) <= l * (u * u + d * d)) {
964
+ c.push(x, S);
965
+ return;
1113
966
  }
1114
- } else if (U > FLT_EPSILON) {
1115
- if (U * U <= z * (B * B + H * H)) {
1116
- if (mAngleTolerance < curveAngleToleranceEpsilon) {
1117
- R.push(Q, $);
1118
- return;
1119
- }
1120
- if (G = Math.abs(Math.atan2(F - N, P - M) - Math.atan2(N - j, M - n)), G >= V && (G = 2 * V - G), G < mAngleTolerance) {
1121
- R.push(M, N), R.push(P, F);
1122
- return;
1123
- }
1124
- if (mCuspLimit !== 0 && G > mCuspLimit) {
1125
- R.push(M, N);
1126
- return;
1127
- }
967
+ } else if (f > F) {
968
+ if (f * f <= l * (u * u + d * d)) {
969
+ c.push(x, S);
970
+ return;
1128
971
  }
1129
- } else if (W > FLT_EPSILON) {
1130
- if (W * W <= z * (B * B + H * H)) {
1131
- if (mAngleTolerance < curveAngleToleranceEpsilon) {
1132
- R.push(Q, $);
1133
- return;
1134
- }
1135
- if (G = Math.abs(Math.atan2(L - F, I - P) - Math.atan2(F - N, P - M)), G >= V && (G = 2 * V - G), G < mAngleTolerance) {
1136
- R.push(M, N), R.push(P, F);
1137
- return;
1138
- }
1139
- if (mCuspLimit !== 0 && G > mCuspLimit) {
1140
- R.push(P, F);
1141
- return;
1142
- }
972
+ } else if (p > F) {
973
+ if (p * p <= l * (u * u + d * d)) {
974
+ c.push(x, S);
975
+ return;
1143
976
  }
1144
- } else if (B = Q - (n + I) / 2, H = $ - (j + L) / 2, B * B + H * H <= z) {
1145
- R.push(Q, $);
977
+ } else if (u = x - (e + o) / 2, d = S - (t + s) / 2, u * u + d * d <= l) {
978
+ c.push(x, S);
1146
979
  return;
1147
980
  }
1148
981
  }
1149
- recursive(n, j, H, U, J, Y, Q, $, R, z, B + 1), recursive(Q, $, X, Z, K, q, I, L, R, z, B + 1);
982
+ I(e, t, d, f, _, v, x, S, c, l, u + 1), I(x, S, y, b, h, g, o, s, c, l, u + 1);
1150
983
  }
1151
- var ShapePath = class {
1152
- constructor(n) {
1153
- this.shapePrimitives = [], this._bounds = new Bounds(), this._graphicsPath = n;
984
+ //#endregion
985
+ //#region lib/scene/graphics/path/ShapePath.ts
986
+ var je = new y(), Me = class {
987
+ constructor(e) {
988
+ f(this, "_currentPoly", void 0), f(this, "shapePrimitives", []), f(this, "_graphicsPath", void 0), f(this, "_bounds", new w()), this._graphicsPath = e;
1154
989
  }
1155
- _ensurePoly(n = !0) {
1156
- this._currentPoly || (this._currentPoly = new Polygon(), n && this._currentPoly.points.push(0, 0));
990
+ _ensurePoly(e = !0) {
991
+ this._currentPoly || (this._currentPoly = new Ee(), e && this._currentPoly.points.push(0, 0));
1157
992
  }
1158
- lineTo(n, j) {
993
+ lineTo(e, t) {
1159
994
  this._ensurePoly();
1160
- let M = this._currentPoly.points, N = M[M.length - 2], P = M[M.length - 1];
1161
- return (N !== n || P !== j) && M.push(n, j), this;
995
+ let n = this._currentPoly.points, r = n[n.length - 2], i = n[n.length - 1];
996
+ return (r !== e || i !== t) && n.push(e, t), this;
1162
997
  }
1163
- rect(n, j, M, N) {
1164
- return this.drawShape(new Rectangle(n, j, M, N)), this;
998
+ rect(e, t, n, r) {
999
+ return this.drawShape(new y(e, t, n, r)), this;
1165
1000
  }
1166
- drawShape(n) {
1167
- return this.endPloy(), this.shapePrimitives.push({ shape: n }), this;
1001
+ drawShape(e) {
1002
+ return this.endPloy(), this.shapePrimitives.push({ shape: e }), this;
1168
1003
  }
1169
- moveTo(n, j) {
1170
- return this.startPoly(n, j), this;
1004
+ moveTo(e, t) {
1005
+ return this.startPoly(e, t), this;
1171
1006
  }
1172
- bezierCurveTo(n, j, M, N, P, F, I) {
1007
+ bezierCurveTo(e, t, n, r, i, a, o) {
1173
1008
  this._ensurePoly();
1174
- let L = this._currentPoly.points;
1175
- return buildAdaptiveBezier(L, this._currentPoly.lastX, this._currentPoly.lastY, n, j, M, N, P, F, I), this;
1009
+ let s = this._currentPoly.points;
1010
+ return ke(s, this._currentPoly.lastX, this._currentPoly.lastY, e, t, n, r, i, a, o), this;
1176
1011
  }
1177
- startPoly(n, j) {
1178
- return this._currentPoly && this.endPloy(), this._currentPoly = new Polygon(), this._currentPoly.points.push(n, j), this;
1012
+ startPoly(e, t) {
1013
+ return this._currentPoly && this.endPloy(), this._currentPoly = new Ee(), this._currentPoly.points.push(e, t), this;
1179
1014
  }
1180
- endPloy(n = !1) {
1181
- let j = this._currentPoly;
1182
- j && j.points.length > 2 && (j.closePath = n, this.shapePrimitives.push({ shape: j })), this._currentPoly = null;
1015
+ endPloy(e = !1) {
1016
+ let t = this._currentPoly;
1017
+ return t && t.points.length > 2 && (t.closePath = e, this.shapePrimitives.push({ shape: t })), this._currentPoly = null, this;
1183
1018
  }
1184
1019
  closePath() {
1185
1020
  return this.endPloy(!0), this;
1186
1021
  }
1187
1022
  buildPath() {
1188
- let n = this._graphicsPath;
1189
- for (let j = 0; j < n.instructions.length; ++j) {
1190
- let M = n.instructions[j];
1191
- this[M.action](...M.data);
1023
+ let e = this._graphicsPath;
1024
+ for (let t = 0; t < e.instructions.length; ++t) {
1025
+ let n = e.instructions[t];
1026
+ this[n.action](...n.data);
1192
1027
  }
1193
- return this;
1028
+ return this.endPloy(!1), this;
1194
1029
  }
1195
1030
  get bounds() {
1196
- let n = this._bounds;
1197
- n.clear();
1198
- let j = this.shapePrimitives;
1199
- for (let M = 0; M < j.length; ++M) {
1200
- let N = j[M].shape.getBounds();
1201
- n.addRect(N);
1031
+ let e = this._bounds;
1032
+ e.clear();
1033
+ let t = this.shapePrimitives;
1034
+ for (let n = 0; n < t.length; ++n) {
1035
+ let r = t[n].shape.getBounds(je);
1036
+ e.addRect(r);
1202
1037
  }
1203
- return n;
1038
+ return e;
1204
1039
  }
1205
- }, GraphicsPath = class n {
1040
+ }, Ne = class e {
1206
1041
  constructor() {
1207
- this.instructions = [], this._dirty = !0;
1042
+ f(this, "instructions", []), f(this, "_dirty", !0), f(this, "_shapePath", void 0);
1208
1043
  }
1209
- rect(n, j, M, N) {
1044
+ rect(e, t, n, r) {
1210
1045
  return this.instructions.push({
1211
1046
  action: "rect",
1212
1047
  data: [
1048
+ e,
1049
+ t,
1213
1050
  n,
1214
- j,
1215
- M,
1216
- N
1051
+ r
1217
1052
  ]
1218
1053
  }), this._dirty = !0, this;
1219
1054
  }
1220
- lineTo(...n) {
1055
+ lineTo(...e) {
1221
1056
  return this.instructions.push({
1222
1057
  action: "lineTo",
1223
- data: n
1058
+ data: e
1224
1059
  }), this._dirty = !0, this;
1225
1060
  }
1226
- bezierCurveTo(...n) {
1061
+ bezierCurveTo(...e) {
1227
1062
  return this.instructions.push({
1228
1063
  action: "bezierCurveTo",
1229
- data: n
1064
+ data: e
1230
1065
  }), this;
1231
1066
  }
1232
- moveTo(...n) {
1067
+ moveTo(...e) {
1233
1068
  return this.instructions.push({
1234
1069
  action: "moveTo",
1235
- data: n
1070
+ data: e
1236
1071
  }), this;
1237
1072
  }
1238
1073
  closePath() {
@@ -1242,22 +1077,22 @@ var ShapePath = class {
1242
1077
  }), this._dirty = !0, this;
1243
1078
  }
1244
1079
  get shapePath() {
1245
- return this._shapePath || (this._shapePath = new ShapePath(this)), this._dirty && (this._dirty = !1, this._shapePath.buildPath()), this._shapePath;
1080
+ return this._shapePath || (this._shapePath = new Me(this)), this._dirty && (this._dirty = !1, this._shapePath.buildPath()), this._shapePath;
1246
1081
  }
1247
1082
  get bounds() {
1248
1083
  return this.shapePath.bounds;
1249
1084
  }
1250
1085
  getLastPoint() {
1251
- let n = this.instructions.length - 1, j = this.instructions[n];
1252
- if (!j) return {
1086
+ let e = this.instructions.length - 1, t = this.instructions[e];
1087
+ if (!t) return {
1253
1088
  x: 0,
1254
1089
  y: 0
1255
1090
  };
1256
- switch (j.action) {
1091
+ switch (t.action) {
1257
1092
  case "moveTo":
1258
1093
  case "lineTo": return {
1259
- x: j.data[0],
1260
- y: j.data[1]
1094
+ x: t.data[0],
1095
+ y: t.data[1]
1261
1096
  };
1262
1097
  }
1263
1098
  return {
@@ -1269,15 +1104,77 @@ var ShapePath = class {
1269
1104
  this.instructions.length = 0, this._dirty = !0;
1270
1105
  }
1271
1106
  clone() {
1272
- let j = new n();
1273
- return j.instructions = this.instructions.slice(), j;
1107
+ let t = new e();
1108
+ return t.instructions = this.instructions.slice(), t;
1109
+ }
1110
+ };
1111
+ //#endregion
1112
+ //#region lib/utils/color.ts
1113
+ function Pe(e) {
1114
+ let t = e.replace("#", ""), n = t;
1115
+ t.length === 4 && (n = t.split("").map((e) => e + e).join(""));
1116
+ let r = n.substring(0, 2), i = n.substring(2, 4), a = n.substring(4, 6), o = n.substring(6, 8) || "ff", s = Number.parseInt(r, 16), c = Number.parseInt(i, 16), l = Number.parseInt(a, 16);
1117
+ return {
1118
+ r: s,
1119
+ g: c,
1120
+ b: l,
1121
+ a: +(Number.parseInt(o, 16) / 255).toFixed(2),
1122
+ rgb: `rgb(${s}, ${c}, ${l})`,
1123
+ hex: `#${r}${i}${a}`
1124
+ };
1125
+ }
1126
+ //#endregion
1127
+ //#region lib/scene/graphics/utils/convertInputToStyle.ts
1128
+ function L(e, t) {
1129
+ return {
1130
+ ...t,
1131
+ ...e
1132
+ };
1133
+ }
1134
+ function Fe(e, t) {
1135
+ if (e == null) return null;
1136
+ let n = {
1137
+ ...t,
1138
+ ...e
1139
+ };
1140
+ if (n.color.startsWith("#")) {
1141
+ let { a: e, hex: t } = Pe(n.color);
1142
+ n.alpha *= e, n.color = t;
1274
1143
  }
1275
- }, _GraphicsContext, GraphicsContext = class n {
1144
+ return n;
1145
+ }
1146
+ //#endregion
1147
+ //#region lib/scene/graphics/utils/getMaxMiterRatio.ts
1148
+ function Ie(e, t) {
1149
+ let n = 1, r = e.shapePath.shapePrimitives;
1150
+ for (let e = 0; e < r.length; e++) {
1151
+ let i = r[e].shape;
1152
+ if (i.type !== "polygon") continue;
1153
+ let a = i.points, o = a.length;
1154
+ if (o < 6) continue;
1155
+ let s = i.closePath;
1156
+ for (let e = 0; e < o; e += 2) {
1157
+ if (!s && (e === 0 || e === o - 2)) continue;
1158
+ let r = (e - 2 + o) % o, i = (e + 2) % o, c = a[r], l = a[r + 1], u = a[e], d = a[e + 1], f = a[i], p = a[i + 1], m = c - u, h = l - d, g = f - u, _ = p - d, v = m * m + h * h, y = g * g + _ * _;
1159
+ if (v < 1e-12 || y < 1e-12) continue;
1160
+ let b = (m * g + h * _) / Math.sqrt(v * y);
1161
+ b < -1 ? b = -1 : b > 1 && (b = 1);
1162
+ let x = Math.sqrt((1 - b) * .5);
1163
+ if (x < 1e-6) continue;
1164
+ let S = Math.min(1 / x, t);
1165
+ S > n && (n = S);
1166
+ }
1167
+ }
1168
+ return n;
1169
+ }
1170
+ //#endregion
1171
+ //#region lib/scene/graphics/GraphicsContext.ts
1172
+ var R = class e {
1276
1173
  constructor() {
1277
- this._activePath = new GraphicsPath(), this._bounds = new Bounds(), this._boundsDirty = !0, this.instructions = [];
1174
+ f(this, "_strokeStyle", { ...e.defaultStrokeStyle }), f(this, "_fillStyle", { ...e.defaultFillStyle }), f(this, "_activePath", new Ne()), f(this, "_bounds", new w()), f(this, "_boundsDirty", !0), f(this, "_tick", 0), f(this, "instructions", []);
1278
1175
  }
1279
- setStrokeStyle(j) {
1280
- this._strokeStyle = toStrokeStyle(j, n.defaultStrokeStyle);
1176
+ setStrokeStyle(t) {
1177
+ this._strokeStyle = L(t, e.defaultStrokeStyle);
1281
1178
  }
1282
1179
  clear() {
1283
1180
  return this._activePath.clear(), this.instructions.length = 0, this.onUpdate(), this;
@@ -1285,75 +1182,106 @@ var ShapePath = class {
1285
1182
  onUpdate() {
1286
1183
  this._boundsDirty = !0;
1287
1184
  }
1288
- moveTo(n, j) {
1289
- return this._activePath.moveTo(n, j), this;
1185
+ moveTo(e, t) {
1186
+ return ++this._tick, this._activePath.moveTo(e, t), this;
1290
1187
  }
1291
- lineTo(n, j) {
1292
- return this._activePath.lineTo(n, j), this;
1188
+ lineTo(e, t) {
1189
+ return ++this._tick, this._activePath.lineTo(e, t), this;
1293
1190
  }
1294
- bezierCurveTo(n, j, M, N, P, F, I) {
1295
- return this._activePath.bezierCurveTo(n, j, M, N, P, F, I), this;
1191
+ bezierCurveTo(e, t, n, r, i, a, o) {
1192
+ return ++this._tick, this._activePath.bezierCurveTo(e, t, n, r, i, a, o), this;
1296
1193
  }
1297
- rect(n, j, M, N) {
1298
- return this._activePath.rect(n, j, M, N), this;
1194
+ rect(e, t, n, r) {
1195
+ return ++this._tick, this._activePath.rect(e, t, n, r), this;
1299
1196
  }
1300
1197
  beginPath() {
1301
- return this._activePath = new GraphicsPath(), this;
1198
+ return this._activePath = new Ne(), this;
1302
1199
  }
1303
1200
  closePath() {
1304
- return this._activePath.closePath(), this;
1201
+ return ++this._tick, this._activePath.closePath(), this;
1305
1202
  }
1306
- fill(j) {
1307
- let M = {
1308
- ...n.defaultStrokeStyle,
1309
- color: j
1310
- };
1311
- return this.instructions.push({
1203
+ get fillStyle() {
1204
+ return this._fillStyle;
1205
+ }
1206
+ set fillStyle(t) {
1207
+ this._fillStyle = Fe(t, e.defaultFillStyle);
1208
+ }
1209
+ get strokeStyle() {
1210
+ return this._strokeStyle;
1211
+ }
1212
+ set strokeStyle(t) {
1213
+ this._strokeStyle = L(t, e.defaultStrokeStyle);
1214
+ }
1215
+ fill(t) {
1216
+ let n = this.instructions[this.instructions.length - 1], r;
1217
+ return r = this._tick === 0 && (n == null ? void 0 : n.action) === "stroke" ? n.data.path : this._activePath.clone(), r ? (t != null && (this._fillStyle = Fe(t, e.defaultFillStyle)), this.instructions.push({
1312
1218
  action: "fill",
1313
1219
  data: {
1314
- style: M,
1315
- path: this._activePath.clone()
1220
+ style: this.fillStyle,
1221
+ path: r
1316
1222
  }
1317
- }), this;
1223
+ }), this.onUpdate(), this._initNextPathLocation(), this._tick = 0, this) : this;
1318
1224
  }
1319
- stroke() {
1320
- this.instructions.push({
1225
+ stroke(t) {
1226
+ let n, r = this.instructions[this.instructions.length - 1];
1227
+ return n = this._tick === 0 && (r == null ? void 0 : r.action) === "fill" ? r.data.path : this._activePath.clone(), n ? (t != null && (this._strokeStyle = L(t, e.defaultStrokeStyle)), this.instructions.push({
1321
1228
  action: "stroke",
1322
1229
  data: {
1323
- style: this._strokeStyle,
1324
- path: this._activePath.clone()
1230
+ style: this.strokeStyle,
1231
+ path: n
1325
1232
  }
1326
- }), this._initNextPathLocation();
1233
+ }), this.onUpdate(), this._initNextPathLocation(), this._tick = 0, this) : this;
1327
1234
  }
1328
1235
  _initNextPathLocation() {
1329
- let { x: n, y: j } = this._activePath.getLastPoint();
1330
- this._activePath.clear(), this._activePath.moveTo(n, j);
1236
+ let { x: e, y: t } = this._activePath.getLastPoint();
1237
+ this._activePath.clear(), this._activePath.moveTo(e, t);
1331
1238
  }
1332
1239
  get bounds() {
1333
1240
  if (!this._boundsDirty) return this._bounds;
1334
1241
  this._boundsDirty = !1;
1335
- let n = this._bounds;
1336
- n.clear();
1337
- for (let j = 0; j < this.instructions.length; ++j) {
1338
- let M = this.instructions[j], N = M.action;
1339
- if (N === "fill") {
1340
- let j = M.data;
1341
- n.addBounds(j.path.bounds);
1342
- } else if (N === "stroke") {
1343
- let j = M.data, N = j.style.alignment, P = j.style.width * (1 - N);
1344
- j.style.join;
1345
- let F = j.path.bounds;
1346
- n.addFrame(F.minX - P, F.minY - P, F.maxX + P, F.maxY + P);
1242
+ let e = this._bounds;
1243
+ e.clear();
1244
+ for (let t = 0; t < this.instructions.length; ++t) {
1245
+ let n = this.instructions[t], r = n.action;
1246
+ if (r === "fill") {
1247
+ let t = n.data;
1248
+ e.addBounds(t.path.bounds);
1249
+ } else if (r === "stroke") {
1250
+ let t = n.data, r = t.style.alignment, i = t.style.width * (1 - r);
1251
+ t.style.join === "miter" && (i *= Ie(t.path, t.style.miterLimit));
1252
+ let a = t.path.bounds;
1253
+ e.addFrame(a.minX - i, a.minY - i, a.maxX + i, a.maxY + i);
1347
1254
  }
1348
1255
  }
1349
- return n.isValid || n.set(0, 0, 0, 0), n;
1256
+ return e.isValid || e.set(0, 0, 0, 0), e;
1257
+ }
1258
+ containsPoint(e) {
1259
+ if (!this.bounds.containsPoint(e.x, e.y)) return !1;
1260
+ let t = this.instructions, n = !1;
1261
+ for (let r = 0; r < t.length; ++r) {
1262
+ let i = t[r], a = i.data, o = a.path;
1263
+ if (!i.action || !o) continue;
1264
+ let s = a.style, c = o.shapePath.shapePrimitives;
1265
+ for (let t = 0; t < c.length; ++t) {
1266
+ let t = c[r].shape;
1267
+ if (!s || !t) continue;
1268
+ let a = e;
1269
+ if (i.action === "fill") n = t.contains(a.x, a.y);
1270
+ else {
1271
+ let e = s;
1272
+ n = t.strokeContains(a.x, a.y, e.width, e.alignment);
1273
+ }
1274
+ if (n) return !0;
1275
+ }
1276
+ }
1277
+ return n;
1350
1278
  }
1351
1279
  clone() {
1352
- let j = new n();
1353
- return j.instructions = this.instructions.slice(), j._activePath = this._activePath.clone(), j._bounds = this._bounds.clone(), j._strokeStyle = { ...this._strokeStyle }, j;
1280
+ let t = new e();
1281
+ return t.instructions = this.instructions.slice(), t._activePath = this._activePath.clone(), t._bounds = this._bounds.clone(), t._strokeStyle = { ...this._strokeStyle }, t;
1354
1282
  }
1355
1283
  };
1356
- _GraphicsContext = GraphicsContext, _GraphicsContext.defaultStrokeStyle = {
1284
+ f(R, "defaultStrokeStyle", {
1357
1285
  width: 1,
1358
1286
  color: "#ffffff",
1359
1287
  alignment: .5,
@@ -1362,45 +1290,56 @@ _GraphicsContext = GraphicsContext, _GraphicsContext.defaultStrokeStyle = {
1362
1290
  join: "miter",
1363
1291
  pixelLine: !1,
1364
1292
  alpha: 1
1365
- };
1366
- function toStrokeStyle(n, j) {
1367
- return {
1368
- ...j,
1369
- ...n
1370
- };
1371
- }
1372
- var Graphics = class extends ViewContainer {
1373
- constructor(n) {
1374
- n instanceof GraphicsContext && (n = { context: n });
1375
- let { context: j, ...M } = n || {};
1293
+ }), f(R, "defaultFillStyle", {
1294
+ color: "#ffffff",
1295
+ alpha: 1
1296
+ });
1297
+ //#endregion
1298
+ //#region lib/scene/graphics/Graphics.ts
1299
+ var Le = class extends P {
1300
+ constructor(e) {
1301
+ e instanceof R && (e = { context: e });
1302
+ let { context: t, ...n } = e || {};
1376
1303
  super({
1377
1304
  label: "Graphics",
1378
- ...M
1379
- }), this.renderPipeId = "graphics", j ? this.context = j : this.context = new GraphicsContext(), this.didViewUpdate = !0;
1305
+ ...n
1306
+ }), f(this, "renderPipeId", "graphics"), f(this, "_context", void 0), t ? this.context = t : this.context = new R(), this.didViewUpdate = !0;
1380
1307
  }
1381
1308
  get context() {
1382
1309
  return this._context;
1383
1310
  }
1384
- set context(n) {
1385
- n !== this._context && (this._context = n, this.onViewUpdate());
1311
+ set context(e) {
1312
+ e !== this._context && (this._context = e, this.onViewUpdate());
1386
1313
  }
1387
- setStrokeStyle(...n) {
1388
- return this._callContextMethod("setStrokeStyle", n);
1314
+ get fillStyle() {
1315
+ return this._context.fillStyle;
1389
1316
  }
1390
- rect(...n) {
1391
- return this._callContextMethod("rect", n);
1317
+ set fillStyle(e) {
1318
+ this._context.fillStyle = e;
1392
1319
  }
1393
- bezierCurveTo(...n) {
1394
- return this._callContextMethod("bezierCurveTo", n);
1320
+ get strokeStyle() {
1321
+ return this._context.strokeStyle;
1395
1322
  }
1396
- lineTo(...n) {
1397
- return this._callContextMethod("lineTo", n);
1323
+ set strokeStyle(e) {
1324
+ this._context.strokeStyle = e;
1398
1325
  }
1399
- moveTo(...n) {
1400
- return this._callContextMethod("moveTo", n);
1326
+ setStrokeStyle(...e) {
1327
+ return this._callContextMethod("setStrokeStyle", e);
1401
1328
  }
1402
- stroke(...n) {
1403
- return this._callContextMethod("stroke", n);
1329
+ rect(...e) {
1330
+ return this._callContextMethod("rect", e);
1331
+ }
1332
+ bezierCurveTo(...e) {
1333
+ return this._callContextMethod("bezierCurveTo", e);
1334
+ }
1335
+ lineTo(...e) {
1336
+ return this._callContextMethod("lineTo", e);
1337
+ }
1338
+ moveTo(...e) {
1339
+ return this._callContextMethod("moveTo", e);
1340
+ }
1341
+ stroke(...e) {
1342
+ return this._callContextMethod("stroke", e);
1404
1343
  }
1405
1344
  beginPath() {
1406
1345
  return this._callContextMethod("beginPath", []);
@@ -1408,11 +1347,11 @@ var Graphics = class extends ViewContainer {
1408
1347
  closePath() {
1409
1348
  return this._callContextMethod("closePath", []);
1410
1349
  }
1411
- fill(n) {
1412
- return this._callContextMethod("fill", [n]);
1350
+ fill(...e) {
1351
+ return this._callContextMethod("fill", e);
1413
1352
  }
1414
- _callContextMethod(n, j) {
1415
- return this.context[n](...j), this;
1353
+ _callContextMethod(e, t) {
1354
+ return this.context[e](...t), this;
1416
1355
  }
1417
1356
  updateBounds() {}
1418
1357
  get bounds() {
@@ -1421,153 +1360,213 @@ var Graphics = class extends ViewContainer {
1421
1360
  clear() {
1422
1361
  return this._callContextMethod("clear", []);
1423
1362
  }
1424
- }, _GraphicsPipe, GraphicsPipe = class {
1425
- constructor(n) {
1426
- this._renderer = n;
1363
+ }, z = class {
1364
+ constructor(e) {
1365
+ f(this, "_renderer", void 0), this._renderer = e;
1427
1366
  }
1428
- addRenderable(n, j) {
1429
- this._renderer.renderPipes.batch.break(j), j.add(n);
1367
+ addRenderable(e, t) {
1368
+ this._renderer.renderPipes.batch.break(t), t.add(e);
1430
1369
  }
1431
- validateRenderable(n) {
1370
+ validateRenderable(e) {
1432
1371
  return !1;
1433
1372
  }
1434
- execute(n) {
1435
- let j = this._renderer, M = j.canvasContext, N = M.activeConext, P = j.roundPixels, F = (n.groupColorAlpha >>> 24 & 255) / 255;
1436
- if (!(F <= 0)) {
1437
- N.save(), M.setContextTransform(n.relativeGroupTransform, P);
1438
- for (let j = 0; j < n.context.instructions.length; ++j) {
1439
- let M = n.context.instructions[j], P = M.data.style, I = P.alpha * F;
1440
- if (I <= 0) continue;
1441
- N.globalAlpha = I;
1442
- let L = M.action === "stroke";
1443
- if (L) {
1444
- let n = P.color;
1445
- N.lineWidth = P.width, N.lineCap = P.cap, N.lineJoin = P.join, N.miterLimit = P.miterLimit, N.strokeStyle = n;
1446
- } else N.fillStyle = M.data.style.color;
1447
- let R = M.data.path.shapePath.shapePrimitives;
1448
- for (let n = 0; n < R.length; ++n) {
1449
- let j = R[n];
1450
- j.shape && (N.beginPath(), buildShapePath(N, j.shape), L ? N.stroke() : N.fill());
1373
+ execute(e) {
1374
+ let t = this._renderer, n = t.canvasContext, r = n.activeConext, i = t.roundPixels, a = (e.groupColorAlpha >>> 24 & 255) / 255;
1375
+ if (!(a <= 0)) {
1376
+ r.save(), n.setContextTransform(e.relativeGroupTransform, i);
1377
+ for (let t = 0; t < e.context.instructions.length; ++t) {
1378
+ let n = e.context.instructions[t], i = n.data.style, o = i.alpha * a;
1379
+ if (o <= 0) continue;
1380
+ r.globalAlpha = o;
1381
+ let s = n.action === "stroke";
1382
+ if (s) {
1383
+ let e = i.color;
1384
+ r.lineWidth = i.width, r.lineCap = i.cap, r.lineJoin = i.join, r.miterLimit = i.miterLimit, r.strokeStyle = e;
1385
+ } else r.fillStyle = n.data.style.color;
1386
+ let c = n.data.path.shapePath.shapePrimitives;
1387
+ for (let e = 0; e < c.length; ++e) {
1388
+ let t = c[e];
1389
+ t.shape && (r.beginPath(), B(r, t.shape), s ? r.stroke() : r.fill());
1451
1390
  }
1452
1391
  }
1453
- N.restore();
1392
+ r.restore();
1454
1393
  }
1455
1394
  }
1456
1395
  destroy() {
1457
1396
  this._renderer = null;
1458
1397
  }
1459
1398
  };
1460
- _GraphicsPipe = GraphicsPipe, _GraphicsPipe.desc = { name: "graphics" };
1461
- function buildShapePath(n, j) {
1462
- switch (j.type) {
1399
+ f(z, "desc", { name: "graphics" });
1400
+ function B(e, t) {
1401
+ switch (t.type) {
1463
1402
  case "rectangle": {
1464
- let M = j;
1465
- n.rect(M.x, M.y, M.width, M.height);
1403
+ let n = t;
1404
+ e.rect(n.x, n.y, n.width, n.height);
1466
1405
  break;
1467
1406
  }
1468
1407
  case "polygon": {
1469
- let M = j, N = M.points;
1470
- if (!N.length) return;
1471
- n.moveTo(N[0], N[1]);
1472
- for (let j = 2; j < N.length; j += 2) n.lineTo(N[j], N[j + 1]);
1473
- M.closePath && n.closePath();
1408
+ let n = t, r = n.points;
1409
+ if (!r.length) return;
1410
+ e.moveTo(r[0], r[1]);
1411
+ for (let t = 2; t < r.length; t += 2) e.lineTo(r[t], r[t + 1]);
1412
+ n.closePath && e.closePath();
1474
1413
  break;
1475
1414
  }
1476
1415
  }
1477
1416
  }
1478
- var _BatchPipe, Batch = class {
1479
- constructor() {
1480
- this.renderPipeId = "batch", this.elements = [];
1481
- }
1482
- }, BatchPipe = class {
1483
- constructor(n) {
1484
- this._renderer = n;
1485
- }
1486
- get batch() {
1487
- return this._activeBatch;
1488
- }
1489
- buildStart() {
1490
- this._activeBatch = new Batcher();
1491
- }
1492
- buildEnd(n) {
1493
- this.break(n);
1494
- }
1495
- break(n) {
1496
- this._activeBatch.build(n);
1417
+ //#endregion
1418
+ //#region lib/scene/mask/StencilMaskPipe.ts
1419
+ var Re = class {
1420
+ constructor(e) {
1421
+ f(this, "_renderer", void 0), f(this, "_canvasMaskStack", []), this._renderer = e;
1422
+ }
1423
+ push(e, t) {
1424
+ t.add({
1425
+ renderPipeId: "stencilMask",
1426
+ action: "pushMaskBegin",
1427
+ mask: e
1428
+ });
1497
1429
  }
1498
- addToBatch(n, j) {
1499
- this._activeBatch.add({
1500
- ...n,
1501
- getColor: () => n.renderable.groupColorAlpha
1430
+ pop(e, t) {
1431
+ this._renderer.renderPipes.batch.break(t), t.add({
1432
+ renderPipeId: "stencilMask",
1433
+ action: "popMaskEnd",
1434
+ mask: e
1502
1435
  });
1503
1436
  }
1504
- execute(n) {
1505
- let j = n.elements;
1506
- if (!j || !j.length) return;
1507
- let M = this._renderer.canvasContext, N = M.activeConext;
1508
- for (let n = 0; n < j.length; n++) {
1509
- let P = j[n], F = P.roundPixels, I = (P.getColor() >>> 24 & 255) / 255;
1510
- if (I <= 0) continue;
1511
- N.globalAlpha = I, M.setContextTransform(P.transform, F === 1);
1512
- let L = P.bounds, R = P.texture, z = R.frame, B = R.source._resolution || 1, V = z.x * B, H = z.y * B, U = z.width * B, W = z.height * B, G = L.minX, K = L.minY, q = L.maxX - L.minX, J = L.maxY - L.minY, Y = G, X = K, Z = q, Q = J;
1513
- N.drawImage(R.source.resource, V, H, U, W, Y, X, Z, Q);
1437
+ execute(e) {
1438
+ if (e.action !== "pushMaskBegin" && e.action !== "popMaskEnd") return;
1439
+ let t = this._renderer.canvasContext, n = t.activeConext;
1440
+ if (e.action === "popMaskEnd") {
1441
+ this._canvasMaskStack.pop() && n.restore();
1442
+ return;
1514
1443
  }
1444
+ let r = e.mask.mask, i = r.context.instructions, a = r._roundPixels === 1;
1445
+ n.save(), t.setContextTransform(r.relativeGroupTransform, a), n.beginPath();
1446
+ for (let e = 0; e < i.length; ++e) {
1447
+ let t = i[e], r = t.action;
1448
+ if (r !== "fill" && r !== "stroke") return;
1449
+ let a = t.data.path.shapePath.shapePrimitives;
1450
+ for (let e = 0; e < a.length; ++e) {
1451
+ let t = a[e].shape;
1452
+ B(n, t);
1453
+ }
1454
+ }
1455
+ n.clip(), this._canvasMaskStack.push(!0);
1515
1456
  }
1516
1457
  destroy() {
1517
- var n;
1518
- this._renderer = null, (n = this._activeBatch) == null || n.destroy(), this._activeBatch = null;
1458
+ this._renderer = null;
1519
1459
  }
1520
1460
  };
1521
- _BatchPipe = BatchPipe, _BatchPipe.desc = { name: "batch" };
1522
- var Batcher = class {
1523
- constructor() {
1524
- this.renderPipeId = "batch", this.elements = [], this.elementSize = 0;
1461
+ f(Re, "desc", { name: "stencilMask" });
1462
+ //#endregion
1463
+ //#region lib/scene/sprite/SpritePipe.ts
1464
+ var ze = class {
1465
+ constructor(e) {
1466
+ f(this, "_renderer", void 0), this._renderer = e;
1467
+ }
1468
+ addRenderable(e, t) {
1469
+ let n = this._getRuntimeSprite(e);
1470
+ e.didViewUpdate && this._updateBatchableSprite(e, n), this._renderer.renderPipes.batch.addToBatch(n, t);
1471
+ }
1472
+ _updateBatchableSprite(e, t) {
1473
+ t.texture = e._texture, t.bounds = e.bounds;
1474
+ }
1475
+ validateRenderable(e) {
1476
+ return this._getRuntimeSprite(e).texture._source.uid !== e._texture._source.uid;
1477
+ }
1478
+ _getRuntimeSprite(e) {
1479
+ return e._runtimeData[this._renderer.uid] || this._initCacheSprite(e);
1480
+ }
1481
+ _initCacheSprite(e) {
1482
+ let t = {
1483
+ renderable: e,
1484
+ texture: e.texture,
1485
+ transform: e.relativeGroupTransform,
1486
+ bounds: e.bounds,
1487
+ roundPixels: this._renderer._roundPixels | e._roundPixels,
1488
+ destroy() {
1489
+ this.renderable = null, this.texture = null, this.transform = null, this.bounds = null;
1490
+ }
1491
+ };
1492
+ return e._runtimeData[this._renderer.uid] = t, t;
1525
1493
  }
1526
- add(n) {
1527
- this.elements[this.elementSize++] = n;
1494
+ destroy() {
1495
+ this._renderer = null;
1528
1496
  }
1529
- build(n) {
1530
- let j = new Batch(), M = this.elements;
1531
- if (M[0]) {
1532
- for (let n = 0; n < M.length; n++) {
1533
- let N = M[n];
1534
- this.elements[n] = null, j.elements.push(N);
1535
- }
1536
- n.add(j);
1497
+ };
1498
+ f(ze, "desc", { name: "sprite" });
1499
+ //#endregion
1500
+ //#region lib/scene/text/TextPipe.ts
1501
+ var V = class {
1502
+ constructor(e) {
1503
+ f(this, "_renderer", void 0), this._renderer = e;
1504
+ }
1505
+ addRenderable(e, t) {
1506
+ let n = this._getRuntimeText(e);
1507
+ if (e._didTextUpdate) {
1508
+ let t = e._autoResolution ? this._renderer.resolution : e.resolution;
1509
+ (n.currentKey !== e.styleKey || e._resolution !== t) && this._updateRuntimeText(e), e._didTextUpdate = !1, ae(n.bounds, e._anchor, n.texture);
1537
1510
  }
1511
+ this._renderer.renderPipes.batch.addToBatch(n, t);
1512
+ }
1513
+ validateRenderable(e) {
1514
+ let t = this._getRuntimeText(e), n = e.styleKey;
1515
+ return t.currentKey === n ? e._didTextUpdate : !0;
1516
+ }
1517
+ initCacheText(e) {
1518
+ let t = {
1519
+ currentKey: "--",
1520
+ transform: e.relativeGroupTransform,
1521
+ bounds: e.bounds,
1522
+ roundPixels: this._renderer._roundPixels | e._roundPixels,
1523
+ renderable: e,
1524
+ texture: null,
1525
+ destroy() {
1526
+ this.renderable = null, this.texture = null, this.bounds = null;
1527
+ }
1528
+ };
1529
+ return e._runtimeData[this._renderer.uid] = t, t;
1530
+ }
1531
+ _getRuntimeText(e) {
1532
+ return e._runtimeData[this._renderer.uid] || this.initCacheText(e);
1533
+ }
1534
+ _updateRuntimeText(e) {
1535
+ let t = this._getRuntimeText(e);
1536
+ t.texture, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, t.texture = this._renderer.text.getManagedTexture(e), t.currentKey = e.styleKey;
1538
1537
  }
1539
1538
  destroy() {
1540
- this.elements = null;
1539
+ this._renderer = null;
1541
1540
  }
1542
1541
  };
1543
- const CanvasPool = new class {
1542
+ f(V, "desc", { name: "text" });
1543
+ var Be = new class {
1544
1544
  constructor() {
1545
- this._canvasPool = Object.create(null);
1545
+ f(this, "_canvasPool", void 0), this._canvasPool = Object.create(null);
1546
1546
  }
1547
- getOptimalCanvasAndContext(n, j, M = 1) {
1548
- let N = nextPow2(n * M - 1e-6), P = nextPow2(j * M - 1e-6), F = N << 17 + P << 1;
1549
- this._canvasPool[F] || (this._canvasPool[F] = []);
1550
- let I = this._canvasPool[F].pop();
1551
- if (I) return I;
1547
+ getOptimalCanvasAndContext(e, t, n = 1) {
1548
+ let r = x(e * n - 1e-6), i = x(t * n - 1e-6), a = r << 17 + i << 1;
1549
+ this._canvasPool[a] || (this._canvasPool[a] = []);
1550
+ let o = this._canvasPool[a].pop();
1551
+ if (o) return o;
1552
1552
  {
1553
- let n = document.createElement("canvas");
1554
- return n.width = N, n.height = P, {
1555
- canvas: n,
1556
- context: n.getContext("2d")
1553
+ let e = document.createElement("canvas");
1554
+ return e.width = r, e.height = i, {
1555
+ canvas: e,
1556
+ context: e.getContext("2d")
1557
1557
  };
1558
1558
  }
1559
1559
  }
1560
- }();
1561
- var _TextStyle, TextStyle = class n {
1562
- constructor(j) {
1563
- this.uid = uid("textStyle"), this._tick = 0;
1564
- let M = {
1565
- ...n.defaultStyle,
1566
- ...j
1560
+ }(), H = class e {
1561
+ constructor(t) {
1562
+ f(this, "uid", D("textStyle")), f(this, "_cachedFontString", void 0), f(this, "_fontSize", void 0), f(this, "_fontFamily", void 0), f(this, "_fontStyle", void 0), f(this, "_lineHeight", void 0), f(this, "_leading", void 0), f(this, "_fontVariant", void 0), f(this, "_fontWeight", void 0), f(this, "_letterSpacing", void 0), f(this, "_textBaseline", void 0), f(this, "_align", void 0), f(this, "_wordWrap", void 0), f(this, "_fill", void 0), f(this, "_tick", 0);
1563
+ let n = {
1564
+ ...e.defaultStyle,
1565
+ ...t
1567
1566
  };
1568
- for (let n in M) {
1569
- let j = n;
1570
- this[j] = M[n];
1567
+ for (let e in n) {
1568
+ let t = e;
1569
+ this[t] = n[e];
1571
1570
  }
1572
1571
  }
1573
1572
  get styleKey() {
@@ -1576,86 +1575,86 @@ var _TextStyle, TextStyle = class n {
1576
1575
  get fontSize() {
1577
1576
  return this._fontSize;
1578
1577
  }
1579
- set fontSize(n) {
1580
- this._fontSize !== n && (this._fontSize = n, this.update());
1578
+ set fontSize(e) {
1579
+ this._fontSize !== e && (this._fontSize = e, this.update());
1581
1580
  }
1582
1581
  get fill() {
1583
1582
  return this._fill;
1584
1583
  }
1585
- set fill(n) {
1586
- this._fill !== n && (this._fill = n, this.update());
1584
+ set fill(e) {
1585
+ this._fill !== e && (this._fill = e, this.update());
1587
1586
  }
1588
1587
  get align() {
1589
1588
  return this._align;
1590
1589
  }
1591
- set align(n) {
1592
- this._align !== n && (this._align = n, this.update());
1590
+ set align(e) {
1591
+ this._align !== e && (this._align = e, this.update());
1593
1592
  }
1594
- get wordWarp() {
1593
+ get wordWrap() {
1595
1594
  return this._wordWrap;
1596
1595
  }
1597
- set wordWrap(n) {
1598
- this._wordWrap !== n && (this._wordWrap = n, this.update());
1596
+ set wordWrap(e) {
1597
+ this._wordWrap !== e && (this._wordWrap = e, this.update());
1599
1598
  }
1600
1599
  get fontFamily() {
1601
1600
  return this._fontFamily;
1602
1601
  }
1603
- set fontFamily(n) {
1604
- this._fontFamily !== n && (this._fontFamily = n, this.update());
1602
+ set fontFamily(e) {
1603
+ this._fontFamily !== e && (this._fontFamily = e, this.update());
1605
1604
  }
1606
1605
  get leading() {
1607
1606
  return this._leading;
1608
1607
  }
1609
- set leading(n) {
1610
- this._leading !== n && (this._leading = n, this.update());
1608
+ set leading(e) {
1609
+ this._leading !== e && (this._leading = e, this.update());
1611
1610
  }
1612
1611
  get fontStyle() {
1613
1612
  return this._fontStyle;
1614
1613
  }
1615
- set fontStyle(n) {
1616
- this._fontStyle !== n && (this._fontStyle = n.toLowerCase(), this.update());
1614
+ set fontStyle(e) {
1615
+ this._fontStyle !== e && (this._fontStyle = e.toLowerCase(), this.update());
1617
1616
  }
1618
1617
  get textBaseline() {
1619
1618
  return this._textBaseline;
1620
1619
  }
1621
- set textBaseline(n) {
1622
- this._textBaseline = n, this.update();
1620
+ set textBaseline(e) {
1621
+ this._textBaseline = e, this.update();
1623
1622
  }
1624
1623
  get lineHeight() {
1625
1624
  return this._lineHeight;
1626
1625
  }
1627
- set lineHeight(n) {
1628
- this._lineHeight !== n && (this._lineHeight = n, this.update());
1626
+ set lineHeight(e) {
1627
+ this._lineHeight !== e && (this._lineHeight = e, this.update());
1629
1628
  }
1630
1629
  get letterSpacing() {
1631
1630
  return this._letterSpacing;
1632
1631
  }
1633
- set letterSpacing(n) {
1634
- this._letterSpacing !== n && (this._letterSpacing = n, this.update());
1632
+ set letterSpacing(e) {
1633
+ this._letterSpacing !== e && (this._letterSpacing = e, this.update());
1635
1634
  }
1636
1635
  get fontVariant() {
1637
1636
  return this._fontVariant;
1638
1637
  }
1639
- set fontVariant(n) {
1640
- this._fontVariant !== n && (this._fontVariant = n, this.update());
1638
+ set fontVariant(e) {
1639
+ this._fontVariant !== e && (this._fontVariant = e, this.update());
1641
1640
  }
1642
1641
  get fontWeight() {
1643
1642
  return this._fontWeight;
1644
1643
  }
1645
- set fontWeight(n) {
1646
- this._fontWeight !== n && (this._fontWeight = n, this.update());
1644
+ set fontWeight(e) {
1645
+ this._fontWeight !== e && (this._fontWeight = e, this.update());
1647
1646
  }
1648
1647
  get _fontString() {
1649
- return this._cachedFontString === null && (this._cachedFontString = fontStringFromTextStyle(this)), this._cachedFontString;
1648
+ return this._cachedFontString === null && (this._cachedFontString = He(this)), this._cachedFontString;
1650
1649
  }
1651
1650
  update() {
1652
1651
  this._tick++, this._cachedFontString = null;
1653
1652
  }
1654
- destroy(n = !1) {
1653
+ destroy(e = !1) {
1655
1654
  this._fill = null;
1656
1655
  }
1657
1656
  };
1658
- _TextStyle = TextStyle, _TextStyle.defaultStyle = {
1657
+ f(H, "defaultStyle", {
1659
1658
  align: "left",
1660
1659
  breakWords: !1,
1661
1660
  dropShadow: null,
@@ -1675,8 +1674,8 @@ _TextStyle = TextStyle, _TextStyle.defaultStyle = {
1675
1674
  whiteSpace: "pre",
1676
1675
  wordWrap: !1,
1677
1676
  wordWrapWidth: 100
1678
- };
1679
- var genericFontFamilies = [
1677
+ });
1678
+ var Ve = [
1680
1679
  "serif",
1681
1680
  "sans-serif",
1682
1681
  "monospace",
@@ -1684,199 +1683,201 @@ var genericFontFamilies = [
1684
1683
  "fantasy",
1685
1684
  "system-ui"
1686
1685
  ];
1687
- function fontStringFromTextStyle(n) {
1688
- let j = typeof n.fontSize == "number" ? `${n.fontSize}px` : n.fontSize, M = n.fontFamily;
1689
- Array.isArray(n.fontFamily) || (M = n.fontFamily.split(","));
1690
- for (let n = M.length - 1; n >= 0; n--) {
1691
- let j = M[n].trim();
1692
- !/([\"\'])[^\'\"]+\1/.test(j) && !genericFontFamilies.includes(j) && (j = `"${j}"`), M[n] = j;
1693
- }
1694
- return `${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${j} ${M.join(",")}`;
1686
+ function He(e) {
1687
+ let t = typeof e.fontSize == "number" ? `${e.fontSize}px` : e.fontSize, n = e.fontFamily;
1688
+ Array.isArray(e.fontFamily) || (n = e.fontFamily.split(","));
1689
+ for (let e = n.length - 1; e >= 0; e--) {
1690
+ let t = n[e].trim();
1691
+ !/(["'])[^'"]+\1/.test(t) && !Ve.includes(t) && (t = `"${t}"`), n[e] = t;
1692
+ }
1693
+ return `${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(",")}`;
1695
1694
  }
1696
- var _TextMetrics;
1697
- const NEWLINE_MATCH_REGEX = /(?:\r\n|\r|\n)/;
1698
- var TextMetrics = class n {
1699
- constructor(n, j, M, N, P, F, I, L, R) {
1700
- this.text = n, this.style = j, this.width = M, this.height = N, this.lines = P, this.lineWidths = F, this.lineHeight = I, this.maxLineWidth = L, this.fontProperties = R;
1695
+ //#endregion
1696
+ //#region lib/scene/text/utils.ts
1697
+ var Ue = /(?:\r\n|\r|\n)/, U = class e {
1698
+ constructor(e, t, n, r, i, a, o, s, c) {
1699
+ f(this, "text", void 0), f(this, "style", void 0), f(this, "width", void 0), f(this, "height", void 0), f(this, "lines", void 0), f(this, "lineWidths", void 0), f(this, "lineHeight", void 0), f(this, "maxLineWidth", void 0), f(this, "fontProperties", void 0), this.text = e, this.style = t, this.width = n, this.height = r, this.lines = i, this.lineWidths = a, this.lineHeight = o, this.maxLineWidth = s, this.fontProperties = c;
1701
1700
  }
1702
1701
  static get canvas() {
1703
- if (!n._canvas) {
1704
- let j;
1702
+ if (!e._canvas) {
1703
+ let t;
1705
1704
  try {
1706
- let M = new OffscreenCanvas(0, 0);
1707
- if (M.getContext("2d", { willReadFrequently: !0 }).measureText) return n._canvas = M, M;
1708
- j = createCanvas(10, 10);
1709
- } catch (n) {
1710
- j = createCanvas(10, 10);
1705
+ let n = new OffscreenCanvas(0, 0);
1706
+ if (n.getContext("2d", { willReadFrequently: !0 }).measureText) return e._canvas = n, n;
1707
+ t = W(10, 10);
1708
+ } catch (e) {
1709
+ t = W(10, 10);
1711
1710
  }
1712
- n._canvas = j;
1711
+ e._canvas = t;
1713
1712
  }
1714
- return n._canvas;
1713
+ return e._canvas;
1715
1714
  }
1716
1715
  static get context() {
1717
- return n._context || (n._context = n.canvas.getContext("2d", { willReadFrequently: !0 })), n._context;
1718
- }
1719
- static measureText(j, M) {
1720
- let N = `${j}-${M.styleKey}`;
1721
- if (n._measurementCache.has(N)) return n._measurementCache.get(N);
1722
- let P = M._fontString, F = n.measureFont(P);
1723
- F.fontSize === 0 && (F.fontSize = M.fontSize, F.ascent = M.fontSize, F.descent = 0);
1724
- let I = n.context;
1725
- I.font = P;
1726
- let L = j.split(NEWLINE_MATCH_REGEX), R = Array(L.length), z = 0;
1727
- for (let j = 0; j < L.length; ++j) {
1728
- let N = n._measureText(L[j], M.letterSpacing);
1729
- R[j] = N, z = Math.max(z, N);
1716
+ return e._context || (e._context = e.canvas.getContext("2d", { willReadFrequently: !0 })), e._context;
1717
+ }
1718
+ static measureText(t, n) {
1719
+ let r = `${t}-${n.styleKey}`;
1720
+ if (e._measurementCache.has(r)) return e._measurementCache.get(r);
1721
+ let i = n._fontString, a = e.measureFont(i);
1722
+ a.fontSize === 0 && (a.fontSize = n.fontSize, a.ascent = n.fontSize, a.descent = 0);
1723
+ let o = e.context;
1724
+ o.font = i;
1725
+ let s = t.split(Ue), c = Array.from({ length: s.length }), l = 0;
1726
+ for (let t = 0; t < s.length; ++t) {
1727
+ let r = e._measureText(s[t], n.letterSpacing);
1728
+ c[t] = r, l = Math.max(l, r);
1730
1729
  }
1731
- let B = M.lineHeight || F.fontSize, V = new n(j, M, z, Math.max(B, F.fontSize + (L.length - 1) * (B + M.leading)), L, R, B, z, F);
1732
- return n._measurementCache.set(N, V), V;
1733
- }
1734
- static _measureText(j, M) {
1735
- var N, P;
1736
- let F = n.context;
1737
- F.letterSpacing = "0px", F.textLetterSpacing = M;
1738
- let I = F.measureText(j), L = I.width, R = 0;
1739
- L > 0 && (R = (n.graphemeSegmenter(j).length - 1) * M, L += R);
1740
- let z = -((N = I.actualBoundingBoxLeft) == null ? 0 : N), B = ((P = I.actualBoundingBoxRight) == null ? 0 : P) - z;
1741
- return I.width > 0 && (B += R), Math.max(L, B);
1742
- }
1743
- static measureFont(j) {
1744
- var M, N;
1745
- if (n._fonts[j]) return n._fonts[j];
1746
- let P = n.context;
1747
- P.font = j;
1748
- let F = P.measureText(n.METRICS_STRING + n.BASELINE_SYMBOL), I = (M = F.actualBoundingBoxAscent) == null ? 0 : M, L = (N = F.actualBoundingBoxDescent) == null ? 0 : N, R = {
1749
- ascent: I,
1750
- descent: L,
1751
- fontSize: I + L
1730
+ let u = n.lineHeight || a.fontSize, d = new e(t, n, l, Math.max(u, a.fontSize + (s.length - 1) * (u + n.leading)), s, c, u, l, a);
1731
+ return e._measurementCache.set(r, d), d;
1732
+ }
1733
+ static _measureText(t, n) {
1734
+ var r, i;
1735
+ let a = e.context;
1736
+ a.letterSpacing = "0px", a.textLetterSpacing = n;
1737
+ let o = a.measureText(t), s = o.width, c = 0;
1738
+ s > 0 && (c = (e.graphemeSegmenter(t).length - 1) * n, s += c);
1739
+ let l = -((r = o.actualBoundingBoxLeft) == null ? 0 : r), u = ((i = o.actualBoundingBoxRight) == null ? 0 : i) - l;
1740
+ return o.width > 0 && (u += c), Math.max(s, u);
1741
+ }
1742
+ static measureFont(t) {
1743
+ var n, r;
1744
+ if (e._fonts[t]) return e._fonts[t];
1745
+ let i = e.context;
1746
+ i.font = t;
1747
+ let a = i.measureText(e.METRICS_STRING + e.BASELINE_SYMBOL), o = (n = a.actualBoundingBoxAscent) == null ? 0 : n, s = (r = a.actualBoundingBoxDescent) == null ? 0 : r, c = {
1748
+ ascent: o,
1749
+ descent: s,
1750
+ fontSize: o + s
1752
1751
  };
1753
- return n._fonts[j] = R, R;
1752
+ return e._fonts[t] = c, c;
1754
1753
  }
1755
1754
  };
1756
- _TextMetrics = TextMetrics, _TextMetrics.METRICS_STRING = "|ÉqÅ", _TextMetrics.BASELINE_SYMBOL = "M", _TextMetrics._measurementCache = /* @__PURE__ */ new Map(), _TextMetrics._fonts = {}, _TextMetrics.graphemeSegmenter = (() => {
1757
- var n;
1758
- if (typeof ((n = Intl) == null ? void 0 : n.Segmenter) == "function") {
1759
- let n = new Intl.Segmenter();
1760
- return (j) => {
1761
- let M = n.segment(j), N = [], P = 0;
1762
- for (let n of M) N[P++] = n.segment;
1763
- return N;
1755
+ f(U, "METRICS_STRING", "|ÉqÅ"), f(U, "BASELINE_SYMBOL", "M"), f(U, "_canvas", void 0), f(U, "_context", void 0), f(U, "_measurementCache", /* @__PURE__ */ new Map()), f(U, "_fonts", {}), f(U, "graphemeSegmenter", (() => {
1756
+ var e;
1757
+ if (typeof ((e = Intl) == null ? void 0 : e.Segmenter) == "function") {
1758
+ let e = new Intl.Segmenter();
1759
+ return (t) => {
1760
+ let n = e.segment(t), r = [], i = 0;
1761
+ for (let e of n) r[i++] = e.segment;
1762
+ return r;
1764
1763
  };
1765
1764
  }
1766
- return (n) => [...n];
1767
- })();
1768
- function createCanvas(n, j) {
1769
- let M = document.createElement("canvas");
1770
- return M.width = n, M.height = j, M;
1765
+ return (e) => [...e];
1766
+ })());
1767
+ function W(e, t) {
1768
+ let n = document.createElement("canvas");
1769
+ return n.width = e, n.height = t, n;
1771
1770
  }
1772
- function generateTextTexture(n) {
1773
- let { text: j, style: M, resolution: N = 1, padding: P = 0 } = n, F = TextMetrics.measureText(j, M), I = Math.ceil(Math.ceil(Math.max(1, F.width) + P * 2) * N), L = Math.ceil(Math.ceil(Math.max(1, F.height) + P * 2) * N), R = CanvasPool.getOptimalCanvasAndContext(I, L);
1774
- return renderTextToCanvas(M, N, P, R, F), {
1775
- canvasAndContext: R,
1776
- frame: new Rectangle(0, 0, I, L)
1771
+ function We(e) {
1772
+ let { text: t, style: n, resolution: r = 1, padding: i = 0 } = e, a = U.measureText(t, n), o = Math.ceil(Math.ceil(Math.max(1, a.width) + i * 2) * r), s = Math.ceil(Math.ceil(Math.max(1, a.height) + i * 2) * r), c = Be.getOptimalCanvasAndContext(o, s);
1773
+ return Ge(n, r, i, c, a), {
1774
+ canvasAndContext: c,
1775
+ frame: new y(0, 0, o, s)
1777
1776
  };
1778
1777
  }
1779
- function renderTextToCanvas(n, j, M, N, P) {
1780
- let { context: F } = N, I = fontStringFromTextStyle(n), { lines: L, lineHeight: R, lineWidths: z, maxLineWidth: B, fontProperties: V } = P;
1781
- F.resetTransform(), F.scale(j, j), F.textBaseline = n.textBaseline, F.font = I;
1782
- let H = Math.min(0, (R - V.fontSize) / 2);
1783
- F.fillStyle = n.fill;
1784
- for (let j = 0; j < L.length; ++j) {
1785
- let P = getAlignmentOffset(z[j], B, n.align), F = j * R + V.ascent + H, I = 0;
1786
- if (n.align === "justify" && n.wordWrap && j < L.length - 1) {
1787
- let n = countSpaces(L[j]);
1788
- n > 0 && (I = (B - z[j]) / n);
1778
+ function Ge(e, t, n, r, i) {
1779
+ let { context: a } = r, o = He(e), { lines: s, lineHeight: c, lineWidths: l, maxLineWidth: u, fontProperties: d } = i;
1780
+ a.resetTransform(), a.scale(t, t), a.textBaseline = e.textBaseline, a.font = o;
1781
+ let f = Math.min(0, (c - d.fontSize) / 2);
1782
+ a.fillStyle = e.fill;
1783
+ for (let t = 0; t < s.length; ++t) {
1784
+ let i = Ke(l[t], u, e.align), a = t * c + d.ascent + f, o = 0;
1785
+ if (e.align === "justify" && e.wordWrap && t < s.length - 1) {
1786
+ let e = qe(s[t]);
1787
+ e > 0 && (o = (u - l[t]) / e);
1789
1788
  }
1790
- drawLetterSpacing(L[j], n, N, P + M, F + M, !1, I);
1789
+ Je(s[t], e, r, i + n, a + n, !1, o);
1791
1790
  }
1792
1791
  }
1793
- function getAlignmentOffset(n, j, M) {
1794
- return M === "right" ? j - n : M === "center" ? (j - n) / 2 : 0;
1792
+ function Ke(e, t, n) {
1793
+ return n === "right" ? t - e : n === "center" ? (t - e) / 2 : 0;
1795
1794
  }
1796
- function countSpaces(n) {
1797
- let j = 0;
1798
- for (let M = 0; M < n.length; M++) n.charCodeAt(M) === 32 && j++;
1799
- return j;
1795
+ function qe(e) {
1796
+ let t = 0;
1797
+ for (let n = 0; n < e.length; n++) e.charCodeAt(n) === 32 && t++;
1798
+ return t;
1800
1799
  }
1801
- function drawLetterSpacing(n, j, M, N, P, F = !1, I = 0) {
1802
- let L = M.context, R = j.letterSpacing;
1803
- if (R === 0 && I === 0) {
1804
- L.fillText(n, N, P);
1800
+ function Je(e, t, n, r, i, a = !1, o = 0) {
1801
+ let s = n.context, c = t.letterSpacing;
1802
+ if (c === 0 && o === 0) {
1803
+ s.fillText(e, r, i);
1805
1804
  return;
1806
1805
  }
1807
- if (I !== 0 && R === 0) {
1808
- let j = n.split(" "), M = N, F = L.measureText(" ").width;
1809
- for (let n = 0; n < j.length; ++n) L.fillText(j[n], M, P), M += L.measureText(j[n]).width + F + I;
1806
+ if (o !== 0 && c === 0) {
1807
+ let t = e.split(" "), n = r, a = s.measureText(" ").width;
1808
+ for (let e = 0; e < t.length; ++e) s.fillText(t[e], n, i), n += s.measureText(t[e]).width + a + o;
1810
1809
  return;
1811
1810
  }
1812
- let z = N, B = TextMetrics.graphemeSegmenter(n), V = L.measureText(n).width, H = 0;
1813
- for (let n = 0; n < B.length; ++n) {
1814
- let j = B[n];
1815
- L.fillText(j, z, P);
1816
- let M = "";
1817
- for (let j = n + 1; j < B.length; ++j) M += B[j];
1818
- H = L.measureText(M).width, z += V - H + R, j === "" && (z += I), V = H;
1811
+ let l = r, u = U.graphemeSegmenter(e), d = s.measureText(e).width, f = 0;
1812
+ for (let e = 0; e < u.length; ++e) {
1813
+ let t = u[e];
1814
+ s.fillText(t, l, i);
1815
+ let n = "";
1816
+ for (let t = e + 1; t < u.length; ++t) n += u[t];
1817
+ f = s.measureText(n).width, l += d - f + c, t === "" && (l += o), d = f;
1819
1818
  }
1820
1819
  }
1821
- var _TextureSource, TextureSource = class n extends eventemitter3_default {
1822
- constructor(j) {
1823
- super(), this.uid = uid("textureSource"), this._resolution = 1, this.pixelWidth = 1, this.pixelHeight = 1, this.width = 1, this.height = 1;
1824
- let M = {
1825
- ...n.defaultOptions,
1826
- ...j
1820
+ //#endregion
1821
+ //#region lib/renderer/texture/TextureSource.ts
1822
+ var G = class e extends c {
1823
+ constructor(t) {
1824
+ super(), f(this, "uid", D("textureSource")), f(this, "label", void 0), f(this, "_resolution", 1), f(this, "pixelWidth", 1), f(this, "pixelHeight", 1), f(this, "width", 1), f(this, "height", 1), f(this, "resource", void 0), f(this, "destroyed", void 0);
1825
+ let n = {
1826
+ ...e.defaultOptions,
1827
+ ...t
1827
1828
  };
1828
- this.label = j.label, this.resource = M.resource, this._resolution = M.resolution, M.width ? this.pixelWidth = j.width * this._resolution : this.pixelWidth = this.resource && this.resourceWidth || 1, M.height ? this.pixelHeight = j.height * this._resolution : this.pixelHeight = this.resource && this.resourceHeight || 1, this.width = this.pixelWidth / this._resolution, this.height = this.pixelHeight / this._resolution, this.destroyed = !1;
1829
+ this.label = t.label, this.resource = n.resource, this._resolution = n.resolution, n.width ? this.pixelWidth = t.width * this._resolution : this.pixelWidth = this.resource && this.resourceWidth || 1, n.height ? this.pixelHeight = t.height * this._resolution : this.pixelHeight = this.resource && this.resourceHeight || 1, this.width = this.pixelWidth / this._resolution, this.height = this.pixelHeight / this._resolution, this.destroyed = !1;
1829
1830
  }
1830
1831
  get resolution() {
1831
1832
  return this._resolution;
1832
1833
  }
1833
- set resolution(n) {
1834
- this._resolution !== n && (this._resolution = n, this.width = this.pixelWidth / n, this.height = this.pixelHeight / n);
1834
+ set resolution(e) {
1835
+ this._resolution !== e && (this._resolution = e, this.width = this.pixelWidth / e, this.height = this.pixelHeight / e);
1835
1836
  }
1836
1837
  get resourceWidth() {
1837
- let n = this.resource;
1838
- return n.naturalWidth || n.width;
1838
+ let e = this.resource;
1839
+ return e.naturalWidth || e.width;
1839
1840
  }
1840
1841
  get resourceHeight() {
1841
- let n = this.resource;
1842
- return n.naturalHeight || n.height;
1842
+ let e = this.resource;
1843
+ return e.naturalHeight || e.height;
1843
1844
  }
1844
- resize(n, j, M) {
1845
- M || (M = this._resolution), n || (n = this.width), j || (j = this.height);
1846
- let N = Math.round(n * M), P = Math.round(j * M);
1847
- return this.width = N / M, this.height = P / M, this._resolution = M, this.pixelWidth === N && this.pixelHeight === P ? !1 : (this.pixelWidth = N, this.pixelHeight = P, this.emit("resize", this), !0);
1845
+ resize(e, t, n) {
1846
+ n || (n = this._resolution), e || (e = this.width), t || (t = this.height);
1847
+ let r = Math.round(e * n), i = Math.round(t * n);
1848
+ return this.width = r / n, this.height = i / n, this._resolution = n, this.pixelWidth === r && this.pixelHeight === i ? !1 : (this.pixelWidth = r, this.pixelHeight = i, this.emit("resize", this), !0);
1848
1849
  }
1849
1850
  destroy() {
1850
1851
  this.destroyed = !0, this.resource = null, this.emit("destroy", this), this.removeAllListeners();
1851
1852
  }
1852
1853
  };
1853
- _TextureSource = TextureSource, _TextureSource.defaultOptions = { resolution: 1 };
1854
- var CanvasSource = class extends TextureSource {
1855
- constructor(n) {
1856
- n.resource || (n.resource = createCanvas()), n.width || (n.width = n.resource.width, n.autoDensity || (n.width /= n.resolution)), n.height || (n.height = n.resource.height, n.autoDensity || (n.height /= n.resolution)), super(n), this.autoDensity = n.autoDensity, this.resizeCanvas();
1854
+ f(G, "defaultOptions", { resolution: 1 });
1855
+ var Ye = class extends G {
1856
+ constructor(e) {
1857
+ e.resource || (e.resource = W()), e.width || (e.width = e.resource.width, e.autoDensity || (e.width /= e.resolution)), e.height || (e.height = e.resource.height, e.autoDensity || (e.height /= e.resolution)), super(e), f(this, "autoDensity", void 0), this.autoDensity = e.autoDensity, this.resizeCanvas();
1857
1858
  }
1858
1859
  resizeCanvas() {
1859
1860
  this.autoDensity && (this.resource.style.width = `${this.width}px`, this.resource.style.height = `${this.height}px`), (this.resource.width !== this.pixelWidth || this.resource.height !== this.pixelHeight) && (this.resource.width = this.pixelWidth, this.resource.height = this.pixelHeight);
1860
1861
  }
1861
- resize(n = this.width, j = this.height, M = this._resolution) {
1862
- let N = super.resize(n, j, M);
1863
- return N && this.resizeCanvas(), N;
1862
+ resize(e = this.width, t = this.height, n = this._resolution) {
1863
+ let r = super.resize(e, t, n);
1864
+ return r && this.resizeCanvas(), r;
1864
1865
  }
1865
- }, Texture = class extends eventemitter3_default {
1866
- constructor({ source: n, label: j, frame: M, orig: N, rotate: P } = {}) {
1867
- if (super(), this.frame = new Rectangle(), this.noFrame = !1, this.label = j, this.source = n, M) this.frame.copyFrom(M);
1866
+ }, K = class extends c {
1867
+ constructor({ source: e, label: t, frame: n, orig: r, rotate: i } = {}) {
1868
+ if (super(), f(this, "label", void 0), f(this, "_source", void 0), f(this, "orig", void 0), f(this, "frame", new y()), f(this, "rotate", void 0), f(this, "destroyed", void 0), f(this, "noFrame", !1), this.label = t, this.source = e, n) this.frame.copyFrom(n);
1868
1869
  else {
1869
1870
  this.noFrame = !0;
1870
- let { width: j, height: M } = n;
1871
- this.frame.width = j, this.frame.height = M;
1871
+ let { width: t, height: n } = e;
1872
+ this.frame.width = t, this.frame.height = n;
1872
1873
  }
1873
- this.orig = N || this.frame, this.rotate = P == null ? 0 : P, this.destroyed = !1;
1874
+ this.orig = r || this.frame, this.rotate = i == null ? 0 : i, this.destroyed = !1;
1874
1875
  }
1875
1876
  get source() {
1876
1877
  return this._source;
1877
1878
  }
1878
- set source(n) {
1879
- this._source && this._source.off("resize", this.update, this), this._source = n, n.on("resize", this.update, this);
1879
+ set source(e) {
1880
+ this._source && this._source.off("resize", this.update, this), this._source = e, e.on("resize", this.update, this);
1880
1881
  }
1881
1882
  get width() {
1882
1883
  return this.orig.width;
@@ -1887,100 +1888,76 @@ var CanvasSource = class extends TextureSource {
1887
1888
  update() {
1888
1889
  this.noFrame && (this.frame.width = this._source.width, this.frame.height = this._source.height);
1889
1890
  }
1890
- destroy(n = !1) {
1891
- this._source && (this._source.off("resize", this.update, this), n && (this._source.destroy(), this._source = null)), this.destroyed = !0, this.emit("destroy", this), this.removeAllListeners();
1891
+ destroy(e = !1) {
1892
+ this._source && (this._source.off("resize", this.update, this), e && (this._source.destroy(), this._source = null)), this.destroyed = !0, this.emit("destroy", this), this.removeAllListeners();
1892
1893
  }
1893
1894
  };
1894
- Texture.EMPTY = new Texture({
1895
+ f(K, "EMPTY", void 0), K.EMPTY = new K({
1895
1896
  label: "EMPTY",
1896
- source: new TextureSource({ label: "EMPTY" })
1897
+ source: new G({ label: "EMPTY" })
1897
1898
  });
1898
- var _TextSystem, TextSystem = class {
1899
- constructor(n) {
1900
- this._activeTexture = {}, this.renderer = n;
1901
- }
1902
- getManagedTexture(n) {
1903
- n._resolution = n._autoResolution ? this.renderer.resolution : n.resolution;
1904
- let j = n.styleKey;
1905
- if (this._activeTexture[j]) return this._activeTexture[j];
1906
- let M = this.getTexture({
1907
- text: n.text,
1908
- style: n.style,
1909
- resolution: n._resolution
1899
+ //#endregion
1900
+ //#region lib/scene/text/TextSystem.ts
1901
+ var Xe = class {
1902
+ constructor(e) {
1903
+ f(this, "renderer", void 0), f(this, "_activeTexture", {}), this.renderer = e;
1904
+ }
1905
+ getManagedTexture(e) {
1906
+ e._resolution = e._autoResolution ? this.renderer.resolution : e.resolution;
1907
+ let t = e.styleKey;
1908
+ if (this._activeTexture[t]) return this._activeTexture[t];
1909
+ let n = this.getTexture({
1910
+ text: e.text,
1911
+ style: e.style,
1912
+ resolution: e._resolution
1910
1913
  });
1911
- return this._activeTexture[j] = M, M;
1912
- }
1913
- getTexture(n) {
1914
- let { text: j, style: M } = n, N = n.resolution || this.renderer.resolution, { frame: P, canvasAndContext: F } = generateTextTexture({
1915
- text: j,
1916
- style: M,
1917
- resolution: N
1918
- }), I = F.canvas, L = new Texture({ source: new TextureSource({
1919
- resource: I,
1920
- resolution: N
1914
+ return this._activeTexture[t] = n, n;
1915
+ }
1916
+ getTexture(e) {
1917
+ let { text: t, style: n } = e, r = e.resolution || this.renderer.resolution, { frame: i, canvasAndContext: a } = We({
1918
+ text: t,
1919
+ style: n,
1920
+ resolution: r
1921
+ }), o = a.canvas, s = new K({ source: new G({
1922
+ resource: o,
1923
+ resolution: r
1921
1924
  }) });
1922
- return L.frame.width = P.width / N, L.frame.height = P.height / N, L;
1925
+ return s.frame.width = i.width / r, s.frame.height = i.height / r, s;
1923
1926
  }
1924
1927
  };
1925
- _TextSystem = TextSystem, _TextSystem.desc = { name: "text" };
1926
- var _StencilMaskPipe, StencilMaskPipe = class {
1927
- constructor(n) {
1928
- this._canvasMaskStack = [], this._renderer = n;
1929
- }
1930
- push(n, j) {
1931
- j.add({
1932
- renderPipeId: "stencilMask",
1933
- action: "pushMaskBegin",
1934
- mask: n
1935
- });
1928
+ f(Xe, "desc", { name: "text" });
1929
+ //#endregion
1930
+ //#region lib/system/CanvasContextSystem.ts
1931
+ var Ze = class {
1932
+ constructor(e) {
1933
+ f(this, "_renderer", void 0), f(this, "rootContext", void 0), f(this, "activeConext", void 0), f(this, "activeResolution", 1), f(this, "globalTransform", new _()), this._renderer = e;
1936
1934
  }
1937
- pop(n, j) {
1938
- this._renderer.renderPipes.batch.break(j), j.add({
1939
- renderPipeId: "stencilMask",
1940
- action: "popMaskEnd",
1941
- mask: n
1942
- });
1943
- }
1944
- execute(n) {
1945
- if (n.action !== "pushMaskBegin" && n.action !== "popMaskEnd") return;
1946
- let j = this._renderer.canvasContext, M = j.activeConext;
1947
- if (n.action === "popMaskEnd") {
1948
- this._canvasMaskStack.pop() && M.restore();
1949
- return;
1950
- }
1951
- let N = n.mask.mask, P = N.context.instructions, F = N._roundPixels === 1;
1952
- M.save(), j.setContextTransform(N.relativeGroupTransform, F), M.beginPath();
1953
- for (let n = 0; n < P.length; ++n) {
1954
- let j = P[n], N = j.action;
1955
- if (N !== "fill" && N !== "stroke") return;
1956
- let F = j.data.path.shapePath.shapePrimitives;
1957
- for (let n = 0; n < F.length; ++n) {
1958
- let j = F[n].shape;
1959
- buildShapePath(M, j);
1960
- }
1961
- }
1962
- M.clip(), this._canvasMaskStack.push(!0);
1935
+ init() {
1936
+ this.activeConext = this._renderer.canvas.getContext("2d"), this.rootContext = this.activeConext, this.activeResolution = this._renderer.resolution;
1963
1937
  }
1964
- destroy() {
1965
- this._renderer = null;
1938
+ setContextTransform(e, t, n) {
1939
+ let r = this.activeResolution, i = _.append(this.globalTransform, e);
1940
+ n || (n = this.activeResolution), t ? this.activeConext.setTransform(i.a * n, i.b * n, i.c * n, i.d * n, i.tx * r | 0, i.ty * r | 0) : this.activeConext.setTransform(i.a * n, i.b * n, i.c * n, i.d * n, i.tx * r, i.ty * r);
1966
1941
  }
1967
1942
  };
1968
- _StencilMaskPipe = StencilMaskPipe, _StencilMaskPipe.desc = { name: "stencilMask" };
1969
- var RenderTexture = class n extends Texture {
1970
- static create(j) {
1971
- return new n({ source: new TextureSource(j) });
1972
- }
1973
- }, Sprite = class extends ViewContainer {
1974
- constructor(n = Texture.EMPTY) {
1975
- n instanceof Texture && (n = { texture: n });
1976
- let { texture: j = Texture.EMPTY, width: M, height: N, ...P } = n;
1943
+ f(Ze, "desc", { name: "canvasContext" });
1944
+ //#endregion
1945
+ //#region lib/renderer/texture/RenderTexture.ts
1946
+ var Qe = class e extends K {
1947
+ static create(t) {
1948
+ return new e({ source: new G(t) });
1949
+ }
1950
+ }, $e = class extends P {
1951
+ constructor(e = K.EMPTY) {
1952
+ e instanceof K && (e = { texture: e });
1953
+ let { texture: t = K.EMPTY, width: n, height: r, ...i } = e;
1977
1954
  super({
1978
1955
  label: "Sprite",
1979
- ...P
1980
- }), this.renderPipeId = "sprite", this.texture = j, this.anchor = new Vector2(), M != null && (this.width = M), N != null && (this.height = N);
1956
+ ...i
1957
+ }), f(this, "_texture", void 0), f(this, "anchor", void 0), f(this, "renderPipeId", "sprite"), f(this, "_width", void 0), f(this, "_height", void 0), this.texture = t, this.anchor = new b(), n != null && (this.width = n), r != null && (this.height = r);
1981
1958
  }
1982
- set texture(n) {
1983
- n || (n = Texture.EMPTY), this._texture !== n && (this._texture = n, this._width && this._setWidth(this.width, this._texture.orig.width), this._height && this._setHeight(this.height, this._texture.orig.height), this.onViewUpdate());
1959
+ set texture(e) {
1960
+ e || (e = K.EMPTY), this._texture !== e && (this._texture = e, this._width && this._setWidth(this.width, this._texture.orig.width), this._height && this._setHeight(this.height, this._texture.orig.height), this.onViewUpdate());
1984
1961
  }
1985
1962
  get texture() {
1986
1963
  return this._texture;
@@ -1988,31 +1965,31 @@ var RenderTexture = class n extends Texture {
1988
1965
  get height() {
1989
1966
  return Math.abs(this.scale.y) * this.texture.orig.height;
1990
1967
  }
1991
- set height(n) {
1992
- let j = this.texture.orig.height, M = Math.sign(this.scale.y) || 1;
1993
- j === 0 ? this.scale.y = M : this.scale.y = n / j * M, this._height = n;
1968
+ set height(e) {
1969
+ let t = this.texture.orig.height, n = Math.sign(this.scale.y) || 1;
1970
+ t === 0 ? this.scale.y = n : this.scale.y = e / t * n, this._height = e;
1994
1971
  }
1995
1972
  get width() {
1996
1973
  return Math.abs(this.scale.x) * this.texture.orig.width;
1997
1974
  }
1998
- set width(n) {
1999
- let j = this.texture.orig.width, M = Math.sign(this.scale.x) || 1;
2000
- j === 0 ? this.scale.x = M : this.scale.x = n / j * M, this._width = n;
1975
+ set width(e) {
1976
+ let t = this.texture.orig.width, n = Math.sign(this.scale.x) || 1;
1977
+ t === 0 ? this.scale.x = n : this.scale.x = e / t * n, this._width = e;
2001
1978
  }
2002
1979
  updateBounds() {
2003
- let n = this._bounds, { width: j, height: M } = this.texture.orig;
2004
- n.minX = -this.anchor.x * j, n.maxX = n.minX + j, n.minY = -this.anchor.y * M, n.maxY = n.minY + M;
2005
- }
2006
- }, Text = class extends ViewContainer {
2007
- constructor(n) {
2008
- var j;
2009
- let { text: M, resolution: N, style: P, width: F, height: I, ...L } = n;
2010
- super(L), this.renderPipeId = "text", this._didTextUpdate = !0, this._resolution = null, this._autoResolution = !0, this._anchor = new ObservablePoint({ _onUpdate: () => {
1980
+ let e = this._bounds, { width: t, height: n } = this.texture.orig;
1981
+ e.minX = -this.anchor.x * t, e.maxX = e.minX + t, e.minY = -this.anchor.y * n, e.maxY = e.minY + n;
1982
+ }
1983
+ }, et = class extends P {
1984
+ constructor(e) {
1985
+ var t;
1986
+ let { text: n, resolution: r, style: i, width: a, height: o, ...s } = e;
1987
+ super(s), f(this, "renderPipeId", "text"), f(this, "_anchor", void 0), f(this, "_didTextUpdate", !0), f(this, "_resolution", null), f(this, "_autoResolution", !0), f(this, "_text", void 0), f(this, "_style", void 0), this._anchor = new C({ _onUpdate: () => {
2011
1988
  this.onViewUpdate();
2012
- } }, 0, 0), this.text = (j = n.text) == null ? "" : j, this.style = P, this.resolution = N == null ? null : N, F != null && (this.width = F), I != null && (this.height = I);
1989
+ } }, 0, 0), this.text = (t = e.text) == null ? "" : t, this.style = i, this.resolution = r == null ? null : r, a != null && (this.width = a), o != null && (this.height = o);
2013
1990
  }
2014
- set resolution(n) {
2015
- this._autoResolution = n === null, this._resolution = n, this.onViewUpdate();
1991
+ set resolution(e) {
1992
+ this._autoResolution = e === null, this._resolution = e, this.onViewUpdate();
2016
1993
  }
2017
1994
  get resolution() {
2018
1995
  return this._resolution;
@@ -2020,226 +1997,497 @@ var RenderTexture = class n extends Texture {
2020
1997
  get anchor() {
2021
1998
  return this._anchor;
2022
1999
  }
2023
- set anchor(n) {
2024
- this._anchor.copyFrom(n);
2000
+ set anchor(e) {
2001
+ this._anchor.copyFrom(e);
2025
2002
  }
2026
2003
  get text() {
2027
2004
  return this._text;
2028
2005
  }
2029
- set text(n) {
2030
- let j = String(n);
2031
- this._text !== j && (this._text = j, this.onViewUpdate());
2006
+ set text(e) {
2007
+ let t = String(e);
2008
+ this._text !== t && (this._text = t, this.onViewUpdate());
2032
2009
  }
2033
2010
  get style() {
2034
2011
  return this._style;
2035
2012
  }
2036
- set style(n) {
2037
- n || (n = {}), n instanceof TextStyle ? this._style = n : this._style = new TextStyle(n), this.onViewUpdate();
2013
+ set style(e) {
2014
+ e || (e = {}), e instanceof H ? this._style = e : this._style = new H(e), this.onViewUpdate();
2038
2015
  }
2039
2016
  get width() {
2040
2017
  return Math.abs(this.scale.x) * this.bounds.width;
2041
2018
  }
2042
- set width(n) {
2043
- this._setWidth(n, this.bounds.width);
2019
+ set width(e) {
2020
+ this._setWidth(e, this.bounds.width);
2044
2021
  }
2045
2022
  get height() {
2046
2023
  return Math.abs(this.scale.y) * this.bounds.height;
2047
2024
  }
2048
- set height(n) {
2049
- this._setHeight(n, this.bounds.height);
2025
+ set height(e) {
2026
+ this._setHeight(e, this.bounds.height);
2050
2027
  }
2051
2028
  onViewUpdate() {
2052
2029
  this.didViewUpdate || (this._didTextUpdate = !0), super.onViewUpdate();
2053
2030
  }
2054
2031
  updateBounds() {
2055
- let n = this._bounds, j = this._anchor, M = TextMetrics.measureText(this._text, this._style), N = M.width, P = M.height;
2056
- n.minX = -j._x * N, n.minY = -j._y * P, n.maxX = n.minX + N, n.maxY = n.minY + P;
2032
+ let e = this._bounds, t = this._anchor, n = U.measureText(this._text, this._style), r = n.width, i = n.height;
2033
+ e.minX = -t._x * r, e.minY = -t._y * i, e.maxX = e.minX + r, e.maxY = e.minY + i;
2057
2034
  }
2058
2035
  get styleKey() {
2059
2036
  return `${this._text}:${this._style.styleKey}:${this._resolution}`;
2060
2037
  }
2061
- destroy(n = !1) {
2062
- super.destroy(n), this._bounds = null, this._anchor = null, (typeof n == "boolean" ? n : n != null && n.style) && this._style.destroy(n), this._style = null, this._text = null;
2063
- }
2064
- }, _ExtractSystem, ExtractSystem = class {
2065
- constructor(n) {
2066
- this._renderer = n;
2067
- }
2068
- texture(n) {
2069
- return this._generateTexture(n);
2070
- }
2071
- _generateTexture(n) {
2072
- n instanceof Container && (n = { target: n });
2073
- let j = n.resolution || this._renderer.resolution, M = n.target, N = new Bounds(), P = n.frame || getLocalBounds(M, N).rectangle;
2074
- P.width = Math.max(P.width, 1 / j) | 0, P.height = Math.max(P.height, 1 / j) | 0;
2075
- let F = RenderTexture.create({
2076
- width: P.width,
2077
- height: P.height,
2078
- resolution: j
2079
- }), I = new Matrix();
2080
- return I.tx = -P.x, I.ty = -P.y, this._renderer.render({
2038
+ destroy(e = !1) {
2039
+ super.destroy(e), this._bounds = null, this._anchor = null, (typeof e == "boolean" ? e : e != null && e.style) && this._style.destroy(e), this._style = null, this._text = null;
2040
+ }
2041
+ }, tt = class {
2042
+ constructor(e) {
2043
+ f(this, "_renderer", void 0), this._renderer = e;
2044
+ }
2045
+ texture(e) {
2046
+ return this._generateTexture(e);
2047
+ }
2048
+ _generateTexture(e) {
2049
+ e instanceof N && (e = { target: e });
2050
+ let t = e.resolution || this._renderer.resolution, n = e.target, r = new w(), i = e.frame || O(n, r).rectangle;
2051
+ i.width = Math.max(i.width, 1 / t) | 0, i.height = Math.max(i.height, 1 / t) | 0;
2052
+ let a = Qe.create({
2053
+ width: i.width,
2054
+ height: i.height,
2055
+ resolution: t
2056
+ }), o = T.get();
2057
+ return o.tx = -i.x, o.ty = -i.y, this._renderer.render({
2081
2058
  clearColor: "transparent",
2082
- container: M,
2083
- transform: I,
2084
- target: F
2085
- }), F;
2059
+ container: n,
2060
+ transform: o,
2061
+ target: a
2062
+ }), T.return(o), a;
2086
2063
  }
2087
2064
  };
2088
- _ExtractSystem = ExtractSystem, _ExtractSystem.desc = { name: "extract" };
2089
- var _CanvasContextSystem, CanvasContextSystem = class {
2090
- constructor(n) {
2091
- this.activeResolution = 1, this.globalTransform = new Matrix(), this._renderer = n;
2092
- }
2093
- init() {
2094
- this.activeConext = this._renderer.canvas.getContext("2d"), this.rootContext = this.activeConext, this.activeResolution = this._renderer.resolution;
2095
- }
2096
- setContextTransform(n, j, M) {
2097
- let N = this.activeResolution, P = Matrix.append(this.globalTransform, n);
2098
- M || (M = this.activeResolution), j ? this.activeConext.setTransform(P.a * M, P.b * M, P.c * M, P.d * M, P.tx * N | 0, P.ty * N | 0) : this.activeConext.setTransform(P.a * M, P.b * M, P.c * M, P.d * M, P.tx * N, P.ty * N);
2065
+ f(tt, "desc", { name: "extract" });
2066
+ //#endregion
2067
+ //#region lib/system/ViewSystem.ts
2068
+ var q = class e {
2069
+ constructor() {
2070
+ f(this, "canvas", void 0), f(this, "screen", void 0), f(this, "texture", void 0);
2099
2071
  }
2100
- };
2101
- _CanvasContextSystem = CanvasContextSystem, _CanvasContextSystem.desc = { name: "canvasContext" };
2102
- var _ViewSystem, ViewSystem = class n {
2103
2072
  get resolution() {
2104
2073
  return this.texture.source._resolution;
2105
2074
  }
2106
- set resolution(n) {
2107
- this.texture.source.resize(this.texture.source.width, this.texture.source.height, n);
2075
+ set resolution(e) {
2076
+ this.texture.source.resize(this.texture.source.width, this.texture.source.height, e);
2108
2077
  }
2109
- init(j) {
2110
- j = {
2111
- ...n.defaultOptions,
2112
- ...j
2113
- }, this.screen = new Rectangle(0, 0, j.width, j.height), this.canvas = createCanvas(), this.texture = new Texture({ source: new CanvasSource({
2078
+ init(t) {
2079
+ t = {
2080
+ ...e.defaultOptions,
2081
+ ...t
2082
+ }, this.screen = new y(0, 0, t.width, t.height), this.canvas = W(), this.texture = new K({ source: new Ye({
2114
2083
  resource: this.canvas,
2115
- ...j
2116
- }) }), this.resolution = j.resolution;
2084
+ ...t
2085
+ }) }), this.resolution = t.resolution;
2117
2086
  }
2118
- resize(n, j, M) {
2119
- this.texture.source.resize(n, j, M), this.screen.width = this.texture.frame.width, this.screen.height = this.texture.frame.height;
2087
+ resize(e, t, n) {
2088
+ this.texture.source.resize(e, t, n), this.screen.width = this.texture.frame.width, this.screen.height = this.texture.frame.height;
2120
2089
  }
2121
2090
  };
2122
- _ViewSystem = ViewSystem, _ViewSystem.desc = { name: "view" }, _ViewSystem.defaultOptions = {
2091
+ f(q, "desc", { name: "view" }), f(q, "defaultOptions", {
2123
2092
  width: 800,
2124
2093
  height: 600,
2125
2094
  autoDensity: !1
2095
+ });
2096
+ //#endregion
2097
+ //#region lib/events/FederatedEvent.ts
2098
+ var J = class {
2099
+ constructor(e) {
2100
+ f(this, "system", void 0), f(this, "target", void 0), f(this, "currentTarget", void 0), f(this, "nativeEvent", void 0), f(this, "type", void 0), f(this, "global", new b()), f(this, "screen", new b()), f(this, "path", void 0), this.system = e;
2101
+ }
2102
+ getLocalPosition(e, t) {
2103
+ return e.worldTransform.applyInverse(t || this.global);
2104
+ }
2105
+ composedPath() {
2106
+ return (!this.path || this.path[this.path.length - 1] !== this.target) && (this.path = this.target ? this.system.propagationPath(this.target) : []), this.path;
2107
+ }
2108
+ }, nt = 2048, rt = class {
2109
+ constructor(e) {
2110
+ f(this, "renderer", void 0), f(this, "domElement", null), f(this, "rootTarget", null), f(this, "resolution", 1), f(this, "eventPool", /* @__PURE__ */ new Map()), f(this, "_allInteractiveElements", []), f(this, "_hitElements", []), f(this, "_rootPointerEvent", void 0), f(this, "_isPointerMoveEvent", !1), f(this, "mappingState", { trackingData: {} }), this.renderer = e, this.resolution = e.resolution, this._rootPointerEvent = new J(null), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerOverOut = this._onPointerOverOut.bind(this), this.init();
2111
+ }
2112
+ get pointer() {
2113
+ return this._rootPointerEvent;
2114
+ }
2115
+ trackingData(e) {
2116
+ return this.mappingState.trackingData[e] || (this.mappingState.trackingData[e] = {
2117
+ pressTargetsByButton: {},
2118
+ clicksByButton: {},
2119
+ overTargets: null
2120
+ }), this.mappingState.trackingData[e];
2121
+ }
2122
+ init() {
2123
+ let e = this.renderer.canvas;
2124
+ this.setTargetElement(e);
2125
+ }
2126
+ setTargetElement(e) {
2127
+ this._removeEvents(), this.domElement = e, this._addEvents();
2128
+ }
2129
+ dispatchEvent(e, t) {
2130
+ if (!e.target) return;
2131
+ let n = e.composedPath();
2132
+ for (let r = 0; r < n.length - 1; ++r) e.currentTarget = n[r], this._notifyTarget(e, t);
2133
+ e.currentTarget = e.target, this._notifyTarget(e, t);
2134
+ }
2135
+ _notifyTarget(e, t) {
2136
+ t != null || (t = e.type);
2137
+ let n = e.currentTarget._events[t];
2138
+ if (n) if ("fn" in n) n.once && e.target.removeListener(t, n.fn, void 0, !0), n.fn.call(n.context, e);
2139
+ else for (let r = 0; r < n.length; ++r) {
2140
+ let i = n[r];
2141
+ i.once && e.target.removeListener(t, i.fn, void 0, !0), i.fn.call(i.context, e);
2142
+ }
2143
+ }
2144
+ propagationPath(e) {
2145
+ let t = [e];
2146
+ for (let n = 0; n < nt && (e !== this.rootTarget || e.parent); ++n) {
2147
+ if (!e.parent) throw Error("Cannot find propagation path to disconnected target");
2148
+ t.push(e.parent), e = e.parent;
2149
+ }
2150
+ return t.reverse(), t;
2151
+ }
2152
+ _removeEvents() {
2153
+ let e = this.domElement;
2154
+ e && (globalThis.document.removeEventListener("pointermove", this._onPointerMove, !0), e.removeEventListener("pointerdown", this._onPointerDown, !0), e.removeEventListener("pointerleave", this._onPointerOverOut, !0), e.removeEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.removeEventListener("pointerup", this._onPointerUp, !0));
2155
+ }
2156
+ _addEvents() {
2157
+ let e = this.domElement;
2158
+ if (!e) return;
2159
+ let t = e.style;
2160
+ t && (t.touchAction = "none"), globalThis.document.addEventListener("pointermove", this._onPointerMove, !0), e.addEventListener("pointerdown", this._onPointerDown, !0), e.addEventListener("pointerleave", this._onPointerOverOut, !0), e.addEventListener("pointerover", this._onPointerOverOut, !0), globalThis.document.addEventListener("pointerup", this._onPointerUp, !0);
2161
+ }
2162
+ _onPointerMove(e) {
2163
+ var t;
2164
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2165
+ this._isPointerMoveEvent = !0, this._allInteractiveElements.length = 0, this._hitElements.length = 0;
2166
+ let n = this._bootstrapEvent(this._rootPointerEvent, e), r = this.createPointEvent(n);
2167
+ this._isPointerMoveEvent = !1;
2168
+ let i = this.trackingData(e.pointerId), a = it(i.overTargets);
2169
+ if (((t = i.overTargets) == null ? void 0 : t.length) > 0 && a !== r.target) {
2170
+ let e = this.createPointEvent(n, "pointerout", a);
2171
+ this.dispatchEvent(e, "pointerout");
2172
+ let t = r.composedPath();
2173
+ if (!t.includes(a)) {
2174
+ let e = this.createPointEvent(n, "pointerleave", a);
2175
+ for (; e.target && !t.includes(e.target);) e.currentTarget = e.target, this._notifyTarget(e), e.target = e.target.parent;
2176
+ }
2177
+ }
2178
+ if (a !== r.target) {
2179
+ let e = "pointerover", t = this.clonePointEvent(r, e);
2180
+ this.dispatchEvent(t, e);
2181
+ let n = a == null ? void 0 : a.parent;
2182
+ for (; n && n !== this.rootTarget.parent && n !== r.target;) n = n.parent;
2183
+ if (!n || n === this.rootTarget.parent) {
2184
+ let e = this.clonePointEvent(r, "pointerenter");
2185
+ for (; e.target && e.target !== a && e.target !== this.rootTarget.parent;) e.currentTarget = e.target, this._notifyTarget(e), e.target = e.target.parent;
2186
+ }
2187
+ this.freeEvent(t);
2188
+ }
2189
+ this.dispatchEvent(r, "pointermove");
2190
+ let o = this._allInteractiveElements;
2191
+ for (let e = o.length - 1; e >= 0; --e) r.currentTarget = o[e], this._notifyTarget(r, "globalpointermove");
2192
+ this._allInteractiveElements.length = 0, this._hitElements.length = 0, i.overTargets = r.composedPath(), this.freeEvent(r);
2193
+ }
2194
+ _onPointerDown(e) {
2195
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2196
+ let t = this._bootstrapEvent(this._rootPointerEvent, e), n = this.createPointEvent(t);
2197
+ this.dispatchEvent(n, "pointerdown");
2198
+ let r = this.trackingData(e.pointerId);
2199
+ r.pressTargetsByButton[e.button] = n.composedPath(), this.freeEvent(n);
2200
+ }
2201
+ _onPointerOverOut(e) {
2202
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2203
+ let t = this._bootstrapEvent(this._rootPointerEvent, e), n = this.createPointEvent(t);
2204
+ this.dispatchEvent(n, "pointerout"), this.freeEvent(n);
2205
+ }
2206
+ _onPointerUp(e) {
2207
+ if (this.rootTarget = this.renderer.renderedObject, !this.rootTarget) return;
2208
+ let t = e.target;
2209
+ e.composedPath && e.composedPath().length > 1 && (t = e.composedPath()[0]);
2210
+ let n = this._bootstrapEvent(this._rootPointerEvent, e), r = t === this.domElement ? "" : "outside", i = this.createPointEvent(n);
2211
+ this.dispatchEvent(i, `pointerup${r}`), this.freeEvent(i);
2212
+ }
2213
+ _isInteractive(e) {
2214
+ return e === "static";
2215
+ }
2216
+ _bootstrapEvent(e, t) {
2217
+ return e.nativeEvent = t, this.mapPositionToPoint(e.screen, t.clientX, t.clientY), e.global.copyFrom(e.screen), t.type === "pointerleave" ? e.type = "pointerout" : e.type = t.type, e;
2218
+ }
2219
+ allocateEvent(e) {
2220
+ this.eventPool.has(e) || this.eventPool.set(e, []);
2221
+ let t = this.eventPool.get(e).pop() || new e(this);
2222
+ return t.currentTarget = null, t.path = null, t.target = null, t;
2223
+ }
2224
+ freeEvent(e) {
2225
+ let t = e.constructor;
2226
+ this.eventPool.has(t) || this.eventPool.set(t, []), this.eventPool.get(t).push(e);
2227
+ }
2228
+ createPointEvent(e, t, n) {
2229
+ var r;
2230
+ let i = this.allocateEvent(J);
2231
+ return i.global.copyFrom(e.global), i.screen.copyFrom(e.screen), i.nativeEvent = e.nativeEvent, i.target = (r = n == null ? this.hitTest(i.global.x, i.global.y) : n) == null ? this._hitElements[0] : r, t && (i.type = t), i;
2232
+ }
2233
+ clonePointEvent(e, t) {
2234
+ let n = this.allocateEvent(J);
2235
+ return n.nativeEvent = e.nativeEvent, n.global = e.global, n.type = t == null ? e.type : t, n.path = e.composedPath().slice(), n.target = e.target, n;
2236
+ }
2237
+ mapPositionToPoint(e, t, n) {
2238
+ let r = this.domElement, i = r.isConnected ? r.getBoundingClientRect() : {
2239
+ x: 0,
2240
+ y: 0,
2241
+ width: r.width,
2242
+ height: r.height,
2243
+ left: 0,
2244
+ top: 0
2245
+ }, a = 1 / this.resolution;
2246
+ return e.x = (t - i.left) * (r.width / i.width) * a, e.y = (n - i.top) * (r.height / i.height) * a, e;
2247
+ }
2248
+ hitTest(e, t) {
2249
+ let n = this._isPointerMoveEvent, r = this[n ? "hitTestMoveRecursive" : "hitTestRecursive"](this.rootTarget, this.rootTarget.eventMode, new b(e, t));
2250
+ return r && r[0];
2251
+ }
2252
+ _interactivePrune(e) {
2253
+ return !e || !e.visible || !e.renderable || !e.measurable || e.eventMode === "none";
2254
+ }
2255
+ hitTestMoveRecursive(e, t, n) {
2256
+ let r = !1;
2257
+ if (this._interactivePrune(e)) return;
2258
+ let i = e.children;
2259
+ if (i && i.length > 0) for (let a = i.length - 1; a >= 0; --a) {
2260
+ let o = i[a], s = this.hitTestMoveRecursive(o, this._isInteractive(t) ? t : o.eventMode, n);
2261
+ if (s) {
2262
+ if (s.length > 0 && !s[s.length - 1].parent) continue;
2263
+ let t = this._isInteractive(e.eventMode);
2264
+ (s.length > 0 || t) && (t && this._allInteractiveElements.push(e), s.push(e)), this._hitElements.length === 0 && (this._hitElements = s), r = !0;
2265
+ }
2266
+ }
2267
+ let a = this._isInteractive(t), o = this._isInteractive(e.eventMode);
2268
+ if (o && this._allInteractiveElements.push(e), !(this._hitElements.length > 0)) {
2269
+ if (r) return this._hitElements;
2270
+ if (a && this.hitTestFn(e, n)) return o ? [e] : [];
2271
+ }
2272
+ }
2273
+ hitTestRecursive(e, t, n) {
2274
+ if (this._interactivePrune(e)) return;
2275
+ let r = e.children;
2276
+ for (let i = r.length - 1; i >= 0; i--) {
2277
+ let a = r[i], o = this.hitTestRecursive(a, this._isInteractive(t) ? t : a.eventMode, n);
2278
+ if (o) {
2279
+ let t = this._isInteractive(e.eventMode);
2280
+ return (o.length > 0 || t) && o.push(e), o;
2281
+ }
2282
+ }
2283
+ let i = this._isInteractive(t), a = this._isInteractive(e.eventMode);
2284
+ return i && this.hitTestFn(e, n) ? a ? [e] : [] : null;
2285
+ }
2286
+ hitTestFn(e, t) {
2287
+ if (e.hitArea) return !0;
2288
+ if (e.containsPoint) {
2289
+ let n = e.worldTransform.applyInverse(t);
2290
+ return e.containsPoint(n);
2291
+ }
2292
+ return !1;
2293
+ }
2294
+ };
2295
+ f(rt, "desc", { name: "events" });
2296
+ function it(e) {
2297
+ if (!e) return;
2298
+ let t = e[0];
2299
+ for (let n = 1; n < e.length && e[n].parent === t; ++n) t = e[n];
2300
+ return t;
2301
+ }
2302
+ //#endregion
2303
+ //#region lib/scene/container/utils/updateRenderGroupTransform.ts
2304
+ var at = 7;
2305
+ function ot(e, t = !1) {
2306
+ let n = e.root;
2307
+ e.worldTransform.copyFrom(n.localTransform);
2308
+ let r = e.childrenToUpdate;
2309
+ for (let t in r) {
2310
+ let n = Number(t), i = r[n], a = i.list, o = i.index;
2311
+ for (let t = 0; t < o; ++t) {
2312
+ let r = a[t];
2313
+ r.parentRenderGroup === e && r.relativeRenderGroupDepth === n && st(r, 0);
2314
+ }
2315
+ ve(a, o), i.index = 0;
2316
+ }
2317
+ if (t) for (let n = 0; n < e.renderGroupChildren.length; ++n) ot(e.renderGroupChildren[n], t);
2318
+ }
2319
+ function st(e, t) {
2320
+ e.didChange = !1;
2321
+ let n = e.parent, r = e.localTransform;
2322
+ e.updateLocalTransform(), n && (t |= e._updateFlags, e.relativeGroupTransform.appendFrom(r, n.relativeGroupTransform), t & at && ct(e, n, t));
2323
+ let i = e.children;
2324
+ for (let e = 0; e < i.length; e++) st(i[e], t);
2325
+ }
2326
+ function ct(e, t, n) {
2327
+ if (n & 1) {
2328
+ e.groupColor = t.groupColor;
2329
+ let n = e.localAlpha * t.groupAlpha;
2330
+ n = n < 0 ? 0 : n > 1 ? 1 : n, e.groupAlpha = n, e.groupColorAlpha = e.groupColor + ((n * 255 | 0) << 24);
2331
+ }
2332
+ n & 4 && (e.globalDisplayStatus = e.localDisplayStatus & t.globalDisplayStatus), e._updateFlags = 0;
2333
+ }
2334
+ //#endregion
2335
+ //#region lib/scene/container/utils/validateRenderables.ts
2336
+ function lt(e, t) {
2337
+ let { list: n, index: r } = e.childrenRenderablesToUpdate, i = !1;
2338
+ for (let e = 0; e < r; ++e) {
2339
+ let r = n[e];
2340
+ if (i = t[r.renderPipeId].validateRenderable(r), i) break;
2341
+ }
2342
+ return e.structureDidChange = i, i;
2343
+ }
2344
+ //#endregion
2345
+ //#region lib/system/RenderGroupSystem.ts
2346
+ var ut = class {
2347
+ constructor(e) {
2348
+ f(this, "renderer", void 0), this.renderer = e;
2349
+ }
2350
+ _updateRenderGroup(e) {
2351
+ let t = this.renderer, n = t.renderPipes;
2352
+ e.runOnRender(t), e.instructionSet.renderPipes = n, e.structureDidChange ? ve(e.childrenRenderablesToUpdate.list, 0) : lt(e, n), ot(e), e.structureDidChange && (e.structureDidChange = !1, this._buildInstructions(e, t)), e.childrenRenderablesToUpdate.index = 0;
2353
+ }
2354
+ render({ container: e, transform: t }) {
2355
+ let n = this.renderer;
2356
+ t && e.renderGroup.localTransform.copyFrom(t), n.canvasContext.globalTransform = t ? e.renderGroup.localTransform : e.renderGroup.worldTransform, this._updateRenderGroup(e.renderGroup), dt(e.renderGroup, n.renderPipes);
2357
+ }
2358
+ _buildInstructions(e, t) {
2359
+ let n = t.renderPipes, r = e.root;
2360
+ e.instructionSet.reset(), r.sortableChildren && r.sortChildren(), n.batch.buildStart(), r.collectRenderablesWithEffects(n, e.instructionSet), n.batch.buildEnd(e.instructionSet);
2361
+ }
2126
2362
  };
2127
- var systems = [
2128
- ViewSystem,
2129
- EventSystem,
2130
- RenderGroupSystem,
2131
- TextSystem,
2132
- ExtractSystem,
2133
- CanvasContextSystem
2134
- ], pipes = [
2135
- BatchPipe,
2136
- GraphicsPipe,
2137
- TextPipe,
2138
- SpritePipe,
2139
- StencilMaskPipe
2140
- ], CanvasRenderer = class extends eventemitter3_default {
2363
+ f(ut, "desc", { name: "renderGroup" });
2364
+ function dt(e, t) {
2365
+ let { instructionSet: n } = e, r = n.instructions;
2366
+ for (let e = 0; e < n.instructionSize; e++) {
2367
+ let n = r[e];
2368
+ t[n.renderPipeId].execute(n);
2369
+ }
2370
+ }
2371
+ //#endregion
2372
+ //#region lib/renderer/index.ts
2373
+ var Y = [
2374
+ q,
2375
+ rt,
2376
+ ut,
2377
+ Xe,
2378
+ tt,
2379
+ Ze
2380
+ ], ft = [
2381
+ m,
2382
+ z,
2383
+ V,
2384
+ ze,
2385
+ Re
2386
+ ], pt = class extends c {
2141
2387
  constructor() {
2142
- super(), this.uid = uid("renderer"), this.renderedObject = null, this.renderPipes = {}, this.background = { color: "#000000" };
2388
+ super(), f(this, "uid", D("renderer")), f(this, "context", void 0), f(this, "background", void 0), f(this, "renderedObject", null), f(this, "_roundPixels", void 0), f(this, "resolution", void 0), f(this, "activeRenderGroup", void 0), f(this, "renderPipes", {}), this.background = { color: "#000000" };
2143
2389
  }
2144
2390
  get canvas() {
2145
2391
  return this.view.canvas;
2146
2392
  }
2147
2393
  _addPipes() {
2148
- pipes.forEach((n) => {
2149
- this.renderPipes[n.desc.name] = new n(this);
2394
+ ft.forEach((e) => {
2395
+ this.renderPipes[e.desc.name] = new e(this);
2150
2396
  });
2151
2397
  }
2152
2398
  _addSystems() {
2153
- systems.forEach((n) => {
2154
- this[n.desc.name] = new n(this);
2399
+ Y.forEach((e) => {
2400
+ this[e.desc.name] = new e(this);
2155
2401
  });
2156
2402
  }
2157
- async init(n) {
2158
- this.resolution = n.resolution || 1, this._addSystems(), this._addPipes();
2159
- for (let N = 0; N < systems.length; ++N) {
2160
- var j, M;
2161
- await ((j = (M = this[systems[N].desc.name]).init) == null ? void 0 : j.call(M, n));
2403
+ async init(e) {
2404
+ this.resolution = e.resolution || 1, this._addSystems(), this._addPipes();
2405
+ for (let r = 0; r < Y.length; ++r) {
2406
+ var t, n;
2407
+ await ((t = (n = this[Y[r].desc.name]).init) == null ? void 0 : t.call(n, e));
2162
2408
  }
2163
- n.backgroundColor && (this.background.color = n.backgroundColor), this._roundPixels = n.roundPixels ? 1 : 0;
2409
+ e.backgroundColor && (this.background.color = e.backgroundColor), this._roundPixels = +!!e.roundPixels;
2164
2410
  }
2165
2411
  get roundPixels() {
2166
2412
  return !!this._roundPixels;
2167
2413
  }
2168
- render(n) {
2169
- let j = n;
2170
- if (j instanceof Container && (j = { container: j }), this.renderedObject = j.container, j.transform || (j.container.updateLocalTransform(), j.transform = j.container.localTransform), j.clearColor != null || (j.clearColor = this.background.color), !j.container.visible) return;
2171
- j.container.enableRenderGroup();
2172
- let M = j.container.renderGroup;
2173
- if (this.activeRenderGroup = M, this.canvasContext.globalTransform = M.worldTransform, this.canvasContext.activeConext = this.canvasContext.rootContext, j.target) {
2174
- let { context: n } = ensureCanvas(j.target.source);
2175
- this.canvasContext.activeConext = n;
2414
+ render(e) {
2415
+ let t = e;
2416
+ if (t instanceof N && (t = { container: t }), this.renderedObject = t.container, t.transform || (t.container.updateLocalTransform(), t.transform = t.container.localTransform), t.clearColor != null || (t.clearColor = this.background.color), !t.container.visible) return;
2417
+ t.container.enableRenderGroup();
2418
+ let n = t.container.renderGroup;
2419
+ if (this.activeRenderGroup = n, this.canvasContext.globalTransform = n.worldTransform, this.canvasContext.activeConext = this.canvasContext.rootContext, t.target) {
2420
+ let { context: e } = mt(t.target.source);
2421
+ this.canvasContext.activeConext = e;
2176
2422
  }
2177
- this.clear(j), systems.forEach((n) => {
2178
- var M, N;
2179
- (M = (N = this[n.desc.name]).render) == null || M.call(N, j);
2423
+ this.clear(t), Y.forEach((e) => {
2424
+ var n, r;
2425
+ (n = (r = this[e.desc.name]).render) == null || n.call(r, t);
2180
2426
  });
2181
2427
  }
2182
- clear(n) {
2183
- let j = this.canvasContext.activeConext;
2184
- j.setTransform(1, 0, 0, 1, 0, 0), j.clearRect(0, 0, this.canvas.width, this.canvas.height), j.globalAlpha = 1, j.fillStyle = n.clearColor, j.fillRect(0, 0, this.canvas.width, this.canvas.height), j.globalAlpha = 1;
2428
+ clear(e) {
2429
+ let t = this.canvasContext.activeConext;
2430
+ t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, this.canvas.width, this.canvas.height), t.globalAlpha = 1, t.fillStyle = e.clearColor, t.fillRect(0, 0, this.canvas.width, this.canvas.height), t.globalAlpha = 1;
2185
2431
  }
2186
2432
  destroy() {
2187
- this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), pipes.forEach((n) => {
2188
- var j;
2189
- (j = this.renderPipes[n.desc.name]) == null || j.destroy();
2433
+ this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), ft.forEach((e) => {
2434
+ var t;
2435
+ (t = this.renderPipes[e.desc.name]) == null || t.destroy();
2190
2436
  }), this.renderPipes = null;
2191
2437
  }
2192
- resize(n, j, M) {
2193
- this.view.resize(n, j, M), this.emit("resize", this.view.screen.width, this.view.screen.height, this.view.resolution);
2438
+ resize(e, t, n) {
2439
+ this.view.resize(e, t, n), this.emit("resize", this.view.screen.width, this.view.screen.height, this.view.resolution);
2194
2440
  }
2195
2441
  };
2196
- function ensureCanvas(n) {
2197
- let j = n.resource;
2198
- return j || (j = createCanvas(n.pixelWidth, n.pixelHeight), n.resource = j), (j.width !== n.pixelWidth || j.height !== n.pixelHeight) && (j.width = n.pixelWidth, j.height = n.pixelHeight), {
2199
- canvas: j,
2200
- context: j.getContext("2d")
2442
+ function mt(e) {
2443
+ let t = e.resource;
2444
+ return t || (t = W(e.pixelWidth, e.pixelHeight), e.resource = t), (t.width !== e.pixelWidth || t.height !== e.pixelHeight) && (t.width = e.pixelWidth, t.height = e.pixelHeight), {
2445
+ canvas: t,
2446
+ context: t.getContext("2d")
2201
2447
  };
2202
2448
  }
2203
- var TickerListener = class {
2204
- constructor(n, j, M = 0, N = !1) {
2205
- this.next = null, this.previous = null, this.priority = 0, this._destroyed = !1, this._fn = n, this._context = j, this.priority = M, this._once = N;
2449
+ //#endregion
2450
+ //#region lib/ticker/TickerListener.ts
2451
+ var X = class {
2452
+ constructor(e, t, n = 0, r = !1) {
2453
+ f(this, "next", null), f(this, "previous", null), f(this, "priority", 0), f(this, "_fn", void 0), f(this, "_context", void 0), f(this, "_once", void 0), f(this, "_destroyed", !1), this._fn = e, this._context = t, this.priority = n, this._once = r;
2206
2454
  }
2207
- match(n, j) {
2208
- return this._fn === n && this._context === j;
2455
+ match(e, t) {
2456
+ return this._fn === e && this._context === t;
2209
2457
  }
2210
- emit(n) {
2211
- this._fn && (this._context ? this._fn.call(this._context, n) : this._fn(n));
2212
- let j = this.next;
2213
- return this._once && this.destroy(!0), this._destroyed && (this.next = null), j;
2458
+ emit(e) {
2459
+ this._fn && (this._context ? this._fn.call(this._context, e) : this._fn(e));
2460
+ let t = this.next;
2461
+ return this._once && this.destroy(!0), this._destroyed && (this.next = null), t;
2214
2462
  }
2215
- destroy(n) {
2463
+ destroy(e) {
2216
2464
  this._destroyed = !0, this._fn = null, this._context = null, this.previous && (this.previous.next = this.next), this.next && (this.next.previous = this.previous);
2217
- let j = this.next;
2218
- return this.next = n ? null : j, this.previous = null, j;
2465
+ let t = this.next;
2466
+ return this.next = e ? null : t, this.previous = null, t;
2219
2467
  }
2220
- connect(n) {
2221
- this.previous = n, n.next && (n.next.previous = this), this.next = n.next, n.next = this;
2468
+ connect(e) {
2469
+ this.previous = e, e.next && (e.next.previous = this), this.next = e.next, e.next = this;
2222
2470
  }
2223
- }, _Ticker, Ticker = class n {
2471
+ }, Z = class e {
2224
2472
  constructor() {
2225
- this.autoStart = !1, this.deltaTime = 1, this.lastTime = -1, this.speed = 1, this.started = !1, this._requestId = null, this._maxElapsedMS = 100, this._minElapsedMS = 0, this._lastFrame = -1, this._head = null, this._head = new TickerListener(null, null, Infinity), this.deltaMS = 1 / n.targetFPMS, this.elapsedMS = this.deltaMS, this._tick = (n) => {
2226
- this._requestId = null, this.started && (this.update(n), this.started && this._requestId === null && (this._requestId = requestAnimationFrame(this._tick)));
2473
+ f(this, "autoStart", !1), f(this, "deltaTime", 1), f(this, "deltaMS", void 0), f(this, "elapsedMS", void 0), f(this, "lastTime", -1), f(this, "speed", 1), f(this, "started", !1), f(this, "_tick", void 0), f(this, "_requestId", null), f(this, "_maxElapsedMS", 100), f(this, "_minElapsedMS", 0), f(this, "_lastFrame", -1), f(this, "_head", null), this._head = new X(null, null, Infinity), this.deltaMS = 1 / e.targetFPMS, this.elapsedMS = this.deltaMS, this._tick = (e) => {
2474
+ this._requestId = null, this.started && (this.update(e), this.started && this._requestId === null && (this._requestId = requestAnimationFrame(this._tick)));
2227
2475
  };
2228
2476
  }
2229
- update(j = performance.now()) {
2230
- let M;
2231
- if (j > this.lastTime) {
2232
- if (M = this.elapsedMS = j - this.lastTime, M > this._maxElapsedMS && (M = this._maxElapsedMS), M *= this.speed, this._minElapsedMS) {
2233
- let n = j - this._lastFrame | 0;
2234
- if (n < this._minElapsedMS) return;
2235
- this._lastFrame = j - n % this._minElapsedMS;
2477
+ update(t = performance.now()) {
2478
+ let n;
2479
+ if (t > this.lastTime) {
2480
+ if (n = this.elapsedMS = t - this.lastTime, n > this._maxElapsedMS && (n = this._maxElapsedMS), n *= this.speed, this._minElapsedMS) {
2481
+ let e = t - this._lastFrame | 0;
2482
+ if (e < this._minElapsedMS) return;
2483
+ this._lastFrame = t - e % this._minElapsedMS;
2236
2484
  }
2237
- this.deltaMS = M, this.deltaTime = this.deltaMS * n.targetFPMS;
2238
- let N = this._head, P = N.next;
2239
- for (; P;) P = P.emit(this);
2240
- N.next || this._cancelIfNeeded();
2485
+ this.deltaMS = n, this.deltaTime = this.deltaMS * e.targetFPMS;
2486
+ let r = this._head, i = r.next;
2487
+ for (; i;) i = i.emit(this);
2488
+ r.next || this._cancelIfNeeded();
2241
2489
  } else this.deltaTime = this.deltaMS = this.elapsedMS = 0;
2242
- this.lastTime = j;
2490
+ this.lastTime = t;
2243
2491
  }
2244
2492
  get FPS() {
2245
2493
  return 1e3 / this.elapsedMS;
@@ -2247,27 +2495,28 @@ var TickerListener = class {
2247
2495
  get maxFPS() {
2248
2496
  return this._minElapsedMS ? Math.round(1e3 / this._minElapsedMS) : 0;
2249
2497
  }
2250
- set maxFPS(n) {
2251
- n === 0 ? this._minElapsedMS = 0 : (n < this.minFPS && (this.minFPS = n), this._minElapsedMS = 1 / (n / 1e3));
2498
+ set maxFPS(e) {
2499
+ e === 0 ? this._minElapsedMS = 0 : (e < this.minFPS && (this.minFPS = e), this._minElapsedMS = 1 / (e / 1e3));
2252
2500
  }
2253
2501
  get minFPS() {
2254
2502
  return 1e3 / this._maxElapsedMS;
2255
2503
  }
2256
- set minFPS(j) {
2257
- this._maxElapsedMS = 1 / Math.min(Math.max(0, j) / 1e3, n.targetFPMS), this._minElapsedMS && j > this.maxFPS && (this.maxFPS = j);
2504
+ set minFPS(t) {
2505
+ let n = Math.min(Math.max(0, t) / 1e3, e.targetFPMS);
2506
+ this._maxElapsedMS = 1 / n, this._minElapsedMS && t > this.maxFPS && (this.maxFPS = t);
2258
2507
  }
2259
- add(n, j, M = 0) {
2260
- let N = new TickerListener(n, j, M), P = this._head.next, F = this._head;
2261
- if (!P) N.connect(F);
2508
+ add(e, t, n = 0) {
2509
+ let r = new X(e, t, n), i = this._head.next, a = this._head;
2510
+ if (!i) r.connect(a);
2262
2511
  else {
2263
- for (; P;) {
2264
- if (N.priority > P.priority) {
2265
- N.connect(F);
2512
+ for (; i;) {
2513
+ if (r.priority > i.priority) {
2514
+ r.connect(a);
2266
2515
  break;
2267
2516
  }
2268
- F = P, P = P.next;
2517
+ a = i, i = i.next;
2269
2518
  }
2270
- N.previous || N.connect(F);
2519
+ r.previous || r.connect(a);
2271
2520
  }
2272
2521
  return this._startIfPossible(), this;
2273
2522
  }
@@ -2277,9 +2526,9 @@ var TickerListener = class {
2277
2526
  stop() {
2278
2527
  this.started && (this.started = !1, this._cancelIfNeeded());
2279
2528
  }
2280
- remove(n, j) {
2281
- let M = this._head.next;
2282
- for (; M;) M = M.match(n, j) ? M.destroy() : M.next;
2529
+ remove(e, t) {
2530
+ let n = this._head.next;
2531
+ for (; n;) n = n.match(e, t) ? n.destroy() : n.next;
2283
2532
  return this._head.next || this._cancelIfNeeded(), this;
2284
2533
  }
2285
2534
  _startIfPossible() {
@@ -2293,18 +2542,20 @@ var TickerListener = class {
2293
2542
  }
2294
2543
  destroy() {
2295
2544
  this.stop();
2296
- let n = this._head.next;
2297
- for (; n;) n = n.destroy(!0);
2545
+ let e = this._head.next;
2546
+ for (; e;) e = e.destroy(!0);
2298
2547
  this._head.destroy(), this._head = null;
2299
2548
  }
2300
2549
  };
2301
- _Ticker = Ticker, _Ticker.targetFPMS = .06;
2302
- var plugins = [class {
2303
- static init(n) {
2550
+ f(Z, "targetFPMS", .06);
2551
+ //#endregion
2552
+ //#region lib/app/ResizePlugin.ts
2553
+ var Q = class {
2554
+ static init(e) {
2304
2555
  Object.defineProperty(this, "resizeTo", {
2305
2556
  configurable: !0,
2306
- set(n) {
2307
- globalThis.removeEventListener("resize", this.queueResize), this._resizeTo = n, n && (globalThis.addEventListener("resize", this.queueResize), this.resize());
2557
+ set(e) {
2558
+ globalThis.removeEventListener("resize", this.queueResize), this._resizeTo = e, e && (globalThis.addEventListener("resize", this.queueResize), this.resize());
2308
2559
  },
2309
2560
  get() {
2310
2561
  return this._resizeTo;
@@ -2316,26 +2567,30 @@ var plugins = [class {
2316
2567
  }, this.resize = () => {
2317
2568
  if (!this._resizeTo) return;
2318
2569
  this._cancelResize();
2319
- let n, j;
2320
- if (this._resizeTo === globalThis.window) n = globalThis.innerWidth, j = globalThis.innerHeight;
2570
+ let e, t;
2571
+ if (this._resizeTo === globalThis.window) e = globalThis.innerWidth, t = globalThis.innerHeight;
2321
2572
  else {
2322
- let { clientWidth: M, clientHeight: N } = this._resizeTo;
2323
- n = M, j = N;
2573
+ let { clientWidth: n, clientHeight: r } = this._resizeTo;
2574
+ e = n, t = r;
2324
2575
  }
2325
- this.renderer.resize(n, j), this.render();
2326
- }, this._resizeId = null, this._resizeTo = null, this.resizeTo = n.resizeTo || null;
2576
+ this.renderer.resize(e, t), this.render();
2577
+ }, this._resizeId = null, this._resizeTo = null, this.resizeTo = e.resizeTo || null;
2327
2578
  }
2328
2579
  static destroy() {
2329
2580
  globalThis.removeEventListener("resize", this.queueResize), this._cancelResize(), this._cancelResize = null, this.queueResize = null, this.resizeTo = null, this.resize = null;
2330
2581
  }
2331
- }], Application = class {
2582
+ };
2583
+ f(Q, "resizeTo", void 0), f(Q, "queueResize", void 0), f(Q, "_resizeTo", void 0), f(Q, "_resizeId", void 0), f(Q, "resize", void 0), f(Q, "_cancelResize", void 0), f(Q, "renderer", void 0), f(Q, "render", void 0);
2584
+ //#endregion
2585
+ //#region lib/app/Application.ts
2586
+ var ht = [Q], gt = class {
2332
2587
  constructor() {
2333
- this.stage = new Container();
2588
+ f(this, "renderer", void 0), f(this, "stage", new N()), f(this, "_ticker", void 0);
2334
2589
  }
2335
- async init(n = {}) {
2336
- n = { ...n }, this.stage || (this.stage = new Container()), this.renderer = new CanvasRenderer(), await this.renderer.init(n), plugins.forEach((j) => {
2337
- j.init.call(this, n);
2338
- }), this.ticker = new Ticker(), (n.autoStart || n.autoStart == null) && this._ticker.start();
2590
+ async init(e = {}) {
2591
+ e = { ...e }, this.stage || (this.stage = new N()), this.renderer = new pt(), await this.renderer.init(e), ht.forEach((t) => {
2592
+ t.init.call(this, e);
2593
+ }), this.ticker = new Z(), (e.autoStart || e.autoStart == null) && this._ticker.start();
2339
2594
  }
2340
2595
  get canvas() {
2341
2596
  return this.renderer.canvas;
@@ -2346,199 +2601,199 @@ var plugins = [class {
2346
2601
  get ticker() {
2347
2602
  return this._ticker;
2348
2603
  }
2349
- set ticker(n) {
2350
- this._ticker && this._ticker.remove(this.render, this), this._ticker = n, n && n.add(this.render, this);
2604
+ set ticker(e) {
2605
+ this._ticker && this._ticker.remove(this.render, this), this._ticker = e, e && e.add(this.render, this);
2351
2606
  }
2352
2607
  render() {
2353
2608
  this.renderer.render({ container: this.stage });
2354
2609
  }
2355
2610
  destroy() {
2356
- let n = plugins.slice(0);
2357
- if (n.reverse(), n.forEach((n) => {
2358
- n.destroy.call(this);
2611
+ let e = ht.slice(0);
2612
+ if (e.reverse(), e.forEach((e) => {
2613
+ e.destroy.call(this);
2359
2614
  }), this.stage.destroy(), this.stage = null, this.renderer.destroy(), this.renderer = null, this._ticker) {
2360
- let n = this._ticker;
2361
- this._ticker = null, n.destroy();
2615
+ let e = this._ticker;
2616
+ this._ticker = null, e.destroy();
2362
2617
  }
2363
2618
  }
2364
- };
2365
- const Cache = new class {
2619
+ }, $ = new class {
2366
2620
  constructor() {
2367
2621
  this._cache = /* @__PURE__ */ new Map(), this._cacheMap = /* @__PURE__ */ new Map();
2368
2622
  }
2369
2623
  reset() {
2370
2624
  this._cache.clear(), this._cacheMap.clear();
2371
2625
  }
2372
- has(n) {
2373
- return this._cache.has(n);
2626
+ has(e) {
2627
+ return this._cache.has(e);
2374
2628
  }
2375
- get(n) {
2376
- let j = this._cache.get(n);
2377
- if (!j) throw Error(`Asset ${n} not found`);
2378
- return j;
2629
+ get(e) {
2630
+ let t = this._cache.get(e);
2631
+ if (!t) throw Error(`Asset ${e} not found`);
2632
+ return t;
2379
2633
  }
2380
- set(n, j) {
2381
- let M = Array.isArray(n) ? n : [n], N = /* @__PURE__ */ new Map();
2382
- M.forEach((n) => {
2383
- N.set(n, j);
2634
+ set(e, t) {
2635
+ let n = Array.isArray(e) ? e : [e], r = /* @__PURE__ */ new Map();
2636
+ n.forEach((e) => {
2637
+ r.set(e, t);
2384
2638
  });
2385
- let P = [...N.keys()], F = {
2386
- cacheKeys: P,
2387
- keys: M
2639
+ let i = [...r.keys()], a = {
2640
+ cacheKeys: i,
2641
+ keys: n
2388
2642
  };
2389
- M.forEach((n) => {
2390
- this._cacheMap.set(n, F);
2391
- }), P.forEach((n) => {
2392
- this._cache.has(n) && this._cache.has(n), this._cache.set(n, N.get(n));
2643
+ n.forEach((e) => {
2644
+ this._cacheMap.set(e, a);
2645
+ }), i.forEach((e) => {
2646
+ this._cache.set(e, r.get(e));
2393
2647
  });
2394
2648
  }
2395
- remove(n) {
2396
- if (!this._cacheMap.has(n)) return;
2397
- let j = this._cacheMap.get(n);
2398
- ((j == null ? void 0 : j.cacheKeys) || []).forEach((n) => {
2399
- this._cache.delete(n);
2400
- }), j == null || j.keys.forEach((n) => {
2401
- this._cacheMap.delete(n);
2649
+ remove(e) {
2650
+ if (!this._cacheMap.has(e)) return;
2651
+ let t = this._cacheMap.get(e);
2652
+ ((t == null ? void 0 : t.cacheKeys) || []).forEach((e) => {
2653
+ this._cache.delete(e);
2654
+ }), t == null || t.keys.forEach((e) => {
2655
+ this._cacheMap.delete(e);
2402
2656
  });
2403
2657
  }
2404
- }();
2405
- var _Loader, Loader = class n {
2658
+ }(), _t = class e {
2406
2659
  constructor() {
2407
- this.promiseCache = {}, this.loadOptions = { ...n.defaultOptions };
2408
- }
2409
- getAlias(n) {
2410
- let { alias: j, src: M } = n, N = j || M;
2411
- return (Array.isArray(N) ? N : [N]).map((n) => typeof n == "string" ? n : Array.isArray(n) ? n.map((n) => {
2412
- var j;
2413
- return (j = n.src) == null ? n : j;
2414
- }) : n != null && n.src ? n.src : n);
2415
- }
2416
- async load(j, M) {
2417
- let { onProgress: N, onError: P, strategy: F, retryCount: I, retryDelay: L } = typeof M == "function" ? {
2418
- ...n.defaultOptions,
2660
+ f(this, "promiseCache", {}), f(this, "loadOptions", { ...e.defaultOptions });
2661
+ }
2662
+ getAlias(e) {
2663
+ let { alias: t, src: n } = e, r = t || n;
2664
+ return (Array.isArray(r) ? r : [r]).map((e) => typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => {
2665
+ var t;
2666
+ return (t = e.src) == null ? e : t;
2667
+ }) : e != null && e.src ? e.src : e);
2668
+ }
2669
+ async load(t, n) {
2670
+ let { onProgress: r, onError: i, strategy: a, retryCount: o, retryDelay: s } = typeof n == "function" ? {
2671
+ ...e.defaultOptions,
2419
2672
  ...this.loadOptions,
2420
- onProgress: M
2673
+ onProgress: n
2421
2674
  } : {
2422
- ...n.defaultOptions,
2675
+ ...e.defaultOptions,
2423
2676
  ...this.loadOptions,
2424
- ...M || {}
2425
- }, R = 0, z = {}, B = j.reduce((n, j) => n + (j.progressSize || 1), 0), V = j.map(async (n) => {
2426
- if (z[n.src]) return;
2427
- let j = n.src;
2428
- await this._loadAssetWithRetry(j, n, {
2429
- onProgress: N,
2430
- onError: P,
2431
- strategy: F,
2432
- retryCount: I,
2433
- retryDelay: L
2434
- }, z), R += n.progressSize || 1, N && N(R / B);
2677
+ ...n || {}
2678
+ }, c = 0, l = {}, u = t.reduce((e, t) => e + (t.progressSize || 1), 0), d = t.map(async (e) => {
2679
+ if (l[e.src]) return;
2680
+ let t = e.src;
2681
+ await this._loadAssetWithRetry(t, e, {
2682
+ onProgress: r,
2683
+ onError: i,
2684
+ strategy: a,
2685
+ retryCount: o,
2686
+ retryDelay: s
2687
+ }, l), c += e.progressSize || 1, r && r(c / u);
2435
2688
  });
2436
- return await Promise.all(V), z;
2437
- }
2438
- async unload(n) {
2439
- let j = n.map(async (n) => {
2440
- let j = n.src, M = this.promiseCache[j];
2441
- if (M) {
2442
- let n = await M;
2443
- delete this.promiseCache[j], n.destroy(!0);
2689
+ return await Promise.all(d), l;
2690
+ }
2691
+ async unload(e) {
2692
+ let t = e.map(async (e) => {
2693
+ let t = e.src, n = this.promiseCache[t];
2694
+ if (n) {
2695
+ let e = await n;
2696
+ delete this.promiseCache[t], e.destroy(!0);
2444
2697
  }
2445
2698
  });
2446
- await Promise.all(j);
2699
+ await Promise.all(t);
2447
2700
  }
2448
- _getLoadPromise(n, j) {
2449
- return (async () => await loadTextures(n, j, this))();
2701
+ _getLoadPromise(e, t) {
2702
+ return (async () => await vt(e, t, this))();
2450
2703
  }
2451
- async _loadAssetWithRetry(n, j, M, N) {
2452
- let P = 0, { onError: F, strategy: I, retryCount: L, retryDelay: R } = M, z = (n) => new Promise((j) => setTimeout(j, n));
2704
+ async _loadAssetWithRetry(e, t, n, r) {
2705
+ let i = 0, { onError: a, strategy: o, retryCount: s, retryDelay: c } = n, l = (e) => new Promise((t) => setTimeout(t, e));
2453
2706
  for (;;) try {
2454
- this.promiseCache[n] || (this.promiseCache[n] = this._getLoadPromise(n, j)), N[j.src] = await this.promiseCache[n];
2707
+ this.promiseCache[e] || (this.promiseCache[e] = this._getLoadPromise(e, t)), r[t.src] = await this.promiseCache[e];
2455
2708
  return;
2456
- } catch (M) {
2457
- if (delete this.promiseCache[n], delete N[j.src], P++, I === "retry" && !(I !== "retry" || P > L)) {
2458
- F && F(M, j.src), await z(R);
2709
+ } catch (n) {
2710
+ if (delete this.promiseCache[e], delete r[t.src], i++, o === "retry" && !(o !== "retry" || i > s)) {
2711
+ a && a(n, t.src), await l(c);
2459
2712
  continue;
2460
2713
  }
2461
- if (I === "skip") {
2462
- F && F(M, j.src);
2714
+ if (o === "skip") {
2715
+ a && a(n, t.src);
2463
2716
  return;
2464
2717
  }
2465
- F && F(M, j.src);
2466
- let B = /* @__PURE__ */ Error(`[Loader.load] Failed to load ${n}.\n${M}`);
2467
- throw M instanceof Error && M.stack && (B.stack = M.stack), B;
2718
+ a && a(n, t.src);
2719
+ let u = /* @__PURE__ */ Error(`[Loader.load] Failed to load ${e}.\n${n}`);
2720
+ throw n instanceof Error && n.stack && (u.stack = n.stack), u;
2468
2721
  }
2469
2722
  }
2470
2723
  reset() {
2471
2724
  this.promiseCache = {};
2472
2725
  }
2473
2726
  };
2474
- _Loader = Loader, _Loader.defaultOptions = {
2727
+ f(_t, "defaultOptions", {
2475
2728
  strategy: "throw",
2476
2729
  retryCount: 3,
2477
2730
  retryDelay: 250
2478
- };
2479
- async function loadTextures(n, j, M) {
2480
- let N = null;
2481
- return N = globalThis.createImageBitmap ? await loadImageBitmap(n) : await new Promise((j, M) => {
2482
- N = new Image(), N.crossOrigin = "anonymous", N.src = n, N.complete ? j(N) : (N.onload = () => {
2483
- j(N);
2484
- }, N.onerror = M);
2485
- }), createTexture(new TextureSource({ resource: N }), M, n);
2731
+ });
2732
+ async function vt(e, t, n) {
2733
+ let r = null;
2734
+ return r = globalThis.createImageBitmap ? await yt(e) : await new Promise((t, n) => {
2735
+ r = new Image(), r.crossOrigin = "anonymous", r.src = e, r.complete ? t(r) : (r.onload = () => {
2736
+ t(r);
2737
+ }, r.onerror = n);
2738
+ }), bt(new G({ resource: r }), n, e);
2486
2739
  }
2487
- async function loadImageBitmap(n) {
2488
- let j = await window.fetch(n);
2489
- if (j.headers.get("content-type") === "text/html" || !j.ok) throw Error(`[loadImageBitmap] Failed to fetch ${n}: ${j.status} ${j.statusText}`);
2490
- let M = await j.blob();
2491
- return window.createImageBitmap(M);
2740
+ async function yt(e) {
2741
+ let t = await window.fetch(e);
2742
+ if (t.headers.get("content-type") === "text/html" || !t.ok) throw Error(`[loadImageBitmap] Failed to fetch ${e}: ${t.status} ${t.statusText}`);
2743
+ let n = await t.blob();
2744
+ return window.createImageBitmap(n);
2492
2745
  }
2493
- function createTexture(n, j, M) {
2494
- n.label = M;
2495
- let N = new Texture({
2496
- source: n,
2497
- label: M
2498
- }), P = () => {
2499
- delete j.promiseCache[M], Cache.has(M) && Cache.remove(M);
2746
+ function bt(e, t, n) {
2747
+ e.label = n;
2748
+ let r = new K({
2749
+ source: e,
2750
+ label: n
2751
+ }), i = () => {
2752
+ delete t.promiseCache[n], $.has(n) && $.remove(n);
2500
2753
  };
2501
- return N.source.on("destroy", () => {
2502
- j.promiseCache[M] && P();
2503
- }), N.on("destroy", () => {
2504
- n.destroyed || P();
2505
- }), N;
2754
+ return r.source.on("destroy", () => {
2755
+ t.promiseCache[n] && i();
2756
+ }), r.on("destroy", () => {
2757
+ e.destroyed || i();
2758
+ }), r;
2506
2759
  }
2507
- var AssetsClass = class {
2760
+ //#endregion
2761
+ //#region lib/assets/Assets.ts
2762
+ var xt = class {
2508
2763
  constructor() {
2509
- this._initialized = !1, this.loader = new Loader(), this.cache = Cache;
2764
+ f(this, "cache", void 0), f(this, "loader", void 0), f(this, "basePath", void 0), f(this, "_initialized", !1), this.loader = new _t(), this.cache = $;
2510
2765
  }
2511
- init(n = {}) {
2512
- this._initialized || (this._initialized = !0, n.basePath && (this.basePath = n.basePath), n.loadOptions && (this.loader.loadOptions = {
2766
+ init(e = {}) {
2767
+ this._initialized || (this._initialized = !0, e.basePath && (this.basePath = e.basePath), e.loadOptions && (this.loader.loadOptions = {
2513
2768
  ...this.loader.loadOptions,
2514
- ...n.loadOptions
2769
+ ...e.loadOptions
2515
2770
  }));
2516
2771
  }
2517
- async load(n, j) {
2772
+ async load(e, t) {
2518
2773
  this._initialized || this.init();
2519
- let M = n.map((n) => ({
2520
- ...n,
2521
- src: toAbsolutePath(n.src, this.basePath)
2774
+ let n = e.map((e) => ({
2775
+ ...e,
2776
+ src: Ct(e.src, this.basePath)
2522
2777
  }));
2523
- return await this._mapLoadToResolve(M, j);
2778
+ return await this._mapLoadToResolve(n, t);
2524
2779
  }
2525
- async _mapLoadToResolve(n, j) {
2526
- let M = Object.values(n), N = await this.loader.load(M, j), P = {};
2527
- return M.forEach((n) => {
2528
- let j = N[n.src], M = Array.isArray(n.alias) ? n.alias : [n.alias], F = [n.src, ...M];
2529
- F.forEach((n) => {
2530
- P[n] = j;
2531
- }), Cache.set(F, j);
2532
- }), P;
2780
+ async _mapLoadToResolve(e, t) {
2781
+ let n = Object.values(e), r = await this.loader.load(n, t), i = {};
2782
+ return n.forEach((e) => {
2783
+ let t = r[e.src], n = Array.isArray(e.alias) ? e.alias : [e.alias], a = [e.src, ...n];
2784
+ a.forEach((e) => {
2785
+ i[e] = t;
2786
+ }), $.set(a, t);
2787
+ }), i;
2533
2788
  }
2534
2789
  reset() {
2535
2790
  this._initialized = !1, this.cache.reset(), this.loader.reset();
2536
2791
  }
2537
- };
2538
- const Assets = new AssetsClass();
2539
- function toAbsolutePath(n, j) {
2540
- return n.startsWith("http") || !j ? n : n.startsWith("/") && j.endsWith("/") ? j + n.slice(1) : n.startsWith("/") && !j.endsWith("/") || !n.startsWith("/") && j.endsWith("/") ? j + n : `${j}/${n}`;
2792
+ }, St = new xt();
2793
+ function Ct(e, t) {
2794
+ return e.startsWith("http") || !t ? e : e.startsWith("/") && t.endsWith("/") ? t + e.slice(1) : e.startsWith("/") && !t.endsWith("/") || !e.startsWith("/") && t.endsWith("/") ? t + e : `${t}/${e}`;
2541
2795
  }
2542
- export { Application, Assets, AssetsClass, CanvasRenderer, Container, Graphics, GraphicsContext, GraphicsPipe, Matrix, PI_2, Rectangle, RenderGroup, RenderTexture, Sprite, Text, TextPipe, Texture, Ticker, TickerListener, UPDATE_BLEND, UPDATE_COLOR, UPDATE_TRANSFORM, UPDATE_VISIBLE, Vector2, ViewContainer, buildShapePath, nextPow2 };
2796
+ //#endregion
2797
+ export { gt as Application, St as Assets, xt as AssetsClass, pt as CanvasRenderer, N as Container, Le as Graphics, R as GraphicsContext, z as GraphicsPipe, _ as Matrix, g as PI_2, y as Rectangle, _e as RenderGroup, Qe as RenderTexture, $e as Sprite, et as Text, V as TextPipe, K as Texture, Z as Ticker, X as TickerListener, xe as UPDATE_BLEND, be as UPDATE_COLOR, Ce as UPDATE_TRANSFORM, Se as UPDATE_VISIBLE, b as Vector2, P as ViewContainer, B as buildShapePath, x as nextPow2 };
2543
2798
 
2544
2799
  //# sourceMappingURL=dao.js.map