@darajs/ui-causal-graph-editor 0.4.8

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 (223) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -0
  3. package/dist/CanvasPool.5cd3cdcd.js +30 -0
  4. package/dist/SharedSystems.140ebe02.js +1905 -0
  5. package/dist/WebGLRenderer.6ede660f.js +2241 -0
  6. package/dist/WebGPURenderer.f884c756.js +1544 -0
  7. package/dist/browserAll.2dcaa9f7.js +953 -0
  8. package/dist/colorToUniform.7c604fe6.js +76 -0
  9. package/dist/index.a01cfc5f.js +61895 -0
  10. package/dist/index.js +35 -0
  11. package/dist/index.umd.cjs +10287 -0
  12. package/dist/init.73e5c5e2.js +2602 -0
  13. package/dist/style.css +1 -0
  14. package/dist/types/graph-viewer/causal-graph-editor.d.ts +58 -0
  15. package/dist/types/graph-viewer/causal-graph-editor.d.ts.map +1 -0
  16. package/dist/types/graph-viewer/storybook/stories-utils.d.ts +1247 -0
  17. package/dist/types/graph-viewer/storybook/stories-utils.d.ts.map +1 -0
  18. package/dist/types/graph-viewer/utils/use-iterate-edges.d.ts +32 -0
  19. package/dist/types/graph-viewer/utils/use-iterate-edges.d.ts.map +1 -0
  20. package/dist/types/graph-viewer/utils/use-iterate-nodes.d.ts +32 -0
  21. package/dist/types/graph-viewer/utils/use-iterate-nodes.d.ts.map +1 -0
  22. package/dist/types/index.d.ts +32 -0
  23. package/dist/types/index.d.ts.map +1 -0
  24. package/dist/types/jest-setup.d.ts +18 -0
  25. package/dist/types/jest-setup.d.ts.map +1 -0
  26. package/dist/types/node-hierarchy-builder/index.d.ts +19 -0
  27. package/dist/types/node-hierarchy-builder/index.d.ts.map +1 -0
  28. package/dist/types/node-hierarchy-builder/layer-divider.d.ts +15 -0
  29. package/dist/types/node-hierarchy-builder/layer-divider.d.ts.map +1 -0
  30. package/dist/types/node-hierarchy-builder/layer-label-editor.d.ts +24 -0
  31. package/dist/types/node-hierarchy-builder/layer-label-editor.d.ts.map +1 -0
  32. package/dist/types/node-hierarchy-builder/layer.d.ts +35 -0
  33. package/dist/types/node-hierarchy-builder/layer.d.ts.map +1 -0
  34. package/dist/types/node-hierarchy-builder/node-hierarchy-builder.d.ts +27 -0
  35. package/dist/types/node-hierarchy-builder/node-hierarchy-builder.d.ts.map +1 -0
  36. package/dist/types/node-hierarchy-builder/node.d.ts +21 -0
  37. package/dist/types/node-hierarchy-builder/node.d.ts.map +1 -0
  38. package/dist/types/node-hierarchy-builder/shared.d.ts +93 -0
  39. package/dist/types/node-hierarchy-builder/shared.d.ts.map +1 -0
  40. package/dist/types/shared/causal-graph-store.d.ts +118 -0
  41. package/dist/types/shared/causal-graph-store.d.ts.map +1 -0
  42. package/dist/types/shared/editor-overlay/buttons/add-node-button.d.ts +25 -0
  43. package/dist/types/shared/editor-overlay/buttons/add-node-button.d.ts.map +1 -0
  44. package/dist/types/shared/editor-overlay/buttons/center-graph-button.d.ts +7 -0
  45. package/dist/types/shared/editor-overlay/buttons/center-graph-button.d.ts.map +1 -0
  46. package/dist/types/shared/editor-overlay/buttons/collapse-all-button.d.ts +7 -0
  47. package/dist/types/shared/editor-overlay/buttons/collapse-all-button.d.ts.map +1 -0
  48. package/dist/types/shared/editor-overlay/buttons/collapse-expand-button.d.ts +26 -0
  49. package/dist/types/shared/editor-overlay/buttons/collapse-expand-button.d.ts.map +1 -0
  50. package/dist/types/shared/editor-overlay/buttons/drag-mode-button.d.ts +27 -0
  51. package/dist/types/shared/editor-overlay/buttons/drag-mode-button.d.ts.map +1 -0
  52. package/dist/types/shared/editor-overlay/buttons/index.d.ts +24 -0
  53. package/dist/types/shared/editor-overlay/buttons/index.d.ts.map +1 -0
  54. package/dist/types/shared/editor-overlay/buttons/recalculate-layout-button.d.ts +7 -0
  55. package/dist/types/shared/editor-overlay/buttons/recalculate-layout-button.d.ts.map +1 -0
  56. package/dist/types/shared/editor-overlay/buttons/save-image-button.d.ts +7 -0
  57. package/dist/types/shared/editor-overlay/buttons/save-image-button.d.ts.map +1 -0
  58. package/dist/types/shared/editor-overlay/buttons/soft-edge-arrow-button.d.ts +19 -0
  59. package/dist/types/shared/editor-overlay/buttons/soft-edge-arrow-button.d.ts.map +1 -0
  60. package/dist/types/shared/editor-overlay/floating-elements.d.ts +29 -0
  61. package/dist/types/shared/editor-overlay/floating-elements.d.ts.map +1 -0
  62. package/dist/types/shared/editor-overlay/index.d.ts +22 -0
  63. package/dist/types/shared/editor-overlay/index.d.ts.map +1 -0
  64. package/dist/types/shared/editor-overlay/legend/index.d.ts +19 -0
  65. package/dist/types/shared/editor-overlay/legend/index.d.ts.map +1 -0
  66. package/dist/types/shared/editor-overlay/legend/legend-data.d.ts +49 -0
  67. package/dist/types/shared/editor-overlay/legend/legend-data.d.ts.map +1 -0
  68. package/dist/types/shared/editor-overlay/legend/legend-list.d.ts +6 -0
  69. package/dist/types/shared/editor-overlay/legend/legend-list.d.ts.map +1 -0
  70. package/dist/types/shared/editor-overlay/legend/legend.d.ts +7 -0
  71. package/dist/types/shared/editor-overlay/legend/legend.d.ts.map +1 -0
  72. package/dist/types/shared/editor-overlay/overlay.d.ts +42 -0
  73. package/dist/types/shared/editor-overlay/overlay.d.ts.map +1 -0
  74. package/dist/types/shared/editor-overlay/panel-content/edge/edge-editor.d.ts +8 -0
  75. package/dist/types/shared/editor-overlay/panel-content/edge/edge-editor.d.ts.map +1 -0
  76. package/dist/types/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts +41 -0
  77. package/dist/types/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts.map +1 -0
  78. package/dist/types/shared/editor-overlay/panel-content/edge/editor-props.d.ts +35 -0
  79. package/dist/types/shared/editor-overlay/panel-content/edge/editor-props.d.ts.map +1 -0
  80. package/dist/types/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts +23 -0
  81. package/dist/types/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts.map +1 -0
  82. package/dist/types/shared/editor-overlay/panel-content/edge/index.d.ts +18 -0
  83. package/dist/types/shared/editor-overlay/panel-content/edge/index.d.ts.map +1 -0
  84. package/dist/types/shared/editor-overlay/panel-content/edge/pag-editor.d.ts +23 -0
  85. package/dist/types/shared/editor-overlay/panel-content/edge/pag-editor.d.ts.map +1 -0
  86. package/dist/types/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts +7 -0
  87. package/dist/types/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts.map +1 -0
  88. package/dist/types/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts +27 -0
  89. package/dist/types/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts.map +1 -0
  90. package/dist/types/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts +15 -0
  91. package/dist/types/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts.map +1 -0
  92. package/dist/types/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts +21 -0
  93. package/dist/types/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts.map +1 -0
  94. package/dist/types/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts +17 -0
  95. package/dist/types/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts.map +1 -0
  96. package/dist/types/shared/editor-overlay/panel-content/edge/sections/index.d.ts +19 -0
  97. package/dist/types/shared/editor-overlay/panel-content/edge/sections/index.d.ts.map +1 -0
  98. package/dist/types/shared/editor-overlay/panel-content/index.d.ts +20 -0
  99. package/dist/types/shared/editor-overlay/panel-content/index.d.ts.map +1 -0
  100. package/dist/types/shared/editor-overlay/panel-content/node/index.d.ts +18 -0
  101. package/dist/types/shared/editor-overlay/panel-content/node/index.d.ts.map +1 -0
  102. package/dist/types/shared/editor-overlay/panel-content/node/label-editor.d.ts +11 -0
  103. package/dist/types/shared/editor-overlay/panel-content/node/label-editor.d.ts.map +1 -0
  104. package/dist/types/shared/editor-overlay/panel-content/node/node-info-content.d.ts +34 -0
  105. package/dist/types/shared/editor-overlay/panel-content/node/node-info-content.d.ts.map +1 -0
  106. package/dist/types/shared/editor-overlay/panel-content/panel-content.d.ts +17 -0
  107. package/dist/types/shared/editor-overlay/panel-content/panel-content.d.ts.map +1 -0
  108. package/dist/types/shared/editor-overlay/panel-content/panel-title.d.ts +12 -0
  109. package/dist/types/shared/editor-overlay/panel-content/panel-title.d.ts.map +1 -0
  110. package/dist/types/shared/editor-overlay/panel-content/styled.d.ts +9 -0
  111. package/dist/types/shared/editor-overlay/panel-content/styled.d.ts.map +1 -0
  112. package/dist/types/shared/editor-overlay/positional-divs.d.ts +25 -0
  113. package/dist/types/shared/editor-overlay/positional-divs.d.ts.map +1 -0
  114. package/dist/types/shared/editor-overlay/search-bar/index.d.ts +19 -0
  115. package/dist/types/shared/editor-overlay/search-bar/index.d.ts.map +1 -0
  116. package/dist/types/shared/editor-overlay/search-bar/search-bar.d.ts +21 -0
  117. package/dist/types/shared/editor-overlay/search-bar/search-bar.d.ts.map +1 -0
  118. package/dist/types/shared/editor-overlay/search-bar/use-search.d.ts +32 -0
  119. package/dist/types/shared/editor-overlay/search-bar/use-search.d.ts.map +1 -0
  120. package/dist/types/shared/editor-overlay/zoom-prompt.d.ts +9 -0
  121. package/dist/types/shared/editor-overlay/zoom-prompt.d.ts.map +1 -0
  122. package/dist/types/shared/graph-context.d.ts +26 -0
  123. package/dist/types/shared/graph-context.d.ts.map +1 -0
  124. package/dist/types/shared/graph-layout/circular-layout.d.ts +32 -0
  125. package/dist/types/shared/graph-layout/circular-layout.d.ts.map +1 -0
  126. package/dist/types/shared/graph-layout/common.d.ts +96 -0
  127. package/dist/types/shared/graph-layout/common.d.ts.map +1 -0
  128. package/dist/types/shared/graph-layout/custom-layout.d.ts +36 -0
  129. package/dist/types/shared/graph-layout/custom-layout.d.ts.map +1 -0
  130. package/dist/types/shared/graph-layout/fcose-layout.d.ts +132 -0
  131. package/dist/types/shared/graph-layout/fcose-layout.d.ts.map +1 -0
  132. package/dist/types/shared/graph-layout/force-atlas-layout.d.ts +103 -0
  133. package/dist/types/shared/graph-layout/force-atlas-layout.d.ts.map +1 -0
  134. package/dist/types/shared/graph-layout/index.d.ts +25 -0
  135. package/dist/types/shared/graph-layout/index.d.ts.map +1 -0
  136. package/dist/types/shared/graph-layout/marketing-layout.d.ts +63 -0
  137. package/dist/types/shared/graph-layout/marketing-layout.d.ts.map +1 -0
  138. package/dist/types/shared/graph-layout/planar-layout.d.ts +67 -0
  139. package/dist/types/shared/graph-layout/planar-layout.d.ts.map +1 -0
  140. package/dist/types/shared/graph-layout/spring-layout.d.ts +101 -0
  141. package/dist/types/shared/graph-layout/spring-layout.d.ts.map +1 -0
  142. package/dist/types/shared/graph-layout/worker/circular.d.ts +5 -0
  143. package/dist/types/shared/graph-layout/worker/circular.d.ts.map +1 -0
  144. package/dist/types/shared/graph-layout/worker/client.d.ts +22 -0
  145. package/dist/types/shared/graph-layout/worker/client.d.ts.map +1 -0
  146. package/dist/types/shared/graph-layout/worker/fcose.d.ts +18 -0
  147. package/dist/types/shared/graph-layout/worker/fcose.d.ts.map +1 -0
  148. package/dist/types/shared/graph-layout/worker/force-atlas.d.ts +5 -0
  149. package/dist/types/shared/graph-layout/worker/force-atlas.d.ts.map +1 -0
  150. package/dist/types/shared/graph-layout/worker/marketing.d.ts +5 -0
  151. package/dist/types/shared/graph-layout/worker/marketing.d.ts.map +1 -0
  152. package/dist/types/shared/graph-layout/worker/planar.d.ts +5 -0
  153. package/dist/types/shared/graph-layout/worker/planar.d.ts.map +1 -0
  154. package/dist/types/shared/graph-layout/worker/spring.d.ts +19 -0
  155. package/dist/types/shared/graph-layout/worker/spring.d.ts.map +1 -0
  156. package/dist/types/shared/graph-layout/worker/worker.d.ts +27 -0
  157. package/dist/types/shared/graph-layout/worker/worker.d.ts.map +1 -0
  158. package/dist/types/shared/parsers.d.ts +43 -0
  159. package/dist/types/shared/parsers.d.ts.map +1 -0
  160. package/dist/types/shared/pointer-context.d.ts +20 -0
  161. package/dist/types/shared/pointer-context.d.ts.map +1 -0
  162. package/dist/types/shared/rendering/background.d.ts +48 -0
  163. package/dist/types/shared/rendering/background.d.ts.map +1 -0
  164. package/dist/types/shared/rendering/colors.d.ts +27 -0
  165. package/dist/types/shared/rendering/colors.d.ts.map +1 -0
  166. package/dist/types/shared/rendering/edge/curve.d.ts +51 -0
  167. package/dist/types/shared/rendering/edge/curve.d.ts.map +1 -0
  168. package/dist/types/shared/rendering/edge/definitions.d.ts +73 -0
  169. package/dist/types/shared/rendering/edge/definitions.d.ts.map +1 -0
  170. package/dist/types/shared/rendering/edge/edge-object.d.ts +93 -0
  171. package/dist/types/shared/rendering/edge/edge-object.d.ts.map +1 -0
  172. package/dist/types/shared/rendering/edge/index.d.ts +19 -0
  173. package/dist/types/shared/rendering/edge/index.d.ts.map +1 -0
  174. package/dist/types/shared/rendering/edge/symbols.d.ts +40 -0
  175. package/dist/types/shared/rendering/edge/symbols.d.ts.map +1 -0
  176. package/dist/types/shared/rendering/edge/utils.d.ts +27 -0
  177. package/dist/types/shared/rendering/edge/utils.d.ts.map +1 -0
  178. package/dist/types/shared/rendering/engine.d.ts +436 -0
  179. package/dist/types/shared/rendering/engine.d.ts.map +1 -0
  180. package/dist/types/shared/rendering/grouping/group-container-object.d.ts +56 -0
  181. package/dist/types/shared/rendering/grouping/group-container-object.d.ts.map +1 -0
  182. package/dist/types/shared/rendering/grouping/index.d.ts +2 -0
  183. package/dist/types/shared/rendering/grouping/index.d.ts.map +1 -0
  184. package/dist/types/shared/rendering/node/definitions.d.ts +59 -0
  185. package/dist/types/shared/rendering/node/definitions.d.ts.map +1 -0
  186. package/dist/types/shared/rendering/node/index.d.ts +20 -0
  187. package/dist/types/shared/rendering/node/index.d.ts.map +1 -0
  188. package/dist/types/shared/rendering/node/node-object.d.ts +78 -0
  189. package/dist/types/shared/rendering/node/node-object.d.ts.map +1 -0
  190. package/dist/types/shared/rendering/node/utils.d.ts +33 -0
  191. package/dist/types/shared/rendering/node/utils.d.ts.map +1 -0
  192. package/dist/types/shared/rendering/svg.d.ts +26 -0
  193. package/dist/types/shared/rendering/svg.d.ts.map +1 -0
  194. package/dist/types/shared/rendering/text.d.ts +33 -0
  195. package/dist/types/shared/rendering/text.d.ts.map +1 -0
  196. package/dist/types/shared/rendering/texture-cache.d.ts +47 -0
  197. package/dist/types/shared/rendering/texture-cache.d.ts.map +1 -0
  198. package/dist/types/shared/rendering/use-render-engine.d.ts +115 -0
  199. package/dist/types/shared/rendering/use-render-engine.d.ts.map +1 -0
  200. package/dist/types/shared/rendering/utils.d.ts +27 -0
  201. package/dist/types/shared/rendering/utils.d.ts.map +1 -0
  202. package/dist/types/shared/serializer.d.ts +39 -0
  203. package/dist/types/shared/serializer.d.ts.map +1 -0
  204. package/dist/types/shared/settings-context.d.ts +56 -0
  205. package/dist/types/shared/settings-context.d.ts.map +1 -0
  206. package/dist/types/shared/styles.d.ts +4 -0
  207. package/dist/types/shared/styles.d.ts.map +1 -0
  208. package/dist/types/shared/use-causal-graph-editor.d.ts +22 -0
  209. package/dist/types/shared/use-causal-graph-editor.d.ts.map +1 -0
  210. package/dist/types/shared/use-drag-mode.d.ts +33 -0
  211. package/dist/types/shared/use-drag-mode.d.ts.map +1 -0
  212. package/dist/types/shared/use-edge-encoder.d.ts +45 -0
  213. package/dist/types/shared/use-edge-encoder.d.ts.map +1 -0
  214. package/dist/types/shared/use-graph-tooltip.d.ts +15 -0
  215. package/dist/types/shared/use-graph-tooltip.d.ts.map +1 -0
  216. package/dist/types/shared/use-pane-visibility.d.ts +12 -0
  217. package/dist/types/shared/use-pane-visibility.d.ts.map +1 -0
  218. package/dist/types/shared/utils.d.ts +79 -0
  219. package/dist/types/shared/utils.d.ts.map +1 -0
  220. package/dist/types/types.d.ts +277 -0
  221. package/dist/types/types.d.ts.map +1 -0
  222. package/dist/webworkerAll.2e3715a5.js +7 -0
  223. package/package.json +120 -0
@@ -0,0 +1,2602 @@
1
+ import { E as _, U as yt, T as _e, a as vt, d as k, v as H, b as R, c as G, M as P, F as Tt, f as wt, w as E, g as ne, h as D, R as ae, I as St, i as V, j as F, k as se, G as le, l as L, B as ke, m as U, P as Bt, n as ue, o as Ge, p as N, q as A, s as Ct, S as ee, t as T, u as Pt, x as ce, y as oe, V as q, z as he, A as Rt, D as Mt, H as Ft, J as ze, K as He, L as We, N as De, O as Ut, Q as At, W as kt, X as Gt, Y as zt, Z as Ht, _ as Wt, $ as de, a0 as Oe, a1 as be, e as S, a2 as Dt } from "./index.a01cfc5f.js";
2
+ import { c as re, l as Ot, a as It, B as Ie } from "./colorToUniform.7c604fe6.js";
3
+ import { C as I } from "./CanvasPool.5cd3cdcd.js";
4
+ class Ee {
5
+ static init(e) {
6
+ Object.defineProperty(
7
+ this,
8
+ "resizeTo",
9
+ {
10
+ set(t) {
11
+ globalThis.removeEventListener("resize", this.queueResize), this._resizeTo = t, t && (globalThis.addEventListener("resize", this.queueResize), this.resize());
12
+ },
13
+ get() {
14
+ return this._resizeTo;
15
+ }
16
+ }
17
+ ), this.queueResize = () => {
18
+ !this._resizeTo || (this._cancelResize(), this._resizeId = requestAnimationFrame(() => this.resize()));
19
+ }, this._cancelResize = () => {
20
+ this._resizeId && (cancelAnimationFrame(this._resizeId), this._resizeId = null);
21
+ }, this.resize = () => {
22
+ if (!this._resizeTo)
23
+ return;
24
+ this._cancelResize();
25
+ let t, r;
26
+ if (this._resizeTo === globalThis.window)
27
+ t = globalThis.innerWidth, r = globalThis.innerHeight;
28
+ else {
29
+ const { clientWidth: i, clientHeight: s } = this._resizeTo;
30
+ t = i, r = s;
31
+ }
32
+ this.renderer.resize(t, r), this.render();
33
+ }, this._resizeId = null, this._resizeTo = null, this.resizeTo = e.resizeTo || null;
34
+ }
35
+ static destroy() {
36
+ globalThis.removeEventListener("resize", this.queueResize), this._cancelResize(), this._cancelResize = null, this.queueResize = null, this.resizeTo = null, this.resize = null;
37
+ }
38
+ }
39
+ Ee.extension = _.Application;
40
+ class Ve {
41
+ static init(e) {
42
+ e = Object.assign({
43
+ autoStart: !0,
44
+ sharedTicker: !1
45
+ }, e), Object.defineProperty(
46
+ this,
47
+ "ticker",
48
+ {
49
+ set(t) {
50
+ this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this, yt.LOW);
51
+ },
52
+ get() {
53
+ return this._ticker;
54
+ }
55
+ }
56
+ ), this.stop = () => {
57
+ this._ticker.stop();
58
+ }, this.start = () => {
59
+ this._ticker.start();
60
+ }, this._ticker = null, this.ticker = e.sharedTicker ? _e.shared : new _e(), e.autoStart && this.start();
61
+ }
62
+ static destroy() {
63
+ if (this._ticker) {
64
+ const e = this._ticker;
65
+ this.ticker = null, e.destroy();
66
+ }
67
+ }
68
+ }
69
+ Ve.extension = _.Application;
70
+ class Et extends vt {
71
+ constructor() {
72
+ super(...arguments), this.chars = /* @__PURE__ */ Object.create(null), this.lineHeight = 0, this.fontFamily = "", this.fontMetrics = { fontSize: 0, ascent: 0, descent: 0 }, this.baseLineOffset = 0, this.distanceField = { type: "none", range: 0 }, this.pages = [], this.applyFillAsTint = !0, this.baseMeasurementFontSize = 100, this.baseRenderedFontSize = 100;
73
+ }
74
+ get font() {
75
+ return k(H, "BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."), this.fontFamily;
76
+ }
77
+ get pageTextures() {
78
+ return k(H, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
79
+ }
80
+ get size() {
81
+ return k(H, "BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."), this.fontMetrics.fontSize;
82
+ }
83
+ get distanceFieldRange() {
84
+ return k(H, "BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."), this.distanceField.range;
85
+ }
86
+ get distanceFieldType() {
87
+ return k(H, "BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."), this.distanceField.type;
88
+ }
89
+ destroy(e = !1) {
90
+ var t;
91
+ this.emit("destroy", this), this.removeAllListeners();
92
+ for (const r in this.chars)
93
+ (t = this.chars[r].texture) == null || t.destroy();
94
+ this.chars = null, e && (this.pages.forEach((r) => r.texture.destroy(!0)), this.pages = null);
95
+ }
96
+ }
97
+ function te(n, e) {
98
+ var t;
99
+ if (n.texture === R.WHITE && !n.fill)
100
+ return G.shared.setValue(n.color).setAlpha((t = n.alpha) != null ? t : 1).toHexa();
101
+ if (n.fill) {
102
+ if (n.fill instanceof Tt) {
103
+ const r = n.fill, i = e.createPattern(r.texture.source.resource, "repeat"), s = r.transform.copyTo(P.shared);
104
+ return s.scale(
105
+ r.texture.frame.width,
106
+ r.texture.frame.height
107
+ ), i.setTransform(s), i;
108
+ } else if (n.fill instanceof wt) {
109
+ const r = n.fill;
110
+ if (r.type === "linear") {
111
+ const i = e.createLinearGradient(
112
+ r.x0,
113
+ r.y0,
114
+ r.x1,
115
+ r.y1
116
+ );
117
+ return r.gradientStops.forEach((s) => {
118
+ i.addColorStop(s.offset, G.shared.setValue(s.color).toHex());
119
+ }), i;
120
+ }
121
+ }
122
+ } else {
123
+ const r = e.createPattern(n.texture.source.resource, "repeat"), i = n.matrix.copyTo(P.shared);
124
+ return i.scale(n.texture.frame.width, n.texture.frame.height), r.setTransform(i), r;
125
+ }
126
+ return E("FillStyle not recognised", n), "red";
127
+ }
128
+ function Le(n) {
129
+ if (n === "")
130
+ return [];
131
+ typeof n == "string" && (n = [n]);
132
+ const e = [];
133
+ for (let t = 0, r = n.length; t < r; t++) {
134
+ const i = n[t];
135
+ if (Array.isArray(i)) {
136
+ if (i.length !== 2)
137
+ throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${i.length}.`);
138
+ if (i[0].length === 0 || i[1].length === 0)
139
+ throw new Error("[BitmapFont]: Invalid character delimiter.");
140
+ const s = i[0].charCodeAt(0), a = i[1].charCodeAt(0);
141
+ if (a < s)
142
+ throw new Error("[BitmapFont]: Invalid character range.");
143
+ for (let o = s, d = a; o <= d; o++)
144
+ e.push(String.fromCharCode(o));
145
+ } else
146
+ e.push(...Array.from(i));
147
+ }
148
+ if (e.length === 0)
149
+ throw new Error("[BitmapFont]: Empty set when resolving characters.");
150
+ return e;
151
+ }
152
+ const $e = class Ye extends Et {
153
+ constructor(e) {
154
+ var a, o, d;
155
+ super(), this.resolution = 1, this.pages = [], this._padding = 0, this._measureCache = /* @__PURE__ */ Object.create(null), this._currentChars = [], this._currentX = 0, this._currentY = 0, this._currentPageIndex = -1, this._skipKerning = !1;
156
+ const t = { ...Ye.defaultOptions, ...e };
157
+ this._textureSize = t.textureSize, this._mipmap = t.mipmap;
158
+ const r = t.style.clone();
159
+ t.overrideFill && (r._fill.color = 16777215, r._fill.alpha = 1, r._fill.texture = R.WHITE, r._fill.fill = null), this.applyFillAsTint = t.overrideFill;
160
+ const i = r.fontSize;
161
+ r.fontSize = this.baseMeasurementFontSize;
162
+ const s = ne(r);
163
+ t.overrideSize ? r._stroke && (r._stroke.width *= this.baseRenderedFontSize / i) : r.fontSize = this.baseRenderedFontSize = i, this._style = r, this._skipKerning = (a = t.skipKerning) != null ? a : !1, this.resolution = (o = t.resolution) != null ? o : 1, this._padding = (d = t.padding) != null ? d : 4, this.fontMetrics = D.measureFont(s), this.lineHeight = r.lineHeight || this.fontMetrics.fontSize || r.fontSize;
164
+ }
165
+ ensureCharacters(e) {
166
+ var g, h, p, x;
167
+ const t = Le(e).filter((v) => !this._currentChars.includes(v)).filter((v, b, y) => y.indexOf(v) === b);
168
+ if (!t.length)
169
+ return;
170
+ this._currentChars = [...this._currentChars, ...t];
171
+ let r;
172
+ this._currentPageIndex === -1 ? r = this._nextPage() : r = this.pages[this._currentPageIndex];
173
+ let { canvas: i, context: s } = r.canvasAndContext, a = r.texture.source;
174
+ const o = this._style;
175
+ let d = this._currentX, l = this._currentY;
176
+ const u = this.baseRenderedFontSize / this.baseMeasurementFontSize, c = this._padding * u;
177
+ let f = 0, m = !1;
178
+ for (let v = 0; v < t.length; v++) {
179
+ const b = t[v], y = D.measureText(b, o, i, !1), C = Math.ceil((o.fontStyle === "italic" ? 2 : 1) * y.width);
180
+ y.lineHeight = y.height;
181
+ const W = y.width * u, B = y.height * u, M = C + c * 2, O = B + c * 2;
182
+ if (m = !1, b !== `
183
+ ` && b !== "\r" && b !== " " && b !== " " && (m = !0, f = Math.ceil(Math.max(O, f))), d + M > this._textureSize && (l += f, f = O, d = 0, l + f > this._textureSize)) {
184
+ a.update();
185
+ const z = this._nextPage();
186
+ i = z.canvasAndContext.canvas, s = z.canvasAndContext.context, a = z.texture.source, l = 0;
187
+ }
188
+ const ie = W / u - ((h = (g = o.dropShadow) == null ? void 0 : g.distance) != null ? h : 0) - ((x = (p = o._stroke) == null ? void 0 : p.width) != null ? x : 0);
189
+ if (this.chars[b] = {
190
+ id: b.codePointAt(0),
191
+ xOffset: -this._padding,
192
+ yOffset: -this._padding,
193
+ xAdvance: ie,
194
+ kerning: {}
195
+ }, m) {
196
+ this._drawGlyph(
197
+ s,
198
+ y,
199
+ d + c,
200
+ l + c,
201
+ u,
202
+ o
203
+ );
204
+ const z = a.width * u, $ = a.height * u, w = new ae(
205
+ d / z * a.width,
206
+ l / $ * a.height,
207
+ M / z * a.width,
208
+ O / $ * a.height
209
+ );
210
+ this.chars[b].texture = new R({
211
+ source: a,
212
+ frame: w
213
+ }), d += Math.ceil(M);
214
+ }
215
+ }
216
+ a.update(), this._currentX = d, this._currentY = l, this._skipKerning && this._applyKerning(t, s);
217
+ }
218
+ get pageTextures() {
219
+ return k(H, "BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."), this.pages;
220
+ }
221
+ _applyKerning(e, t) {
222
+ const r = this._measureCache;
223
+ for (let i = 0; i < e.length; i++) {
224
+ const s = e[i];
225
+ for (let a = 0; a < this._currentChars.length; a++) {
226
+ const o = this._currentChars[a];
227
+ let d = r[s];
228
+ d || (d = r[s] = t.measureText(s).width);
229
+ let l = r[o];
230
+ l || (l = r[o] = t.measureText(o).width);
231
+ let u = t.measureText(s + o).width, c = u - (d + l);
232
+ c && (this.chars[s].kerning[o] = c), u = t.measureText(s + o).width, c = u - (d + l), c && (this.chars[o].kerning[s] = c);
233
+ }
234
+ }
235
+ }
236
+ _nextPage() {
237
+ this._currentPageIndex++;
238
+ const e = this.resolution, t = I.getOptimalCanvasAndContext(
239
+ this._textureSize,
240
+ this._textureSize,
241
+ e
242
+ );
243
+ this._setupContext(t.context, this._style, e);
244
+ const r = e * (this.baseRenderedFontSize / this.baseMeasurementFontSize), i = new R({
245
+ source: new St({
246
+ resource: t.canvas,
247
+ resolution: r,
248
+ alphaMode: "premultiply-alpha-on-upload",
249
+ autoGenerateMipmaps: this._mipmap
250
+ })
251
+ }), s = {
252
+ canvasAndContext: t,
253
+ texture: i
254
+ };
255
+ return this.pages[this._currentPageIndex] = s, s;
256
+ }
257
+ _setupContext(e, t, r) {
258
+ var a;
259
+ t.fontSize = this.baseRenderedFontSize, e.scale(r, r), e.font = ne(t), t.fontSize = this.baseMeasurementFontSize, e.textBaseline = t.textBaseline;
260
+ const i = t._stroke, s = (a = i == null ? void 0 : i.width) != null ? a : 0;
261
+ if (i && (e.lineWidth = s, e.lineJoin = i.join, e.miterLimit = i.miterLimit, e.strokeStyle = te(i, e)), t._fill && (e.fillStyle = te(t._fill, e)), t.dropShadow) {
262
+ const o = t.dropShadow, d = G.shared.setValue(o.color).toArray(), l = o.blur * r, u = o.distance * r;
263
+ e.shadowColor = `rgba(${d[0] * 255},${d[1] * 255},${d[2] * 255},${o.alpha})`, e.shadowBlur = l, e.shadowOffsetX = Math.cos(o.angle) * u, e.shadowOffsetY = Math.sin(o.angle) * u;
264
+ } else
265
+ e.shadowColor = "black", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0;
266
+ }
267
+ _drawGlyph(e, t, r, i, s, a) {
268
+ var h;
269
+ const o = t.text, d = t.fontProperties, l = a._stroke, u = ((h = l == null ? void 0 : l.width) != null ? h : 0) * s, c = r + u / 2, f = i - u / 2, m = d.descent * s, g = t.lineHeight * s;
270
+ a.stroke && u && e.strokeText(o, c, f + g - m), a._fill && e.fillText(o, c, f + g - m);
271
+ }
272
+ destroy() {
273
+ super.destroy();
274
+ for (let e = 0; e < this.pages.length; e++) {
275
+ const { canvasAndContext: t, texture: r } = this.pages[e];
276
+ I.returnCanvasAndContext(t), r.destroy(!0);
277
+ }
278
+ this.pages = null;
279
+ }
280
+ };
281
+ $e.defaultOptions = {
282
+ textureSize: 512,
283
+ style: new V(),
284
+ mipmap: !0
285
+ };
286
+ let ye = $e;
287
+ function je(n, e, t, r) {
288
+ const i = {
289
+ width: 0,
290
+ height: 0,
291
+ offsetY: 0,
292
+ scale: e.fontSize / t.baseMeasurementFontSize,
293
+ lines: [{
294
+ width: 0,
295
+ charPositions: [],
296
+ spaceWidth: 0,
297
+ spacesIndex: [],
298
+ chars: []
299
+ }]
300
+ };
301
+ i.offsetY = t.baseLineOffset;
302
+ let s = i.lines[0], a = null, o = !0;
303
+ const d = {
304
+ spaceWord: !1,
305
+ width: 0,
306
+ start: 0,
307
+ index: 0,
308
+ positions: [],
309
+ chars: []
310
+ }, l = (g) => {
311
+ const h = s.width;
312
+ for (let p = 0; p < d.index; p++) {
313
+ const x = g.positions[p];
314
+ s.chars.push(g.chars[p]), s.charPositions.push(x + h);
315
+ }
316
+ s.width += g.width, o = !1, d.width = 0, d.index = 0, d.chars.length = 0;
317
+ }, u = () => {
318
+ let g = s.chars.length - 1;
319
+ if (r) {
320
+ let h = s.chars[g];
321
+ for (; h === " "; )
322
+ s.width -= t.chars[h].xAdvance, h = s.chars[--g];
323
+ }
324
+ i.width = Math.max(i.width, s.width), s = {
325
+ width: 0,
326
+ charPositions: [],
327
+ chars: [],
328
+ spaceWidth: 0,
329
+ spacesIndex: []
330
+ }, o = !0, i.lines.push(s), i.height += t.lineHeight;
331
+ }, c = t.baseMeasurementFontSize / e.fontSize, f = e.letterSpacing * c, m = e.wordWrapWidth * c;
332
+ for (let g = 0; g < n.length + 1; g++) {
333
+ let h;
334
+ const p = g === n.length;
335
+ p || (h = n[g]);
336
+ const x = t.chars[h] || t.chars[" "];
337
+ if (/(?:\s)/.test(h) || h === "\r" || h === `
338
+ ` || p) {
339
+ if (!o && e.wordWrap && s.width + d.width - f > m ? (u(), l(d), p || s.charPositions.push(0)) : (d.start = s.width, l(d), p || s.charPositions.push(0)), h === "\r" || h === `
340
+ `)
341
+ s.width !== 0 && u();
342
+ else if (!p) {
343
+ const C = x.xAdvance + (x.kerning[a] || 0) + f;
344
+ s.width += C, s.spaceWidth = C, s.spacesIndex.push(s.charPositions.length), s.chars.push(h);
345
+ }
346
+ } else {
347
+ const y = x.kerning[a] || 0, C = x.xAdvance + y + f;
348
+ d.positions[d.index++] = d.width + y, d.chars.push(h), d.width += C;
349
+ }
350
+ a = h;
351
+ }
352
+ return u(), e.align === "center" ? Vt(i) : e.align === "right" ? Lt(i) : e.align === "justify" && $t(i), i;
353
+ }
354
+ function Vt(n) {
355
+ for (let e = 0; e < n.lines.length; e++) {
356
+ const t = n.lines[e], r = n.width / 2 - t.width / 2;
357
+ for (let i = 0; i < t.charPositions.length; i++)
358
+ t.charPositions[i] += r;
359
+ }
360
+ }
361
+ function Lt(n) {
362
+ for (let e = 0; e < n.lines.length; e++) {
363
+ const t = n.lines[e], r = n.width - t.width;
364
+ for (let i = 0; i < t.charPositions.length; i++)
365
+ t.charPositions[i] += r;
366
+ }
367
+ }
368
+ function $t(n) {
369
+ const e = n.width;
370
+ for (let t = 0; t < n.lines.length; t++) {
371
+ const r = n.lines[t];
372
+ let i = 0, s = r.spacesIndex[i++], a = 0;
373
+ const o = r.spacesIndex.length, l = (e - r.width) / o;
374
+ for (let u = 0; u < r.charPositions.length; u++)
375
+ u === s && (s = r.spacesIndex[i++], a += l), r.charPositions[u] += a;
376
+ }
377
+ }
378
+ let Q = 0;
379
+ class Yt {
380
+ constructor() {
381
+ this.ALPHA = [["a", "z"], ["A", "Z"], " "], this.NUMERIC = [["0", "9"]], this.ALPHANUMERIC = [["a", "z"], ["A", "Z"], ["0", "9"], " "], this.ASCII = [[" ", "~"]], this.defaultOptions = {
382
+ chars: this.ALPHANUMERIC,
383
+ resolution: 1,
384
+ padding: 4,
385
+ skipKerning: !1
386
+ };
387
+ }
388
+ getFont(e, t) {
389
+ var a;
390
+ let r = `${t.fontFamily}-bitmap`, i = !0;
391
+ if (t._fill.fill && !t._stroke)
392
+ r += t._fill.fill.styleKey, i = !1;
393
+ else if (t._stroke || t.dropShadow) {
394
+ let o = t.styleKey;
395
+ o = o.substring(0, o.lastIndexOf("-")), r = `${o}-bitmap`, i = !1;
396
+ }
397
+ if (!F.has(r)) {
398
+ const o = new ye({
399
+ style: t,
400
+ overrideFill: i,
401
+ overrideSize: !0,
402
+ ...this.defaultOptions
403
+ });
404
+ Q++, Q > 50 && E("BitmapText", `You have dynamically created ${Q} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``), o.once("destroy", () => {
405
+ Q--, F.remove(r);
406
+ }), F.set(
407
+ r,
408
+ o
409
+ );
410
+ }
411
+ const s = F.get(r);
412
+ return (a = s.ensureCharacters) == null || a.call(s, e), s;
413
+ }
414
+ getLayout(e, t, r = !0) {
415
+ const i = this.getFont(e, t);
416
+ return je([...e], t, i, r);
417
+ }
418
+ measureText(e, t, r = !0) {
419
+ return this.getLayout(e, t, r);
420
+ }
421
+ install(...e) {
422
+ var l, u, c, f;
423
+ let t = e[0];
424
+ typeof t == "string" && (t = {
425
+ name: t,
426
+ style: e[1],
427
+ chars: (l = e[2]) == null ? void 0 : l.chars,
428
+ resolution: (u = e[2]) == null ? void 0 : u.resolution,
429
+ padding: (c = e[2]) == null ? void 0 : c.padding,
430
+ skipKerning: (f = e[2]) == null ? void 0 : f.skipKerning
431
+ }, k(H, "BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));
432
+ const r = t == null ? void 0 : t.name;
433
+ if (!r)
434
+ throw new Error("[BitmapFontManager] Property `name` is required.");
435
+ t = { ...this.defaultOptions, ...t };
436
+ const i = t.style, s = i instanceof V ? i : new V(i), a = s._fill.fill !== null && s._fill.fill !== void 0, o = new ye({
437
+ style: s,
438
+ overrideFill: a,
439
+ skipKerning: t.skipKerning,
440
+ padding: t.padding,
441
+ resolution: t.resolution,
442
+ overrideSize: !1
443
+ }), d = Le(t.chars);
444
+ return o.ensureCharacters(d.join("")), F.set(`${r}-bitmap`, o), o.once("destroy", () => F.remove(`${r}-bitmap`)), o;
445
+ }
446
+ uninstall(e) {
447
+ const t = `${e}-bitmap`, r = F.get(t);
448
+ r && r.destroy();
449
+ }
450
+ }
451
+ const jt = new Yt();
452
+ class Xe {
453
+ constructor(e) {
454
+ this._renderer = e;
455
+ }
456
+ push(e, t, r) {
457
+ this._renderer.renderPipes.batch.break(r), r.add({
458
+ renderPipeId: "filter",
459
+ canBundle: !1,
460
+ action: "pushFilter",
461
+ container: t,
462
+ filterEffect: e
463
+ });
464
+ }
465
+ pop(e, t, r) {
466
+ this._renderer.renderPipes.batch.break(r), r.add({
467
+ renderPipeId: "filter",
468
+ action: "popFilter",
469
+ canBundle: !1
470
+ });
471
+ }
472
+ execute(e) {
473
+ e.action === "pushFilter" ? this._renderer.filter.push(e) : e.action === "popFilter" && this._renderer.filter.pop();
474
+ }
475
+ destroy() {
476
+ this._renderer = null;
477
+ }
478
+ }
479
+ Xe.extension = {
480
+ type: [
481
+ _.WebGLPipes,
482
+ _.WebGPUPipes,
483
+ _.CanvasPipes
484
+ ],
485
+ name: "filter"
486
+ };
487
+ const Xt = new P();
488
+ function Kt(n, e) {
489
+ return e.clear(), Ke(n, e), e.isValid || e.set(0, 0, 0, 0), n.renderGroup ? e.applyMatrix(n.renderGroup.localTransform) : e.applyMatrix(n.parentRenderGroup.worldTransform), e;
490
+ }
491
+ function Ke(n, e) {
492
+ if (n.localDisplayStatus !== 7 || !n.measurable)
493
+ return;
494
+ const t = !!n.effects.length;
495
+ let r = e;
496
+ if ((n.renderGroup || t) && (r = se.get().clear()), n.boundsArea)
497
+ e.addRect(n.boundsArea, n.worldTransform);
498
+ else {
499
+ if (n.renderPipeId) {
500
+ const s = n.bounds;
501
+ r.addFrame(
502
+ s.minX,
503
+ s.minY,
504
+ s.maxX,
505
+ s.maxY,
506
+ n.groupTransform
507
+ );
508
+ }
509
+ const i = n.children;
510
+ for (let s = 0; s < i.length; s++)
511
+ Ke(i[s], r);
512
+ }
513
+ if (t) {
514
+ let i = !1;
515
+ for (let s = 0; s < n.effects.length; s++)
516
+ n.effects[s].addBounds && (i || (i = !0, r.applyMatrix(n.parentRenderGroup.worldTransform)), n.effects[s].addBounds(r, !0));
517
+ i && (r.applyMatrix(n.parentRenderGroup.worldTransform.copyTo(Xt).invert()), e.addBounds(r, n.relativeGroupTransform)), e.addBounds(r), se.return(r);
518
+ } else
519
+ n.renderGroup && (e.addBounds(r, n.relativeGroupTransform), se.return(r));
520
+ }
521
+ function Nt(n, e) {
522
+ e.clear();
523
+ const t = e.matrix;
524
+ for (let r = 0; r < n.length; r++) {
525
+ const i = n[r];
526
+ i.globalDisplayStatus < 7 || (e.matrix = i.worldTransform, i.addBounds(e));
527
+ }
528
+ return e.matrix = t, e;
529
+ }
530
+ const qt = new le({
531
+ attributes: {
532
+ aPosition: {
533
+ buffer: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
534
+ format: "float32x2",
535
+ stride: 2 * 4,
536
+ offset: 0
537
+ }
538
+ },
539
+ indexBuffer: new Uint32Array([0, 1, 2, 0, 2, 3])
540
+ });
541
+ class Ne {
542
+ constructor(e) {
543
+ this._filterStackIndex = 0, this._filterStack = [], this._filterGlobalUniforms = new L({
544
+ uInputSize: { value: new Float32Array(4), type: "vec4<f32>" },
545
+ uInputPixel: { value: new Float32Array(4), type: "vec4<f32>" },
546
+ uInputClamp: { value: new Float32Array(4), type: "vec4<f32>" },
547
+ uOutputFrame: { value: new Float32Array(4), type: "vec4<f32>" },
548
+ uGlobalFrame: { value: new Float32Array(4), type: "vec4<f32>" },
549
+ uOutputTexture: { value: new Float32Array(4), type: "vec4<f32>" }
550
+ }), this._globalFilterBindGroup = new ke({}), this.renderer = e;
551
+ }
552
+ get activeBackTexture() {
553
+ var e;
554
+ return (e = this._activeFilterData) == null ? void 0 : e.backTexture;
555
+ }
556
+ push(e) {
557
+ var m, g;
558
+ const t = this.renderer, r = e.filterEffect.filters;
559
+ this._filterStack[this._filterStackIndex] || (this._filterStack[this._filterStackIndex] = this._getFilterData());
560
+ const i = this._filterStack[this._filterStackIndex];
561
+ if (this._filterStackIndex++, r.length === 0) {
562
+ i.skip = !0;
563
+ return;
564
+ }
565
+ const s = i.bounds;
566
+ e.renderables ? Nt(e.renderables, s) : e.filterEffect.filterArea ? (s.clear(), s.addRect(e.filterEffect.filterArea), s.applyMatrix(e.container.worldTransform)) : Kt(e.container, s);
567
+ const a = t.renderTarget.renderTarget.colorTexture.source;
568
+ let o = 1 / 0, d = 0, l = !0, u = !1, c = !1, f = !0;
569
+ for (let h = 0; h < r.length; h++) {
570
+ const p = r[h];
571
+ if (o = Math.min(o, p.resolution === "inherit" ? a._resolution : p.resolution), d += p.padding, p.antialias === "off" ? l = !1 : p.antialias === "inherit" && l && (l = a.antialias), p.clipToViewport || (f = !1), !!!(p.compatibleRenderers & t.type)) {
572
+ c = !1;
573
+ break;
574
+ }
575
+ if (p.blendRequired && !((g = (m = t.backBuffer) == null ? void 0 : m.useBackBuffer) == null || g)) {
576
+ E("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), c = !1;
577
+ break;
578
+ }
579
+ c = p.enabled || c, u = u || p.blendRequired;
580
+ }
581
+ if (!c) {
582
+ i.skip = !0;
583
+ return;
584
+ }
585
+ if (s.scale(o), f) {
586
+ const h = t.renderTarget.rootViewPort;
587
+ s.fitBounds(0, h.width, 0, h.height);
588
+ }
589
+ if (s.ceil().scale(1 / o).pad(d | 0), !s.isPositive) {
590
+ i.skip = !0;
591
+ return;
592
+ }
593
+ i.skip = !1, i.bounds = s, i.blendRequired = u, i.container = e.container, i.filterEffect = e.filterEffect, i.previousRenderSurface = t.renderTarget.renderSurface, i.inputTexture = U.getOptimalTexture(
594
+ s.width,
595
+ s.height,
596
+ o,
597
+ l
598
+ ), t.renderTarget.bind(i.inputTexture, !0), t.globalUniforms.push({
599
+ offset: s
600
+ });
601
+ }
602
+ pop() {
603
+ const e = this.renderer;
604
+ this._filterStackIndex--;
605
+ const t = this._filterStack[this._filterStackIndex];
606
+ if (t.skip)
607
+ return;
608
+ this._activeFilterData = t;
609
+ const r = t.inputTexture, i = t.bounds;
610
+ let s = R.EMPTY;
611
+ if (e.renderTarget.finishRenderPass(), t.blendRequired) {
612
+ const o = this._filterStackIndex > 0 ? this._filterStack[this._filterStackIndex - 1].bounds : null, d = e.renderTarget.getRenderTarget(t.previousRenderSurface);
613
+ s = this.getBackTexture(d, i, o);
614
+ }
615
+ t.backTexture = s;
616
+ const a = t.filterEffect.filters;
617
+ if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(s.source, 3), e.globalUniforms.pop(), a.length === 1)
618
+ a[0].apply(this, r, t.previousRenderSurface, !1), U.returnTexture(r);
619
+ else {
620
+ let o = t.inputTexture, d = U.getOptimalTexture(
621
+ i.width,
622
+ i.height,
623
+ o.source._resolution,
624
+ !1
625
+ ), l = 0;
626
+ for (l = 0; l < a.length - 1; ++l) {
627
+ a[l].apply(this, o, d, !0);
628
+ const c = o;
629
+ o = d, d = c;
630
+ }
631
+ a[l].apply(this, o, t.previousRenderSurface, !1), U.returnTexture(o), U.returnTexture(d);
632
+ }
633
+ t.blendRequired && U.returnTexture(s);
634
+ }
635
+ getBackTexture(e, t, r) {
636
+ const i = e.colorTexture.source._resolution, s = U.getOptimalTexture(
637
+ t.width,
638
+ t.height,
639
+ i,
640
+ !1
641
+ );
642
+ let a = t.minX, o = t.minY;
643
+ r && (a -= r.minX, o -= r.minY), a = Math.floor(a * i), o = Math.floor(o * i);
644
+ const d = Math.ceil(t.width * i), l = Math.ceil(t.height * i);
645
+ return this.renderer.renderTarget.copyToTexture(
646
+ e,
647
+ s,
648
+ { x: a, y: o },
649
+ { width: d, height: l },
650
+ { x: 0, y: 0 }
651
+ ), s;
652
+ }
653
+ applyFilter(e, t, r, i) {
654
+ const s = this.renderer, a = this._filterStack[this._filterStackIndex], o = a.bounds, d = Bt.shared, u = a.previousRenderSurface === r;
655
+ let c = this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution, f = this._filterStackIndex - 1;
656
+ for (; f > 0 && this._filterStack[f].skip; )
657
+ --f;
658
+ f > 0 && (c = this._filterStack[f].inputTexture.source._resolution);
659
+ const m = this._filterGlobalUniforms, g = m.uniforms, h = g.uOutputFrame, p = g.uInputSize, x = g.uInputPixel, v = g.uInputClamp, b = g.uGlobalFrame, y = g.uOutputTexture;
660
+ if (u) {
661
+ let B = this._filterStackIndex;
662
+ for (; B > 0; ) {
663
+ B--;
664
+ const M = this._filterStack[this._filterStackIndex - 1];
665
+ if (!M.skip) {
666
+ d.x = M.bounds.minX, d.y = M.bounds.minY;
667
+ break;
668
+ }
669
+ }
670
+ h[0] = o.minX - d.x, h[1] = o.minY - d.y;
671
+ } else
672
+ h[0] = 0, h[1] = 0;
673
+ h[2] = t.frame.width, h[3] = t.frame.height, p[0] = t.source.width, p[1] = t.source.height, p[2] = 1 / p[0], p[3] = 1 / p[1], x[0] = t.source.pixelWidth, x[1] = t.source.pixelHeight, x[2] = 1 / x[0], x[3] = 1 / x[1], v[0] = 0.5 * x[2], v[1] = 0.5 * x[3], v[2] = t.frame.width * p[2] - 0.5 * x[2], v[3] = t.frame.height * p[3] - 0.5 * x[3];
674
+ const C = this.renderer.renderTarget.rootRenderTarget.colorTexture;
675
+ b[0] = d.x * c, b[1] = d.y * c, b[2] = C.source.width * c, b[3] = C.source.height * c;
676
+ const W = this.renderer.renderTarget.getRenderTarget(r);
677
+ if (s.renderTarget.bind(r, !!i), r instanceof R ? (y[0] = r.frame.width, y[1] = r.frame.height) : (y[0] = W.width, y[1] = W.height), y[2] = W.isRoot ? -1 : 1, m.update(), s.renderPipes.uniformBatch) {
678
+ const B = s.renderPipes.uniformBatch.getUboResource(m);
679
+ this._globalFilterBindGroup.setResource(B, 0);
680
+ } else
681
+ this._globalFilterBindGroup.setResource(m, 0);
682
+ this._globalFilterBindGroup.setResource(t.source, 1), this._globalFilterBindGroup.setResource(t.source.style, 2), e.groups[0] = this._globalFilterBindGroup, s.encoder.draw({
683
+ geometry: qt,
684
+ shader: e,
685
+ state: e._state,
686
+ topology: "triangle-list"
687
+ }), s.type === ue.WEBGL && s.renderTarget.finishRenderPass();
688
+ }
689
+ _getFilterData() {
690
+ return {
691
+ skip: !1,
692
+ inputTexture: null,
693
+ bounds: new Ge(),
694
+ container: null,
695
+ filterEffect: null,
696
+ blendRequired: !1,
697
+ previousRenderSurface: null
698
+ };
699
+ }
700
+ calculateSpriteMatrix(e, t) {
701
+ const r = this._activeFilterData, i = e.set(
702
+ r.inputTexture._source.width,
703
+ 0,
704
+ 0,
705
+ r.inputTexture._source.height,
706
+ r.bounds.minX,
707
+ r.bounds.minY
708
+ ), s = t.worldTransform.copyTo(P.shared);
709
+ return s.invert(), i.prepend(s), i.scale(
710
+ 1 / t.texture.frame.width,
711
+ 1 / t.texture.frame.height
712
+ ), i.translate(t.anchor.x, t.anchor.y), i;
713
+ }
714
+ }
715
+ Ne.extension = {
716
+ type: [
717
+ _.WebGLSystem,
718
+ _.WebGPUSystem
719
+ ],
720
+ name: "filter"
721
+ };
722
+ const qe = class Qe extends le {
723
+ constructor(...e) {
724
+ var u;
725
+ let t = (u = e[0]) != null ? u : {};
726
+ t instanceof Float32Array && (k(H, "use new MeshGeometry({ positions, uvs, indices }) instead"), t = {
727
+ positions: t,
728
+ uvs: e[1],
729
+ indices: e[2]
730
+ }), t = { ...Qe.defaultOptions, ...t };
731
+ const r = t.positions || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]), i = t.uvs || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]), s = t.indices || new Uint32Array([0, 1, 2, 0, 2, 3]), a = t.shrinkBuffersToFit, o = new N({
732
+ data: r,
733
+ label: "attribute-mesh-positions",
734
+ shrinkToFit: a,
735
+ usage: A.VERTEX | A.COPY_DST
736
+ }), d = new N({
737
+ data: i,
738
+ label: "attribute-mesh-uvs",
739
+ shrinkToFit: a,
740
+ usage: A.VERTEX | A.COPY_DST
741
+ }), l = new N({
742
+ data: s,
743
+ label: "index-mesh-buffer",
744
+ shrinkToFit: a,
745
+ usage: A.INDEX | A.COPY_DST
746
+ });
747
+ super({
748
+ attributes: {
749
+ aPosition: {
750
+ buffer: o,
751
+ format: "float32x2",
752
+ stride: 2 * 4,
753
+ offset: 0
754
+ },
755
+ aUV: {
756
+ buffer: d,
757
+ format: "float32x2",
758
+ stride: 2 * 4,
759
+ offset: 0
760
+ }
761
+ },
762
+ indexBuffer: l,
763
+ topology: t.topology
764
+ }), this.batchMode = "auto";
765
+ }
766
+ get positions() {
767
+ return this.attributes.aPosition.buffer.data;
768
+ }
769
+ set positions(e) {
770
+ this.attributes.aPosition.buffer.data = e;
771
+ }
772
+ get uvs() {
773
+ return this.attributes.aUV.buffer.data;
774
+ }
775
+ set uvs(e) {
776
+ this.attributes.aUV.buffer.data = e;
777
+ }
778
+ get indices() {
779
+ return this.indexBuffer.data;
780
+ }
781
+ set indices(e) {
782
+ this.indexBuffer.data = e;
783
+ }
784
+ };
785
+ qe.defaultOptions = {
786
+ topology: "triangle-list",
787
+ shrinkBuffersToFit: !1
788
+ };
789
+ let fe = qe;
790
+ function Qt(n) {
791
+ const e = n._stroke, t = n._fill, i = [`div { ${[
792
+ `color: ${G.shared.setValue(t.color).toHex()}`,
793
+ `font-size: ${n.fontSize}px`,
794
+ `font-family: ${n.fontFamily}`,
795
+ `font-weight: ${n.fontWeight}`,
796
+ `font-style: ${n.fontStyle}`,
797
+ `font-variant: ${n.fontVariant}`,
798
+ `letter-spacing: ${n.letterSpacing}px`,
799
+ `text-align: ${n.align}`,
800
+ `padding: ${n.padding}px`,
801
+ `white-space: ${n.whiteSpace === "pre" && n.wordWrap ? "pre-wrap" : n.whiteSpace}`,
802
+ ...n.lineHeight ? [`line-height: ${n.lineHeight}px`] : [],
803
+ ...n.wordWrap ? [
804
+ `word-wrap: ${n.breakWords ? "break-all" : "break-word"}`,
805
+ `max-width: ${n.wordWrapWidth}px`
806
+ ] : [],
807
+ ...e ? [Ze(e)] : [],
808
+ ...n.dropShadow ? [Je(n.dropShadow)] : [],
809
+ ...n.cssOverrides
810
+ ].join(";")} }`];
811
+ return Jt(n.tagStyles, i), i.join(" ");
812
+ }
813
+ function Je(n) {
814
+ const e = G.shared.setValue(n.color).setAlpha(n.alpha).toHexa(), t = Math.round(Math.cos(n.angle) * n.distance), r = Math.round(Math.sin(n.angle) * n.distance), i = `${t}px ${r}px`;
815
+ return n.blur > 0 ? `text-shadow: ${i} ${n.blur}px ${e}` : `text-shadow: ${i} ${e}`;
816
+ }
817
+ function Ze(n) {
818
+ return [
819
+ `-webkit-text-stroke-width: ${n.width}px`,
820
+ `-webkit-text-stroke-color: ${G.shared.setValue(n.color).toHex()}`,
821
+ `text-stroke-width: ${n.width}px`,
822
+ `text-stroke-color: ${G.shared.setValue(n.color).toHex()}`,
823
+ "paint-order: stroke"
824
+ ].join(";");
825
+ }
826
+ const ve = {
827
+ fontSize: "font-size: {{VALUE}}px",
828
+ fontFamily: "font-family: {{VALUE}}",
829
+ fontWeight: "font-weight: {{VALUE}}",
830
+ fontStyle: "font-style: {{VALUE}}",
831
+ fontVariant: "font-variant: {{VALUE}}",
832
+ letterSpacing: "letter-spacing: {{VALUE}}px",
833
+ align: "text-align: {{VALUE}}",
834
+ padding: "padding: {{VALUE}}px",
835
+ whiteSpace: "white-space: {{VALUE}}",
836
+ lineHeight: "line-height: {{VALUE}}px",
837
+ wordWrapWidth: "max-width: {{VALUE}}px"
838
+ }, Te = {
839
+ fill: (n) => `color: ${G.shared.setValue(n).toHex()}`,
840
+ breakWords: (n) => `word-wrap: ${n ? "break-all" : "break-word"}`,
841
+ stroke: Ze,
842
+ dropShadow: Je
843
+ };
844
+ function Jt(n, e) {
845
+ for (const t in n) {
846
+ const r = n[t], i = [];
847
+ for (const s in r)
848
+ Te[s] ? i.push(Te[s](r[s])) : ve[s] && i.push(ve[s].replace("{{VALUE}}", r[s]));
849
+ e.push(`${t} { ${i.join(";")} }`);
850
+ }
851
+ }
852
+ class pe extends V {
853
+ constructor(e = {}) {
854
+ var t, r;
855
+ super(e), this._cssOverrides = [], (t = this.cssOverrides) != null || (this.cssOverrides = e.cssOverrides), this.tagStyles = (r = e.tagStyles) != null ? r : {};
856
+ }
857
+ set cssOverrides(e) {
858
+ this._cssOverrides = e instanceof Array ? e : [e], this.update();
859
+ }
860
+ get cssOverrides() {
861
+ return this._cssOverrides;
862
+ }
863
+ _generateKey() {
864
+ return this._styleKey = Ct(this) + this._cssOverrides.join("-"), this._styleKey;
865
+ }
866
+ update() {
867
+ this._cssStyle = null, super.update();
868
+ }
869
+ clone() {
870
+ return new pe({
871
+ align: this.align,
872
+ breakWords: this.breakWords,
873
+ dropShadow: this.dropShadow ? { ...this.dropShadow } : null,
874
+ fill: this._fill,
875
+ fontFamily: this.fontFamily,
876
+ fontSize: this.fontSize,
877
+ fontStyle: this.fontStyle,
878
+ fontVariant: this.fontVariant,
879
+ fontWeight: this.fontWeight,
880
+ letterSpacing: this.letterSpacing,
881
+ lineHeight: this.lineHeight,
882
+ padding: this.padding,
883
+ stroke: this._stroke,
884
+ whiteSpace: this.whiteSpace,
885
+ wordWrap: this.wordWrap,
886
+ wordWrapWidth: this.wordWrapWidth,
887
+ cssOverrides: this.cssOverrides
888
+ });
889
+ }
890
+ get cssStyle() {
891
+ return this._cssStyle || (this._cssStyle = Qt(this)), this._cssStyle;
892
+ }
893
+ addOverride(...e) {
894
+ const t = e.filter((r) => !this.cssOverrides.includes(r));
895
+ t.length > 0 && (this.cssOverrides.push(...t), this.update());
896
+ }
897
+ removeOverride(...e) {
898
+ const t = e.filter((r) => this.cssOverrides.includes(r));
899
+ t.length > 0 && (this.cssOverrides = this.cssOverrides.filter((r) => !t.includes(r)), this.update());
900
+ }
901
+ set fill(e) {
902
+ typeof e != "string" && typeof e != "number" && E("[HTMLTextStyle] only color fill is not supported by HTMLText"), super.fill = e;
903
+ }
904
+ set stroke(e) {
905
+ e && typeof e != "string" && typeof e != "number" && E("[HTMLTextStyle] only color stroke is not supported by HTMLText"), super.stroke = e;
906
+ }
907
+ }
908
+ const we = "http://www.w3.org/2000/svg", Se = "http://www.w3.org/1999/xhtml";
909
+ class et {
910
+ constructor() {
911
+ this.svgRoot = document.createElementNS(we, "svg"), this.foreignObject = document.createElementNS(we, "foreignObject"), this.domElement = document.createElementNS(Se, "div"), this.styleElement = document.createElementNS(Se, "style"), this.image = new Image();
912
+ const { foreignObject: e, svgRoot: t, styleElement: r, domElement: i } = this;
913
+ e.setAttribute("width", "10000"), e.setAttribute("height", "10000"), e.style.overflow = "hidden", t.appendChild(e), e.appendChild(r), e.appendChild(i);
914
+ }
915
+ }
916
+ let Be;
917
+ function Zt(n, e, t, r) {
918
+ r = r || Be || (Be = new et());
919
+ const { domElement: i, styleElement: s, svgRoot: a } = r;
920
+ i.innerHTML = `<style>${e.cssStyle};</style><div style='padding:0'>${n}</div>`, i.setAttribute("style", "transform-origin: top left; display: inline-block"), t && (s.textContent = t), document.body.appendChild(a);
921
+ const o = i.getBoundingClientRect();
922
+ a.remove();
923
+ const d = e.padding * 2;
924
+ return {
925
+ width: o.width - d,
926
+ height: o.height - d
927
+ };
928
+ }
929
+ class tt {
930
+ constructor(e, t) {
931
+ this.state = ee.for2d(), this._graphicsBatchesHash = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this.renderer = e, this._adaptor = t, this._adaptor.init(), this.renderer.renderableGC.addManagedHash(this, "_graphicsBatchesHash");
932
+ }
933
+ validateRenderable(e) {
934
+ const t = e.context, r = !!this._graphicsBatchesHash[e.uid], i = this.renderer.graphicsContext.updateGpuContext(t);
935
+ return !!(i.isBatchable || r !== i.isBatchable);
936
+ }
937
+ addRenderable(e, t) {
938
+ const r = this.renderer.graphicsContext.updateGpuContext(e.context);
939
+ e.didViewUpdate && this._rebuild(e), r.isBatchable ? this._addToBatcher(e, t) : (this.renderer.renderPipes.batch.break(t), t.add(e));
940
+ }
941
+ updateRenderable(e) {
942
+ const t = this._graphicsBatchesHash[e.uid];
943
+ if (t)
944
+ for (let r = 0; r < t.length; r++) {
945
+ const i = t[r];
946
+ i._batcher.updateElement(i);
947
+ }
948
+ }
949
+ destroyRenderable(e) {
950
+ this._graphicsBatchesHash[e.uid] && this._removeBatchForRenderable(e.uid), e.off("destroyed", this._destroyRenderableBound);
951
+ }
952
+ execute(e) {
953
+ if (!e.isRenderable)
954
+ return;
955
+ const t = this.renderer, r = e.context;
956
+ if (!t.graphicsContext.getGpuContext(r).batches.length)
957
+ return;
958
+ const s = r.customShader || this._adaptor.shader;
959
+ this.state.blendMode = e.groupBlendMode;
960
+ const a = s.resources.localUniforms.uniforms;
961
+ a.uTransformMatrix = e.groupTransform, a.uRound = t._roundPixels | e._roundPixels, re(
962
+ e.groupColorAlpha,
963
+ a.uColor,
964
+ 0
965
+ ), this._adaptor.execute(this, e);
966
+ }
967
+ _rebuild(e) {
968
+ const t = !!this._graphicsBatchesHash[e.uid], r = this.renderer.graphicsContext.updateGpuContext(e.context);
969
+ t && this._removeBatchForRenderable(e.uid), r.isBatchable && this._initBatchesForRenderable(e), e.batched = r.isBatchable;
970
+ }
971
+ _addToBatcher(e, t) {
972
+ const r = this.renderer.renderPipes.batch, i = this._getBatchesForRenderable(e);
973
+ for (let s = 0; s < i.length; s++) {
974
+ const a = i[s];
975
+ r.addToBatch(a, t);
976
+ }
977
+ }
978
+ _getBatchesForRenderable(e) {
979
+ return this._graphicsBatchesHash[e.uid] || this._initBatchesForRenderable(e);
980
+ }
981
+ _initBatchesForRenderable(e) {
982
+ const t = e.context, r = this.renderer.graphicsContext.getGpuContext(t), i = this.renderer._roundPixels | e._roundPixels, s = r.batches.map((a) => {
983
+ const o = T.get(Pt);
984
+ return a.copyTo(o), o.renderable = e, o.roundPixels = i, o;
985
+ });
986
+ return this._graphicsBatchesHash[e.uid] === void 0 && e.on("destroyed", this._destroyRenderableBound), this._graphicsBatchesHash[e.uid] = s, s;
987
+ }
988
+ _removeBatchForRenderable(e) {
989
+ this._graphicsBatchesHash[e].forEach((t) => {
990
+ T.return(t);
991
+ }), this._graphicsBatchesHash[e] = null;
992
+ }
993
+ destroy() {
994
+ this.renderer = null, this._adaptor.destroy(), this._adaptor = null, this.state = null;
995
+ for (const e in this._graphicsBatchesHash)
996
+ this._removeBatchForRenderable(e);
997
+ this._graphicsBatchesHash = null;
998
+ }
999
+ }
1000
+ tt.extension = {
1001
+ type: [
1002
+ _.WebGLPipes,
1003
+ _.WebGPUPipes,
1004
+ _.CanvasPipes
1005
+ ],
1006
+ name: "graphics"
1007
+ };
1008
+ const rt = class it extends fe {
1009
+ constructor(...e) {
1010
+ var r;
1011
+ super({});
1012
+ let t = (r = e[0]) != null ? r : {};
1013
+ typeof t == "number" && (k(H, "PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"), t = {
1014
+ width: t,
1015
+ height: e[1],
1016
+ verticesX: e[2],
1017
+ verticesY: e[3]
1018
+ }), this.build(t);
1019
+ }
1020
+ build(e) {
1021
+ var c, f, m, g;
1022
+ e = { ...it.defaultOptions, ...e }, this.verticesX = (c = this.verticesX) != null ? c : e.verticesX, this.verticesY = (f = this.verticesY) != null ? f : e.verticesY, this.width = (m = this.width) != null ? m : e.width, this.height = (g = this.height) != null ? g : e.height;
1023
+ const t = this.verticesX * this.verticesY, r = [], i = [], s = [], a = this.verticesX - 1, o = this.verticesY - 1, d = this.width / a, l = this.height / o;
1024
+ for (let h = 0; h < t; h++) {
1025
+ const p = h % this.verticesX, x = h / this.verticesX | 0;
1026
+ r.push(p * d, x * l), i.push(p / a, x / o);
1027
+ }
1028
+ const u = a * o;
1029
+ for (let h = 0; h < u; h++) {
1030
+ const p = h % a, x = h / a | 0, v = x * this.verticesX + p, b = x * this.verticesX + p + 1, y = (x + 1) * this.verticesX + p, C = (x + 1) * this.verticesX + p + 1;
1031
+ s.push(
1032
+ v,
1033
+ b,
1034
+ y,
1035
+ b,
1036
+ C,
1037
+ y
1038
+ );
1039
+ }
1040
+ this.buffers[0].data = new Float32Array(r), this.buffers[1].data = new Float32Array(i), this.indexBuffer.data = new Uint32Array(s), this.buffers[0].update(), this.buffers[1].update(), this.indexBuffer.update();
1041
+ }
1042
+ };
1043
+ rt.defaultOptions = {
1044
+ width: 100,
1045
+ height: 100,
1046
+ verticesX: 10,
1047
+ verticesY: 10
1048
+ };
1049
+ let er = rt;
1050
+ class ge {
1051
+ constructor() {
1052
+ this.batcherName = "default", this.packAsQuad = !1, this.indexOffset = 0, this.attributeOffset = 0, this.roundPixels = 0, this._batcher = null, this._batch = null, this._uvUpdateId = -1, this._textureMatrixUpdateId = -1;
1053
+ }
1054
+ get blendMode() {
1055
+ return this.renderable.groupBlendMode;
1056
+ }
1057
+ reset() {
1058
+ this.renderable = null, this.texture = null, this._batcher = null, this._batch = null, this.geometry = null, this._uvUpdateId = -1, this._textureMatrixUpdateId = -1;
1059
+ }
1060
+ get uvs() {
1061
+ const t = this.geometry.getBuffer("aUV"), r = t.data;
1062
+ let i = r;
1063
+ const s = this.texture.textureMatrix;
1064
+ return s.isSimple || (i = this._transformedUvs, (this._textureMatrixUpdateId !== s._updateID || this._uvUpdateId !== t._updateID) && ((!i || i.length < r.length) && (i = this._transformedUvs = new Float32Array(r.length)), this._textureMatrixUpdateId = s._updateID, this._uvUpdateId = t._updateID, s.multiplyUvs(r, i))), i;
1065
+ }
1066
+ get positions() {
1067
+ return this.geometry.positions;
1068
+ }
1069
+ get indices() {
1070
+ return this.geometry.indices;
1071
+ }
1072
+ get color() {
1073
+ return this.renderable.groupColorAlpha;
1074
+ }
1075
+ get groupTransform() {
1076
+ return this.renderable.groupTransform;
1077
+ }
1078
+ get attributeSize() {
1079
+ return this.geometry.positions.length / 2;
1080
+ }
1081
+ get indexSize() {
1082
+ return this.geometry.indices.length;
1083
+ }
1084
+ }
1085
+ class st {
1086
+ constructor(e, t) {
1087
+ this.localUniforms = new L({
1088
+ uTransformMatrix: { value: new P(), type: "mat3x3<f32>" },
1089
+ uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
1090
+ uRound: { value: 0, type: "f32" }
1091
+ }), this.localUniformsBindGroup = new ke({
1092
+ 0: this.localUniforms
1093
+ }), this._meshDataHash = /* @__PURE__ */ Object.create(null), this._gpuBatchableMeshHash = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this.renderer = e, this._adaptor = t, this._adaptor.init(), e.renderableGC.addManagedHash(this, "_gpuBatchableMeshHash"), e.renderableGC.addManagedHash(this, "_meshDataHash");
1094
+ }
1095
+ validateRenderable(e) {
1096
+ const t = this._getMeshData(e), r = t.batched, i = e.batched;
1097
+ if (t.batched = i, r !== i)
1098
+ return !0;
1099
+ if (i) {
1100
+ const s = e._geometry;
1101
+ if (s.indices.length !== t.indexSize || s.positions.length !== t.vertexSize)
1102
+ return t.indexSize = s.indices.length, t.vertexSize = s.positions.length, !0;
1103
+ const a = this._getBatchableMesh(e), o = e.texture;
1104
+ if (a.texture._source !== o._source && a.texture._source !== o._source)
1105
+ return !a._batcher.checkAndUpdateTexture(a, o);
1106
+ }
1107
+ return !1;
1108
+ }
1109
+ addRenderable(e, t) {
1110
+ const r = this.renderer.renderPipes.batch, { batched: i } = this._getMeshData(e);
1111
+ if (i) {
1112
+ const s = this._getBatchableMesh(e);
1113
+ s.texture = e._texture, s.geometry = e._geometry, r.addToBatch(s, t);
1114
+ } else
1115
+ r.break(t), t.add(e);
1116
+ }
1117
+ updateRenderable(e) {
1118
+ if (e.batched) {
1119
+ const t = this._gpuBatchableMeshHash[e.uid];
1120
+ t.texture = e._texture, t.geometry = e._geometry, t._batcher.updateElement(t);
1121
+ }
1122
+ }
1123
+ destroyRenderable(e) {
1124
+ this._meshDataHash[e.uid] = null;
1125
+ const t = this._gpuBatchableMeshHash[e.uid];
1126
+ t && (T.return(t), this._gpuBatchableMeshHash[e.uid] = null), e.off("destroyed", this._destroyRenderableBound);
1127
+ }
1128
+ execute(e) {
1129
+ if (!e.isRenderable)
1130
+ return;
1131
+ e.state.blendMode = ce(e.groupBlendMode, e.texture._source);
1132
+ const t = this.localUniforms;
1133
+ t.uniforms.uTransformMatrix = e.groupTransform, t.uniforms.uRound = this.renderer._roundPixels | e._roundPixels, t.update(), re(
1134
+ e.groupColorAlpha,
1135
+ t.uniforms.uColor,
1136
+ 0
1137
+ ), this._adaptor.execute(this, e);
1138
+ }
1139
+ _getMeshData(e) {
1140
+ return this._meshDataHash[e.uid] || this._initMeshData(e);
1141
+ }
1142
+ _initMeshData(e) {
1143
+ var t, r;
1144
+ return this._meshDataHash[e.uid] = {
1145
+ batched: e.batched,
1146
+ indexSize: (t = e._geometry.indices) == null ? void 0 : t.length,
1147
+ vertexSize: (r = e._geometry.positions) == null ? void 0 : r.length
1148
+ }, e.on("destroyed", this._destroyRenderableBound), this._meshDataHash[e.uid];
1149
+ }
1150
+ _getBatchableMesh(e) {
1151
+ return this._gpuBatchableMeshHash[e.uid] || this._initBatchableMesh(e);
1152
+ }
1153
+ _initBatchableMesh(e) {
1154
+ const t = T.get(ge);
1155
+ return t.renderable = e, t.texture = e._texture, t.transform = e.groupTransform, t.roundPixels = this.renderer._roundPixels | e._roundPixels, this._gpuBatchableMeshHash[e.uid] = t, t;
1156
+ }
1157
+ destroy() {
1158
+ for (const e in this._gpuBatchableMeshHash)
1159
+ this._gpuBatchableMeshHash[e] && T.return(this._gpuBatchableMeshHash[e]);
1160
+ this._gpuBatchableMeshHash = null, this._meshDataHash = null, this.localUniforms = null, this.localUniformsBindGroup = null, this._adaptor.destroy(), this._adaptor = null, this.renderer = null;
1161
+ }
1162
+ }
1163
+ st.extension = {
1164
+ type: [
1165
+ _.WebGLPipes,
1166
+ _.WebGPUPipes,
1167
+ _.CanvasPipes
1168
+ ],
1169
+ name: "mesh"
1170
+ };
1171
+ class tr {
1172
+ execute(e, t) {
1173
+ const r = e.state, i = e.renderer, s = t.shader || e.defaultShader;
1174
+ s.resources.uTexture = t.texture._source, s.resources.uniforms = e.localUniforms;
1175
+ const a = i.gl, o = e.getBuffers(t);
1176
+ i.shader.bind(s), i.state.set(r), i.geometry.bind(o.geometry, s.glProgram);
1177
+ const l = o.geometry.indexBuffer.data.BYTES_PER_ELEMENT === 2 ? a.UNSIGNED_SHORT : a.UNSIGNED_INT;
1178
+ a.drawElements(a.TRIANGLES, t.particleChildren.length * 6, l, 0);
1179
+ }
1180
+ }
1181
+ class rr {
1182
+ execute(e, t) {
1183
+ const r = e.renderer, i = t.shader || e.defaultShader;
1184
+ i.groups[0] = r.renderPipes.uniformBatch.getUniformBindGroup(e.localUniforms, !0), i.groups[1] = r.texture.getTextureBindGroup(t.texture);
1185
+ const s = e.state, a = e.getBuffers(t);
1186
+ r.encoder.draw({
1187
+ geometry: a.geometry,
1188
+ shader: t.shader || e.defaultShader,
1189
+ state: s,
1190
+ size: t.particleChildren.length * 6
1191
+ });
1192
+ }
1193
+ }
1194
+ function Ce(n, e = null) {
1195
+ const t = n * 6;
1196
+ if (t > 65535 ? e = e || new Uint32Array(t) : e = e || new Uint16Array(t), e.length !== t)
1197
+ throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);
1198
+ for (let r = 0, i = 0; r < t; r += 6, i += 4)
1199
+ e[r + 0] = i + 0, e[r + 1] = i + 1, e[r + 2] = i + 2, e[r + 3] = i + 0, e[r + 4] = i + 2, e[r + 5] = i + 3;
1200
+ return e;
1201
+ }
1202
+ function ir(n) {
1203
+ return {
1204
+ dynamicUpdate: Pe(n, !0),
1205
+ staticUpdate: Pe(n, !1)
1206
+ };
1207
+ }
1208
+ function Pe(n, e) {
1209
+ const t = [];
1210
+ t.push(`
1211
+
1212
+ var index = 0;
1213
+
1214
+ for (let i = 0; i < ps.length; ++i)
1215
+ {
1216
+ const p = ps[i];
1217
+
1218
+ `);
1219
+ let r = 0;
1220
+ for (const s in n) {
1221
+ const a = n[s];
1222
+ if (e !== a.dynamic)
1223
+ continue;
1224
+ t.push(`offset = index + ${r}`), t.push(a.code);
1225
+ const o = oe(a.format);
1226
+ r += o.stride / 4;
1227
+ }
1228
+ t.push(`
1229
+ index += stride * 4;
1230
+ }
1231
+ `), t.unshift(`
1232
+ var stride = ${r};
1233
+ `);
1234
+ const i = t.join(`
1235
+ `);
1236
+ return new Function("ps", "f32v", "u32v", i);
1237
+ }
1238
+ class sr {
1239
+ constructor(e) {
1240
+ var u;
1241
+ this._size = 0, this._generateParticleUpdateCache = {};
1242
+ const t = this._size = (u = e.size) != null ? u : 1e3, r = e.properties;
1243
+ let i = 0, s = 0;
1244
+ for (const c in r) {
1245
+ const f = r[c], m = oe(f.format);
1246
+ f.dynamic ? s += m.stride : i += m.stride;
1247
+ }
1248
+ this._dynamicStride = s / 4, this._staticStride = i / 4, this.staticAttributeBuffer = new q(t * 4 * i), this.dynamicAttributeBuffer = new q(t * 4 * s), this.indexBuffer = Ce(t);
1249
+ const a = new le();
1250
+ let o = 0, d = 0;
1251
+ this._staticBuffer = new N({
1252
+ data: new Float32Array(1),
1253
+ label: "static-particle-buffer",
1254
+ shrinkToFit: !1,
1255
+ usage: A.VERTEX | A.COPY_DST
1256
+ }), this._dynamicBuffer = new N({
1257
+ data: new Float32Array(1),
1258
+ label: "dynamic-particle-buffer",
1259
+ shrinkToFit: !1,
1260
+ usage: A.VERTEX | A.COPY_DST
1261
+ });
1262
+ for (const c in r) {
1263
+ const f = r[c], m = oe(f.format);
1264
+ f.dynamic ? (a.addAttribute(f.attributeName, {
1265
+ buffer: this._dynamicBuffer,
1266
+ stride: this._dynamicStride * 4,
1267
+ offset: o * 4,
1268
+ format: f.format
1269
+ }), o += m.size) : (a.addAttribute(f.attributeName, {
1270
+ buffer: this._staticBuffer,
1271
+ stride: this._staticStride * 4,
1272
+ offset: d * 4,
1273
+ format: f.format
1274
+ }), d += m.size);
1275
+ }
1276
+ a.addIndex(this.indexBuffer);
1277
+ const l = this.getParticleUpdate(r);
1278
+ this._dynamicUpload = l.dynamicUpdate, this._staticUpload = l.staticUpdate, this.geometry = a;
1279
+ }
1280
+ getParticleUpdate(e) {
1281
+ const t = nr(e);
1282
+ return this._generateParticleUpdateCache[t] ? this._generateParticleUpdateCache[t] : (this._generateParticleUpdateCache[t] = this.generateParticleUpdate(e), this._generateParticleUpdateCache[t]);
1283
+ }
1284
+ generateParticleUpdate(e) {
1285
+ return ir(e);
1286
+ }
1287
+ update(e, t) {
1288
+ e.length > this._size && (t = !0, this._size = Math.max(e.length, this._size * 1.5 | 0), this.staticAttributeBuffer = new q(this._size * this._staticStride * 4 * 4), this.dynamicAttributeBuffer = new q(this._size * this._dynamicStride * 4 * 4), this.indexBuffer = Ce(this._size), this.geometry.indexBuffer.setDataWithSize(
1289
+ this.indexBuffer,
1290
+ this.indexBuffer.byteLength,
1291
+ !0
1292
+ ));
1293
+ const r = this.dynamicAttributeBuffer;
1294
+ if (this._dynamicUpload(e, r.float32View, r.uint32View), this._dynamicBuffer.setDataWithSize(
1295
+ this.dynamicAttributeBuffer.float32View,
1296
+ e.length * this._dynamicStride * 4,
1297
+ !0
1298
+ ), t) {
1299
+ const i = this.staticAttributeBuffer;
1300
+ this._staticUpload(e, i.float32View, i.uint32View), this._staticBuffer.setDataWithSize(
1301
+ i.float32View,
1302
+ e.length * this._staticStride * 4,
1303
+ !0
1304
+ );
1305
+ }
1306
+ }
1307
+ destroy() {
1308
+ this._staticBuffer.destroy(), this._dynamicBuffer.destroy(), this.geometry.destroy();
1309
+ }
1310
+ }
1311
+ function nr(n) {
1312
+ const e = [];
1313
+ for (const t in n) {
1314
+ const r = n[t];
1315
+ e.push(t, r.code, r.dynamic ? "d" : "s");
1316
+ }
1317
+ return e.join("_");
1318
+ }
1319
+ var ar = `varying vec2 vUV;
1320
+ varying vec4 vColor;
1321
+
1322
+ uniform sampler2D uTexture;
1323
+
1324
+ void main(void){
1325
+ vec4 color = texture2D(uTexture, vUV) * vColor;
1326
+ gl_FragColor = color;
1327
+ }`, or = `attribute vec2 aVertex;
1328
+ attribute vec2 aUV;
1329
+ attribute vec4 aColor;
1330
+
1331
+ attribute vec2 aPosition;
1332
+ attribute float aRotation;
1333
+
1334
+ uniform mat3 uTranslationMatrix;
1335
+ uniform float uRound;
1336
+ uniform vec2 uResolution;
1337
+ uniform vec4 uColor;
1338
+
1339
+ varying vec2 vUV;
1340
+ varying vec4 vColor;
1341
+
1342
+ vec2 roundPixels(vec2 position, vec2 targetSize)
1343
+ {
1344
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
1345
+ }
1346
+
1347
+ void main(void){
1348
+ float cosRotation = cos(aRotation);
1349
+ float sinRotation = sin(aRotation);
1350
+ float x = aVertex.x * cosRotation - aVertex.y * sinRotation;
1351
+ float y = aVertex.x * sinRotation + aVertex.y * cosRotation;
1352
+
1353
+ vec2 v = vec2(x, y);
1354
+ v = v + aPosition;
1355
+
1356
+ gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
1357
+
1358
+ if(uRound == 1.0)
1359
+ {
1360
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
1361
+ }
1362
+
1363
+ vUV = aUV;
1364
+ vColor = aColor * uColor;
1365
+ }
1366
+ `, Re = `
1367
+ struct ParticleUniforms {
1368
+ uProjectionMatrix:mat3x3<f32>,
1369
+ uResolution:vec2<f32>,
1370
+ uRoundPixels:f32,
1371
+ };
1372
+
1373
+ @group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
1374
+
1375
+ @group(1) @binding(0) var uTexture: texture_2d<f32>;
1376
+ @group(1) @binding(1) var uSampler : sampler;
1377
+
1378
+ struct VSOutput {
1379
+ @builtin(position) position: vec4<f32>,
1380
+ @location(0) uv : vec2<f32>,
1381
+ @location(1) color : vec4<f32>,
1382
+ };
1383
+ @vertex
1384
+ fn mainVertex(
1385
+ @location(0) aVertex: vec2<f32>,
1386
+ @location(1) aPosition: vec2<f32>,
1387
+ @location(2) aUV: vec2<f32>,
1388
+ @location(3) aColor: vec4<f32>,
1389
+ @location(4) aRotation: f32,
1390
+ ) -> VSOutput {
1391
+
1392
+ let v = vec2(
1393
+ aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),
1394
+ aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
1395
+ ) + aPosition;
1396
+
1397
+ let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
1398
+
1399
+ return VSOutput(
1400
+ position,
1401
+ aUV,
1402
+ aColor,
1403
+ );
1404
+ }
1405
+
1406
+ @fragment
1407
+ fn mainFragment(
1408
+ @location(0) uv: vec2<f32>,
1409
+ @location(1) color: vec4<f32>,
1410
+ @builtin(position) position: vec4<f32>,
1411
+ ) -> @location(0) vec4<f32> {
1412
+
1413
+ var sample = textureSample(uTexture, uSampler, uv) * color;
1414
+
1415
+ return sample;
1416
+ }`;
1417
+ class dr extends he {
1418
+ constructor() {
1419
+ const e = Rt.from({
1420
+ vertex: or,
1421
+ fragment: ar
1422
+ }), t = Mt.from({
1423
+ fragment: {
1424
+ source: Re,
1425
+ entryPoint: "mainFragment"
1426
+ },
1427
+ vertex: {
1428
+ source: Re,
1429
+ entryPoint: "mainVertex"
1430
+ }
1431
+ });
1432
+ super({
1433
+ glProgram: e,
1434
+ gpuProgram: t,
1435
+ resources: {
1436
+ uTexture: R.WHITE.source,
1437
+ uSampler: new Ft({}),
1438
+ uniforms: {
1439
+ uTranslationMatrix: { value: new P(), type: "mat3x3<f32>" },
1440
+ uColor: { value: new G(16777215), type: "vec4<f32>" },
1441
+ uRound: { value: 1, type: "f32" },
1442
+ uResolution: { value: [0, 0], type: "vec2<f32>" }
1443
+ }
1444
+ }
1445
+ });
1446
+ }
1447
+ }
1448
+ class nt {
1449
+ constructor(e, t) {
1450
+ this.state = ee.for2d(), this._gpuBufferHash = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this.localUniforms = new L({
1451
+ uTranslationMatrix: { value: new P(), type: "mat3x3<f32>" },
1452
+ uColor: { value: new Float32Array(4), type: "vec4<f32>" },
1453
+ uRound: { value: 1, type: "f32" },
1454
+ uResolution: { value: [0, 0], type: "vec2<f32>" }
1455
+ }), this.renderer = e, this.adaptor = t, this.defaultShader = new dr(), this.state = ee.for2d();
1456
+ }
1457
+ validateRenderable(e) {
1458
+ return !1;
1459
+ }
1460
+ addRenderable(e, t) {
1461
+ this.renderer.renderPipes.batch.break(t), t.add(e);
1462
+ }
1463
+ getBuffers(e) {
1464
+ return this._gpuBufferHash[e.uid] || this._initBuffer(e);
1465
+ }
1466
+ _initBuffer(e) {
1467
+ return this._gpuBufferHash[e.uid] = new sr({
1468
+ size: e.particleChildren.length,
1469
+ properties: e._properties
1470
+ }), e.on("destroyed", this._destroyRenderableBound), this._gpuBufferHash[e.uid];
1471
+ }
1472
+ updateRenderable(e) {
1473
+ }
1474
+ destroyRenderable(e) {
1475
+ this._gpuBufferHash[e.uid].destroy(), this._gpuBufferHash[e.uid] = null, e.off("destroyed", this._destroyRenderableBound);
1476
+ }
1477
+ execute(e) {
1478
+ const t = e.particleChildren;
1479
+ if (t.length === 0)
1480
+ return;
1481
+ const r = this.renderer, i = this.getBuffers(e);
1482
+ e.texture || (e.texture = t[0].texture);
1483
+ const s = this.state;
1484
+ i.update(t, e._childrenDirty), e._childrenDirty = !1, s.blendMode = ce(e.blendMode, e.texture._source);
1485
+ const a = this.localUniforms.uniforms, o = a.uTranslationMatrix;
1486
+ e.worldTransform.copyTo(o), o.prepend(r.globalUniforms.globalUniformData.projectionMatrix), a.uResolution = r.globalUniforms.globalUniformData.resolution, a.uRound = r._roundPixels | e._roundPixels, re(
1487
+ e.groupColorAlpha,
1488
+ a.uColor,
1489
+ 0
1490
+ ), this.adaptor.execute(this, e);
1491
+ }
1492
+ destroy() {
1493
+ this.defaultShader && (this.defaultShader.destroy(), this.defaultShader = null);
1494
+ }
1495
+ }
1496
+ class at extends nt {
1497
+ constructor(e) {
1498
+ super(e, new tr());
1499
+ }
1500
+ }
1501
+ at.extension = {
1502
+ type: [
1503
+ _.WebGLPipes
1504
+ ],
1505
+ name: "particle"
1506
+ };
1507
+ class ot extends nt {
1508
+ constructor(e) {
1509
+ super(e, new rr());
1510
+ }
1511
+ }
1512
+ ot.extension = {
1513
+ type: [
1514
+ _.WebGPUPipes
1515
+ ],
1516
+ name: "particle"
1517
+ };
1518
+ const dt = class lt extends er {
1519
+ constructor(e = {}) {
1520
+ e = { ...lt.defaultOptions, ...e }, super({
1521
+ width: e.width,
1522
+ height: e.height,
1523
+ verticesX: 4,
1524
+ verticesY: 4
1525
+ }), this.update(e);
1526
+ }
1527
+ update(e) {
1528
+ var t, r, i, s, a, o, d, l;
1529
+ this.width = (t = e.width) != null ? t : this.width, this.height = (r = e.height) != null ? r : this.height, this._originalWidth = (i = e.originalWidth) != null ? i : this._originalWidth, this._originalHeight = (s = e.originalHeight) != null ? s : this._originalHeight, this._leftWidth = (a = e.leftWidth) != null ? a : this._leftWidth, this._rightWidth = (o = e.rightWidth) != null ? o : this._rightWidth, this._topHeight = (d = e.topHeight) != null ? d : this._topHeight, this._bottomHeight = (l = e.bottomHeight) != null ? l : this._bottomHeight, this.updateUvs(), this.updatePositions();
1530
+ }
1531
+ updatePositions() {
1532
+ const e = this.positions, t = this._leftWidth + this._rightWidth, r = this.width > t ? 1 : this.width / t, i = this._topHeight + this._bottomHeight, s = this.height > i ? 1 : this.height / i, a = Math.min(r, s);
1533
+ e[9] = e[11] = e[13] = e[15] = this._topHeight * a, e[17] = e[19] = e[21] = e[23] = this.height - this._bottomHeight * a, e[25] = e[27] = e[29] = e[31] = this.height, e[2] = e[10] = e[18] = e[26] = this._leftWidth * a, e[4] = e[12] = e[20] = e[28] = this.width - this._rightWidth * a, e[6] = e[14] = e[22] = e[30] = this.width, this.getBuffer("aPosition").update();
1534
+ }
1535
+ updateUvs() {
1536
+ const e = this.uvs;
1537
+ e[0] = e[8] = e[16] = e[24] = 0, e[1] = e[3] = e[5] = e[7] = 0, e[6] = e[14] = e[22] = e[30] = 1, e[25] = e[27] = e[29] = e[31] = 1;
1538
+ const t = 1 / this._originalWidth, r = 1 / this._originalHeight;
1539
+ e[2] = e[10] = e[18] = e[26] = t * this._leftWidth, e[9] = e[11] = e[13] = e[15] = r * this._topHeight, e[4] = e[12] = e[20] = e[28] = 1 - t * this._rightWidth, e[17] = e[19] = e[21] = e[23] = 1 - r * this._bottomHeight, this.getBuffer("aUV").update();
1540
+ }
1541
+ };
1542
+ dt.defaultOptions = {
1543
+ width: 100,
1544
+ height: 100,
1545
+ leftWidth: 10,
1546
+ topHeight: 10,
1547
+ rightWidth: 10,
1548
+ bottomHeight: 10,
1549
+ originalWidth: 100,
1550
+ originalHeight: 100
1551
+ };
1552
+ let lr = dt;
1553
+ class ut {
1554
+ constructor(e) {
1555
+ this._gpuSpriteHash = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_gpuSpriteHash");
1556
+ }
1557
+ addRenderable(e, t) {
1558
+ const r = this._getGpuSprite(e);
1559
+ e.didViewUpdate && this._updateBatchableSprite(e, r), this._renderer.renderPipes.batch.addToBatch(r, t);
1560
+ }
1561
+ updateRenderable(e) {
1562
+ const t = this._gpuSpriteHash[e.uid];
1563
+ e.didViewUpdate && this._updateBatchableSprite(e, t), t._batcher.updateElement(t);
1564
+ }
1565
+ validateRenderable(e) {
1566
+ const t = e._texture, r = this._getGpuSprite(e);
1567
+ return r.texture._source !== t._source ? !r._batcher.checkAndUpdateTexture(r, t) : !1;
1568
+ }
1569
+ destroyRenderable(e) {
1570
+ const t = this._gpuSpriteHash[e.uid];
1571
+ T.return(t.geometry), T.return(t), this._gpuSpriteHash[e.uid] = null, e.off("destroyed", this._destroyRenderableBound);
1572
+ }
1573
+ _updateBatchableSprite(e, t) {
1574
+ t.geometry.update(e), t.texture = e._texture;
1575
+ }
1576
+ _getGpuSprite(e) {
1577
+ return this._gpuSpriteHash[e.uid] || this._initGPUSprite(e);
1578
+ }
1579
+ _initGPUSprite(e) {
1580
+ const t = T.get(ge);
1581
+ return t.geometry = T.get(lr), t.renderable = e, t.transform = e.groupTransform, t.texture = e._texture, t.roundPixels = this._renderer._roundPixels | e._roundPixels, this._gpuSpriteHash[e.uid] = t, e.didViewUpdate || this._updateBatchableSprite(e, t), e.on("destroyed", this._destroyRenderableBound), t;
1582
+ }
1583
+ destroy() {
1584
+ for (const e in this._gpuSpriteHash)
1585
+ this._gpuSpriteHash[e].geometry.destroy();
1586
+ this._gpuSpriteHash = null, this._renderer = null;
1587
+ }
1588
+ }
1589
+ ut.extension = {
1590
+ type: [
1591
+ _.WebGLPipes,
1592
+ _.WebGPUPipes,
1593
+ _.CanvasPipes
1594
+ ],
1595
+ name: "nineSliceSprite"
1596
+ };
1597
+ const ur = {
1598
+ name: "tiling-bit",
1599
+ vertex: {
1600
+ header: `
1601
+ struct TilingUniforms {
1602
+ uMapCoord:mat3x3<f32>,
1603
+ uClampFrame:vec4<f32>,
1604
+ uClampOffset:vec2<f32>,
1605
+ uTextureTransform:mat3x3<f32>,
1606
+ uSizeAnchor:vec4<f32>
1607
+ };
1608
+
1609
+ @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
1610
+ @group(2) @binding(1) var uTexture: texture_2d<f32>;
1611
+ @group(2) @binding(2) var uSampler: sampler;
1612
+ `,
1613
+ main: `
1614
+ uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
1615
+
1616
+ position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
1617
+ `
1618
+ },
1619
+ fragment: {
1620
+ header: `
1621
+ struct TilingUniforms {
1622
+ uMapCoord:mat3x3<f32>,
1623
+ uClampFrame:vec4<f32>,
1624
+ uClampOffset:vec2<f32>,
1625
+ uTextureTransform:mat3x3<f32>,
1626
+ uSizeAnchor:vec4<f32>
1627
+ };
1628
+
1629
+ @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
1630
+ @group(2) @binding(1) var uTexture: texture_2d<f32>;
1631
+ @group(2) @binding(2) var uSampler: sampler;
1632
+ `,
1633
+ main: `
1634
+
1635
+ var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
1636
+ coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
1637
+ var unclamped = coord;
1638
+ coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
1639
+
1640
+ var bias = 0.;
1641
+
1642
+ if(unclamped.x == coord.x && unclamped.y == coord.y)
1643
+ {
1644
+ bias = -32.;
1645
+ }
1646
+
1647
+ outColor = textureSampleBias(uTexture, uSampler, coord, bias);
1648
+ `
1649
+ }
1650
+ }, cr = {
1651
+ name: "tiling-bit",
1652
+ vertex: {
1653
+ header: `
1654
+ uniform mat3 uTextureTransform;
1655
+ uniform vec4 uSizeAnchor;
1656
+
1657
+ `,
1658
+ main: `
1659
+ uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
1660
+
1661
+ position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
1662
+ `
1663
+ },
1664
+ fragment: {
1665
+ header: `
1666
+ uniform sampler2D uTexture;
1667
+ uniform mat3 uMapCoord;
1668
+ uniform vec4 uClampFrame;
1669
+ uniform vec2 uClampOffset;
1670
+ `,
1671
+ main: `
1672
+
1673
+ vec2 coord = vUV + ceil(uClampOffset - vUV);
1674
+ coord = (uMapCoord * vec3(coord, 1.0)).xy;
1675
+ vec2 unclamped = coord;
1676
+ coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
1677
+
1678
+ outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
1679
+
1680
+ `
1681
+ }
1682
+ };
1683
+ let Y, j;
1684
+ class hr extends he {
1685
+ constructor() {
1686
+ Y != null || (Y = ze({
1687
+ name: "tiling-sprite-shader",
1688
+ bits: [
1689
+ Ot,
1690
+ ur,
1691
+ He
1692
+ ]
1693
+ })), j != null || (j = We({
1694
+ name: "tiling-sprite-shader",
1695
+ bits: [
1696
+ It,
1697
+ cr,
1698
+ De
1699
+ ]
1700
+ }));
1701
+ const e = new L({
1702
+ uMapCoord: { value: new P(), type: "mat3x3<f32>" },
1703
+ uClampFrame: { value: new Float32Array([0, 0, 1, 1]), type: "vec4<f32>" },
1704
+ uClampOffset: { value: new Float32Array([0, 0]), type: "vec2<f32>" },
1705
+ uTextureTransform: { value: new P(), type: "mat3x3<f32>" },
1706
+ uSizeAnchor: { value: new Float32Array([100, 100, 0.5, 0.5]), type: "vec4<f32>" }
1707
+ });
1708
+ super({
1709
+ glProgram: j,
1710
+ gpuProgram: Y,
1711
+ resources: {
1712
+ localUniforms: new L({
1713
+ uTransformMatrix: { value: new P(), type: "mat3x3<f32>" },
1714
+ uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
1715
+ uRound: { value: 0, type: "f32" }
1716
+ }),
1717
+ tilingUniforms: e,
1718
+ uTexture: R.EMPTY.source,
1719
+ uSampler: R.EMPTY.source.style
1720
+ }
1721
+ });
1722
+ }
1723
+ updateUniforms(e, t, r, i, s, a) {
1724
+ const o = this.resources.tilingUniforms, d = a.width, l = a.height, u = a.textureMatrix, c = o.uniforms.uTextureTransform;
1725
+ c.set(
1726
+ r.a * d / e,
1727
+ r.b * d / t,
1728
+ r.c * l / e,
1729
+ r.d * l / t,
1730
+ r.tx / e,
1731
+ r.ty / t
1732
+ ), c.invert(), o.uniforms.uMapCoord = u.mapCoord, o.uniforms.uClampFrame = u.uClampFrame, o.uniforms.uClampOffset = u.uClampOffset, o.uniforms.uTextureTransform = c, o.uniforms.uSizeAnchor[0] = e, o.uniforms.uSizeAnchor[1] = t, o.uniforms.uSizeAnchor[2] = i, o.uniforms.uSizeAnchor[3] = s, a && (this.resources.uTexture = a.source, this.resources.uSampler = a.source.style);
1733
+ }
1734
+ }
1735
+ class fr extends fe {
1736
+ constructor() {
1737
+ super({
1738
+ positions: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
1739
+ uvs: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
1740
+ indices: new Uint32Array([0, 1, 2, 0, 2, 3])
1741
+ });
1742
+ }
1743
+ }
1744
+ function pr(n, e) {
1745
+ const t = n.anchor.x, r = n.anchor.y;
1746
+ e[0] = -t * n.width, e[1] = -r * n.height, e[2] = (1 - t) * n.width, e[3] = -r * n.height, e[4] = (1 - t) * n.width, e[5] = (1 - r) * n.height, e[6] = -t * n.width, e[7] = (1 - r) * n.height;
1747
+ }
1748
+ function gr(n, e, t, r) {
1749
+ let i = 0;
1750
+ const s = n.length / (e || 2), a = r.a, o = r.b, d = r.c, l = r.d, u = r.tx, c = r.ty;
1751
+ for (t *= e; i < s; ) {
1752
+ const f = n[t], m = n[t + 1];
1753
+ n[t] = a * f + d * m + u, n[t + 1] = o * f + l * m + c, t += e, i++;
1754
+ }
1755
+ }
1756
+ function mr(n, e) {
1757
+ const t = n.texture, r = t.frame.width, i = t.frame.height;
1758
+ let s = 0, a = 0;
1759
+ n._applyAnchorToTexture && (s = n.anchor.x, a = n.anchor.y), e[0] = e[6] = -s, e[2] = e[4] = 1 - s, e[1] = e[3] = -a, e[5] = e[7] = 1 - a;
1760
+ const o = P.shared;
1761
+ o.copyFrom(n._tileTransform.matrix), o.tx /= n.width, o.ty /= n.height, o.invert(), o.scale(n.width / r, n.height / i), gr(e, 2, 0, o);
1762
+ }
1763
+ const J = new fr();
1764
+ class ct {
1765
+ constructor(e) {
1766
+ this._state = ee.default2d, this._tilingSpriteDataHash = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_tilingSpriteDataHash");
1767
+ }
1768
+ validateRenderable(e) {
1769
+ const t = this._getTilingSpriteData(e), r = t.canBatch;
1770
+ this._updateCanBatch(e);
1771
+ const i = t.canBatch;
1772
+ if (i && i === r) {
1773
+ const { batchableMesh: s } = t;
1774
+ if (s && s.texture._source !== e.texture._source)
1775
+ return !s._batcher.checkAndUpdateTexture(s, e.texture);
1776
+ }
1777
+ return r !== i;
1778
+ }
1779
+ addRenderable(e, t) {
1780
+ const r = this._renderer.renderPipes.batch;
1781
+ this._updateCanBatch(e);
1782
+ const i = this._getTilingSpriteData(e), { geometry: s, canBatch: a } = i;
1783
+ if (a) {
1784
+ i.batchableMesh || (i.batchableMesh = new ge());
1785
+ const o = i.batchableMesh;
1786
+ e.didViewUpdate && (this._updateBatchableMesh(e), o.geometry = s, o.renderable = e, o.transform = e.groupTransform, o.texture = e._texture), o.roundPixels = this._renderer._roundPixels | e._roundPixels, r.addToBatch(o, t);
1787
+ } else
1788
+ r.break(t), i.shader || (i.shader = new hr()), this.updateRenderable(e), t.add(e);
1789
+ }
1790
+ execute(e) {
1791
+ const { shader: t } = this._tilingSpriteDataHash[e.uid];
1792
+ t.groups[0] = this._renderer.globalUniforms.bindGroup;
1793
+ const r = t.resources.localUniforms.uniforms;
1794
+ r.uTransformMatrix = e.groupTransform, r.uRound = this._renderer._roundPixels | e._roundPixels, re(
1795
+ e.groupColorAlpha,
1796
+ r.uColor,
1797
+ 0
1798
+ ), this._state.blendMode = ce(e.groupBlendMode, e.texture._source), this._renderer.encoder.draw({
1799
+ geometry: J,
1800
+ shader: t,
1801
+ state: this._state
1802
+ });
1803
+ }
1804
+ updateRenderable(e) {
1805
+ const t = this._getTilingSpriteData(e), { canBatch: r } = t;
1806
+ if (r) {
1807
+ const { batchableMesh: i } = t;
1808
+ e.didViewUpdate && this._updateBatchableMesh(e), i._batcher.updateElement(i);
1809
+ } else if (e.didViewUpdate) {
1810
+ const { shader: i } = t;
1811
+ i.updateUniforms(
1812
+ e.width,
1813
+ e.height,
1814
+ e._tileTransform.matrix,
1815
+ e.anchor.x,
1816
+ e.anchor.y,
1817
+ e.texture
1818
+ );
1819
+ }
1820
+ }
1821
+ destroyRenderable(e) {
1822
+ var r;
1823
+ const t = this._getTilingSpriteData(e);
1824
+ t.batchableMesh = null, (r = t.shader) == null || r.destroy(), this._tilingSpriteDataHash[e.uid] = null, e.off("destroyed", this._destroyRenderableBound);
1825
+ }
1826
+ _getTilingSpriteData(e) {
1827
+ return this._tilingSpriteDataHash[e.uid] || this._initTilingSpriteData(e);
1828
+ }
1829
+ _initTilingSpriteData(e) {
1830
+ const t = new fe({
1831
+ indices: J.indices,
1832
+ positions: J.positions.slice(),
1833
+ uvs: J.uvs.slice()
1834
+ });
1835
+ return this._tilingSpriteDataHash[e.uid] = {
1836
+ canBatch: !0,
1837
+ renderable: e,
1838
+ geometry: t
1839
+ }, e.on("destroyed", this._destroyRenderableBound), this._tilingSpriteDataHash[e.uid];
1840
+ }
1841
+ _updateBatchableMesh(e) {
1842
+ const t = this._getTilingSpriteData(e), { geometry: r } = t, i = e.texture.source.style;
1843
+ i.addressMode !== "repeat" && (i.addressMode = "repeat", i.update()), mr(e, r.uvs), pr(e, r.positions);
1844
+ }
1845
+ destroy() {
1846
+ for (const e in this._tilingSpriteDataHash)
1847
+ this.destroyRenderable(this._tilingSpriteDataHash[e].renderable);
1848
+ this._tilingSpriteDataHash = null, this._renderer = null;
1849
+ }
1850
+ _updateCanBatch(e) {
1851
+ const t = this._getTilingSpriteData(e), r = e.texture;
1852
+ let i = !0;
1853
+ return this._renderer.type === ue.WEBGL && (i = this._renderer.context.supports.nonPowOf2wrapping), t.canBatch = r.textureMatrix.isSimple && (i || r.source.isPowerOfTwo), t.canBatch;
1854
+ }
1855
+ }
1856
+ ct.extension = {
1857
+ type: [
1858
+ _.WebGLPipes,
1859
+ _.WebGPUPipes,
1860
+ _.CanvasPipes
1861
+ ],
1862
+ name: "tilingSprite"
1863
+ };
1864
+ const xr = {
1865
+ name: "local-uniform-msdf-bit",
1866
+ vertex: {
1867
+ header: `
1868
+ struct LocalUniforms {
1869
+ uColor:vec4<f32>,
1870
+ uTransformMatrix:mat3x3<f32>,
1871
+ uDistance: f32,
1872
+ uRound:f32,
1873
+ }
1874
+
1875
+ @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
1876
+ `,
1877
+ main: `
1878
+ vColor *= localUniforms.uColor;
1879
+ modelMatrix *= localUniforms.uTransformMatrix;
1880
+ `,
1881
+ end: `
1882
+ if(localUniforms.uRound == 1)
1883
+ {
1884
+ vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
1885
+ }
1886
+ `
1887
+ },
1888
+ fragment: {
1889
+ header: `
1890
+ struct LocalUniforms {
1891
+ uColor:vec4<f32>,
1892
+ uTransformMatrix:mat3x3<f32>,
1893
+ uDistance: f32
1894
+ }
1895
+
1896
+ @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
1897
+ `,
1898
+ main: `
1899
+ outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
1900
+ `
1901
+ }
1902
+ }, _r = {
1903
+ name: "local-uniform-msdf-bit",
1904
+ vertex: {
1905
+ header: `
1906
+ uniform mat3 uTransformMatrix;
1907
+ uniform vec4 uColor;
1908
+ uniform float uRound;
1909
+ `,
1910
+ main: `
1911
+ vColor *= uColor;
1912
+ modelMatrix *= uTransformMatrix;
1913
+ `,
1914
+ end: `
1915
+ if(uRound == 1.)
1916
+ {
1917
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
1918
+ }
1919
+ `
1920
+ },
1921
+ fragment: {
1922
+ header: `
1923
+ uniform float uDistance;
1924
+ `,
1925
+ main: `
1926
+ outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
1927
+ `
1928
+ }
1929
+ }, br = {
1930
+ name: "msdf-bit",
1931
+ fragment: {
1932
+ header: `
1933
+ fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
1934
+
1935
+ // MSDF
1936
+ var median = msdfColor.r + msdfColor.g + msdfColor.b -
1937
+ min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
1938
+ max(msdfColor.r, max(msdfColor.g, msdfColor.b));
1939
+
1940
+ // SDF
1941
+ median = min(median, msdfColor.a);
1942
+
1943
+ var screenPxDistance = distance * (median - 0.5);
1944
+ var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
1945
+ if (median < 0.01) {
1946
+ alpha = 0.0;
1947
+ } else if (median > 0.99) {
1948
+ alpha = 1.0;
1949
+ }
1950
+
1951
+ // Gamma correction for coverage-like alpha
1952
+ var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
1953
+ var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
1954
+ var coverage: f32 = pow(shapeColor.a * alpha, gamma);
1955
+
1956
+ return coverage;
1957
+
1958
+ }
1959
+ `
1960
+ }
1961
+ }, yr = {
1962
+ name: "msdf-bit",
1963
+ fragment: {
1964
+ header: `
1965
+ float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
1966
+
1967
+ // MSDF
1968
+ float median = msdfColor.r + msdfColor.g + msdfColor.b -
1969
+ min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
1970
+ max(msdfColor.r, max(msdfColor.g, msdfColor.b));
1971
+
1972
+ // SDF
1973
+ median = min(median, msdfColor.a);
1974
+
1975
+ float screenPxDistance = distance * (median - 0.5);
1976
+ float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
1977
+
1978
+ if (median < 0.01) {
1979
+ alpha = 0.0;
1980
+ } else if (median > 0.99) {
1981
+ alpha = 1.0;
1982
+ }
1983
+
1984
+ // Gamma correction for coverage-like alpha
1985
+ float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
1986
+ float gamma = mix(1.0, 1.0 / 2.2, luma);
1987
+ float coverage = pow(shapeColor.a * alpha, gamma);
1988
+
1989
+ return coverage;
1990
+ }
1991
+ `
1992
+ }
1993
+ };
1994
+ let X, K;
1995
+ class vr extends he {
1996
+ constructor() {
1997
+ const e = new L({
1998
+ uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
1999
+ uTransformMatrix: { value: new P(), type: "mat3x3<f32>" },
2000
+ uDistance: { value: 4, type: "f32" },
2001
+ uRound: { value: 0, type: "f32" }
2002
+ }), t = Ut();
2003
+ X != null || (X = ze({
2004
+ name: "sdf-shader",
2005
+ bits: [
2006
+ At,
2007
+ kt(t),
2008
+ xr,
2009
+ br,
2010
+ He
2011
+ ]
2012
+ })), K != null || (K = We({
2013
+ name: "sdf-shader",
2014
+ bits: [
2015
+ Gt,
2016
+ zt(t),
2017
+ _r,
2018
+ yr,
2019
+ De
2020
+ ]
2021
+ })), super({
2022
+ glProgram: K,
2023
+ gpuProgram: X,
2024
+ resources: {
2025
+ localUniforms: e,
2026
+ batchSamplers: Ht(t)
2027
+ }
2028
+ });
2029
+ }
2030
+ }
2031
+ class ht {
2032
+ constructor(e) {
2033
+ this._gpuBitmapText = {}, this._destroyRenderableBound = this.destroyRenderable.bind(this), this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_gpuBitmapText");
2034
+ }
2035
+ validateRenderable(e) {
2036
+ const t = this._getGpuBitmapText(e);
2037
+ return e._didTextUpdate && (e._didTextUpdate = !1, this._updateContext(e, t)), this._renderer.renderPipes.graphics.validateRenderable(t);
2038
+ }
2039
+ addRenderable(e, t) {
2040
+ const r = this._getGpuBitmapText(e);
2041
+ Me(e, r), e._didTextUpdate && (e._didTextUpdate = !1, this._updateContext(e, r)), this._renderer.renderPipes.graphics.addRenderable(r, t), r.context.customShader && this._updateDistanceField(e);
2042
+ }
2043
+ destroyRenderable(e) {
2044
+ e.off("destroyed", this._destroyRenderableBound), this._destroyRenderableByUid(e.uid);
2045
+ }
2046
+ _destroyRenderableByUid(e) {
2047
+ const t = this._gpuBitmapText[e].context;
2048
+ t.customShader && (T.return(t.customShader), t.customShader = null), T.return(this._gpuBitmapText[e]), this._gpuBitmapText[e] = null;
2049
+ }
2050
+ updateRenderable(e) {
2051
+ const t = this._getGpuBitmapText(e);
2052
+ Me(e, t), this._renderer.renderPipes.graphics.updateRenderable(t), t.context.customShader && this._updateDistanceField(e);
2053
+ }
2054
+ _updateContext(e, t) {
2055
+ const { context: r } = t, i = jt.getFont(e.text, e._style);
2056
+ r.clear(), i.distanceField.type !== "none" && (r.customShader || (r.customShader = T.get(vr)));
2057
+ const s = Array.from(e.text), a = e._style;
2058
+ let o = i.baseLineOffset;
2059
+ const d = je(s, a, i, !0);
2060
+ let l = 0;
2061
+ const u = a.padding, c = d.scale;
2062
+ let f = d.width, m = d.height + d.offsetY;
2063
+ a._stroke && (f += a._stroke.width / c, m += a._stroke.width / c), r.translate(-e._anchor._x * f - u, -e._anchor._y * m - u).scale(c, c);
2064
+ const g = i.applyFillAsTint ? a._fill.color : 16777215;
2065
+ for (let h = 0; h < d.lines.length; h++) {
2066
+ const p = d.lines[h];
2067
+ for (let x = 0; x < p.charPositions.length; x++) {
2068
+ const v = s[l++], b = i.chars[v];
2069
+ b != null && b.texture && r.texture(
2070
+ b.texture,
2071
+ g || "black",
2072
+ Math.round(p.charPositions[x] + b.xOffset),
2073
+ Math.round(o + b.yOffset)
2074
+ );
2075
+ }
2076
+ o += i.lineHeight;
2077
+ }
2078
+ }
2079
+ _getGpuBitmapText(e) {
2080
+ return this._gpuBitmapText[e.uid] || this.initGpuText(e);
2081
+ }
2082
+ initGpuText(e) {
2083
+ const t = T.get(Wt);
2084
+ return this._gpuBitmapText[e.uid] = t, this._updateContext(e, t), e.on("destroyed", this._destroyRenderableBound), this._gpuBitmapText[e.uid];
2085
+ }
2086
+ _updateDistanceField(e) {
2087
+ const t = this._getGpuBitmapText(e).context, r = e._style.fontFamily, i = F.get(`${r}-bitmap`), { a: s, b: a, c: o, d } = e.groupTransform, l = Math.sqrt(s * s + a * a), u = Math.sqrt(o * o + d * d), c = (Math.abs(l) + Math.abs(u)) / 2, f = i.baseRenderedFontSize / e._style.fontSize, m = c * i.distanceField.range * (1 / f);
2088
+ t.customShader.resources.localUniforms.uniforms.uDistance = m;
2089
+ }
2090
+ destroy() {
2091
+ for (const e in this._gpuBitmapText)
2092
+ this._destroyRenderableByUid(e);
2093
+ this._gpuBitmapText = null, this._renderer = null;
2094
+ }
2095
+ }
2096
+ ht.extension = {
2097
+ type: [
2098
+ _.WebGLPipes,
2099
+ _.WebGPUPipes,
2100
+ _.CanvasPipes
2101
+ ],
2102
+ name: "bitmapText"
2103
+ };
2104
+ function Me(n, e) {
2105
+ e.groupTransform = n.groupTransform, e.groupColorAlpha = n.groupColorAlpha, e.groupColor = n.groupColor, e.groupBlendMode = n.groupBlendMode, e.globalDisplayStatus = n.globalDisplayStatus, e.groupTransform = n.groupTransform, e.localDisplayStatus = n.localDisplayStatus, e.groupAlpha = n.groupAlpha, e._roundPixels = n._roundPixels;
2106
+ }
2107
+ class ft {
2108
+ constructor(e) {
2109
+ this._gpuText = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this._renderer = e, this._renderer.runners.resolutionChange.add(this), this._renderer.renderableGC.addManagedHash(this, "_gpuText");
2110
+ }
2111
+ resolutionChange() {
2112
+ for (const e in this._gpuText) {
2113
+ const t = this._gpuText[e];
2114
+ if (!t)
2115
+ continue;
2116
+ const r = t.batchableSprite.renderable;
2117
+ r._autoResolution && (r._resolution = this._renderer.resolution, r.onViewUpdate());
2118
+ }
2119
+ }
2120
+ validateRenderable(e) {
2121
+ const t = this._getGpuText(e), r = e._getKey();
2122
+ return t.textureNeedsUploading ? (t.textureNeedsUploading = !1, !0) : t.currentKey !== r;
2123
+ }
2124
+ addRenderable(e, t) {
2125
+ const i = this._getGpuText(e).batchableSprite;
2126
+ e._didTextUpdate && this._updateText(e), this._renderer.renderPipes.batch.addToBatch(i, t);
2127
+ }
2128
+ updateRenderable(e) {
2129
+ const r = this._getGpuText(e).batchableSprite;
2130
+ e._didTextUpdate && this._updateText(e), r._batcher.updateElement(r);
2131
+ }
2132
+ destroyRenderable(e) {
2133
+ e.off("destroyed", this._destroyRenderableBound), this._destroyRenderableById(e.uid);
2134
+ }
2135
+ _destroyRenderableById(e) {
2136
+ const t = this._gpuText[e];
2137
+ this._renderer.htmlText.decreaseReferenceCount(t.currentKey), T.return(t.batchableSprite), this._gpuText[e] = null;
2138
+ }
2139
+ _updateText(e) {
2140
+ const t = e._getKey(), r = this._getGpuText(e), i = r.batchableSprite;
2141
+ r.currentKey !== t && this._updateGpuText(e).catch((a) => {
2142
+ console.error(a);
2143
+ }), e._didTextUpdate = !1;
2144
+ const s = e._style.padding;
2145
+ de(i.bounds, e._anchor, i.texture, s);
2146
+ }
2147
+ async _updateGpuText(e) {
2148
+ var d;
2149
+ e._didTextUpdate = !1;
2150
+ const t = this._getGpuText(e);
2151
+ if (t.generatingTexture)
2152
+ return;
2153
+ const r = e._getKey();
2154
+ this._renderer.htmlText.decreaseReferenceCount(t.currentKey), t.generatingTexture = !0, t.currentKey = r;
2155
+ const i = (d = e.resolution) != null ? d : this._renderer.resolution, s = await this._renderer.htmlText.getManagedTexture(
2156
+ e.text,
2157
+ i,
2158
+ e._style,
2159
+ e._getKey()
2160
+ ), a = t.batchableSprite;
2161
+ a.texture = t.texture = s, t.generatingTexture = !1, t.textureNeedsUploading = !0, e.onViewUpdate();
2162
+ const o = e._style.padding;
2163
+ de(a.bounds, e._anchor, a.texture, o);
2164
+ }
2165
+ _getGpuText(e) {
2166
+ return this._gpuText[e.uid] || this.initGpuText(e);
2167
+ }
2168
+ initGpuText(e) {
2169
+ const t = {
2170
+ texture: R.EMPTY,
2171
+ currentKey: "--",
2172
+ batchableSprite: T.get(Ie),
2173
+ textureNeedsUploading: !1,
2174
+ generatingTexture: !1
2175
+ }, r = t.batchableSprite;
2176
+ return r.renderable = e, r.transform = e.groupTransform, r.texture = R.EMPTY, r.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, r.roundPixels = this._renderer._roundPixels | e._roundPixels, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, this._gpuText[e.uid] = t, e.on("destroyed", this._destroyRenderableBound), t;
2177
+ }
2178
+ destroy() {
2179
+ for (const e in this._gpuText)
2180
+ this._destroyRenderableById(e);
2181
+ this._gpuText = null, this._renderer = null;
2182
+ }
2183
+ }
2184
+ ft.extension = {
2185
+ type: [
2186
+ _.WebGLPipes,
2187
+ _.WebGPUPipes,
2188
+ _.CanvasPipes
2189
+ ],
2190
+ name: "htmlText"
2191
+ };
2192
+ function Tr() {
2193
+ const { userAgent: n } = Oe.get().getNavigator();
2194
+ return /^((?!chrome|android).)*safari/i.test(n);
2195
+ }
2196
+ const wr = new Ge();
2197
+ function pt(n, e, t, r) {
2198
+ const i = wr;
2199
+ i.minX = 0, i.minY = 0, i.maxX = n.width / r | 0, i.maxY = n.height / r | 0;
2200
+ const s = U.getOptimalTexture(
2201
+ i.width,
2202
+ i.height,
2203
+ r,
2204
+ !1
2205
+ );
2206
+ return s.source.uploadMethodId = "image", s.source.resource = n, s.source.alphaMode = "premultiply-alpha-on-upload", s.frame.width = e / r, s.frame.height = t / r, s.source.emit("update", s.source), s.updateUvs(), s;
2207
+ }
2208
+ function Sr(n, e) {
2209
+ const t = e.fontFamily, r = [], i = {}, s = /font-family:([^;"\s]+)/g, a = n.match(s);
2210
+ function o(d) {
2211
+ i[d] || (r.push(d), i[d] = !0);
2212
+ }
2213
+ if (Array.isArray(t))
2214
+ for (let d = 0; d < t.length; d++)
2215
+ o(t[d]);
2216
+ else
2217
+ o(t);
2218
+ a && a.forEach((d) => {
2219
+ const l = d.split(":")[1].trim();
2220
+ o(l);
2221
+ });
2222
+ for (const d in e.tagStyles) {
2223
+ const l = e.tagStyles[d].fontFamily;
2224
+ o(l);
2225
+ }
2226
+ return r;
2227
+ }
2228
+ async function Br(n) {
2229
+ const t = await (await Oe.get().fetch(n)).blob(), r = new FileReader();
2230
+ return await new Promise((s, a) => {
2231
+ r.onloadend = () => s(r.result), r.onerror = a, r.readAsDataURL(t);
2232
+ });
2233
+ }
2234
+ async function Fe(n, e) {
2235
+ const t = await Br(e);
2236
+ return `@font-face {
2237
+ font-family: "${n.fontFamily}";
2238
+ src: url('${t}');
2239
+ font-weight: ${n.fontWeight};
2240
+ font-style: ${n.fontStyle};
2241
+ }`;
2242
+ }
2243
+ const Z = /* @__PURE__ */ new Map();
2244
+ async function Cr(n, e, t) {
2245
+ const r = n.filter((i) => F.has(`${i}-and-url`)).map((i, s) => {
2246
+ if (!Z.has(i)) {
2247
+ const { url: a } = F.get(`${i}-and-url`);
2248
+ s === 0 ? Z.set(i, Fe({
2249
+ fontWeight: e.fontWeight,
2250
+ fontStyle: e.fontStyle,
2251
+ fontFamily: i
2252
+ }, a)) : Z.set(i, Fe({
2253
+ fontWeight: t.fontWeight,
2254
+ fontStyle: t.fontStyle,
2255
+ fontFamily: i
2256
+ }, a));
2257
+ }
2258
+ return Z.get(i);
2259
+ });
2260
+ return (await Promise.all(r)).join(`
2261
+ `);
2262
+ }
2263
+ function Pr(n, e, t, r, i) {
2264
+ const { domElement: s, styleElement: a, svgRoot: o } = i;
2265
+ s.innerHTML = `<style>${e.cssStyle}</style><div style='padding:0;'>${n}</div>`, s.setAttribute("style", `transform: scale(${t});transform-origin: top left; display: inline-block`), a.textContent = r;
2266
+ const { width: d, height: l } = i.image;
2267
+ return o.setAttribute("width", d.toString()), o.setAttribute("height", l.toString()), new XMLSerializer().serializeToString(o);
2268
+ }
2269
+ function Rr(n, e) {
2270
+ const t = I.getOptimalCanvasAndContext(
2271
+ n.width,
2272
+ n.height,
2273
+ e
2274
+ ), { context: r } = t;
2275
+ return r.clearRect(0, 0, n.width, n.height), r.drawImage(n, 0, 0), t;
2276
+ }
2277
+ function Mr(n, e, t) {
2278
+ return new Promise(async (r) => {
2279
+ t && await new Promise((i) => setTimeout(i, 100)), n.onload = () => {
2280
+ r();
2281
+ }, n.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`, n.crossOrigin = "anonymous";
2282
+ });
2283
+ }
2284
+ class me {
2285
+ constructor(e) {
2286
+ this._activeTextures = {}, this._renderer = e, this._createCanvas = e.type === ue.WEBGPU;
2287
+ }
2288
+ getTexture(e) {
2289
+ return this._buildTexturePromise(
2290
+ e.text,
2291
+ e.resolution,
2292
+ e.style
2293
+ );
2294
+ }
2295
+ getManagedTexture(e, t, r, i) {
2296
+ if (this._activeTextures[i])
2297
+ return this._increaseReferenceCount(i), this._activeTextures[i].promise;
2298
+ const s = this._buildTexturePromise(e, t, r).then((a) => (this._activeTextures[i].texture = a, a));
2299
+ return this._activeTextures[i] = {
2300
+ texture: null,
2301
+ promise: s,
2302
+ usageCount: 1
2303
+ }, s;
2304
+ }
2305
+ async _buildTexturePromise(e, t, r) {
2306
+ const i = T.get(et), s = Sr(e, r), a = await Cr(
2307
+ s,
2308
+ r,
2309
+ pe.defaultTextStyle
2310
+ ), o = Zt(e, r, a, i), d = Math.ceil(Math.ceil(Math.max(1, o.width) + r.padding * 2) * t), l = Math.ceil(Math.ceil(Math.max(1, o.height) + r.padding * 2) * t), u = i.image, c = 2;
2311
+ u.width = (d | 0) + c, u.height = (l | 0) + c;
2312
+ const f = Pr(e, r, t, a, i);
2313
+ await Mr(u, f, Tr() && s.length > 0);
2314
+ const m = u;
2315
+ let g;
2316
+ this._createCanvas && (g = Rr(u, t));
2317
+ const h = pt(
2318
+ g ? g.canvas : m,
2319
+ u.width - c,
2320
+ u.height - c,
2321
+ t
2322
+ );
2323
+ return this._createCanvas && (this._renderer.texture.initSource(h.source), I.returnCanvasAndContext(g)), T.return(i), h;
2324
+ }
2325
+ _increaseReferenceCount(e) {
2326
+ this._activeTextures[e].usageCount++;
2327
+ }
2328
+ decreaseReferenceCount(e) {
2329
+ const t = this._activeTextures[e];
2330
+ !t || (t.usageCount--, t.usageCount === 0 && (t.texture ? this._cleanUp(t) : t.promise.then((r) => {
2331
+ t.texture = r, this._cleanUp(t);
2332
+ }).catch(() => {
2333
+ E("HTMLTextSystem: Failed to clean texture");
2334
+ }), this._activeTextures[e] = null));
2335
+ }
2336
+ _cleanUp(e) {
2337
+ U.returnTexture(e.texture), e.texture.source.resource = null, e.texture.source.uploadMethodId = "unknown";
2338
+ }
2339
+ getReferenceCount(e) {
2340
+ return this._activeTextures[e].usageCount;
2341
+ }
2342
+ destroy() {
2343
+ this._activeTextures = null;
2344
+ }
2345
+ }
2346
+ me.extension = {
2347
+ type: [
2348
+ _.WebGLSystem,
2349
+ _.WebGPUSystem,
2350
+ _.CanvasSystem
2351
+ ],
2352
+ name: "htmlText"
2353
+ };
2354
+ me.defaultFontOptions = {
2355
+ fontFamily: "Arial",
2356
+ fontStyle: "normal",
2357
+ fontWeight: "normal"
2358
+ };
2359
+ class gt {
2360
+ constructor(e) {
2361
+ this._gpuText = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this._renderer = e, this._renderer.runners.resolutionChange.add(this), this._renderer.renderableGC.addManagedHash(this, "_gpuText");
2362
+ }
2363
+ resolutionChange() {
2364
+ for (const e in this._gpuText) {
2365
+ const t = this._gpuText[e];
2366
+ if (!t)
2367
+ continue;
2368
+ const r = t.batchableSprite.renderable;
2369
+ r._autoResolution && (r._resolution = this._renderer.resolution, r.onViewUpdate());
2370
+ }
2371
+ }
2372
+ validateRenderable(e) {
2373
+ const t = this._getGpuText(e), r = e._getKey();
2374
+ return t.currentKey !== r;
2375
+ }
2376
+ addRenderable(e, t) {
2377
+ const i = this._getGpuText(e).batchableSprite;
2378
+ e._didTextUpdate && this._updateText(e), this._renderer.renderPipes.batch.addToBatch(i, t);
2379
+ }
2380
+ updateRenderable(e) {
2381
+ const r = this._getGpuText(e).batchableSprite;
2382
+ e._didTextUpdate && this._updateText(e), r._batcher.updateElement(r);
2383
+ }
2384
+ destroyRenderable(e) {
2385
+ e.off("destroyed", this._destroyRenderableBound), this._destroyRenderableById(e.uid);
2386
+ }
2387
+ _destroyRenderableById(e) {
2388
+ const t = this._gpuText[e];
2389
+ this._renderer.canvasText.decreaseReferenceCount(t.currentKey), T.return(t.batchableSprite), this._gpuText[e] = null;
2390
+ }
2391
+ _updateText(e) {
2392
+ const t = e._getKey(), r = this._getGpuText(e), i = r.batchableSprite;
2393
+ r.currentKey !== t && this._updateGpuText(e), e._didTextUpdate = !1;
2394
+ const s = e._style.padding;
2395
+ de(i.bounds, e._anchor, i.texture, s);
2396
+ }
2397
+ _updateGpuText(e) {
2398
+ const t = this._getGpuText(e), r = t.batchableSprite;
2399
+ t.texture && this._renderer.canvasText.decreaseReferenceCount(t.currentKey), t.texture = r.texture = this._renderer.canvasText.getManagedTexture(e), t.currentKey = e._getKey(), r.texture = t.texture;
2400
+ }
2401
+ _getGpuText(e) {
2402
+ return this._gpuText[e.uid] || this.initGpuText(e);
2403
+ }
2404
+ initGpuText(e) {
2405
+ const t = {
2406
+ texture: null,
2407
+ currentKey: "--",
2408
+ batchableSprite: T.get(Ie)
2409
+ };
2410
+ return t.batchableSprite.renderable = e, t.batchableSprite.transform = e.groupTransform, t.batchableSprite.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 }, t.batchableSprite.roundPixels = this._renderer._roundPixels | e._roundPixels, this._gpuText[e.uid] = t, e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution, this._updateText(e), e.on("destroyed", this._destroyRenderableBound), t;
2411
+ }
2412
+ destroy() {
2413
+ for (const e in this._gpuText)
2414
+ this._destroyRenderableById(e);
2415
+ this._gpuText = null, this._renderer = null;
2416
+ }
2417
+ }
2418
+ gt.extension = {
2419
+ type: [
2420
+ _.WebGLPipes,
2421
+ _.WebGPUPipes,
2422
+ _.CanvasPipes
2423
+ ],
2424
+ name: "text"
2425
+ };
2426
+ function Ue(n, e, t) {
2427
+ for (let r = 0, i = 4 * t * e; r < e; ++r, i += 4)
2428
+ if (n[i + 3] !== 0)
2429
+ return !1;
2430
+ return !0;
2431
+ }
2432
+ function Ae(n, e, t, r, i) {
2433
+ const s = 4 * e;
2434
+ for (let a = r, o = r * s + 4 * t; a <= i; ++a, o += s)
2435
+ if (n[o + 3] !== 0)
2436
+ return !1;
2437
+ return !0;
2438
+ }
2439
+ function Fr(n, e = 1) {
2440
+ const { width: t, height: r } = n, i = n.getContext("2d", {
2441
+ willReadFrequently: !0
2442
+ });
2443
+ if (i === null)
2444
+ throw new TypeError("Failed to get canvas 2D context");
2445
+ const a = i.getImageData(0, 0, t, r).data;
2446
+ let o = 0, d = 0, l = t - 1, u = r - 1;
2447
+ for (; d < r && Ue(a, t, d); )
2448
+ ++d;
2449
+ if (d === r)
2450
+ return ae.EMPTY;
2451
+ for (; Ue(a, t, u); )
2452
+ --u;
2453
+ for (; Ae(a, t, o, d, u); )
2454
+ ++o;
2455
+ for (; Ae(a, t, l, d, u); )
2456
+ --l;
2457
+ return ++l, ++u, new ae(o / e, d / e, (l - o) / e, (u - d) / e);
2458
+ }
2459
+ class mt {
2460
+ constructor(e) {
2461
+ this._activeTextures = {}, this._renderer = e;
2462
+ }
2463
+ getTextureSize(e, t, r) {
2464
+ const i = D.measureText(e || " ", r);
2465
+ let s = Math.ceil(Math.ceil(Math.max(1, i.width) + r.padding * 2) * t), a = Math.ceil(Math.ceil(Math.max(1, i.height) + r.padding * 2) * t);
2466
+ return s = Math.ceil(s - 1e-6), a = Math.ceil(a - 1e-6), s = be(s), a = be(a), { width: s, height: a };
2467
+ }
2468
+ getTexture(e, t, r, i) {
2469
+ typeof e == "string" && (k("8.0.0", "CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"), e = {
2470
+ text: e,
2471
+ style: r,
2472
+ resolution: t
2473
+ }), e.style instanceof V || (e.style = new V(e.style));
2474
+ const { texture: s, canvasAndContext: a } = this.createTextureAndCanvas(
2475
+ e
2476
+ );
2477
+ return this._renderer.texture.initSource(s._source), I.returnCanvasAndContext(a), s;
2478
+ }
2479
+ createTextureAndCanvas(e) {
2480
+ var c;
2481
+ const { text: t, style: r } = e, i = (c = e.resolution) != null ? c : this._renderer.resolution, s = D.measureText(t || " ", r), a = Math.ceil(Math.ceil(Math.max(1, s.width) + r.padding * 2) * i), o = Math.ceil(Math.ceil(Math.max(1, s.height) + r.padding * 2) * i), d = I.getOptimalCanvasAndContext(a, o), { canvas: l } = d;
2482
+ this.renderTextToCanvas(t, r, i, d);
2483
+ const u = pt(l, a, o, i);
2484
+ if (r.trim) {
2485
+ const f = Fr(l, i);
2486
+ u.frame.copyFrom(f), u.updateUvs();
2487
+ }
2488
+ return { texture: u, canvasAndContext: d };
2489
+ }
2490
+ getManagedTexture(e) {
2491
+ e._resolution = e._autoResolution ? this._renderer.resolution : e.resolution;
2492
+ const t = e._getKey();
2493
+ if (this._activeTextures[t])
2494
+ return this._increaseReferenceCount(t), this._activeTextures[t].texture;
2495
+ const { texture: r, canvasAndContext: i } = this.createTextureAndCanvas(e);
2496
+ return this._activeTextures[t] = {
2497
+ canvasAndContext: i,
2498
+ texture: r,
2499
+ usageCount: 1
2500
+ }, r;
2501
+ }
2502
+ _increaseReferenceCount(e) {
2503
+ this._activeTextures[e].usageCount++;
2504
+ }
2505
+ decreaseReferenceCount(e) {
2506
+ const t = this._activeTextures[e];
2507
+ if (t.usageCount--, t.usageCount === 0) {
2508
+ I.returnCanvasAndContext(t.canvasAndContext), U.returnTexture(t.texture);
2509
+ const r = t.texture.source;
2510
+ r.resource = null, r.uploadMethodId = "unknown", r.alphaMode = "no-premultiply-alpha", this._activeTextures[e] = null;
2511
+ }
2512
+ }
2513
+ getReferenceCount(e) {
2514
+ return this._activeTextures[e].usageCount;
2515
+ }
2516
+ renderTextToCanvas(e, t, r, i) {
2517
+ var v, b, y, C, W;
2518
+ const { canvas: s, context: a } = i, o = ne(t), d = D.measureText(e || " ", t), l = d.lines, u = d.lineHeight, c = d.lineWidths, f = d.maxLineWidth, m = d.fontProperties, g = s.height;
2519
+ if (a.resetTransform(), a.scale(r, r), a.textBaseline = t.textBaseline, (v = t._stroke) != null && v.width) {
2520
+ const B = t._stroke;
2521
+ a.lineWidth = B.width, a.miterLimit = B.miterLimit, a.lineJoin = B.join, a.lineCap = B.cap;
2522
+ }
2523
+ a.font = o;
2524
+ let h, p;
2525
+ const x = t.dropShadow ? 2 : 1;
2526
+ for (let B = 0; B < x; ++B) {
2527
+ const M = t.dropShadow && B === 0, O = M ? Math.ceil(Math.max(1, g) + t.padding * 2) : 0, ie = O * r;
2528
+ if (M) {
2529
+ a.fillStyle = "black", a.strokeStyle = "black";
2530
+ const w = t.dropShadow, xt = w.color, _t = w.alpha;
2531
+ a.shadowColor = G.shared.setValue(xt).setAlpha(_t).toRgbaString();
2532
+ const bt = w.blur * r, xe = w.distance * r;
2533
+ a.shadowBlur = bt, a.shadowOffsetX = Math.cos(w.angle) * xe, a.shadowOffsetY = Math.sin(w.angle) * xe + ie;
2534
+ } else
2535
+ a.fillStyle = t._fill ? te(t._fill, a) : null, (b = t._stroke) != null && b.width && (a.strokeStyle = te(t._stroke, a)), a.shadowColor = "black";
2536
+ let z = (u - m.fontSize) / 2;
2537
+ u - m.fontSize < 0 && (z = 0);
2538
+ const $ = (C = (y = t._stroke) == null ? void 0 : y.width) != null ? C : 0;
2539
+ for (let w = 0; w < l.length; w++)
2540
+ h = $ / 2, p = $ / 2 + w * u + m.ascent + z, t.align === "right" ? h += f - c[w] : t.align === "center" && (h += (f - c[w]) / 2), (W = t._stroke) != null && W.width && this._drawLetterSpacing(
2541
+ l[w],
2542
+ t,
2543
+ i,
2544
+ h + t.padding,
2545
+ p + t.padding - O,
2546
+ !0
2547
+ ), t._fill !== void 0 && this._drawLetterSpacing(
2548
+ l[w],
2549
+ t,
2550
+ i,
2551
+ h + t.padding,
2552
+ p + t.padding - O
2553
+ );
2554
+ }
2555
+ }
2556
+ _drawLetterSpacing(e, t, r, i, s, a = !1) {
2557
+ const { context: o } = r, d = t.letterSpacing;
2558
+ let l = !1;
2559
+ if (D.experimentalLetterSpacingSupported && (D.experimentalLetterSpacing ? (o.letterSpacing = `${d}px`, o.textLetterSpacing = `${d}px`, l = !0) : (o.letterSpacing = "0px", o.textLetterSpacing = "0px")), d === 0 || l) {
2560
+ a ? o.strokeText(e, i, s) : o.fillText(e, i, s);
2561
+ return;
2562
+ }
2563
+ let u = i;
2564
+ const c = D.graphemeSegmenter(e);
2565
+ let f = o.measureText(e).width, m = 0;
2566
+ for (let g = 0; g < c.length; ++g) {
2567
+ const h = c[g];
2568
+ a ? o.strokeText(h, u, s) : o.fillText(h, u, s);
2569
+ let p = "";
2570
+ for (let x = g + 1; x < c.length; ++x)
2571
+ p += c[x];
2572
+ m = o.measureText(p).width, u += f - m + d, f = m;
2573
+ }
2574
+ }
2575
+ destroy() {
2576
+ this._activeTextures = null;
2577
+ }
2578
+ }
2579
+ mt.extension = {
2580
+ type: [
2581
+ _.WebGLSystem,
2582
+ _.WebGPUSystem,
2583
+ _.CanvasSystem
2584
+ ],
2585
+ name: "canvasText"
2586
+ };
2587
+ S.add(Ee);
2588
+ S.add(Ve);
2589
+ S.add(tt);
2590
+ S.add(Dt);
2591
+ S.add(st);
2592
+ S.add(at);
2593
+ S.add(ot);
2594
+ S.add(mt);
2595
+ S.add(gt);
2596
+ S.add(ht);
2597
+ S.add(me);
2598
+ S.add(ft);
2599
+ S.add(ct);
2600
+ S.add(ut);
2601
+ S.add(Ne);
2602
+ S.add(Xe);