@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,1905 @@
1
+ import { ab as Re, ac as Be, l as X, M as v, D as Ue, A as Ae, E as u, e as R, ad as Q, S as Ie, o as Z, t as b, ae as Ee, m as L, n as B, af as ee, ag as De, b as m, a5 as p, a7 as w, w as te, y as W, ah as Fe, p as z, q as y, R as G, ai as Oe, a8 as V, aj as He, ak as j, a9 as re, a as Le, al as C, C as T, am as se, an as ne, ao as ae, c as ie, ap as We, P as ze, B as Ve, T as N, a0 as je, aq as $, ar as Ne, as as $e } from "./index.a01cfc5f.js";
2
+ import { B as qe, c as Ke } from "./colorToUniform.7c604fe6.js";
3
+ var Ye = `in vec2 vMaskCoord;
4
+ in vec2 vTextureCoord;
5
+
6
+ uniform sampler2D uTexture;
7
+ uniform sampler2D uMaskTexture;
8
+
9
+ uniform float uAlpha;
10
+ uniform vec4 uMaskClamp;
11
+ uniform float uInverse;
12
+
13
+ out vec4 finalColor;
14
+
15
+ void main(void)
16
+ {
17
+ float clip = step(3.5,
18
+ step(uMaskClamp.x, vMaskCoord.x) +
19
+ step(uMaskClamp.y, vMaskCoord.y) +
20
+ step(vMaskCoord.x, uMaskClamp.z) +
21
+ step(vMaskCoord.y, uMaskClamp.w));
22
+
23
+ // TODO look into why this is needed
24
+ float npmAlpha = uAlpha;
25
+ vec4 original = texture(uTexture, vTextureCoord);
26
+ vec4 masky = texture(uMaskTexture, vMaskCoord);
27
+ float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
28
+
29
+ float a = alphaMul * masky.r * npmAlpha * clip;
30
+
31
+ if (uInverse == 1.0) {
32
+ a = 1.0 - a;
33
+ }
34
+
35
+ finalColor = original * a;
36
+ }
37
+ `, Je = `in vec2 aPosition;
38
+
39
+ out vec2 vTextureCoord;
40
+ out vec2 vMaskCoord;
41
+
42
+
43
+ uniform vec4 uInputSize;
44
+ uniform vec4 uOutputFrame;
45
+ uniform vec4 uOutputTexture;
46
+ uniform mat3 uFilterMatrix;
47
+
48
+ vec4 filterVertexPosition( vec2 aPosition )
49
+ {
50
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
51
+
52
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
53
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
54
+
55
+ return vec4(position, 0.0, 1.0);
56
+ }
57
+
58
+ vec2 filterTextureCoord( vec2 aPosition )
59
+ {
60
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
61
+ }
62
+
63
+ vec2 getFilterCoord( vec2 aPosition )
64
+ {
65
+ return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
66
+ }
67
+
68
+ void main(void)
69
+ {
70
+ gl_Position = filterVertexPosition(aPosition);
71
+ vTextureCoord = filterTextureCoord(aPosition);
72
+ vMaskCoord = getFilterCoord(aPosition);
73
+ }
74
+ `, q = `struct GlobalFilterUniforms {
75
+ uInputSize:vec4<f32>,
76
+ uInputPixel:vec4<f32>,
77
+ uInputClamp:vec4<f32>,
78
+ uOutputFrame:vec4<f32>,
79
+ uGlobalFrame:vec4<f32>,
80
+ uOutputTexture:vec4<f32>,
81
+ };
82
+
83
+ struct MaskUniforms {
84
+ uFilterMatrix:mat3x3<f32>,
85
+ uMaskClamp:vec4<f32>,
86
+ uAlpha:f32,
87
+ uInverse:f32,
88
+ };
89
+
90
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
91
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
92
+ @group(0) @binding(2) var uSampler : sampler;
93
+
94
+ @group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
95
+ @group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
96
+
97
+ struct VSOutput {
98
+ @builtin(position) position: vec4<f32>,
99
+ @location(0) uv : vec2<f32>,
100
+ @location(1) filterUv : vec2<f32>,
101
+ };
102
+
103
+ fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
104
+ {
105
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
106
+
107
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
108
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
109
+
110
+ return vec4(position, 0.0, 1.0);
111
+ }
112
+
113
+ fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
114
+ {
115
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
116
+ }
117
+
118
+ fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
119
+ {
120
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
121
+ }
122
+
123
+ fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
124
+ {
125
+ return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
126
+ }
127
+
128
+ fn getSize() -> vec2<f32>
129
+ {
130
+ return gfu.uGlobalFrame.zw;
131
+ }
132
+
133
+ @vertex
134
+ fn mainVertex(
135
+ @location(0) aPosition : vec2<f32>,
136
+ ) -> VSOutput {
137
+ return VSOutput(
138
+ filterVertexPosition(aPosition),
139
+ filterTextureCoord(aPosition),
140
+ getFilterCoord(aPosition)
141
+ );
142
+ }
143
+
144
+ @fragment
145
+ fn mainFragment(
146
+ @location(0) uv: vec2<f32>,
147
+ @location(1) filterUv: vec2<f32>,
148
+ @builtin(position) position: vec4<f32>
149
+ ) -> @location(0) vec4<f32> {
150
+
151
+ var maskClamp = filterUniforms.uMaskClamp;
152
+ var uAlpha = filterUniforms.uAlpha;
153
+
154
+ var clip = step(3.5,
155
+ step(maskClamp.x, filterUv.x) +
156
+ step(maskClamp.y, filterUv.y) +
157
+ step(filterUv.x, maskClamp.z) +
158
+ step(filterUv.y, maskClamp.w));
159
+
160
+ var mask = textureSample(uMaskTexture, uSampler, filterUv);
161
+ var source = textureSample(uTexture, uSampler, uv);
162
+ var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
163
+
164
+ var a: f32 = alphaMul * mask.r * uAlpha * clip;
165
+
166
+ if (filterUniforms.uInverse == 1.0) {
167
+ a = 1.0 - a;
168
+ }
169
+
170
+ return source * a;
171
+ }
172
+ `;
173
+ class Xe extends Re {
174
+ constructor(e) {
175
+ const { sprite: t, ...r } = e, n = new Be(t.texture), a = new X({
176
+ uFilterMatrix: { value: new v(), type: "mat3x3<f32>" },
177
+ uMaskClamp: { value: n.uClampFrame, type: "vec4<f32>" },
178
+ uAlpha: { value: 1, type: "f32" },
179
+ uInverse: { value: e.inverse ? 1 : 0, type: "f32" }
180
+ }), i = Ue.from({
181
+ vertex: {
182
+ source: q,
183
+ entryPoint: "mainVertex"
184
+ },
185
+ fragment: {
186
+ source: q,
187
+ entryPoint: "mainFragment"
188
+ }
189
+ }), l = Ae.from({
190
+ vertex: Je,
191
+ fragment: Ye,
192
+ name: "mask-filter"
193
+ });
194
+ super({
195
+ ...r,
196
+ gpuProgram: i,
197
+ glProgram: l,
198
+ resources: {
199
+ filterUniforms: a,
200
+ uMaskTexture: t.texture.source
201
+ }
202
+ }), this.sprite = t, this._textureMatrix = n;
203
+ }
204
+ set inverse(e) {
205
+ this.resources.filterUniforms.uniforms.uInverse = e ? 1 : 0;
206
+ }
207
+ get inverse() {
208
+ return this.resources.filterUniforms.uniforms.uInverse === 1;
209
+ }
210
+ apply(e, t, r, n) {
211
+ this._textureMatrix.texture = this.sprite.texture, e.calculateSpriteMatrix(
212
+ this.resources.filterUniforms.uniforms.uFilterMatrix,
213
+ this.sprite
214
+ ).prepend(this._textureMatrix.mapCoord), this.resources.uMaskTexture = this.sprite.texture.source, e.applyFilter(this, t, r, n);
215
+ }
216
+ }
217
+ const U = class oe {
218
+ constructor(e, t) {
219
+ var r, n;
220
+ this.state = Ie.for2d(), this._batchersByInstructionSet = /* @__PURE__ */ Object.create(null), this._activeBatches = /* @__PURE__ */ Object.create(null), this.renderer = e, this._adaptor = t, (n = (r = this._adaptor).init) == null || n.call(r, this);
221
+ }
222
+ static getBatcher(e) {
223
+ return new this._availableBatchers[e]();
224
+ }
225
+ buildStart(e) {
226
+ let t = this._batchersByInstructionSet[e.uid];
227
+ t || (t = this._batchersByInstructionSet[e.uid] = /* @__PURE__ */ Object.create(null), t.default || (t.default = new Q())), this._activeBatches = t, this._activeBatch = this._activeBatches.default;
228
+ for (const r in this._activeBatches)
229
+ this._activeBatches[r].begin();
230
+ }
231
+ addToBatch(e, t) {
232
+ if (this._activeBatch.name !== e.batcherName) {
233
+ this._activeBatch.break(t);
234
+ let r = this._activeBatches[e.batcherName];
235
+ r || (r = this._activeBatches[e.batcherName] = oe.getBatcher(e.batcherName), r.begin()), this._activeBatch = r;
236
+ }
237
+ this._activeBatch.add(e);
238
+ }
239
+ break(e) {
240
+ this._activeBatch.break(e);
241
+ }
242
+ buildEnd(e) {
243
+ this._activeBatch.break(e);
244
+ const t = this._activeBatches;
245
+ for (const r in t) {
246
+ const n = t[r], a = n.geometry;
247
+ a.indexBuffer.setDataWithSize(n.indexBuffer, n.indexSize, !0), a.buffers[0].setDataWithSize(n.attributeBuffer.float32View, n.attributeSize, !1);
248
+ }
249
+ }
250
+ upload(e) {
251
+ const t = this._batchersByInstructionSet[e.uid];
252
+ for (const r in t) {
253
+ const n = t[r], a = n.geometry;
254
+ n.dirty && (n.dirty = !1, a.buffers[0].update(n.attributeSize * 4));
255
+ }
256
+ }
257
+ execute(e) {
258
+ if (e.action === "startBatch") {
259
+ const t = e.batcher, r = t.geometry, n = t.shader;
260
+ this._adaptor.start(this, r, n);
261
+ }
262
+ this._adaptor.execute(this, e);
263
+ }
264
+ destroy() {
265
+ this.state = null, this.renderer = null, this._adaptor = null;
266
+ for (const e in this._activeBatches)
267
+ this._activeBatches[e].destroy();
268
+ this._activeBatches = null;
269
+ }
270
+ };
271
+ U.extension = {
272
+ type: [
273
+ u.WebGLPipes,
274
+ u.WebGPUPipes,
275
+ u.CanvasPipes
276
+ ],
277
+ name: "batch"
278
+ };
279
+ U._availableBatchers = /* @__PURE__ */ Object.create(null);
280
+ let le = U;
281
+ R.handleByMap(u.Batcher, le._availableBatchers);
282
+ R.add(Q);
283
+ const Pt = {
284
+ name: "texture-bit",
285
+ vertex: {
286
+ header: `
287
+
288
+ struct TextureUniforms {
289
+ uTextureMatrix:mat3x3<f32>,
290
+ }
291
+
292
+ @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
293
+ `,
294
+ main: `
295
+ uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
296
+ `
297
+ },
298
+ fragment: {
299
+ header: `
300
+ @group(2) @binding(0) var uTexture: texture_2d<f32>;
301
+ @group(2) @binding(1) var uSampler: sampler;
302
+
303
+
304
+ `,
305
+ main: `
306
+ outColor = textureSample(uTexture, uSampler, vUV);
307
+ `
308
+ }
309
+ }, St = {
310
+ name: "texture-bit",
311
+ vertex: {
312
+ header: `
313
+ uniform mat3 uTextureMatrix;
314
+ `,
315
+ main: `
316
+ uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
317
+ `
318
+ },
319
+ fragment: {
320
+ header: `
321
+ uniform sampler2D uTexture;
322
+
323
+
324
+ `,
325
+ main: `
326
+ outColor = texture(uTexture, vUV);
327
+ `
328
+ }
329
+ };
330
+ function Qe(s, e) {
331
+ const t = s.root, r = s.instructionSet;
332
+ r.reset();
333
+ const n = e.renderPipes ? e : e.batch.renderer, a = n.renderPipes;
334
+ a.batch.buildStart(r), a.blendMode.buildStart(), a.colorMask.buildStart(), t.sortableChildren && t.sortChildren(), de(t, r, n, !0), a.batch.buildEnd(r), a.blendMode.buildEnd(r);
335
+ }
336
+ function M(s, e, t) {
337
+ const r = t.renderPipes ? t : t.batch.renderer;
338
+ s.globalDisplayStatus < 7 || !s.includeInBuild || (s.sortableChildren && s.sortChildren(), s.isSimple ? Ze(s, e, r) : de(s, e, r, !1));
339
+ }
340
+ function Ze(s, e, t) {
341
+ if (s.renderPipeId) {
342
+ const r = s, { renderPipes: n, renderableGC: a } = t;
343
+ n.blendMode.setBlendMode(r, s.groupBlendMode, e), n[r.renderPipeId].addRenderable(r, e), a.addRenderable(r, e), r.didViewUpdate = !1;
344
+ }
345
+ if (!s.renderGroup) {
346
+ const r = s.children, n = r.length;
347
+ for (let a = 0; a < n; a++)
348
+ M(r[a], e, t);
349
+ }
350
+ }
351
+ function de(s, e, t, r) {
352
+ const { renderPipes: n, renderableGC: a } = t;
353
+ if (!r && s.renderGroup)
354
+ n.renderGroup.addRenderGroup(s.renderGroup, e);
355
+ else {
356
+ for (let d = 0; d < s.effects.length; d++) {
357
+ const c = s.effects[d];
358
+ n[c.pipe].push(c, s, e);
359
+ }
360
+ const i = s, l = i.renderPipeId;
361
+ l && (n.blendMode.setBlendMode(i, i.groupBlendMode, e), n[l].addRenderable(i, e), a.addRenderable(i, e), i.didViewUpdate = !1);
362
+ const o = s.children;
363
+ if (o.length)
364
+ for (let d = 0; d < o.length; d++)
365
+ M(o[d], e, t);
366
+ for (let d = s.effects.length - 1; d >= 0; d--) {
367
+ const c = s.effects[d];
368
+ n[c.pipe].pop(c, s, e);
369
+ }
370
+ }
371
+ }
372
+ const et = new Z();
373
+ class tt extends ee {
374
+ constructor() {
375
+ super(), this.filters = [new Xe({
376
+ sprite: new De(m.EMPTY),
377
+ inverse: !1,
378
+ resolution: "inherit",
379
+ antialias: "inherit"
380
+ })];
381
+ }
382
+ get sprite() {
383
+ return this.filters[0].sprite;
384
+ }
385
+ set sprite(e) {
386
+ this.filters[0].sprite = e;
387
+ }
388
+ get inverse() {
389
+ return this.filters[0].inverse;
390
+ }
391
+ set inverse(e) {
392
+ this.filters[0].inverse = e;
393
+ }
394
+ }
395
+ class ue {
396
+ constructor(e) {
397
+ this._activeMaskStage = [], this._renderer = e;
398
+ }
399
+ push(e, t, r) {
400
+ const n = this._renderer;
401
+ if (n.renderPipes.batch.break(r), r.add({
402
+ renderPipeId: "alphaMask",
403
+ action: "pushMaskBegin",
404
+ mask: e,
405
+ inverse: t._maskOptions.inverse,
406
+ canBundle: !1,
407
+ maskedContainer: t
408
+ }), e.inverse = t._maskOptions.inverse, e.renderMaskToTexture) {
409
+ const a = e.mask;
410
+ a.includeInBuild = !0, M(
411
+ a,
412
+ r,
413
+ n
414
+ ), a.includeInBuild = !1;
415
+ }
416
+ n.renderPipes.batch.break(r), r.add({
417
+ renderPipeId: "alphaMask",
418
+ action: "pushMaskEnd",
419
+ mask: e,
420
+ maskedContainer: t,
421
+ inverse: t._maskOptions.inverse,
422
+ canBundle: !1
423
+ });
424
+ }
425
+ pop(e, t, r) {
426
+ this._renderer.renderPipes.batch.break(r), r.add({
427
+ renderPipeId: "alphaMask",
428
+ action: "popMaskEnd",
429
+ mask: e,
430
+ inverse: t._maskOptions.inverse,
431
+ canBundle: !1
432
+ });
433
+ }
434
+ execute(e) {
435
+ const t = this._renderer, r = e.mask.renderMaskToTexture;
436
+ if (e.action === "pushMaskBegin") {
437
+ const n = b.get(tt);
438
+ if (n.inverse = e.inverse, r) {
439
+ e.mask.mask.measurable = !0;
440
+ const a = Ee(e.mask.mask, !0, et);
441
+ e.mask.mask.measurable = !1, a.ceil();
442
+ const i = t.renderTarget.renderTarget.colorTexture.source, l = L.getOptimalTexture(
443
+ a.width,
444
+ a.height,
445
+ i._resolution,
446
+ i.antialias
447
+ );
448
+ t.renderTarget.push(l, !0), t.globalUniforms.push({
449
+ offset: a,
450
+ worldColor: 4294967295
451
+ });
452
+ const o = n.sprite;
453
+ o.texture = l, o.worldTransform.tx = a.minX, o.worldTransform.ty = a.minY, this._activeMaskStage.push({
454
+ filterEffect: n,
455
+ maskedContainer: e.maskedContainer,
456
+ filterTexture: l
457
+ });
458
+ } else
459
+ n.sprite = e.mask.mask, this._activeMaskStage.push({
460
+ filterEffect: n,
461
+ maskedContainer: e.maskedContainer
462
+ });
463
+ } else if (e.action === "pushMaskEnd") {
464
+ const n = this._activeMaskStage[this._activeMaskStage.length - 1];
465
+ r && (t.type === B.WEBGL && t.renderTarget.finishRenderPass(), t.renderTarget.pop(), t.globalUniforms.pop()), t.filter.push({
466
+ renderPipeId: "filter",
467
+ action: "pushFilter",
468
+ container: n.maskedContainer,
469
+ filterEffect: n.filterEffect,
470
+ canBundle: !1
471
+ });
472
+ } else if (e.action === "popMaskEnd") {
473
+ t.filter.pop();
474
+ const n = this._activeMaskStage.pop();
475
+ r && L.returnTexture(n.filterTexture), b.return(n.filterEffect);
476
+ }
477
+ }
478
+ destroy() {
479
+ this._renderer = null, this._activeMaskStage = null;
480
+ }
481
+ }
482
+ ue.extension = {
483
+ type: [
484
+ u.WebGLPipes,
485
+ u.WebGPUPipes,
486
+ u.CanvasPipes
487
+ ],
488
+ name: "alphaMask"
489
+ };
490
+ class ce {
491
+ constructor(e) {
492
+ this._colorStack = [], this._colorStackIndex = 0, this._currentColor = 0, this._renderer = e;
493
+ }
494
+ buildStart() {
495
+ this._colorStack[0] = 15, this._colorStackIndex = 1, this._currentColor = 15;
496
+ }
497
+ push(e, t, r) {
498
+ this._renderer.renderPipes.batch.break(r);
499
+ const a = this._colorStack;
500
+ a[this._colorStackIndex] = a[this._colorStackIndex - 1] & e.mask;
501
+ const i = this._colorStack[this._colorStackIndex];
502
+ i !== this._currentColor && (this._currentColor = i, r.add({
503
+ renderPipeId: "colorMask",
504
+ colorMask: i,
505
+ canBundle: !1
506
+ })), this._colorStackIndex++;
507
+ }
508
+ pop(e, t, r) {
509
+ this._renderer.renderPipes.batch.break(r);
510
+ const a = this._colorStack;
511
+ this._colorStackIndex--;
512
+ const i = a[this._colorStackIndex - 1];
513
+ i !== this._currentColor && (this._currentColor = i, r.add({
514
+ renderPipeId: "colorMask",
515
+ colorMask: i,
516
+ canBundle: !1
517
+ }));
518
+ }
519
+ execute(e) {
520
+ this._renderer.colorMask.setMask(e.colorMask);
521
+ }
522
+ destroy() {
523
+ this._colorStack = null;
524
+ }
525
+ }
526
+ ce.extension = {
527
+ type: [
528
+ u.WebGLPipes,
529
+ u.WebGPUPipes,
530
+ u.CanvasPipes
531
+ ],
532
+ name: "colorMask"
533
+ };
534
+ class he {
535
+ constructor(e) {
536
+ this._maskStackHash = {}, this._maskHash = /* @__PURE__ */ new WeakMap(), this._renderer = e;
537
+ }
538
+ push(e, t, r) {
539
+ var h;
540
+ var n;
541
+ const a = e, i = this._renderer;
542
+ i.renderPipes.batch.break(r), i.renderPipes.blendMode.setBlendMode(a.mask, "none", r), r.add({
543
+ renderPipeId: "stencilMask",
544
+ action: "pushMaskBegin",
545
+ mask: e,
546
+ inverse: t._maskOptions.inverse,
547
+ canBundle: !1
548
+ });
549
+ const l = a.mask;
550
+ l.includeInBuild = !0, this._maskHash.has(a) || this._maskHash.set(a, {
551
+ instructionsStart: 0,
552
+ instructionsLength: 0
553
+ });
554
+ const o = this._maskHash.get(a);
555
+ o.instructionsStart = r.instructionSize, M(
556
+ l,
557
+ r,
558
+ i
559
+ ), l.includeInBuild = !1, i.renderPipes.batch.break(r), r.add({
560
+ renderPipeId: "stencilMask",
561
+ action: "pushMaskEnd",
562
+ mask: e,
563
+ inverse: t._maskOptions.inverse,
564
+ canBundle: !1
565
+ });
566
+ const d = r.instructionSize - o.instructionsStart - 1;
567
+ o.instructionsLength = d;
568
+ const c = i.renderTarget.renderTarget.uid;
569
+ (h = (n = this._maskStackHash)[c]) != null || (n[c] = 0);
570
+ }
571
+ pop(e, t, r) {
572
+ const n = e, a = this._renderer;
573
+ a.renderPipes.batch.break(r), a.renderPipes.blendMode.setBlendMode(n.mask, "none", r), r.add({
574
+ renderPipeId: "stencilMask",
575
+ action: "popMaskBegin",
576
+ inverse: t._maskOptions.inverse,
577
+ canBundle: !1
578
+ });
579
+ const i = this._maskHash.get(e);
580
+ for (let l = 0; l < i.instructionsLength; l++)
581
+ r.instructions[r.instructionSize++] = r.instructions[i.instructionsStart++];
582
+ r.add({
583
+ renderPipeId: "stencilMask",
584
+ action: "popMaskEnd",
585
+ canBundle: !1
586
+ });
587
+ }
588
+ execute(e) {
589
+ var i;
590
+ var t;
591
+ const r = this._renderer, n = r.renderTarget.renderTarget.uid;
592
+ let a = (i = (t = this._maskStackHash)[n]) != null ? i : t[n] = 0;
593
+ e.action === "pushMaskBegin" ? (r.renderTarget.ensureDepthStencil(), r.stencil.setStencilMode(p.RENDERING_MASK_ADD, a), a++, r.colorMask.setMask(0)) : e.action === "pushMaskEnd" ? (e.inverse ? r.stencil.setStencilMode(p.INVERSE_MASK_ACTIVE, a) : r.stencil.setStencilMode(p.MASK_ACTIVE, a), r.colorMask.setMask(15)) : e.action === "popMaskBegin" ? (r.colorMask.setMask(0), a !== 0 ? r.stencil.setStencilMode(p.RENDERING_MASK_REMOVE, a) : (r.renderTarget.clear(null, w.STENCIL), r.stencil.setStencilMode(p.DISABLED, a)), a--) : e.action === "popMaskEnd" && (e.inverse ? r.stencil.setStencilMode(p.INVERSE_MASK_ACTIVE, a) : r.stencil.setStencilMode(p.MASK_ACTIVE, a), r.colorMask.setMask(15)), this._maskStackHash[n] = a;
594
+ }
595
+ destroy() {
596
+ this._renderer = null, this._maskStackHash = null, this._maskHash = null;
597
+ }
598
+ }
599
+ he.extension = {
600
+ type: [
601
+ u.WebGLPipes,
602
+ u.WebGPUPipes,
603
+ u.CanvasPipes
604
+ ],
605
+ name: "stencilMask"
606
+ };
607
+ function wt(s, e) {
608
+ var t, r, n;
609
+ for (const a in s.attributes) {
610
+ const i = s.attributes[a], l = e[a];
611
+ l ? ((t = i.format) != null || (i.format = l.format), (r = i.offset) != null || (i.offset = l.offset), (n = i.instance) != null || (i.instance = l.instance)) : te(`Attribute ${a} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);
612
+ }
613
+ rt(s);
614
+ }
615
+ function rt(s) {
616
+ var a, i;
617
+ const { buffers: e, attributes: t } = s, r = {}, n = {};
618
+ for (const l in e) {
619
+ const o = e[l];
620
+ r[o.uid] = 0, n[o.uid] = 0;
621
+ }
622
+ for (const l in t) {
623
+ const o = t[l];
624
+ r[o.buffer.uid] += W(o.format).stride;
625
+ }
626
+ for (const l in t) {
627
+ const o = t[l];
628
+ (a = o.stride) != null || (o.stride = r[o.buffer.uid]), (i = o.start) != null || (o.start = n[o.buffer.uid]), n[o.buffer.uid] += W(o.format).stride;
629
+ }
630
+ }
631
+ const _ = [];
632
+ _[p.NONE] = void 0;
633
+ _[p.DISABLED] = {
634
+ stencilWriteMask: 0,
635
+ stencilReadMask: 0
636
+ };
637
+ _[p.RENDERING_MASK_ADD] = {
638
+ stencilFront: {
639
+ compare: "equal",
640
+ passOp: "increment-clamp"
641
+ },
642
+ stencilBack: {
643
+ compare: "equal",
644
+ passOp: "increment-clamp"
645
+ }
646
+ };
647
+ _[p.RENDERING_MASK_REMOVE] = {
648
+ stencilFront: {
649
+ compare: "equal",
650
+ passOp: "decrement-clamp"
651
+ },
652
+ stencilBack: {
653
+ compare: "equal",
654
+ passOp: "decrement-clamp"
655
+ }
656
+ };
657
+ _[p.MASK_ACTIVE] = {
658
+ stencilWriteMask: 0,
659
+ stencilFront: {
660
+ compare: "equal",
661
+ passOp: "keep"
662
+ },
663
+ stencilBack: {
664
+ compare: "equal",
665
+ passOp: "keep"
666
+ }
667
+ };
668
+ _[p.INVERSE_MASK_ACTIVE] = {
669
+ stencilWriteMask: 0,
670
+ stencilFront: {
671
+ compare: "not-equal",
672
+ passOp: "replace"
673
+ },
674
+ stencilBack: {
675
+ compare: "not-equal",
676
+ passOp: "replace"
677
+ }
678
+ };
679
+ class Gt {
680
+ constructor(e) {
681
+ this._syncFunctionHash = /* @__PURE__ */ Object.create(null), this._adaptor = e, this._systemCheck();
682
+ }
683
+ _systemCheck() {
684
+ if (!Fe())
685
+ throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.");
686
+ }
687
+ ensureUniformGroup(e) {
688
+ const t = this.getUniformGroupData(e);
689
+ e.buffer || (e.buffer = new z({
690
+ data: new Float32Array(t.layout.size / 4),
691
+ usage: y.UNIFORM | y.COPY_DST
692
+ }));
693
+ }
694
+ getUniformGroupData(e) {
695
+ return this._syncFunctionHash[e._signature] || this._initUniformGroup(e);
696
+ }
697
+ _initUniformGroup(e) {
698
+ const t = e._signature;
699
+ let r = this._syncFunctionHash[t];
700
+ if (!r) {
701
+ const n = Object.keys(e.uniformStructures).map((l) => e.uniformStructures[l]), a = this._adaptor.createUboElements(n), i = this._generateUboSync(a.uboElements);
702
+ r = this._syncFunctionHash[t] = {
703
+ layout: a,
704
+ syncFunction: i
705
+ };
706
+ }
707
+ return this._syncFunctionHash[t];
708
+ }
709
+ _generateUboSync(e) {
710
+ return this._adaptor.generateUboSync(e);
711
+ }
712
+ syncUniformGroup(e, t, r) {
713
+ const n = this.getUniformGroupData(e);
714
+ return e.buffer || (e.buffer = new z({
715
+ data: new Float32Array(n.layout.size / 4),
716
+ usage: y.UNIFORM | y.COPY_DST
717
+ })), t || (t = e.buffer.data), r || (r = 0), n.syncFunction(e.uniforms, t, r), !0;
718
+ }
719
+ updateUniformGroup(e) {
720
+ if (e.isStatic && !e._dirtyId)
721
+ return !1;
722
+ e._dirtyId = 0;
723
+ const t = this.syncUniformGroup(e);
724
+ return e.buffer.update(), t;
725
+ }
726
+ destroy() {
727
+ this._syncFunctionHash = null;
728
+ }
729
+ }
730
+ const k = [
731
+ {
732
+ type: "mat3x3<f32>",
733
+ test: (s) => s.value.a !== void 0,
734
+ ubo: `
735
+ var matrix = uv[name].toArray(true);
736
+ data[offset] = matrix[0];
737
+ data[offset + 1] = matrix[1];
738
+ data[offset + 2] = matrix[2];
739
+ data[offset + 4] = matrix[3];
740
+ data[offset + 5] = matrix[4];
741
+ data[offset + 6] = matrix[5];
742
+ data[offset + 8] = matrix[6];
743
+ data[offset + 9] = matrix[7];
744
+ data[offset + 10] = matrix[8];
745
+ `,
746
+ uniform: `
747
+ gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
748
+ `
749
+ },
750
+ {
751
+ type: "vec4<f32>",
752
+ test: (s) => s.type === "vec4<f32>" && s.size === 1 && s.value.width !== void 0,
753
+ ubo: `
754
+ v = uv[name];
755
+ data[offset] = v.x;
756
+ data[offset + 1] = v.y;
757
+ data[offset + 2] = v.width;
758
+ data[offset + 3] = v.height;
759
+ `,
760
+ uniform: `
761
+ cv = ud[name].value;
762
+ v = uv[name];
763
+ if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
764
+ cv[0] = v.x;
765
+ cv[1] = v.y;
766
+ cv[2] = v.width;
767
+ cv[3] = v.height;
768
+ gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
769
+ }
770
+ `
771
+ },
772
+ {
773
+ type: "vec2<f32>",
774
+ test: (s) => s.type === "vec2<f32>" && s.size === 1 && s.value.x !== void 0,
775
+ ubo: `
776
+ v = uv[name];
777
+ data[offset] = v.x;
778
+ data[offset + 1] = v.y;
779
+ `,
780
+ uniform: `
781
+ cv = ud[name].value;
782
+ v = uv[name];
783
+ if (cv[0] !== v.x || cv[1] !== v.y) {
784
+ cv[0] = v.x;
785
+ cv[1] = v.y;
786
+ gl.uniform2f(ud[name].location, v.x, v.y);
787
+ }
788
+ `
789
+ },
790
+ {
791
+ type: "vec4<f32>",
792
+ test: (s) => s.type === "vec4<f32>" && s.size === 1 && s.value.red !== void 0,
793
+ ubo: `
794
+ v = uv[name];
795
+ data[offset] = v.red;
796
+ data[offset + 1] = v.green;
797
+ data[offset + 2] = v.blue;
798
+ data[offset + 3] = v.alpha;
799
+ `,
800
+ uniform: `
801
+ cv = ud[name].value;
802
+ v = uv[name];
803
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
804
+ cv[0] = v.red;
805
+ cv[1] = v.green;
806
+ cv[2] = v.blue;
807
+ cv[3] = v.alpha;
808
+ gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
809
+ }
810
+ `
811
+ },
812
+ {
813
+ type: "vec3<f32>",
814
+ test: (s) => s.type === "vec3<f32>" && s.size === 1 && s.value.red !== void 0,
815
+ ubo: `
816
+ v = uv[name];
817
+ data[offset] = v.red;
818
+ data[offset + 1] = v.green;
819
+ data[offset + 2] = v.blue;
820
+ `,
821
+ uniform: `
822
+ cv = ud[name].value;
823
+ v = uv[name];
824
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
825
+ cv[0] = v.red;
826
+ cv[1] = v.green;
827
+ cv[2] = v.blue;
828
+ gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
829
+ }
830
+ `
831
+ }
832
+ ];
833
+ function Rt(s, e, t, r) {
834
+ const n = [`
835
+ var v = null;
836
+ var v2 = null;
837
+ var t = 0;
838
+ var index = 0;
839
+ var name = null;
840
+ var arrayOffset = null;
841
+ `];
842
+ let a = 0;
843
+ for (let l = 0; l < s.length; l++) {
844
+ const o = s[l], d = o.data.name;
845
+ let c = !1, h = 0;
846
+ for (let f = 0; f < k.length; f++)
847
+ if (k[f].test(o.data)) {
848
+ h = o.offset / 4, n.push(
849
+ `name = "${d}";`,
850
+ `offset += ${h - a};`,
851
+ k[f][e] || k[f].ubo
852
+ ), c = !0;
853
+ break;
854
+ }
855
+ if (!c)
856
+ if (o.data.size > 1)
857
+ h = o.offset / 4, n.push(t(o, h - a));
858
+ else {
859
+ const f = r[o.data.type];
860
+ h = o.offset / 4, n.push(
861
+ `
862
+ v = uv.${d};
863
+ offset += ${h - a};
864
+ ${f};
865
+ `
866
+ );
867
+ }
868
+ a = h;
869
+ }
870
+ const i = n.join(`
871
+ `);
872
+ return new Function(
873
+ "uv",
874
+ "data",
875
+ "offset",
876
+ i
877
+ );
878
+ }
879
+ function g(s, e) {
880
+ return `
881
+ for (let i = 0; i < ${s * e}; i++) {
882
+ data[offset + (((i / ${s})|0) * 4) + (i % ${s})] = v[i];
883
+ }
884
+ `;
885
+ }
886
+ const st = {
887
+ f32: `
888
+ data[offset] = v;`,
889
+ i32: `
890
+ data[offset] = v;`,
891
+ "vec2<f32>": `
892
+ data[offset] = v[0];
893
+ data[offset + 1] = v[1];`,
894
+ "vec3<f32>": `
895
+ data[offset] = v[0];
896
+ data[offset + 1] = v[1];
897
+ data[offset + 2] = v[2];`,
898
+ "vec4<f32>": `
899
+ data[offset] = v[0];
900
+ data[offset + 1] = v[1];
901
+ data[offset + 2] = v[2];
902
+ data[offset + 3] = v[3];`,
903
+ "mat2x2<f32>": `
904
+ data[offset] = v[0];
905
+ data[offset + 1] = v[1];
906
+ data[offset + 4] = v[2];
907
+ data[offset + 5] = v[3];`,
908
+ "mat3x3<f32>": `
909
+ data[offset] = v[0];
910
+ data[offset + 1] = v[1];
911
+ data[offset + 2] = v[2];
912
+ data[offset + 4] = v[3];
913
+ data[offset + 5] = v[4];
914
+ data[offset + 6] = v[5];
915
+ data[offset + 8] = v[6];
916
+ data[offset + 9] = v[7];
917
+ data[offset + 10] = v[8];`,
918
+ "mat4x4<f32>": `
919
+ for (let i = 0; i < 16; i++) {
920
+ data[offset + i] = v[i];
921
+ }`,
922
+ "mat3x2<f32>": g(3, 2),
923
+ "mat4x2<f32>": g(4, 2),
924
+ "mat2x3<f32>": g(2, 3),
925
+ "mat4x3<f32>": g(4, 3),
926
+ "mat2x4<f32>": g(2, 4),
927
+ "mat3x4<f32>": g(3, 4)
928
+ }, Bt = {
929
+ ...st,
930
+ "mat2x2<f32>": `
931
+ data[offset] = v[0];
932
+ data[offset + 1] = v[1];
933
+ data[offset + 2] = v[2];
934
+ data[offset + 3] = v[3];
935
+ `
936
+ };
937
+ function nt(s, e, t, r, n, a) {
938
+ const i = a ? 1 : -1;
939
+ return s.identity(), s.a = 1 / r * 2, s.d = i * (1 / n * 2), s.tx = -1 - e * s.a, s.ty = -i - t * s.d, s;
940
+ }
941
+ function at(s) {
942
+ const e = s.colorTexture.source.resource;
943
+ return globalThis.HTMLCanvasElement && e instanceof HTMLCanvasElement && document.body.contains(e);
944
+ }
945
+ class Ut {
946
+ constructor(e) {
947
+ this.rootViewPort = new G(), this.viewport = new G(), this.onRenderTargetChange = new Oe("onRenderTargetChange"), this.projectionMatrix = new v(), this.defaultClearColor = [0, 0, 0, 0], this._renderSurfaceToRenderTargetHash = /* @__PURE__ */ new Map(), this._gpuRenderTargetHash = /* @__PURE__ */ Object.create(null), this._renderTargetStack = [], this._renderer = e, e.renderableGC.addManagedHash(this, "_gpuRenderTargetHash");
948
+ }
949
+ finishRenderPass() {
950
+ this.adaptor.finishRenderPass(this.renderTarget);
951
+ }
952
+ renderStart({
953
+ target: e,
954
+ clear: t,
955
+ clearColor: r,
956
+ frame: n
957
+ }) {
958
+ this._renderTargetStack.length = 0, this.push(
959
+ e,
960
+ t,
961
+ r,
962
+ n
963
+ ), this.rootViewPort.copyFrom(this.viewport), this.rootRenderTarget = this.renderTarget, this.renderingToScreen = at(this.rootRenderTarget);
964
+ }
965
+ postrender() {
966
+ var e, t;
967
+ (t = (e = this.adaptor).postrender) == null || t.call(e, this.rootRenderTarget);
968
+ }
969
+ bind(e, t = !0, r, n) {
970
+ const a = this.getRenderTarget(e), i = this.renderTarget !== a;
971
+ this.renderTarget = a, this.renderSurface = e;
972
+ const l = this.getGpuRenderTarget(a);
973
+ (a.pixelWidth !== l.width || a.pixelHeight !== l.height) && (this.adaptor.resizeGpuRenderTarget(a), l.width = a.pixelWidth, l.height = a.pixelHeight);
974
+ const o = a.colorTexture, d = this.viewport, c = o.pixelWidth, h = o.pixelHeight;
975
+ if (!n && e instanceof m && (n = e.frame), n) {
976
+ const f = o._resolution;
977
+ d.x = n.x * f + 0.5 | 0, d.y = n.y * f + 0.5 | 0, d.width = n.width * f + 0.5 | 0, d.height = n.height * f + 0.5 | 0;
978
+ } else
979
+ d.x = 0, d.y = 0, d.width = c, d.height = h;
980
+ return nt(
981
+ this.projectionMatrix,
982
+ 0,
983
+ 0,
984
+ d.width / o.resolution,
985
+ d.height / o.resolution,
986
+ !a.isRoot
987
+ ), this.adaptor.startRenderPass(a, t, r, d), i && this.onRenderTargetChange.emit(a), a;
988
+ }
989
+ clear(e, t = w.ALL, r) {
990
+ !t || (e && (e = this.getRenderTarget(e)), this.adaptor.clear(
991
+ e || this.renderTarget,
992
+ t,
993
+ r,
994
+ this.viewport
995
+ ));
996
+ }
997
+ contextChange() {
998
+ this._gpuRenderTargetHash = /* @__PURE__ */ Object.create(null);
999
+ }
1000
+ push(e, t = w.ALL, r, n) {
1001
+ const a = this.bind(e, t, r, n);
1002
+ return this._renderTargetStack.push({
1003
+ renderTarget: a,
1004
+ frame: n
1005
+ }), a;
1006
+ }
1007
+ pop() {
1008
+ this._renderTargetStack.pop();
1009
+ const e = this._renderTargetStack[this._renderTargetStack.length - 1];
1010
+ this.bind(e.renderTarget, !1, null, e.frame);
1011
+ }
1012
+ getRenderTarget(e) {
1013
+ var t;
1014
+ return e.isTexture && (e = e.source), (t = this._renderSurfaceToRenderTargetHash.get(e)) != null ? t : this._initRenderTarget(e);
1015
+ }
1016
+ copyToTexture(e, t, r, n, a) {
1017
+ r.x < 0 && (n.width += r.x, a.x -= r.x, r.x = 0), r.y < 0 && (n.height += r.y, a.y -= r.y, r.y = 0);
1018
+ const { pixelWidth: i, pixelHeight: l } = e;
1019
+ return n.width = Math.min(n.width, i - r.x), n.height = Math.min(n.height, l - r.y), this.adaptor.copyToTexture(
1020
+ e,
1021
+ t,
1022
+ r,
1023
+ n,
1024
+ a
1025
+ );
1026
+ }
1027
+ ensureDepthStencil() {
1028
+ this.renderTarget.stencil || (this.renderTarget.stencil = !0, this.adaptor.startRenderPass(this.renderTarget, !1, null, this.viewport));
1029
+ }
1030
+ destroy() {
1031
+ this._renderer = null, this._renderSurfaceToRenderTargetHash.forEach((e, t) => {
1032
+ e !== t && e.destroy();
1033
+ }), this._renderSurfaceToRenderTargetHash.clear(), this._gpuRenderTargetHash = /* @__PURE__ */ Object.create(null);
1034
+ }
1035
+ _initRenderTarget(e) {
1036
+ let t = null;
1037
+ return V.test(e) && (e = He(e).source), e instanceof j ? t = e : e instanceof re && (t = new j({
1038
+ colorTextures: [e]
1039
+ }), V.test(e.source.resource) && (t.isRoot = !0), e.once("destroy", () => {
1040
+ t.destroy(), this._renderSurfaceToRenderTargetHash.delete(e);
1041
+ const r = this._gpuRenderTargetHash[t.uid];
1042
+ r && (this._gpuRenderTargetHash[t.uid] = null, this.adaptor.destroyGpuRenderTarget(r));
1043
+ })), this._renderSurfaceToRenderTargetHash.set(e, t), t;
1044
+ }
1045
+ getGpuRenderTarget(e) {
1046
+ return this._gpuRenderTargetHash[e.uid] || (this._gpuRenderTargetHash[e.uid] = this.adaptor.initGpuRenderTarget(e));
1047
+ }
1048
+ }
1049
+ class At extends Le {
1050
+ constructor({ buffer: e, offset: t, size: r }) {
1051
+ super(), this.uid = C("buffer"), this._resourceType = "bufferResource", this._touched = 0, this._resourceId = C("resource"), this._bufferResource = !0, this.destroyed = !1, this.buffer = e, this.offset = t | 0, this.size = r, this.buffer.on("change", this.onBufferChange, this);
1052
+ }
1053
+ onBufferChange() {
1054
+ this._resourceId = C("resource"), this.emit("change", this);
1055
+ }
1056
+ destroy(e = !1) {
1057
+ this.destroyed = !0, e && this.buffer.destroy(), this.emit("change", this), this.buffer = null;
1058
+ }
1059
+ }
1060
+ class fe {
1061
+ constructor(e) {
1062
+ this._renderer = e;
1063
+ }
1064
+ updateRenderable() {
1065
+ }
1066
+ destroyRenderable() {
1067
+ }
1068
+ validateRenderable() {
1069
+ return !1;
1070
+ }
1071
+ addRenderable(e, t) {
1072
+ this._renderer.renderPipes.batch.break(t), t.add(e);
1073
+ }
1074
+ execute(e) {
1075
+ !e.isRenderable || e.render(this._renderer);
1076
+ }
1077
+ destroy() {
1078
+ this._renderer = null;
1079
+ }
1080
+ }
1081
+ fe.extension = {
1082
+ type: [
1083
+ u.WebGLPipes,
1084
+ u.WebGPUPipes,
1085
+ u.CanvasPipes
1086
+ ],
1087
+ name: "customRender"
1088
+ };
1089
+ function pe(s, e) {
1090
+ const t = s.instructionSet, r = t.instructions;
1091
+ for (let n = 0; n < t.instructionSize; n++) {
1092
+ const a = r[n];
1093
+ e[a.renderPipeId].execute(a);
1094
+ }
1095
+ }
1096
+ class me {
1097
+ constructor(e) {
1098
+ this._renderer = e;
1099
+ }
1100
+ addRenderGroup(e, t) {
1101
+ this._renderer.renderPipes.batch.break(t), t.add(e);
1102
+ }
1103
+ execute(e) {
1104
+ !e.isRenderable || (this._renderer.globalUniforms.push({
1105
+ worldTransformMatrix: e.worldTransform,
1106
+ worldColor: e.worldColorAlpha
1107
+ }), pe(e, this._renderer.renderPipes), this._renderer.globalUniforms.pop());
1108
+ }
1109
+ destroy() {
1110
+ this._renderer = null;
1111
+ }
1112
+ }
1113
+ me.extension = {
1114
+ type: [
1115
+ u.WebGLPipes,
1116
+ u.WebGPUPipes,
1117
+ u.CanvasPipes
1118
+ ],
1119
+ name: "renderGroup"
1120
+ };
1121
+ function A(s, e) {
1122
+ e || (e = 0);
1123
+ for (let t = e; t < s.length && s[t]; t++)
1124
+ s[t] = null;
1125
+ }
1126
+ function ve(s, e = []) {
1127
+ e.push(s);
1128
+ for (let t = 0; t < s.renderGroupChildren.length; t++)
1129
+ ve(s.renderGroupChildren[t], e);
1130
+ return e;
1131
+ }
1132
+ function it(s, e, t) {
1133
+ const r = s >> 16 & 255, n = s >> 8 & 255, a = s & 255, i = e >> 16 & 255, l = e >> 8 & 255, o = e & 255, d = r + (i - r) * t, c = n + (l - n) * t, h = a + (o - a) * t;
1134
+ return (d << 16) + (c << 8) + h;
1135
+ }
1136
+ const P = 16777215;
1137
+ function ge(s, e) {
1138
+ return s === P || e === P ? s + e - P : it(s, e, 0.5);
1139
+ }
1140
+ const ot = new T(), K = ae | se | ne;
1141
+ function _e(s, e = !1) {
1142
+ lt(s);
1143
+ const t = s.childrenToUpdate, r = s.updateTick++;
1144
+ for (const n in t) {
1145
+ const a = Number(n), i = t[n], l = i.list, o = i.index;
1146
+ for (let d = 0; d < o; d++) {
1147
+ const c = l[d];
1148
+ c.parentRenderGroup === s && c.relativeRenderGroupDepth === a && be(c, r, 0);
1149
+ }
1150
+ A(l, o), i.index = 0;
1151
+ }
1152
+ if (e)
1153
+ for (let n = 0; n < s.renderGroupChildren.length; n++)
1154
+ _e(s.renderGroupChildren[n], e);
1155
+ }
1156
+ function lt(s) {
1157
+ const e = s.root;
1158
+ let t;
1159
+ if (s.renderGroupParent) {
1160
+ const r = s.renderGroupParent;
1161
+ s.worldTransform.appendFrom(
1162
+ e.relativeGroupTransform,
1163
+ r.worldTransform
1164
+ ), s.worldColor = ge(
1165
+ e.groupColor,
1166
+ r.worldColor
1167
+ ), t = e.groupAlpha * r.worldAlpha;
1168
+ } else
1169
+ s.worldTransform.copyFrom(e.localTransform), s.worldColor = e.localColor, t = e.localAlpha;
1170
+ t = t < 0 ? 0 : t > 1 ? 1 : t, s.worldAlpha = t, s.worldColorAlpha = s.worldColor + ((t * 255 | 0) << 24);
1171
+ }
1172
+ function be(s, e, t) {
1173
+ if (e === s.updateTick)
1174
+ return;
1175
+ s.updateTick = e, s.didChange = !1;
1176
+ const r = s.localTransform;
1177
+ s.updateLocalTransform();
1178
+ const n = s.parent;
1179
+ if (n && !n.renderGroup ? (t = t | s._updateFlags, s.relativeGroupTransform.appendFrom(
1180
+ r,
1181
+ n.relativeGroupTransform
1182
+ ), t & K && Y(s, n, t)) : (t = s._updateFlags, s.relativeGroupTransform.copyFrom(r), t & K && Y(s, ot, t)), !s.renderGroup) {
1183
+ const a = s.children, i = a.length;
1184
+ for (let d = 0; d < i; d++)
1185
+ be(a[d], e, t);
1186
+ const l = s.parentRenderGroup, o = s;
1187
+ o.renderPipeId && !l.structureDidChange && l.updateRenderable(o);
1188
+ }
1189
+ }
1190
+ function Y(s, e, t) {
1191
+ if (t & se) {
1192
+ s.groupColor = ge(
1193
+ s.localColor,
1194
+ e.groupColor
1195
+ );
1196
+ let r = s.localAlpha * e.groupAlpha;
1197
+ r = r < 0 ? 0 : r > 1 ? 1 : r, s.groupAlpha = r, s.groupColorAlpha = s.groupColor + ((r * 255 | 0) << 24);
1198
+ }
1199
+ t & ne && (s.groupBlendMode = s.localBlendMode === "inherit" ? e.groupBlendMode : s.localBlendMode), t & ae && (s.globalDisplayStatus = s.localDisplayStatus & e.globalDisplayStatus), s._updateFlags = 0;
1200
+ }
1201
+ function dt(s, e) {
1202
+ const { list: t, index: r } = s.childrenRenderablesToUpdate;
1203
+ let n = !1;
1204
+ for (let a = 0; a < r; a++) {
1205
+ const i = t[a];
1206
+ if (n = e[i.renderPipeId].validateRenderable(i), n)
1207
+ break;
1208
+ }
1209
+ return s.structureDidChange = n, n;
1210
+ }
1211
+ const ut = new v();
1212
+ class xe {
1213
+ constructor(e) {
1214
+ this._renderer = e;
1215
+ }
1216
+ render({ container: e, transform: t }) {
1217
+ e.isRenderGroup = !0;
1218
+ const r = e.parent, n = e.renderGroup.renderGroupParent;
1219
+ e.parent = null, e.renderGroup.renderGroupParent = null;
1220
+ const a = this._renderer, i = ve(e.renderGroup, []);
1221
+ let l = ut;
1222
+ t && (l = l.copyFrom(e.renderGroup.localTransform), e.renderGroup.localTransform.copyFrom(t));
1223
+ const o = a.renderPipes;
1224
+ for (let d = 0; d < i.length; d++) {
1225
+ const c = i[d];
1226
+ c.runOnRender(), c.instructionSet.renderPipes = o, c.structureDidChange ? A(c.childrenRenderablesToUpdate.list, 0) : dt(c, o), _e(c), c.structureDidChange ? (c.structureDidChange = !1, Qe(c, a)) : ct(c), c.childrenRenderablesToUpdate.index = 0, a.renderPipes.batch.upload(c.instructionSet);
1227
+ }
1228
+ a.globalUniforms.start({
1229
+ worldTransformMatrix: t ? e.renderGroup.localTransform : e.renderGroup.worldTransform,
1230
+ worldColor: e.renderGroup.worldColorAlpha
1231
+ }), pe(e.renderGroup, o), o.uniformBatch && o.uniformBatch.renderEnd(), t && e.renderGroup.localTransform.copyFrom(l), e.parent = r, e.renderGroup.renderGroupParent = n;
1232
+ }
1233
+ destroy() {
1234
+ this._renderer = null;
1235
+ }
1236
+ }
1237
+ xe.extension = {
1238
+ type: [
1239
+ u.WebGLSystem,
1240
+ u.WebGPUSystem,
1241
+ u.CanvasSystem
1242
+ ],
1243
+ name: "renderGroup"
1244
+ };
1245
+ function ct(s) {
1246
+ const { list: e, index: t } = s.childrenRenderablesToUpdate;
1247
+ for (let r = 0; r < t; r++) {
1248
+ const n = e[r];
1249
+ n.didViewUpdate && s.updateRenderable(n);
1250
+ }
1251
+ A(e, t);
1252
+ }
1253
+ class ye {
1254
+ constructor(e) {
1255
+ this._gpuSpriteHash = /* @__PURE__ */ Object.create(null), this._destroyRenderableBound = this.destroyRenderable.bind(this), this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_gpuSpriteHash");
1256
+ }
1257
+ addRenderable(e, t) {
1258
+ const r = this._getGpuSprite(e);
1259
+ e.didViewUpdate && this._updateBatchableSprite(e, r), this._renderer.renderPipes.batch.addToBatch(r, t);
1260
+ }
1261
+ updateRenderable(e) {
1262
+ const t = this._gpuSpriteHash[e.uid];
1263
+ e.didViewUpdate && this._updateBatchableSprite(e, t), t._batcher.updateElement(t);
1264
+ }
1265
+ validateRenderable(e) {
1266
+ const t = e._texture, r = this._getGpuSprite(e);
1267
+ return r.texture._source !== t._source ? !r._batcher.checkAndUpdateTexture(r, t) : !1;
1268
+ }
1269
+ destroyRenderable(e) {
1270
+ const t = this._gpuSpriteHash[e.uid];
1271
+ b.return(t), this._gpuSpriteHash[e.uid] = null, e.off("destroyed", this._destroyRenderableBound);
1272
+ }
1273
+ _updateBatchableSprite(e, t) {
1274
+ t.bounds = e.bounds, t.texture = e._texture;
1275
+ }
1276
+ _getGpuSprite(e) {
1277
+ return this._gpuSpriteHash[e.uid] || this._initGPUSprite(e);
1278
+ }
1279
+ _initGPUSprite(e) {
1280
+ const t = b.get(qe);
1281
+ return t.renderable = e, t.transform = e.groupTransform, t.texture = e._texture, t.bounds = e.bounds, t.roundPixels = this._renderer._roundPixels | e._roundPixels, this._gpuSpriteHash[e.uid] = t, e.on("destroyed", this._destroyRenderableBound), t;
1282
+ }
1283
+ destroy() {
1284
+ for (const e in this._gpuSpriteHash)
1285
+ b.return(this._gpuSpriteHash[e]);
1286
+ this._gpuSpriteHash = null, this._renderer = null;
1287
+ }
1288
+ }
1289
+ ye.extension = {
1290
+ type: [
1291
+ u.WebGLPipes,
1292
+ u.WebGPUPipes,
1293
+ u.CanvasPipes
1294
+ ],
1295
+ name: "sprite"
1296
+ };
1297
+ const I = class ke {
1298
+ constructor() {
1299
+ this.clearBeforeRender = !0, this._backgroundColor = new ie(0), this.color = this._backgroundColor, this.alpha = 1;
1300
+ }
1301
+ init(e) {
1302
+ e = { ...ke.defaultOptions, ...e }, this.clearBeforeRender = e.clearBeforeRender, this.color = e.background || e.backgroundColor || this._backgroundColor, this.alpha = e.backgroundAlpha, this._backgroundColor.setAlpha(e.backgroundAlpha);
1303
+ }
1304
+ get color() {
1305
+ return this._backgroundColor;
1306
+ }
1307
+ set color(e) {
1308
+ this._backgroundColor.setValue(e);
1309
+ }
1310
+ get alpha() {
1311
+ return this._backgroundColor.alpha;
1312
+ }
1313
+ set alpha(e) {
1314
+ this._backgroundColor.setAlpha(e);
1315
+ }
1316
+ get colorRgba() {
1317
+ return this._backgroundColor.toArray();
1318
+ }
1319
+ destroy() {
1320
+ }
1321
+ };
1322
+ I.extension = {
1323
+ type: [
1324
+ u.WebGLSystem,
1325
+ u.WebGPUSystem,
1326
+ u.CanvasSystem
1327
+ ],
1328
+ name: "background",
1329
+ priority: 0
1330
+ };
1331
+ I.defaultOptions = {
1332
+ backgroundAlpha: 1,
1333
+ backgroundColor: 0,
1334
+ clearBeforeRender: !0
1335
+ };
1336
+ let ht = I;
1337
+ const x = {};
1338
+ R.handle(u.BlendMode, (s) => {
1339
+ if (!s.name)
1340
+ throw new Error("BlendMode extension must have a name property");
1341
+ x[s.name] = s.ref;
1342
+ }, (s) => {
1343
+ delete x[s.name];
1344
+ });
1345
+ class Te {
1346
+ constructor(e) {
1347
+ this._isAdvanced = !1, this._filterHash = /* @__PURE__ */ Object.create(null), this._renderer = e;
1348
+ }
1349
+ setBlendMode(e, t, r) {
1350
+ if (this._activeBlendMode === t) {
1351
+ this._isAdvanced && this._renderableList.push(e);
1352
+ return;
1353
+ }
1354
+ this._activeBlendMode = t, this._isAdvanced && this._endAdvancedBlendMode(r), this._isAdvanced = !!x[t], this._isAdvanced && (this._beginAdvancedBlendMode(r), this._renderableList.push(e));
1355
+ }
1356
+ _beginAdvancedBlendMode(e) {
1357
+ this._renderer.renderPipes.batch.break(e);
1358
+ const t = this._activeBlendMode;
1359
+ if (!x[t]) {
1360
+ te(`Unable to assign BlendMode: '${t}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);
1361
+ return;
1362
+ }
1363
+ let r = this._filterHash[t];
1364
+ r || (r = this._filterHash[t] = new ee(), r.filters = [new x[t]()]);
1365
+ const n = {
1366
+ renderPipeId: "filter",
1367
+ action: "pushFilter",
1368
+ renderables: [],
1369
+ filterEffect: r,
1370
+ canBundle: !1
1371
+ };
1372
+ this._renderableList = n.renderables, e.add(n);
1373
+ }
1374
+ _endAdvancedBlendMode(e) {
1375
+ this._renderableList = null, this._renderer.renderPipes.batch.break(e), e.add({
1376
+ renderPipeId: "filter",
1377
+ action: "popFilter",
1378
+ canBundle: !1
1379
+ });
1380
+ }
1381
+ buildStart() {
1382
+ this._isAdvanced = !1;
1383
+ }
1384
+ buildEnd(e) {
1385
+ this._isAdvanced && this._endAdvancedBlendMode(e);
1386
+ }
1387
+ destroy() {
1388
+ this._renderer = null, this._renderableList = null;
1389
+ for (const e in this._filterHash)
1390
+ this._filterHash[e].destroy();
1391
+ this._filterHash = null;
1392
+ }
1393
+ }
1394
+ Te.extension = {
1395
+ type: [
1396
+ u.WebGLPipes,
1397
+ u.WebGPUPipes,
1398
+ u.CanvasPipes
1399
+ ],
1400
+ name: "blendMode"
1401
+ };
1402
+ const S = {
1403
+ png: "image/png",
1404
+ jpg: "image/jpeg",
1405
+ webp: "image/webp"
1406
+ }, E = class Me {
1407
+ constructor(e) {
1408
+ this._renderer = e;
1409
+ }
1410
+ _normalizeOptions(e, t = {}) {
1411
+ return e instanceof T || e instanceof m ? {
1412
+ target: e,
1413
+ ...t
1414
+ } : {
1415
+ ...t,
1416
+ ...e
1417
+ };
1418
+ }
1419
+ async image(e) {
1420
+ const t = new Image();
1421
+ return t.src = await this.base64(e), t;
1422
+ }
1423
+ async base64(e) {
1424
+ e = this._normalizeOptions(
1425
+ e,
1426
+ Me.defaultImageOptions
1427
+ );
1428
+ const { format: t, quality: r } = e, n = this.canvas(e);
1429
+ if (n.toBlob !== void 0)
1430
+ return new Promise((a, i) => {
1431
+ n.toBlob((l) => {
1432
+ if (!l) {
1433
+ i(new Error("ICanvas.toBlob failed!"));
1434
+ return;
1435
+ }
1436
+ const o = new FileReader();
1437
+ o.onload = () => a(o.result), o.onerror = i, o.readAsDataURL(l);
1438
+ }, S[t], r);
1439
+ });
1440
+ if (n.toDataURL !== void 0)
1441
+ return n.toDataURL(S[t], r);
1442
+ if (n.convertToBlob !== void 0) {
1443
+ const a = await n.convertToBlob({ type: S[t], quality: r });
1444
+ return new Promise((i, l) => {
1445
+ const o = new FileReader();
1446
+ o.onload = () => i(o.result), o.onerror = l, o.readAsDataURL(a);
1447
+ });
1448
+ }
1449
+ throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented");
1450
+ }
1451
+ canvas(e) {
1452
+ e = this._normalizeOptions(e);
1453
+ const t = e.target, r = this._renderer;
1454
+ if (t instanceof m)
1455
+ return r.texture.generateCanvas(t);
1456
+ const n = r.textureGenerator.generateTexture(e), a = r.texture.generateCanvas(n);
1457
+ return n.destroy(), a;
1458
+ }
1459
+ pixels(e) {
1460
+ e = this._normalizeOptions(e);
1461
+ const t = e.target, r = this._renderer, n = t instanceof m ? t : r.textureGenerator.generateTexture(e), a = r.texture.getPixels(n);
1462
+ return t instanceof T && n.destroy(), a;
1463
+ }
1464
+ texture(e) {
1465
+ return e = this._normalizeOptions(e), e.target instanceof m ? e.target : this._renderer.textureGenerator.generateTexture(e);
1466
+ }
1467
+ download(e) {
1468
+ var n;
1469
+ e = this._normalizeOptions(e);
1470
+ const t = this.canvas(e), r = document.createElement("a");
1471
+ r.download = (n = e.filename) != null ? n : "image.png", r.href = t.toDataURL("image/png"), document.body.appendChild(r), r.click(), document.body.removeChild(r);
1472
+ }
1473
+ log(e) {
1474
+ var i;
1475
+ const t = (i = e.width) != null ? i : 200;
1476
+ e = this._normalizeOptions(e);
1477
+ const r = this.canvas(e), n = r.toDataURL();
1478
+ console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);
1479
+ const a = [
1480
+ "font-size: 1px;",
1481
+ `padding: ${t}px ${300}px;`,
1482
+ `background: url(${n}) no-repeat;`,
1483
+ "background-size: contain;"
1484
+ ].join(" ");
1485
+ console.log("%c ", a);
1486
+ }
1487
+ destroy() {
1488
+ this._renderer = null;
1489
+ }
1490
+ };
1491
+ E.extension = {
1492
+ type: [
1493
+ u.WebGLSystem,
1494
+ u.WebGPUSystem
1495
+ ],
1496
+ name: "extract"
1497
+ };
1498
+ E.defaultImageOptions = {
1499
+ format: "png",
1500
+ quality: 1
1501
+ };
1502
+ let ft = E;
1503
+ class D extends m {
1504
+ static create(e) {
1505
+ return new D({
1506
+ source: new re(e)
1507
+ });
1508
+ }
1509
+ resize(e, t, r) {
1510
+ return this.source.resize(e, t, r), this;
1511
+ }
1512
+ }
1513
+ const pt = new G(), mt = new Z(), vt = [0, 0, 0, 0];
1514
+ class Ce {
1515
+ constructor(e) {
1516
+ this._renderer = e;
1517
+ }
1518
+ generateTexture(e) {
1519
+ var d;
1520
+ e instanceof T && (e = {
1521
+ target: e,
1522
+ frame: void 0,
1523
+ textureSourceOptions: {},
1524
+ resolution: void 0
1525
+ });
1526
+ const t = e.resolution || this._renderer.resolution, r = e.antialias || this._renderer.view.antialias, n = e.target;
1527
+ let a = e.clearColor;
1528
+ a ? a = Array.isArray(a) && a.length === 4 ? a : ie.shared.setValue(a).toArray() : a = vt;
1529
+ const i = ((d = e.frame) == null ? void 0 : d.copyTo(pt)) || We(n, mt).rectangle;
1530
+ i.width = Math.max(i.width, 1 / t) | 0, i.height = Math.max(i.height, 1 / t) | 0;
1531
+ const l = D.create({
1532
+ ...e.textureSourceOptions,
1533
+ width: i.width,
1534
+ height: i.height,
1535
+ resolution: t,
1536
+ antialias: r
1537
+ }), o = v.shared.translate(-i.x, -i.y);
1538
+ return this._renderer.render({
1539
+ container: n,
1540
+ transform: o,
1541
+ target: l,
1542
+ clearColor: a
1543
+ }), l.source.updateMipmaps(), l;
1544
+ }
1545
+ destroy() {
1546
+ this._renderer = null;
1547
+ }
1548
+ }
1549
+ Ce.extension = {
1550
+ type: [
1551
+ u.WebGLSystem,
1552
+ u.WebGPUSystem
1553
+ ],
1554
+ name: "textureGenerator"
1555
+ };
1556
+ class Pe {
1557
+ constructor(e) {
1558
+ this._stackIndex = 0, this._globalUniformDataStack = [], this._uniformsPool = [], this._activeUniforms = [], this._bindGroupPool = [], this._activeBindGroups = [], this._renderer = e;
1559
+ }
1560
+ reset() {
1561
+ this._stackIndex = 0;
1562
+ for (let e = 0; e < this._activeUniforms.length; e++)
1563
+ this._uniformsPool.push(this._activeUniforms[e]);
1564
+ for (let e = 0; e < this._activeBindGroups.length; e++)
1565
+ this._bindGroupPool.push(this._activeBindGroups[e]);
1566
+ this._activeUniforms.length = 0, this._activeBindGroups.length = 0;
1567
+ }
1568
+ start(e) {
1569
+ this.reset(), this.push(e);
1570
+ }
1571
+ bind({
1572
+ size: e,
1573
+ projectionMatrix: t,
1574
+ worldTransformMatrix: r,
1575
+ worldColor: n,
1576
+ offset: a
1577
+ }) {
1578
+ const i = this._renderer.renderTarget.renderTarget, l = this._stackIndex ? this._globalUniformDataStack[this._stackIndex - 1] : {
1579
+ projectionData: i,
1580
+ worldTransformMatrix: new v(),
1581
+ worldColor: 4294967295,
1582
+ offset: new ze()
1583
+ }, o = {
1584
+ projectionMatrix: t || this._renderer.renderTarget.projectionMatrix,
1585
+ resolution: e || i.size,
1586
+ worldTransformMatrix: r || l.worldTransformMatrix,
1587
+ worldColor: n || l.worldColor,
1588
+ offset: a || l.offset,
1589
+ bindGroup: null
1590
+ }, d = this._uniformsPool.pop() || this._createUniforms();
1591
+ this._activeUniforms.push(d);
1592
+ const c = d.uniforms;
1593
+ c.uProjectionMatrix = o.projectionMatrix, c.uResolution = o.resolution, c.uWorldTransformMatrix.copyFrom(o.worldTransformMatrix), c.uWorldTransformMatrix.tx -= o.offset.x, c.uWorldTransformMatrix.ty -= o.offset.y, Ke(
1594
+ o.worldColor,
1595
+ c.uWorldColorAlpha,
1596
+ 0
1597
+ ), d.update();
1598
+ let h;
1599
+ this._renderer.renderPipes.uniformBatch ? h = this._renderer.renderPipes.uniformBatch.getUniformBindGroup(d, !1) : (h = this._bindGroupPool.pop() || new Ve(), this._activeBindGroups.push(h), h.setResource(d, 0)), o.bindGroup = h, this._currentGlobalUniformData = o;
1600
+ }
1601
+ push(e) {
1602
+ this.bind(e), this._globalUniformDataStack[this._stackIndex++] = this._currentGlobalUniformData;
1603
+ }
1604
+ pop() {
1605
+ this._currentGlobalUniformData = this._globalUniformDataStack[--this._stackIndex - 1], this._renderer.type === B.WEBGL && this._currentGlobalUniformData.bindGroup.resources[0].update();
1606
+ }
1607
+ get bindGroup() {
1608
+ return this._currentGlobalUniformData.bindGroup;
1609
+ }
1610
+ get globalUniformData() {
1611
+ return this._currentGlobalUniformData;
1612
+ }
1613
+ get uniformGroup() {
1614
+ return this._currentGlobalUniformData.bindGroup.resources[0];
1615
+ }
1616
+ _createUniforms() {
1617
+ return new X({
1618
+ uProjectionMatrix: { value: new v(), type: "mat3x3<f32>" },
1619
+ uWorldTransformMatrix: { value: new v(), type: "mat3x3<f32>" },
1620
+ uWorldColorAlpha: { value: new Float32Array(4), type: "vec4<f32>" },
1621
+ uResolution: { value: [0, 0], type: "vec2<f32>" }
1622
+ }, {
1623
+ isStatic: !0
1624
+ });
1625
+ }
1626
+ destroy() {
1627
+ this._renderer = null;
1628
+ }
1629
+ }
1630
+ Pe.extension = {
1631
+ type: [
1632
+ u.WebGLSystem,
1633
+ u.WebGPUSystem,
1634
+ u.CanvasSystem
1635
+ ],
1636
+ name: "globalUniforms"
1637
+ };
1638
+ let gt = 1;
1639
+ class Se {
1640
+ constructor() {
1641
+ this._tasks = [], this._offset = 0;
1642
+ }
1643
+ init() {
1644
+ N.system.add(this._update, this);
1645
+ }
1646
+ repeat(e, t, r = !0) {
1647
+ const n = gt++;
1648
+ let a = 0;
1649
+ return r && (this._offset += 1e3, a = this._offset), this._tasks.push({
1650
+ func: e,
1651
+ duration: t,
1652
+ start: performance.now(),
1653
+ offset: a,
1654
+ last: performance.now(),
1655
+ repeat: !0,
1656
+ id: n
1657
+ }), n;
1658
+ }
1659
+ cancel(e) {
1660
+ for (let t = 0; t < this._tasks.length; t++)
1661
+ if (this._tasks[t].id === e) {
1662
+ this._tasks.splice(t, 1);
1663
+ return;
1664
+ }
1665
+ }
1666
+ _update() {
1667
+ const e = performance.now();
1668
+ for (let t = 0; t < this._tasks.length; t++) {
1669
+ const r = this._tasks[t];
1670
+ if (e - r.offset - r.last >= r.duration) {
1671
+ const n = e - r.start;
1672
+ r.func(n), r.last = e;
1673
+ }
1674
+ }
1675
+ }
1676
+ destroy() {
1677
+ N.system.remove(this._update, this), this._tasks.length = 0;
1678
+ }
1679
+ }
1680
+ Se.extension = {
1681
+ type: [
1682
+ u.WebGLSystem,
1683
+ u.WebGPUSystem,
1684
+ u.CanvasSystem
1685
+ ],
1686
+ name: "scheduler",
1687
+ priority: 0
1688
+ };
1689
+ let J = !1;
1690
+ function _t(s) {
1691
+ if (!J) {
1692
+ if (je.get().getNavigator().userAgent.toLowerCase().indexOf("chrome") > -1) {
1693
+ const e = [
1694
+ `%c %c %c %c %c PixiJS %c v${$} (${s}) http://www.pixijs.com/
1695
+
1696
+ `,
1697
+ "background: #E72264; padding:5px 0;",
1698
+ "background: #6CA2EA; padding:5px 0;",
1699
+ "background: #B5D33D; padding:5px 0;",
1700
+ "background: #FED23F; padding:5px 0;",
1701
+ "color: #FFFFFF; background: #E72264; padding:5px 0;",
1702
+ "color: #E72264; background: #FFFFFF; padding:5px 0;"
1703
+ ];
1704
+ globalThis.console.log(...e);
1705
+ } else
1706
+ globalThis.console && globalThis.console.log(`PixiJS ${$} - ${s} - http://www.pixijs.com/`);
1707
+ J = !0;
1708
+ }
1709
+ }
1710
+ class F {
1711
+ constructor(e) {
1712
+ this._renderer = e;
1713
+ }
1714
+ init(e) {
1715
+ if (e.hello) {
1716
+ let t = this._renderer.name;
1717
+ this._renderer.type === B.WEBGL && (t += ` ${this._renderer.context.webGLVersion}`), _t(t);
1718
+ }
1719
+ }
1720
+ }
1721
+ F.extension = {
1722
+ type: [
1723
+ u.WebGLSystem,
1724
+ u.WebGPUSystem,
1725
+ u.CanvasSystem
1726
+ ],
1727
+ name: "hello",
1728
+ priority: -2
1729
+ };
1730
+ F.defaultOptions = {
1731
+ hello: !1
1732
+ };
1733
+ function bt(s) {
1734
+ let e = !1;
1735
+ for (const r in s)
1736
+ if (s[r] == null) {
1737
+ e = !0;
1738
+ break;
1739
+ }
1740
+ if (!e)
1741
+ return s;
1742
+ const t = /* @__PURE__ */ Object.create(null);
1743
+ for (const r in s) {
1744
+ const n = s[r];
1745
+ n && (t[r] = n);
1746
+ }
1747
+ return t;
1748
+ }
1749
+ function xt(s) {
1750
+ let e = 0;
1751
+ for (let t = 0; t < s.length; t++)
1752
+ s[t] == null ? e++ : s[t - e] = s[t];
1753
+ return s.length = s.length - e, s;
1754
+ }
1755
+ const O = class we {
1756
+ constructor(e) {
1757
+ this._managedRenderables = [], this._managedHashes = [], this._managedArrays = [], this._renderer = e;
1758
+ }
1759
+ init(e) {
1760
+ e = { ...we.defaultOptions, ...e }, this.maxUnusedTime = e.renderableGCMaxUnusedTime, this._frequency = e.renderableGCFrequency, this.enabled = e.renderableGCActive;
1761
+ }
1762
+ get enabled() {
1763
+ return !!this._handler;
1764
+ }
1765
+ set enabled(e) {
1766
+ this.enabled !== e && (e ? (this._handler = this._renderer.scheduler.repeat(
1767
+ () => this.run(),
1768
+ this._frequency,
1769
+ !1
1770
+ ), this._hashHandler = this._renderer.scheduler.repeat(
1771
+ () => {
1772
+ for (const t of this._managedHashes)
1773
+ t.context[t.hash] = bt(t.context[t.hash]);
1774
+ },
1775
+ this._frequency
1776
+ ), this._arrayHandler = this._renderer.scheduler.repeat(
1777
+ () => {
1778
+ for (const t of this._managedArrays)
1779
+ xt(t.context[t.hash]);
1780
+ },
1781
+ this._frequency
1782
+ )) : (this._renderer.scheduler.cancel(this._handler), this._renderer.scheduler.cancel(this._hashHandler), this._renderer.scheduler.cancel(this._arrayHandler)));
1783
+ }
1784
+ addManagedHash(e, t) {
1785
+ this._managedHashes.push({ context: e, hash: t });
1786
+ }
1787
+ addManagedArray(e, t) {
1788
+ this._managedArrays.push({ context: e, hash: t });
1789
+ }
1790
+ prerender() {
1791
+ this._now = performance.now();
1792
+ }
1793
+ addRenderable(e, t) {
1794
+ !this.enabled || (e._lastUsed = this._now, e._lastInstructionTick === -1 && (this._managedRenderables.push(e), e.once("destroyed", this._removeRenderable, this)), e._lastInstructionTick = t.tick);
1795
+ }
1796
+ run() {
1797
+ var a, i, l;
1798
+ const e = performance.now(), t = this._managedRenderables, r = this._renderer.renderPipes;
1799
+ let n = 0;
1800
+ for (let o = 0; o < t.length; o++) {
1801
+ const d = t[o];
1802
+ if (d === null) {
1803
+ n++;
1804
+ continue;
1805
+ }
1806
+ const c = (a = d.renderGroup) != null ? a : d.parentRenderGroup, h = (l = (i = c == null ? void 0 : c.instructionSet) == null ? void 0 : i.tick) != null ? l : -1;
1807
+ d._lastInstructionTick !== h && e - d._lastUsed > this.maxUnusedTime ? (d.destroyed || r[d.renderPipeId].destroyRenderable(d), d._lastInstructionTick = -1, n++, d.off("destroyed", this._removeRenderable, this)) : t[o - n] = d;
1808
+ }
1809
+ t.length = t.length - n;
1810
+ }
1811
+ destroy() {
1812
+ this.enabled = !1, this._renderer = null, this._managedRenderables.length = 0, this._managedHashes.length = 0, this._managedArrays.length = 0;
1813
+ }
1814
+ _removeRenderable(e) {
1815
+ const t = this._managedRenderables.indexOf(e);
1816
+ t >= 0 && (e.off("destroyed", this._removeRenderable, this), this._managedRenderables[t] = null);
1817
+ }
1818
+ };
1819
+ O.extension = {
1820
+ type: [
1821
+ u.WebGLSystem,
1822
+ u.WebGPUSystem
1823
+ ],
1824
+ name: "renderableGC",
1825
+ priority: 0
1826
+ };
1827
+ O.defaultOptions = {
1828
+ renderableGCActive: !0,
1829
+ renderableGCMaxUnusedTime: 6e4,
1830
+ renderableGCFrequency: 3e4
1831
+ };
1832
+ let yt = O;
1833
+ const H = class Ge {
1834
+ constructor(e) {
1835
+ this._renderer = e, this.count = 0, this.checkCount = 0;
1836
+ }
1837
+ init(e) {
1838
+ var t;
1839
+ e = { ...Ge.defaultOptions, ...e }, this.checkCountMax = e.textureGCCheckCountMax, this.maxIdle = (t = e.textureGCAMaxIdle) != null ? t : e.textureGCMaxIdle, this.active = e.textureGCActive;
1840
+ }
1841
+ postrender() {
1842
+ !this._renderer.renderingToScreen || (this.count++, this.active && (this.checkCount++, this.checkCount > this.checkCountMax && (this.checkCount = 0, this.run())));
1843
+ }
1844
+ run() {
1845
+ const e = this._renderer.texture.managedTextures;
1846
+ for (let t = 0; t < e.length; t++) {
1847
+ const r = e[t];
1848
+ r.autoGarbageCollect && r.resource && r._touched > -1 && this.count - r._touched > this.maxIdle && (r._touched = -1, r.unload());
1849
+ }
1850
+ }
1851
+ destroy() {
1852
+ this._renderer = null;
1853
+ }
1854
+ };
1855
+ H.extension = {
1856
+ type: [
1857
+ u.WebGLSystem,
1858
+ u.WebGPUSystem
1859
+ ],
1860
+ name: "textureGC"
1861
+ };
1862
+ H.defaultOptions = {
1863
+ textureGCActive: !0,
1864
+ textureGCAMaxIdle: null,
1865
+ textureGCMaxIdle: 60 * 60,
1866
+ textureGCCheckCountMax: 600
1867
+ };
1868
+ let kt = H;
1869
+ const It = [
1870
+ ht,
1871
+ Pe,
1872
+ F,
1873
+ Ne,
1874
+ xe,
1875
+ kt,
1876
+ Ce,
1877
+ ft,
1878
+ $e,
1879
+ yt,
1880
+ Se
1881
+ ], Et = [
1882
+ Te,
1883
+ le,
1884
+ ye,
1885
+ me,
1886
+ ue,
1887
+ he,
1888
+ ce,
1889
+ fe
1890
+ ];
1891
+ export {
1892
+ At as B,
1893
+ _ as G,
1894
+ Ut as R,
1895
+ It as S,
1896
+ Gt as U,
1897
+ Et as a,
1898
+ st as b,
1899
+ Rt as c,
1900
+ k as d,
1901
+ wt as e,
1902
+ St as f,
1903
+ Pt as t,
1904
+ Bt as u
1905
+ };