shaders 2.2.23 → 2.2.25

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 (213) hide show
  1. package/dist/core/AngularBlur-Dl2gwk68.js +64 -0
  2. package/dist/core/Ascii-Dha_QpT3.js +286 -0
  3. package/dist/core/Beam-CTN9Ni43.js +139 -0
  4. package/dist/core/Blob-CxFDZovO.js +218 -0
  5. package/dist/core/Blur-Y2FsmFk_.js +77 -0
  6. package/dist/core/Bulge-Cb-t0xqI.js +132 -0
  7. package/dist/core/CRTScreen-CtERsenz.js +112 -0
  8. package/dist/core/ChannelBlur-CvM6GJgZ.js +118 -0
  9. package/dist/core/Checkerboard-CgB-egNY.js +83 -0
  10. package/dist/core/ChromaFlow-vRCwhQpN.js +222 -0
  11. package/dist/core/ChromaticAberration-FTquTQIL.js +88 -0
  12. package/dist/core/Circle-Daziv5d7.js +67 -0
  13. package/dist/core/CursorTrail-Bsz9e6Fn.js +145 -0
  14. package/dist/core/DiffuseBlur-Cj2PtRNd.js +83 -0
  15. package/dist/core/Dither-D2Nf4p3w.js +66 -0
  16. package/dist/core/DotGrid-CzOwquo4.js +75 -0
  17. package/dist/core/Duotone-XuTN9tI7.js +65 -0
  18. package/dist/core/FilmGrain-D3-nbi12.js +28 -0
  19. package/dist/core/FloatingParticles-D9Nnu1qg.js +217 -0
  20. package/dist/core/GlassTiles-CnjCvajI.js +69 -0
  21. package/dist/core/Glow-BluFc9be.js +75 -0
  22. package/dist/core/Godrays-ChLh_vGl.js +144 -0
  23. package/dist/core/Grayscale-DRny75A9.js +20 -0
  24. package/dist/core/Grid-DgyDa4H1.js +58 -0
  25. package/dist/core/GridDistortion-BAspCYvp.js +188 -0
  26. package/dist/core/Group-Dul7PUBl.js +14 -0
  27. package/dist/core/Halftone-Ifv5F_FT.js +65 -0
  28. package/dist/core/HueShift-De8ukMWs.js +31 -0
  29. package/dist/core/ImageTexture-DvYcQgJB.js +143 -0
  30. package/dist/core/Invert-Fz0NtIJc.js +21 -0
  31. package/dist/core/LinearBlur-LmhnQoA4.js +62 -0
  32. package/dist/core/LinearGradient-xbloQjzt.js +133 -0
  33. package/dist/core/Liquify-DMe1V5-O.js +175 -0
  34. package/dist/core/Pixelate-Cv8537Pj.js +37 -0
  35. package/dist/core/PolarCoordinates-DDvDhBE-.js +112 -0
  36. package/dist/core/Posterize-3m3xkWOz.js +29 -0
  37. package/dist/core/ProgressiveBlur-EGkevObV.js +121 -0
  38. package/dist/core/RadialGradient-B7ZZB_VJ.js +71 -0
  39. package/dist/core/RectangularCoordinates-muWR8mZS.js +101 -0
  40. package/dist/core/Ripples-8XaZaXQF.js +117 -0
  41. package/dist/core/Saturation-CYFI1jzN.js +30 -0
  42. package/dist/core/SimplexNoise-DJUe0wz_.js +99 -0
  43. package/dist/core/SineWave-Dl3nFO1W.js +120 -0
  44. package/dist/core/SolidColor-CWGq_Bjq.js +21 -0
  45. package/dist/core/Spherize-C-jZEUsN.js +128 -0
  46. package/dist/core/Spiral-BSB_R39p.js +132 -0
  47. package/dist/core/Strands-0stO5BMy.js +161 -0
  48. package/dist/core/Stretch-B645paha.js +133 -0
  49. package/dist/core/Swirl-CVnbawit.js +173 -0
  50. package/dist/core/TiltShift-0CxNRI6L.js +134 -0
  51. package/dist/core/Tritone-Daa-I5UD.js +76 -0
  52. package/dist/core/Twirl-2CJVZEtk.js +96 -0
  53. package/dist/core/Vibrance-DRtecEvb.js +30 -0
  54. package/dist/core/WaveDistortion-BscXN2rs.js +173 -0
  55. package/dist/core/ZoomBlur-CAqK0Kju.js +62 -0
  56. package/dist/core/colorMixing-BXiTAqJU.js +69 -0
  57. package/dist/core/edges-Bn_OIa_h.js +26 -0
  58. package/dist/core/index.js +2257 -1604
  59. package/dist/core/shaderRegistry.d.ts.map +1 -1
  60. package/dist/core/shaders/AngularBlur/index.js +3 -7
  61. package/dist/core/shaders/Ascii/index.js +2 -6
  62. package/dist/core/shaders/Beam/index.d.ts +71 -0
  63. package/dist/core/shaders/Beam/index.d.ts.map +1 -0
  64. package/dist/core/shaders/Beam/index.js +4 -0
  65. package/dist/core/shaders/Blob/index.js +5 -9
  66. package/dist/core/shaders/Blur/index.js +2 -6
  67. package/dist/core/shaders/Bulge/index.js +4 -8
  68. package/dist/core/shaders/CRTScreen/index.js +2 -6
  69. package/dist/core/shaders/ChannelBlur/index.js +2 -6
  70. package/dist/core/shaders/Checkerboard/index.js +4 -8
  71. package/dist/core/shaders/ChromaFlow/index.js +3 -7
  72. package/dist/core/shaders/ChromaticAberration/index.js +3 -7
  73. package/dist/core/shaders/Circle/index.js +3 -7
  74. package/dist/core/shaders/CursorTrail/index.js +4 -8
  75. package/dist/core/shaders/DiffuseBlur/index.js +4 -8
  76. package/dist/core/shaders/Dither/index.js +3 -7
  77. package/dist/core/shaders/DotGrid/index.js +3 -7
  78. package/dist/core/shaders/Duotone/index.js +4 -8
  79. package/dist/core/shaders/FilmGrain/index.js +2 -6
  80. package/dist/core/shaders/FloatingParticles/index.js +3 -7
  81. package/dist/core/shaders/GlassTiles/index.js +2 -6
  82. package/dist/core/shaders/Glow/index.js +2 -6
  83. package/dist/core/shaders/Godrays/index.js +3 -7
  84. package/dist/core/shaders/Grayscale/index.js +2 -8
  85. package/dist/core/shaders/Grid/index.js +3 -7
  86. package/dist/core/shaders/GridDistortion/index.js +4 -8
  87. package/dist/core/shaders/Group/index.js +2 -6
  88. package/dist/core/shaders/Halftone/index.js +3 -7
  89. package/dist/core/shaders/HueShift/index.js +2 -8
  90. package/dist/core/shaders/ImageTexture/index.js +2 -6
  91. package/dist/core/shaders/Invert/index.js +2 -6
  92. package/dist/core/shaders/LinearBlur/index.js +3 -7
  93. package/dist/core/shaders/LinearGradient/index.js +4 -8
  94. package/dist/core/shaders/Liquify/index.js +4 -8
  95. package/dist/core/shaders/Pixelate/index.js +2 -6
  96. package/dist/core/shaders/PolarCoordinates/index.js +4 -8
  97. package/dist/core/shaders/Posterize/index.js +2 -7
  98. package/dist/core/shaders/ProgressiveBlur/index.js +3 -7
  99. package/dist/core/shaders/RadialGradient/index.js +4 -8
  100. package/dist/core/shaders/RectangularCoordinates/index.js +4 -8
  101. package/dist/core/shaders/Ripples/index.js +5 -9
  102. package/dist/core/shaders/Saturation/index.js +2 -8
  103. package/dist/core/shaders/SimplexNoise/index.js +5 -9
  104. package/dist/core/shaders/SineWave/index.js +3 -7
  105. package/dist/core/shaders/SolidColor/index.js +3 -7
  106. package/dist/core/shaders/Spherize/index.js +3 -7
  107. package/dist/core/shaders/Spiral/index.js +4 -8
  108. package/dist/core/shaders/Strands/index.js +4 -8
  109. package/dist/core/shaders/Stretch/index.js +4 -8
  110. package/dist/core/shaders/Swirl/index.js +5 -9
  111. package/dist/core/shaders/TiltShift/index.js +3 -7
  112. package/dist/core/shaders/Tritone/index.js +4 -8
  113. package/dist/core/shaders/Twirl/index.js +4 -8
  114. package/dist/core/shaders/Vibrance/index.js +2 -8
  115. package/dist/core/shaders/WaveDistortion/index.js +4 -8
  116. package/dist/core/shaders/ZoomBlur/index.js +3 -7
  117. package/dist/core/telemetry/index.js +189 -157
  118. package/dist/core/time-CTJvRUZ4.js +10 -0
  119. package/dist/core/transformations-DxfQXZWi.js +4715 -0
  120. package/dist/react/components/Beam.d.ts +31 -0
  121. package/dist/react/components/Beam.d.ts.map +1 -0
  122. package/dist/react/generatePresetCode-CCibXbtZ.js +645 -0
  123. package/dist/react/index.d.ts +1 -0
  124. package/dist/react/index.d.ts.map +1 -1
  125. package/dist/react/index.js +7649 -104600
  126. package/dist/react/utils/generatePresetCode.d.ts.map +1 -1
  127. package/dist/react/utils/generatePresetCode.js +2 -5
  128. package/dist/registry.js +224 -0
  129. package/dist/solid/components/Beam.d.ts +28 -0
  130. package/dist/solid/components/Beam.d.ts.map +1 -0
  131. package/dist/solid/index.d.ts +1 -0
  132. package/dist/solid/index.d.ts.map +1 -1
  133. package/dist/solid/index.js +6691 -102524
  134. package/dist/solid/utils/generatePresetCode.d.ts.map +1 -1
  135. package/dist/solid/utils/generatePresetCode.js +586 -537
  136. package/dist/svelte/components/Beam.svelte.d.ts +19 -0
  137. package/dist/svelte/generatePresetCode-CymgoDq_.js +645 -0
  138. package/dist/svelte/index.d.ts +1 -0
  139. package/dist/svelte/index.js +6175 -102455
  140. package/dist/svelte/utils/generatePresetCode.js +2 -5
  141. package/dist/vue/components/Beam.vue.d.ts +57 -0
  142. package/dist/vue/components/Beam.vue.d.ts.map +1 -0
  143. package/dist/vue/generatePresetCode-CRJmU8iF.js +649 -0
  144. package/dist/vue/index.d.ts +1 -0
  145. package/dist/vue/index.d.ts.map +1 -1
  146. package/dist/vue/index.js +6929 -103492
  147. package/dist/vue/utils/generatePresetCode.d.ts.map +1 -1
  148. package/dist/vue/utils/generatePresetCode.js +2 -5
  149. package/package.json +12 -1
  150. package/dist/core/AngularBlur-ClvtyURQ.js +0 -56
  151. package/dist/core/Ascii-BT0-K_vw.js +0 -196
  152. package/dist/core/Blob-BlQ_1T_8.js +0 -169
  153. package/dist/core/Blur-421AjWLH.js +0 -64
  154. package/dist/core/Bulge-CZRVoR6C.js +0 -103
  155. package/dist/core/CRTScreen-C_U9g_IR.js +0 -91
  156. package/dist/core/ChannelBlur-5pzcB6Zv.js +0 -89
  157. package/dist/core/Checkerboard-CrQkqXhD.js +0 -75
  158. package/dist/core/ChromaFlow-CNrQdL8f.js +0 -134
  159. package/dist/core/ChromaticAberration-D9H7O17Y.js +0 -82
  160. package/dist/core/Circle-DnLaDn8V.js +0 -62
  161. package/dist/core/ColorAdjustment-CKwpE_4M.js +0 -14
  162. package/dist/core/CursorTrail-NY6n97VG.js +0 -105
  163. package/dist/core/DiffuseBlur-C_n01ABk.js +0 -69
  164. package/dist/core/Dither-4s-c4zh4.js +0 -61
  165. package/dist/core/DotGrid-BYl8XdMi.js +0 -61
  166. package/dist/core/Duotone-DbewOoB4.js +0 -66
  167. package/dist/core/FilmGrain-zA_-knOw.js +0 -28
  168. package/dist/core/FloatingParticles-BhVnqMsE.js +0 -160
  169. package/dist/core/GlassTiles-CFI57glh.js +0 -52
  170. package/dist/core/Glow-CQgl3IoS.js +0 -66
  171. package/dist/core/Godrays-BHMix_Bh.js +0 -105
  172. package/dist/core/Grayscale-CAEFLteL.js +0 -21
  173. package/dist/core/Grid-DlM-rVbZ.js +0 -50
  174. package/dist/core/GridDistortion-ZOZphSAT.js +0 -147
  175. package/dist/core/Group-BQAs3RiH.js +0 -17
  176. package/dist/core/Halftone-ci4ga-_J.js +0 -55
  177. package/dist/core/HueShift-CyxzPcJV.js +0 -32
  178. package/dist/core/ImageTexture-CdAGsPuH.js +0 -105
  179. package/dist/core/Invert-iPsiIqNZ.js +0 -20
  180. package/dist/core/LinearBlur-BEaaoIk-.js +0 -56
  181. package/dist/core/LinearGradient-DR_7RxLX.js +0 -111
  182. package/dist/core/Liquify-Bi02_ugh.js +0 -139
  183. package/dist/core/Pixelate-CSsdT1rr.js +0 -38
  184. package/dist/core/PolarCoordinates-D626ml58.js +0 -103
  185. package/dist/core/Posterize-DhZkMaC7.js +0 -46
  186. package/dist/core/ProgressiveBlur-CGtCfLF8.js +0 -102
  187. package/dist/core/RadialGradient-C0_WzmbH.js +0 -71
  188. package/dist/core/RectangularCoordinates-DfXw7fhI.js +0 -92
  189. package/dist/core/Ripples-DkemN3eh.js +0 -106
  190. package/dist/core/Saturation-Dup81Pnq.js +0 -31
  191. package/dist/core/SimplexNoise-BYEiCjDj.js +0 -94
  192. package/dist/core/SineWave-C6MRPtsy.js +0 -107
  193. package/dist/core/SolidColor-BZHRczgb.js +0 -22
  194. package/dist/core/Spherize-DOAnDx2l.js +0 -103
  195. package/dist/core/Spiral-BMjnWXh1.js +0 -115
  196. package/dist/core/Strands-BOVsuJLe.js +0 -125
  197. package/dist/core/Stretch-D6bHc6yp.js +0 -103
  198. package/dist/core/Swirl-BFoc0ImG.js +0 -148
  199. package/dist/core/TSLBase-BFMvTOak.js +0 -8053
  200. package/dist/core/TiltShift-BiNvvhzj.js +0 -114
  201. package/dist/core/Tritone-gdx2AA0m.js +0 -75
  202. package/dist/core/Twirl-BsV8YbqC.js +0 -82
  203. package/dist/core/Vibrance-C182fbSw.js +0 -31
  204. package/dist/core/WaveDistortion-CmaS2zDB.js +0 -132
  205. package/dist/core/ZoomBlur-DLf5xQ16.js +0 -56
  206. package/dist/core/colorMixing--dhzx0ch.js +0 -21
  207. package/dist/core/edges-CDzKsauJ.js +0 -15
  208. package/dist/core/three.tsl-Btj1hLsf.js +0 -43845
  209. package/dist/core/time-DbRMw6Jm.js +0 -10
  210. package/dist/core/transformations-CsrIJXh-.js +0 -3992
  211. package/dist/react/generatePresetCode-DaS7jkcT.js +0 -626
  212. package/dist/svelte/generatePresetCode-DaS7jkcT.js +0 -626
  213. package/dist/vue/generatePresetCode-Cd1B-Y9j.js +0 -632
@@ -1,1648 +1,2301 @@
1
- import { B as Nn, C as Vn, E as R, F as He, I as qn, L as Pn, M as S, N as ye, O as le, P as ln, R as Xn, T as Se, V as Yn, _ as l, b as W, c as In, d as j, g as Me, h as We, i as Hn, j as N, k as G, l as bn, m as je, n as y, o as Wn, s as jn, t as Qn, w as vn, x as de, z as Jn } from "./three.tsl-Btj1hLsf.js";
2
- import { n as re, t as he } from "./edges-CDzKsauJ.js";
3
- import { t as Qr } from "./time-DbRMw6Jm.js";
4
- import "./transformations-CsrIJXh-.js";
5
- import { n as Zn } from "./AngularBlur-ClvtyURQ.js";
6
- import { n as Kn } from "./Ascii-BT0-K_vw.js";
7
- import "./colorMixing--dhzx0ch.js";
8
- import { n as et } from "./Blob-BlQ_1T_8.js";
9
- import { n as nt } from "./Blur-421AjWLH.js";
10
- import { n as tt } from "./Bulge-CZRVoR6C.js";
11
- import { n as rt } from "./ChannelBlur-5pzcB6Zv.js";
12
- import { n as ot } from "./Checkerboard-CrQkqXhD.js";
13
- import { n as it } from "./ChromaFlow-CNrQdL8f.js";
14
- import { n as at } from "./ChromaticAberration-D9H7O17Y.js";
15
- import { n as st } from "./Circle-DnLaDn8V.js";
16
- import { n as lt } from "./CRTScreen-C_U9g_IR.js";
17
- import { n as ct } from "./CursorTrail-NY6n97VG.js";
18
- import { n as ft } from "./DiffuseBlur-C_n01ABk.js";
19
- import { n as ut } from "./Dither-4s-c4zh4.js";
20
- import { n as mt } from "./DotGrid-BYl8XdMi.js";
21
- import { n as dt } from "./Duotone-DbewOoB4.js";
22
- import { n as ht } from "./FilmGrain-zA_-knOw.js";
23
- import { n as pt } from "./FloatingParticles-BhVnqMsE.js";
24
- import { n as gt } from "./GlassTiles-CFI57glh.js";
25
- import { n as bt } from "./Glow-CQgl3IoS.js";
26
- import { n as vt } from "./Godrays-BHMix_Bh.js";
27
- import "./TSLBase-BFMvTOak.js";
28
- import "./ColorAdjustment-CKwpE_4M.js";
29
- import { n as Ct } from "./Grayscale-CAEFLteL.js";
30
- import { n as Rt } from "./Grid-DlM-rVbZ.js";
31
- import { n as kt } from "./GridDistortion-ZOZphSAT.js";
32
- import { n as Tt } from "./Group-BQAs3RiH.js";
33
- import { n as yt } from "./Halftone-ci4ga-_J.js";
34
- import { n as wt } from "./HueShift-CyxzPcJV.js";
35
- import { n as Ut } from "./ImageTexture-CdAGsPuH.js";
36
- import { n as St } from "./Invert-iPsiIqNZ.js";
37
- import { n as Mt } from "./LinearBlur-BEaaoIk-.js";
38
- import { n as xt } from "./LinearGradient-DR_7RxLX.js";
39
- import { n as At } from "./Liquify-Bi02_ugh.js";
40
- import { n as zt } from "./Pixelate-CSsdT1rr.js";
41
- import { n as Dt } from "./PolarCoordinates-D626ml58.js";
42
- import { n as Et } from "./Posterize-DhZkMaC7.js";
43
- import { n as Ft } from "./ProgressiveBlur-CGtCfLF8.js";
44
- import { n as $t } from "./RadialGradient-C0_WzmbH.js";
45
- import { n as Ot } from "./RectangularCoordinates-DfXw7fhI.js";
46
- import { n as Bt } from "./Ripples-DkemN3eh.js";
47
- import { n as _t } from "./Saturation-Dup81Pnq.js";
48
- import { n as Lt } from "./SimplexNoise-BYEiCjDj.js";
49
- import { n as Gt } from "./SineWave-C6MRPtsy.js";
50
- import { n as Nt } from "./SolidColor-BZHRczgb.js";
51
- import { n as Vt } from "./Spherize-DOAnDx2l.js";
52
- import { n as qt } from "./Spiral-BMjnWXh1.js";
53
- import { n as Pt } from "./Strands-BOVsuJLe.js";
54
- import { n as Xt } from "./Stretch-D6bHc6yp.js";
55
- import { n as Yt } from "./Swirl-BFoc0ImG.js";
56
- import { n as It } from "./TiltShift-BiNvvhzj.js";
57
- import { n as Ht } from "./Tritone-gdx2AA0m.js";
58
- import { n as Wt } from "./Twirl-BsV8YbqC.js";
59
- import { n as jt } from "./Vibrance-C182fbSw.js";
60
- import { n as Qt } from "./WaveDistortion-CmaS2zDB.js";
61
- import { n as Jt } from "./ZoomBlur-DLf5xQ16.js";
62
- import { WebGLRenderer as Zt } from "three";
63
- function Kt(e, n, s = 1) {
64
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
65
- return S(y(l(n.rgb, t), l(e.rgb, l(e.a, R(1, t)))), u);
1
+ import { n as applyEdgeToUV, t as applyEdgeHandling } from "./edges-Bn_OIa_h.js";
2
+ import { t as createAnimatedTime } from "./time-CTJvRUZ4.js";
3
+ import "./transformations-DxfQXZWi.js";
4
+ import { n as componentDefinition } from "./AngularBlur-Dl2gwk68.js";
5
+ import { n as componentDefinition$1 } from "./Ascii-Dha_QpT3.js";
6
+ import "./colorMixing-BXiTAqJU.js";
7
+ import { n as componentDefinition$2 } from "./Beam-CTN9Ni43.js";
8
+ import { n as componentDefinition$3 } from "./Blob-CxFDZovO.js";
9
+ import { n as componentDefinition$4 } from "./Blur-Y2FsmFk_.js";
10
+ import { n as componentDefinition$5 } from "./Bulge-Cb-t0xqI.js";
11
+ import { n as componentDefinition$6 } from "./ChannelBlur-CvM6GJgZ.js";
12
+ import { n as componentDefinition$7 } from "./Checkerboard-CgB-egNY.js";
13
+ import { n as componentDefinition$8 } from "./ChromaFlow-vRCwhQpN.js";
14
+ import { n as componentDefinition$9 } from "./ChromaticAberration-FTquTQIL.js";
15
+ import { n as componentDefinition$10 } from "./Circle-Daziv5d7.js";
16
+ import { n as componentDefinition$11 } from "./CRTScreen-CtERsenz.js";
17
+ import { n as componentDefinition$12 } from "./CursorTrail-Bsz9e6Fn.js";
18
+ import { n as componentDefinition$13 } from "./DiffuseBlur-Cj2PtRNd.js";
19
+ import { n as componentDefinition$14 } from "./Dither-D2Nf4p3w.js";
20
+ import { n as componentDefinition$15 } from "./DotGrid-CzOwquo4.js";
21
+ import { n as componentDefinition$16 } from "./Duotone-XuTN9tI7.js";
22
+ import { n as componentDefinition$17 } from "./FilmGrain-D3-nbi12.js";
23
+ import { n as componentDefinition$18 } from "./FloatingParticles-D9Nnu1qg.js";
24
+ import { n as componentDefinition$19 } from "./GlassTiles-CnjCvajI.js";
25
+ import { n as componentDefinition$20 } from "./Glow-BluFc9be.js";
26
+ import { n as componentDefinition$21 } from "./Godrays-ChLh_vGl.js";
27
+ import { n as componentDefinition$22 } from "./Grayscale-DRny75A9.js";
28
+ import { n as componentDefinition$23 } from "./Grid-DgyDa4H1.js";
29
+ import { n as componentDefinition$24 } from "./GridDistortion-BAspCYvp.js";
30
+ import { n as componentDefinition$25 } from "./Group-Dul7PUBl.js";
31
+ import { n as componentDefinition$26 } from "./Halftone-Ifv5F_FT.js";
32
+ import { n as componentDefinition$27 } from "./HueShift-De8ukMWs.js";
33
+ import { n as componentDefinition$28 } from "./ImageTexture-DvYcQgJB.js";
34
+ import { n as componentDefinition$29 } from "./Invert-Fz0NtIJc.js";
35
+ import { n as componentDefinition$30 } from "./LinearBlur-LmhnQoA4.js";
36
+ import { n as componentDefinition$31 } from "./LinearGradient-xbloQjzt.js";
37
+ import { n as componentDefinition$32 } from "./Liquify-DMe1V5-O.js";
38
+ import { n as componentDefinition$33 } from "./Pixelate-Cv8537Pj.js";
39
+ import { n as componentDefinition$34 } from "./PolarCoordinates-DDvDhBE-.js";
40
+ import { n as componentDefinition$35 } from "./Posterize-3m3xkWOz.js";
41
+ import { n as componentDefinition$36 } from "./ProgressiveBlur-EGkevObV.js";
42
+ import { n as componentDefinition$37 } from "./RadialGradient-B7ZZB_VJ.js";
43
+ import { n as componentDefinition$38 } from "./RectangularCoordinates-muWR8mZS.js";
44
+ import { n as componentDefinition$39 } from "./Ripples-8XaZaXQF.js";
45
+ import { n as componentDefinition$40 } from "./Saturation-CYFI1jzN.js";
46
+ import { n as componentDefinition$41 } from "./SimplexNoise-DJUe0wz_.js";
47
+ import { n as componentDefinition$42 } from "./SineWave-Dl3nFO1W.js";
48
+ import { n as componentDefinition$43 } from "./SolidColor-CWGq_Bjq.js";
49
+ import { n as componentDefinition$44 } from "./Spherize-C-jZEUsN.js";
50
+ import { n as componentDefinition$45 } from "./Spiral-BSB_R39p.js";
51
+ import { n as componentDefinition$46 } from "./Strands-0stO5BMy.js";
52
+ import { n as componentDefinition$47 } from "./Stretch-B645paha.js";
53
+ import { n as componentDefinition$48 } from "./Swirl-CVnbawit.js";
54
+ import { n as componentDefinition$49 } from "./TiltShift-0CxNRI6L.js";
55
+ import { n as componentDefinition$50 } from "./Tritone-Daa-I5UD.js";
56
+ import { n as componentDefinition$51 } from "./Twirl-2CJVZEtk.js";
57
+ import { n as componentDefinition$52 } from "./Vibrance-DRtecEvb.js";
58
+ import { n as componentDefinition$53 } from "./WaveDistortion-BscXN2rs.js";
59
+ import { n as componentDefinition$54 } from "./ZoomBlur-CAqK0Kju.js";
60
+ import { Material, Mesh, MeshBasicNodeMaterial, OrthographicCamera, PlaneGeometry, SRGBColorSpace, Scene, WebGPURenderer } from "three/webgpu";
61
+ import { WebGLRenderer } from "three";
62
+ import * as TSL from "three/tsl";
63
+ import { abs, add, atan, convertToTexture, cos, div, dot, float, max, min, mix, mul, pow, screenUV, sin, sqrt, step, sub, uniform, vec3, vec4, viewportSize } from "three/tsl";
64
+ function normal_default(base, overlay, opacity = 1) {
65
+ const overlayAlpha = mul(overlay.a, opacity);
66
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
67
+ return vec4(add(mul(overlay.rgb, overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
66
68
  }
67
- var cn = (e) => N(e.x.mul(1.2249401).sub(e.y.mul(0.2249404)).sub(e.z.mul(0)), e.x.mul(-0.0420569).add(e.y.mul(1.0420571)).add(e.z.mul(0)), e.x.mul(-0.0196376).sub(e.y.mul(0.0786361)).add(e.z.mul(1.0982735))), er = (e) => N(e.x.mul(0.8224621).add(e.y.mul(0.177538)).add(e.z.mul(0)), e.x.mul(0.0331941).add(e.y.mul(0.9668058)).add(e.z.mul(0)), e.x.mul(0.0170826).add(e.y.mul(0.0723974)).add(e.z.mul(0.9105199))), fn = (e) => {
68
- const n = e.x, s = e.y, t = e.z, u = n.mul(0.4122214708).add(s.mul(0.5363325363)).add(t.mul(0.0514459929)), p = n.mul(0.2119034982).add(s.mul(0.6806995451).add(t.mul(0.1073969566))), h = n.mul(0.0883024619).add(s.mul(0.2817188376)).add(t.mul(0.6299787005)), d = W(u, j(1 / 3)), k = W(p, j(1 / 3)), U = W(h, j(1 / 3));
69
- return N(d.mul(0.2104542553).add(k.mul(0.793617785)).sub(U.mul(0.0040720468)), d.mul(1.9779984951).sub(k.mul(2.428592205)).add(U.mul(0.4505937099)), d.mul(0.0259040371).add(k.mul(0.7827717662)).sub(U.mul(0.808675766)));
70
- }, nr = (e) => {
71
- const n = e.x, s = e.y, t = e.z, u = n.add(s.mul(0.3963377774)).add(t.mul(0.2158037573)), p = n.sub(s.mul(0.1055613458)).sub(t.mul(0.0638541728)), h = n.sub(s.mul(0.0894841775)).sub(t.mul(1.291485548)), d = W(u, j(3)), k = W(p, j(3)), U = W(h, j(3));
72
- return N(d.mul(4.0767416621).sub(k.mul(3.3077115913)).add(U.mul(0.2309699292)), d.mul(-1.2684380046).add(k.mul(2.6097574011)).sub(U.mul(0.3413193965)), d.mul(-0.0041960863).sub(k.mul(0.7034186147)).add(U.mul(1.707614701)));
73
- }, un = (e) => {
74
- const n = e.x, s = e.y, t = e.z;
75
- return N(n, vn(s.mul(s).add(t.mul(t))), Hn(t, s));
76
- }, tr = (e) => {
77
- const n = e.x, s = e.y, t = e.z;
78
- return N(n, s.mul(jn(t)), s.mul(Vn(t)));
69
+ var p3ToSRGB$1 = (p3) => {
70
+ return vec3(p3.x.mul(1.2249401).sub(p3.y.mul(.2249404)).sub(p3.z.mul(0)), p3.x.mul(-.0420569).add(p3.y.mul(1.0420571)).add(p3.z.mul(0)), p3.x.mul(-.0196376).sub(p3.y.mul(.0786361)).add(p3.z.mul(1.0982735)));
79
71
  };
80
- function rr(e, n, s = 1) {
81
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t))), p = cn(N(e.r, e.g, e.b)), h = cn(N(n.r, n.g, n.b)), d = fn(p), k = fn(h), U = un(d);
82
- return S(er(nr(tr(y(l(un(k), t), l(U, l(e.a, R(1, t))))))), u);
72
+ var sRGBToP3$1 = (srgb) => {
73
+ return vec3(srgb.x.mul(.8224621).add(srgb.y.mul(.177538)).add(srgb.z.mul(0)), srgb.x.mul(.0331941).add(srgb.y.mul(.9668058)).add(srgb.z.mul(0)), srgb.x.mul(.0170826).add(srgb.y.mul(.0723974)).add(srgb.z.mul(.9105199)));
74
+ };
75
+ var rgbToOklab$1 = (rgb) => {
76
+ const r = rgb.x;
77
+ const g = rgb.y;
78
+ const b = rgb.z;
79
+ const l = r.mul(.4122214708).add(g.mul(.5363325363)).add(b.mul(.0514459929));
80
+ const m = r.mul(.2119034982).add(g.mul(.6806995451).add(b.mul(.1073969566)));
81
+ const s = r.mul(.0883024619).add(g.mul(.2817188376)).add(b.mul(.6299787005));
82
+ const l_ = pow(l, float(1 / 3));
83
+ const m_ = pow(m, float(1 / 3));
84
+ const s_ = pow(s, float(1 / 3));
85
+ return vec3(l_.mul(.2104542553).add(m_.mul(.793617785)).sub(s_.mul(.0040720468)), l_.mul(1.9779984951).sub(m_.mul(2.428592205)).add(s_.mul(.4505937099)), l_.mul(.0259040371).add(m_.mul(.7827717662)).sub(s_.mul(.808675766)));
86
+ };
87
+ var oklabToRgb$1 = (lab) => {
88
+ const L = lab.x;
89
+ const a = lab.y;
90
+ const b = lab.z;
91
+ const l_ = L.add(a.mul(.3963377774)).add(b.mul(.2158037573));
92
+ const m_ = L.sub(a.mul(.1055613458)).sub(b.mul(.0638541728));
93
+ const s_ = L.sub(a.mul(.0894841775)).sub(b.mul(1.291485548));
94
+ const l = pow(l_, float(3));
95
+ const m = pow(m_, float(3));
96
+ const s = pow(s_, float(3));
97
+ return vec3(l.mul(4.0767416621).sub(m.mul(3.3077115913)).add(s.mul(.2309699292)), l.mul(-1.2684380046).add(m.mul(2.6097574011)).sub(s.mul(.3413193965)), l.mul(-.0041960863).sub(m.mul(.7034186147)).add(s.mul(1.707614701)));
98
+ };
99
+ var oklabToOklch = (lab) => {
100
+ const L = lab.x;
101
+ const a = lab.y;
102
+ const b = lab.z;
103
+ return vec3(L, sqrt(a.mul(a).add(b.mul(b))), atan(b, a));
104
+ };
105
+ var oklchToOklab = (lch) => {
106
+ const L = lch.x;
107
+ const C = lch.y;
108
+ const h = lch.z;
109
+ return vec3(L, C.mul(cos(h)), C.mul(sin(h)));
110
+ };
111
+ function normal_oklch_default(base, overlay, opacity = 1) {
112
+ const overlayAlpha = mul(overlay.a, opacity);
113
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
114
+ const baseSRGB = p3ToSRGB$1(vec3(base.r, base.g, base.b));
115
+ const overlaySRGB = p3ToSRGB$1(vec3(overlay.r, overlay.g, overlay.b));
116
+ const baseOklab = rgbToOklab$1(baseSRGB);
117
+ const overlayOklab = rgbToOklab$1(overlaySRGB);
118
+ const baseOklch = oklabToOklch(baseOklab);
119
+ return vec4(sRGBToP3$1(oklabToRgb$1(oklchToOklab(add(mul(oklabToOklch(overlayOklab), overlayAlpha), mul(baseOklch, mul(base.a, sub(1, overlayAlpha))))))), finalAlpha);
83
120
  }
84
- var mn = (e) => N(e.x.mul(1.2249401).sub(e.y.mul(0.2249404)).sub(e.z.mul(0)), e.x.mul(-0.0420569).add(e.y.mul(1.0420571)).add(e.z.mul(0)), e.x.mul(-0.0196376).sub(e.y.mul(0.0786361)).add(e.z.mul(1.0982735))), or = (e) => N(e.x.mul(0.8224621).add(e.y.mul(0.177538)).add(e.z.mul(0)), e.x.mul(0.0331941).add(e.y.mul(0.9668058)).add(e.z.mul(0)), e.x.mul(0.0170826).add(e.y.mul(0.0723974)).add(e.z.mul(0.9105199))), dn = (e) => {
85
- const n = e.x, s = e.y, t = e.z, u = n.mul(0.4122214708).add(s.mul(0.5363325363)).add(t.mul(0.0514459929)), p = n.mul(0.2119034982).add(s.mul(0.6806995451).add(t.mul(0.1073969566))), h = n.mul(0.0883024619).add(s.mul(0.2817188376)).add(t.mul(0.6299787005)), d = W(u, j(1 / 3)), k = W(p, j(1 / 3)), U = W(h, j(1 / 3));
86
- return N(d.mul(0.2104542553).add(k.mul(0.793617785)).sub(U.mul(0.0040720468)), d.mul(1.9779984951).sub(k.mul(2.428592205)).add(U.mul(0.4505937099)), d.mul(0.0259040371).add(k.mul(0.7827717662)).sub(U.mul(0.808675766)));
87
- }, ir = (e) => {
88
- const n = e.x, s = e.y, t = e.z, u = n.add(s.mul(0.3963377774)).add(t.mul(0.2158037573)), p = n.sub(s.mul(0.1055613458)).sub(t.mul(0.0638541728)), h = n.sub(s.mul(0.0894841775)).sub(t.mul(1.291485548)), d = W(u, j(3)), k = W(p, j(3)), U = W(h, j(3));
89
- return N(d.mul(4.0767416621).sub(k.mul(3.3077115913)).add(U.mul(0.2309699292)), d.mul(-1.2684380046).add(k.mul(2.6097574011)).sub(U.mul(0.3413193965)), d.mul(-0.0041960863).sub(k.mul(0.7034186147)).add(U.mul(1.707614701)));
121
+ var p3ToSRGB = (p3) => {
122
+ return vec3(p3.x.mul(1.2249401).sub(p3.y.mul(.2249404)).sub(p3.z.mul(0)), p3.x.mul(-.0420569).add(p3.y.mul(1.0420571)).add(p3.z.mul(0)), p3.x.mul(-.0196376).sub(p3.y.mul(.0786361)).add(p3.z.mul(1.0982735)));
123
+ };
124
+ var sRGBToP3 = (srgb) => {
125
+ return vec3(srgb.x.mul(.8224621).add(srgb.y.mul(.177538)).add(srgb.z.mul(0)), srgb.x.mul(.0331941).add(srgb.y.mul(.9668058)).add(srgb.z.mul(0)), srgb.x.mul(.0170826).add(srgb.y.mul(.0723974)).add(srgb.z.mul(.9105199)));
126
+ };
127
+ var rgbToOklab = (rgb) => {
128
+ const r = rgb.x;
129
+ const g = rgb.y;
130
+ const b = rgb.z;
131
+ const l = r.mul(.4122214708).add(g.mul(.5363325363)).add(b.mul(.0514459929));
132
+ const m = r.mul(.2119034982).add(g.mul(.6806995451).add(b.mul(.1073969566)));
133
+ const s = r.mul(.0883024619).add(g.mul(.2817188376)).add(b.mul(.6299787005));
134
+ const l_ = pow(l, float(1 / 3));
135
+ const m_ = pow(m, float(1 / 3));
136
+ const s_ = pow(s, float(1 / 3));
137
+ return vec3(l_.mul(.2104542553).add(m_.mul(.793617785)).sub(s_.mul(.0040720468)), l_.mul(1.9779984951).sub(m_.mul(2.428592205)).add(s_.mul(.4505937099)), l_.mul(.0259040371).add(m_.mul(.7827717662)).sub(s_.mul(.808675766)));
90
138
  };
91
- function ar(e, n, s = 1) {
92
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t))), p = mn(N(e.r, e.g, e.b)), h = mn(N(n.r, n.g, n.b)), d = dn(p);
93
- return S(or(ir(y(l(dn(h), t), l(d, l(e.a, R(1, t)))))), u);
139
+ var oklabToRgb = (lab) => {
140
+ const L = lab.x;
141
+ const a = lab.y;
142
+ const b = lab.z;
143
+ const l_ = L.add(a.mul(.3963377774)).add(b.mul(.2158037573));
144
+ const m_ = L.sub(a.mul(.1055613458)).sub(b.mul(.0638541728));
145
+ const s_ = L.sub(a.mul(.0894841775)).sub(b.mul(1.291485548));
146
+ const l = pow(l_, float(3));
147
+ const m = pow(m_, float(3));
148
+ const s = pow(s_, float(3));
149
+ return vec3(l.mul(4.0767416621).sub(m.mul(3.3077115913)).add(s.mul(.2309699292)), l.mul(-1.2684380046).add(m.mul(2.6097574011)).sub(s.mul(.3413193965)), l.mul(-.0041960863).sub(m.mul(.7034186147)).add(s.mul(1.707614701)));
150
+ };
151
+ function normal_oklab_default(base, overlay, opacity = 1) {
152
+ const overlayAlpha = mul(overlay.a, opacity);
153
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
154
+ const baseSRGB = p3ToSRGB(vec3(base.r, base.g, base.b));
155
+ const overlaySRGB = p3ToSRGB(vec3(overlay.r, overlay.g, overlay.b));
156
+ const baseOklab = rgbToOklab(baseSRGB);
157
+ return vec4(sRGBToP3(oklabToRgb(add(mul(rgbToOklab(overlaySRGB), overlayAlpha), mul(baseOklab, mul(base.a, sub(1, overlayAlpha)))))), finalAlpha);
94
158
  }
95
- function sr(e, n, s = 1) {
96
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
97
- return S(y(l(l(e.rgb, n.rgb), t), l(e.rgb, l(e.a, R(1, t)))), u);
159
+ function multiply_default(base, overlay, opacity = 1) {
160
+ const overlayAlpha = mul(overlay.a, opacity);
161
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
162
+ return vec4(add(mul(mul(base.rgb, overlay.rgb), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
98
163
  }
99
- function lr(e, n, s = 1) {
100
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
101
- return S(y(l(R(1, l(R(1, e.rgb), R(1, n.rgb))), t), l(e.rgb, l(e.a, R(1, t)))), u);
164
+ function screen_default(base, overlay, opacity = 1) {
165
+ const overlayAlpha = mul(overlay.a, opacity);
166
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
167
+ return vec4(add(mul(sub(1, mul(sub(1, base.rgb), sub(1, overlay.rgb))), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
102
168
  }
103
- function cr(e, n, s = 1) {
104
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
105
- return S(y(l(We(y(e.rgb, n.rgb), 1), t), l(e.rgb, l(e.a, R(1, t)))), u);
169
+ function linearDodge_default(base, overlay, opacity = 1) {
170
+ const overlayAlpha = mul(overlay.a, opacity);
171
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
172
+ return vec4(add(mul(min(add(base.rgb, overlay.rgb), 1), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
106
173
  }
107
- function fr(e, n, s = 1) {
108
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
109
- return S(y(l(Me(l(2, l(e.rgb, n.rgb)), R(1, l(2, l(R(1, e.rgb), R(1, n.rgb)))), Se(0.5, e.rgb)), t), l(e.rgb, l(e.a, R(1, t)))), u);
174
+ function overlay_default(base, overlay, opacity = 1) {
175
+ const overlayAlpha = mul(overlay.a, opacity);
176
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
177
+ return vec4(add(mul(mix(mul(2, mul(base.rgb, overlay.rgb)), sub(1, mul(2, mul(sub(1, base.rgb), sub(1, overlay.rgb)))), step(.5, base.rgb)), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
110
178
  }
111
- function ur(e, n, s = 1) {
112
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
113
- return S(y(l(Qn(R(e.rgb, n.rgb)), t), l(e.rgb, l(e.a, R(1, t)))), u);
179
+ function difference_default(base, overlay, opacity = 1) {
180
+ const overlayAlpha = mul(overlay.a, opacity);
181
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
182
+ return vec4(add(mul(abs(sub(base.rgb, overlay.rgb)), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
114
183
  }
115
- function mr(e, n, s = 1) {
116
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
117
- return S(y(l(Me(e.rgb, We(In(e.rgb, R(1, n.rgb)), 1), Se(1e-3, R(1, n.rgb))), t), l(e.rgb, l(e.a, R(1, t)))), u);
184
+ function colorDodge_default(base, overlay, opacity = 1) {
185
+ const overlayAlpha = mul(overlay.a, opacity);
186
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
187
+ return vec4(add(mul(mix(base.rgb, min(div(base.rgb, sub(1, overlay.rgb)), 1), step(.001, sub(1, overlay.rgb))), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
118
188
  }
119
- function dr(e, n, s = 1) {
120
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
121
- return S(y(l(R(y(e.rgb, n.rgb), l(2, l(e.rgb, n.rgb))), t), l(e.rgb, l(e.a, R(1, t)))), u);
189
+ function exclusion_default(base, overlay, opacity = 1) {
190
+ const overlayAlpha = mul(overlay.a, opacity);
191
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
192
+ return vec4(add(mul(sub(add(base.rgb, overlay.rgb), mul(2, mul(base.rgb, overlay.rgb))), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
122
193
  }
123
- function oe(e) {
124
- return y(y(l(e.r, 0.2126), l(e.g, 0.7152)), l(e.b, 0.0722));
194
+ function getLuminance(rgb) {
195
+ return add(add(mul(rgb.r, .2126), mul(rgb.g, .7152)), mul(rgb.b, .0722));
125
196
  }
126
- function hr(e, n, s = 1) {
127
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t))), p = R(oe(e.rgb), oe(n.rgb));
128
- return S(y(l(y(n.rgb, p), t), l(e.rgb, l(e.a, R(1, t)))), u);
197
+ function color_default(base, overlay, opacity = 1) {
198
+ const overlayAlpha = mul(overlay.a, opacity);
199
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
200
+ const lumDiff = sub(getLuminance(base.rgb), getLuminance(overlay.rgb));
201
+ return vec4(add(mul(add(overlay.rgb, lumDiff), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
129
202
  }
130
- function pr(e, n, s = 1) {
131
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t))), p = oe(e.rgb), h = oe(n.rgb).div(y(p, 1e-4));
132
- return S(y(l(l(e.rgb, h), t), l(e.rgb, l(e.a, R(1, t)))), u);
203
+ function luminosity_default(base, overlay, opacity = 1) {
204
+ const overlayAlpha = mul(overlay.a, opacity);
205
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
206
+ const baseLum = getLuminance(base.rgb);
207
+ const lumRatio = getLuminance(overlay.rgb).div(add(baseLum, 1e-4));
208
+ return vec4(add(mul(mul(base.rgb, lumRatio), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
133
209
  }
134
- function gr(e, n, s = 1) {
135
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
136
- return S(y(l(We(e.rgb, n.rgb), t), l(e.rgb, l(e.a, R(1, t)))), u);
210
+ function darken_default(base, overlay, opacity = 1) {
211
+ const overlayAlpha = mul(overlay.a, opacity);
212
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
213
+ return vec4(add(mul(min(base.rgb, overlay.rgb), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
137
214
  }
138
- function br(e, n, s = 1) {
139
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
140
- return S(y(l(je(e.rgb, n.rgb), t), l(e.rgb, l(e.a, R(1, t)))), u);
215
+ function lighten_default(base, overlay, opacity = 1) {
216
+ const overlayAlpha = mul(overlay.a, opacity);
217
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
218
+ return vec4(add(mul(max(base.rgb, overlay.rgb), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
141
219
  }
142
- function vr(e, n, s = 1) {
143
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
144
- return S(y(l(Me(S(0, 0, 0, 1).rgb, je(R(1, R(1, e.rgb).div(y(n.rgb, 1e-4))), 0), Se(1e-4, n.rgb)), t), l(e.rgb, l(e.a, R(1, t)))), u);
220
+ function colorBurn_default(base, overlay, opacity = 1) {
221
+ const overlayAlpha = mul(overlay.a, opacity);
222
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
223
+ return vec4(add(mul(mix(vec4(0, 0, 0, 1).rgb, max(sub(1, sub(1, base.rgb).div(add(overlay.rgb, 1e-4))), 0), step(1e-4, overlay.rgb)), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
145
224
  }
146
- function Cr(e, n, s = 1) {
147
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
148
- return S(y(l(je(y(y(e.rgb, n.rgb), -1), 0), t), l(e.rgb, l(e.a, R(1, t)))), u);
225
+ function linearBurn_default(base, overlay, opacity = 1) {
226
+ const overlayAlpha = mul(overlay.a, opacity);
227
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
228
+ return vec4(add(mul(max(add(add(base.rgb, overlay.rgb), -1), 0), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
149
229
  }
150
- function Rr(e, n, s = 1) {
151
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t))), p = y(l(2, l(e.rgb, n.rgb)), l(l(e.rgb, e.rgb), R(1, l(2, n.rgb)))), h = vn(e.rgb);
152
- return S(y(l(Me(p, y(l(2, l(e.rgb, R(1, n.rgb))), l(h, R(l(2, n.rgb), 1))), Se(0.5, n.rgb)), t), l(e.rgb, l(e.a, R(1, t)))), u);
230
+ function softLight_default(base, overlay, opacity = 1) {
231
+ const overlayAlpha = mul(overlay.a, opacity);
232
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
233
+ const softLightDark = add(mul(2, mul(base.rgb, overlay.rgb)), mul(mul(base.rgb, base.rgb), sub(1, mul(2, overlay.rgb))));
234
+ const baseSqrt = sqrt(base.rgb);
235
+ return vec4(add(mul(mix(softLightDark, add(mul(2, mul(base.rgb, sub(1, overlay.rgb))), mul(baseSqrt, sub(mul(2, overlay.rgb), 1))), step(.5, overlay.rgb)), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
153
236
  }
154
- function kr(e, n, s = 1) {
155
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t)));
156
- return S(y(l(Me(l(2, l(e.rgb, n.rgb)), R(1, l(2, l(R(1, e.rgb), R(1, n.rgb)))), Se(0.5, n.rgb)), t), l(e.rgb, l(e.a, R(1, t)))), u);
237
+ function hardLight_default(base, overlay, opacity = 1) {
238
+ const overlayAlpha = mul(overlay.a, opacity);
239
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
240
+ return vec4(add(mul(mix(mul(2, mul(base.rgb, overlay.rgb)), sub(1, mul(2, mul(sub(1, base.rgb), sub(1, overlay.rgb)))), step(.5, overlay.rgb)), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
157
241
  }
158
- function Tr(e, n, s = 1) {
159
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t))), p = oe(e.rgb), h = oe(n.rgb), d = e.rgb.sub(p), k = n.rgb.sub(h), U = d.length();
160
- return S(y(l(y(l(k.normalize(), U), p), t), l(e.rgb, l(e.a, R(1, t)))), u);
242
+ function hue_default(base, overlay, opacity = 1) {
243
+ const overlayAlpha = mul(overlay.a, opacity);
244
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
245
+ const baseLum = getLuminance(base.rgb);
246
+ const overlayLum = getLuminance(overlay.rgb);
247
+ const baseChromaticity = base.rgb.sub(baseLum);
248
+ const overlayChromaticity = overlay.rgb.sub(overlayLum);
249
+ const baseChromaLength = baseChromaticity.length();
250
+ return vec4(add(mul(add(mul(overlayChromaticity.normalize(), baseChromaLength), baseLum), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
161
251
  }
162
- function yr(e, n, s = 1) {
163
- const t = l(n.a, s), u = y(t, l(e.a, R(1, t))), p = oe(e.rgb), h = oe(n.rgb), d = e.rgb.sub(p), k = n.rgb.sub(h);
164
- return S(y(l(y(l(d.normalize(), k.length()), p), t), l(e.rgb, l(e.a, R(1, t)))), u);
252
+ function saturation_default(base, overlay, opacity = 1) {
253
+ const overlayAlpha = mul(overlay.a, opacity);
254
+ const finalAlpha = add(overlayAlpha, mul(base.a, sub(1, overlayAlpha)));
255
+ const baseLum = getLuminance(base.rgb);
256
+ const overlayLum = getLuminance(overlay.rgb);
257
+ const baseChromaticity = base.rgb.sub(baseLum);
258
+ const overlayChromaticity = overlay.rgb.sub(overlayLum);
259
+ return vec4(add(mul(add(mul(baseChromaticity.normalize(), overlayChromaticity.length()), baseLum), overlayAlpha), mul(base.rgb, mul(base.a, sub(1, overlayAlpha)))), finalAlpha);
165
260
  }
166
- var hn = {
167
- normal: Kt,
168
- "normal-oklch": rr,
169
- "normal-oklab": ar,
170
- multiply: sr,
171
- screen: lr,
172
- linearDodge: cr,
173
- overlay: fr,
174
- difference: ur,
175
- colorDodge: mr,
176
- exclusion: dr,
177
- color: hr,
178
- luminosity: pr,
179
- darken: gr,
180
- lighten: br,
181
- colorBurn: vr,
182
- linearBurn: Cr,
183
- softLight: Rr,
184
- hardLight: kr,
185
- hue: Tr,
186
- saturation: yr
261
+ var blendModes = {
262
+ normal: normal_default,
263
+ "normal-oklch": normal_oklch_default,
264
+ "normal-oklab": normal_oklab_default,
265
+ multiply: multiply_default,
266
+ screen: screen_default,
267
+ linearDodge: linearDodge_default,
268
+ overlay: overlay_default,
269
+ difference: difference_default,
270
+ colorDodge: colorDodge_default,
271
+ exclusion: exclusion_default,
272
+ color: color_default,
273
+ luminosity: luminosity_default,
274
+ darken: darken_default,
275
+ lighten: lighten_default,
276
+ colorBurn: colorBurn_default,
277
+ linearBurn: linearBurn_default,
278
+ softLight: softLight_default,
279
+ hardLight: hardLight_default,
280
+ hue: hue_default,
281
+ saturation: saturation_default
187
282
  };
188
- function H(e, n, s = "normal", t = 1) {
189
- return (hn[s] || hn.normal)(e, n, t);
283
+ function applyBlendMode(baseNode, overlayNode, blendMode = "normal", opacity = 1) {
284
+ return (blendModes[blendMode] || blendModes.normal)(baseNode, overlayNode, opacity);
190
285
  }
191
- function wr(e, n) {
192
- const s = l(e.a, n.a);
193
- return S(e.rgb, s);
286
+ function alpha_default(target, mask) {
287
+ const maskedAlpha = mul(target.a, mask.a);
288
+ return vec4(target.rgb, maskedAlpha);
194
289
  }
195
- function Ur(e, n) {
196
- const s = R(1, n.a), t = l(e.a, s);
197
- return S(e.rgb, t);
290
+ function alphaInverted_default(target, mask) {
291
+ const invertedMaskAlpha = sub(1, mask.a);
292
+ const maskedAlpha = mul(target.a, invertedMaskAlpha);
293
+ return vec4(target.rgb, maskedAlpha);
198
294
  }
199
- function Sr(e, n) {
200
- const s = N(0.2126, 0.7152, 0.0722), t = bn(n.rgb, s), u = l(e.a, t);
201
- return S(e.rgb, u);
295
+ function luminance_default(target, mask) {
296
+ const luminanceWeights = vec3(.2126, .7152, .0722);
297
+ const luminance = dot(mask.rgb, luminanceWeights);
298
+ const maskedAlpha = mul(target.a, luminance);
299
+ return vec4(target.rgb, maskedAlpha);
202
300
  }
203
- function Mr(e, n) {
204
- const s = N(0.2126, 0.7152, 0.0722), t = R(1, bn(n.rgb, s)), u = l(e.a, t);
205
- return S(e.rgb, u);
301
+ function luminanceInverted_default(target, mask) {
302
+ const luminanceWeights = vec3(.2126, .7152, .0722);
303
+ const invertedLuminance = sub(1, dot(mask.rgb, luminanceWeights));
304
+ const maskedAlpha = mul(target.a, invertedLuminance);
305
+ return vec4(target.rgb, maskedAlpha);
206
306
  }
207
- var pn = {
208
- alpha: wr,
209
- alphaInverted: Ur,
210
- luminance: Sr,
211
- luminanceInverted: Mr
307
+ var maskFunctions = {
308
+ "alpha": alpha_default,
309
+ "alphaInverted": alphaInverted_default,
310
+ "luminance": luminance_default,
311
+ "luminanceInverted": luminanceInverted_default
212
312
  };
213
- function xr(e, n, s = "alpha") {
214
- return (pn[s] || pn.alpha)(e, n);
313
+ function applyMask(target, mask, maskType = "alpha") {
314
+ return (maskFunctions[maskType] || maskFunctions["alpha"])(target, mask);
215
315
  }
216
- var Ar = class {
217
- frameTimesMs = [];
218
- maxSamples = 60;
219
- targetFrameTime = 16.67;
220
- jankFrameCount = 0;
221
- totalFrameCount = 0;
222
- memorySnapshots = [];
223
- memoryWindowMs = 5e3;
224
- nodeCount = 0;
225
- rttNodeCount = 0;
226
- lastCpuTime = null;
227
- lastGpuTime = null;
228
- isRendering = !1;
229
- lastFrameTimestamp = 0;
230
- frameIntervals = [];
231
- /**
232
- * Records a frame's render time
233
- */
234
- recordFrame(e) {
235
- this.frameTimesMs.push(e), this.frameTimesMs.length > this.maxSamples && this.frameTimesMs.shift(), this.totalFrameCount++, e > this.targetFrameTime && this.jankFrameCount++;
236
- const n = performance.now();
237
- if (this.lastFrameTimestamp > 0) {
238
- const s = n - this.lastFrameTimestamp;
239
- this.frameIntervals.push(s), this.frameIntervals.length > this.maxSamples && this.frameIntervals.shift();
240
- }
241
- this.lastFrameTimestamp = n, this.recordMemorySnapshot();
242
- }
243
- /**
244
- * Records CPU time for the last frame
245
- */
246
- recordCpuTime(e) {
247
- this.lastCpuTime = e;
248
- }
249
- /**
250
- * Records GPU time for the last frame
251
- */
252
- recordGpuTime(e) {
253
- this.lastGpuTime = e;
254
- }
255
- /**
256
- * Updates node counts for complexity calculation
257
- */
258
- updateNodeCounts(e, n) {
259
- this.nodeCount = e, this.rttNodeCount = n;
260
- }
261
- /**
262
- * Sets rendering state
263
- */
264
- setRendering(e) {
265
- this.isRendering = e;
266
- }
267
- /**
268
- * Records a memory snapshot for growth rate calculation
269
- */
270
- recordMemorySnapshot() {
271
- if (!performance.memory) return;
272
- const e = performance.now(), n = performance.memory.usedJSHeapSize;
273
- this.memorySnapshots.push({
274
- time: e,
275
- bytes: n
276
- });
277
- const s = e - this.memoryWindowMs;
278
- this.memorySnapshots = this.memorySnapshots.filter((t) => t.time > s);
279
- }
280
- /**
281
- * Calculates memory growth rate in MB/sec
282
- */
283
- calculateMemoryGrowthRate() {
284
- if (this.memorySnapshots.length < 2) return null;
285
- const e = this.memorySnapshots[0], n = this.memorySnapshots[this.memorySnapshots.length - 1], s = (n.time - e.time) / 1e3;
286
- return (n.bytes - e.bytes) / (1024 * 1024) / s;
287
- }
288
- /**
289
- * Calculates standard deviation of frame times
290
- */
291
- calculateStdDev(e) {
292
- if (e.length === 0) return 0;
293
- const n = e.reduce((t, u) => t + u, 0) / e.length, s = e.map((t) => Math.pow(t - n, 2)).reduce((t, u) => t + u, 0) / e.length;
294
- return Math.sqrt(s);
295
- }
296
- /**
297
- * Calculates 99th percentile frame time
298
- */
299
- calculateP99(e) {
300
- if (e.length === 0) return 0;
301
- const n = [...e].sort((t, u) => t - u), s = Math.floor(n.length * 0.99);
302
- return n[Math.min(s, n.length - 1)];
303
- }
304
- /**
305
- * Calculates complexity score based on node structure
306
- * RTT nodes are 10x more expensive than regular nodes
307
- */
308
- calculateComplexityScore() {
309
- return this.nodeCount + this.rttNodeCount * 10;
310
- }
311
- /**
312
- * Calculates normalized intensity score (0-100) for "average machine" estimation
313
- * Combines frame time, complexity, and GPU time into single metric
314
- *
315
- * Scoring:
316
- * - 0-20: Very Light (simple effects, <5ms)
317
- * - 21-40: Light (basic effects, 5-8ms)
318
- * - 41-60: Medium (moderate effects, 8-12ms)
319
- * - 61-80: Heavy (complex effects, 12-15ms)
320
- * - 81-100: Very Heavy (intensive effects, >15ms)
321
- */
322
- calculateIntensityScore() {
323
- const e = this.frameTimesMs.length;
324
- if (e === 0) return {
325
- score: 0,
326
- label: "N/A"
327
- };
328
- const n = this.frameTimesMs.reduce((U, B) => U + B, 0) / e, s = Math.min(n / 16.67 * 100, 100), t = this.calculateComplexityScore(), u = Math.min(t / 100 * 100, 100);
329
- let p = 0;
330
- this.lastGpuTime !== null && (p = Math.min(this.lastGpuTime / 16.67 * 100, 100));
331
- const h = this.lastGpuTime !== null ? {
332
- frame: 0.4,
333
- gpu: 0.4,
334
- complexity: 0.2
335
- } : {
336
- frame: 0.7,
337
- gpu: 0,
338
- complexity: 0.3
339
- }, d = Math.round(s * h.frame + p * h.gpu + u * h.complexity);
340
- let k;
341
- return d <= 20 ? k = "Very Light" : d <= 40 ? k = "Light" : d <= 60 ? k = "Medium" : d <= 80 ? k = "Heavy" : k = "Very Heavy", {
342
- score: Math.min(d, 100),
343
- label: k
344
- };
345
- }
346
- /**
347
- * Gets current performance statistics
348
- */
349
- getStats(e) {
350
- const n = this.frameTimesMs.length, s = this.frameIntervals.length > 0 ? 1e3 / (this.frameIntervals.reduce((D, E) => D + E, 0) / this.frameIntervals.length) : 0, t = n > 0 ? this.frameTimesMs.reduce((D, E) => D + E, 0) / n : 0, u = n > 0 ? Math.min(...this.frameTimesMs) : 0, p = n > 0 ? Math.max(...this.frameTimesMs) : 0, h = this.calculateP99(this.frameTimesMs), d = this.calculateStdDev(this.frameTimesMs), k = this.totalFrameCount > 0 ? this.jankFrameCount / this.totalFrameCount * 100 : 0, U = performance.memory, B = U ? U.usedJSHeapSize / (1024 * 1024) : null, O = this.calculateMemoryGrowthRate(), Q = t > 0 ? t / this.targetFrameTime * 100 : 0, V = e?.render?.calls ?? null, q = e?.programs?.length ?? null, ce = e?.memory?.textures ?? null, ie = this.calculateIntensityScore();
351
- return {
352
- fps: Math.round(s),
353
- avgFrameTime: Math.round(t * 100) / 100,
354
- minFrameTime: Math.round(u * 100) / 100,
355
- maxFrameTime: Math.round(p * 100) / 100,
356
- p99FrameTime: Math.round(h * 100) / 100,
357
- stdDevFrameTime: Math.round(d * 100) / 100,
358
- jankCount: this.jankFrameCount,
359
- jankPercent: Math.round(k * 10) / 10,
360
- nodeCount: this.nodeCount,
361
- rttNodeCount: this.rttNodeCount,
362
- complexityScore: this.calculateComplexityScore(),
363
- memoryUsedMB: B !== null ? Math.round(B * 100) / 100 : null,
364
- memoryGrowthRate: O !== null ? Math.round(O * 1e3) / 1e3 : null,
365
- cpuTime: this.lastCpuTime !== null ? Math.round(this.lastCpuTime * 100) / 100 : null,
366
- gpuTime: this.lastGpuTime !== null ? Math.round(this.lastGpuTime * 100) / 100 : null,
367
- budgetUsed: Math.round(Q * 10) / 10,
368
- drawCalls: V,
369
- shaderPrograms: q,
370
- textureCount: ce,
371
- intensityScore: ie.score,
372
- intensityLabel: ie.label,
373
- isRendering: this.isRendering
374
- };
375
- }
376
- /**
377
- * Resets all statistics
378
- */
379
- reset() {
380
- this.frameTimesMs = [], this.frameIntervals = [], this.lastFrameTimestamp = 0, this.jankFrameCount = 0, this.totalFrameCount = 0, this.memorySnapshots = [], this.lastCpuTime = null, this.lastGpuTime = null;
381
- }
382
- }, { vec2: we, cos: zr, sin: Dr, float: Er, PI: Fr } = le;
383
- const ne = (e) => e ? e.offsetX !== 0 || e.offsetY !== 0 || e.rotation !== 0 || e.scale !== 1 || e.anchorX !== 0.5 || e.anchorY !== 0.5 : !1, Ue = (e, n, s, t, u, p, h, d) => {
384
- const k = t.mul(Fr).div(Er(180)), U = zr(k), B = Dr(k), O = we(p, h), Q = e.sub(O).div(u), V = we(Q.x.mul(d), Q.y), q = we(V.x.mul(U).sub(V.y.mul(B)), V.x.mul(B).add(V.y.mul(U)));
385
- return we(q.x.div(d), q.y).sub(we(n, s)).add(O);
316
+ var PerformanceTracker = class {
317
+ frameTimesMs = [];
318
+ maxSamples = 60;
319
+ targetFrameTime = 16.67;
320
+ jankFrameCount = 0;
321
+ totalFrameCount = 0;
322
+ memorySnapshots = [];
323
+ memoryWindowMs = 5e3;
324
+ nodeCount = 0;
325
+ rttNodeCount = 0;
326
+ lastCpuTime = null;
327
+ lastGpuTime = null;
328
+ isRendering = false;
329
+ lastFrameTimestamp = 0;
330
+ frameIntervals = [];
331
+ recordFrame(frameTimeMs) {
332
+ this.frameTimesMs.push(frameTimeMs);
333
+ if (this.frameTimesMs.length > this.maxSamples) this.frameTimesMs.shift();
334
+ this.totalFrameCount++;
335
+ if (frameTimeMs > this.targetFrameTime) this.jankFrameCount++;
336
+ const now = performance.now();
337
+ if (this.lastFrameTimestamp > 0) {
338
+ const interval = now - this.lastFrameTimestamp;
339
+ this.frameIntervals.push(interval);
340
+ if (this.frameIntervals.length > this.maxSamples) this.frameIntervals.shift();
341
+ }
342
+ this.lastFrameTimestamp = now;
343
+ this.recordMemorySnapshot();
344
+ }
345
+ recordCpuTime(timeMs) {
346
+ this.lastCpuTime = timeMs;
347
+ }
348
+ recordGpuTime(timeMs) {
349
+ this.lastGpuTime = timeMs;
350
+ }
351
+ updateNodeCounts(nodeCount, rttNodeCount) {
352
+ this.nodeCount = nodeCount;
353
+ this.rttNodeCount = rttNodeCount;
354
+ }
355
+ setRendering(rendering) {
356
+ this.isRendering = rendering;
357
+ }
358
+ recordMemorySnapshot() {
359
+ if (!performance.memory) return;
360
+ const now = performance.now();
361
+ const bytes = performance.memory.usedJSHeapSize;
362
+ this.memorySnapshots.push({
363
+ time: now,
364
+ bytes
365
+ });
366
+ const cutoff = now - this.memoryWindowMs;
367
+ this.memorySnapshots = this.memorySnapshots.filter((s) => s.time > cutoff);
368
+ }
369
+ calculateMemoryGrowthRate() {
370
+ if (this.memorySnapshots.length < 2) return null;
371
+ const oldest = this.memorySnapshots[0];
372
+ const newest = this.memorySnapshots[this.memorySnapshots.length - 1];
373
+ const timeDeltaSeconds = (newest.time - oldest.time) / 1e3;
374
+ return (newest.bytes - oldest.bytes) / (1024 * 1024) / timeDeltaSeconds;
375
+ }
376
+ calculateStdDev(values) {
377
+ if (values.length === 0) return 0;
378
+ const mean = values.reduce((a, b) => a + b, 0) / values.length;
379
+ const avgSquaredDiff = values.map((v) => Math.pow(v - mean, 2)).reduce((a, b) => a + b, 0) / values.length;
380
+ return Math.sqrt(avgSquaredDiff);
381
+ }
382
+ calculateP99(values) {
383
+ if (values.length === 0) return 0;
384
+ const sorted = [...values].sort((a, b) => a - b);
385
+ const index = Math.floor(sorted.length * .99);
386
+ return sorted[Math.min(index, sorted.length - 1)];
387
+ }
388
+ calculateComplexityScore() {
389
+ return this.nodeCount + this.rttNodeCount * 10;
390
+ }
391
+ calculateIntensityScore() {
392
+ const frameCount = this.frameTimesMs.length;
393
+ if (frameCount === 0) return {
394
+ score: 0,
395
+ label: "N/A"
396
+ };
397
+ const avgFrameTime = this.frameTimesMs.reduce((a, b) => a + b, 0) / frameCount;
398
+ const frameTimeScore = Math.min(avgFrameTime / 16.67 * 100, 100);
399
+ const complexity = this.calculateComplexityScore();
400
+ const complexityScore = Math.min(complexity / 100 * 100, 100);
401
+ let gpuTimeScore = 0;
402
+ if (this.lastGpuTime !== null) gpuTimeScore = Math.min(this.lastGpuTime / 16.67 * 100, 100);
403
+ const weights = this.lastGpuTime !== null ? {
404
+ frame: .4,
405
+ gpu: .4,
406
+ complexity: .2
407
+ } : {
408
+ frame: .7,
409
+ gpu: 0,
410
+ complexity: .3
411
+ };
412
+ const finalScore = Math.round(frameTimeScore * weights.frame + gpuTimeScore * weights.gpu + complexityScore * weights.complexity);
413
+ let label;
414
+ if (finalScore <= 20) label = "Very Light";
415
+ else if (finalScore <= 40) label = "Light";
416
+ else if (finalScore <= 60) label = "Medium";
417
+ else if (finalScore <= 80) label = "Heavy";
418
+ else label = "Very Heavy";
419
+ return {
420
+ score: Math.min(finalScore, 100),
421
+ label
422
+ };
423
+ }
424
+ getStats(rendererInfo) {
425
+ const frameCount = this.frameTimesMs.length;
426
+ const fps = this.frameIntervals.length > 0 ? 1e3 / (this.frameIntervals.reduce((a, b) => a + b, 0) / this.frameIntervals.length) : 0;
427
+ const avgFrameTime = frameCount > 0 ? this.frameTimesMs.reduce((a, b) => a + b, 0) / frameCount : 0;
428
+ const minFrameTime = frameCount > 0 ? Math.min(...this.frameTimesMs) : 0;
429
+ const maxFrameTime = frameCount > 0 ? Math.max(...this.frameTimesMs) : 0;
430
+ const p99FrameTime = this.calculateP99(this.frameTimesMs);
431
+ const stdDevFrameTime = this.calculateStdDev(this.frameTimesMs);
432
+ const jankPercent = this.totalFrameCount > 0 ? this.jankFrameCount / this.totalFrameCount * 100 : 0;
433
+ const memory = performance.memory;
434
+ const memoryUsedMB = memory ? memory.usedJSHeapSize / (1024 * 1024) : null;
435
+ const memoryGrowthRate = this.calculateMemoryGrowthRate();
436
+ const budgetUsed = avgFrameTime > 0 ? avgFrameTime / this.targetFrameTime * 100 : 0;
437
+ const drawCalls = rendererInfo?.render?.calls ?? null;
438
+ const shaderPrograms = rendererInfo?.programs?.length ?? null;
439
+ const textureCount = rendererInfo?.memory?.textures ?? null;
440
+ const intensity = this.calculateIntensityScore();
441
+ return {
442
+ fps: Math.round(fps),
443
+ avgFrameTime: Math.round(avgFrameTime * 100) / 100,
444
+ minFrameTime: Math.round(minFrameTime * 100) / 100,
445
+ maxFrameTime: Math.round(maxFrameTime * 100) / 100,
446
+ p99FrameTime: Math.round(p99FrameTime * 100) / 100,
447
+ stdDevFrameTime: Math.round(stdDevFrameTime * 100) / 100,
448
+ jankCount: this.jankFrameCount,
449
+ jankPercent: Math.round(jankPercent * 10) / 10,
450
+ nodeCount: this.nodeCount,
451
+ rttNodeCount: this.rttNodeCount,
452
+ complexityScore: this.calculateComplexityScore(),
453
+ memoryUsedMB: memoryUsedMB !== null ? Math.round(memoryUsedMB * 100) / 100 : null,
454
+ memoryGrowthRate: memoryGrowthRate !== null ? Math.round(memoryGrowthRate * 1e3) / 1e3 : null,
455
+ cpuTime: this.lastCpuTime !== null ? Math.round(this.lastCpuTime * 100) / 100 : null,
456
+ gpuTime: this.lastGpuTime !== null ? Math.round(this.lastGpuTime * 100) / 100 : null,
457
+ budgetUsed: Math.round(budgetUsed * 10) / 10,
458
+ drawCalls,
459
+ shaderPrograms,
460
+ textureCount,
461
+ intensityScore: intensity.score,
462
+ intensityLabel: intensity.label,
463
+ isRendering: this.isRendering
464
+ };
465
+ }
466
+ reset() {
467
+ this.frameTimesMs = [];
468
+ this.frameIntervals = [];
469
+ this.lastFrameTimestamp = 0;
470
+ this.jankFrameCount = 0;
471
+ this.totalFrameCount = 0;
472
+ this.memorySnapshots = [];
473
+ this.lastCpuTime = null;
474
+ this.lastGpuTime = null;
475
+ }
476
+ };
477
+ var { vec2: vec2$3, cos: cos$1, sin: sin$2, float: float$1, PI } = TSL;
478
+ const needsTransformation = (transform) => {
479
+ if (!transform) return false;
480
+ return transform.offsetX !== 0 || transform.offsetY !== 0 || transform.rotation !== 0 || transform.scale !== 1 || transform.anchorX !== .5 || transform.anchorY !== .5;
481
+ };
482
+ const applyUVTransform = (uv, offsetXUniform, offsetYUniform, rotationUniform, scaleUniform, anchorXUniform, anchorYUniform, aspectRatioUniform) => {
483
+ const rotationRad = rotationUniform.mul(PI).div(float$1(180));
484
+ const cosAngle = cos$1(rotationRad);
485
+ const sinAngle = sin$2(rotationRad);
486
+ const anchor = vec2$3(anchorXUniform, anchorYUniform);
487
+ const scaledUV = uv.sub(anchor).div(scaleUniform);
488
+ const squareUV = vec2$3(scaledUV.x.mul(aspectRatioUniform), scaledUV.y);
489
+ const rotatedSquareUV = vec2$3(squareUV.x.mul(cosAngle).sub(squareUV.y.mul(sinAngle)), squareUV.x.mul(sinAngle).add(squareUV.y.mul(cosAngle)));
490
+ return vec2$3(rotatedSquareUV.x.div(aspectRatioUniform), rotatedSquareUV.y).sub(vec2$3(offsetXUniform, offsetYUniform)).add(anchor);
386
491
  };
387
- var { uniform: $r } = le;
388
- function ri(e, n, s) {
389
- const t = {};
390
- return Object.entries(e.props).forEach(([u, p]) => {
391
- const h = n[u];
392
- let d = h;
393
- if (p.transform) {
394
- const U = p.transform(h);
395
- d = U?.node ?? U;
396
- }
397
- if (d == null && (d = p.default, p.transform && d !== null && d !== void 0)) {
398
- const U = p.transform(d);
399
- d = U?.node ?? U;
400
- }
401
- d == null && (console.error(`[Shaders] Uniform "${u}" is null/undefined after fallback. PropConfig:`, {
402
- propName: u,
403
- initialValue: h,
404
- default: p.default,
405
- hasTransform: !!p.transform
406
- }), d = 0);
407
- const k = $r(d).setName(`${u}_${s}`);
408
- typeof d == "string" && k.value === null && (k.value = d), t[u] = {
409
- uniform: k,
410
- transform: p.transform || void 0
411
- };
412
- }), t;
492
+ var { uniform: uniform$1 } = TSL;
493
+ function createUniformsMap(component, reactiveProps, instanceId) {
494
+ const uniformsMap = {};
495
+ Object.entries(component.props).forEach(([propName, propConfig]) => {
496
+ const initialValue = reactiveProps[propName];
497
+ let uniformValue = initialValue;
498
+ if (propConfig.transform) {
499
+ const transformed = propConfig.transform(initialValue);
500
+ uniformValue = transformed?.node ?? transformed;
501
+ }
502
+ if (uniformValue === null || uniformValue === void 0) {
503
+ uniformValue = propConfig.default;
504
+ if (propConfig.transform && uniformValue !== null && uniformValue !== void 0) {
505
+ const transformed = propConfig.transform(uniformValue);
506
+ uniformValue = transformed?.node ?? transformed;
507
+ }
508
+ }
509
+ if (uniformValue === null || uniformValue === void 0) {
510
+ console.error(`[Shaders] Uniform "${propName}" is null/undefined after fallback. PropConfig:`, {
511
+ propName,
512
+ initialValue,
513
+ default: propConfig.default,
514
+ hasTransform: !!propConfig.transform
515
+ });
516
+ uniformValue = 0;
517
+ }
518
+ const uniformNode = uniform$1(uniformValue).setName(`${propName}_${instanceId}`);
519
+ if (typeof uniformValue === "string" && uniformNode.value === null) uniformNode.value = uniformValue;
520
+ uniformsMap[propName] = {
521
+ uniform: uniformNode,
522
+ transform: propConfig.transform || void 0
523
+ };
524
+ });
525
+ return uniformsMap;
413
526
  }
414
- function Or(e, n) {
415
- if (e?.transform) {
416
- const s = e.transform(n), t = s?.data ?? s;
417
- e.uniform.value = t;
418
- } else e.uniform.value = n;
527
+ function updateUniformValue(uniform$2, newValue) {
528
+ if (uniform$2?.transform) {
529
+ const transformed = uniform$2.transform(newValue);
530
+ const dataValue = transformed?.data ?? transformed;
531
+ uniform$2.uniform.value = dataValue;
532
+ } else uniform$2.uniform.value = newValue;
419
533
  }
420
- var gn = !1, Br = /* @__PURE__ */ (() => {
421
- let e = 0;
422
- const n = /* @__PURE__ */ new Set(), s = (h) => {
423
- n.forEach((d) => {
424
- try {
425
- d.onMouseMove(h);
426
- } catch (k) {
427
- console.error("[Shaders] Error in mouse move handler:", k);
428
- }
429
- });
430
- }, t = (h) => {
431
- n.forEach((d) => {
432
- try {
433
- d.onTouchMove(h);
434
- } catch (k) {
435
- console.error("[Shaders] Error in touch move handler:", k);
436
- }
437
- });
438
- }, u = () => {
439
- n.forEach((h) => {
440
- try {
441
- h.onMouseUp();
442
- } catch (d) {
443
- console.error("[Shaders] Error in mouse up handler:", d);
444
- }
445
- });
446
- }, p = () => {
447
- n.forEach((h) => {
448
- try {
449
- h.onTouchEnd();
450
- } catch (d) {
451
- console.error("[Shaders] Error in touch end handler:", d);
452
- }
453
- });
454
- };
455
- return { register(h) {
456
- return n.add(h), e++, e === 1 && (window.addEventListener("mousemove", s), window.addEventListener("touchmove", t), window.addEventListener("mouseup", u), window.addEventListener("touchend", p)), () => {
457
- n.delete(h), e--, e === 0 && (window.removeEventListener("mousemove", s), window.removeEventListener("touchmove", t), window.removeEventListener("mouseup", u), window.removeEventListener("touchend", p));
458
- };
459
- } };
460
- })(), _r = () => {
461
- try {
462
- {
463
- const { MODE: e, DEV: n } = {
464
- DEV: !1,
465
- MODE: "production"
466
- };
467
- return n || e === "development";
468
- }
469
- if (typeof window < "u" && window.location) {
470
- const e = window.location.hostname;
471
- return e === "localhost" || e === "127.0.0.1" || e.endsWith(".local") || e.includes("dev.") || e.startsWith("dev-");
472
- }
473
- return !1;
474
- } catch {
475
- return !1;
476
- }
534
+ var hasLoggedLicenseInfo = false;
535
+ var globalEventManager = (() => {
536
+ let instanceCount = 0;
537
+ const callbacks = /* @__PURE__ */ new Set();
538
+ const globalMouseMoveHandler = (e) => {
539
+ callbacks.forEach((cb) => {
540
+ try {
541
+ cb.onMouseMove(e);
542
+ } catch (error) {
543
+ console.error("[Shaders] Error in mouse move handler:", error);
544
+ }
545
+ });
546
+ };
547
+ const globalTouchMoveHandler = (e) => {
548
+ callbacks.forEach((cb) => {
549
+ try {
550
+ cb.onTouchMove(e);
551
+ } catch (error) {
552
+ console.error("[Shaders] Error in touch move handler:", error);
553
+ }
554
+ });
555
+ };
556
+ const globalMouseUpHandler = () => {
557
+ callbacks.forEach((cb) => {
558
+ try {
559
+ cb.onMouseUp();
560
+ } catch (error) {
561
+ console.error("[Shaders] Error in mouse up handler:", error);
562
+ }
563
+ });
564
+ };
565
+ const globalTouchEndHandler = () => {
566
+ callbacks.forEach((cb) => {
567
+ try {
568
+ cb.onTouchEnd();
569
+ } catch (error) {
570
+ console.error("[Shaders] Error in touch end handler:", error);
571
+ }
572
+ });
573
+ };
574
+ return { register(handlers) {
575
+ callbacks.add(handlers);
576
+ instanceCount++;
577
+ if (instanceCount === 1) {
578
+ window.addEventListener("mousemove", globalMouseMoveHandler);
579
+ window.addEventListener("touchmove", globalTouchMoveHandler);
580
+ window.addEventListener("mouseup", globalMouseUpHandler);
581
+ window.addEventListener("touchend", globalTouchEndHandler);
582
+ }
583
+ return () => {
584
+ callbacks.delete(handlers);
585
+ instanceCount--;
586
+ if (instanceCount === 0) {
587
+ window.removeEventListener("mousemove", globalMouseMoveHandler);
588
+ window.removeEventListener("touchmove", globalTouchMoveHandler);
589
+ window.removeEventListener("mouseup", globalMouseUpHandler);
590
+ window.removeEventListener("touchend", globalTouchEndHandler);
591
+ }
592
+ };
593
+ } };
594
+ })();
595
+ var isDevelopment = () => {
596
+ try {
597
+ {
598
+ const { MODE, DEV } = {
599
+ "DEV": false,
600
+ "MODE": "production"
601
+ };
602
+ return DEV || MODE === "development";
603
+ }
604
+ if (typeof window !== "undefined" && window.location) {
605
+ const hostname = window.location.hostname;
606
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname.endsWith(".local") || hostname.includes("dev.") || hostname.startsWith("dev-");
607
+ }
608
+ return false;
609
+ } catch (error) {
610
+ return false;
611
+ }
477
612
  };
478
- function oi() {
479
- let e = null, n, s, t, u, p;
480
- const h = {
481
- nodes: /* @__PURE__ */ new Map(),
482
- rootId: null,
483
- idToNodeId: /* @__PURE__ */ new Map()
484
- }, d = /* @__PURE__ */ new Map();
485
- let k = null, U = null, B = null, O = !1, Q = !1, V = !1, q = null, ce = !1, ie = !0, D = 0, E = 0, pe = 0, Qe = !1, xe = 0.5, Ae = 0.5, ae = !1, ze = !1, De = null, ge = null, se = !1;
486
- const te = new Ar();
487
- let K = [], Ge = !1, Ee = [], fe = null, Fe = [], ue = null, Je = /* @__PURE__ */ new Set(), Ze = /* @__PURE__ */ new Set(), Ne = 0, be = /* @__PURE__ */ new Set(), Ve = /* @__PURE__ */ new Set(), ve = null, $e = !1;
488
- const Cn = (i, r) => {
489
- i <= 0 || r <= 0 || i === D && r === E || (ve = {
490
- width: i,
491
- height: r
492
- }, $e || ($e = !0, requestAnimationFrame(() => {
493
- if ($e = !1, !ve) return;
494
- const { width: o, height: f } = ve;
495
- ve = null, D = o, E = f, V || (V = !0), n.setSize(o, f, !1);
496
- const c = o / f, b = 2, v = b * c;
497
- s.left = -v / 2, s.right = v / 2, s.top = b / 2, s.bottom = -b / 2, s.updateProjectionMatrix(), u.scale.set(v, b, 1), h.nodes.forEach((m) => {
498
- m.transformUniforms?.aspectRatio && (m.transformUniforms.aspectRatio.value = c), m.resizeCallbacks.forEach((M) => {
499
- try {
500
- M({
501
- width: o,
502
- height: f
503
- });
504
- } catch (z) {
505
- console.error("Error in resize callback:", z);
506
- }
507
- });
508
- }), Z().catch(console.warn);
509
- })));
510
- }, Rn = () => O && !!n && !!t && !!s && !!p && D > 0 && E > 0, kn = (i) => {
511
- if (!n || !s || !u) return;
512
- const r = i[0];
513
- if (!r) return;
514
- let o, f;
515
- if (r.contentBoxSize) {
516
- const c = Array.isArray(r.contentBoxSize) ? r.contentBoxSize[0] : r.contentBoxSize;
517
- c ? (o = Math.round(c.inlineSize), f = Math.round(c.blockSize)) : (o = Math.round(r.contentRect.width), f = Math.round(r.contentRect.height));
518
- } else
519
- o = Math.round(r.contentRect.width), f = Math.round(r.contentRect.height);
520
- o === 0 || f === 0 || Cn(o, f);
521
- }, Tn = (i) => {
522
- const r = i[0];
523
- r && (ce = r.isIntersecting);
524
- }, yn = (i, r) => {
525
- if (i.size !== r.size) return !1;
526
- for (const o of i) if (!r.has(o)) return !1;
527
- return !0;
528
- }, Ce = (i) => {
529
- Ne++;
530
- const r = Wn(i);
531
- return be.add(r), r;
532
- }, Ke = () => {
533
- Ve.forEach((i) => {
534
- try {
535
- i?.renderTarget?.dispose && i.renderTarget.dispose();
536
- } catch {
537
- }
538
- }), Ve.clear();
539
- };
540
- let me = !1;
541
- const Re = () => {
542
- if (!(!h.rootId || !p || ze) && h.nodes.get(h.rootId)) {
543
- if (D === 0 || E === 0) {
544
- me || (me = !0, requestAnimationFrame(() => {
545
- me = !1, D > 0 && E > 0 && Re();
546
- }));
547
- return;
548
- }
549
- ze = !0;
550
- try {
551
- Ve = new Set(be), be.clear();
552
- const i = /* @__PURE__ */ new Set();
553
- Ze.clear(), h.nodes.forEach((o, f) => {
554
- (o.requiresRTT || o.transformRTTActive) && Ze.add(f);
555
- }), Ne = 0;
556
- const r = I(h.rootId, /* @__PURE__ */ new Set(), i);
557
- if (r && p) {
558
- const o = !yn(Je, i), f = p.fragmentNode !== r;
559
- if (o || Qe || f) {
560
- Ke();
561
- try {
562
- p.dispose(), n.renderTarget && n.renderTarget.dispose();
563
- } catch {
564
- }
565
- const c = new ln({ transparent: !0 });
566
- c.fragmentNode = r, c.needsUpdate = !0, u.material = c, p = c, Qe = !1, Je = i;
567
- }
568
- }
569
- } catch (i) {
570
- console.error("Error composing shader tree:", i);
571
- } finally {
572
- ze = !1;
573
- }
574
- Z().catch(console.warn);
575
- }
576
- }, P = (i) => {
577
- const r = d.get(i);
578
- if (!r) return [];
579
- const o = [];
580
- for (const f of r) {
581
- const c = h.nodes.get(f);
582
- c && o.push(c);
583
- }
584
- return o;
585
- }, wn = (i) => {
586
- for (const [r, o] of h.nodes.entries()) if (o.metadata.id === i) return r;
587
- return null;
588
- }, J = (i, r, o, f, c) => {
589
- if (!r.metadata.mask?.source) return i;
590
- const b = r.metadata.mask.source, v = wn(b);
591
- if (!v) return i;
592
- if (f.has(v))
593
- return console.error("Uh oh, looks like you've got a circular dependency in your shader masks."), i;
594
- const m = new Set(f);
595
- m.add(o);
596
- const M = I(v, m);
597
- let z = M;
598
- c && (z = Ce(M).sample(c));
599
- const T = r.metadata.mask.type || "alpha";
600
- return xr(i, z, T);
601
- }, ee = (i, r) => {
602
- if (!r.metadata.transform || !r.transformUniforms || !ne(r.metadata.transform) && !r.transformRTTActive) return i;
603
- const o = Ce(i), f = Ue(de, r.transformUniforms.offsetX, r.transformUniforms.offsetY, r.transformUniforms.rotation, r.transformUniforms.scale, r.transformUniforms.anchorX, r.transformUniforms.anchorY, r.transformUniforms.aspectRatio);
604
- return he(f, o.sample(f), o, r.transformUniforms.edges);
605
- }, X = (i) => !!i.uvTransformFunc && i.requiresChild && i.metadata.blendMode === "normal" && (i.metadata.opacity === void 0 || i.metadata.opacity === 1) && i.metadata.visible !== !1 && !i.metadata.mask?.source && !(i.transformUniforms && i.metadata.transform && ne(i.metadata.transform)), Oe = (i) => {
606
- const r = [];
607
- let o = i;
608
- for (; o; ) {
609
- const f = h.nodes.get(o);
610
- if (!f || !X(f)) break;
611
- r.push(f);
612
- const c = P(f.id);
613
- if (c.length !== 1) break;
614
- const b = c[0];
615
- if (X(b)) o = b.id;
616
- else break;
617
- }
618
- return r;
619
- }, Un = (i) => {
620
- if (i.length === 0) return null;
621
- const r = i[i.length - 1], o = P(r.id);
622
- return o.length === 0 ? null : o.length === 1 ? o[0] : null;
623
- }, ke = (i) => {
624
- if (!i.uvTransformFunc || !X(i)) return !1;
625
- const r = P(i.id);
626
- if (r.length !== 1) return !1;
627
- const o = r[0];
628
- return o.acceptsUVContext && !o.requiresChild ? !0 : o.uvTransformFunc && X(o) ? ke(o) : !1;
629
- }, Be = (i, r, o) => {
630
- const f = [];
631
- let c = i;
632
- for (; c; ) {
633
- const g = h.nodes.get(c);
634
- if (!g) break;
635
- if (f.length >= 2) return I(i, r, o, !0);
636
- if (f.push(g), o && o.add(g.id), g.acceptsUVContext && !g.requiresChild) break;
637
- const a = P(c);
638
- if (a.length !== 1) break;
639
- c = a[0].id;
640
- }
641
- if (f.length === 0) return S(0, 0, 0, 0);
642
- const b = f[f.length - 1];
643
- let v = de;
644
- for (let g = 0; g < f.length; g++) {
645
- const a = f[g];
646
- a.uvTransformFunc && (v = a.uvTransformFunc({
647
- uv: v,
648
- uniforms: a.uniforms,
649
- viewportSize: ye
650
- })), a.transformUniforms && a.metadata.transform && ne(a.metadata.transform) && (v = Ue(v, a.transformUniforms.offsetX, a.transformUniforms.offsetY, a.transformUniforms.rotation, a.transformUniforms.scale, a.transformUniforms.anchorX, a.transformUniforms.anchorY, a.transformUniforms.aspectRatio), a.transformUniforms.edges && (v = re(v, a.transformUniforms.edges)), a.transformRTTActive = !0);
651
- }
652
- for (let g = 0; g < f.length - 1; g++) {
653
- const a = f[g];
654
- if (!a.requiresChild) continue;
655
- const A = (_) => {
656
- a.cleanupCallbacks.push(_);
657
- }, Y = (_) => {
658
- a.beforeRenderCallbacks.push(_);
659
- }, x = (_) => {
660
- a.afterRenderCallbacks.push(_);
661
- }, w = (_) => {
662
- a.resizeCallbacks.push(_);
663
- };
664
- a.cleanupCallbacks.forEach((_) => {
665
- try {
666
- _();
667
- } catch (F) {
668
- console.error("Error in cleanup callback:", F);
669
- }
670
- }), a.cleanupCallbacks = [], a.beforeRenderCallbacks = [], a.afterRenderCallbacks = [], a.resizeCallbacks = [], a.fragmentNodeFunc({
671
- uniforms: a.uniforms ?? {},
672
- childNode: void 0,
673
- uvContext: void 0,
674
- onCleanup: A,
675
- onBeforeRender: Y,
676
- onAfterRender: x,
677
- onResize: w,
678
- canvas: e,
679
- dimensions: {
680
- width: D,
681
- height: E
682
- },
683
- renderer: n
684
- });
685
- }
686
- const m = (g) => {
687
- b.cleanupCallbacks.push(g);
688
- }, M = (g) => {
689
- b.beforeRenderCallbacks.push(g);
690
- }, z = (g) => {
691
- b.afterRenderCallbacks.push(g);
692
- }, T = (g) => {
693
- b.resizeCallbacks.push(g);
694
- };
695
- b.cleanupCallbacks.forEach((g) => {
696
- try {
697
- g();
698
- } catch (a) {
699
- console.error("Error in cleanup callback:", a);
700
- }
701
- }), b.cleanupCallbacks = [], b.beforeRenderCallbacks = [], b.afterRenderCallbacks = [], b.resizeCallbacks = [];
702
- const C = b.fragmentNodeFunc({
703
- uniforms: b.uniforms ?? {},
704
- childNode: void 0,
705
- uvContext: v,
706
- onCleanup: m,
707
- onBeforeRender: M,
708
- onAfterRender: z,
709
- onResize: T,
710
- canvas: e,
711
- dimensions: {
712
- width: D,
713
- height: E
714
- },
715
- renderer: n
716
- });
717
- for (const g of f) if (g.uniforms.edges?.uniform) return he(v, C, null, g.uniforms.edges.uniform);
718
- return C;
719
- }, _e = (i, r, o) => {
720
- if (i.length === 0) return S(0, 0, 0, 0);
721
- const f = Un(i);
722
- let c;
723
- if (f) c = I(f.id, r, o);
724
- else {
725
- const z = i[i.length - 1];
726
- if (P(z.id).length === 0) return S(0, 0, 0, 0);
727
- c = I(z.id, r, o);
728
- }
729
- const b = Ce(c);
730
- let v = de;
731
- for (let z = i.length - 1; z >= 0; z--) {
732
- const T = i[z];
733
- T.uvTransformFunc && (v = T.uvTransformFunc({
734
- uv: v,
735
- uniforms: T.uniforms,
736
- viewportSize: ye
737
- }), T.uniforms.edges?.uniform && (v = re(v, T.uniforms.edges.uniform))), o && o.add(T.id);
738
- }
739
- const m = b.sample(v), M = i[0];
740
- return M.uniforms.edges?.uniform ? he(v, m, b, M.uniforms.edges.uniform) : m;
741
- }, qe = (i, r) => {
742
- const o = [];
743
- for (let f = r; f < i.length; f++) {
744
- const c = i[f];
745
- if (!X(c) || P(c.id).length > 0) break;
746
- o.push(c);
747
- }
748
- return o;
749
- }, Pe = (i, r, o) => {
750
- if (i.length === 0) return r;
751
- const f = Ce(r);
752
- let c = de;
753
- for (let m = i.length - 1; m >= 0; m--) {
754
- const M = i[m];
755
- M.uvTransformFunc && (c = M.uvTransformFunc({
756
- uv: c,
757
- uniforms: M.uniforms,
758
- viewportSize: ye
759
- }), M.uniforms.edges?.uniform && (c = re(c, M.uniforms.edges.uniform))), o && o.add(M.id);
760
- }
761
- const b = f.sample(c), v = i[i.length - 1];
762
- return v.uniforms.edges?.uniform ? he(c, b, f, v.uniforms.edges.uniform) : b;
763
- }, Xe = (i) => {
764
- const r = [], o = [];
765
- let f = !1;
766
- for (let v = 0; v < i.length; v++) {
767
- const m = i[v], M = P(m.id).length > 0;
768
- m.acceptsUVContext && !m.requiresChild && r.push(v), X(m) && !M && (o.push(v), r.length > 0 && (f = !0));
769
- }
770
- if (r.length === 0 || o.length === 0 || !f) return !1;
771
- const c = Math.min(...r), b = Math.max(...o);
772
- for (let v = c + 1; v < b; v++) {
773
- const m = i[v];
774
- if (m.requiresRTT && !X(m) && !(m.acceptsUVContext && !m.requiresChild)) return !1;
775
- }
776
- return !(o.length > 2);
777
- }, Ye = (i, r, o) => {
778
- const f = [], c = [];
779
- i.forEach((v, m) => {
780
- const M = P(v.id).length > 0;
781
- X(v) && !M ? c.push({
782
- node: v,
783
- index: m
784
- }) : v.acceptsUVContext && !v.requiresChild && !M && f.push({
785
- node: v,
786
- index: m
787
- });
788
- });
789
- for (const v of c) {
790
- const m = v.node;
791
- m.cleanupCallbacks.forEach((g) => {
792
- try {
793
- g();
794
- } catch (a) {
795
- console.error("Cleanup error:", a);
796
- }
797
- }), m.cleanupCallbacks = [], m.beforeRenderCallbacks = [], m.afterRenderCallbacks = [], m.resizeCallbacks = [];
798
- const M = (g) => m.cleanupCallbacks.push(g), z = (g) => m.beforeRenderCallbacks.push(g), T = (g) => m.afterRenderCallbacks.push(g), C = (g) => m.resizeCallbacks.push(g);
799
- m.fragmentNodeFunc({
800
- uniforms: m.uniforms ?? {},
801
- childNode: void 0,
802
- uvContext: void 0,
803
- onCleanup: M,
804
- onBeforeRender: z,
805
- onAfterRender: T,
806
- onResize: C,
807
- canvas: e,
808
- dimensions: {
809
- width: D,
810
- height: E
811
- },
812
- renderer: n
813
- }), o && o.add(m.id);
814
- }
815
- let b;
816
- for (let v = 0; v < i.length; v++) {
817
- const m = i[v];
818
- if (m.metadata.visible === !1) continue;
819
- const M = m.metadata.opacity ?? 1;
820
- m.opacityUniform.value = M, o && o.add(m.id);
821
- const z = P(m.id).length > 0;
822
- let T;
823
- const C = f.find((g) => g.index === v);
824
- if (C) {
825
- const g = c.filter((F) => F.index > C.index).sort((F, $) => F.index - $.index).map((F) => F.node);
826
- let a = de;
827
- for (let F = g.length - 1; F >= 0; F--) {
828
- const $ = g[F];
829
- $.uvTransformFunc && (a = $.uvTransformFunc({
830
- uv: a,
831
- uniforms: $.uniforms,
832
- viewportSize: ye
833
- })), $.transformUniforms && $.metadata.transform && ne($.metadata.transform) && (a = Ue(a, $.transformUniforms.offsetX, $.transformUniforms.offsetY, $.transformUniforms.rotation, $.transformUniforms.scale, $.transformUniforms.anchorX, $.transformUniforms.anchorY, $.transformUniforms.aspectRatio), $.transformUniforms.edges && (a = re(a, $.transformUniforms.edges)), $.transformRTTActive = !0), $.uniforms.edges?.uniform && (a = re(a, $.uniforms.edges.uniform));
834
- }
835
- C.node.transformUniforms && C.node.metadata.transform && ne(C.node.metadata.transform) && (a = Ue(a, C.node.transformUniforms.offsetX, C.node.transformUniforms.offsetY, C.node.transformUniforms.rotation, C.node.transformUniforms.scale, C.node.transformUniforms.anchorX, C.node.transformUniforms.anchorY, C.node.transformUniforms.aspectRatio), C.node.transformUniforms.edges && (a = re(a, C.node.transformUniforms.edges)), C.node.transformRTTActive = !0), m.cleanupCallbacks.forEach((F) => {
836
- try {
837
- F();
838
- } catch ($) {
839
- console.error("Cleanup error:", $);
840
- }
841
- }), m.cleanupCallbacks = [], m.beforeRenderCallbacks = [], m.afterRenderCallbacks = [], m.resizeCallbacks = [];
842
- const A = (F) => m.cleanupCallbacks.push(F), Y = (F) => m.beforeRenderCallbacks.push(F), x = (F) => m.afterRenderCallbacks.push(F), w = (F) => m.resizeCallbacks.push(F);
843
- let _ = m.fragmentNodeFunc({
844
- uniforms: m.uniforms ?? {},
845
- childNode: void 0,
846
- uvContext: a,
847
- onCleanup: A,
848
- onBeforeRender: Y,
849
- onAfterRender: x,
850
- onResize: w,
851
- canvas: e,
852
- dimensions: {
853
- width: D,
854
- height: E
855
- },
856
- renderer: n
857
- });
858
- if (g.length > 0) {
859
- const F = g[0];
860
- F.uniforms.edges?.uniform && (_ = he(a, _, null, F.uniforms.edges.uniform));
861
- }
862
- T = J(_, m, m.id, r, a);
863
- } else {
864
- if (c.find((g) => g.index === v)) continue;
865
- if (z) {
866
- if (ke(m)) T = Be(m.id, r, o);
867
- else if (X(m)) {
868
- const a = Oe(m.id);
869
- a.length > 1 ? T = _e(a, r, o) : T = I(m.id, r, o);
870
- } else T = I(m.id, r, o);
871
- const g = c.filter((a) => a.index > v).sort((a, A) => a.index - A.index).map((a) => a.node);
872
- if (g.length > 0) {
873
- const a = Ce(T);
874
- let A = de;
875
- for (let x = g.length - 1; x >= 0; x--) {
876
- const w = g[x];
877
- w.uvTransformFunc && (A = w.uvTransformFunc({
878
- uv: A,
879
- uniforms: w.uniforms,
880
- viewportSize: ye
881
- })), w.transformUniforms && w.metadata.transform && ne(w.metadata.transform) && (A = Ue(A, w.transformUniforms.offsetX, w.transformUniforms.offsetY, w.transformUniforms.rotation, w.transformUniforms.scale, w.transformUniforms.anchorX, w.transformUniforms.anchorY, w.transformUniforms.aspectRatio), w.transformUniforms.edges && (A = re(A, w.transformUniforms.edges)), w.transformRTTActive = !0), w.uniforms.edges?.uniform && (A = re(A, w.uniforms.edges.uniform));
882
- }
883
- T = a.sample(A);
884
- const Y = g[g.length - 1];
885
- Y.transformUniforms?.edges && (T = he(A, T, a, Y.transformUniforms.edges));
886
- }
887
- } else {
888
- m.cleanupCallbacks.forEach((w) => {
889
- try {
890
- w();
891
- } catch (_) {
892
- console.error("Cleanup error:", _);
893
- }
894
- }), m.cleanupCallbacks = [], m.beforeRenderCallbacks = [], m.afterRenderCallbacks = [], m.resizeCallbacks = [];
895
- const g = (w) => m.cleanupCallbacks.push(w), a = (w) => m.beforeRenderCallbacks.push(w), A = (w) => m.afterRenderCallbacks.push(w), Y = (w) => m.resizeCallbacks.push(w);
896
- let x = b;
897
- m.requiresRTT && b !== void 0 && (x = H(S(0, 0, 0, 0), b, "normal", 1)), T = J(ee(m.fragmentNodeFunc({
898
- uniforms: m.uniforms ?? {},
899
- childNode: x,
900
- onCleanup: g,
901
- onBeforeRender: a,
902
- onAfterRender: A,
903
- onResize: Y,
904
- canvas: e,
905
- dimensions: {
906
- width: D,
907
- height: E
908
- },
909
- renderer: n
910
- }), m), m, m.id, r);
911
- }
912
- }
913
- m.requiresChild && m.metadata.blendMode === "normal" && !z ? b = H(S(0, 0, 0, 0), T, "normal", m.opacityUniform) : b === void 0 ? b = H(S(1, 1, 1, 0), T, m.metadata.blendMode, m.opacityUniform) : b = H(b, T, m.metadata.blendMode, m.opacityUniform);
914
- }
915
- return b ?? S(0, 0, 0, 0);
916
- }, I = (i, r = /* @__PURE__ */ new Set(), o, f = !1) => {
917
- if (D === 0 || E === 0) return S(0, 0, 0, 0);
918
- const c = h.nodes.get(i);
919
- if (!c) return S(0, 0, 0, 0);
920
- const b = (T) => {
921
- c.cleanupCallbacks.push(T);
922
- }, v = (T) => {
923
- c.beforeRenderCallbacks.push(T);
924
- }, m = (T) => {
925
- c.afterRenderCallbacks.push(T);
926
- }, M = (T) => {
927
- c.resizeCallbacks.push(T);
928
- }, z = P(i);
929
- if (z.length === 0)
930
- return c.cleanupCallbacks.forEach((T) => {
931
- try {
932
- T();
933
- } catch (C) {
934
- console.error("Error in cleanup callback:", C);
935
- }
936
- }), c.cleanupCallbacks = [], c.beforeRenderCallbacks = [], c.afterRenderCallbacks = [], c.resizeCallbacks = [], J(ee(c.fragmentNodeFunc({
937
- uniforms: c.uniforms ?? {},
938
- childNode: void 0,
939
- onCleanup: b,
940
- onBeforeRender: v,
941
- onAfterRender: m,
942
- onResize: M,
943
- canvas: e,
944
- dimensions: {
945
- width: D,
946
- height: E
947
- },
948
- renderer: n
949
- }), c), c, i, r);
950
- {
951
- const T = [...z].sort((C, g) => C.metadata.renderOrder - g.metadata.renderOrder);
952
- if (c.parentId === null) {
953
- if (!f && Xe(T)) return J(ee(Ye(T, r, o), c), c, i, r);
954
- let C;
955
- for (let g = 0; g < T.length; g++) {
956
- const a = T[g];
957
- let A;
958
- if (a.metadata.opacity === void 0 ? (A = 1, a.opacityUniform.value = A) : (A = a.metadata.opacity, a.opacityUniform.value = A), a.metadata.visible === !1) continue;
959
- o && o.add(a.id);
960
- const Y = P(a.id).length > 0;
961
- let x;
962
- if (Y) if (f) x = I(a.id, r, o, !0);
963
- else if (ke(a)) x = Be(a.id, r, o);
964
- else if (X(a)) {
965
- const w = Oe(a.id);
966
- w.length > 1 ? x = _e(w, r, o) : x = I(a.id, r, o);
967
- } else x = I(a.id, r, o);
968
- else {
969
- if (X(a) && a.requiresChild && C !== void 0) {
970
- const w = qe(T, g);
971
- if (w.length > 1) {
972
- x = Pe(w, C, o), g += w.length - 1, C = x;
973
- continue;
974
- }
975
- }
976
- {
977
- const w = (L) => {
978
- a.cleanupCallbacks.push(L);
979
- }, _ = (L) => {
980
- a.beforeRenderCallbacks.push(L);
981
- }, F = (L) => {
982
- a.afterRenderCallbacks.push(L);
983
- }, $ = (L) => {
984
- a.resizeCallbacks.push(L);
985
- };
986
- let Te = C;
987
- a.requiresRTT && C !== void 0 && (Te = H(S(0, 0, 0, 0), C, "normal", 1)), a.cleanupCallbacks.forEach((L) => {
988
- try {
989
- L();
990
- } catch (Gn) {
991
- console.error("Error in cleanup callback:", Gn);
992
- }
993
- }), a.cleanupCallbacks = [], a.beforeRenderCallbacks = [], a.afterRenderCallbacks = [], a.resizeCallbacks = [], x = J(ee(a.fragmentNodeFunc({
994
- uniforms: a.uniforms ?? {},
995
- childNode: Te,
996
- onCleanup: w,
997
- onBeforeRender: _,
998
- onAfterRender: F,
999
- onResize: $,
1000
- canvas: e,
1001
- dimensions: {
1002
- width: D,
1003
- height: E
1004
- },
1005
- renderer: n
1006
- }), a), a, a.id, r);
1007
- }
1008
- }
1009
- a.requiresChild && a.metadata.blendMode === "normal" && !Y ? C = H(S(0, 0, 0, 0), x, "normal", a.opacityUniform) : C === void 0 ? c.requiresRTT || A !== 1 ? C = H(S(1, 1, 1, 0), x, a.metadata.blendMode, a.opacityUniform) : C = x : C = H(C, x, a.metadata.blendMode, a.opacityUniform);
1010
- }
1011
- return c.cleanupCallbacks.forEach((g) => {
1012
- try {
1013
- g();
1014
- } catch (a) {
1015
- console.error("Error in cleanup callback:", a);
1016
- }
1017
- }), c.cleanupCallbacks = [], c.beforeRenderCallbacks = [], c.afterRenderCallbacks = [], c.resizeCallbacks = [], J(ee(c.fragmentNodeFunc({
1018
- uniforms: c.uniforms ?? {},
1019
- childNode: C,
1020
- onCleanup: b,
1021
- onBeforeRender: v,
1022
- onAfterRender: m,
1023
- onResize: M,
1024
- canvas: e,
1025
- dimensions: {
1026
- width: D,
1027
- height: E
1028
- },
1029
- renderer: n
1030
- }), c), c, i, r);
1031
- } else {
1032
- if (!f && Xe(T)) {
1033
- const g = Ye(T, r, o);
1034
- return J(ee(c.fragmentNodeFunc({
1035
- uniforms: c.uniforms ?? {},
1036
- childNode: g,
1037
- onCleanup: b,
1038
- onBeforeRender: v,
1039
- onAfterRender: m,
1040
- onResize: M,
1041
- canvas: e,
1042
- dimensions: {
1043
- width: D,
1044
- height: E
1045
- },
1046
- renderer: n
1047
- }), c), c, i, r);
1048
- }
1049
- let C;
1050
- for (let g = 0; g < T.length; g++) {
1051
- const a = T[g];
1052
- let A;
1053
- if (a.metadata.opacity === void 0 ? (A = 1, a.opacityUniform.value = A) : (A = a.metadata.opacity, a.opacityUniform.value = A), a.metadata.visible === !1) continue;
1054
- o && o.add(a.id);
1055
- const Y = P(a.id).length > 0;
1056
- let x;
1057
- if (Y) if (f) x = I(a.id, r, o, !0);
1058
- else if (ke(a)) x = Be(a.id, r, o);
1059
- else if (X(a)) {
1060
- const w = Oe(a.id);
1061
- w.length > 1 ? x = _e(w, r, o) : x = I(a.id, r, o);
1062
- } else x = I(a.id, r, o);
1063
- else {
1064
- if (X(a) && a.requiresChild && C !== void 0) {
1065
- const w = qe(T, g);
1066
- if (w.length > 1) {
1067
- x = Pe(w, C, o), g += w.length - 1, C = x;
1068
- continue;
1069
- }
1070
- }
1071
- {
1072
- const w = (L) => {
1073
- a.cleanupCallbacks.push(L);
1074
- }, _ = (L) => {
1075
- a.beforeRenderCallbacks.push(L);
1076
- }, F = (L) => {
1077
- a.afterRenderCallbacks.push(L);
1078
- }, $ = (L) => {
1079
- a.resizeCallbacks.push(L);
1080
- };
1081
- let Te = C;
1082
- a.requiresRTT && C !== void 0 && (Te = H(S(0, 0, 0, 0), C, "normal", 1)), a.cleanupCallbacks = [], a.beforeRenderCallbacks = [], a.afterRenderCallbacks = [], a.resizeCallbacks = [], x = J(ee(a.fragmentNodeFunc({
1083
- uniforms: a.uniforms ?? {},
1084
- childNode: Te,
1085
- onCleanup: w,
1086
- onBeforeRender: _,
1087
- onAfterRender: F,
1088
- onResize: $,
1089
- canvas: e,
1090
- dimensions: {
1091
- width: D,
1092
- height: E
1093
- },
1094
- renderer: n
1095
- }), a), a, a.id, r);
1096
- }
1097
- }
1098
- a.requiresChild && a.metadata.blendMode === "normal" && !Y ? C = H(S(0, 0, 0, 0), x, "normal", a.opacityUniform) : C === void 0 ? c.requiresRTT || A !== 1 ? C = H(S(1, 1, 1, 0), x, a.metadata.blendMode, a.opacityUniform) : C = x : C = H(C, x, a.metadata.blendMode, a.opacityUniform);
1099
- }
1100
- return c.cleanupCallbacks.forEach((g) => {
1101
- try {
1102
- g();
1103
- } catch (a) {
1104
- console.error("Error in cleanup callback:", a);
1105
- }
1106
- }), c.cleanupCallbacks = [], c.beforeRenderCallbacks = [], c.afterRenderCallbacks = [], c.resizeCallbacks = [], J(ee(c.fragmentNodeFunc({
1107
- uniforms: c.uniforms ?? {},
1108
- childNode: C,
1109
- onCleanup: b,
1110
- onBeforeRender: v,
1111
- onAfterRender: m,
1112
- onResize: M,
1113
- canvas: e,
1114
- dimensions: {
1115
- width: D,
1116
- height: E
1117
- },
1118
- renderer: n
1119
- }), c), c, i, r);
1120
- }
1121
- }
1122
- }, en = (i, r, o, f, c = {}, b) => {
1123
- if (r === null) {
1124
- const C = K.findIndex((g) => g.id === i);
1125
- if (C !== -1) {
1126
- K.splice(C, 1);
1127
- return;
1128
- }
1129
- Ie(i);
1130
- return;
1131
- }
1132
- if (!Ge) {
1133
- const C = K.findIndex((g) => g.id === i);
1134
- C !== -1 ? K[C] = {
1135
- id: i,
1136
- fragmentNodeFunc: r,
1137
- parentId: o,
1138
- metadata: f,
1139
- uniforms: c,
1140
- componentDefinition: b
1141
- } : K.push({
1142
- id: i,
1143
- fragmentNodeFunc: r,
1144
- parentId: o,
1145
- metadata: f,
1146
- uniforms: c,
1147
- componentDefinition: b
1148
- });
1149
- return;
1150
- }
1151
- let v = 0;
1152
- if (o !== null) {
1153
- const C = d.get(o);
1154
- if (C && C.size > 0) {
1155
- let g = 0;
1156
- for (const a of C) {
1157
- const A = h.nodes.get(a);
1158
- A && A.metadata.renderOrder > g && (g = A.metadata.renderOrder);
1159
- }
1160
- v = g + 1;
1161
- }
1162
- }
1163
- const m = G(f?.opacity !== void 0 ? f.opacity : 1);
1164
- let M;
1165
- if (f?.transform) {
1166
- const C = D / Math.max(1, E);
1167
- M = {
1168
- offsetX: G(f.transform.offsetX),
1169
- offsetY: G(f.transform.offsetY),
1170
- rotation: G(f.transform.rotation),
1171
- scale: G(f.transform.scale),
1172
- anchorX: G(f.transform.anchorX),
1173
- anchorY: G(f.transform.anchorY),
1174
- edges: G(f.transform.edges === "stretch" ? 0 : f.transform.edges === "transparent" ? 1 : f.transform.edges === "mirror" ? 2 : 3),
1175
- aspectRatio: G(C)
1176
- };
1177
- }
1178
- const z = {
1179
- id: i,
1180
- componentName: b?.name || "Unknown",
1181
- fragmentNodeFunc: r,
1182
- parentId: o,
1183
- requiresRTT: b?.requiresRTT || !1,
1184
- requiresChild: b?.requiresChild || !1,
1185
- opacityUniform: m,
1186
- metadata: {
1187
- blendMode: f?.blendMode || "normal",
1188
- opacity: f?.opacity,
1189
- visible: f?.visible !== !1,
1190
- id: f?.id,
1191
- mask: f?.mask,
1192
- renderOrder: f?.renderOrder !== void 0 ? f?.renderOrder : v,
1193
- transform: f?.transform
1194
- },
1195
- uniforms: c,
1196
- cleanupCallbacks: [],
1197
- beforeRenderCallbacks: [],
1198
- afterRenderCallbacks: [],
1199
- resizeCallbacks: [],
1200
- transformUniforms: M,
1201
- transformRTTActive: !1,
1202
- uvTransformFunc: b?.uvTransformNode,
1203
- acceptsUVContext: b?.acceptsUVContext || !1
1204
- };
1205
- h.nodes.set(i, z), o === null && (h.rootId = i);
1206
- const T = d.get(o) || /* @__PURE__ */ new Set();
1207
- T.add(i), d.set(o, T), p && O && D > 0 && E > 0 ? (Ee.includes(i) || Ee.push(i), fe === null && (fe = requestAnimationFrame(() => {
1208
- fe = null, Ee = [], Re();
1209
- }))) : p && O && (me || (me = !0, requestAnimationFrame(() => {
1210
- me = !1, D > 0 && E > 0 && Re();
1211
- })));
1212
- }, Sn = (i, r, o) => {
1213
- const f = h.nodes.get(i);
1214
- if (!f || !f.uniforms) return;
1215
- const c = f.uniforms[r];
1216
- !c || !c.uniform || (c.transform ? Or(c, o) : c.uniform.value = o, Z());
1217
- }, Mn = (i, r) => {
1218
- const o = h.nodes.get(i);
1219
- if (!o) return;
1220
- let f = !1;
1221
- r.blendMode !== void 0 && o.metadata.blendMode !== r.blendMode && (o.metadata.blendMode = r.blendMode, f = !0), r.opacity !== void 0 && o.metadata.opacity !== r.opacity && (o.metadata.opacity = r.opacity, o.opacityUniform.value = r.opacity), r.renderOrder !== void 0 && o.metadata.renderOrder !== r.renderOrder && (o.metadata.renderOrder = r.renderOrder, f = !0);
1222
- const c = r.visible !== !1;
1223
- if (o.metadata.visible !== c && (o.metadata.visible = c, f = !0), r.id !== void 0 && o.metadata.id !== r.id && (o.metadata.id = r.id, f = !0), r.mask !== void 0 && (o.metadata.mask?.source !== r.mask?.source || o.metadata.mask?.type !== r.mask?.type) && (o.metadata.mask = r.mask, f = !0), r.transform !== void 0) {
1224
- const b = o.metadata.transform ? ne(o.metadata.transform) : !1, v = ne(r.transform);
1225
- if (o.metadata.transform = r.transform, !o.transformUniforms && r.transform) {
1226
- const m = D / Math.max(1, E);
1227
- o.transformUniforms = {
1228
- offsetX: G(r.transform.offsetX),
1229
- offsetY: G(r.transform.offsetY),
1230
- rotation: G(r.transform.rotation),
1231
- scale: G(r.transform.scale),
1232
- anchorX: G(r.transform.anchorX),
1233
- anchorY: G(r.transform.anchorY),
1234
- edges: G(r.transform.edges === "stretch" ? 0 : r.transform.edges === "transparent" ? 1 : r.transform.edges === "mirror" ? 2 : 3),
1235
- aspectRatio: G(m)
1236
- };
1237
- } else o.transformUniforms && (o.transformUniforms.offsetX.value = r.transform.offsetX, o.transformUniforms.offsetY.value = r.transform.offsetY, o.transformUniforms.rotation.value = r.transform.rotation, o.transformUniforms.scale.value = r.transform.scale, o.transformUniforms.anchorX.value = r.transform.anchorX, o.transformUniforms.anchorY.value = r.transform.anchorY, o.transformUniforms.edges.value = r.transform.edges === "stretch" ? 0 : r.transform.edges === "transparent" ? 1 : r.transform.edges === "mirror" ? 2 : 3);
1238
- v && !o.transformRTTActive && (o.transformRTTActive = !0, f = !0), !b && v && !o.transformRTTActive && (f = !0);
1239
- }
1240
- f && p && O ? (Fe.includes(i) || Fe.push(i), ue === null && (ue = requestAnimationFrame(() => {
1241
- ue = null, Fe = [], Re();
1242
- }))) : Z();
1243
- }, Ie = (i) => {
1244
- if (!h.nodes.has(i)) return;
1245
- const r = h.nodes.get(i);
1246
- if (r && r.cleanupCallbacks.length > 0) for (const f of r.cleanupCallbacks) try {
1247
- f();
1248
- } catch (c) {
1249
- console.error(`Error executing cleanup callback for node ${i}:`, c);
1250
- }
1251
- const o = P(i);
1252
- for (const f of o) Ie(f.id);
1253
- if (h.rootId === i && (h.rootId = null), r) {
1254
- const f = d.get(r.parentId);
1255
- f && (f.delete(i), f.size === 0 && d.delete(r.parentId));
1256
- }
1257
- h.nodes.delete(i), p && O && Re();
1258
- }, xn = (i) => {
1259
- const r = {
1260
- deltaTime: i,
1261
- pointer: {
1262
- x: xe,
1263
- y: Ae
1264
- },
1265
- pointerActive: ae,
1266
- dimensions: {
1267
- width: D,
1268
- height: E
1269
- }
1270
- };
1271
- for (const o of h.nodes.values()) if (o.beforeRenderCallbacks.length > 0) for (const f of o.beforeRenderCallbacks) try {
1272
- f(r);
1273
- } catch (c) {
1274
- console.error(`Error executing before render callback for node ${o.id}:`, c);
1275
- }
1276
- }, An = (i) => {
1277
- const r = {
1278
- deltaTime: i,
1279
- pointer: {
1280
- x: xe,
1281
- y: Ae
1282
- },
1283
- pointerActive: ae,
1284
- dimensions: {
1285
- width: D,
1286
- height: E
1287
- }
1288
- };
1289
- for (const o of h.nodes.values()) if (o.afterRenderCallbacks.length > 0) for (const f of o.afterRenderCallbacks) try {
1290
- f(r);
1291
- } catch (c) {
1292
- console.error(`Error executing after render callback for node ${o.id}:`, c);
1293
- }
1294
- }, Z = async () => {
1295
- if (!Rn()) return;
1296
- const i = se ? performance.now() : 0, r = i || performance.now(), o = pe > 0 ? (r - pe) / 1e3 : 0.016;
1297
- if (!ce && pe > 0 && r - pe < 1e3)
1298
- return;
1299
- const c = Math.min(o, 0.1);
1300
- pe = r, se && performance.mark("shader-cpu-start"), xn(c);
1301
- try {
1302
- if (ze) return;
1303
- if (se && performance.mark("shader-gpu-start"), n.render(t, s), An(c), se) {
1304
- if (performance.mark("shader-gpu-end"), n instanceof He) try {
1305
- const b = n.backend;
1306
- if (b && b.get && b.get(n)) {
1307
- const v = b.get(n);
1308
- if (v?.timestampQuery) {
1309
- const m = v.timestampQuery.getResult();
1310
- m != null && te.recordGpuTime(m / 1e6);
1311
- }
1312
- }
1313
- } catch {
1314
- }
1315
- try {
1316
- performance.measure("shader-gpu-time", "shader-gpu-start", "shader-gpu-end");
1317
- const b = performance.getEntriesByName("shader-gpu-time")[0];
1318
- b && te.recordGpuTime(b.duration), performance.clearMarks("shader-gpu-start"), performance.clearMarks("shader-gpu-end"), performance.clearMeasures("shader-gpu-time");
1319
- } catch {
1320
- }
1321
- }
1322
- if (se) {
1323
- performance.mark("shader-cpu-end");
1324
- try {
1325
- performance.measure("shader-cpu-time", "shader-cpu-start", "shader-cpu-end");
1326
- const v = performance.getEntriesByName("shader-cpu-time")[0];
1327
- v && te.recordCpuTime(v.duration), performance.clearMarks("shader-cpu-start"), performance.clearMarks("shader-cpu-end"), performance.clearMeasures("shader-cpu-time");
1328
- } catch {
1329
- }
1330
- const b = performance.now() - i;
1331
- te.recordFrame(b);
1332
- }
1333
- } catch (b) {
1334
- console.error("Render frame error:", b);
1335
- }
1336
- }, zn = () => {
1337
- const i = Math.max(0, h.nodes.size - 1), r = Ne;
1338
- te.updateNodeCounts(i, r);
1339
- }, Dn = () => {
1340
- zn();
1341
- const i = n?.info;
1342
- return te.getStats(i);
1343
- }, nn = () => {
1344
- if (k || !ie) return;
1345
- te.setRendering(!0);
1346
- const i = () => {
1347
- k = requestAnimationFrame(i), Z().catch(console.warn);
1348
- };
1349
- i();
1350
- }, tn = () => {
1351
- k && (cancelAnimationFrame(k), k = null), te.setRendering(!1);
1352
- }, rn = (i) => {
1353
- if (!e) return;
1354
- let r, o;
1355
- if ("touches" in i) {
1356
- if (i.touches.length === 0) return;
1357
- r = i.touches[0].clientX, o = i.touches[0].clientY;
1358
- } else
1359
- r = i.clientX, o = i.clientY;
1360
- const f = e.getBoundingClientRect(), c = (r - f.left) / f.width, b = (o - f.top) / f.height;
1361
- xe = c, Ae = b;
1362
- }, En = (i) => {
1363
- !O || !e || rn(i);
1364
- }, Fn = (i) => {
1365
- !O || !e || rn(i);
1366
- }, $n = () => {
1367
- O && (ae = !1, Z().catch(console.warn));
1368
- }, On = () => {
1369
- O && (ae = !1, Z().catch(console.warn));
1370
- }, on = () => {
1371
- ae = !0, Z().catch(console.warn);
1372
- }, an = () => {
1373
- ae = !0, Z().catch(console.warn);
1374
- }, Bn = () => {
1375
- if (K.length === 0) return;
1376
- const i = [...K];
1377
- K = [];
1378
- for (const { id: r, fragmentNodeFunc: o, parentId: f, metadata: c, uniforms: b, componentDefinition: v } of i) o && en(r, o, f, c, b, v);
1379
- }, _n = async ({ canvas: i, enablePerformanceTracking: r = !1 }) => {
1380
- if (O || Q) return;
1381
- se = r, Q = !0, q = new AbortController();
1382
- const o = q;
1383
- try {
1384
- if (e = i, t = new Yn(), t.background = null, s = new Xn(-1, 1, 1, -1, 0.1, 10), s.position.z = 1, s.lookAt(0, 0, 0), De = Br.register({
1385
- onMouseMove: En,
1386
- onTouchMove: Fn,
1387
- onMouseUp: $n,
1388
- onTouchEnd: On
1389
- }), i.addEventListener("mousedown", on), i.addEventListener("touchstart", an), ge = () => {
1390
- sn();
1391
- }, window.addEventListener("beforeunload", ge), o.signal.aborted) return;
1392
- try {
1393
- const z = {
1394
- canvas: i,
1395
- antialias: !0,
1396
- alpha: !0,
1397
- depth: !1,
1398
- powerPreference: "high-performance"
1399
- };
1400
- if (se && (z.forceWebGL = !1, z.requiredFeatures = ["timestamp-query"]), n = new He(z), await n.init(), o.signal.aborted) return;
1401
- } catch (z) {
1402
- if (o.signal.aborted) return;
1403
- console.warn("[Shaders] WebGPU initialization failed, falling back to WebGL:", z);
1404
- try {
1405
- if (n = new Zt({
1406
- canvas: i,
1407
- antialias: !0,
1408
- alpha: !0,
1409
- depth: !1,
1410
- powerPreference: "high-performance"
1411
- }), o.signal.aborted) return;
1412
- } catch (T) {
1413
- if (o.signal.aborted) return;
1414
- console.error("[Shaders] Both WebGPU and WebGL initialization failed:", T);
1415
- return;
1416
- }
1417
- }
1418
- if (o.signal.aborted) return;
1419
- n.setPixelRatio(Math.min(window.devicePixelRatio, 2)), n.outputColorSpace = Nn, p = new ln({ transparent: !0 }), p.fragmentNode = S(0, 0, 0, 0), u = new Pn(new Jn(2, 2), p), t.add(u);
1420
- const f = i.parentElement;
1421
- if (!f) {
1422
- console.warn("[Shaders] Canvas has no parent element for resize observation");
1423
- return;
1424
- }
1425
- U = new ResizeObserver(kn), U.observe(f), B = new IntersectionObserver(Tn, { threshold: 0 }), B.observe(i);
1426
- const c = i.getBoundingClientRect();
1427
- ce = c.width > 0 && c.height > 0 && c.top < window.innerHeight && c.bottom > 0 && c.left < window.innerWidth && c.right > 0, ie = !0;
1428
- const { width: b, height: v } = i.getBoundingClientRect(), m = Math.round(b), M = Math.round(v);
1429
- if (m > 0 && M > 0) {
1430
- D = m, E = M, V = !0, n.setSize(m, M, !1);
1431
- const z = m / M, T = 2, C = T * z;
1432
- s.left = -C / 2, s.right = C / 2, s.top = T / 2, s.bottom = -T / 2, s.updateProjectionMatrix(), u.scale.set(C, T, 1), await Z();
1433
- } else V = !1;
1434
- ie && nn(), o.signal.aborted || (O = !0, Ge = !0, Bn());
1435
- } catch (f) {
1436
- console.error("[Shaders] Initialization error:", f);
1437
- } finally {
1438
- Q = !1, q === o && (q = null);
1439
- }
1440
- }, Ln = () => {
1441
- !_r() || gn || (console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production."), gn = !0);
1442
- }, sn = () => {
1443
- if (q && q.abort(), U && (U.disconnect(), U = null), B && (B.disconnect(), B = null), De && (De(), De = null), e && (e.removeEventListener("mousedown", on), e.removeEventListener("touchstart", an)), ge && (window.removeEventListener("beforeunload", ge), ge = null), tn(), Ke(), be.forEach((i) => {
1444
- try {
1445
- i?.renderTarget?.dispose && i.renderTarget.dispose();
1446
- } catch {
1447
- }
1448
- }), be.clear(), h.nodes.clear(), h.rootId = null, h.idToNodeId.clear(), d.clear(), K = [], Ge = !1, Ee = [], fe !== null && (cancelAnimationFrame(fe), fe = null), Fe = [], ue !== null && (cancelAnimationFrame(ue), ue = null), ve = null, $e = !1, u) {
1449
- t && t.remove(u);
1450
- try {
1451
- u.geometry && typeof u.geometry.dispose == "function" && u.geometry.dispose();
1452
- } catch {
1453
- }
1454
- try {
1455
- u.material instanceof qn && typeof u.material.dispose == "function" && u.material.dispose();
1456
- } catch {
1457
- }
1458
- }
1459
- if (n && typeof n.dispose == "function") try {
1460
- n.dispose();
1461
- } catch {
1462
- }
1463
- e = null, n = null, s = null, t = null, u = null, p = null, O = !1, Q = !1, V = !1, q = null, D = 0, E = 0, ce = !1, ie = !0, xe = 0.5, Ae = 0.5, ae = !1;
1464
- };
1465
- return {
1466
- initialize: _n,
1467
- cleanup: sn,
1468
- registerNode: en,
1469
- removeNode: Ie,
1470
- updateUniformValue: Sn,
1471
- updateNodeMetadata: Mn,
1472
- showLicenseWarning: Ln,
1473
- isInitialized: () => O,
1474
- startAnimation: nn,
1475
- stopAnimation: tn,
1476
- getPerformanceStats: Dn,
1477
- getNodeRegistry: () => ({ nodes: new Map(h.nodes) }),
1478
- getRendererType: () => n ? n instanceof He ? "webgpu" : "webgl" : null,
1479
- __testing: {
1480
- isUVComposable: X,
1481
- canSkipRTT: ke,
1482
- hasUVPropagationOpportunity: Xe,
1483
- needsTransformation: ne,
1484
- findUVChain: Oe,
1485
- findSiblingUVChain: qe,
1486
- findChildNodes: P,
1487
- composeUVContextChain: Be,
1488
- composeUVChain: _e,
1489
- composeSiblingUVChain: Pe,
1490
- composeSiblingsWithUVContext: Ye,
1491
- applyMaskIfNeeded: J,
1492
- applyNodeTransformation: ee,
1493
- getNodeRegistry: () => h,
1494
- getParentToChildren: () => d
1495
- }
1496
- };
613
+ function shaderRenderer() {
614
+ let canvasElement = null;
615
+ let renderer;
616
+ let camera;
617
+ let scene;
618
+ let mesh;
619
+ let material;
620
+ const nodeRegistry = {
621
+ nodes: /* @__PURE__ */ new Map(),
622
+ rootId: null,
623
+ idToNodeId: /* @__PURE__ */ new Map()
624
+ };
625
+ const parentToChildren = /* @__PURE__ */ new Map();
626
+ let animationFrameId = null;
627
+ let resizeObserver = null;
628
+ let intersectionObserver = null;
629
+ let isInitialized = false;
630
+ let isInitializing = false;
631
+ let hasInitialDimensions = false;
632
+ let initializationAbortController = null;
633
+ let isVisible = false;
634
+ let shouldAnimate = true;
635
+ let currentWidth = 0;
636
+ let currentHeight = 0;
637
+ let lastRenderTime = 0;
638
+ let needsMaterialRefresh = false;
639
+ let pointerX = .5;
640
+ let pointerY = .5;
641
+ let pointerActive = false;
642
+ let isUpdatingMaterial = false;
643
+ let globalEventUnregister = null;
644
+ let unloadHandler = null;
645
+ let enablePerformanceTracking = false;
646
+ const performanceTracker = new PerformanceTracker();
647
+ let pendingRegistrationQueue = [];
648
+ let isRendererReady = false;
649
+ let registrationQueue = [];
650
+ let registrationBatchRAF = null;
651
+ let metadataUpdateQueue = [];
652
+ let metadataUpdateBatchRAF = null;
653
+ let lastComposedNodes = /* @__PURE__ */ new Set();
654
+ let activeRTTNodes = /* @__PURE__ */ new Set();
655
+ let actualRTTOperations = 0;
656
+ let currentTextures = /* @__PURE__ */ new Set();
657
+ let previousTextures = /* @__PURE__ */ new Set();
658
+ let pendingResize = null;
659
+ let isResizeScheduled = false;
660
+ const updateRendererDimensions = (width, height) => {
661
+ if (width <= 0 || height <= 0) return;
662
+ if (width === currentWidth && height === currentHeight) return;
663
+ pendingResize = {
664
+ width,
665
+ height
666
+ };
667
+ if (!isResizeScheduled) {
668
+ isResizeScheduled = true;
669
+ requestAnimationFrame(() => {
670
+ isResizeScheduled = false;
671
+ if (!pendingResize) return;
672
+ const { width: width$1, height: height$1 } = pendingResize;
673
+ pendingResize = null;
674
+ currentWidth = width$1;
675
+ currentHeight = height$1;
676
+ if (!hasInitialDimensions) hasInitialDimensions = true;
677
+ renderer.setSize(width$1, height$1, false);
678
+ const aspectRatio = width$1 / height$1;
679
+ const frustumHeight = 2;
680
+ const frustumWidth = frustumHeight * aspectRatio;
681
+ camera.left = -frustumWidth / 2;
682
+ camera.right = frustumWidth / 2;
683
+ camera.top = frustumHeight / 2;
684
+ camera.bottom = -frustumHeight / 2;
685
+ camera.updateProjectionMatrix();
686
+ mesh.scale.set(frustumWidth, frustumHeight, 1);
687
+ nodeRegistry.nodes.forEach((nodeInfo) => {
688
+ if (nodeInfo.transformUniforms?.aspectRatio) nodeInfo.transformUniforms.aspectRatio.value = aspectRatio;
689
+ nodeInfo.resizeCallbacks.forEach((callback) => {
690
+ try {
691
+ callback({
692
+ width: width$1,
693
+ height: height$1
694
+ });
695
+ } catch (error) {
696
+ console.error("Error in resize callback:", error);
697
+ }
698
+ });
699
+ });
700
+ renderFrame().catch(console.warn);
701
+ });
702
+ }
703
+ };
704
+ const canRender = () => {
705
+ return isInitialized && !!renderer && !!scene && !!camera && !!material && currentWidth > 0 && currentHeight > 0;
706
+ };
707
+ const handleResize = (entries) => {
708
+ if (!renderer || !camera || !mesh) return;
709
+ const entry = entries[0];
710
+ if (!entry) return;
711
+ let width, height;
712
+ if (entry.contentBoxSize) {
713
+ const boxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
714
+ if (boxSize) {
715
+ width = Math.round(boxSize.inlineSize);
716
+ height = Math.round(boxSize.blockSize);
717
+ } else {
718
+ width = Math.round(entry.contentRect.width);
719
+ height = Math.round(entry.contentRect.height);
720
+ }
721
+ } else {
722
+ width = Math.round(entry.contentRect.width);
723
+ height = Math.round(entry.contentRect.height);
724
+ }
725
+ if (width === 0 || height === 0) return;
726
+ updateRendererDimensions(width, height);
727
+ };
728
+ const handleVisibilityChange = (entries) => {
729
+ const entry = entries[0];
730
+ if (!entry) return;
731
+ isVisible = entry.isIntersecting;
732
+ };
733
+ const setsAreEqual = (set1, set2) => {
734
+ if (set1.size !== set2.size) return false;
735
+ for (const item of set1) if (!set2.has(item)) return false;
736
+ return true;
737
+ };
738
+ const trackConvertToTexture = (node) => {
739
+ actualRTTOperations++;
740
+ const texture = convertToTexture(node);
741
+ currentTextures.add(texture);
742
+ return texture;
743
+ };
744
+ const disposePreviousTextures = () => {
745
+ previousTextures.forEach((texture) => {
746
+ try {
747
+ if (texture?.renderTarget?.dispose) texture.renderTarget.dispose();
748
+ } catch (e) {}
749
+ });
750
+ previousTextures.clear();
751
+ };
752
+ let materialUpdatePending = false;
753
+ const updateMaterial = () => {
754
+ if (!nodeRegistry.rootId || !material || isUpdatingMaterial) return;
755
+ if (!nodeRegistry.nodes.get(nodeRegistry.rootId)) return;
756
+ if (currentWidth === 0 || currentHeight === 0) {
757
+ if (!materialUpdatePending) {
758
+ materialUpdatePending = true;
759
+ requestAnimationFrame(() => {
760
+ materialUpdatePending = false;
761
+ if (currentWidth > 0 && currentHeight > 0) updateMaterial();
762
+ });
763
+ }
764
+ return;
765
+ }
766
+ isUpdatingMaterial = true;
767
+ try {
768
+ previousTextures = new Set(currentTextures);
769
+ currentTextures.clear();
770
+ const currentComposedNodes = /* @__PURE__ */ new Set();
771
+ activeRTTNodes.clear();
772
+ nodeRegistry.nodes.forEach((nodeInfo, nodeId) => {
773
+ if (nodeInfo.requiresRTT || nodeInfo.transformRTTActive) activeRTTNodes.add(nodeId);
774
+ });
775
+ actualRTTOperations = 0;
776
+ const composedNode = composeNodeTree(nodeRegistry.rootId, /* @__PURE__ */ new Set(), currentComposedNodes);
777
+ if (composedNode && material) {
778
+ const compositionChanged = !setsAreEqual(lastComposedNodes, currentComposedNodes);
779
+ const nodeChanged = material.fragmentNode !== composedNode;
780
+ if (compositionChanged || needsMaterialRefresh || nodeChanged) {
781
+ disposePreviousTextures();
782
+ try {
783
+ material.dispose();
784
+ if (renderer.renderTarget) renderer.renderTarget.dispose();
785
+ } catch (e) {}
786
+ const newMaterial = new MeshBasicNodeMaterial({ transparent: true });
787
+ newMaterial.fragmentNode = composedNode;
788
+ newMaterial.needsUpdate = true;
789
+ mesh.material = newMaterial;
790
+ material = newMaterial;
791
+ needsMaterialRefresh = false;
792
+ lastComposedNodes = currentComposedNodes;
793
+ }
794
+ }
795
+ } catch (error) {
796
+ console.error("Error composing shader tree:", error);
797
+ } finally {
798
+ isUpdatingMaterial = false;
799
+ }
800
+ renderFrame().catch(console.warn);
801
+ };
802
+ const findChildNodes = (parentId) => {
803
+ const childIds = parentToChildren.get(parentId);
804
+ if (!childIds) return [];
805
+ const children = [];
806
+ for (const childId of childIds) {
807
+ const nodeInfo = nodeRegistry.nodes.get(childId);
808
+ if (nodeInfo) children.push(nodeInfo);
809
+ }
810
+ return children;
811
+ };
812
+ const findNodeByCustomId = (customId) => {
813
+ for (const [nodeId, info] of nodeRegistry.nodes.entries()) if (info.metadata.id === customId) return nodeId;
814
+ return null;
815
+ };
816
+ const applyMaskIfNeeded = (result, nodeInfo, nodeId, processedMasks, distortedUV) => {
817
+ if (!nodeInfo.metadata.mask?.source) return result;
818
+ const maskSourceId = nodeInfo.metadata.mask.source;
819
+ const maskNodeId = findNodeByCustomId(maskSourceId);
820
+ if (!maskNodeId) return result;
821
+ if (processedMasks.has(maskNodeId)) {
822
+ console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`);
823
+ return result;
824
+ }
825
+ const newProcessedMasks = new Set(processedMasks);
826
+ newProcessedMasks.add(nodeId);
827
+ const maskNode = composeNodeTree(maskNodeId, newProcessedMasks);
828
+ let finalMaskNode = maskNode;
829
+ if (distortedUV) finalMaskNode = trackConvertToTexture(maskNode).sample(distortedUV);
830
+ const maskType = nodeInfo.metadata.mask.type || "alpha";
831
+ return applyMask(result, finalMaskNode, maskType);
832
+ };
833
+ const applyNodeTransformation = (result, nodeInfo) => {
834
+ if (!nodeInfo.metadata.transform || !nodeInfo.transformUniforms || !needsTransformation(nodeInfo.metadata.transform) && !nodeInfo.transformRTTActive) return result;
835
+ const texture = trackConvertToTexture(result);
836
+ const transformedUV = applyUVTransform(screenUV, nodeInfo.transformUniforms.offsetX, nodeInfo.transformUniforms.offsetY, nodeInfo.transformUniforms.rotation, nodeInfo.transformUniforms.scale, nodeInfo.transformUniforms.anchorX, nodeInfo.transformUniforms.anchorY, nodeInfo.transformUniforms.aspectRatio);
837
+ return applyEdgeHandling(transformedUV, texture.sample(transformedUV), texture, nodeInfo.transformUniforms.edges);
838
+ };
839
+ const isUVComposable = (nodeInfo) => {
840
+ return !!nodeInfo.uvTransformFunc && nodeInfo.requiresChild && nodeInfo.metadata.blendMode === "normal" && (nodeInfo.metadata.opacity === void 0 || nodeInfo.metadata.opacity === 1) && nodeInfo.metadata.visible !== false && !nodeInfo.metadata.mask?.source && !(nodeInfo.transformUniforms && nodeInfo.metadata.transform && needsTransformation(nodeInfo.metadata.transform));
841
+ };
842
+ const findUVChain = (startNodeId) => {
843
+ const chain = [];
844
+ let currentId = startNodeId;
845
+ while (currentId) {
846
+ const nodeInfo = nodeRegistry.nodes.get(currentId);
847
+ if (!nodeInfo) break;
848
+ if (!isUVComposable(nodeInfo)) break;
849
+ chain.push(nodeInfo);
850
+ const children = findChildNodes(nodeInfo.id);
851
+ if (children.length !== 1) break;
852
+ const child = children[0];
853
+ if (isUVComposable(child)) currentId = child.id;
854
+ else break;
855
+ }
856
+ return chain;
857
+ };
858
+ const findUVChainTerminus = (chain) => {
859
+ if (chain.length === 0) return null;
860
+ const innermostNode = chain[chain.length - 1];
861
+ const children = findChildNodes(innermostNode.id);
862
+ if (children.length === 0) return null;
863
+ if (children.length === 1) return children[0];
864
+ return null;
865
+ };
866
+ const canSkipRTT = (distortionInfo) => {
867
+ if (!distortionInfo.uvTransformFunc) return false;
868
+ if (!isUVComposable(distortionInfo)) return false;
869
+ const children = findChildNodes(distortionInfo.id);
870
+ if (children.length !== 1) return false;
871
+ const child = children[0];
872
+ if (child.acceptsUVContext && !child.requiresChild) return true;
873
+ if (child.uvTransformFunc && isUVComposable(child)) return canSkipRTT(child);
874
+ return false;
875
+ };
876
+ const composeUVContextChain = (startNodeId, _processedMasks, currentlyComposedNodes) => {
877
+ const chain = [];
878
+ let currentId = startNodeId;
879
+ while (currentId) {
880
+ const nodeInfo = nodeRegistry.nodes.get(currentId);
881
+ if (!nodeInfo) break;
882
+ if (chain.length >= 2) return composeNodeTree(startNodeId, _processedMasks, currentlyComposedNodes, true);
883
+ chain.push(nodeInfo);
884
+ if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
885
+ if (nodeInfo.acceptsUVContext && !nodeInfo.requiresChild) break;
886
+ const children = findChildNodes(currentId);
887
+ if (children.length !== 1) break;
888
+ currentId = children[0].id;
889
+ }
890
+ if (chain.length === 0) return vec4(0, 0, 0, 0);
891
+ const terminus = chain[chain.length - 1];
892
+ let composedUV = screenUV;
893
+ for (let i = 0; i < chain.length; i++) {
894
+ const nodeInfo = chain[i];
895
+ if (nodeInfo.uvTransformFunc) composedUV = nodeInfo.uvTransformFunc({
896
+ uv: composedUV,
897
+ uniforms: nodeInfo.uniforms,
898
+ viewportSize
899
+ });
900
+ if (nodeInfo.transformUniforms && nodeInfo.metadata.transform && needsTransformation(nodeInfo.metadata.transform)) {
901
+ composedUV = applyUVTransform(composedUV, nodeInfo.transformUniforms.offsetX, nodeInfo.transformUniforms.offsetY, nodeInfo.transformUniforms.rotation, nodeInfo.transformUniforms.scale, nodeInfo.transformUniforms.anchorX, nodeInfo.transformUniforms.anchorY, nodeInfo.transformUniforms.aspectRatio);
902
+ if (nodeInfo.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, nodeInfo.transformUniforms.edges);
903
+ nodeInfo.transformRTTActive = true;
904
+ }
905
+ }
906
+ for (let i = 0; i < chain.length - 1; i++) {
907
+ const distortion = chain[i];
908
+ if (!distortion.requiresChild) continue;
909
+ const distortionOnCleanup = (callback) => {
910
+ distortion.cleanupCallbacks.push(callback);
911
+ };
912
+ const distortionOnBeforeRender = (callback) => {
913
+ distortion.beforeRenderCallbacks.push(callback);
914
+ };
915
+ const distortionOnAfterRender = (callback) => {
916
+ distortion.afterRenderCallbacks.push(callback);
917
+ };
918
+ const distortionOnResize = (callback) => {
919
+ distortion.resizeCallbacks.push(callback);
920
+ };
921
+ distortion.cleanupCallbacks.forEach((callback) => {
922
+ try {
923
+ callback();
924
+ } catch (e) {
925
+ console.error("Error in cleanup callback:", e);
926
+ }
927
+ });
928
+ distortion.cleanupCallbacks = [];
929
+ distortion.beforeRenderCallbacks = [];
930
+ distortion.afterRenderCallbacks = [];
931
+ distortion.resizeCallbacks = [];
932
+ distortion.fragmentNodeFunc({
933
+ uniforms: distortion.uniforms ?? {},
934
+ childNode: void 0,
935
+ uvContext: void 0,
936
+ onCleanup: distortionOnCleanup,
937
+ onBeforeRender: distortionOnBeforeRender,
938
+ onAfterRender: distortionOnAfterRender,
939
+ onResize: distortionOnResize,
940
+ canvas: canvasElement,
941
+ dimensions: {
942
+ width: currentWidth,
943
+ height: currentHeight
944
+ },
945
+ renderer
946
+ });
947
+ }
948
+ const terminusOnCleanup = (callback) => {
949
+ terminus.cleanupCallbacks.push(callback);
950
+ };
951
+ const terminusOnBeforeRender = (callback) => {
952
+ terminus.beforeRenderCallbacks.push(callback);
953
+ };
954
+ const terminusOnAfterRender = (callback) => {
955
+ terminus.afterRenderCallbacks.push(callback);
956
+ };
957
+ const terminusOnResize = (callback) => {
958
+ terminus.resizeCallbacks.push(callback);
959
+ };
960
+ terminus.cleanupCallbacks.forEach((callback) => {
961
+ try {
962
+ callback();
963
+ } catch (e) {
964
+ console.error("Error in cleanup callback:", e);
965
+ }
966
+ });
967
+ terminus.cleanupCallbacks = [];
968
+ terminus.beforeRenderCallbacks = [];
969
+ terminus.afterRenderCallbacks = [];
970
+ terminus.resizeCallbacks = [];
971
+ const result = terminus.fragmentNodeFunc({
972
+ uniforms: terminus.uniforms ?? {},
973
+ childNode: void 0,
974
+ uvContext: composedUV,
975
+ onCleanup: terminusOnCleanup,
976
+ onBeforeRender: terminusOnBeforeRender,
977
+ onAfterRender: terminusOnAfterRender,
978
+ onResize: terminusOnResize,
979
+ canvas: canvasElement,
980
+ dimensions: {
981
+ width: currentWidth,
982
+ height: currentHeight
983
+ },
984
+ renderer
985
+ });
986
+ for (const nodeInfo of chain) if (nodeInfo.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, result, null, nodeInfo.uniforms.edges.uniform);
987
+ return result;
988
+ };
989
+ const composeUVChain = (chain, processedMasks, currentlyComposedNodes) => {
990
+ if (chain.length === 0) return vec4(0, 0, 0, 0);
991
+ const terminus = findUVChainTerminus(chain);
992
+ let terminusNode;
993
+ if (terminus) terminusNode = composeNodeTree(terminus.id, processedMasks, currentlyComposedNodes);
994
+ else {
995
+ const innermostNode = chain[chain.length - 1];
996
+ if (findChildNodes(innermostNode.id).length === 0) return vec4(0, 0, 0, 0);
997
+ terminusNode = composeNodeTree(innermostNode.id, processedMasks, currentlyComposedNodes);
998
+ }
999
+ const texture = trackConvertToTexture(terminusNode);
1000
+ let composedUV = screenUV;
1001
+ for (let i = chain.length - 1; i >= 0; i--) {
1002
+ const nodeInfo = chain[i];
1003
+ if (nodeInfo.uvTransformFunc) {
1004
+ composedUV = nodeInfo.uvTransformFunc({
1005
+ uv: composedUV,
1006
+ uniforms: nodeInfo.uniforms,
1007
+ viewportSize
1008
+ });
1009
+ if (nodeInfo.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, nodeInfo.uniforms.edges.uniform);
1010
+ }
1011
+ if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
1012
+ }
1013
+ const sampledColor = texture.sample(composedUV);
1014
+ const outermostNode = chain[0];
1015
+ if (outermostNode.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, sampledColor, texture, outermostNode.uniforms.edges.uniform);
1016
+ return sampledColor;
1017
+ };
1018
+ const findSiblingUVChain = (sortedChildren, startIndex) => {
1019
+ const chain = [];
1020
+ for (let i = startIndex; i < sortedChildren.length; i++) {
1021
+ const sibling = sortedChildren[i];
1022
+ if (!isUVComposable(sibling)) break;
1023
+ if (findChildNodes(sibling.id).length > 0) break;
1024
+ chain.push(sibling);
1025
+ }
1026
+ return chain;
1027
+ };
1028
+ const composeSiblingUVChain = (chain, inputContent, currentlyComposedNodes) => {
1029
+ if (chain.length === 0) return inputContent;
1030
+ const texture = trackConvertToTexture(inputContent);
1031
+ let composedUV = screenUV;
1032
+ for (let i = chain.length - 1; i >= 0; i--) {
1033
+ const nodeInfo = chain[i];
1034
+ if (nodeInfo.uvTransformFunc) {
1035
+ composedUV = nodeInfo.uvTransformFunc({
1036
+ uv: composedUV,
1037
+ uniforms: nodeInfo.uniforms,
1038
+ viewportSize
1039
+ });
1040
+ if (nodeInfo.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, nodeInfo.uniforms.edges.uniform);
1041
+ }
1042
+ if (currentlyComposedNodes) currentlyComposedNodes.add(nodeInfo.id);
1043
+ }
1044
+ const sampledColor = texture.sample(composedUV);
1045
+ const lastNode = chain[chain.length - 1];
1046
+ if (lastNode.uniforms.edges?.uniform) return applyEdgeHandling(composedUV, sampledColor, texture, lastNode.uniforms.edges.uniform);
1047
+ return sampledColor;
1048
+ };
1049
+ const hasUVPropagationOpportunity = (sortedChildren) => {
1050
+ const generators = [];
1051
+ const distortions = [];
1052
+ let hasGeneratorBeforeDistortion = false;
1053
+ for (let i = 0; i < sortedChildren.length; i++) {
1054
+ const child = sortedChildren[i];
1055
+ const childHasChildren = findChildNodes(child.id).length > 0;
1056
+ if (child.acceptsUVContext && !child.requiresChild) generators.push(i);
1057
+ if (isUVComposable(child) && !childHasChildren) {
1058
+ distortions.push(i);
1059
+ if (generators.length > 0) hasGeneratorBeforeDistortion = true;
1060
+ }
1061
+ }
1062
+ if (generators.length === 0 || distortions.length === 0 || !hasGeneratorBeforeDistortion) return false;
1063
+ const minGen = Math.min(...generators);
1064
+ const maxDist = Math.max(...distortions);
1065
+ for (let i = minGen + 1; i < maxDist; i++) {
1066
+ const node = sortedChildren[i];
1067
+ if (node.requiresRTT && !isUVComposable(node) && !(node.acceptsUVContext && !node.requiresChild)) return false;
1068
+ }
1069
+ if (distortions.length > 2) return false;
1070
+ return true;
1071
+ };
1072
+ const composeSiblingsWithUVContext = (sortedChildren, processedMasks, currentlyComposedNodes) => {
1073
+ const generators = [];
1074
+ const distortions = [];
1075
+ sortedChildren.forEach((child, index) => {
1076
+ const hasChildren = findChildNodes(child.id).length > 0;
1077
+ if (isUVComposable(child) && !hasChildren) distortions.push({
1078
+ node: child,
1079
+ index
1080
+ });
1081
+ else if (child.acceptsUVContext && !child.requiresChild && !hasChildren) generators.push({
1082
+ node: child,
1083
+ index
1084
+ });
1085
+ });
1086
+ for (const d of distortions) {
1087
+ const distortion = d.node;
1088
+ distortion.cleanupCallbacks.forEach((cb) => {
1089
+ try {
1090
+ cb();
1091
+ } catch (e) {
1092
+ console.error("Cleanup error:", e);
1093
+ }
1094
+ });
1095
+ distortion.cleanupCallbacks = [];
1096
+ distortion.beforeRenderCallbacks = [];
1097
+ distortion.afterRenderCallbacks = [];
1098
+ distortion.resizeCallbacks = [];
1099
+ const onCleanup = (cb) => distortion.cleanupCallbacks.push(cb);
1100
+ const onBeforeRender = (cb) => distortion.beforeRenderCallbacks.push(cb);
1101
+ const onAfterRender = (cb) => distortion.afterRenderCallbacks.push(cb);
1102
+ const onResize = (cb) => distortion.resizeCallbacks.push(cb);
1103
+ distortion.fragmentNodeFunc({
1104
+ uniforms: distortion.uniforms ?? {},
1105
+ childNode: void 0,
1106
+ uvContext: void 0,
1107
+ onCleanup,
1108
+ onBeforeRender,
1109
+ onAfterRender,
1110
+ onResize,
1111
+ canvas: canvasElement,
1112
+ dimensions: {
1113
+ width: currentWidth,
1114
+ height: currentHeight
1115
+ },
1116
+ renderer
1117
+ });
1118
+ if (currentlyComposedNodes) currentlyComposedNodes.add(distortion.id);
1119
+ }
1120
+ let composedResult = void 0;
1121
+ for (let i = 0; i < sortedChildren.length; i++) {
1122
+ const childInfo = sortedChildren[i];
1123
+ if (childInfo.metadata.visible === false) continue;
1124
+ const effectiveOpacity = childInfo.metadata.opacity ?? 1;
1125
+ childInfo.opacityUniform.value = effectiveOpacity;
1126
+ if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
1127
+ const hasChildren = findChildNodes(childInfo.id).length > 0;
1128
+ let childResult;
1129
+ const genEntry = generators.find((g) => g.index === i);
1130
+ if (genEntry) {
1131
+ const applicableDistortions = distortions.filter((d) => d.index > genEntry.index).sort((a, b) => a.index - b.index).map((d) => d.node);
1132
+ let composedUV = screenUV;
1133
+ for (let j = applicableDistortions.length - 1; j >= 0; j--) {
1134
+ const distortion = applicableDistortions[j];
1135
+ if (distortion.uvTransformFunc) composedUV = distortion.uvTransformFunc({
1136
+ uv: composedUV,
1137
+ uniforms: distortion.uniforms,
1138
+ viewportSize
1139
+ });
1140
+ if (distortion.transformUniforms && distortion.metadata.transform && needsTransformation(distortion.metadata.transform)) {
1141
+ composedUV = applyUVTransform(composedUV, distortion.transformUniforms.offsetX, distortion.transformUniforms.offsetY, distortion.transformUniforms.rotation, distortion.transformUniforms.scale, distortion.transformUniforms.anchorX, distortion.transformUniforms.anchorY, distortion.transformUniforms.aspectRatio);
1142
+ if (distortion.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, distortion.transformUniforms.edges);
1143
+ distortion.transformRTTActive = true;
1144
+ }
1145
+ if (distortion.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, distortion.uniforms.edges.uniform);
1146
+ }
1147
+ if (genEntry.node.transformUniforms && genEntry.node.metadata.transform && needsTransformation(genEntry.node.metadata.transform)) {
1148
+ composedUV = applyUVTransform(composedUV, genEntry.node.transformUniforms.offsetX, genEntry.node.transformUniforms.offsetY, genEntry.node.transformUniforms.rotation, genEntry.node.transformUniforms.scale, genEntry.node.transformUniforms.anchorX, genEntry.node.transformUniforms.anchorY, genEntry.node.transformUniforms.aspectRatio);
1149
+ if (genEntry.node.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, genEntry.node.transformUniforms.edges);
1150
+ genEntry.node.transformRTTActive = true;
1151
+ }
1152
+ childInfo.cleanupCallbacks.forEach((cb) => {
1153
+ try {
1154
+ cb();
1155
+ } catch (e) {
1156
+ console.error("Cleanup error:", e);
1157
+ }
1158
+ });
1159
+ childInfo.cleanupCallbacks = [];
1160
+ childInfo.beforeRenderCallbacks = [];
1161
+ childInfo.afterRenderCallbacks = [];
1162
+ childInfo.resizeCallbacks = [];
1163
+ const onCleanup = (cb) => childInfo.cleanupCallbacks.push(cb);
1164
+ const onBeforeRender = (cb) => childInfo.beforeRenderCallbacks.push(cb);
1165
+ const onAfterRender = (cb) => childInfo.afterRenderCallbacks.push(cb);
1166
+ const onResize = (cb) => childInfo.resizeCallbacks.push(cb);
1167
+ let fragmentResult = childInfo.fragmentNodeFunc({
1168
+ uniforms: childInfo.uniforms ?? {},
1169
+ childNode: void 0,
1170
+ uvContext: composedUV,
1171
+ onCleanup,
1172
+ onBeforeRender,
1173
+ onAfterRender,
1174
+ onResize,
1175
+ canvas: canvasElement,
1176
+ dimensions: {
1177
+ width: currentWidth,
1178
+ height: currentHeight
1179
+ },
1180
+ renderer
1181
+ });
1182
+ if (applicableDistortions.length > 0) {
1183
+ const outermostDistortion = applicableDistortions[0];
1184
+ if (outermostDistortion.uniforms.edges?.uniform) fragmentResult = applyEdgeHandling(composedUV, fragmentResult, null, outermostDistortion.uniforms.edges.uniform);
1185
+ }
1186
+ childResult = applyMaskIfNeeded(fragmentResult, childInfo, childInfo.id, processedMasks, composedUV);
1187
+ } else if (distortions.find((d) => d.index === i)) continue;
1188
+ else if (hasChildren) {
1189
+ if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
1190
+ else if (isUVComposable(childInfo)) {
1191
+ const uvChain = findUVChain(childInfo.id);
1192
+ if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
1193
+ else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
1194
+ } else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
1195
+ const applicableDistortions = distortions.filter((d) => d.index > i).sort((a, b) => a.index - b.index).map((d) => d.node);
1196
+ if (applicableDistortions.length > 0) {
1197
+ const childTexture = trackConvertToTexture(childResult);
1198
+ let composedUV = screenUV;
1199
+ for (let j = applicableDistortions.length - 1; j >= 0; j--) {
1200
+ const distortion = applicableDistortions[j];
1201
+ if (distortion.uvTransformFunc) composedUV = distortion.uvTransformFunc({
1202
+ uv: composedUV,
1203
+ uniforms: distortion.uniforms,
1204
+ viewportSize
1205
+ });
1206
+ if (distortion.transformUniforms && distortion.metadata.transform && needsTransformation(distortion.metadata.transform)) {
1207
+ composedUV = applyUVTransform(composedUV, distortion.transformUniforms.offsetX, distortion.transformUniforms.offsetY, distortion.transformUniforms.rotation, distortion.transformUniforms.scale, distortion.transformUniforms.anchorX, distortion.transformUniforms.anchorY, distortion.transformUniforms.aspectRatio);
1208
+ if (distortion.transformUniforms.edges) composedUV = applyEdgeToUV(composedUV, distortion.transformUniforms.edges);
1209
+ distortion.transformRTTActive = true;
1210
+ }
1211
+ if (distortion.uniforms.edges?.uniform) composedUV = applyEdgeToUV(composedUV, distortion.uniforms.edges.uniform);
1212
+ }
1213
+ childResult = childTexture.sample(composedUV);
1214
+ const outermostDistortion = applicableDistortions[applicableDistortions.length - 1];
1215
+ if (outermostDistortion.transformUniforms?.edges) childResult = applyEdgeHandling(composedUV, childResult, childTexture, outermostDistortion.transformUniforms.edges);
1216
+ }
1217
+ } else {
1218
+ childInfo.cleanupCallbacks.forEach((cb) => {
1219
+ try {
1220
+ cb();
1221
+ } catch (e) {
1222
+ console.error("Cleanup error:", e);
1223
+ }
1224
+ });
1225
+ childInfo.cleanupCallbacks = [];
1226
+ childInfo.beforeRenderCallbacks = [];
1227
+ childInfo.afterRenderCallbacks = [];
1228
+ childInfo.resizeCallbacks = [];
1229
+ const onCleanup = (cb) => childInfo.cleanupCallbacks.push(cb);
1230
+ const onBeforeRender = (cb) => childInfo.beforeRenderCallbacks.push(cb);
1231
+ const onAfterRender = (cb) => childInfo.afterRenderCallbacks.push(cb);
1232
+ const onResize = (cb) => childInfo.resizeCallbacks.push(cb);
1233
+ let effectiveChildNode = composedResult;
1234
+ if (childInfo.requiresRTT && composedResult !== void 0) effectiveChildNode = applyBlendMode(vec4(0, 0, 0, 0), composedResult, "normal", 1);
1235
+ childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
1236
+ uniforms: childInfo.uniforms ?? {},
1237
+ childNode: effectiveChildNode,
1238
+ onCleanup,
1239
+ onBeforeRender,
1240
+ onAfterRender,
1241
+ onResize,
1242
+ canvas: canvasElement,
1243
+ dimensions: {
1244
+ width: currentWidth,
1245
+ height: currentHeight
1246
+ },
1247
+ renderer
1248
+ }), childInfo), childInfo, childInfo.id, processedMasks);
1249
+ }
1250
+ if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !hasChildren) composedResult = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
1251
+ else if (composedResult === void 0) composedResult = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
1252
+ else composedResult = applyBlendMode(composedResult, childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
1253
+ }
1254
+ return composedResult ?? vec4(0, 0, 0, 0);
1255
+ };
1256
+ const composeNodeTree = (nodeId, processedMasks = /* @__PURE__ */ new Set(), currentlyComposedNodes, forceRTT = false) => {
1257
+ if (currentWidth === 0 || currentHeight === 0) return vec4(0, 0, 0, 0);
1258
+ const nodeInfo = nodeRegistry.nodes.get(nodeId);
1259
+ if (!nodeInfo) return vec4(0, 0, 0, 0);
1260
+ const nodeSpecificOnCleanup = (callback) => {
1261
+ nodeInfo.cleanupCallbacks.push(callback);
1262
+ };
1263
+ const nodeSpecificOnBeforeRender = (callback) => {
1264
+ nodeInfo.beforeRenderCallbacks.push(callback);
1265
+ };
1266
+ const nodeSpecificOnAfterRender = (callback) => {
1267
+ nodeInfo.afterRenderCallbacks.push(callback);
1268
+ };
1269
+ const nodeSpecificOnResize = (callback) => {
1270
+ nodeInfo.resizeCallbacks.push(callback);
1271
+ };
1272
+ const childNodes = findChildNodes(nodeId);
1273
+ if (childNodes.length === 0) {
1274
+ nodeInfo.cleanupCallbacks.forEach((callback) => {
1275
+ try {
1276
+ callback();
1277
+ } catch (e) {
1278
+ console.error("Error in cleanup callback:", e);
1279
+ }
1280
+ });
1281
+ nodeInfo.cleanupCallbacks = [];
1282
+ nodeInfo.beforeRenderCallbacks = [];
1283
+ nodeInfo.afterRenderCallbacks = [];
1284
+ nodeInfo.resizeCallbacks = [];
1285
+ return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc({
1286
+ uniforms: nodeInfo.uniforms ?? {},
1287
+ childNode: void 0,
1288
+ onCleanup: nodeSpecificOnCleanup,
1289
+ onBeforeRender: nodeSpecificOnBeforeRender,
1290
+ onAfterRender: nodeSpecificOnAfterRender,
1291
+ onResize: nodeSpecificOnResize,
1292
+ canvas: canvasElement,
1293
+ dimensions: {
1294
+ width: currentWidth,
1295
+ height: currentHeight
1296
+ },
1297
+ renderer
1298
+ }), nodeInfo), nodeInfo, nodeId, processedMasks);
1299
+ } else {
1300
+ const sortedChildren = [...childNodes].sort((a, b) => a.metadata.renderOrder - b.metadata.renderOrder);
1301
+ if (nodeInfo.parentId === null) {
1302
+ if (!forceRTT && hasUVPropagationOpportunity(sortedChildren)) return applyMaskIfNeeded(applyNodeTransformation(composeSiblingsWithUVContext(sortedChildren, processedMasks, currentlyComposedNodes), nodeInfo), nodeInfo, nodeId, processedMasks);
1303
+ let composedChildren = void 0;
1304
+ for (let i = 0; i < sortedChildren.length; i++) {
1305
+ const childInfo = sortedChildren[i];
1306
+ let effectiveOpacity;
1307
+ if (childInfo.metadata.opacity === void 0) {
1308
+ effectiveOpacity = 1;
1309
+ childInfo.opacityUniform.value = effectiveOpacity;
1310
+ } else {
1311
+ effectiveOpacity = childInfo.metadata.opacity;
1312
+ childInfo.opacityUniform.value = effectiveOpacity;
1313
+ }
1314
+ if (childInfo.metadata.visible === false) continue;
1315
+ if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
1316
+ const childHasChildren = findChildNodes(childInfo.id).length > 0;
1317
+ let childResult;
1318
+ if (childHasChildren) if (forceRTT) childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes, true);
1319
+ else if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
1320
+ else if (isUVComposable(childInfo)) {
1321
+ const uvChain = findUVChain(childInfo.id);
1322
+ if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
1323
+ else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
1324
+ } else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
1325
+ else {
1326
+ if (isUVComposable(childInfo) && childInfo.requiresChild && composedChildren !== void 0) {
1327
+ const siblingChain = findSiblingUVChain(sortedChildren, i);
1328
+ if (siblingChain.length > 1) {
1329
+ childResult = composeSiblingUVChain(siblingChain, composedChildren, currentlyComposedNodes);
1330
+ i += siblingChain.length - 1;
1331
+ composedChildren = childResult;
1332
+ continue;
1333
+ }
1334
+ }
1335
+ {
1336
+ const childSpecificOnCleanup = (callback) => {
1337
+ childInfo.cleanupCallbacks.push(callback);
1338
+ };
1339
+ const childSpecificOnBeforeRender = (callback) => {
1340
+ childInfo.beforeRenderCallbacks.push(callback);
1341
+ };
1342
+ const childSpecificOnAfterRender = (callback) => {
1343
+ childInfo.afterRenderCallbacks.push(callback);
1344
+ };
1345
+ const childSpecificOnResize = (callback) => {
1346
+ childInfo.resizeCallbacks.push(callback);
1347
+ };
1348
+ let effectiveChildNode = composedChildren;
1349
+ if (childInfo.requiresRTT && composedChildren !== void 0) effectiveChildNode = applyBlendMode(vec4(0, 0, 0, 0), composedChildren, "normal", 1);
1350
+ childInfo.cleanupCallbacks.forEach((callback) => {
1351
+ try {
1352
+ callback();
1353
+ } catch (e) {
1354
+ console.error("Error in cleanup callback:", e);
1355
+ }
1356
+ });
1357
+ childInfo.cleanupCallbacks = [];
1358
+ childInfo.beforeRenderCallbacks = [];
1359
+ childInfo.afterRenderCallbacks = [];
1360
+ childInfo.resizeCallbacks = [];
1361
+ childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
1362
+ uniforms: childInfo.uniforms ?? {},
1363
+ childNode: effectiveChildNode,
1364
+ onCleanup: childSpecificOnCleanup,
1365
+ onBeforeRender: childSpecificOnBeforeRender,
1366
+ onAfterRender: childSpecificOnAfterRender,
1367
+ onResize: childSpecificOnResize,
1368
+ canvas: canvasElement,
1369
+ dimensions: {
1370
+ width: currentWidth,
1371
+ height: currentHeight
1372
+ },
1373
+ renderer
1374
+ }), childInfo), childInfo, childInfo.id, processedMasks);
1375
+ }
1376
+ }
1377
+ if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildren = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
1378
+ else if (composedChildren === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildren = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
1379
+ else composedChildren = childResult;
1380
+ else composedChildren = applyBlendMode(composedChildren, childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
1381
+ }
1382
+ nodeInfo.cleanupCallbacks.forEach((callback) => {
1383
+ try {
1384
+ callback();
1385
+ } catch (e) {
1386
+ console.error("Error in cleanup callback:", e);
1387
+ }
1388
+ });
1389
+ nodeInfo.cleanupCallbacks = [];
1390
+ nodeInfo.beforeRenderCallbacks = [];
1391
+ nodeInfo.afterRenderCallbacks = [];
1392
+ nodeInfo.resizeCallbacks = [];
1393
+ return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc({
1394
+ uniforms: nodeInfo.uniforms ?? {},
1395
+ childNode: composedChildren,
1396
+ onCleanup: nodeSpecificOnCleanup,
1397
+ onBeforeRender: nodeSpecificOnBeforeRender,
1398
+ onAfterRender: nodeSpecificOnAfterRender,
1399
+ onResize: nodeSpecificOnResize,
1400
+ canvas: canvasElement,
1401
+ dimensions: {
1402
+ width: currentWidth,
1403
+ height: currentHeight
1404
+ },
1405
+ renderer
1406
+ }), nodeInfo), nodeInfo, nodeId, processedMasks);
1407
+ } else {
1408
+ if (!forceRTT && hasUVPropagationOpportunity(sortedChildren)) {
1409
+ const composedChildrenResult$1 = composeSiblingsWithUVContext(sortedChildren, processedMasks, currentlyComposedNodes);
1410
+ return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc({
1411
+ uniforms: nodeInfo.uniforms ?? {},
1412
+ childNode: composedChildrenResult$1,
1413
+ onCleanup: nodeSpecificOnCleanup,
1414
+ onBeforeRender: nodeSpecificOnBeforeRender,
1415
+ onAfterRender: nodeSpecificOnAfterRender,
1416
+ onResize: nodeSpecificOnResize,
1417
+ canvas: canvasElement,
1418
+ dimensions: {
1419
+ width: currentWidth,
1420
+ height: currentHeight
1421
+ },
1422
+ renderer
1423
+ }), nodeInfo), nodeInfo, nodeId, processedMasks);
1424
+ }
1425
+ let composedChildrenResult = void 0;
1426
+ for (let i = 0; i < sortedChildren.length; i++) {
1427
+ const childInfo = sortedChildren[i];
1428
+ let effectiveOpacity;
1429
+ if (childInfo.metadata.opacity === void 0) {
1430
+ effectiveOpacity = 1;
1431
+ childInfo.opacityUniform.value = effectiveOpacity;
1432
+ } else {
1433
+ effectiveOpacity = childInfo.metadata.opacity;
1434
+ childInfo.opacityUniform.value = effectiveOpacity;
1435
+ }
1436
+ if (childInfo.metadata.visible === false) continue;
1437
+ if (currentlyComposedNodes) currentlyComposedNodes.add(childInfo.id);
1438
+ const childHasChildren = findChildNodes(childInfo.id).length > 0;
1439
+ let childResult;
1440
+ if (childHasChildren) if (forceRTT) childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes, true);
1441
+ else if (canSkipRTT(childInfo)) childResult = composeUVContextChain(childInfo.id, processedMasks, currentlyComposedNodes);
1442
+ else if (isUVComposable(childInfo)) {
1443
+ const uvChain = findUVChain(childInfo.id);
1444
+ if (uvChain.length > 1) childResult = composeUVChain(uvChain, processedMasks, currentlyComposedNodes);
1445
+ else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
1446
+ } else childResult = composeNodeTree(childInfo.id, processedMasks, currentlyComposedNodes);
1447
+ else {
1448
+ if (isUVComposable(childInfo) && childInfo.requiresChild && composedChildrenResult !== void 0) {
1449
+ const siblingChain = findSiblingUVChain(sortedChildren, i);
1450
+ if (siblingChain.length > 1) {
1451
+ childResult = composeSiblingUVChain(siblingChain, composedChildrenResult, currentlyComposedNodes);
1452
+ i += siblingChain.length - 1;
1453
+ composedChildrenResult = childResult;
1454
+ continue;
1455
+ }
1456
+ }
1457
+ {
1458
+ const childSpecificOnCleanup = (callback) => {
1459
+ childInfo.cleanupCallbacks.push(callback);
1460
+ };
1461
+ const childSpecificOnBeforeRender = (callback) => {
1462
+ childInfo.beforeRenderCallbacks.push(callback);
1463
+ };
1464
+ const childSpecificOnAfterRender = (callback) => {
1465
+ childInfo.afterRenderCallbacks.push(callback);
1466
+ };
1467
+ const childSpecificOnResize = (callback) => {
1468
+ childInfo.resizeCallbacks.push(callback);
1469
+ };
1470
+ let effectiveChildNode = composedChildrenResult;
1471
+ if (childInfo.requiresRTT && composedChildrenResult !== void 0) effectiveChildNode = applyBlendMode(vec4(0, 0, 0, 0), composedChildrenResult, "normal", 1);
1472
+ childInfo.cleanupCallbacks = [];
1473
+ childInfo.beforeRenderCallbacks = [];
1474
+ childInfo.afterRenderCallbacks = [];
1475
+ childInfo.resizeCallbacks = [];
1476
+ childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc({
1477
+ uniforms: childInfo.uniforms ?? {},
1478
+ childNode: effectiveChildNode,
1479
+ onCleanup: childSpecificOnCleanup,
1480
+ onBeforeRender: childSpecificOnBeforeRender,
1481
+ onAfterRender: childSpecificOnAfterRender,
1482
+ onResize: childSpecificOnResize,
1483
+ canvas: canvasElement,
1484
+ dimensions: {
1485
+ width: currentWidth,
1486
+ height: currentHeight
1487
+ },
1488
+ renderer
1489
+ }), childInfo), childInfo, childInfo.id, processedMasks);
1490
+ }
1491
+ }
1492
+ if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildrenResult = applyBlendMode(vec4(0, 0, 0, 0), childResult, "normal", childInfo.opacityUniform);
1493
+ else if (composedChildrenResult === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildrenResult = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
1494
+ else composedChildrenResult = childResult;
1495
+ else composedChildrenResult = applyBlendMode(composedChildrenResult, childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
1496
+ }
1497
+ nodeInfo.cleanupCallbacks.forEach((callback) => {
1498
+ try {
1499
+ callback();
1500
+ } catch (e) {
1501
+ console.error("Error in cleanup callback:", e);
1502
+ }
1503
+ });
1504
+ nodeInfo.cleanupCallbacks = [];
1505
+ nodeInfo.beforeRenderCallbacks = [];
1506
+ nodeInfo.afterRenderCallbacks = [];
1507
+ nodeInfo.resizeCallbacks = [];
1508
+ return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc({
1509
+ uniforms: nodeInfo.uniforms ?? {},
1510
+ childNode: composedChildrenResult,
1511
+ onCleanup: nodeSpecificOnCleanup,
1512
+ onBeforeRender: nodeSpecificOnBeforeRender,
1513
+ onAfterRender: nodeSpecificOnAfterRender,
1514
+ onResize: nodeSpecificOnResize,
1515
+ canvas: canvasElement,
1516
+ dimensions: {
1517
+ width: currentWidth,
1518
+ height: currentHeight
1519
+ },
1520
+ renderer
1521
+ }), nodeInfo), nodeInfo, nodeId, processedMasks);
1522
+ }
1523
+ }
1524
+ };
1525
+ const registerNode = (id, fragmentNodeFunc, parentId, metadata, uniforms = {}, componentDefinition$55) => {
1526
+ if (fragmentNodeFunc === null) {
1527
+ const queueIndex = pendingRegistrationQueue.findIndex((item) => item.id === id);
1528
+ if (queueIndex !== -1) {
1529
+ pendingRegistrationQueue.splice(queueIndex, 1);
1530
+ return;
1531
+ }
1532
+ removeNode(id);
1533
+ return;
1534
+ }
1535
+ if (!isRendererReady) {
1536
+ const existing = pendingRegistrationQueue.findIndex((item) => item.id === id);
1537
+ if (existing !== -1) pendingRegistrationQueue[existing] = {
1538
+ id,
1539
+ fragmentNodeFunc,
1540
+ parentId,
1541
+ metadata,
1542
+ uniforms,
1543
+ componentDefinition: componentDefinition$55
1544
+ };
1545
+ else pendingRegistrationQueue.push({
1546
+ id,
1547
+ fragmentNodeFunc,
1548
+ parentId,
1549
+ metadata,
1550
+ uniforms,
1551
+ componentDefinition: componentDefinition$55
1552
+ });
1553
+ return;
1554
+ }
1555
+ let defaultRenderOrder = 0;
1556
+ if (parentId !== null) {
1557
+ const siblings = parentToChildren.get(parentId);
1558
+ if (siblings && siblings.size > 0) {
1559
+ let maxOrder = 0;
1560
+ for (const siblingId of siblings) {
1561
+ const sibling = nodeRegistry.nodes.get(siblingId);
1562
+ if (sibling && sibling.metadata.renderOrder > maxOrder) maxOrder = sibling.metadata.renderOrder;
1563
+ }
1564
+ defaultRenderOrder = maxOrder + 1;
1565
+ }
1566
+ }
1567
+ const opacityUniform = uniform(metadata?.opacity !== void 0 ? metadata.opacity : 1);
1568
+ let transformUniforms = void 0;
1569
+ if (metadata?.transform) {
1570
+ const aspectRatio = currentWidth / Math.max(1, currentHeight);
1571
+ transformUniforms = {
1572
+ offsetX: uniform(metadata.transform.offsetX),
1573
+ offsetY: uniform(metadata.transform.offsetY),
1574
+ rotation: uniform(metadata.transform.rotation),
1575
+ scale: uniform(metadata.transform.scale),
1576
+ anchorX: uniform(metadata.transform.anchorX),
1577
+ anchorY: uniform(metadata.transform.anchorY),
1578
+ edges: uniform(metadata.transform.edges === "stretch" ? 0 : metadata.transform.edges === "transparent" ? 1 : metadata.transform.edges === "mirror" ? 2 : 3),
1579
+ aspectRatio: uniform(aspectRatio)
1580
+ };
1581
+ }
1582
+ const nodeInfo = {
1583
+ id,
1584
+ componentName: componentDefinition$55?.name || "Unknown",
1585
+ fragmentNodeFunc,
1586
+ parentId,
1587
+ requiresRTT: componentDefinition$55?.requiresRTT || false,
1588
+ requiresChild: componentDefinition$55?.requiresChild || false,
1589
+ opacityUniform,
1590
+ metadata: {
1591
+ blendMode: metadata?.blendMode || "normal",
1592
+ opacity: metadata?.opacity,
1593
+ visible: metadata?.visible === false ? false : true,
1594
+ id: metadata?.id,
1595
+ mask: metadata?.mask,
1596
+ renderOrder: metadata?.renderOrder !== void 0 ? metadata?.renderOrder : defaultRenderOrder,
1597
+ transform: metadata?.transform
1598
+ },
1599
+ uniforms,
1600
+ cleanupCallbacks: [],
1601
+ beforeRenderCallbacks: [],
1602
+ afterRenderCallbacks: [],
1603
+ resizeCallbacks: [],
1604
+ transformUniforms,
1605
+ transformRTTActive: false,
1606
+ uvTransformFunc: componentDefinition$55?.uvTransformNode,
1607
+ acceptsUVContext: componentDefinition$55?.acceptsUVContext || false
1608
+ };
1609
+ nodeRegistry.nodes.set(id, nodeInfo);
1610
+ if (parentId === null) nodeRegistry.rootId = id;
1611
+ const childrenSet = parentToChildren.get(parentId) || /* @__PURE__ */ new Set();
1612
+ childrenSet.add(id);
1613
+ parentToChildren.set(parentId, childrenSet);
1614
+ if (material && isInitialized && currentWidth > 0 && currentHeight > 0) {
1615
+ if (!registrationQueue.includes(id)) registrationQueue.push(id);
1616
+ if (registrationBatchRAF === null) registrationBatchRAF = requestAnimationFrame(() => {
1617
+ registrationBatchRAF = null;
1618
+ registrationQueue = [];
1619
+ updateMaterial();
1620
+ });
1621
+ } else if (material && isInitialized) {
1622
+ if (!materialUpdatePending) {
1623
+ materialUpdatePending = true;
1624
+ requestAnimationFrame(() => {
1625
+ materialUpdatePending = false;
1626
+ if (currentWidth > 0 && currentHeight > 0) updateMaterial();
1627
+ });
1628
+ }
1629
+ }
1630
+ };
1631
+ const updateUniformValue$1 = (nodeId, uniformName, value) => {
1632
+ const nodeInfo = nodeRegistry.nodes.get(nodeId);
1633
+ if (!nodeInfo || !nodeInfo.uniforms) return;
1634
+ const uniformDefinition = nodeInfo.uniforms[uniformName];
1635
+ if (!uniformDefinition || !uniformDefinition.uniform) return;
1636
+ if (uniformDefinition.transform) updateUniformValue(uniformDefinition, value);
1637
+ else uniformDefinition.uniform.value = value;
1638
+ renderFrame();
1639
+ };
1640
+ const updateNodeMetadata = (nodeId, metadata) => {
1641
+ const existingNode = nodeRegistry.nodes.get(nodeId);
1642
+ if (!existingNode) return;
1643
+ let needsRecompose = false;
1644
+ if (metadata.blendMode !== void 0 && existingNode.metadata.blendMode !== metadata.blendMode) {
1645
+ existingNode.metadata.blendMode = metadata.blendMode;
1646
+ needsRecompose = true;
1647
+ }
1648
+ if (metadata.opacity !== void 0 && existingNode.metadata.opacity !== metadata.opacity) {
1649
+ existingNode.metadata.opacity = metadata.opacity;
1650
+ existingNode.opacityUniform.value = metadata.opacity;
1651
+ }
1652
+ if (metadata.renderOrder !== void 0 && existingNode.metadata.renderOrder !== metadata.renderOrder) {
1653
+ existingNode.metadata.renderOrder = metadata.renderOrder;
1654
+ needsRecompose = true;
1655
+ }
1656
+ const newVisible = metadata.visible === false ? false : true;
1657
+ if (existingNode.metadata.visible !== newVisible) {
1658
+ existingNode.metadata.visible = newVisible;
1659
+ needsRecompose = true;
1660
+ }
1661
+ if (metadata.id !== void 0 && existingNode.metadata.id !== metadata.id) {
1662
+ existingNode.metadata.id = metadata.id;
1663
+ needsRecompose = true;
1664
+ }
1665
+ if (metadata.mask !== void 0 && (existingNode.metadata.mask?.source !== metadata.mask?.source || existingNode.metadata.mask?.type !== metadata.mask?.type)) {
1666
+ existingNode.metadata.mask = metadata.mask;
1667
+ needsRecompose = true;
1668
+ }
1669
+ if (metadata.transform !== void 0) {
1670
+ const oldTransformState = existingNode.metadata.transform ? needsTransformation(existingNode.metadata.transform) : false;
1671
+ const newTransformState = needsTransformation(metadata.transform);
1672
+ existingNode.metadata.transform = metadata.transform;
1673
+ if (!existingNode.transformUniforms && metadata.transform) {
1674
+ const aspectRatio = currentWidth / Math.max(1, currentHeight);
1675
+ existingNode.transformUniforms = {
1676
+ offsetX: uniform(metadata.transform.offsetX),
1677
+ offsetY: uniform(metadata.transform.offsetY),
1678
+ rotation: uniform(metadata.transform.rotation),
1679
+ scale: uniform(metadata.transform.scale),
1680
+ anchorX: uniform(metadata.transform.anchorX),
1681
+ anchorY: uniform(metadata.transform.anchorY),
1682
+ edges: uniform(metadata.transform.edges === "stretch" ? 0 : metadata.transform.edges === "transparent" ? 1 : metadata.transform.edges === "mirror" ? 2 : 3),
1683
+ aspectRatio: uniform(aspectRatio)
1684
+ };
1685
+ } else if (existingNode.transformUniforms) {
1686
+ existingNode.transformUniforms.offsetX.value = metadata.transform.offsetX;
1687
+ existingNode.transformUniforms.offsetY.value = metadata.transform.offsetY;
1688
+ existingNode.transformUniforms.rotation.value = metadata.transform.rotation;
1689
+ existingNode.transformUniforms.scale.value = metadata.transform.scale;
1690
+ existingNode.transformUniforms.anchorX.value = metadata.transform.anchorX;
1691
+ existingNode.transformUniforms.anchorY.value = metadata.transform.anchorY;
1692
+ existingNode.transformUniforms.edges.value = metadata.transform.edges === "stretch" ? 0 : metadata.transform.edges === "transparent" ? 1 : metadata.transform.edges === "mirror" ? 2 : 3;
1693
+ }
1694
+ if (newTransformState && !existingNode.transformRTTActive) {
1695
+ existingNode.transformRTTActive = true;
1696
+ needsRecompose = true;
1697
+ }
1698
+ if (!oldTransformState && newTransformState && !existingNode.transformRTTActive) needsRecompose = true;
1699
+ }
1700
+ if (needsRecompose && material && isInitialized) {
1701
+ if (!metadataUpdateQueue.includes(nodeId)) metadataUpdateQueue.push(nodeId);
1702
+ if (metadataUpdateBatchRAF === null) metadataUpdateBatchRAF = requestAnimationFrame(() => {
1703
+ metadataUpdateBatchRAF = null;
1704
+ metadataUpdateQueue = [];
1705
+ updateMaterial();
1706
+ });
1707
+ } else renderFrame();
1708
+ };
1709
+ const removeNode = (id) => {
1710
+ if (!nodeRegistry.nodes.has(id)) return;
1711
+ const nodeInfo = nodeRegistry.nodes.get(id);
1712
+ if (nodeInfo && nodeInfo.cleanupCallbacks.length > 0) for (const callback of nodeInfo.cleanupCallbacks) try {
1713
+ callback();
1714
+ } catch (e) {
1715
+ console.error(`Error executing cleanup callback for node ${id}:`, e);
1716
+ }
1717
+ const childNodes = findChildNodes(id);
1718
+ for (const child of childNodes) removeNode(child.id);
1719
+ if (nodeRegistry.rootId === id) nodeRegistry.rootId = null;
1720
+ if (nodeInfo) {
1721
+ const childrenSet = parentToChildren.get(nodeInfo.parentId);
1722
+ if (childrenSet) {
1723
+ childrenSet.delete(id);
1724
+ if (childrenSet.size === 0) parentToChildren.delete(nodeInfo.parentId);
1725
+ }
1726
+ }
1727
+ nodeRegistry.nodes.delete(id);
1728
+ if (material && isInitialized) updateMaterial();
1729
+ };
1730
+ const executeBeforeRenderCallbacks = (deltaTime) => {
1731
+ const params = {
1732
+ deltaTime,
1733
+ pointer: {
1734
+ x: pointerX,
1735
+ y: pointerY
1736
+ },
1737
+ pointerActive,
1738
+ dimensions: {
1739
+ width: currentWidth,
1740
+ height: currentHeight
1741
+ }
1742
+ };
1743
+ for (const nodeInfo of nodeRegistry.nodes.values()) if (nodeInfo.beforeRenderCallbacks.length > 0) for (const callback of nodeInfo.beforeRenderCallbacks) try {
1744
+ callback(params);
1745
+ } catch (e) {
1746
+ console.error(`Error executing before render callback for node ${nodeInfo.id}:`, e);
1747
+ }
1748
+ };
1749
+ const executeAfterRenderCallbacks = (deltaTime) => {
1750
+ const params = {
1751
+ deltaTime,
1752
+ pointer: {
1753
+ x: pointerX,
1754
+ y: pointerY
1755
+ },
1756
+ pointerActive,
1757
+ dimensions: {
1758
+ width: currentWidth,
1759
+ height: currentHeight
1760
+ }
1761
+ };
1762
+ for (const nodeInfo of nodeRegistry.nodes.values()) if (nodeInfo.afterRenderCallbacks.length > 0) for (const callback of nodeInfo.afterRenderCallbacks) try {
1763
+ callback(params);
1764
+ } catch (e) {
1765
+ console.error(`Error executing after render callback for node ${nodeInfo.id}:`, e);
1766
+ }
1767
+ };
1768
+ const renderFrame = async () => {
1769
+ if (!canRender()) return;
1770
+ const frameStartTime = enablePerformanceTracking ? performance.now() : 0;
1771
+ const currentTime = frameStartTime || performance.now();
1772
+ const deltaTime = lastRenderTime > 0 ? (currentTime - lastRenderTime) / 1e3 : .016;
1773
+ const OFF_SCREEN_FPS_INTERVAL = 1e3;
1774
+ if (!isVisible && lastRenderTime > 0) {
1775
+ if (currentTime - lastRenderTime < OFF_SCREEN_FPS_INTERVAL) return;
1776
+ }
1777
+ const cappedDeltaTime = Math.min(deltaTime, .1);
1778
+ lastRenderTime = currentTime;
1779
+ if (enablePerformanceTracking) performance.mark("shader-cpu-start");
1780
+ executeBeforeRenderCallbacks(cappedDeltaTime);
1781
+ try {
1782
+ if (isUpdatingMaterial) return;
1783
+ if (enablePerformanceTracking) performance.mark("shader-gpu-start");
1784
+ renderer.render(scene, camera);
1785
+ executeAfterRenderCallbacks(cappedDeltaTime);
1786
+ if (enablePerformanceTracking) {
1787
+ performance.mark("shader-gpu-end");
1788
+ if (renderer instanceof WebGPURenderer) try {
1789
+ const backend = renderer.backend;
1790
+ if (backend && backend.get && backend.get(renderer)) {
1791
+ const renderContext = backend.get(renderer);
1792
+ if (renderContext?.timestampQuery) {
1793
+ const gpuTime = renderContext.timestampQuery.getResult();
1794
+ if (gpuTime !== null && gpuTime !== void 0) performanceTracker.recordGpuTime(gpuTime / 1e6);
1795
+ }
1796
+ }
1797
+ } catch (e) {}
1798
+ try {
1799
+ performance.measure("shader-gpu-time", "shader-gpu-start", "shader-gpu-end");
1800
+ const gpuMeasure = performance.getEntriesByName("shader-gpu-time")[0];
1801
+ if (gpuMeasure) performanceTracker.recordGpuTime(gpuMeasure.duration);
1802
+ performance.clearMarks("shader-gpu-start");
1803
+ performance.clearMarks("shader-gpu-end");
1804
+ performance.clearMeasures("shader-gpu-time");
1805
+ } catch (e) {}
1806
+ }
1807
+ if (enablePerformanceTracking) {
1808
+ performance.mark("shader-cpu-end");
1809
+ try {
1810
+ performance.measure("shader-cpu-time", "shader-cpu-start", "shader-cpu-end");
1811
+ const cpuMeasure = performance.getEntriesByName("shader-cpu-time")[0];
1812
+ if (cpuMeasure) performanceTracker.recordCpuTime(cpuMeasure.duration);
1813
+ performance.clearMarks("shader-cpu-start");
1814
+ performance.clearMarks("shader-cpu-end");
1815
+ performance.clearMeasures("shader-cpu-time");
1816
+ } catch (e) {}
1817
+ const frameTime = performance.now() - frameStartTime;
1818
+ performanceTracker.recordFrame(frameTime);
1819
+ }
1820
+ } catch (error) {
1821
+ console.error("Render frame error:", error);
1822
+ }
1823
+ };
1824
+ const updatePerformanceNodeCounts = () => {
1825
+ const nodeCount = Math.max(0, nodeRegistry.nodes.size - 1);
1826
+ const rttNodeCount = actualRTTOperations;
1827
+ performanceTracker.updateNodeCounts(nodeCount, rttNodeCount);
1828
+ };
1829
+ const getPerformanceStats = () => {
1830
+ updatePerformanceNodeCounts();
1831
+ const rendererInfo = renderer?.info;
1832
+ return performanceTracker.getStats(rendererInfo);
1833
+ };
1834
+ const startAnimation = () => {
1835
+ if (animationFrameId || !shouldAnimate) return;
1836
+ performanceTracker.setRendering(true);
1837
+ const animate = () => {
1838
+ animationFrameId = requestAnimationFrame(animate);
1839
+ renderFrame().catch(console.warn);
1840
+ };
1841
+ animate();
1842
+ };
1843
+ const stopAnimation = () => {
1844
+ if (animationFrameId) {
1845
+ cancelAnimationFrame(animationFrameId);
1846
+ animationFrameId = null;
1847
+ }
1848
+ performanceTracker.setRendering(false);
1849
+ };
1850
+ const updatePointerCoords = (event) => {
1851
+ if (!canvasElement) return;
1852
+ let clientX;
1853
+ let clientY;
1854
+ if ("touches" in event) {
1855
+ if (event.touches.length === 0) return;
1856
+ clientX = event.touches[0].clientX;
1857
+ clientY = event.touches[0].clientY;
1858
+ } else {
1859
+ clientX = event.clientX;
1860
+ clientY = event.clientY;
1861
+ }
1862
+ const rect = canvasElement.getBoundingClientRect();
1863
+ const x = (clientX - rect.left) / rect.width;
1864
+ const y = (clientY - rect.top) / rect.height;
1865
+ pointerX = x;
1866
+ pointerY = y;
1867
+ };
1868
+ const globalMouseMoveHandler = (event) => {
1869
+ if (!isInitialized || !canvasElement) return;
1870
+ updatePointerCoords(event);
1871
+ };
1872
+ const globalTouchMoveHandler = (event) => {
1873
+ if (!isInitialized || !canvasElement) return;
1874
+ updatePointerCoords(event);
1875
+ };
1876
+ const globalMouseUpHandler = () => {
1877
+ if (!isInitialized) return;
1878
+ pointerActive = false;
1879
+ renderFrame().catch(console.warn);
1880
+ };
1881
+ const globalTouchEndHandler = () => {
1882
+ if (!isInitialized) return;
1883
+ pointerActive = false;
1884
+ renderFrame().catch(console.warn);
1885
+ };
1886
+ const canvasMouseDownHandler = () => {
1887
+ pointerActive = true;
1888
+ renderFrame().catch(console.warn);
1889
+ };
1890
+ const canvasTouchStartHandler = () => {
1891
+ pointerActive = true;
1892
+ renderFrame().catch(console.warn);
1893
+ };
1894
+ const processQueuedRegistrations = () => {
1895
+ if (pendingRegistrationQueue.length === 0) return;
1896
+ const queue = [...pendingRegistrationQueue];
1897
+ pendingRegistrationQueue = [];
1898
+ for (const { id, fragmentNodeFunc, parentId, metadata, uniforms, componentDefinition: componentDefinition$55 } of queue) if (fragmentNodeFunc) registerNode(id, fragmentNodeFunc, parentId, metadata, uniforms, componentDefinition$55);
1899
+ };
1900
+ const initialize = async ({ canvas, enablePerformanceTracking: enableTracking = false }) => {
1901
+ if (isInitialized || isInitializing) return;
1902
+ enablePerformanceTracking = enableTracking;
1903
+ isInitializing = true;
1904
+ initializationAbortController = new AbortController();
1905
+ const localAbortController = initializationAbortController;
1906
+ try {
1907
+ canvasElement = canvas;
1908
+ scene = new Scene();
1909
+ scene.background = null;
1910
+ camera = new OrthographicCamera(-1, 1, 1, -1, .1, 10);
1911
+ camera.position.z = 1;
1912
+ camera.lookAt(0, 0, 0);
1913
+ globalEventUnregister = globalEventManager.register({
1914
+ onMouseMove: globalMouseMoveHandler,
1915
+ onTouchMove: globalTouchMoveHandler,
1916
+ onMouseUp: globalMouseUpHandler,
1917
+ onTouchEnd: globalTouchEndHandler
1918
+ });
1919
+ canvas.addEventListener("mousedown", canvasMouseDownHandler);
1920
+ canvas.addEventListener("touchstart", canvasTouchStartHandler);
1921
+ unloadHandler = () => {
1922
+ cleanup();
1923
+ };
1924
+ window.addEventListener("beforeunload", unloadHandler);
1925
+ if (localAbortController.signal.aborted) return;
1926
+ try {
1927
+ const rendererOptions = {
1928
+ canvas,
1929
+ antialias: true,
1930
+ alpha: true,
1931
+ depth: false,
1932
+ powerPreference: "high-performance"
1933
+ };
1934
+ if (enablePerformanceTracking) {
1935
+ rendererOptions.forceWebGL = false;
1936
+ rendererOptions.requiredFeatures = ["timestamp-query"];
1937
+ }
1938
+ renderer = new WebGPURenderer(rendererOptions);
1939
+ await renderer.init();
1940
+ if (localAbortController.signal.aborted) return;
1941
+ } catch (e) {
1942
+ if (localAbortController.signal.aborted) return;
1943
+ console.warn("[Shaders] WebGPU initialization failed, falling back to WebGL:", e);
1944
+ try {
1945
+ renderer = new WebGLRenderer({
1946
+ canvas,
1947
+ antialias: true,
1948
+ alpha: true,
1949
+ depth: false,
1950
+ powerPreference: "high-performance"
1951
+ });
1952
+ if (localAbortController.signal.aborted) return;
1953
+ } catch (webglError) {
1954
+ if (localAbortController.signal.aborted) return;
1955
+ console.error("[Shaders] Both WebGPU and WebGL initialization failed:", webglError);
1956
+ return;
1957
+ }
1958
+ }
1959
+ if (localAbortController.signal.aborted) return;
1960
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
1961
+ renderer.outputColorSpace = SRGBColorSpace;
1962
+ material = new MeshBasicNodeMaterial({ transparent: true });
1963
+ material.fragmentNode = vec4(0, 0, 0, 0);
1964
+ mesh = new Mesh(new PlaneGeometry(2, 2), material);
1965
+ scene.add(mesh);
1966
+ const parentElement = canvas.parentElement;
1967
+ if (!parentElement) {
1968
+ console.warn("[Shaders] Canvas has no parent element for resize observation");
1969
+ return;
1970
+ }
1971
+ resizeObserver = new ResizeObserver(handleResize);
1972
+ resizeObserver.observe(parentElement);
1973
+ intersectionObserver = new IntersectionObserver(handleVisibilityChange, { threshold: 0 });
1974
+ intersectionObserver.observe(canvas);
1975
+ const rect = canvas.getBoundingClientRect();
1976
+ isVisible = rect.width > 0 && rect.height > 0 && rect.top < window.innerHeight && rect.bottom > 0 && rect.left < window.innerWidth && rect.right > 0;
1977
+ shouldAnimate = true;
1978
+ const { width, height } = canvas.getBoundingClientRect();
1979
+ const roundedWidth = Math.round(width);
1980
+ const roundedHeight = Math.round(height);
1981
+ if (roundedWidth > 0 && roundedHeight > 0) {
1982
+ currentWidth = roundedWidth;
1983
+ currentHeight = roundedHeight;
1984
+ hasInitialDimensions = true;
1985
+ renderer.setSize(roundedWidth, roundedHeight, false);
1986
+ const aspectRatio = roundedWidth / roundedHeight;
1987
+ const frustumHeight = 2;
1988
+ const frustumWidth = frustumHeight * aspectRatio;
1989
+ camera.left = -frustumWidth / 2;
1990
+ camera.right = frustumWidth / 2;
1991
+ camera.top = frustumHeight / 2;
1992
+ camera.bottom = -frustumHeight / 2;
1993
+ camera.updateProjectionMatrix();
1994
+ mesh.scale.set(frustumWidth, frustumHeight, 1);
1995
+ await renderFrame();
1996
+ } else hasInitialDimensions = false;
1997
+ if (shouldAnimate) startAnimation();
1998
+ if (!localAbortController.signal.aborted) {
1999
+ isInitialized = true;
2000
+ isRendererReady = true;
2001
+ processQueuedRegistrations();
2002
+ }
2003
+ } catch (error) {
2004
+ console.error("[Shaders] Initialization error:", error);
2005
+ } finally {
2006
+ isInitializing = false;
2007
+ if (initializationAbortController === localAbortController) initializationAbortController = null;
2008
+ }
2009
+ };
2010
+ const showLicenseWarning = () => {
2011
+ if (!isDevelopment() || hasLoggedLicenseInfo) return;
2012
+ console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.");
2013
+ hasLoggedLicenseInfo = true;
2014
+ };
2015
+ const cleanup = () => {
2016
+ if (initializationAbortController) initializationAbortController.abort();
2017
+ if (resizeObserver) {
2018
+ resizeObserver.disconnect();
2019
+ resizeObserver = null;
2020
+ }
2021
+ if (intersectionObserver) {
2022
+ intersectionObserver.disconnect();
2023
+ intersectionObserver = null;
2024
+ }
2025
+ if (globalEventUnregister) {
2026
+ globalEventUnregister();
2027
+ globalEventUnregister = null;
2028
+ }
2029
+ if (canvasElement) {
2030
+ canvasElement.removeEventListener("mousedown", canvasMouseDownHandler);
2031
+ canvasElement.removeEventListener("touchstart", canvasTouchStartHandler);
2032
+ }
2033
+ if (unloadHandler) {
2034
+ window.removeEventListener("beforeunload", unloadHandler);
2035
+ unloadHandler = null;
2036
+ }
2037
+ stopAnimation();
2038
+ disposePreviousTextures();
2039
+ currentTextures.forEach((texture) => {
2040
+ try {
2041
+ if (texture?.renderTarget?.dispose) texture.renderTarget.dispose();
2042
+ } catch (e) {}
2043
+ });
2044
+ currentTextures.clear();
2045
+ nodeRegistry.nodes.clear();
2046
+ nodeRegistry.rootId = null;
2047
+ nodeRegistry.idToNodeId.clear();
2048
+ parentToChildren.clear();
2049
+ pendingRegistrationQueue = [];
2050
+ isRendererReady = false;
2051
+ registrationQueue = [];
2052
+ if (registrationBatchRAF !== null) {
2053
+ cancelAnimationFrame(registrationBatchRAF);
2054
+ registrationBatchRAF = null;
2055
+ }
2056
+ metadataUpdateQueue = [];
2057
+ if (metadataUpdateBatchRAF !== null) {
2058
+ cancelAnimationFrame(metadataUpdateBatchRAF);
2059
+ metadataUpdateBatchRAF = null;
2060
+ }
2061
+ pendingResize = null;
2062
+ isResizeScheduled = false;
2063
+ if (mesh) {
2064
+ if (scene) scene.remove(mesh);
2065
+ try {
2066
+ if (mesh.geometry && typeof mesh.geometry.dispose === "function") mesh.geometry.dispose();
2067
+ } catch (e) {}
2068
+ try {
2069
+ if (mesh.material instanceof Material && typeof mesh.material.dispose === "function") mesh.material.dispose();
2070
+ } catch (e) {}
2071
+ }
2072
+ if (renderer && typeof renderer.dispose === "function") try {
2073
+ renderer.dispose();
2074
+ } catch (e) {}
2075
+ canvasElement = null;
2076
+ renderer = null;
2077
+ camera = null;
2078
+ scene = null;
2079
+ mesh = null;
2080
+ material = null;
2081
+ isInitialized = false;
2082
+ isInitializing = false;
2083
+ hasInitialDimensions = false;
2084
+ initializationAbortController = null;
2085
+ currentWidth = 0;
2086
+ currentHeight = 0;
2087
+ isVisible = false;
2088
+ shouldAnimate = true;
2089
+ pointerX = .5;
2090
+ pointerY = .5;
2091
+ pointerActive = false;
2092
+ };
2093
+ const getRendererType = () => {
2094
+ if (!renderer) return null;
2095
+ return renderer instanceof WebGPURenderer ? "webgpu" : "webgl";
2096
+ };
2097
+ return {
2098
+ initialize,
2099
+ cleanup,
2100
+ registerNode,
2101
+ removeNode,
2102
+ updateUniformValue: updateUniformValue$1,
2103
+ updateNodeMetadata,
2104
+ showLicenseWarning,
2105
+ isInitialized: () => isInitialized,
2106
+ startAnimation,
2107
+ stopAnimation,
2108
+ getPerformanceStats,
2109
+ getNodeRegistry: () => ({ nodes: new Map(nodeRegistry.nodes) }),
2110
+ getRendererType,
2111
+ __testing: {
2112
+ isUVComposable,
2113
+ canSkipRTT,
2114
+ hasUVPropagationOpportunity,
2115
+ needsTransformation,
2116
+ findUVChain,
2117
+ findSiblingUVChain,
2118
+ findChildNodes,
2119
+ composeUVContextChain,
2120
+ composeUVChain,
2121
+ composeSiblingUVChain,
2122
+ composeSiblingsWithUVContext,
2123
+ applyMaskIfNeeded,
2124
+ applyNodeTransformation,
2125
+ getNodeRegistry: () => nodeRegistry,
2126
+ getParentToChildren: () => parentToChildren
2127
+ }
2128
+ };
1497
2129
  }
1498
- function ii(e) {
1499
- const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), t = {
1500
- processingOrder: [],
1501
- maskSources: /* @__PURE__ */ new Map(),
1502
- circularDependencies: []
1503
- };
1504
- return e.forEach((u) => {
1505
- u.elementId && n.set(u.elementId, u.id);
1506
- }), e.forEach((u) => {
1507
- if (u.mask?.source) {
1508
- const p = u.mask.source.startsWith("#") ? u.mask.source.substring(1) : u.mask.source, h = n.get(p);
1509
- h ? (s.has(u.id) || s.set(u.id, []), s.get(u.id)?.push(h), t.maskSources.set(u.id, h)) : console.warn(`Mask source "${p}" not found for node "${u.id}"`);
1510
- }
1511
- }), t.processingOrder = Lr(s, t.circularDependencies), t;
2130
+ function resolveMaskDependencies(nodes) {
2131
+ const elementIdToNodeId = /* @__PURE__ */ new Map();
2132
+ const maskDependencies = /* @__PURE__ */ new Map();
2133
+ const result = {
2134
+ processingOrder: [],
2135
+ maskSources: /* @__PURE__ */ new Map(),
2136
+ circularDependencies: []
2137
+ };
2138
+ nodes.forEach((node) => {
2139
+ if (node.elementId) elementIdToNodeId.set(node.elementId, node.id);
2140
+ });
2141
+ nodes.forEach((node) => {
2142
+ if (node.mask?.source) {
2143
+ const sourceElementId = node.mask.source.startsWith("#") ? node.mask.source.substring(1) : node.mask.source;
2144
+ const sourceNodeId = elementIdToNodeId.get(sourceElementId);
2145
+ if (sourceNodeId) {
2146
+ if (!maskDependencies.has(node.id)) maskDependencies.set(node.id, []);
2147
+ maskDependencies.get(node.id)?.push(sourceNodeId);
2148
+ result.maskSources.set(node.id, sourceNodeId);
2149
+ } else console.warn(`Mask source "${sourceElementId}" not found for node "${node.id}"`);
2150
+ }
2151
+ });
2152
+ result.processingOrder = topologicalSort(maskDependencies, result.circularDependencies);
2153
+ return result;
1512
2154
  }
1513
- function Lr(e, n) {
1514
- const s = [], t = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
1515
- function p(d, k = []) {
1516
- if (t.has(d)) return;
1517
- if (u.has(d)) {
1518
- const B = [...k.slice(k.indexOf(d)), d];
1519
- n.push(B);
1520
- return;
1521
- }
1522
- u.add(d), k.push(d);
1523
- const U = e.get(d) || [];
1524
- for (const B of U) p(B, [...k]);
1525
- u.delete(d), t.add(d), s.push(d);
1526
- }
1527
- for (const d of e.keys()) t.has(d) || p(d);
1528
- const h = new Set([...e.values()].flat());
1529
- for (const d of h) !t.has(d) && !e.has(d) && s.push(d);
1530
- return s.reverse();
2155
+ function topologicalSort(dependencies, circularDependencies) {
2156
+ const result = [];
2157
+ const visited = /* @__PURE__ */ new Set();
2158
+ const tempVisited = /* @__PURE__ */ new Set();
2159
+ function visit(nodeId, path = []) {
2160
+ if (visited.has(nodeId)) return;
2161
+ if (tempVisited.has(nodeId)) {
2162
+ const cycle = [...path.slice(path.indexOf(nodeId)), nodeId];
2163
+ circularDependencies.push(cycle);
2164
+ return;
2165
+ }
2166
+ tempVisited.add(nodeId);
2167
+ path.push(nodeId);
2168
+ const deps = dependencies.get(nodeId) || [];
2169
+ for (const depId of deps) visit(depId, [...path]);
2170
+ tempVisited.delete(nodeId);
2171
+ visited.add(nodeId);
2172
+ result.push(nodeId);
2173
+ }
2174
+ for (const nodeId of dependencies.keys()) if (!visited.has(nodeId)) visit(nodeId);
2175
+ const allSourceNodeIds = new Set([...dependencies.values()].flat());
2176
+ for (const sourceId of allSourceNodeIds) if (!visited.has(sourceId) && !dependencies.has(sourceId)) result.push(sourceId);
2177
+ return result.reverse();
1531
2178
  }
1532
- var { vec2: Gr, fract: Nr, sin: Vr, dot: qr } = le;
1533
- const Pr = (e) => Nr(Vr(qr(e, Gr(12.12345, 78.12345))).mul(40000.12345)), ai = (e = 0.03) => (n) => Pr(n).mul(e).mul(0.10012345);
1534
- var { vec2: Xr } = le;
1535
- const si = (e = Xr(0), n = 0.02, s = 1, t = 1) => {
1536
- const { vec2: u, sin: p, cos: h, time: d } = le, k = t * 1.618033988749895, U = t * 2.718281828459045, B = (Math.sin(t) + 2) * 5, O = (Math.cos(t) + 2) * 5, Q = u(p(e.x.mul(s).mul(B).add(d.mul(0.1)).add(k)), h(e.y.mul(s).mul(B).add(d.mul(0.1)).add(U))), V = u(p(e.y.mul(s).mul(O).add(d.mul(0.05)).add(U)), h(e.x.mul(s).mul(O).add(d.mul(0.05)).add(k))), q = Q.add(V).mul(n);
1537
- return e.add(q);
1538
- }, li = (e, n, s = 0.6, t = 0.3, u = 1) => {
1539
- const { max: p, smoothstep: h, vec4: d } = le, k = p(p(e.r, e.g), e.b), U = h(s, s + t, k).mul(u).mul(1);
1540
- return d(e.rgb.add(n.rgb.mul(U)), e.a);
1541
- }, ci = (e = {}) => {
1542
- const { inset: n = 0.4, softness: s = 0.5, offsetX: t = 0, offsetY: u = 0 } = e, { float: p, smoothstep: h, uv: d } = le, k = d(), U = k.x.sub(0.5).sub(p(t)).mul(2), B = k.y.sub(0.5).add(p(u)).mul(2), O = U.mul(U).add(B.mul(B)).sqrt();
1543
- return p(1).sub(h(p(1).sub(p(n)), p(1).sub(p(n)).add(p(s)), O.mul(p(1).add(p(s)))));
2179
+ var { vec2: vec2$2, fract, sin: sin$1, dot: dot$1 } = TSL;
2180
+ const noise = (st) => fract(sin$1(dot$1(st, vec2$2(12.12345, 78.12345))).mul(40000.12345));
2181
+ const grain = (intensity = .03) => (st) => noise(st).mul(intensity).mul(.10012345);
2182
+ var { vec2: vec2$1 } = TSL;
2183
+ const distort = (uv = vec2$1(0), intensity = .02, frequency = 1, seed = 1) => {
2184
+ const { vec2: vec2$4, sin: sin$3, cos: cos$2, time } = TSL;
2185
+ const phaseX = seed * 1.618033988749895;
2186
+ const phaseY = seed * 2.718281828459045;
2187
+ const freqMod1 = (Math.sin(seed) + 2) * 5;
2188
+ const freqMod2 = (Math.cos(seed) + 2) * 5;
2189
+ const flow1 = vec2$4(sin$3(uv.x.mul(frequency).mul(freqMod1).add(time.mul(.1)).add(phaseX)), cos$2(uv.y.mul(frequency).mul(freqMod1).add(time.mul(.1)).add(phaseY)));
2190
+ const flow2 = vec2$4(sin$3(uv.y.mul(frequency).mul(freqMod2).add(time.mul(.05)).add(phaseY)), cos$2(uv.x.mul(frequency).mul(freqMod2).add(time.mul(.05)).add(phaseX)));
2191
+ const offset = flow1.add(flow2).mul(intensity);
2192
+ return uv.add(offset);
1544
2193
  };
1545
- var Yr = () => {
1546
- const e = {};
1547
- return Object.entries({
1548
- AngularBlur: Zn,
1549
- Ascii: Kn,
1550
- Blob: et,
1551
- Blur: nt,
1552
- Bulge: tt,
1553
- ChannelBlur: rt,
1554
- Checkerboard: ot,
1555
- ChromaFlow: it,
1556
- ChromaticAberration: at,
1557
- Circle: st,
1558
- CRTScreen: lt,
1559
- CursorTrail: ct,
1560
- DiffuseBlur: ft,
1561
- Dither: ut,
1562
- DotGrid: mt,
1563
- Duotone: dt,
1564
- FilmGrain: ht,
1565
- FloatingParticles: pt,
1566
- GlassTiles: gt,
1567
- Glow: bt,
1568
- Godrays: vt,
1569
- Grayscale: Ct,
1570
- Grid: Rt,
1571
- GridDistortion: kt,
1572
- Group: Tt,
1573
- Halftone: yt,
1574
- HueShift: wt,
1575
- ImageTexture: Ut,
1576
- Invert: St,
1577
- LinearBlur: Mt,
1578
- LinearGradient: xt,
1579
- Liquify: At,
1580
- Pixelate: zt,
1581
- PolarCoordinates: Dt,
1582
- Posterize: Et,
1583
- ProgressiveBlur: Ft,
1584
- RadialGradient: $t,
1585
- RectangularCoordinates: Ot,
1586
- Ripples: Bt,
1587
- Saturation: _t,
1588
- SimplexNoise: Lt,
1589
- SineWave: Gt,
1590
- SolidColor: Nt,
1591
- Spherize: Vt,
1592
- Spiral: qt,
1593
- Strands: Pt,
1594
- Stretch: Xt,
1595
- Swirl: Yt,
1596
- TiltShift: It,
1597
- Tritone: Ht,
1598
- Twirl: Wt,
1599
- Vibrance: jt,
1600
- WaveDistortion: Qt,
1601
- ZoomBlur: Jt
1602
- }).forEach(([s, t]) => {
1603
- const u = {};
1604
- t.props && Object.entries(t.props).forEach(([p, h]) => {
1605
- h.ui && (u[p] = {
1606
- ui: h.ui,
1607
- default: h.default,
1608
- description: h.description
1609
- });
1610
- }), e[t.name] = {
1611
- name: t.name,
1612
- fileName: s,
1613
- category: t.category || "Uncategorized",
1614
- definition: t,
1615
- propsMetadata: u
1616
- };
1617
- }), e;
2194
+ const glow = (color, glowColor, threshold = .6, softness = .3, intensity = 1) => {
2195
+ const { max: max$1, smoothstep, vec4: vec4$1 } = TSL;
2196
+ const brightness = max$1(max$1(color.r, color.g), color.b);
2197
+ const glowAmount = smoothstep(threshold, threshold + softness, brightness).mul(intensity).mul(1);
2198
+ return vec4$1(color.rgb.add(glowColor.rgb.mul(glowAmount)), color.a);
1618
2199
  };
1619
- const Le = Yr();
1620
- function fi() {
1621
- return Object.values(Le);
2200
+ const edgeMask = (options = {}) => {
2201
+ const { inset = .4, softness = .5, offsetX = 0, offsetY = 0 } = options;
2202
+ const { float: float$2, smoothstep, uv } = TSL;
2203
+ const rawUV = uv();
2204
+ const ovalX = rawUV.x.sub(.5).sub(float$2(offsetX)).mul(2);
2205
+ const ovalY = rawUV.y.sub(.5).add(float$2(offsetY)).mul(2);
2206
+ const ovalDistance = ovalX.mul(ovalX).add(ovalY.mul(ovalY)).sqrt();
2207
+ return float$2(1).sub(smoothstep(float$2(1).sub(float$2(inset)), float$2(1).sub(float$2(inset)).add(float$2(softness)), ovalDistance.mul(float$2(1).add(float$2(softness)))));
2208
+ };
2209
+ var createShaderRegistry = () => {
2210
+ const registry = {};
2211
+ const shaderDefinitions = {
2212
+ AngularBlur: componentDefinition,
2213
+ Ascii: componentDefinition$1,
2214
+ Beam: componentDefinition$2,
2215
+ Blob: componentDefinition$3,
2216
+ Blur: componentDefinition$4,
2217
+ Bulge: componentDefinition$5,
2218
+ ChannelBlur: componentDefinition$6,
2219
+ Checkerboard: componentDefinition$7,
2220
+ ChromaFlow: componentDefinition$8,
2221
+ ChromaticAberration: componentDefinition$9,
2222
+ Circle: componentDefinition$10,
2223
+ CRTScreen: componentDefinition$11,
2224
+ CursorTrail: componentDefinition$12,
2225
+ DiffuseBlur: componentDefinition$13,
2226
+ Dither: componentDefinition$14,
2227
+ DotGrid: componentDefinition$15,
2228
+ Duotone: componentDefinition$16,
2229
+ FilmGrain: componentDefinition$17,
2230
+ FloatingParticles: componentDefinition$18,
2231
+ GlassTiles: componentDefinition$19,
2232
+ Glow: componentDefinition$20,
2233
+ Godrays: componentDefinition$21,
2234
+ Grayscale: componentDefinition$22,
2235
+ Grid: componentDefinition$23,
2236
+ GridDistortion: componentDefinition$24,
2237
+ Group: componentDefinition$25,
2238
+ Halftone: componentDefinition$26,
2239
+ HueShift: componentDefinition$27,
2240
+ ImageTexture: componentDefinition$28,
2241
+ Invert: componentDefinition$29,
2242
+ LinearBlur: componentDefinition$30,
2243
+ LinearGradient: componentDefinition$31,
2244
+ Liquify: componentDefinition$32,
2245
+ Pixelate: componentDefinition$33,
2246
+ PolarCoordinates: componentDefinition$34,
2247
+ Posterize: componentDefinition$35,
2248
+ ProgressiveBlur: componentDefinition$36,
2249
+ RadialGradient: componentDefinition$37,
2250
+ RectangularCoordinates: componentDefinition$38,
2251
+ Ripples: componentDefinition$39,
2252
+ Saturation: componentDefinition$40,
2253
+ SimplexNoise: componentDefinition$41,
2254
+ SineWave: componentDefinition$42,
2255
+ SolidColor: componentDefinition$43,
2256
+ Spherize: componentDefinition$44,
2257
+ Spiral: componentDefinition$45,
2258
+ Strands: componentDefinition$46,
2259
+ Stretch: componentDefinition$47,
2260
+ Swirl: componentDefinition$48,
2261
+ TiltShift: componentDefinition$49,
2262
+ Tritone: componentDefinition$50,
2263
+ Twirl: componentDefinition$51,
2264
+ Vibrance: componentDefinition$52,
2265
+ WaveDistortion: componentDefinition$53,
2266
+ ZoomBlur: componentDefinition$54
2267
+ };
2268
+ Object.entries(shaderDefinitions).forEach(([fileName, def]) => {
2269
+ const propsMetadata = {};
2270
+ if (def.props) Object.entries(def.props).forEach(([propName, propConfig]) => {
2271
+ if (propConfig.ui) propsMetadata[propName] = {
2272
+ ui: propConfig.ui,
2273
+ default: propConfig.default,
2274
+ description: propConfig.description
2275
+ };
2276
+ });
2277
+ registry[def.name] = {
2278
+ name: def.name,
2279
+ fileName,
2280
+ category: def.category || "Uncategorized",
2281
+ definition: def,
2282
+ propsMetadata
2283
+ };
2284
+ });
2285
+ return registry;
2286
+ };
2287
+ const shaderRegistry = createShaderRegistry();
2288
+ function getAllShaders() {
2289
+ return Object.values(shaderRegistry);
1622
2290
  }
1623
- function ui(e) {
1624
- return Le[e];
2291
+ function getShaderByName(name) {
2292
+ return shaderRegistry[name];
1625
2293
  }
1626
- function mi(e) {
1627
- return Object.values(Le).filter((n) => n.category === e);
2294
+ function getShadersByCategory(category) {
2295
+ return Object.values(shaderRegistry).filter((shader) => shader.category === category);
1628
2296
  }
1629
- function di() {
1630
- const e = new Set(Object.values(Le).map((n) => n.category));
1631
- return Array.from(e).sort();
2297
+ function getShaderCategories() {
2298
+ const categories = new Set(Object.values(shaderRegistry).map((shader) => shader.category));
2299
+ return Array.from(categories).sort();
1632
2300
  }
1633
- export {
1634
- Qr as createAnimatedTime,
1635
- ri as createUniformsMap,
1636
- si as distort,
1637
- ci as edgeMask,
1638
- fi as getAllShaders,
1639
- ui as getShaderByName,
1640
- di as getShaderCategories,
1641
- mi as getShadersByCategory,
1642
- li as glow,
1643
- ai as grain,
1644
- ii as resolveMaskDependencies,
1645
- Le as shaderRegistry,
1646
- oi as shaderRenderer,
1647
- Or as updateUniformValue
1648
- };
2301
+ export { createAnimatedTime, createUniformsMap, distort, edgeMask, getAllShaders, getShaderByName, getShaderCategories, getShadersByCategory, glow, grain, resolveMaskDependencies, shaderRegistry, shaderRenderer, updateUniformValue };