zhuda-laya-engine 0.0.0-stage → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (740) hide show
  1. package/AGENTS.md +236 -0
  2. package/CHANGELOG.md +431 -0
  3. package/LICENSE +41 -0
  4. package/README.md +247 -2
  5. package/assets/branding/layaair-tribute-mark.svg +5 -0
  6. package/assets/branding/zhuda-layaair-mark.svg +34 -0
  7. package/assets/prefabs/CoinFountainVfx.lh +197 -0
  8. package/assets/prefabs/ConfirmActionButton.lh +87 -0
  9. package/assets/prefabs/LevelUpAuraVfx.lh +136 -0
  10. package/assets/prefabs/MineExplosionParticle.lh +352 -0
  11. package/assets/prefabs/NineSliceDialogFrame.lh +171 -0
  12. package/assets/prefabs/SwordSlashTrailVfx.lh +117 -0
  13. package/assets/prefabs/TacticalHudBar.lh +134 -0
  14. package/assets/prefabs/TelemetryDashboard.lh +87 -0
  15. package/assets/prefabs/UnityCrystalGuardian.lh +144 -0
  16. package/assets/prefabs/ZhudaSpine42Mascot.lh +183 -0
  17. package/assets/scenes/MinesweeperStage.ls +1180 -0
  18. package/dist/asset-calibration-report.json +969 -0
  19. package/dist/build-manifest.json +254 -0
  20. package/dist/sdk/zhuda-laya-csg.cjs +710 -0
  21. package/dist/sdk/zhuda-laya-csg.esm.js +683 -0
  22. package/dist/sdk/zhuda-laya-csg.min.cjs +7 -0
  23. package/dist/sdk/zhuda-laya-csg.min.esm.js +7 -0
  24. package/dist/sdk/zhuda-laya-demo.cjs +5990 -0
  25. package/dist/sdk/zhuda-laya-demo.esm.js +5956 -0
  26. package/dist/sdk/zhuda-laya-demo.min.cjs +12 -0
  27. package/dist/sdk/zhuda-laya-demo.min.esm.js +12 -0
  28. package/dist/sdk/zhuda-laya-engine.cjs +52628 -0
  29. package/dist/sdk/zhuda-laya-engine.esm.js +51848 -0
  30. package/dist/sdk/zhuda-laya-engine.min.cjs +2710 -0
  31. package/dist/sdk/zhuda-laya-engine.min.esm.js +2710 -0
  32. package/docs/3d-acceptance.md +47 -0
  33. package/docs/3d-integration.md +190 -0
  34. package/docs/README.md +112 -0
  35. package/docs/SUPPORT.md +21 -0
  36. package/docs/agent-development.md +219 -0
  37. package/docs/animation-control.md +213 -0
  38. package/docs/asset-loading.md +97 -0
  39. package/docs/assets/reference-games.jpg +0 -0
  40. package/docs/assets/solana-qr.png +0 -0
  41. package/docs/assets/sponsor-pass.svg +32 -0
  42. package/docs/audio.md +319 -0
  43. package/docs/backend-delivery.md +218 -0
  44. package/docs/basis-textures.md +94 -0
  45. package/docs/browser-sdk-releases.json +204 -0
  46. package/docs/browser-sdk.md +187 -0
  47. package/docs/cinematics.md +267 -0
  48. package/docs/cloth.md +280 -0
  49. package/docs/combat-runtime.md +82 -0
  50. package/docs/consumer-route.md +169 -0
  51. package/docs/consumer-tooling.md +518 -0
  52. package/docs/crowd-runtime.md +195 -0
  53. package/docs/developer-tooling.md +191 -0
  54. package/docs/film-scenes.md +1504 -0
  55. package/docs/filmic-rendering.md +743 -0
  56. package/docs/flythrough.md +89 -0
  57. package/docs/gpu-depth.md +207 -0
  58. package/docs/grass.md +127 -0
  59. package/docs/hdr-environment.md +76 -0
  60. package/docs/instanced-meshes.md +137 -0
  61. package/docs/layout-and-media.md +37 -0
  62. package/docs/layout-wireframe.md +80 -0
  63. package/docs/lighting-depth.md +185 -0
  64. package/docs/minigame-packaging.md +79 -0
  65. package/docs/model-editor.md +66 -0
  66. package/docs/model-lod.md +122 -0
  67. package/docs/model-pipeline.md +74 -0
  68. package/docs/model-showcase.md +365 -0
  69. package/docs/overview.md +183 -0
  70. package/docs/plans/README.md +133 -0
  71. package/docs/plans/TASK-TEMPLATE.md +64 -0
  72. package/docs/plans/TASK-spine38-isolated-topology-20261106.md +89 -0
  73. package/docs/plans/TEMPLATE.md +44 -0
  74. package/docs/plans/VERIFICATION-TEMPLATE.md +45 -0
  75. package/docs/plans/asset-packaging.md +140 -0
  76. package/docs/plans/cinematic-production/task.md +97 -0
  77. package/docs/plans/cinematic-production/verification.md +49 -0
  78. package/docs/plans/consumer-delivery-followups.md +129 -0
  79. package/docs/plans/desktop-and-agent-gates/hardening-task.md +85 -0
  80. package/docs/plans/desktop-and-agent-gates/hardening-verification.md +109 -0
  81. package/docs/plans/desktop-and-agent-gates/task.md +94 -0
  82. package/docs/plans/desktop-and-agent-gates/verification.md +60 -0
  83. package/docs/plans/prefab-toolchain.md +73 -0
  84. package/docs/plans/preview-runtime-hardening.md +68 -0
  85. package/docs/platform-adapters.md +113 -0
  86. package/docs/post-quality.md +242 -0
  87. package/docs/prefab-editor.md +194 -0
  88. package/docs/prefab-library.md +94 -0
  89. package/docs/prefab-workflow.md +75 -0
  90. package/docs/procedural-assets.md +463 -0
  91. package/docs/procedural-prefabs.md +133 -0
  92. package/docs/quality-route.md +386 -0
  93. package/docs/release-policy.md +79 -0
  94. package/docs/routes/README.md +180 -0
  95. package/docs/routes/TEMPLATE.md +54 -0
  96. package/docs/routes/action-adventure-3d-minigame.md +238 -0
  97. package/docs/routes/apocalypse-survival-3d.md +219 -0
  98. package/docs/routes/aqua-freeze-2d-minigame.md +183 -0
  99. package/docs/routes/astral-minimal-film-look.md +141 -0
  100. package/docs/routes/cascade-slot.md +93 -0
  101. package/docs/routes/clip-free-garments.md +229 -0
  102. package/docs/routes/drop-merge-2d-minigame.md +200 -0
  103. package/docs/routes/dungeon-line-slot.md +87 -0
  104. package/docs/routes/film-as-data.md +131 -0
  105. package/docs/routes/film-fight-that-lands.md +198 -0
  106. package/docs/routes/film-ink-lines.md +120 -0
  107. package/docs/routes/floating-island.md +229 -0
  108. package/docs/routes/game-2d.md +168 -0
  109. package/docs/routes/game-rules-first.md +89 -0
  110. package/docs/routes/game-to-prefabs.md +249 -0
  111. package/docs/routes/go-game-server.md +95 -0
  112. package/docs/routes/good-looking-3d-scene.md +99 -0
  113. package/docs/routes/high-quality-character.md +263 -0
  114. package/docs/routes/humanoid-from-shapes.md +97 -0
  115. package/docs/routes/hunting-action-3d.md +76 -0
  116. package/docs/routes/idle-gacha-2d.md +67 -0
  117. package/docs/routes/interactive-film-viewer.md +141 -0
  118. package/docs/routes/isometric-mystery-2d.md +217 -0
  119. package/docs/routes/key-art-to-animated-title.md +132 -0
  120. package/docs/routes/laya-ide-project-cli-web.md +125 -0
  121. package/docs/routes/layered-cloth-on-body.md +240 -0
  122. package/docs/routes/low-poly-character-from-shapes.md +475 -0
  123. package/docs/routes/match-three-2d.md +64 -0
  124. package/docs/routes/merge-2d.md +59 -0
  125. package/docs/routes/mini-game-build.md +80 -0
  126. package/docs/routes/mobile-always-landscape.md +149 -0
  127. package/docs/routes/mobile-web-fullscreen.md +255 -0
  128. package/docs/routes/model-from-dcc.md +106 -0
  129. package/docs/routes/new-game-project.md +100 -0
  130. package/docs/routes/onboarding-tutorial-2d.md +54 -0
  131. package/docs/routes/online-lockstep-match.md +473 -0
  132. package/docs/routes/outdoor-landscape.md +134 -0
  133. package/docs/routes/outfit-swap-3d.md +144 -0
  134. package/docs/routes/papercraft-diorama.md +186 -0
  135. package/docs/routes/platform-fighter-2d.md +235 -0
  136. package/docs/routes/platformer-2d.md +69 -0
  137. package/docs/routes/pole-rescue-arcade-3d.md +198 -0
  138. package/docs/routes/pose-atlas-motion.md +188 -0
  139. package/docs/routes/prototype-to-center.md +162 -0
  140. package/docs/routes/raft-brawl-3d-minigame.md +205 -0
  141. package/docs/routes/rhythm-2d.md +82 -0
  142. package/docs/routes/rigged-phone-character.md +120 -0
  143. package/docs/routes/screen-fit-game-box.md +127 -0
  144. package/docs/routes/shared-islands.md +195 -0
  145. package/docs/routes/side-view-duel.md +266 -0
  146. package/docs/routes/single-html-page.md +83 -0
  147. package/docs/routes/smooth-character-motion.md +162 -0
  148. package/docs/routes/spine-character.md +175 -0
  149. package/docs/routes/story-counting-2d.md +219 -0
  150. package/docs/routes/survivors-2d.md +60 -0
  151. package/docs/routes/third-person-town-3d.md +240 -0
  152. package/docs/routes/tower-defence-3d.md +67 -0
  153. package/docs/routes/ui-test-by-probe.md +219 -0
  154. package/docs/routes/underwater.md +138 -0
  155. package/docs/routes/visual-content-prefab.md +101 -0
  156. package/docs/runtime-hardening.md +108 -0
  157. package/docs/shader-warm-up.md +125 -0
  158. package/docs/spring-bones.md +79 -0
  159. package/docs/stylized-shading.md +171 -0
  160. package/docs/terrain-shader.md +130 -0
  161. package/docs/vrm.md +128 -0
  162. package/docs/walking.md +97 -0
  163. package/docs/webgpu.md +225 -0
  164. package/docs/white-label-themes.md +212 -0
  165. package/docs/zh-CN/README.md +130 -0
  166. package/examples/browser-sdk/2d-webgpu.html +46 -0
  167. package/examples/browser-sdk/2d.html +46 -0
  168. package/examples/browser-sdk/3d-gltf-webgpu.html +50 -0
  169. package/examples/browser-sdk/3d-gltf.html +50 -0
  170. package/examples/browser-sdk/3d-webgpu.html +46 -0
  171. package/examples/browser-sdk/3d.html +46 -0
  172. package/examples/cinematic-capture/Main.ts +294 -0
  173. package/examples/cinematic-capture/README.md +27 -0
  174. package/examples/model-inspector/README.md +15 -0
  175. package/examples/model-inspector/asset.gltf +158 -0
  176. package/examples/windows-webgpu/README.md +57 -0
  177. package/examples/windows-webgpu/bundle.mjs +122 -0
  178. package/examples/windows-webgpu/main.mjs +302 -0
  179. package/examples/windows-webgpu/package-lock.json +2353 -0
  180. package/examples/windows-webgpu/package.json +40 -0
  181. package/examples/windows-webgpu/squirrel.mjs +66 -0
  182. package/package.json +259 -4
  183. package/packages/ci-gate/export-film.mjs +347 -0
  184. package/packages/ci-gate/verify-sequence.mjs +285 -0
  185. package/packages/compiler/agent-contract.mjs +545 -0
  186. package/packages/compiler/ast-scanner.mjs +254 -0
  187. package/packages/compiler/backend-loader.mjs +62 -0
  188. package/packages/compiler/branding-assets.mjs +32 -0
  189. package/packages/compiler/branding.mjs +324 -0
  190. package/packages/compiler/browser-auto-example.mjs +31 -0
  191. package/packages/compiler/browser-model-example.mjs +53 -0
  192. package/packages/compiler/browser-process.mjs +344 -0
  193. package/packages/compiler/browser-sdk-example.mjs +50 -0
  194. package/packages/compiler/browser-sdk.mjs +342 -0
  195. package/packages/compiler/chrome-host.mjs +196 -0
  196. package/packages/compiler/cli.mjs +22 -0
  197. package/packages/compiler/compiler-runtime.mjs +41 -0
  198. package/packages/compiler/consumer-accept.mjs +89 -0
  199. package/packages/compiler/consumer-build.mjs +641 -0
  200. package/packages/compiler/consumer-guards.mjs +422 -0
  201. package/packages/compiler/consumer-publication.mjs +56 -0
  202. package/packages/compiler/consumer-scripts.mjs +134 -0
  203. package/packages/compiler/consumer-starter-2d.mjs +54 -0
  204. package/packages/compiler/consumer-starter-minigame.mjs +30 -0
  205. package/packages/compiler/editor-http.mjs +210 -0
  206. package/packages/compiler/editor-request.ts +12 -0
  207. package/packages/compiler/film-host-client.ts +249 -0
  208. package/packages/compiler/flythrough-file.mjs +144 -0
  209. package/packages/compiler/json-locate.mjs +85 -0
  210. package/packages/compiler/layout-contract.mjs +472 -0
  211. package/packages/compiler/minigame-bootstrap.mjs +24 -0
  212. package/packages/compiler/minigame-bridge.mjs +66 -0
  213. package/packages/compiler/minigame-guards.mjs +107 -0
  214. package/packages/compiler/minigame-toolchain.mjs +241 -0
  215. package/packages/compiler/model-crown.mjs +173 -0
  216. package/packages/compiler/model-editor-client.ts +809 -0
  217. package/packages/compiler/model-editor.mjs +242 -0
  218. package/packages/compiler/model-lod.mjs +547 -0
  219. package/packages/compiler/prefab-check.mjs +288 -0
  220. package/packages/compiler/prefab-checks.mjs +74 -0
  221. package/packages/compiler/prefab-dependencies.mjs +102 -0
  222. package/packages/compiler/prefab-editor-client.ts +950 -0
  223. package/packages/compiler/prefab-editor-preview.ts +89 -0
  224. package/packages/compiler/prefab-editor-server.mjs +585 -0
  225. package/packages/compiler/prefab-editor.mjs +43 -0
  226. package/packages/compiler/prefab-environment.mjs +107 -0
  227. package/packages/compiler/prefab-lifecycle.mjs +60 -0
  228. package/packages/compiler/prefab-preview.mjs +159 -0
  229. package/packages/compiler/prefab-watch.mjs +459 -0
  230. package/packages/compiler/runtime3d-types.mjs +91 -0
  231. package/packages/compiler/stage-probe.mjs +557 -0
  232. package/packages/compiler/visual-asset-audit.mjs +609 -0
  233. package/packages/compiler/visual-contract-audit.mjs +173 -0
  234. package/packages/compiler/webgpu-loader.mjs +153 -0
  235. package/packages/compiler/zhuda-build.mjs +714 -0
  236. package/packages/compiler/zhuda-doctor.mjs +186 -0
  237. package/packages/compiler/zhuda-init.mjs +353 -0
  238. package/packages/compiler/zhuda-layout.mjs +163 -0
  239. package/packages/compiler/zhuda-minigame.mjs +636 -0
  240. package/packages/core/BenchmarkEngine.ts +2 -0
  241. package/packages/core/BitmapFontContract.ts +159 -0
  242. package/packages/core/DeclarativeSDK.ts +686 -0
  243. package/packages/core/IframeSoundAdapter.ts +1824 -0
  244. package/packages/core/NoSleepAdapter.ts +302 -0
  245. package/packages/core/PixelCalibrationEngine.ts +602 -0
  246. package/packages/core/Prefab.ts +314 -0
  247. package/packages/core/RealmGuards.ts +111 -0
  248. package/packages/core/ResponsiveLayout.ts +149 -0
  249. package/packages/core/RuntimeGuards.ts +261 -0
  250. package/packages/core/SpineCharacter.ts +243 -0
  251. package/packages/core/SpineVisualContract.ts +238 -0
  252. package/packages/core/SplashSignal.ts +72 -0
  253. package/packages/core/StaticAssetPipeline.ts +3 -0
  254. package/packages/core/TopologyGraph.ts +693 -0
  255. package/packages/core/UnityBridgePipeline.ts +2 -0
  256. package/packages/core/VideoSurface.ts +75 -0
  257. package/packages/core/ViewportMatrixEngine.ts +237 -0
  258. package/packages/core/VisualFocusContract.ts +76 -0
  259. package/packages/core/VisualMigrationPipeline.ts +245 -0
  260. package/packages/core/WebViewSurface.ts +116 -0
  261. package/packages/core/audio/OfflineMix.ts +186 -0
  262. package/packages/core/audio/Spatial.ts +312 -0
  263. package/packages/core/audio/StreamVoice.ts +161 -0
  264. package/packages/core/csg/Bsp.ts +310 -0
  265. package/packages/core/csg/index.ts +589 -0
  266. package/packages/core/effects/Effect2D.ts +286 -0
  267. package/packages/core/effects/Effect3D.ts +213 -0
  268. package/packages/core/effects/EffectBudget.ts +695 -0
  269. package/packages/core/effects/EffectDirector.ts +254 -0
  270. package/packages/core/effects/EffectPresets.ts +843 -0
  271. package/packages/core/effects/EffectPresets2D.ts +1011 -0
  272. package/packages/core/effects/EffectSprites.ts +143 -0
  273. package/packages/core/effects/ParticleEventLink.ts +53 -0
  274. package/packages/core/effects/README.md +108 -0
  275. package/packages/core/effects/VfxMaterial.ts +253 -0
  276. package/packages/core/film/BakeKey.ts +21 -0
  277. package/packages/core/film/ColorValues.ts +44 -0
  278. package/packages/core/film/FilmLint.ts +353 -0
  279. package/packages/core/film/FilmPrefab.ts +82 -0
  280. package/packages/core/film/FilmReview.ts +84 -0
  281. package/packages/core/film/FilmScene.ts +3442 -0
  282. package/packages/core/film/FilmStage.ts +2148 -0
  283. package/packages/core/film/Flythrough.ts +169 -0
  284. package/packages/core/film/FlythroughReport.ts +326 -0
  285. package/packages/core/film/FrameMetrics.ts +167 -0
  286. package/packages/core/film/LiveLook.ts +242 -0
  287. package/packages/core/film/LookQuality.ts +94 -0
  288. package/packages/core/film/Projection.ts +74 -0
  289. package/packages/core/film/SceneLook.ts +363 -0
  290. package/packages/core/film/index.ts +12 -0
  291. package/packages/core/index.ts +48 -0
  292. package/packages/core/particles/EffectEnvelope.ts +52 -0
  293. package/packages/core/particles/LayaParticleRenderer.ts +182 -0
  294. package/packages/core/particles/LayaParticleRenderer3D.ts +218 -0
  295. package/packages/core/particles/ParticleExtras.ts +163 -0
  296. package/packages/core/particles/ParticleMesh3D.ts +156 -0
  297. package/packages/core/particles/ParticleSystem.ts +324 -0
  298. package/packages/core/particles/ParticleSystem3D.ts +411 -0
  299. package/packages/core/particles/ParticleTypes.ts +230 -0
  300. package/packages/core/particles/ParticleTypes3D.ts +115 -0
  301. package/packages/core/particles/README.md +181 -0
  302. package/packages/core/particles/RibbonPath3D.ts +234 -0
  303. package/packages/core/particles/RibbonTrail.ts +145 -0
  304. package/packages/core/particles/RibbonTrail3D.ts +166 -0
  305. package/packages/core/particles/index.ts +12 -0
  306. package/packages/core/prefabs/PrefabLibrary.ts +692 -0
  307. package/packages/core/prefabs/PrefabTree3D.ts +291 -0
  308. package/packages/core/prefabs/index.ts +10 -0
  309. package/packages/core/procedural/Geometry.ts +1871 -0
  310. package/packages/core/procedural/Hand.ts +1510 -0
  311. package/packages/core/procedural/Isosurface.ts +1035 -0
  312. package/packages/core/procedural/ModuleHarness.ts +180 -0
  313. package/packages/core/procedural/Noise.ts +123 -0
  314. package/packages/core/procedural/PhotoMaterial.ts +283 -0
  315. package/packages/core/procedural/ProceduralAssetProvider.ts +105 -0
  316. package/packages/core/procedural/ProceduralMaterial.ts +184 -0
  317. package/packages/core/procedural/PropFactory.ts +307 -0
  318. package/packages/core/procedural/Random.ts +70 -0
  319. package/packages/core/procedural/SynthAudio.ts +221 -0
  320. package/packages/core/procedural/TerrainMesh.ts +207 -0
  321. package/packages/core/procedural/TextureRecipe.ts +464 -0
  322. package/packages/core/procedural/TriplanarMaterial.ts +169 -0
  323. package/packages/core/procedural/Variation.ts +94 -0
  324. package/packages/core/procedural/index.ts +15 -0
  325. package/packages/core/runtime3d/ActionFrames.ts +245 -0
  326. package/packages/core/runtime3d/AnimationBlend.ts +282 -0
  327. package/packages/core/runtime3d/AnimationBlendMath.ts +98 -0
  328. package/packages/core/runtime3d/AssetProvider.ts +775 -0
  329. package/packages/core/runtime3d/AssetShowcase.ts +190 -0
  330. package/packages/core/runtime3d/Assets.ts +801 -0
  331. package/packages/core/runtime3d/AsyncDeadline.ts +53 -0
  332. package/packages/core/runtime3d/AsyncOperation.ts +39 -0
  333. package/packages/core/runtime3d/BackendChoice.ts +359 -0
  334. package/packages/core/runtime3d/BakedCrowd.ts +575 -0
  335. package/packages/core/runtime3d/BasisTexture.ts +657 -0
  336. package/packages/core/runtime3d/CameraCollision.ts +69 -0
  337. package/packages/core/runtime3d/CameraEffects.ts +752 -0
  338. package/packages/core/runtime3d/CameraRig.ts +70 -0
  339. package/packages/core/runtime3d/CharacterController.ts +272 -0
  340. package/packages/core/runtime3d/CinematicCapture.ts +457 -0
  341. package/packages/core/runtime3d/Clocks.ts +724 -0
  342. package/packages/core/runtime3d/Cloth.ts +183 -0
  343. package/packages/core/runtime3d/Clouds.ts +462 -0
  344. package/packages/core/runtime3d/ColorLut.ts +351 -0
  345. package/packages/core/runtime3d/CombatQueries.ts +240 -0
  346. package/packages/core/runtime3d/ComputePass.ts +582 -0
  347. package/packages/core/runtime3d/CrowdPresentation.ts +368 -0
  348. package/packages/core/runtime3d/DebugDraw.ts +567 -0
  349. package/packages/core/runtime3d/DebugStats.ts +35 -0
  350. package/packages/core/runtime3d/Decals.ts +309 -0
  351. package/packages/core/runtime3d/DensityVolume.ts +238 -0
  352. package/packages/core/runtime3d/DistanceBricks.ts +349 -0
  353. package/packages/core/runtime3d/Dither.ts +199 -0
  354. package/packages/core/runtime3d/DrawWarmUp.ts +217 -0
  355. package/packages/core/runtime3d/EdgeSmoothing.ts +108 -0
  356. package/packages/core/runtime3d/EnvironmentProbe.ts +656 -0
  357. package/packages/core/runtime3d/Filmic.ts +973 -0
  358. package/packages/core/runtime3d/Foliage.ts +367 -0
  359. package/packages/core/runtime3d/GltfIntake.ts +914 -0
  360. package/packages/core/runtime3d/GltfSecondUv.ts +153 -0
  361. package/packages/core/runtime3d/GraphicsGuard.ts +171 -0
  362. package/packages/core/runtime3d/Grass.ts +1080 -0
  363. package/packages/core/runtime3d/GroundTruthAO.ts +360 -0
  364. package/packages/core/runtime3d/HalfFloat.ts +44 -0
  365. package/packages/core/runtime3d/HdrEnvironment.ts +588 -0
  366. package/packages/core/runtime3d/Ik.ts +392 -0
  367. package/packages/core/runtime3d/InputBuffer.ts +165 -0
  368. package/packages/core/runtime3d/InstancedMesh.ts +460 -0
  369. package/packages/core/runtime3d/Laya342Adapters.ts +1095 -0
  370. package/packages/core/runtime3d/Laya342GltfAdapter.ts +751 -0
  371. package/packages/core/runtime3d/LensFinish.ts +153 -0
  372. package/packages/core/runtime3d/LensFlare.ts +490 -0
  373. package/packages/core/runtime3d/LightFog.ts +1008 -0
  374. package/packages/core/runtime3d/LightingDepth.ts +544 -0
  375. package/packages/core/runtime3d/Lightmap.ts +238 -0
  376. package/packages/core/runtime3d/Math3D.ts +84 -0
  377. package/packages/core/runtime3d/MeshQuery.ts +547 -0
  378. package/packages/core/runtime3d/MeshoptModelDecoder.ts +354 -0
  379. package/packages/core/runtime3d/MiniGameSplash.ts +70 -0
  380. package/packages/core/runtime3d/ModelAnimationSampler.ts +97 -0
  381. package/packages/core/runtime3d/ModelCompatibility.ts +890 -0
  382. package/packages/core/runtime3d/ModelDecoder.ts +294 -0
  383. package/packages/core/runtime3d/ModelInspector.ts +226 -0
  384. package/packages/core/runtime3d/ModelLod.ts +163 -0
  385. package/packages/core/runtime3d/ModelPlacements.ts +426 -0
  386. package/packages/core/runtime3d/ObjectMotion.ts +217 -0
  387. package/packages/core/runtime3d/PhysicalCamera.ts +190 -0
  388. package/packages/core/runtime3d/PointShadow.ts +500 -0
  389. package/packages/core/runtime3d/PointShadowSchedule.ts +201 -0
  390. package/packages/core/runtime3d/Pool.ts +120 -0
  391. package/packages/core/runtime3d/ProbeVolume.ts +695 -0
  392. package/packages/core/runtime3d/QualityGovernor.ts +385 -0
  393. package/packages/core/runtime3d/QualityMemory.ts +200 -0
  394. package/packages/core/runtime3d/RenderScale.ts +356 -0
  395. package/packages/core/runtime3d/RenderSpaces.ts +105 -0
  396. package/packages/core/runtime3d/Renderer.ts +377 -0
  397. package/packages/core/runtime3d/ResultPlayback.ts +239 -0
  398. package/packages/core/runtime3d/Runtime.ts +507 -0
  399. package/packages/core/runtime3d/RuntimeDriver.ts +127 -0
  400. package/packages/core/runtime3d/SceneLifecycle.ts +211 -0
  401. package/packages/core/runtime3d/SceneMutation.ts +107 -0
  402. package/packages/core/runtime3d/SceneQueries.ts +191 -0
  403. package/packages/core/runtime3d/ScreenReflections.ts +595 -0
  404. package/packages/core/runtime3d/SelectionOutline.ts +389 -0
  405. package/packages/core/runtime3d/ShaderErrors.ts +104 -0
  406. package/packages/core/runtime3d/ShaderRegistry.ts +34 -0
  407. package/packages/core/runtime3d/ShaderWarmUp.ts +473 -0
  408. package/packages/core/runtime3d/ShadowUpdates.ts +287 -0
  409. package/packages/core/runtime3d/SkinBinding.ts +235 -0
  410. package/packages/core/runtime3d/Smaa.ts +386 -0
  411. package/packages/core/runtime3d/SmaaTables.ts +244 -0
  412. package/packages/core/runtime3d/SpringBones.ts +184 -0
  413. package/packages/core/runtime3d/SurfaceBuffer.ts +76 -0
  414. package/packages/core/runtime3d/Surfaces.ts +1105 -0
  415. package/packages/core/runtime3d/Themes.ts +344 -0
  416. package/packages/core/runtime3d/Timeline.ts +362 -0
  417. package/packages/core/runtime3d/ToneCurves.ts +292 -0
  418. package/packages/core/runtime3d/TransformGizmo.ts +539 -0
  419. package/packages/core/runtime3d/TriangleMask.ts +250 -0
  420. package/packages/core/runtime3d/Underwater.ts +778 -0
  421. package/packages/core/runtime3d/Utf8.ts +87 -0
  422. package/packages/core/runtime3d/Vrm.ts +773 -0
  423. package/packages/core/runtime3d/VrmDocument.ts +1830 -0
  424. package/packages/core/runtime3d/WalkGrid.ts +471 -0
  425. package/packages/core/runtime3d/WebGPU342Adapters.ts +280 -0
  426. package/packages/core/runtime3d/index.ts +147 -0
  427. package/packages/core/shaders/Laya342ShaderTemplates.ts +6 -0
  428. package/packages/core/shaders/LitSurfaceMaterial.ts +1076 -0
  429. package/packages/core/shaders/LitSurfaceTemplates.ts +13 -0
  430. package/packages/core/shaders/ReflectiveSurface.ts +285 -0
  431. package/packages/core/shaders/ShaderMaterials.ts +387 -0
  432. package/packages/core/shaders/ToonMaterial.ts +559 -0
  433. package/packages/core/shaders/WaterRipples.ts +170 -0
  434. package/packages/core/shaders/WaterSurface.ts +480 -0
  435. package/packages/core/shaders/ZhudaCommon.ts +109 -0
  436. package/packages/core/shaders/index.ts +6 -0
  437. package/packages/core/simulation/Cloth.ts +1541 -0
  438. package/packages/core/simulation/ParticleCore.ts +498 -0
  439. package/packages/core/simulation/SpringBones.ts +553 -0
  440. package/packages/core/simulation/index.ts +3 -0
  441. package/packages/core/terrain/Heightfield.ts +385 -0
  442. package/packages/core/terrain/Terrain2D.ts +324 -0
  443. package/packages/core/terrain/Terrain3D.ts +452 -0
  444. package/packages/core/terrain/TerrainShell.ts +94 -0
  445. package/packages/core/terrain/index.ts +3 -0
  446. package/packages/demo/BenchmarkEngine.ts +184 -0
  447. package/packages/demo/PixelCalibrationEngine.ts +36 -0
  448. package/packages/demo/ProceduralStarter.ts +312 -0
  449. package/packages/demo/StaticAssetPipeline.ts +1631 -0
  450. package/packages/demo/UnityBridgePipeline.ts +485 -0
  451. package/packages/demo/index.ts +6 -0
  452. package/packages/mcp-server/arguments.mjs +81 -0
  453. package/packages/mcp-server/corpus.mjs +627 -0
  454. package/packages/mcp-server/film-host.mjs +627 -0
  455. package/packages/mcp-server/film-session.mjs +95 -0
  456. package/packages/mcp-server/film-tools.mjs +460 -0
  457. package/packages/mcp-server/index.mjs +931 -0
  458. package/packages/mcp-server/quality-route.mjs +332 -0
  459. package/packages/mcp-server/roots.mjs +72 -0
  460. package/packages/mcp-server/runtime.mjs +81 -0
  461. package/packages/types/BitmapFontContract.d.ts +19 -0
  462. package/packages/types/DeclarativeSDK.d.ts +137 -0
  463. package/packages/types/IframeSoundAdapter.d.ts +173 -0
  464. package/packages/types/NoSleepAdapter.d.ts +50 -0
  465. package/packages/types/PixelCalibrationEngine.d.ts +83 -0
  466. package/packages/types/Prefab.d.ts +11 -0
  467. package/packages/types/RealmGuards.d.ts +26 -0
  468. package/packages/types/ResponsiveLayout.d.ts +10 -0
  469. package/packages/types/RuntimeGuards.d.ts +55 -0
  470. package/packages/types/SpineCharacter.d.ts +94 -0
  471. package/packages/types/SpineVisualContract.d.ts +50 -0
  472. package/packages/types/SplashSignal.d.ts +27 -0
  473. package/packages/types/TopologyGraph.d.ts +76 -0
  474. package/packages/types/VideoSurface.d.ts +21 -0
  475. package/packages/types/ViewportMatrixEngine.d.ts +27 -0
  476. package/packages/types/VisualFocusContract.d.ts +32 -0
  477. package/packages/types/VisualMigrationPipeline.d.ts +53 -0
  478. package/packages/types/WebViewSurface.d.ts +26 -0
  479. package/packages/types/audio/OfflineMix.d.ts +10 -0
  480. package/packages/types/audio/Spatial.d.ts +63 -0
  481. package/packages/types/audio/StreamVoice.d.ts +31 -0
  482. package/packages/types/browser.d.ts +44 -0
  483. package/packages/types/csg/Bsp.d.ts +85 -0
  484. package/packages/types/csg/index.d.ts +81 -0
  485. package/packages/types/demo/BenchmarkEngine.d.ts +61 -0
  486. package/packages/types/demo/PixelCalibrationEngine.d.ts +13 -0
  487. package/packages/types/demo/ProceduralStarter.d.ts +11 -0
  488. package/packages/types/demo/StaticAssetPipeline.d.ts +87 -0
  489. package/packages/types/demo/UnityBridgePipeline.d.ts +49 -0
  490. package/packages/types/demo/index.d.ts +7 -0
  491. package/packages/types/editor-preview.d.ts +27 -0
  492. package/packages/types/effects/Effect2D.d.ts +65 -0
  493. package/packages/types/effects/Effect3D.d.ts +42 -0
  494. package/packages/types/effects/EffectBudget.d.ts +179 -0
  495. package/packages/types/effects/EffectDirector.d.ts +68 -0
  496. package/packages/types/effects/EffectPresets.d.ts +27 -0
  497. package/packages/types/effects/EffectPresets2D.d.ts +32 -0
  498. package/packages/types/effects/EffectSprites.d.ts +23 -0
  499. package/packages/types/effects/ParticleEventLink.d.ts +16 -0
  500. package/packages/types/effects/VfxMaterial.d.ts +52 -0
  501. package/packages/types/film/BakeKey.d.ts +9 -0
  502. package/packages/types/film/ColorValues.d.ts +25 -0
  503. package/packages/types/film/FilmLint.d.ts +40 -0
  504. package/packages/types/film/FilmPrefab.d.ts +22 -0
  505. package/packages/types/film/FilmReview.d.ts +27 -0
  506. package/packages/types/film/FilmScene.d.ts +1214 -0
  507. package/packages/types/film/FilmStage.d.ts +237 -0
  508. package/packages/types/film/Flythrough.d.ts +44 -0
  509. package/packages/types/film/FlythroughReport.d.ts +132 -0
  510. package/packages/types/film/FrameMetrics.d.ts +49 -0
  511. package/packages/types/film/LiveLook.d.ts +60 -0
  512. package/packages/types/film/LookQuality.d.ts +24 -0
  513. package/packages/types/film/Projection.d.ts +20 -0
  514. package/packages/types/film/SceneLook.d.ts +122 -0
  515. package/packages/types/film/index.d.ts +13 -0
  516. package/packages/types/index.d.ts +49 -0
  517. package/packages/types/particles/EffectEnvelope.d.ts +18 -0
  518. package/packages/types/particles/LayaParticleRenderer.d.ts +30 -0
  519. package/packages/types/particles/LayaParticleRenderer3D.d.ts +29 -0
  520. package/packages/types/particles/ParticleExtras.d.ts +50 -0
  521. package/packages/types/particles/ParticleMesh3D.d.ts +24 -0
  522. package/packages/types/particles/ParticleSystem.d.ts +52 -0
  523. package/packages/types/particles/ParticleSystem3D.d.ts +69 -0
  524. package/packages/types/particles/ParticleTypes.d.ts +89 -0
  525. package/packages/types/particles/ParticleTypes3D.d.ts +56 -0
  526. package/packages/types/particles/RibbonPath3D.d.ts +32 -0
  527. package/packages/types/particles/RibbonTrail.d.ts +38 -0
  528. package/packages/types/particles/RibbonTrail3D.d.ts +22 -0
  529. package/packages/types/particles/index.d.ts +13 -0
  530. package/packages/types/prefabs/PrefabLibrary.d.ts +176 -0
  531. package/packages/types/prefabs/PrefabTree3D.d.ts +59 -0
  532. package/packages/types/prefabs/index.d.ts +4 -0
  533. package/packages/types/procedural/Geometry.d.ts +252 -0
  534. package/packages/types/procedural/Hand.d.ts +150 -0
  535. package/packages/types/procedural/Isosurface.d.ts +181 -0
  536. package/packages/types/procedural/ModuleHarness.d.ts +90 -0
  537. package/packages/types/procedural/Noise.d.ts +15 -0
  538. package/packages/types/procedural/PhotoMaterial.d.ts +49 -0
  539. package/packages/types/procedural/ProceduralAssetProvider.d.ts +31 -0
  540. package/packages/types/procedural/ProceduralMaterial.d.ts +63 -0
  541. package/packages/types/procedural/PropFactory.d.ts +94 -0
  542. package/packages/types/procedural/Random.d.ts +26 -0
  543. package/packages/types/procedural/SynthAudio.d.ts +49 -0
  544. package/packages/types/procedural/TerrainMesh.d.ts +55 -0
  545. package/packages/types/procedural/TextureRecipe.d.ts +125 -0
  546. package/packages/types/procedural/TriplanarMaterial.d.ts +27 -0
  547. package/packages/types/procedural/Variation.d.ts +23 -0
  548. package/packages/types/procedural/index.d.ts +16 -0
  549. package/packages/types/runtime3d/ActionFrames.d.ts +62 -0
  550. package/packages/types/runtime3d/AnimationBlend.d.ts +57 -0
  551. package/packages/types/runtime3d/AnimationBlendMath.d.ts +27 -0
  552. package/packages/types/runtime3d/AssetProvider.d.ts +167 -0
  553. package/packages/types/runtime3d/AssetShowcase.d.ts +44 -0
  554. package/packages/types/runtime3d/Assets.d.ts +166 -0
  555. package/packages/types/runtime3d/AsyncDeadline.d.ts +6 -0
  556. package/packages/types/runtime3d/AsyncOperation.d.ts +3 -0
  557. package/packages/types/runtime3d/BackendChoice.d.ts +130 -0
  558. package/packages/types/runtime3d/BakedCrowd.d.ts +156 -0
  559. package/packages/types/runtime3d/BasisTexture.d.ts +169 -0
  560. package/packages/types/runtime3d/CameraCollision.d.ts +20 -0
  561. package/packages/types/runtime3d/CameraEffects.d.ts +134 -0
  562. package/packages/types/runtime3d/CameraRig.d.ts +27 -0
  563. package/packages/types/runtime3d/CharacterController.d.ts +71 -0
  564. package/packages/types/runtime3d/CinematicCapture.d.ts +103 -0
  565. package/packages/types/runtime3d/Clocks.d.ts +200 -0
  566. package/packages/types/runtime3d/Cloth.d.ts +57 -0
  567. package/packages/types/runtime3d/Clouds.d.ts +69 -0
  568. package/packages/types/runtime3d/ColorLut.d.ts +73 -0
  569. package/packages/types/runtime3d/CombatQueries.d.ts +50 -0
  570. package/packages/types/runtime3d/ComputePass.d.ts +134 -0
  571. package/packages/types/runtime3d/CrowdPresentation.d.ts +104 -0
  572. package/packages/types/runtime3d/DebugDraw.d.ts +161 -0
  573. package/packages/types/runtime3d/DebugStats.d.ts +24 -0
  574. package/packages/types/runtime3d/Decals.d.ts +65 -0
  575. package/packages/types/runtime3d/DensityVolume.d.ts +39 -0
  576. package/packages/types/runtime3d/DistanceBricks.d.ts +97 -0
  577. package/packages/types/runtime3d/Dither.d.ts +78 -0
  578. package/packages/types/runtime3d/DrawWarmUp.d.ts +93 -0
  579. package/packages/types/runtime3d/EdgeSmoothing.d.ts +10 -0
  580. package/packages/types/runtime3d/EnvironmentProbe.d.ts +139 -0
  581. package/packages/types/runtime3d/Filmic.d.ts +243 -0
  582. package/packages/types/runtime3d/Foliage.d.ts +95 -0
  583. package/packages/types/runtime3d/GltfIntake.d.ts +236 -0
  584. package/packages/types/runtime3d/GltfSecondUv.d.ts +54 -0
  585. package/packages/types/runtime3d/GraphicsGuard.d.ts +18 -0
  586. package/packages/types/runtime3d/Grass.d.ts +226 -0
  587. package/packages/types/runtime3d/GroundTruthAO.d.ts +64 -0
  588. package/packages/types/runtime3d/HalfFloat.d.ts +13 -0
  589. package/packages/types/runtime3d/HdrEnvironment.d.ts +144 -0
  590. package/packages/types/runtime3d/Ik.d.ts +123 -0
  591. package/packages/types/runtime3d/InputBuffer.d.ts +49 -0
  592. package/packages/types/runtime3d/InstancedMesh.d.ts +116 -0
  593. package/packages/types/runtime3d/Laya342Adapters.d.ts +306 -0
  594. package/packages/types/runtime3d/Laya342GltfAdapter.d.ts +105 -0
  595. package/packages/types/runtime3d/LensFinish.d.ts +38 -0
  596. package/packages/types/runtime3d/LensFlare.d.ts +114 -0
  597. package/packages/types/runtime3d/LightFog.d.ts +190 -0
  598. package/packages/types/runtime3d/LightingDepth.d.ts +128 -0
  599. package/packages/types/runtime3d/Lightmap.d.ts +55 -0
  600. package/packages/types/runtime3d/Math3D.d.ts +19 -0
  601. package/packages/types/runtime3d/MeshQuery.d.ts +107 -0
  602. package/packages/types/runtime3d/MeshoptModelDecoder.d.ts +34 -0
  603. package/packages/types/runtime3d/MiniGameSplash.d.ts +4 -0
  604. package/packages/types/runtime3d/ModelAnimationSampler.d.ts +26 -0
  605. package/packages/types/runtime3d/ModelCompatibility.d.ts +169 -0
  606. package/packages/types/runtime3d/ModelDecoder.d.ts +66 -0
  607. package/packages/types/runtime3d/ModelInspector.d.ts +77 -0
  608. package/packages/types/runtime3d/ModelLod.d.ts +61 -0
  609. package/packages/types/runtime3d/ModelPlacements.d.ts +77 -0
  610. package/packages/types/runtime3d/ObjectMotion.d.ts +43 -0
  611. package/packages/types/runtime3d/PhysicalCamera.d.ts +51 -0
  612. package/packages/types/runtime3d/PointShadow.d.ts +71 -0
  613. package/packages/types/runtime3d/PointShadowSchedule.d.ts +74 -0
  614. package/packages/types/runtime3d/Pool.d.ts +33 -0
  615. package/packages/types/runtime3d/ProbeVolume.d.ts +123 -0
  616. package/packages/types/runtime3d/QualityGovernor.d.ts +201 -0
  617. package/packages/types/runtime3d/QualityMemory.d.ts +83 -0
  618. package/packages/types/runtime3d/RenderScale.d.ts +69 -0
  619. package/packages/types/runtime3d/RenderSpaces.d.ts +44 -0
  620. package/packages/types/runtime3d/Renderer.d.ts +62 -0
  621. package/packages/types/runtime3d/ResultPlayback.d.ts +70 -0
  622. package/packages/types/runtime3d/Runtime.d.ts +136 -0
  623. package/packages/types/runtime3d/RuntimeDriver.d.ts +42 -0
  624. package/packages/types/runtime3d/SceneLifecycle.d.ts +84 -0
  625. package/packages/types/runtime3d/SceneMutation.d.ts +34 -0
  626. package/packages/types/runtime3d/SceneQueries.d.ts +71 -0
  627. package/packages/types/runtime3d/ScreenReflections.d.ts +78 -0
  628. package/packages/types/runtime3d/SelectionOutline.d.ts +68 -0
  629. package/packages/types/runtime3d/ShaderErrors.d.ts +27 -0
  630. package/packages/types/runtime3d/ShaderRegistry.d.ts +10 -0
  631. package/packages/types/runtime3d/ShaderWarmUp.d.ts +162 -0
  632. package/packages/types/runtime3d/ShadowUpdates.d.ts +125 -0
  633. package/packages/types/runtime3d/SkinBinding.d.ts +53 -0
  634. package/packages/types/runtime3d/Smaa.d.ts +60 -0
  635. package/packages/types/runtime3d/SmaaTables.d.ts +12 -0
  636. package/packages/types/runtime3d/SpringBones.d.ts +69 -0
  637. package/packages/types/runtime3d/SurfaceBuffer.d.ts +28 -0
  638. package/packages/types/runtime3d/Surfaces.d.ts +326 -0
  639. package/packages/types/runtime3d/Themes.d.ts +70 -0
  640. package/packages/types/runtime3d/Timeline.d.ts +88 -0
  641. package/packages/types/runtime3d/ToneCurves.d.ts +59 -0
  642. package/packages/types/runtime3d/TransformGizmo.d.ts +139 -0
  643. package/packages/types/runtime3d/TriangleMask.d.ts +84 -0
  644. package/packages/types/runtime3d/Underwater.d.ts +120 -0
  645. package/packages/types/runtime3d/Utf8.d.ts +12 -0
  646. package/packages/types/runtime3d/Vrm.d.ts +120 -0
  647. package/packages/types/runtime3d/VrmDocument.d.ts +381 -0
  648. package/packages/types/runtime3d/WalkGrid.d.ts +94 -0
  649. package/packages/types/runtime3d/WebGPU342Adapters.d.ts +27 -0
  650. package/packages/types/runtime3d/index.d.ts +102 -0
  651. package/packages/types/shaders/Laya342ShaderTemplates.d.ts +3 -0
  652. package/packages/types/shaders/LitSurfaceMaterial.d.ts +257 -0
  653. package/packages/types/shaders/LitSurfaceTemplates.d.ts +7 -0
  654. package/packages/types/shaders/ReflectiveSurface.d.ts +58 -0
  655. package/packages/types/shaders/ShaderMaterials.d.ts +60 -0
  656. package/packages/types/shaders/ToonMaterial.d.ts +176 -0
  657. package/packages/types/shaders/WaterRipples.d.ts +48 -0
  658. package/packages/types/shaders/WaterSurface.d.ts +110 -0
  659. package/packages/types/shaders/ZhudaCommon.d.ts +31 -0
  660. package/packages/types/shaders/index.d.ts +7 -0
  661. package/packages/types/simulation/Cloth.d.ts +381 -0
  662. package/packages/types/simulation/ParticleCore.d.ts +125 -0
  663. package/packages/types/simulation/SpringBones.d.ts +107 -0
  664. package/packages/types/simulation/index.d.ts +4 -0
  665. package/packages/types/terrain/Heightfield.d.ts +67 -0
  666. package/packages/types/terrain/Terrain2D.d.ts +81 -0
  667. package/packages/types/terrain/Terrain3D.d.ts +80 -0
  668. package/packages/types/terrain/TerrainShell.d.ts +8 -0
  669. package/packages/types/terrain/index.d.ts +4 -0
  670. package/packages/types/vendor/LayaAir.runtime.d.ts +97440 -0
  671. package/packages/types/vendor/REPAIRS.md +30 -0
  672. package/packages/types/vendor/restored-3.4.2.json +142 -0
  673. package/packages/types/vendor/spine.runtime.d.ts +1507 -0
  674. package/packages/types/vendor/wechat-media.d.ts +877 -0
  675. package/packages/types/zhuda-2d-ui.d.ts +244 -0
  676. package/packages/types/zhuda-3d-physics.d.ts +34 -0
  677. package/packages/types/zhuda-audio.d.ts +128 -0
  678. package/packages/types/zhuda-bootstrap.d.ts +100 -0
  679. package/packages/types/zhuda-branding.d.ts +6 -0
  680. package/packages/types/zhuda-core.d.ts +46 -0
  681. package/packages/types/zhuda-declarative.d.ts +81 -0
  682. package/packages/types/zhuda-effects.d.ts +302 -0
  683. package/packages/types/zhuda-layout.d.ts +96 -0
  684. package/packages/types/zhuda-particles.d.ts +477 -0
  685. package/packages/types/zhuda-spine42.d.ts +23 -0
  686. package/packages/types/zhuda-static-assets.d.ts +389 -0
  687. package/packages/types/zhuda-video.d.ts +24 -0
  688. package/packages/types/zhuda-visual-contract.d.ts +52 -0
  689. package/packages/types/zhuda-webview.d.ts +43 -0
  690. package/vendor/basis/LICENSE.txt +55 -0
  691. package/vendor/basis/README.md +25 -0
  692. package/vendor/basis/basis_transcoder.js +19 -0
  693. package/vendor/basis/basis_transcoder.wasm +0 -0
  694. package/vendor/laya-3.4.2/WEBGPU-LICENSES.txt +1259 -0
  695. package/vendor/laya-3.4.2/libs/laya.ani.js +1 -0
  696. package/vendor/laya-3.4.2/libs/laya.box2D.js +1209 -0
  697. package/vendor/laya-3.4.2/libs/laya.bridge.js +2273 -0
  698. package/vendor/laya-3.4.2/libs/laya.bullet.js +1 -0
  699. package/vendor/laya-3.4.2/libs/laya.core.js +1 -0
  700. package/vendor/laya-3.4.2/libs/laya.d3.js +1 -0
  701. package/vendor/laya-3.4.2/libs/laya.device.js +1 -0
  702. package/vendor/laya-3.4.2/libs/laya.gltf.js +1 -0
  703. package/vendor/laya-3.4.2/libs/laya.ik.js +1 -0
  704. package/vendor/laya-3.4.2/libs/laya.light2D.js +1 -0
  705. package/vendor/laya-3.4.2/libs/laya.line2D.js +1 -0
  706. package/vendor/laya-3.4.2/libs/laya.native-spine42.js +7672 -0
  707. package/vendor/laya-3.4.2/libs/laya.navMesh2d.js +1 -0
  708. package/vendor/laya-3.4.2/libs/laya.navMesh3d.js +1 -0
  709. package/vendor/laya-3.4.2/libs/laya.navMeshCommon.js +1 -0
  710. package/vendor/laya-3.4.2/libs/laya.particle.js +1 -0
  711. package/vendor/laya-3.4.2/libs/laya.particle3D.js +1 -0
  712. package/vendor/laya-3.4.2/libs/laya.particleCommon.js +1 -0
  713. package/vendor/laya-3.4.2/libs/laya.physics2D.js +3774 -0
  714. package/vendor/laya-3.4.2/libs/laya.physics3D.js +1 -0
  715. package/vendor/laya-3.4.2/libs/laya.postProcess.js +1 -0
  716. package/vendor/laya-3.4.2/libs/laya.spine.js +1 -0
  717. package/vendor/laya-3.4.2/libs/laya.spine3D.js +1 -0
  718. package/vendor/laya-3.4.2/libs/laya.tilemap.js +1 -0
  719. package/vendor/laya-3.4.2/libs/laya.trail2D.js +1 -0
  720. package/vendor/laya-3.4.2/libs/laya.trail3D.js +1 -0
  721. package/vendor/laya-3.4.2/libs/laya.trailCommon.js +1 -0
  722. package/vendor/laya-3.4.2/libs/laya.ui.js +1 -0
  723. package/vendor/laya-3.4.2/libs/laya.ui2.js +9904 -0
  724. package/vendor/laya-3.4.2/libs/laya.vfx.js +6754 -0
  725. package/vendor/laya-3.4.2/libs/laya.webgl_2D.js +1 -0
  726. package/vendor/laya-3.4.2/libs/laya.webgl_3D.js +1 -0
  727. package/vendor/laya-3.4.2/libs/laya.webgpu_2D.js +18576 -0
  728. package/vendor/laya-3.4.2/libs/laya.webgpu_3D.js +6729 -0
  729. package/vendor/laya-3.4.2/libs/nagabind.js +395 -0
  730. package/vendor/laya-3.4.2/libs/nagabind_bg.wasm +0 -0
  731. package/vendor/laya-3.4.2/libs/shader_compiler_web.js +22 -0
  732. package/vendor/laya-3.4.2/libs/shader_compiler_web.wasm +0 -0
  733. package/vendor/laya-3.4.2/libs/spine-core-3.8.js +1 -0
  734. package/vendor/laya-3.4.2/libs/spine-core-4.2.js +10216 -0
  735. package/vendor/laya-3.4.2/webgpu-provenance.json +41 -0
  736. package/vendor/meshoptimizer/LICENSE.txt +21 -0
  737. package/vendor/meshoptimizer/README.md +13 -0
  738. package/vendor/threejs-post/LICENSE.txt +53 -0
  739. package/vendor/threejs-post/README.md +54 -0
  740. package/zhuda.config.json +22 -0
@@ -0,0 +1 @@
1
+ window.Laya=function(e){"use strict";class t{}t.isAntialias=!0,t.useWebGL2=!0,t.useSPRIV=!1,t.matUseUBO=!0,t.enableUniformBufferObject=!0,t.FPS=60,t.useRetinalCanvas=!1,t.animationInterval=50,t.webGL2D_MeshAllocMaxMem=!0,t.useGraphics2DIndexUInt32=!0,t.isSpriteRenderTextureAntialias=!1,t.defaultFontSize=12,t.defaultFont="Arial",t.isAlpha=!1,t.isDepth=!1,t.isfailIfMajorPerformanceCaveat=!1,t.powerPreference="default",t.premultipliedAlpha=!0,t.isStencil=!0,t.preserveDrawingBuffer=!1,t.printWebglOrder=!1,t.fontFamilyMap={"报隶":"报隶-简","黑体":"黑体-简","楷体":"楷体-简","兰亭黑":"兰亭黑-简","隶变":"隶变-简","凌慧体":"凌慧体-简","翩翩体":"翩翩体-简","苹方":"苹方-简","手札体":"手札体-简","宋体":"宋体-简","娃娃体":"娃娃体-简","魏碑":"魏碑-简","行楷":"行楷-简","雅痞":"雅痞-简","圆体":"圆体-简"},t.fixedFrames=!0,t.destroyResourceImmediatelyDefault=!0,t.audioBufferCacheMaxSize=5242880,t.uvClipMode="cpu",t.useTextureArray=!1;const r={};class s{static isZero(e){return Math.abs(e)<s.zeroTolerance}static nearEqual(e,t){return s.isZero(e-t)}static fastInvSqrt(e){return s.isZero(e)?e:1/Math.sqrt(e)}}s.zeroTolerance=1e-6,s.MaxValue=340282347e30,s.MinValue=-340282347e30,s.Deg2Rad=Math.PI/180;class i{constructor(e=0,t=0,r=0,s=0){this.x=e,this.y=t,this.z=r,this.w=s}setValue(e,t,r,s){return this.x=e,this.y=t,this.z=r,this.w=s,this}fromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(){return[this.x,this.y,this.z,this.w]}writeTo(e,t=0){return e[t+0]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this}cloneTo(e){return e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w,e}clone(){var e=new i;return this.cloneTo(e),e}static lerp(e,t,r,s){var i=e.x,a=e.y,n=e.z,o=e.w;s.x=i+r*(t.x-i),s.y=a+r*(t.y-a),s.z=n+r*(t.z-n),s.w=o+r*(t.w-o)}static transformByM4x4(e,t,r){var s=e.x,i=e.y,a=e.z,n=e.w,o=t.elements;r.x=s*o[0]+i*o[4]+a*o[8]+n*o[12],r.y=s*o[1]+i*o[5]+a*o[9]+n*o[13],r.z=s*o[2]+i*o[6]+a*o[10]+n*o[14],r.w=s*o[3]+i*o[7]+a*o[11]+n*o[15]}static equals(e,t){return s.nearEqual(e.x,t.x)&&s.nearEqual(e.y,t.y)&&s.nearEqual(e.z,t.z)&&s.nearEqual(e.w,t.w)}equal(e){return i.equals(this,e)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static normalize(e,t){var r=e.length();if(r>0){var s=1/r;t.x=e.x*s,t.y=e.y*s,t.z=e.z*s,t.w=e.w*s}}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z,r.w=e.w-t.w}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z,r.w=e.w*t.w}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w*t}static Clamp(e,t,r,s){var i=e.x,a=e.y,n=e.z,o=e.w,l=t.x,h=t.y,u=t.z,d=t.w,c=r.x,_=r.y,p=r.z,g=r.w;i=(i=i>c?c:i)<l?l:i,a=(a=a>_?_:a)<h?h:a,n=(n=n>p?p:n)<u?u:n,o=(o=o>g?g:o)<d?d:o,s.x=i,s.y=a,s.z=n,s.w=o}static distanceSquared(e,t){var r=e.x-t.x,s=e.y-t.y,i=e.z-t.z,a=e.w-t.w;return r*r+s*s+i*i+a*a}static distance(e,t){var r=e.x-t.x,s=e.y-t.y,i=e.z-t.z,a=e.w-t.w;return Math.sqrt(r*r+s*s+i*i+a*a)}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}static min(e,t,r){r.x=Math.min(e.x,t.x),r.y=Math.min(e.y,t.y),r.z=Math.min(e.z,t.z),r.w=Math.min(e.w,t.w)}static max(e,t,r){r.x=Math.max(e.x,t.x),r.y=Math.max(e.y,t.y),r.z=Math.max(e.z,t.z),r.w=Math.max(e.w,t.w)}}i.ZERO=new i,i.ONE=new i(1,1,1,1),i.UnitX=new i(1,0,0,0),i.UnitY=new i(0,1,0,0),i.UnitZ=new i(0,0,1,0),i.UnitW=new i(0,0,0,1),i.TEMP=new i(0,0,0,0);class a{static distanceSquared(e,t){var r=e.x-t.x,s=e.y-t.y,i=e.z-t.z;return r*r+s*s+i*i}static distance(e,t){var r=e.x-t.x,s=e.y-t.y,i=e.z-t.z;return Math.sqrt(r*r+s*s+i*i)}static min(e,t,r){r.x=Math.min(e.x,t.x),r.y=Math.min(e.y,t.y),r.z=Math.min(e.z,t.z)}static max(e,t,r){r.x=Math.max(e.x,t.x),r.y=Math.max(e.y,t.y),r.z=Math.max(e.z,t.z)}static transformQuat(e,t,r){var s=e.x,i=e.y,a=e.z,n=t.x,o=t.y,l=t.z,h=t.w,u=h*s+o*a-l*i,d=h*i+l*s-n*a,c=h*a+n*i-o*s,_=-n*s-o*i-l*a;r.x=u*h+_*-n+d*-l-c*-o,r.y=d*h+_*-o+c*-n-u*-l,r.z=c*h+_*-l+u*-o-d*-n}static scalarLength(e){var t=e.x,r=e.y,s=e.z;return Math.sqrt(t*t+r*r+s*s)}static scalarLengthSquared(e){var t=e.x,r=e.y,s=e.z;return t*t+r*r+s*s}static normalize(e,t){var r=e.x,s=e.y,i=e.z,a=r*r+s*s+i*i;a>0&&(a=1/Math.sqrt(a),t.x=r*a,t.y=s*a,t.z=i*a)}static multiply(e,t,r){r.x=e.x*t.x,r.y=e.y*t.y,r.z=e.z*t.z}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t}static lerp(e,t,r,s){var i=e.x,a=e.y,n=e.z;s.x=i+r*(t.x-i),s.y=a+r*(t.y-a),s.z=n+r*(t.z-n)}static transformV3ToV3(e,t,r){a.transformV3ToV4(e,t,n),r.x=n.x,r.y=n.y,r.z=n.z}static transformV3ToV4(e,t,r){var s=e.x,i=e.y,a=e.z,n=t.elements;r.x=s*n[0]+i*n[4]+a*n[8]+n[12],r.y=s*n[1]+i*n[5]+a*n[9]+n[13],r.z=s*n[2]+i*n[6]+a*n[10]+n[14],r.w=s*n[3]+i*n[7]+a*n[11]+n[15]}static TransformNormal(e,t,r){var s=e.x,i=e.y,a=e.z,n=t.elements;r.x=s*n[0]+i*n[4]+a*n[8],r.y=s*n[1]+i*n[5]+a*n[9],r.z=s*n[2]+i*n[6]+a*n[10]}static transformCoordinate(e,t,r){var s=e.x,i=e.y,a=e.z,n=t.elements,o=s*n[3]+i*n[7]+a*n[11]+n[15];r.x=(s*n[0]+i*n[4]+a*n[8]+n[12])/o,r.y=(s*n[1]+i*n[5]+a*n[9]+n[13])/o,r.z=(s*n[2]+i*n[6]+a*n[10]+n[14])/o}static Clamp(e,t,r,s){var i=e.x,a=e.y,n=e.z,o=t.x,l=t.y,h=t.z,u=r.x,d=r.y,c=r.z;i=(i=i>u?u:i)<o?o:i,a=(a=a>d?d:a)<l?l:a,n=(n=n>c?c:n)<h?h:n,s.x=i,s.y=a,s.z=n}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z}static subtract(e,t,r){r.x=e.x-t.x,r.y=e.y-t.y,r.z=e.z-t.z}static cross(e,t,r){var s=e.x,i=e.y,a=e.z,n=t.x,o=t.y,l=t.z;r.x=i*l-a*o,r.y=a*n-s*l,r.z=s*o-i*n}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}static equals(e,t){return s.nearEqual(e.x,t.x)&&s.nearEqual(e.y,t.y)&&s.nearEqual(e.z,t.z)}constructor(e=0,t=0,r=0){this.x=e,this.y=t,this.z=r}equal(e){return a.equals(this,e)}setValue(e,t,r){return this.x=e,this.y=t,this.z=r,this}set(e,t,r){return this.x=e,this.y=t,this.z=r,this}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2]}toArray(){return[this.x,this.y,this.z]}writeTo(e,t=0){e[t+0]=this.x,e[t+1]=this.y,e[t+2]=this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}vsub(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t}vadd(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t}scale(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t}normalize(){let e=this.x,t=this.y,r=this.z;var s=e*e+t*t+r*r;return s>0&&(s=1/Math.sqrt(s),this.x=e*s,this.y=t*s,this.z=r*s),this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}cross(e,t){var r=this.x,s=this.y,i=this.z,a=e.x,n=e.y,o=e.z;return t.x=s*o-i*n,t.y=i*a-r*o,t.z=r*n-s*a,t}cloneTo(e){return e.x=this.x,e.y=this.y,e.z=this.z,e}clone(){var e=new a;return this.cloneTo(e),e}toDefault(){this.x=0,this.y=0,this.z=0}toString(){return`{x:${this.x}, y:${this.y}, z:${this.z}}`}}a.ZERO=new a(0,0,0),a.ONE=new a(1,1,1),a.NegativeUnitX=new a(-1,0,0),a.UnitX=new a(1,0,0),a.UnitY=new a(0,1,0),a.UnitZ=new a(0,0,1),a.ForwardRH=new a(0,0,-1),a.ForwardLH=new a(0,0,1),a.Up=new a(0,1,0),a.TEMP=new a;const n=new i;class o{static setResolution(e,t){o.customResolution=!0,o._resoluWidth=e,o._resoluHeight=t}}o.enableDynamicBatch=!0,o.enableStaticBatch=!0,o.pixelRatio=1,o.customResolution=!1,o.defaultCacheRTMemory=256,o.defaultPhysicsMemory=16,o.enableMultiLight=!0,o.maxLightCount=32,o.lightClusterCount=new a(12,12,12),o.maxMorphTargetCount=32,o.useBVHCull=!1,o.BVH_max_SpatialCount=7,o.BVH_limit_size=32,o.BVH_Min_Build_nums=10,o._resoluWidth=-1,o._resoluHeight=-1,o.debugFrustumCulling=!1;class l{}l.Laya=null,l.Loader=null,l.InputManager=null,l.Scene3D=null,l.Laya3D=null,l.loader=null,l.timer=null,l.systemTimer=null,l.physicsTimer=null,l.stage=null;class h{static getPoolBySign(e){return h._poolDic[e]||(h._poolDic[e]=[])}static clearBySign(e){h._poolDic[e]&&(h._poolDic[e].length=0)}static recover(e,t){t[h.POOLSIGN]||(t[h.POOLSIGN]=!0,h.getPoolBySign(e).push(t))}static recoverByClass(e){if(e){var t=e.__className||e.constructor._$gid;t&&h.recover(t,e)}}static _getClassSign(e){var t=e.__className||e._$gid;return t||(e._$gid=t=h._CLSID+"",h._CLSID++),t}static createByClass(e){return h.getItemByClass(h._getClassSign(e),e)}static getItemByClass(e,t){let r,s=h.getPoolBySign(e);return r=s.length?s.pop():new t,r[h.POOLSIGN]=!1,r}static getItemByCreateFun(e,t,r=null){var s=h.getPoolBySign(e),i=s.length?s.pop():t.call(r);return i[h.POOLSIGN]=!1,i}static getItem(e){var t=h.getPoolBySign(e),r=t.length?t.pop():null;return r&&(r[h.POOLSIGN]=!1),r}static createPool(e,t,r){let s=new u;return s._ct=e,s._init=t,s._reset=r,s}static createPool2(e,t,r){let s=new u;return s._create=e,s._init=t,s._reset=r,s}}h._CLSID=0,h.POOLSIGN="__InPool",h._poolDic={};class u{constructor(){this.pool=[]}take(...e){let t;return t=this.pool.length>0?this.pool.pop():this._create?this._create():new this._ct,this._init&&this._init(t,...e),t}recover(e){if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++){let r=e[t];this._reset&&this._reset(r),this.pool.push(r)}e.length=0}else this._reset&&this._reset(e),this.pool.push(e)}}class d{constructor(e=0,t=0){this.x=e,this.y=t}static create(){return h.getItemByClass("Point",d)}setTo(e,t){return this.x=e,this.y=t,this}reset(){return this.x=this.y=0,this}recover(){h.recover("Point",this.reset())}distance(e,t){return Math.sqrt((this.x-e)*(this.x-e)+(this.y-t)*(this.y-t))}toString(){return this.x+","+this.y}normalize(){var e=Math.sqrt(this.x*this.x+this.y*this.y);if(e>0){var t=1/e;this.x*=t,this.y*=t}}copy(e){return this.setTo(e.x,e.y)}}d.TEMP=new d,d.EMPTY=new d;class c{static isMouseEvent(e){return _.has(e)}constructor(){this.touchId=0,this.delta=0,this.button=0,this.touchPos=new d}setTo(e,t,r){return this.type=e,this.currentTarget=t,this.target=r,this}stopPropagation(){this._stopped=!0}preventDefault(){this._defaultPrevented=!0}get touches(){return this._touches}get altKey(){var e;return null===(e=this.nativeEvent)||void 0===e?void 0:e.altKey}get ctrlKey(){var e;return null===(e=this.nativeEvent)||void 0===e?void 0:e.ctrlKey}get shiftKey(){var e;return null===(e=this.nativeEvent)||void 0===e?void 0:e.shiftKey}get metaKey(){var e;return null===(e=this.nativeEvent)||void 0===e?void 0:e.metaKey}get key(){return this.nativeEvent.key}get keyCode(){return this.nativeEvent.keyCode}get charCode(){var e;return null===(e=this.nativeEvent)||void 0===e?void 0:e.code}get keyLocation(){return this.nativeEvent?this.nativeEvent.location||this.nativeEvent.keyLocation:0}get stageX(){return this.touchPos.x}get stageY(){return this.touchPos.y}}c.EMPTY=new c,c.MOUSE_DOWN="mousedown",c.MOUSE_UP="mouseup",c.RIGHT_MOUSE_DOWN="rightmousedown",c.RIGHT_MOUSE_UP="rightmouseup",c.CLICK="click",c.RIGHT_CLICK="rightclick",c.MOUSE_MOVE="mousemove",c.MOUSE_OVER="mouseover",c.MOUSE_OUT="mouseout",c.MOUSE_WHEEL="mousewheel",c.ROLL_OVER="mouseover",c.ROLL_OUT="mouseout",c.DOUBLE_CLICK="doubleclick",c.MOUSE_DRAG="mousedrag",c.MOUSE_DRAG_END="mousedragend",c.DRAG_START="dragstart",c.DRAG_MOVE="dragmove",c.DRAG_END="dragend",c.DROP="drop",c.KEY_DOWN="keydown",c.KEY_PRESS="keypress",c.KEY_UP="keyup",c.CHANGE="change",c.CHANGED="changed",c.MOVED="moved",c.WILL_RESIZE="willResize",c.RESIZE="resize",c.ADDED="added",c.REMOVED="removed",c.DISPLAY="display",c.UNDISPLAY="undisplay",c.ERROR="error",c.COMPLETE="complete",c.LOADED="loaded",c.READY="ready",c.PROGRESS="progress",c.INPUT="input",c.RENDER="render",c.OPEN="open",c.MESSAGE="message",c.CLOSE="close",c.FRAME="enterframe",c.ENTER="enter",c.SELECT="select",c.BLUR="blur",c.FOCUS="focus",c.VISIBILITY_CHANGE="visibilitychange",c.ORIENTATION_CHANGE="orientationchange",c.FOCUS_CHANGE="focuschange",c.PLAYED="played",c.PAUSED="paused",c.STOPPED="stopped",c.START="start",c.END="end",c.LINK="link",c.LABEL="label",c.FULL_SCREEN_CHANGE="fullscreenchange",c.DEVICE_LOST="devicelost",c.TRANSFORM_CHANGED="transformchanged",c.LAYER_CHANGE="layerChange",c.STATIC_MASK="staticMask",c.TRIGGER_ENTER="triggerenter",c.TRIGGER_STAY="triggerstay",c.TRIGGER_EXIT="triggerexit",c.COLLISION_ENTER="collisionenter",c.COLLISION_STAY="collisionstay",c.COLLISION_EXIT="collisionexit",c.JOINT_BREAK="jointbreak",c.UPDATE_PHY_EVENT_FILTER="physics3dEventFilter";const _=new Set([c.MOUSE_DOWN,c.MOUSE_UP,c.MOUSE_MOVE,c.CLICK,c.DOUBLE_CLICK,c.RIGHT_CLICK,c.RIGHT_MOUSE_DOWN,c.RIGHT_MOUSE_UP,c.MOUSE_OVER,c.MOUSE_OUT,c.MOUSE_WHEEL,c.MOUSE_DRAG,c.MOUSE_DRAG_END]);class p{}var g;p.version="3.4.2",p.isPlaying=!0,p.isPreview=!1,p.isConch=!!window&&null!=window.conch,p.isModernAPIs=!!window&&null!=window.conchLayaXDevice,p.isEditor=!1,e.StatElement=void 0,(g=e.StatElement||(e.StatElement={}))[g.CT_FPS=0]="CT_FPS",g[g.T_Frame_Time=1]="T_Frame_Time",g[g.T_AllRender3D=2]="T_AllRender3D",g[g.T_DepthPass=3]="T_DepthPass",g[g.T_ShadowPass=4]="T_ShadowPass",g[g.T_3DMainPass=5]="T_3DMainPass",g[g.T_3DContextPre=6]="T_3DContextPre",g[g.T_3DContextRender=7]="T_3DContextRender",g[g.T_3DMainPass_Opaque=8]="T_3DMainPass_Opaque",g[g.T_3DMainPass_Trans=9]="T_3DMainPass_Trans",g[g.T_3DBatchTime=10]="T_3DBatchTime",g[g.T_CullMain=11]="T_CullMain",g[g.T_CullShadow=12]="T_CullShadow",g[g.T_Render_PostProcess=13]="T_Render_PostProcess",g[g.T_AllRender2D=14]="T_AllRender2D",g[g.T_2DPass=15]="T_2DPass",g[g.T_2DContextPre=16]="T_2DContextPre",g[g.T_2DContextRender=17]="T_2DContextRender",g[g.T_ScriptUpdateTime=18]="T_ScriptUpdateTime",g[g.T_ScriptLateUpdateTime=19]="T_ScriptLateUpdateTime",g[g.CT_OpaqueDrawCall=20]="CT_OpaqueDrawCall",g[g.CT_TransDrawCall=21]="CT_TransDrawCall",g[g.CT_DepthCastDrawCall=22]="CT_DepthCastDrawCall",g[g.CT_ShadowDrawCall=23]="CT_ShadowDrawCall",g[g.CT_2DDrawCall=24]="CT_2DDrawCall",g[g.CT_3DDrawCall=25]="CT_3DDrawCall",g[g.CT_DrawCall=26]="CT_DrawCall",g[g.CT_IndirectDrawCall=27]="CT_IndirectDrawCall",g[g.CT_Instancing_DrawCall=28]="CT_Instancing_DrawCall",g[g.M_GPUBuffer=29]="M_GPUBuffer",g[g.C_GPUBuffer=30]="C_GPUBuffer",g[g.M_VertexBuffer=31]="M_VertexBuffer",g[g.C_VertexBuffer=32]="C_VertexBuffer",g[g.M_IndexBuffer=33]="M_IndexBuffer",g[g.C_IndexBuffer=34]="C_IndexBuffer",g[g.M_UBOBuffer=35]="M_UBOBuffer",g[g.C_UBOBuffer=36]="C_UBOBuffer",g[g.M_DeviceBuffer=37]="M_DeviceBuffer",g[g.C_DeviceBuffer=38]="C_DeviceBuffer",g[g.M_AllTexture=39]="M_AllTexture",g[g.C_AllTexture=40]="C_AllTexture",g[g.M_Texture2D=41]="M_Texture2D",g[g.C_Texture2D=42]="C_Texture2D",g[g.M_TextureCube=43]="M_TextureCube",g[g.C_TextureCube=44]="C_TextureCube",g[g.M_Texture3D=45]="M_Texture3D",g[g.C_Texture3D=46]="C_Texture3D",g[g.M_Texture2DArray=47]="M_Texture2DArray",g[g.C_Texture2DArray=48]="C_Texture2DArray",g[g.M_RenderTexture=49]="M_RenderTexture",g[g.C_RenderTexture=50]="C_RenderTexture",g[g.M_GPUMemory=51]="M_GPUMemory",g[g.CT_ShaderChange=52]="CT_ShaderChange",g[g.CT_Triangle=53]="CT_Triangle",g[g.CT_BufferUploadCount=54]="CT_BufferUploadCount",g[g.CT_GeometryBufferUploadCount=55]="CT_GeometryBufferUploadCount",g[g.CT_UBOBufferUploadCount=56]="CT_UBOBufferUploadCount",g[g.CT_UBOBufferUploadMemory=57]="CT_UBOBufferUploadMemory",g[g.C_Sprite2DCount=58]="C_Sprite2DCount",g[g.C_Sprite3DCount=59]="C_Sprite3DCount",g[g.C_BaseRenderCount=60]="C_BaseRenderCount",g[g.C_MeshRenderCount=61]="C_MeshRenderCount",g[g.C_SkinnedMeshRenderCount=62]="C_SkinnedMeshRenderCount",g[g.C_ShurikenParticleRenderCount=63]="C_ShurikenParticleRenderCount",g[g.T_AnimatorUpdate=64]="T_AnimatorUpdate",g[g.T_SkinBoneUpdate=65]="T_SkinBoneUpdate",g[g.T_ShurikenUpdate=66]="T_ShurikenUpdate",g[g.T_Physics_Simulation=67]="T_Physics_Simulation",g[g.T_Physics_UpdateNode=68]="T_Physics_UpdateNode",g[g.T_PhysicsEvent=69]="T_PhysicsEvent",g[g.C_PhysicsEventCount=70]="C_PhysicsEventCount",g[g.T_PhysicsCollider=71]="T_PhysicsCollider",g[g.T_PhysicsTrigger=72]="T_PhysicsTrigger",g[g.T_PhysicsColliderEnter=73]="T_PhysicsColliderEnter",g[g.T_PhysicsColliderExit=74]="T_PhysicsColliderExit",g[g.T_PhysicsColliderStay=75]="T_PhysicsColliderStay",g[g.T_PhysicsTriggerEnter=76]="T_PhysicsTriggerEnter",g[g.T_PhysicsTriggerExit=77]="T_PhysicsTriggerExit",g[g.T_PhysicsTriggerStay=78]="T_PhysicsTriggerStay",g[g.C_PhysicaDynamicRigidBody=79]="C_PhysicaDynamicRigidBody",g[g.C_PhysicaStaticRigidBody=80]="C_PhysicaStaticRigidBody",g[g.C_PhysicaKinematicRigidBody=81]="C_PhysicaKinematicRigidBody",g[g.C_PhysicaCharacterController=82]="C_PhysicaCharacterController",g[g.C_PhysicsJoint=83]="C_PhysicsJoint",g[g.T_LoadResourceTime=84]="T_LoadResourceTime",g[g.C_LoadResourceCount=85]="C_LoadResourceCount",g[g.C_LoadRequestCount=86]="C_LoadRequestCount",g[g.T_LoadRequestTime=87]="T_LoadRequestTime",g[g.StatEnd=88]="StatEnd";class m{constructor(){this._tQueue=new Set,this._ctQueue=new Set,this._cacheCount=0,this._cacheTime=0,this._cacheTime=performance.now(),this._createStatBuffer();for(let t=0;t<e.StatElement.StatEnd;t++){const r=e.StatElement[t];r&&(r.startsWith("T_")&&this._tQueue.add(t),r.startsWith("CT_")&&this._ctQueue.add(t))}}_createStatBuffer(){this._statArray=new Float32Array(e.StatElement.StatEnd),this._timeArray=new Float32Array(e.StatElement.StatEnd)}cloneTo(t){for(let r=0;r<e.StatElement.StatEnd;r++){const s=e.StatElement[r];s&&(s.startsWith("C_")?t.recordCountData(r,this._statArray[r]):s.startsWith("M_")&&t.recordMemoryData(r,1024*this._statArray[r]*1024))}}recordCountData(e,t){this._statArray[e]+=t}recordTimeData(e,t){this._timeArray[e]+=t}recordCTData(e,t){this._timeArray[e]+=t}recordMemoryData(e,t){this._statArray[e]+=t/1024/1024}getElementData(e){return this._statArray[e]}startFrameLogic(){}endFrameLogic(t){this._cacheCount++;let r=t-this._cacheTime;if(r<1e3)return;let s=Math.round(1e3*this._cacheCount)/r;for(let e of this._tQueue)this._statArray[e]=this._timeArray[e]/this._cacheCount,this._timeArray[e]=0;for(let e of this._ctQueue)this._statArray[e]=this._timeArray[e]/this._cacheCount,this._timeArray[e]=0;this._statArray[e.StatElement.CT_FPS]=Math.round(s),this._statArray[e.StatElement.T_Frame_Time]=s>0?Math.floor(1e3/s):0,this._cacheTime=t,this._cacheCount=0}}class f{}f.statAgent=new m;const T={purple:8388736,orange:16753920,white:16777215,red:16711680,green:65280,blue:255,black:0,yellow:16776960,gray:8421504};class y{static hexToString(e){return x.parse(e),x.toString()}static stringToHex(e){return x.parse(e),x.getRGB()}static gammaToLinearSpace(e){return e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)}static linearToGammaSpace(e){return e<=0?0:e<=.0031308?12.92*e:e<=1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)}constructor(e=1,t=1,r=1,s=1){this.r=e,this.g=t,this.b=r,this.a=s}equal(e){if(!e)return!1;const t=(e,t)=>{var r=1e-5;return-r<e-t&&e-t<r};return t(e.r,this.r)&&t(e.g,this.g)&&t(e.b,this.b)&&t(e.a,this.a)}parse(e){if(null==e&&(e=0),"number"==typeof e)(e<0||isNaN(e))&&(e=0),this.setRGB(e);else if("string"!=typeof e)this.setValue(0,0,0,1);else if(e.indexOf("rgba(")>=0||e.indexOf("rgb(")>=0){let t=e.indexOf("("),r=e.indexOf(")");if(-1==t||-1==r)return this.setValue(0,0,0,1),this;let s=(e=e.substring(t+1,r)).split(","),i=s.length;for(let e=0;e<i;e++)s[e]=parseFloat(s[e]),isNaN(s[e])&&(s[e]=0);this.r=s[0]/255,this.g=s[1]/255,this.b=s[2]/255,4==s.length?this.a=s[3]:this.a=1}else{if("#"===e.charAt(0))e=e.substring(1);else{let t=T[e];if(t)return this.setRGB(t),this}let t,r=e.length;if(3===r||4===r){let t="";for(let s=0;s<r;s++)t+=e[s]+e[s];e=t}let s=1;8==r?(t=parseInt(e.substring(0,6),16),s=parseInt(e.substring(6,8),16)/255):(t=parseInt(e,16),s=1),this.setRGB(t),this.a=s}return this}toLinear(e){e.r=y.gammaToLinearSpace(this.r),e.g=y.gammaToLinearSpace(this.g),e.b=y.gammaToLinearSpace(this.b),e.a=this.a}toGamma(e){e.r=y.linearToGammaSpace(this.r),e.g=y.linearToGammaSpace(this.g),e.b=y.linearToGammaSpace(this.b),e.a=this.a}cloneTo(e){e.r=this.r,e.g=this.g,e.b=this.b,e.a=this.a}scale(e){return this.r=this.r*e,this.g=this.g*e,this.b=this.b*e,this}setValue(e,t,r,s){return this.r=e,this.g=t,this.b=r,this.a=s,this}fromArray(e,t=0){this.r=e[t+0],this.g=e[t+1],this.b=e[t+2],this.a=e[t+3]}toArray(){return[this.r,this.g,this.b,this.a]}writeTo(e,t=0){e[t+0]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a}clone(){var e=new y;return this.cloneTo(e),e}getRGB(){return(Math.round(255*this.r)<<16)+(Math.round(255*this.g)<<8)+Math.round(255*this.b)}setRGB(e){this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this.a=1}getARGB(){return(Math.round(255*this.a)<<24)+(Math.round(255*this.r)<<16)+(Math.round(255*this.g)<<8)+Math.round(255*this.b)}getABGR(){return(Math.round(255*this.a)<<24)+(Math.round(255*this.b)<<16)+(Math.round(255*this.g)<<8)+Math.round(255*this.r)}setABGR(e){this.a=(e>>24&255)/255,this.b=(e>>16&255)/255,this.g=(e>>8&255)/255,this.r=(255&e)/255}toString(){let e=this.getRGB().toString(16);for(;e.length<6;)e="0"+e;return"#"+e}getStyleString(){return 1==this.a?this.toString():"rgba("+Math.round(255*this.r)+","+Math.round(255*this.g)+","+Math.round(255*this.b)+","+this.a+")"}}y.RED=new y(1,0,0,1),y.GREEN=new y(0,1,0,1),y.BLUE=new y(0,0,1,1),y.CYAN=new y(0,1,1,1),y.YELLOW=new y(1,.92,.016,1),y.MAGENTA=new y(1,0,1,1),y.GRAY=new y(.5,.5,.5,1),y.WHITE=new y(1,1,1,1),y.BLACK=new y(0,0,0,1),y.CLEAR=new y(0,0,0,0);const x=new y;var S,E,v,D,w;function R(t){switch(t){case e.TextureFormat.ASTC4x4:case e.TextureFormat.ASTC4x4SRGB:case e.TextureFormat.ASTC6x6:case e.TextureFormat.ASTC6x6SRGB:case e.TextureFormat.ASTC8x8:case e.TextureFormat.ASTC8x8SRGB:case e.TextureFormat.ASTC10x10:case e.TextureFormat.ASTC10x10SRGB:case e.TextureFormat.ASTC12x12:case e.TextureFormat.ASTC12x12SRGB:return e.RenderCapable.COMPRESS_TEXTURE_ASTC;case e.TextureFormat.DXT1:case e.TextureFormat.DXT3:case e.TextureFormat.DXT5:return e.RenderCapable.COMPRESS_TEXTURE_S3TC;case e.TextureFormat.PVRTCRGB_2BPPV:case e.TextureFormat.PVRTCRGBA_2BPPV:case e.TextureFormat.PVRTCRGB_4BPPV:case e.TextureFormat.PVRTCRGBA_4BPPV:return e.RenderCapable.COMPRESS_TEXTURE_PVRTC;case e.TextureFormat.ETC2RGB:case e.TextureFormat.ETC2RGBA:case e.TextureFormat.ETC2SRGB_Alpha8:case e.TextureFormat.ETC2SRGB:case e.TextureFormat.ETC2RGB_Alpha1:case e.TextureFormat.ETC2SRGB_Alpha1:return e.RenderCapable.COMPRESS_TEXTURE_ETC;case e.TextureFormat.ETC1RGB:return e.RenderCapable.COMPRESS_TEXTURE_ETC1;default:return null}}e.RenderTargetFormat=void 0,(S=e.RenderTargetFormat||(e.RenderTargetFormat={}))[S.None=-1]="None",S[S.R8G8B8=0]="R8G8B8",S[S.R8G8B8A8=1]="R8G8B8A8",S[S.R16G16B16A16=17]="R16G16B16A16",S[S.R32G32B32=30]="R32G32B32",S[S.R32G32B32A32=15]="R32G32B32A32",S[S.R16G16B16=31]="R16G16B16",S[S.DEPTH_16=35]="DEPTH_16",S[S.STENCIL_8=36]="STENCIL_8",S[S.DEPTHSTENCIL_24_8=37]="DEPTHSTENCIL_24_8",S[S.DEPTH_32=38]="DEPTH_32",S[S.DEPTHSTENCIL_24_Plus=39]="DEPTHSTENCIL_24_Plus",S[S.R16=40]="R16",S[S.R16G16=41]="R16G16",e.RenderCapable=void 0,(E=e.RenderCapable||(e.RenderCapable={}))[E.Element_Index_Uint32=0]="Element_Index_Uint32",E[E.Element_Index_Uint8=1]="Element_Index_Uint8",E[E.TextureFormat_R32G32B32A32=2]="TextureFormat_R32G32B32A32",E[E.TextureFormat_R16G16B16A16=3]="TextureFormat_R16G16B16A16",E[E.Texture_anisotropic=4]="Texture_anisotropic",E[E.RenderTextureFormat_R16G16B16A16=5]="RenderTextureFormat_R16G16B16A16",E[E.RenderTextureFormat_R32G32B32A32=6]="RenderTextureFormat_R32G32B32A32",E[E.RenderTextureFormat_Depth=7]="RenderTextureFormat_Depth",E[E.RenderTextureFormat_ShadowMap=8]="RenderTextureFormat_ShadowMap",E[E.Vertex_VAO=9]="Vertex_VAO",E[E.DrawElement_Instance=10]="DrawElement_Instance",E[E.Shader_TextureLod=11]="Shader_TextureLod",E[E.COMPRESS_TEXTURE_S3TC=12]="COMPRESS_TEXTURE_S3TC",E[E.COMPRESS_TEXTURE_S3TC_SRGB=13]="COMPRESS_TEXTURE_S3TC_SRGB",E[E.COMPRESS_TEXTURE_PVRTC=14]="COMPRESS_TEXTURE_PVRTC",E[E.COMPRESS_TEXTURE_ETC1=15]="COMPRESS_TEXTURE_ETC1",E[E.COMPRESS_TEXTURE_ETC=16]="COMPRESS_TEXTURE_ETC",E[E.COMPRESS_TEXTURE_ASTC=17]="COMPRESS_TEXTURE_ASTC",E[E.Texture_SRGB=18]="Texture_SRGB",E[E.MSAA=19]="MSAA",E[E.UnifromBufferObject=20]="UnifromBufferObject",E[E.Texture3D=21]="Texture3D",E[E.Texture_FloatLinearFiltering=22]="Texture_FloatLinearFiltering",E[E.Texture_HalfFloatLinearFiltering=23]="Texture_HalfFloatLinearFiltering",E[E.StorageBuffer=24]="StorageBuffer",E[E.ComputeShader=25]="ComputeShader",E[E.IndirectDraw=26]="IndirectDraw",E[E.Texture_NPOTFull=27]="Texture_NPOTFull",E[E.MRT=28]="MRT",E[E.RenderTextureFormat_R16=29]="RenderTextureFormat_R16",E[E.RenderTextureFormat_R16G16=30]="RenderTextureFormat_R16G16",e.TextureDimension=void 0,(v=e.TextureDimension||(e.TextureDimension={}))[v.Tex2D=0]="Tex2D",v[v.Cube=1]="Cube",v[v.Tex3D=2]="Tex3D",v[v.Texture2DArray=3]="Texture2DArray",v[v.CubeArray=4]="CubeArray",v[v.Unkonw=5]="Unkonw",v[v.None=6]="None",e.HDREncodeFormat=void 0,(D=e.HDREncodeFormat||(e.HDREncodeFormat={}))[D.NONE=0]="NONE",D[D.RGBM=1]="RGBM",D[D.RGBD=2]="RGBD",e.TextureFormat=void 0,(w=e.TextureFormat||(e.TextureFormat={}))[w.R8G8B8=0]="R8G8B8",w[w.R8G8B8A8=1]="R8G8B8A8",w[w.R5G6B5=16]="R5G6B5",w[w.Alpha8=2]="Alpha8",w[w.DXT1=3]="DXT1",w[w.DXT3=29]="DXT3",w[w.DXT5=4]="DXT5",w[w.ETC1RGB=5]="ETC1RGB",w[w.ETC2RGB=6]="ETC2RGB",w[w.ETC2RGBA=7]="ETC2RGBA",w[w.ETC2SRGB_Alpha8=8]="ETC2SRGB_Alpha8",w[w.ETC2SRGB=28]="ETC2SRGB",w[w.ETC2RGB_Alpha1=32]="ETC2RGB_Alpha1",w[w.ETC2SRGB_Alpha1=33]="ETC2SRGB_Alpha1",w[w.PVRTCRGB_2BPPV=9]="PVRTCRGB_2BPPV",w[w.PVRTCRGBA_2BPPV=10]="PVRTCRGBA_2BPPV",w[w.PVRTCRGB_4BPPV=11]="PVRTCRGB_4BPPV",w[w.PVRTCRGBA_4BPPV=12]="PVRTCRGBA_4BPPV",w[w.R32G32B32A32=15]="R32G32B32A32",w[w.R32G32B32=30]="R32G32B32",w[w.R16G16B16A16=17]="R16G16B16A16",w[w.R16G16B16=31]="R16G16B16",w[w.ASTC4x4=18]="ASTC4x4",w[w.ASTC4x4SRGB=23]="ASTC4x4SRGB",w[w.ASTC6x6=19]="ASTC6x6",w[w.ASTC6x6SRGB=24]="ASTC6x6SRGB",w[w.ASTC8x8=20]="ASTC8x8",w[w.ASTC8x8SRGB=25]="ASTC8x8SRGB",w[w.ASTC10x10=21]="ASTC10x10",w[w.ASTC10x10SRGB=26]="ASTC10x10SRGB",w[w.ASTC12x12=22]="ASTC12x12",w[w.ASTC12x12SRGB=27]="ASTC12x12SRGB",w[w.KTXTEXTURE=-1]="KTXTEXTURE",w[w.PVRTEXTURE=-2]="PVRTEXTURE";class C extends Error{constructor(){super("Not implemented.")}}class M extends Error{constructor(e){super(`Index out of range: ${e}`)}}class b extends Error{constructor(){super("readable flag need to be true.")}}function A(e){if(null!=e&&"object"==typeof e){let t;for(let r in P)if(t=e[P[r]],null!=t)return I(t)}return I(e)}function I(e){return"number"==typeof e?`error code=${e}`:"string"!=typeof e?"error! "+e:e}const P=["errMsg","errorMessage","message","reason","error","errCode","statusCode"];class B{constructor(){this._flag=0,this._items=[]}add(e,t,r){t=t||null;let s=this._items,i=s.findIndex((r,s,i)=>r===e&&i[s+1]===t);-1!=i?(s[i+2]=r,s[i+3]=1):s.push(e,t,r,1)}once(e,t,r){t=t||null;let s=this._items,i=s.findIndex((r,s,i)=>r===e&&i[s+1]===t);-1!=i?(s[i+2]=r,s[i+3]=2):s.push(e,t,r,2)}remove(e,t){t=t||null;let r=this._items,s=r.findIndex((r,s,i)=>r===e&&i[s+1]===t);-1!=s&&(0!=this._flag?(r[s+3]=0,this._flag=2):r.splice(s,4))}clear(){let e=this._items;0!=this._flag?(e.forEach((e,t,r)=>{t%4==3&&(r[t]=0)}),this._flag=2):e.length=0}clearForTarget(e){if(!e)return;let t=this._items;if(0!=this._flag)t.forEach((t,r,s)=>{r%4==1&&s[r]===e&&(s[r+2]=0)}),this._flag=2;else{let r=t.length-4;for(;r>=0;)t[r+1]===e&&t.splice(r,4),r-=4}}get count(){return this._items.length/4}invoke(...e){if(0!=this._flag)return;this._flag=1;let t=this._items,r=t.length;for(let s=0;s<r;s+=4){if(0===t[s+3])continue;let r=t[s+2];try{null!=r?t[s].call(t[s+1],...r,...e):t[s].call(t[s+1],...e)}catch(e){console.error(e)}2===t[s+3]&&(t[s+3]=0,this._flag=2)}if(2===this._flag){let e=t.length,r=0;for(;r<e;)0!==t[r+3]?r+=4:(t.splice(r,4),e-=4)}this._flag=0}}const L=[];class N{onStartListeningToType(e){}hasListener(e){let t=this._events&&this._events[e];return!!t&&t.count>0}event(e,t){let r=this._events&&this._events[e];if(!r)return!1;let s=r.count>0;if(Array.isArray(t))r.invoke(...t);else if(void 0!==t)r.invoke(t);else if(t===c.EMPTY){let t=L.length>0?L.pop():new c;r.invoke(t.setTo(e,this,this)),t.target=t.currentTarget=null,L.push(t)}else r.invoke();return s}on(e,t,r,s){2==arguments.length&&(r=t,t=null),this._events||(this._events={});let i=this._events[e];return i||(this.onStartListeningToType(e),this._events[e]=i=new B),i.add(r,t,s),this}once(e,t,r,s){2==arguments.length&&(r=t,t=null),this._events||(this._events={});let i=this._events[e];return i||(this.onStartListeningToType(e),this._events[e]=i=new B),i.once(r,t,s),this}off(e,t,r){2==arguments.length&&(r=t,t=null);let s=this._events&&this._events[e];return s&&s.remove(r,t),this}offAll(e){if(!this._events)return this;if(null==e)for(let e in this._events)this._events[e].clear();else{let t=this._events[e];t&&t.clear()}return this}offAllCaller(e){if(e&&this._events)for(let t in this._events)this._events[t].clearForTarget(e);return this}}var F,O=0,U=0,k=0;class G extends N{static get cpuMemory(){return G._cpuMemory}static get gpuMemory(){return G._gpuMemory}static _addCPUMemory(e){G._cpuMemory+=e}static _addGPUMemory(e){G._gpuMemory+=e}static _addMemory(e,t){G._cpuMemory+=e,G._gpuMemory+=t}static destroyUnusedResources(){U=0,k=0,l.loader.loading?l.timer.frameLoop(1,G,G._destroyUnusedResources):G._destroyUnusedResources(!0)}static _destroyUnusedResources(e){if(!e&&l.loader.loading)return;l.timer.clear(G,G._destroyUnusedResources);let t=0;for(let e in G._idResourcesMap){let r=G._idResourcesMap[e];r.lock||0!==r._referenceCount||(r.destroy(),t++)}G.DEBUG&&t>0&&console.debug(`destroyUnusedResources(${t})`),t>0&&k<5&&(k++,l.timer.frameLoop(1,G,G._destroyUnusedResources))}get id(){return this._id}get cpuMemory(){return this._cpuMemory}get gpuMemory(){return this._gpuMemory}get destroyed(){return this._destroyed}get obsolute(){return this._obsolute}set obsolute(e){this._obsolute!=e&&(this._obsolute=e,e&&!p.isPlaying&&this.event("obsolute"))}get deps(){return this._deps}get referenceCount(){return this._referenceCount}constructor(e){super(),this._cpuMemory=0,this._gpuMemory=0,this._id=0,this._referenceCount=0,this._id=++O,this._destroyed=!1,this._referenceCount=0,(null==e||e)&&(G._idResourcesMap[this._id]=this),this.lock=!1,this.destroyedImmediately=!0,this._deps=[],this._traceDeps=!1}_setCPUMemory(e){var t=e-this._cpuMemory;this._cpuMemory=e,G._addCPUMemory(t)}_setGPUMemory(e){var t=e-this._gpuMemory;this._gpuMemory=e,G._addGPUMemory(t)}_setCreateURL(e,t){this.url=e,this.uuid=t}isCreateFromURL(e){return this.uuid&&e.length===this.uuid.length+6&&e.endsWith(this.uuid)||this.url===e}_addReference(e=1){this._referenceCount+=e}_removeReference(e=1){this._referenceCount-=e,U>0&&this._referenceCount<=0&&!this.lock&&this.destroyedImmediately&&this.destroy()}_clearReference(){this._referenceCount=0}addDep(e){e instanceof G&&(e._addReference(),this._deps.push(e),!p.isPlaying&&e._traceDeps&&e.on("obsolute",this,this.onDepObsolute))}addDeps(e){for(let t of e)t instanceof G&&(t._addReference(),this._deps.push(t),!p.isPlaying&&t._traceDeps&&t.on("obsolute",this,this.onDepObsolute))}onDepObsolute(){this.obsolute=!0}_disposeResource(){}unmanaged(){return this.lock=!0,delete G._idResourcesMap[this._id],this}destroy(){if(!this._destroyed){this._destroyed=!0,this.lock=!1,U++,this._disposeResource();for(let e of this._deps)e._removeReference(),!p.isPlaying&&e._traceDeps&&e.off("obsolute",this,this.onDepObsolute);U--,this.offAll(),delete G._idResourcesMap[this.id],this.url&&(G.DEBUG&&console.debug(`destroy ${Object.getPrototypeOf(this).constructor.name} ${this.url}`),l.loader.clearRes(this.url,this))}}}G._idResourcesMap={},G._cpuMemory=0,G._gpuMemory=0,G.DEBUG=!1;class V extends G{get width(){return this._width}set width(e){this._width=e}get height(){return this._height}set height(e){this._height=e}get dimension(){return this._dimension}get format(){return this._format}get mipmap(){return this._texture.mipmap}get mipmapCount(){return this._texture.mipmapCount}get anisoLevel(){return this._texture.anisoLevel}set anisoLevel(e){this._texture.anisoLevel=e}get filterMode(){return this._texture.filterMode}set filterMode(e){this._texture.filterMode=e}get wrapModeU(){return this._texture.wrapU}set wrapModeU(e){this._texture.wrapU=e}get wrapModeV(){return this._texture.wrapV}set wrapModeV(e){this._texture.wrapV=e}get wrapModeW(){return this._texture.wrapW}set wrapModeW(e){this._texture.wrapW=e}get compareMode(){return this._texture.compareMode}set compareMode(e){this._texture.compareMode=f.textureContext.setTextureCompareMode(this._texture,e)}get gammaCorrection(){return this._texture.gammaCorrection}get baseMipmapLevel(){return this._texture.baseMipmapLevel}set baseMipmapLevel(e){this._texture.baseMipmapLevel=e}get maxMipmapLevel(){return this._texture.maxMipmapLevel}set maxMipmapLevel(e){this._texture.maxMipmapLevel=e}get gammaSpace(){return this._texture.useSRGBLoad||this._texture.gammaCorrection>1}constructor(r,s,i){super(),this._gammaSpace=!1,this._width=r,this._height=s,this._format=i,this.destroyedImmediately=t.destroyResourceImmediatelyDefault,this.hdrEncodeFormat=e.HDREncodeFormat.NONE}gpuCompressFormat(){switch(this._format){case e.TextureFormat.R8G8B8:case e.TextureFormat.R8G8B8A8:case e.TextureFormat.R16G16B16:case e.TextureFormat.R16G16B16A16:case e.TextureFormat.R32G32B32:case e.TextureFormat.R32G32B32A32:case e.TextureFormat.R5G6B5:case e.TextureFormat.Alpha8:return!1;case e.TextureFormat.DXT1:case e.TextureFormat.DXT3:case e.TextureFormat.DXT5:case e.TextureFormat.ETC1RGB:case e.TextureFormat.ETC2RGB:case e.TextureFormat.ETC2RGBA:case e.TextureFormat.ETC2SRGB_Alpha8:case e.TextureFormat.ETC2SRGB:case e.TextureFormat.ETC2RGB_Alpha1:case e.TextureFormat.ETC2SRGB_Alpha1:case e.TextureFormat.PVRTCRGB_2BPPV:case e.TextureFormat.PVRTCRGBA_2BPPV:case e.TextureFormat.PVRTCRGB_4BPPV:case e.TextureFormat.PVRTCRGBA_4BPPV:case e.TextureFormat.ASTC4x4:case e.TextureFormat.ASTC4x4SRGB:case e.TextureFormat.ASTC6x6:case e.TextureFormat.ASTC6x6SRGB:case e.TextureFormat.ASTC8x8:case e.TextureFormat.ASTC8x8SRGB:case e.TextureFormat.ASTC10x10:case e.TextureFormat.ASTC10x10SRGB:case e.TextureFormat.ASTC12x12:case e.TextureFormat.ASTC12x12SRGB:return!0;default:return!1}}_getFormatByteCount(){switch(this._format){case e.TextureFormat.R8G8B8:return 3;case e.TextureFormat.R8G8B8A8:return 4;case e.TextureFormat.R5G6B5:case e.TextureFormat.Alpha8:return 1;case e.TextureFormat.R16G16B16A16:return 2;case e.TextureFormat.R32G32B32A32:return 4;default:throw new Error("unknown format.")}}_getSource(){return this._texture.resource}get defaultTexture(){throw new C}_disposeResource(){this._texture&&this._texture.dispose()}}e.DepthTextureMode=void 0,(F=e.DepthTextureMode||(e.DepthTextureMode={}))[F.None=0]="None",F[F.Depth=1]="Depth",F[F.DepthNormals=2]="DepthNormals",F[F.DepthAndDepthNormals=3]="DepthAndDepthNormals",F[F.MotionVectors=4]="MotionVectors";class z extends V{static _getCompatibleColorFormat(t){if(t!==e.RenderTargetFormat.R16G16B16&&t!==e.RenderTargetFormat.R16G16B16A16)return t;if(f.renderEngine.getCapable(e.RenderCapable.RenderTextureFormat_R16G16B16A16))return t;const r=f.renderEngine.getCapable(e.RenderCapable.RenderTextureFormat_R32G32B32A32);let s;return s=t===e.RenderTargetFormat.R16G16B16?r?e.RenderTargetFormat.R32G32B32:e.RenderTargetFormat.R8G8B8:r?e.RenderTargetFormat.R32G32B32A32:e.RenderTargetFormat.R8G8B8A8,console.warn(`RenderTexture: ${e.RenderTargetFormat[t]} is not supported, falling back to ${e.RenderTargetFormat[s]}.`),s}static createFromPool(t,r,s,i,a=!1,n=1,o=!1,l=!1,h=!1){a=a&&(f.renderEngine.getCapable(e.RenderCapable.Texture_NPOTFull)||!(t&t-1)&&!(r&r-1)),s=z._getCompatibleColorFormat(s);let u=z._pool.length;for(let e=0;e<u;e++){let d=z._pool[e];if(!d.destroyed&&!d.isMRT&&d.width==t&&d.height==r&&d.colorFormat==s&&d.depthStencilFormat==i&&d._generateMipmap==a&&d.multiSamples==n&&d._gammaSpace==l&&d._storage==h){d._inPool=!1;let t=z._pool[u-1];return z._pool[e]=t,z._pool.length-=1,z._poolMemory-=d._renderTarget.gpuMemory/1024/1024,d.generateDepthTexture=o,d}}let d=new z(t,r,s,i,a,n,o,l,h);return d.lock=!0,d}static recoverToPool(e){e._inPool||e.destroyed||(z._pool.push(e),z._poolMemory+=e._renderTarget.gpuMemory/1024/1024,e._inPool=!0)}static clearPool(){if(!(z._poolMemory<o.defaultCacheRTMemory)){for(var e in z._pool)z._pool[e].destroy();z._pool=[],z._poolMemory=0}}static get bindCanvasRender(){return z._bindCanvasRender}static set bindCanvasRender(e){e!=this._bindCanvasRender&&(this._bindCanvasRender=e)}get isMRT(){return!1}_getRenderTarget(e=!1){return this._renderTarget}get generateDepthTexture(){return this._generateDepthTexture}set generateDepthTexture(t){this.depthStencilFormat!=e.RenderTargetFormat.None?(t&&!this._depthStencilTexture&&(this._depthStencilTexture=new V(this.width,this.height,this.depthStencilFormat),this._depthStencilTexture._dimension=e.TextureDimension.Tex2D,this._depthStencilTexture._texture=f.textureContext.createRenderTargetDepthTexture(this._renderTarget,e.TextureDimension.Tex2D,this.width,this.height)),this._generateDepthTexture=t):this._generateDepthTexture=!1}get depthStencilTexture(){return this._depthStencilTexture}get colorFormat(){return this._renderTarget.colorFormat}get depthStencilFormat(){return this._renderTarget.depthStencilFormat}get multiSamples(){return this._renderTarget._samples}get isCube(){return this._renderTarget._isCube}get samples(){return this._renderTarget._samples}get generateMipmap(){return this._renderTarget._generateMipmap}constructor(t,r,s,i,a=!1,n=1,o=!1,l=!1,h=!1){super(t,r,z._getCompatibleColorFormat(s)),this._inPool=!1,this._isCameraTarget=!1,this._generateDepthTexture=!1,this._storage=!1,this._gammaSpace=l,this._depthStencilFormat=null==i?e.RenderTargetFormat.None:i,this._generateMipmap=a,this._multiSamples=n,this._generateDepthTexture=o,this._storage=h,this._createRenderTarget()}_createRenderTarget(){this._dimension=e.TextureDimension.Tex2D,this._renderTarget=f.textureContext.createRenderTargetInternal(this.width,this.height,this._format,this._depthStencilFormat,this._generateMipmap,this._gammaSpace,this._multiSamples,this._storage),this._generateMipmap=this._renderTarget._generateMipmap,this._renderTarget._texturesResolve?this._texture=this._renderTarget._texturesResolve[0]:this._texture=this._renderTarget._textures[0],this.generateDepthTexture=this._generateDepthTexture}recreate(t,r,s,i,a=!1,n=1,o=!1,l=!1,h=!1){this._width=t,this._height=r,s=z._getCompatibleColorFormat(s),this._format=s,this._gammaSpace=l,this._depthStencilFormat=null==i?e.RenderTargetFormat.None:i,this._generateMipmap=a,this._multiSamples=n,this._generateDepthTexture=o,this._storage=h,this._disposeResource(),this._createRenderTarget()}getData(e,t,r,s,i){return f.textureContext.readRenderTargetPixelData(this._renderTarget,e,t,r,s,i),i}getDataAsync(e,t,r,s,i){return f.textureContext.readRenderTargetPixelDataAsync(this._renderTarget,e,t,r,s,i)}_disposeResource(){var e;this._renderTarget.dispose(),this._renderTarget=null,null===(e=this._depthStencilTexture)||void 0===e||e.destroy(),this._depthStencilTexture=null}}z._pool=[],z._poolMemory=0;const H=["browser","fs","storage","font","textInput","media","device"];class W{static __init__(){for(let e of H){let t=W._classes[e];t&&(W[e]=new t)}}static register(e,t){p.isPlaying&&(W._classes[e]=t)}static warnIncompatibility(e){X.has(e)||(X.add(e),console.warn(`${e} is not supported in this platform.`))}static hasAPI(e,t){let r=t&&e||W.g,s=t||e;return r.willGenerateUndefinedAPIs?null!=Object.getOwnPropertyDescriptor(r,s):null!=r[s]}}W.g=null,W._classes={};const X=new Set;class Y{static createElement(e){return W.browser.createElement(e)}static getElementById(e){return W.browser.getElementById(e)}static removeElement(e){W.browser.removeElement(e)}static now(){return performance.now()}static get clientWidth(){return null!=this._clientWidth?this._clientWidth:W.browser.getClientWidth()}static set clientWidth(e){Y._clientWidth=e}static get clientHeight(){return null!=this._clientHeight?this._clientHeight:W.browser.getClientHeight()}static set clientHeight(e){Y._clientHeight=e}static setWindowSize(e,t){return W.browser.setWindowSize(e,t)}static get width(){return(l.stage&&l.stage.canvasRotation?Y.clientHeight:Y.clientWidth)*Y.pixelRatio}static get height(){return(l.stage&&l.stage.canvasRotation?Y.clientWidth:Y.clientHeight)*Y.pixelRatio}static get pixelRatio(){return W.browser.getPixelRatio()}static get container(){return Y.mainCanvas.source.parentElement||document.body}static getQueryString(e){if(!Y.window.location||!Y.window.location.search)return null;let t=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),r=Y.window.location.search.substring(1).match(t);return null!=r?unescape(r[2]):null}static loadLib(e,t){return new Promise((r,s)=>{let i=document.createElement("script");i.onload=function(){r()},i.onerror=function(){s(`load ${e} failed`)},null!=t&&(i.async=t),i.src=ee.postFormatURL(ee.formatURL(e)),Y.document.body.appendChild(i)})}}Y.platform=0,Y.platformName="",Y.PLATFORM_PC=0,Y.PLATFORM_ANDROID=1,Y.PLATFORM_IOS=2,Y.isDomSupported=!0,Y.systemVersion="",Y.SDKVersion="",Y.bundles=new Map,Y.window=void 0!==typeof window?window:null,Y.document=void 0!==typeof document?document:null;let q=window;q.__getBundle_=function(e){let t=Y.bundles.get(e);return t||Y.bundles.set(e,t={}),t},q.__setBundle_=function(e,t,r){let s=Y.bundles.get(e);s&&function(e,t,r){var s;if(t&&"object"==typeof t||"function"==typeof t)for(let i of Object.getOwnPropertyNames(t))e.hasOwnProperty(i)||i===r||Object.defineProperty(e,i,{get:()=>t[i],enumerable:!(s=Object.getOwnPropertyDescriptor(t,i))||s.enumerable})}(s,t,"default"),Y.bundles.set(e,t),r&&(q[r]=t)};var $=1;const K=180/Math.PI,j=Math.PI/180;class Q{static toRadian(e){return e*j}static toAngle(e){return e*K}static toHexColor(e){return y.hexToString(e)}static fromStringColor(e){return y.stringToHex(e)}static getGID(e,t){return(e?e[Z]||(e[Z]=$++):0)+"_"+(t?"string"==typeof t?t:t[Z]||(t[Z]=$++):0)}static copyArray(e,t){if(e||(e=[]),!t)return e;e.length=t.length;var r=t.length;for(let s=0;s<r;s++)e[s]=t[s];return e}static parseInt(e,t=0){var r=parseInt(e,t);return isNaN(r)?0:r}static getBaseName(e,t){let r=e.lastIndexOf("/");return-1!=r&&(e=e.substring(r+1)),r=e.indexOf("?"),-1!=r&&(e=e.substring(0,r)),t&&(r=e.lastIndexOf("."),-1!=r&&(e=e.substring(0,r))),e}static getFileExtension(e){let t=e.lastIndexOf(".");if(-1!=t){let r=e.substring(t+1).toLowerCase(),s=r.indexOf("?");if(-1!=s&&(r=r.substring(0,s)),"ls"===r){let s=e.lastIndexOf(".",t-1);if(-1!=s){let i=e.substring(s+1,t+1)+r;if("lanit.ls"===i||"ltcb.ls"===i)return i}}return r}return""}static replaceFileExtension(e,t,r){if(!e)return e;let s=e.lastIndexOf(".");if(t.length>0&&!r&&(t="."+t),-1!=s){let r=e.indexOf("?",s);return-1!=r?e.substring(0,s)+t+e.substring(r):e.substring(0,s)+t}return e+t}static isUUID(e){return e&&e.length>=36&&45===e.charCodeAt(8)&&45===e.charCodeAt(13)}static uint8ArrayToArrayBuffer(t){let r;const s=t.width,i=t.height,a=s*i*4,n=t instanceof z?t.colorFormat:t.getColorFormat();switch(n){case e.RenderTargetFormat.R8G8B8:case e.RenderTargetFormat.R8G8B8A8:r=new Uint8Array(a);break;case e.RenderTargetFormat.R16G16B16A16:r=new Float32Array(a);break;default:throw new Error("uint8ArrayToArrayBuffer is not supported for "+t.format.toString()+"format")}if(f.textureContext.readRenderTargetPixelData(t._renderTarget,0,0,s,i,r),n===e.RenderTargetFormat.R16G16B16A16){const e=r,t=new Uint8Array(a);for(let r=0,s=e.length;r<s;r++)t[r]=Math.min(Math.floor(255*e[r]),255);r=t}const o=r,l=Y.createElement("canvas");l.height=i,l.width=s;const h=l.getContext("2d"),u=h.createImageData(s,i);u.data.set(new Uint8ClampedArray(o)),h.putImageData(u,0,0);const d=l.toDataURL();return Y.removeElement(l),d}static uint8ArrayToArrayBufferAsync(t){let r;const s=t.width,i=t.height,a=s*i*4,n=t instanceof z?t.colorFormat:t.getColorFormat();switch(n){case e.RenderTargetFormat.R8G8B8:case e.RenderTargetFormat.R8G8B8A8:r=new Uint8Array(a);break;case e.RenderTargetFormat.R16G16B16A16:r=new Float32Array(a);break;default:throw"this function is not supported "+t.format.toString()+"format Material"}return t.getDataAsync(0,0,s,i,r).then(()=>{if(n===e.RenderTargetFormat.R16G16B16A16){const e=r,t=new Uint8Array(a);for(let r=0,s=e.length;r<s;r++)t[r]=Math.min(Math.floor(255*e[r]),255);r=t}const t=r,o=Y.createElement("canvas");o.height=i,o.width=s;const l=o.getContext("2d"),h=l.createImageData(s,i);h.data.set(new Uint8ClampedArray(t)),l.putImageData(h,0,0);const u=o.toDataURL();return Y.removeElement(o),Promise.resolve(u)})}static parseTemplate(e,t){let r,s,i,a,n=0,o="";for(;-1!=(r=e.indexOf("{",n));)if(r>0&&92==e.charCodeAt(r-1))o+=e.substring(n,r-1),o+="{",n=r+1;else{if(o+=e.substring(n,r),n=r,r=e.indexOf("}",n),-1==r)break;r!=n+1?(i=e.substring(n+1,r),s=i.indexOf("="),-1!=s?(a=t[i.substring(0,s)],o+=null==a?i.substring(s+1):a):(a=t[i],null!=a&&(o+=a)),n=r+1):(o+=e.substring(n,n+2),n=r+1)}return n<e.length&&(o+=e.substring(n)),o}static sleep(e){return e<1?Promise.resolve():new Promise(t=>setTimeout(t,e))}static until(e,t){return e()?Promise.resolve():new Promise(r=>{let s=performance.now();setTimeout(function i(){e()||null!=t&&performance.now()-s>t?r():setTimeout(i,10)},10)})}static runTasks(e,t,r,s){let i;"number"!=typeof t&&(i=t,t=0);let a=e.length;if(t>=a)return Promise.all(e.map((e,t)=>s&&s.aborted?Promise.reject("aborted"):r(e,t)));const n=new Array(a),o=[];let l=0;function h(){if(l>=a||(null==s?void 0:s.aborted))return Promise.resolve();const u=l++,d=e[u],c=Promise.resolve().then(()=>(null==s?void 0:s.aborted)?Promise.reject("aborted"):r(d,u)).then(e=>{n[u]=e,o.splice(o.indexOf(c),1)});return o.push(c),(i?i(o.length):o.length>=t)?Promise.race(o).then(h):h()}const u=[],d=Math.min(t,a);for(let e=0;e<d;e++)u.push(h());return Promise.all(u).then(()=>o.length>0?Promise.all(o):null).then(()=>n)}static runAllTasks(e,t,r,s){let i;"number"!=typeof t&&(i=t,t=0);let a=e.length;if(t>=a)return Promise.allSettled(e.map((e,t)=>Promise.resolve().then(()=>s&&s.aborted?Promise.reject("aborted"):r(e,t))));const n=new Array(a),o=[];let l=0;function h(){if(l>=a||(null==s?void 0:s.aborted))return Promise.resolve();const u=l++,d=e[u],c=Promise.resolve().then(()=>s&&s.aborted?Promise.reject("aborted"):r(d,u)).then(e=>{n[u]={status:"fulfilled",value:e},o.splice(o.indexOf(c),1)}).catch(e=>{n[u]={status:"rejected",reason:e},o.splice(o.indexOf(c),1)});return o.push(c),(i?i(o.length):o.length>=t)?Promise.race(o).then(h):h()}const u=[],d=Math.min(t,a);for(let e=0;e<d;e++)u.push(h());return Promise.allSettled(u).then(()=>o.length>0?Promise.allSettled(o):null).then(()=>n)}static compareVersion(e,t){let r=e.split("."),s=t.split(".");const i=Math.max(r.length,s.length);for(;r.length<i;)r.push("0");for(;s.length<i;)s.push("0");for(let e=0;e<i;e++){const t=parseInt(r[e]),i=parseInt(s[e]);if(t>i)return 1;if(t<i)return-1}return 0}static testPointInPolygon(e,t,r){var s,i,a,n,o,l=0;o=r.length;for(var h=0;h<o;h+=2){if(s=r[h],i=r[h+1],a=r[(h+2)%o],i!=(n=r[(h+3)%o]))if(!(t<Math.min(i,n)))if(!(t>=Math.max(i,n)))(t-i)*(a-s)/(n-i)+s>e&&l++}return l%2==1}}const Z=Symbol();class J{constructor(){this.uuidMap={},this.shaderNameMap={},this.metaMap={},this.i18nUrlMap={}}UUID_to_URL(e){return this.uuidMap[e]}UUID_to_URL_async(e){return Promise.resolve(null)}URL_to_UUID_async(e){return Promise.resolve(null)}resolveURL(e,t){if(e.startsWith("res://")){let r=e.substring(6);return J.inst.UUID_to_URL_async(r).then(e=>(t&&t(e),e))}return t&&t(e),Promise.resolve(e)}shaderName_to_URL(e){return this.shaderNameMap[e]}shaderName_to_URL_async(e){return Promise.resolve(null)}getMeta(e,t){return Promise.resolve(null)}getSubAssetURL(e,t,r,s){return r?`${Q.replaceFileExtension(e,"")}@${r}.${s}`:e}getI18nSettingsURL(e){return this.i18nUrlMap[e]}}J.inst=new J;class ee{static initMiniGameExtensionOverrides(){p.isPreview||(Object.assign(this.overrideFileExts,this.safeFileExtConversionMap,r.safeFileExtConversionMap),this.hasExtOverrides=!0,this.usingSafeFileExts=!0)}constructor(e){this._url=ee.formatURL(e),this._path=ee.getPath(e)}get url(){return this._url}get path(){return this._path}static get rootPath(){return ee.basePaths["~/"]}static set rootPath(e){ee.basePaths["~/"]=e}static formatURL(e,t){if(!e)return t||ee.basePath||"";if(e.startsWith("res://")){let t=e.substring(6),r=J.inst.UUID_to_URL(t);if(!r)return e;e=r}if(-1==e.indexOf(":")&&47!==e.charCodeAt(0)){let r,s=ee.urlMapping[e];s&&(s.endsWith("wasm.br")&&(s=s.substring(0,s.length-3),r=!0),e=s),null!=ee.customFormat&&(e=ee.customFormat(e));let i=ee.version[e];if(null!=i)if(""==i)e+="?v="+Date.now();else{let t=e.lastIndexOf(".");e=e.substring(0,t)+"-"+i+e.substring(t)}if(r&&(e+=".br"),null==t){t=ee.basePath;for(let r in ee.basePaths)if(e.startsWith(r)){126===r.charCodeAt(0)&&(e=e.substring(r.length)),t=ee.basePaths[r];break}}e=ee.join(t,e)}return e}static postFormatURL(e){if(ee.hasExtOverrides){let t=Q.getFileExtension(e),r=ee.overrideFileExts[t];null!=r&&(e=Q.replaceFileExtension(e,r))}return e}static normalize(e){if(-1==e.indexOf("./"))return e;let t=e.split("/"),r=t.length,s=0;for(;s<r;)if("."!=t[s]){if(".."==t[s]){let e=s-1;if(e>=0&&".."!==t[e]){t.splice(e,2),r-=2,s--;continue}}s++}else t.splice(s,1),r--;return t.length=r,t.join("/")}static getResURLByUUID(e){return Q.isUUID(e)?"res://"+e:e}static join(e,t){if(!t)return"";if(t.indexOf(":")>0)return t;if(e){let r=t.charCodeAt(0);126!==r&&47!==r&&(t=47!==e.charCodeAt(e.length-1)?e+"/"+t:e+t)}return ee.normalize(t)}static getPath(e){var t=e.lastIndexOf("/");return t>0?e.substring(0,t+1):""}static getFileName(e){var t=e.lastIndexOf("/");return t>0?e.substring(t+1):e}static getURLVerion(e){var t=e.indexOf("?");return t>=0?e.substring(t):null}static overrideExtension(e,t,r){if(!r||ee.usingSafeFileExts){for(let r of e)ee.overrideFileExts[r]=t;ee.hasExtOverrides=!0}else for(let r of e)ee.safeFileExtConversionMap[r]=t}}ee.version={},ee.basePath="",ee.basePaths={},ee.urlMapping={},ee.overrideFileExts={},ee.hasExtOverrides=!1,ee.usingSafeFileExts=!1,ee.safeFileExtConversionMap={rendertexture:"rt.json",videotexture:"rt.json",controller:"controller.json",mc:"mc.bin",mcc:"mcc.json",shader:"shader.txt",computeshader:"computeshader.txt",fui:"fui.json",glsl:"glsl.txt",skel:"skel.bin",lavm:"lavm.json",bp:"bp.json",tres:"tres.json",lensflare:"lensflare.json",tex2darray:"tex2darray.json",sco:"sco.json"};class te{constructor(e=0,t=0,r=0,s=0){this.x=e,this.y=t,this.width=r,this.height=s}get right(){return this.x+this.width}set right(e){this.width=e-this.x}get bottom(){return this.y+this.height}set bottom(e){this.height=e-this.y}setTo(e,t,r,s){return this.x=e,this.y=t,this.width=r,this.height=s,this}reset(){return this.x=this.y=this.width=this.height=0,this}recover(){this!=te.TEMP&&this!=te.EMPTY&&h.recover("Rectangle",this.reset())}static create(){return h.getItemByClass("Rectangle",te)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}contains(e,t){return!(this.width<=0||this.height<=0)&&(e>=this.x&&e<this.right&&t>=this.y&&t<this.bottom)}intersects(e){return!(e.x>this.x+this.width||e.x+e.width<this.x||e.y>this.y+this.height||e.y+e.height<this.y)}intersection(e,t){if(!this.intersects(e))return null;let r=Math.max(this.x,e.x),s=Math.max(this.y,e.y),i=Math.min(this.right,e.right)-r,a=Math.min(this.bottom,e.bottom)-s;return t||(t=new te),t.setTo(r,s,i,a)}union(e,t){let r=e.x,s=e.y,i=e.width,a=e.height;return t||(t=new te),this.cloneTo(t),i<=0||a<=0?t:this.width<=0||this.height<=0?t.setTo(r,s,i,a):(t.addPoint(r,s),t.addPoint(r+i,s+a),t)}scale(e,t){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}transform(e,t){let r=e.a,s=e.b,i=e.c,a=e.d,n=e.tx,o=e.ty,l=this.x,h=this.y,u=l+this.width,d=h+this.height,c=l*r,_=u*r,p=h*i,g=d*i,m=l*s,f=u*s,T=h*a,y=d*a,x=Math.min(c+p,c+g,_+p,_+g),S=Math.max(c+p,c+g,_+p,_+g),E=Math.min(m+T,m+y,f+T,f+y),v=Math.max(m+T,m+y,f+T,f+y);return t||(t=new te),t.setTo(x+n,E+o,S-x,v-E)}toString(){return this.x+","+this.y+","+this.width+","+this.height}equals(e){return!(!e||e.x!==this.x||e.y!==this.y||e.width!==this.width||e.height!==this.height)}addPoint(e,t){return this.x>e&&(this.width+=this.x-e,this.x=e),this.y>t&&(this.height+=this.y-t,this.y=t),this.width<e-this.x&&(this.width=e-this.x),this.height<t-this.y&&(this.height=t-this.y),this}getBoundPoints(e){return e=e||[],0==this.width||0==this.height||e.push(this.x,this.y,this.x+this.width,this.y,this.x,this.y+this.height,this.x+this.width,this.y+this.height),e}static _getWrapRec(e,t){if(t=t||new te,!e||e.length<1)return t.setTo(0,0,0,0);let r,s,i,a,n,o=e.length;for(s=a=99999,i=n=-s,r=0;r<o;r+=2){let t=e[r],o=e[r+1];s=s<t?s:t,a=a<o?a:o,i=i>t?i:t,n=n>o?n:o}return t.setTo(s,a,i-s,n-a)}static minMaxRect(e,t,r,s,i){return(i=i||new te).setTo(e,t,r-e,s-t)}isEmpty(){return this.width<=0||this.height<=0}clone(e){return e||(e=new te),this.cloneTo(e),e}cloneTo(e){e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height}}te.EMPTY=new te,te.TEMP=new te;const re=new te,se=new te;class ie extends G{static create(e,t,r,s,i,a=0,n=0,o=0,l=0,h=!1){return ie._create(e,t,r,s,i,a,n,o,l,h)}static _create(e,t,r,s,i,a=0,n=0,o=0,l=0,h=!1,u=null){var d,c=e instanceof ie,_=c?e.uv:ie.DEF_UV,p=c?e.bitmap:e;p.width&&t+s>p.width&&(s=p.width-t),p.height&&r+i>p.height&&(i=p.height-r),u?(d=u).setTo(p,null,o||s,l||i):d=new ie(p,null,o||s,l||i),d.width=s,d.height=i,d.offsetX=a,d.offsetY=n;var g=1/p.width,m=1/p.height;t*=g,r*=m,s*=g,i*=m;var f=d.uv[0],T=d.uv[1],y=d.uv[4],x=d.uv[5],S=y-f,E=x-T,v=function(e,t,r){for(var s=0;s<8;s+=2)r[s]+=e,r[s+1]+=t;return r}(_[0],_[1],[t,r,t+s,r,t+s,r+i,t,r+i]);d.uv=new Float32Array([f+v[0]*S,T+v[1]*E,y-(1-v[2])*S,T+v[3]*E,y-(1-v[4])*S,x-(1-v[5])*E,f+v[6]*S,x-(1-v[7])*E]);var D=e.scaleRate;return D&&1!=D?(d.sourceWidth/=D,d.sourceHeight/=D,d.width/=D,d.height/=D,d.scaleRate=D,d.offsetX/=D,d.offsetY/=D):d.scaleRate=1,h&&(d._rotate=!0,d._rotateTexture(!0)),d}static createFromTexture(e,t,r,s,i){var a=e.scaleRate;1!=a&&(t*=a,r*=a,s*=a,i*=a);var n=te.TEMP.setTo(t-e.offsetX,r-e.offsetY,s,i),o=n.intersection(re.setTo(0,0,e.width,e.height),se);if(o){let t=ie.create(e,o.x,o.y,o.width,o.height,o.x-n.x,o.y-n.y,s,i);return t._sizeGrid=e._sizeGrid,t._atlas=e._atlas,t}return null}get uv(){return this._uv}set uv(e){this.uvrect[0]=Math.min(e[0],e[2],e[4],e[6]),this.uvrect[1]=Math.min(e[1],e[3],e[5],e[7]),this.uvrect[2]=Math.max(e[0],e[2],e[4],e[6])-this.uvrect[0],this.uvrect[3]=Math.max(e[1],e[3],e[5],e[7])-this.uvrect[1],this._uv=e}get width(){return this._w?this._w:this.bitmap?this.uv&&this.uv!==ie.DEF_UV?(this.uv[2]-this.uv[0])*this.bitmap.width:this.bitmap.width:0}set width(e){this._w=e,this.sourceWidth||(this.sourceWidth=e)}get height(){return this._h?this._h:this.bitmap?this.uv&&this.uv!==ie.DEF_UV?(this.uv[5]-this.uv[1])*this.bitmap.height:this.bitmap.height:0}set height(e){this._h=e,this.sourceHeight||(this.sourceHeight=e)}get bitmap(){return this._bitmap}set bitmap(e){this._bitmap!=e&&(this._bitmap&&this._bitmap._removeReference(this._referenceCount),this._bitmap=e,e&&e._addReference(this._referenceCount))}get rotate(){return this._rotate}set rotate(e){e!=this._rotate&&this._rotateTexture(e),this._rotate=e}_rotateTexture(e){let t=new Float32Array(8);e?(t[0]=this._uv[2],t[1]=this._uv[3],t[2]=this._uv[4],t[3]=this._uv[5],t[4]=this._uv[6],t[5]=this._uv[7],t[6]=this._uv[0],t[7]=this._uv[1]):(t[2]=this._uv[0],t[3]=this._uv[1],t[4]=this._uv[2],t[5]=this._uv[3],t[6]=this._uv[4],t[7]=this._uv[5],t[0]=this._uv[6],t[1]=this._uv[7]),this.uv=t;let r=this._h;this._h=this._w,this._w=r}constructor(e=null,t=null,r=0,s=0){super(!1),this.uvrect=[0,0,1,1],this._w=0,this._h=0,this.offsetX=0,this.offsetY=0,this.sourceWidth=0,this.sourceHeight=0,this.scaleRate=1,this._dynamic=null,this._rotate=!1;let i=e instanceof ie?e.bitmap:e;this.setTo(i,t,r,s)}_addReference(e=1){var t,r;super._addReference(e),null===(t=this._bitmap)||void 0===t||t._addReference(e),null===(r=this._atlas)||void 0===r||r._addReference(e)}_removeReference(e=1){var t,r;null===(t=this._bitmap)||void 0===t||t._removeReference(e),null===(r=this._atlas)||void 0===r||r._removeReference(e),super._removeReference(e)}_getSource(e=null){return this._destroyed||!this._bitmap?null:(this.recoverBitmap(e),this._bitmap.destroyed?null:this.bitmap._getSource())}setTo(e=null,t=null,r=0,s=0){this.bitmap=e,this.sourceWidth=r,this.sourceHeight=s,e&&(this._w=e.width,this._h=e.height,this.sourceWidth=this.sourceWidth||e.width,this.sourceHeight=this.sourceHeight||e.height),this.uv=t||ie.DEF_UV}load(e,t){return this._destroyed?Promise.resolve():l.loader.load(e).then(e=>{let r=e.bitmap;this.bitmap=r,this.sourceWidth=this._w=r.width,this.sourceHeight=this._h=r.height,t&&t.run(),this.event(c.READY,this)})}getTexturePixels(e,t,r,s){var i,a,n=this.bitmap,o=this._w,l=this._h,h=this.sourceWidth,u=this.sourceHeight,d=n.width,c=n.height,_=this.offsetX,p=this.offsetY;let g=r,m=s;if(e+r>o+_&&(g-=e+r-o-_),e+r>h&&(r-=e+r-h),t+s>l+p&&(m-=t+s-l-p),t+s>u&&(s-=t+s-u),r<=0||s<=0)return null;let f=_>e?_-e:0,T=p>t?p-t:0,y=e>_?e-_:0,x=t>p?t-p:0;g-=f,m-=T;var S=4*r,E=null;try{E=n.getPixels()}catch(e){}if(E){if(0==e&&0==t&&r==d&&s==c)return E;let n=this._uv.slice(),o=Math.round(n[0]*d),l=Math.round(n[1]*c);var v=new Uint8Array(r*s*4);for(i=4*o+4*y+(l+x)*(S=4*d),a=0;a<m;a++)v.set(E.slice(i,i+4*g),4*r*(a+T)+4*f),i+=S;return v}return v}getPixels(e,t,r,s){return this.getTexturePixels(e,t,r,s)}recoverBitmap(e){var t,r=null===(t=this._bitmap)||void 0===t?void 0:t.url;this._destroyed||this._bitmap&&!this._bitmap.destroyed||!r||l.loader.load(r,"image").then(t=>{!this._destroyed&&t&&t.bitmap&&(this.bitmap=t.bitmap),e&&e()})}disposeBitmap(){if(!this.destroyed){if(this._dynamic){let e=this._dynamic.source;this._dynamic.recover(),e&&e.destroy()}else this._bitmap&&this._bitmap.destroy();this.event(c.CHANGE)}}get valid(){return!this._destroyed&&this._bitmap&&!this._bitmap.destroyed}get obsolute(){return this._obsolute||!this._bitmap||this._bitmap.destroyed||this._bitmap.obsolute}set obsolute(e){this._obsolute=e}_disposeResource(){let e=this._bitmap;this._bitmap=null,e&&e._removeReference(this._referenceCount);let t=this._atlas;this._atlas=null,t&&t._removeReference(this._referenceCount)}getCachedClip(e,t,r,s){if(this.destroyed)return null;let i=`${e}_${t}_${r}_${s}`;this._clipCache||(this._clipCache=new Map);let a=this._clipCache.get(i);return a||(a=ie.createFromTexture(this,e,t,r,s),this._clipCache.size>100&&this._clipCache.clear(),this._clipCache.set(i,a),a)}}ie.DEF_UV=new Float32Array([0,0,1,0,1,1,0,1]),ie.NO_UV=new Float32Array([0,0,0,0,0,0,0,0]),ie.INV_UV=new Float32Array([0,1,1,1,1,0,0,0]);class ae{static enable(e,t=null){l.loader.fetch(e,"json").then(e=>{e&&(ae.addAtlases(e),t&&t.run())})}static addAtlases(e){let t=ae._fileLoadDic;for(let r in e){let s=e[r],i=ee.formatURL(s[0]),a=s[1],n=a.length,o={url:r};for(let e=0;e<n;e++)t[i+a[e]]=o}}static addAtlas(e,t,r,s){t=ee.formatURL(t),null==s&&(s=!0);let i=ae._fileLoadDic,a={url:e};for(let e of r){let r=t+e;!s&&i[r]||(i[r]=a)}}static getFileLoadPath(e){return ae._fileLoadDic[e]}}ae._fileLoadDic={};class ne{static workerSupported(){return!!Worker}static get enable(){return ne._enable}static set enable(e){if(ne._enable!=e){if(e){if(!Worker)return;ne._worker||(ne._worker=new Worker(r.workerLoaderLib||ne.workerPath),ne._worker.onmessage=ne.workerMessage)}ne._enable=e}}static load(e,t){try{e=new URL(e,document.baseURI).href}catch(e){}let r=ne._queue[e];return r?new Promise((e,t)=>{r.push(e,t)}):(ne._queue[e]=r=[],new Promise((s,i)=>{r.push(s,i),ne._worker.postMessage({url:e,options:t})}))}static workerMessage(e){let t=e.data;if(t&&"Image"===t.type){let e=ne._queue[t.url];if(e){delete ne._queue[t.url];let r=t.imageBitmap?t.imageBitmap:t.msg;for(let s=t.imageBitmap?0:1;s<e.length;s+=2)e[s](r)}}}}ne.workerPath="libs/laya.workerloader.js",ne._enable=!1,ne._queue={};class oe extends G{constructor(e,t,r){super(),this.dir=e,this.textures=t,this.frames=r;for(let e of r)e._addReference(),e._atlas=this;for(let e of t)e._addReference(),e._atlas=this}update(e,t){this._disposeResource(),this.textures.push(...e),this.frames.push(...t);for(let e of t)e._addReference(),e._atlas=this;for(let t of e)t._addReference(),t._atlas=this}_disposeResource(){for(let e of this.textures)e._atlas=null,e._removeReference();for(let e of this.frames)e._atlas=null,e._removeReference();this.frames.length=0,this.textures.length=0}}class le{constructor(e){this._callback=e,this._items=[],this._weights=[],this._progress=0}get itemCount(){return this._items.length}reset(){this._items.length=0,this._weights.length=0,this._progress=0}createCallback(e){let t=this._items.length;return this._items.push(0),null==e?this._weights.push(null):this._weights.push(Math.max(0,Math.min(e,1))),e=>this.update(t,e)}update(e,t){if(-1!=e){this._items[e]=Math.max(0,Math.min(t,1));let r=0,s=this._items,i=this._weights,a=1/s.length;for(let e=0;e<s.length;e++){let t=s[e],n=i[e];null!=t&&(r+=t*(null!=n?n:a))}(t=r)>1&&(t=1)}t>this._progress&&(this._progress=t,this._callback(t))}}class he{constructor(e=null,t=null,r=null,s=!1){this.once=!1,this._id=0,this.setTo(e,t,r,s)}setTo(e,t,r,s=!1){return this._id=he._gid++,this.caller=e,this.method=t,this.args=r,this.once=s,this}run(){if(null==this.method)return null;var e=this._id,t=this.method.apply(this.caller,this.args);return this._id===e&&this.once&&this.recover(),t}runWith(e){if(null==this.method)return null;var t=this._id;if(null==e)var r=this.method.apply(this.caller,this.args);else r=this.args||e.unshift?this.args?this.method.apply(this.caller,this.args.concat(e)):this.method.apply(this.caller,e):this.method.call(this.caller,e);return this._id===t&&this.once&&this.recover(),r}clear(){return this.caller=null,this.method=null,this.args=null,this}recover(){this._id>0&&(this._id=0,he._pool.push(this.clear()))}static create(e,t,r=null,s=!0){return he._pool.length?he._pool.pop().setTo(e,t,r,s):new he(e,t,r,s)}}he._pool=[],he._gid=1;class ue{static decodeString(e){let t=e.length,r="",s=0,i=0;for(;;){if(i=e.indexOf("&",s),-1==i){r+=e.substring(s);break}r+=e.substring(s,i),s=i+1,i=s;let a=Math.min(t,i+10);for(;i<a&&";"!=e[i];i++);if(i<a&&i>s){let t=e.substring(s,i),a=0;if("#"==t[0])t.length>1?(a="x"==t[1]?parseInt(t.substring(2),16):parseInt(t.substring(1)),r+=String.fromCharCode(a),s=i+1):r+="&";else{switch(t){case"amp":a=38;break;case"apos":a=39;break;case"gt":a=62;break;case"lt":a=60;break;case"nbsp":a=32;break;case"quot":a=34}a>0?(r+=String.fromCharCode(a),s=i+1):r+="&"}}else r+="&"}return r}static encodeString(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")}static getString(e,t,r){if(null==e)return null==r?null:r;let s=e[t];return null!=s?""+s:null==r?null:r}static getInt(e,t,r){let s=this.getString(e,t);if(null!=s&&s.length>0)if("%"==s[s.length-1]){let e=parseInt(s.substring(0,s.length-1));if(!isNaN(e))return Math.ceil(e/100*r)}else{let e=parseInt(s);if(!isNaN(e))return e}return null==r?0:r}static getFloat(e,t,r){let s=this.getString(e,t);if(null==s||0==s.length)return null==r?0:r;let i=parseFloat(s);return isNaN(i)?null==r?0:r:i}static getBool(e,t,r){let s=this.getString(e,t);return null==s||0==s.length?null!=r&&r:"true"==s||"1"==s||"false"!=s&&"0"!=s&&(null!=r&&r)}}var de;e.XMLTagType=void 0,(de=e.XMLTagType||(e.XMLTagType={}))[de.Start=0]="Start",de[de.End=1]="End",de[de.Void=2]="Void",de[de.CDATA=3]="CDATA",de[de.Comment=4]="Comment",de[de.Instruction=5]="Instruction";class ce{static begin(e,t){ce.source=e,ce.lowerCaseName=t,this.sourceLen=e.length,this.parsePos=0,this.lastTagEnd=0,this.tagPos=0,this.tagLength=0,this.tagName=null}static nextTag(){let t,r,s="";for(this.tagType=e.XMLTagType.Start,this.lastTagEnd=this.parsePos,this.attrParsed=!1,this.lastTagName=this.tagName;-1!=(t=this.source.indexOf("<",this.parsePos))&&(this.parsePos=t,t++,t!=this.sourceLen);){if(r=this.source[t],"!"==r){if(this.sourceLen>t+7&&"<![CDATA["==this.source.substring(t-1,t+8))return t=this.source.indexOf("]]>",t),this.tagType=e.XMLTagType.CDATA,this.tagName="",this.tagPos=this.parsePos,this.tagLength=-1==t?this.sourceLen-this.parsePos:t+3-this.parsePos,this.parsePos+=this.tagLength,!0;if(this.sourceLen>t+2&&"\x3c!--"==this.source.substring(t-1,t+3))return t=this.source.indexOf("--\x3e",t),this.tagType=e.XMLTagType.Comment,this.tagName="",this.tagPos=this.parsePos,this.tagLength=-1==t?this.sourceLen-this.parsePos:t+3-this.parsePos,this.parsePos+=this.tagLength,!0;t++,this.tagType=e.XMLTagType.Instruction}else"/"==r?(t++,this.tagType=e.XMLTagType.End):"?"==r&&(t++,this.tagType=e.XMLTagType.Instruction);for(;t<this.sourceLen&&(r=this.source[t],-1==" \t\n\r\v".indexOf(r)&&">"!=r&&"/"!=r);t++);if(t==this.sourceLen)break;s+=this.source.substring(this.parsePos+1,t),s.length>0&&"/"==s[0]&&(s=s.substring(1));let i=!1,a=!1,n=-1;for(;t<this.sourceLen;t++)if(r=this.source[t],'"'==r?i||(a=!a):"'"==r&&(a||(i=!i)),">"==r){if(!i&&!a){n=-1;break}n=t}else if("<"==r)break;if(-1!=n&&(t=n),t==this.sourceLen)break;return"/"==this.source[t-1]&&(this.tagType=e.XMLTagType.Void),this.tagName=s,this.lowerCaseName&&(this.tagName=this.tagName.toLowerCase()),this.tagPos=this.parsePos,this.tagLength=t+1-this.parsePos,this.parsePos+=this.tagLength,!0}return this.tagPos=this.sourceLen,this.tagLength=0,this.tagName=null,!1}static getTagSource(){return this.source.substring(this.tagPos,this.tagPos+this.tagLength)}static getRawText(e){if(this.lastTagEnd==this.tagPos)return"";if(e){let e=this.lastTagEnd;for(;e<this.tagPos;e++){let t=this.source[e];if(-1==" \t\n\r\v".indexOf(t))break}return e==this.tagPos?"":this.source.substring(e,this.tagPos).trim()}return this.source.substring(this.lastTagEnd,this.tagPos)}static getText(e){if(this.lastTagEnd==this.tagPos)return"";if(e){let e=this.lastTagEnd;for(;e<this.tagPos;e++){let t=this.source[e];if(-1==" \t\n\r\v".indexOf(t))break}return e==this.tagPos?"":ue.decodeString(this.source.substring(e,this.tagPos)).trimEnd()}return ue.decodeString(this.source.substring(this.lastTagEnd,this.tagPos))}static get attributes(){if(!this.attrParsed){for(let e in this._attrs)delete this._attrs[e];this.parseAttributes(this._attrs),this.attrParsed=!0}return this._attrs}static getAttribute(e){return this.attributes[e]}static parseAttributes(e){let t,r=0,s=0,i=!1,a=0,n="",o=this.tagPos,l=this.tagPos+this.tagLength;if(o<l&&"<"==this.source[o])for(;o<l;o++){let e=this.source[o];if(-1!=" \t\n\r\v".indexOf(e)||">"==e||"/"==e)break}for(;o<l;o++){let h=this.source[o];if("="==h){r=-1,s=-1,a=0;for(let e=o+1;e<l;e++){let t=this.source[e];if(-1!=" \t\n\r\v".indexOf(t)){if(-1!=r&&0==a){s=e-1;break}}else if(">"==t){if(0==a){s=e-1;break}}else if('"'==t)if(-1!=r){if(1!=a){s=e-1;break}}else a=2,r=e+1;else if("'"==t)if(-1!=r){if(2!=a){s=e-1;break}}else a=1,r=e+1;else-1==r&&(r=e)}if(-1==r||-1==s)break;t=n,this.lowerCaseName&&(t=t.toLowerCase()),n="",e[t]=ue.decodeString(this.source.substring(r,s+1)),o=s+1}else-1==" \t\n\r\v".indexOf(h)?((i||"/"==h||">"==h)&&(n.length>0&&(t=n,this.lowerCaseName&&(t=t.toLowerCase()),e[t]="",n=""),i=!1),"/"!=h&&">"!=h&&(n+=h)):n.length>0&&(i=!0)}}}ce._attrs={},String.prototype.trimEnd||(String.prototype.trimEnd=function(){return this.replace(/\s+$/g,"")});class _e{constructor(e){e&&this.parse(e)}get attributes(){return this._attrs||(this._attrs={}),this._attrs}getAttrString(e,t){return ue.getString(this._attrs,e,t)}getAttrInt(e,t){return ue.getInt(this._attrs,e,t)}getAttrFloat(e,t){return ue.getFloat(this._attrs,e,t)}getAttrBool(e,t){return ue.getBool(this._attrs,e,t)}setAttribute(e,t){this._attrs||(this._attrs={}),this._attrs[e]=t}getNode(e){return this._children?this._children.find(t=>t.name==e):null}elements(e){return this._children||(this._children=new Array),e?this._children.filter(t=>t.name==e):this._children}parse(t){let r;this.reset();let s=new Array;for(ce.begin(t);ce.nextTag();)if(ce.tagType==e.XMLTagType.Start||ce.tagType==e.XMLTagType.Void){let t;if(r)t=new _e;else{if(null!=this.name)throw this.reset(),new Error("Invalid xml format - no root node.");t=this}t.name=ce.tagName,t._attrs=Object.assign({},ce.attributes),r&&(ce.tagType!=e.XMLTagType.Void&&s.push(r),null==r._children&&(r._children=new Array),r._children.push(t)),ce.tagType!=e.XMLTagType.Void&&(r=t)}else if(ce.tagType==e.XMLTagType.End){if(null==r||r.name!=ce.tagName)throw this.reset(),new Error("Invalid xml format - <"+ce.tagName+"> dismatched.");null!=r._children&&0!=r._children.length||(r.text=ce.getText()),r=s.length>0?s.pop():null}}reset(){this._attrs=null,null!=this._children&&this._children.length,this.text=null}}class pe extends N{constructor(){super(...arguments),this._http=new XMLHttpRequest}send(e,t=null,r="get",s="text",i){this._responseType=s,this._data=null,this._url=e;let a=this._http;a.open(r,e,!0);let n=i&&-1!==i.indexOf("Content-Type");if(t?"string"==typeof t?n||a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"):(n||a.setRequestHeader("Content-Type","application/json"),t instanceof ArrayBuffer||(t=JSON.stringify(t))):Y.onBLMiniGame&&Y.onAndroid&&(t={}),i)for(let e=0;e<i.length;e++)a.setRequestHeader(i[e++],i[e]);let o="arraybuffer"!==s?"text":"arraybuffer";a.responseType=o,a.dataType&&(a.dataType=o),a.onerror=e=>this._onError(e),a.onabort=e=>this._onAbort(e),a.onprogress=e=>this._onProgress(e),a.onload=e=>this._onLoad(e),a.send(t)}_onProgress(e){e&&e.lengthComputable&&this.event(c.PROGRESS,e.loaded/e.total)}_onAbort(e){this.error("Request was aborted by user")}_onError(e){this.error("Request failed Status:"+this._http.status+" text:"+this._http.statusText)}_onLoad(e){var t=this._http,r=void 0!==t.status?t.status:200;200===r||204===r||0===r?this.complete():this.error("["+t.status+"]"+t.statusText+":"+t.responseURL)}error(e){this.clear(),this.event(c.ERROR,e)}complete(){this.clear();var e=!0;try{"json"===this._responseType?this._data=JSON.parse(this._http.responseText):"xml"===this._responseType?this._data=new _e(this._http.responseText):this._data=this._http.response||this._http.responseText}catch(t){e=!1,this.error(t.message)}e&&this.event(c.COMPLETE,this._data instanceof Array?[this._data]:this._data)}clear(){var e=this._http;e.onerror=e.onabort=e.onprogress=e.onload=null}get url(){return this._url}get data(){return this._data}get http(){return this._http}reset(){this.offAll(),this._data=null}}class ge{constructor(){this.httpRequestPool=[]}common(e,t,r,s,i,a){let n=this.getRequestInst();n.on(c.COMPLETE,()=>{let e=n.data;this.returnRequestInst(n),a(e)}),n.on(c.ERROR,null,e=>{this.returnRequestInst(n),a(null,e)}),i&&n.on(c.PROGRESS,i),n.send(t,null,"get",s),e.$ref=n}image(e,t,r,s,i){let a=new Y.window.Image;a.crossOrigin="",a.onload=()=>{a.onload=null,a.onerror=null,i(a)},a.onerror=()=>{a.onload=null,a.onerror=null,i(null,"")},a.src=t,e.$ref=a}imageWithBlob(e,t,r,s,i){let a=W.browser.createBufferURL(t);a?this.image(e,a,r,s,i):i(null,"Blob URL creation not supported.")}imageWithWorker(e,t,r,s,i){ne.enable=!0,ne.enable?ne.load(t,e.workerLoaderOptions).then(i).catch(e=>i(null,e)):this.image(e,t,r,s,i)}audio(e,t,r,s,i){let a=Y.createElement("audio");a.crossOrigin="",a.oncanplaythrough=()=>{a.oncanplaythrough=null,a.onerror=null,i(a)},a.onerror=()=>{a.oncanplaythrough=null,a.onerror=null,i(null,"")},a.src=t,e.$ref=a}package(e,t,r){r(null)}getRequestInst(){return 0==this.httpRequestPool.length||Y.onVVMiniGame||Y.onHWMiniGame?new pe:this.httpRequestPool.pop()}returnRequestInst(e){e.reset(),this.httpRequestPool.length<10&&this.httpRequestPool.push(e)}}var me=0;const fe={ext:null,typeId:null,main:!1,loaderType:null};class Te extends N{static registerLoader(e,t,r,s){let i;r?(i=Te.typeMap[r],i?i.loaderType!=t&&(i={typeId:i.typeId,loaderType:t}):Te.typeMap[r]=i={typeId:me++,loaderType:t}):i={typeId:me++,loaderType:t},s&&(Te.hotReloadableFlags[i.typeId]=!0);for(let s of e){let e=Te.extMap[s];if(e&&r){let r=e.findIndex(e=>e.typeId==i.typeId);-1===r?e.push(i):e[r].loaderType=t}else Te.extMap[s]=[i]}}constructor(){super(),this.retryNum=1,this.retryDelay=0,this.maxLoader=5,this._loadings=new Map,this._queue=[],this._downloadings=new Set}get loading(){return this._loadings.size>0}load(e,t,r,s,i,a,n,o,l){let h,u,d,c,_=Se;if(t instanceof he?(h=t,u=s):"string"==typeof t?u=t:null!=t&&(u=t.type,_=t),null==i&&null==a&&null==o&&null==n&&null==l||(_=_===Se?{priority:i,cache:a,ignoreCache:o,group:n,useWorkerLoader:l}:Object.assign(_,{priority:i,cache:a,ignoreCache:o,group:n,useWorkerLoader:l})),!1===_.cache&&null==_.ignoreCache&&(_.ignoreCache=!0),d=r instanceof he?e=>r.runWith(e):r,Array.isArray(e)){let t;d&&(t=new le(d));let r=[];for(let s=0;s<e.length;s++){let i=e[s];i&&("string"==typeof i?r.push(this._load1(i,u,_,null==t?void 0:t.createCallback())):r.push(this._load1(i.url,i.type||u,_!==Se?Object.assign({},_,i):i,null==t?void 0:t.createCallback())))}c=Promise.all(r)}else c="string"==typeof e?this._load1(e,u,_,d):this._load1(e.url,e.type||u,_!==Se?Object.assign({},_,e):e,d);return h?c.then(e=>(h.runWith(e),e)):c}_load1(e,t,r,s){if(p.isPreview){if(e.startsWith("res://")){let i=e.substring(6);return J.inst.UUID_to_URL_async(i).then(a=>{var n;return a?this._load2(a,i,t,r,s):(!r.silent&&Te.warnFailed(e,void 0,null===(n=r.initiator)||void 0===n?void 0:n.url),Promise.resolve(null))})}return J.inst.URL_to_UUID_async(e).then(i=>this._load2(e,i,t,r,s))}return this._load2(e,null,t,r,s)}_load2(t,r,s,i,a){var n,o;let{ext:l,typeId:h,main:u,loaderType:d}=Te.getURLInfo(t,s,i.maybeType);if(!d)return!i.silent&&Te.warnFailed(t,s?`unsupported load type:${s}`:t.startsWith("res://")?"":"unsupported suffix",null===(n=i.initiator)||void 0===n?void 0:n.url),Promise.resolve(null);let _,p=ee.formatURL(t);if(i.group){let e=Te.groupMap[i.group];e||(e=Te.groupMap[i.group]=new Set),e.add(p)}if(!i.ignoreCache){let e=Te._getRes(p,s);if(void 0!==e){if(null==e)return Promise.resolve(null);if(!(e instanceof G))return Promise.resolve(e);if(e.obsolute&&(_=e),!(_||e.uuid&&r&&r!=e.uuid))return Promise.resolve(e)}}let g=p;u||(g+="@"+h);let m=this._loadings.get(g);if(m){let e=i.initiator;for(;e;){if(e===m)return Promise.resolve();e=e.options.initiator}return null!=m.result?m.result:(a&&m.onProgress.add(a),new Promise(e=>m.onComplete.add(e)))}let T=ae.getFileLoadPath(p);if(T)return this.load(T.url,{type:Te.ATLAS,baseUrl:T.baseUrl}).then(()=>Te.getRes(t,s));m=xe.length>0?xe.pop():new ye,m.type=s,m.url=t,m.uuid=r,m.ext=l,delete(i=Object.assign(m.options,i)).type,null==i.priority&&(i.priority=0),null==i.useWorkerLoader&&(i.useWorkerLoader=ne.enable),a&&m.onProgress.add(a),m.loader=this,m.obsoluteInst=_;let y,x=new d;this._loadings.set(g,m);let S=performance.now();try{f.statAgent.recordCountData(e.StatElement.C_LoadResourceCount,1),y=x.load(m)}catch(e){!i.silent&&Te.warnFailed(t,e,null===(o=i.initiator)||void 0===o?void 0:o.url),y=Promise.resolve(null)}return y.then(s=>(f.statAgent.recordTimeData(e.StatElement.T_LoadResourceTime,performance.now()-S),s instanceof G&&(s.obsolute=!1,s._setCreateURL(t,r)),!1!==m.options.cache&&Te._cacheRes(p,s,h,u),null!=s&&null!=x.postLoad?(m.result=s,x.postLoad(m,s).then(()=>(m.progress.update(-1,1),m.onComplete.invoke(s),s))):(m.progress.update(-1,1),m.onComplete.invoke(s),s))).catch(e=>{var r;return!i.silent&&Te.warnFailed(t,e,null===(r=i.initiator)||void 0===r?void 0:r.url),!1!==m.options.cache&&Te._cacheRes(p,null,h,u),m.onComplete.invoke(null),null}).then(e=>(this._loadings.delete(g),m.reset(),xe.push(m),0==this._loadings.size&&this.event(c.COMPLETE),e))}fetch(e,t,r,s){var i;let a={originalUrl:e,url:e,contentType:t,priority:null!==(i=(s=s||Se).priority)&&void 0!==i?i:1,retryCnt:0,onProgress:r,onComplete:null};return s.useWorkerLoader&&(a.useWorkerLoader=!0,a.workerLoaderOptions=s.workerLoaderOptions),s.blob&&(a.blob=s.blob),s.noRetry&&(a.retryCnt=-1),s.silent&&(a.silent=!0),J.inst.resolveURL(e).then(e=>e?new Promise(t=>{a.url=ee.formatURL(e),a.onComplete=t,this.queueToDownload(a)}):null)}queueToDownload(e){if(this._downloadings.size<this.maxLoader)return void this.download(e);let t=e.priority;if(0==t)this._queue.push(e);else{let r=this._queue.findIndex(e=>e.priority<t);-1!=r?this._queue.splice(r,0,e):this._queue.push(e)}}download(t){this._downloadings.add(t),f.statAgent.recordCountData(e.StatElement.C_LoadRequestCount,1),t.startTime=performance.now();let r=ee.postFormatURL(t.url);if("image"==t.contentType){let e=Te.preLoadedMap[t.url];if(e){if(!(e instanceof ArrayBuffer))return void this.completeItem(t,e);t.blob=e}t.blob?Te.downloader.imageWithBlob(t,t.blob,t.originalUrl,t.onProgress,(e,r)=>{e||(t.retryCnt=-1),this.completeItem(t,e,r)}):t.useWorkerLoader?Te.downloader.imageWithWorker(t,r,t.originalUrl,t.onProgress,(e,r)=>{e||(t.useWorkerLoader=!1,t.silent||Te.warnFailed(t.url,r)),this.completeItem(t,e,r)}):Te.downloader.image(t,r,t.originalUrl,t.onProgress,(e,r)=>this.completeItem(t,e,r))}else if("sound"==t.contentType)Te.downloader.audio(t,r,t.originalUrl,t.onProgress,(e,r)=>this.completeItem(t,e,r));else{let e=Te.preLoadedMap[t.url];if(e)return void this.completeItem(t,e);Te.downloader.common(t,r,t.originalUrl,t.contentType,t.onProgress,(e,r)=>this.completeItem(t,e,r))}}completeItem(t,r,s){this._downloadings.delete(t),f.statAgent.recordTimeData(e.StatElement.T_LoadRequestTime,performance.now()-t.startTime),r?(this._downloadings.size<this.maxLoader&&this._queue.length>0&&this.download(this._queue.shift()),t.onProgress&&t.onProgress(1),t.onComplete(r)):-1!=t.retryCnt&&t.retryCnt<this.retryNum?(t.retryCnt++,t.silent||console.debug(`Retry to load ${t.url} (${t.retryCnt})`),l.systemTimer.once(this.retryDelay,this,this.queueToDownload,[t],!1)):(!t.silent&&Te.warnFailed(t.url,s),t.onProgress&&t.onProgress(1),this._downloadings.size<this.maxLoader&&this._queue.length>0&&this.download(this._queue.shift()),t.onComplete(null))}static getURLInfo(e,t,r){let s,i,a,n,o=e.startsWith("data:")?"png":Q.getFileExtension(e);if(o.length>0&&(s=Te.extMap[o]),s||t||(t=r),t){let e=Te.typeMap[t];if(!e)return fe;i=e.typeId;let r=0;s?s[0].typeId===i||-1!=(r=s.findIndex(e=>e.typeId===i))?(a=0===r,n=s[r].loaderType):(a=!1,n=e.loaderType):(a=t!=Te.TEXTURE2D,n=e.loaderType)}else{if(!s)return fe;a=!0,i=s[0].typeId,n=s[0].loaderType}return{ext:o,main:a,typeId:i,loaderType:n}}static warnFailed(e,t,r){r?this.warn(`Failed to load '${e}' (in '${r}')`,t):this.warn(`Failed to load '${e}'`,t)}static warn(e,t){t?console.warn(e,t):console.warn(e)}static getRes(e,t){return e=ee.formatURL(e),Te._getRes(e,t)||null}static _getRes(e,t){let r,s=Te.loadedMap[e];if(s){if(t){let e=Te.typeMap[t];if(!e)return;if(2==s.length)s[0]==e.typeId&&(r=s[1]);else{let t=s.indexOf(e.typeId);-1!=t&&(r=s[t+1])}}else r=s[1];return r instanceof G&&r.destroyed?void 0:r}}static getTexture2D(e){return Te.getRes(e,Te.TEXTURE2D)}static getBaseTexture(e){return Te.getRes(e,Te.TEXTURE2D)}static getAtlas(e){return Te.getRes(e,Te.ATLAS)}getRes(e,t){return Te.getRes(e,t)}static createNodes(e){var t;return null===(t=Te.getRes(e))||void 0===t?void 0:t.create()}static cacheRes(e,t,r){e=ee.formatURL(e);let s=Te.getURLInfo(e,r);null!=s.typeId&&Te._cacheRes(e,t,s.typeId,s.main)}static _cacheRes(e,t,r,s){let i=Te.loadedMap[e];if(s)i?(i[0]=r,i[1]=t):i=Te.loadedMap[e]=[r,t];else if(i){let e=i.findIndex(e=>e===r);-1!=e?i[e+1]=t:i.push(r,t)}else i=Te.loadedMap[e]=[null,void 0,r,t]}cacheRes(e,t,r){Te.cacheRes(e,t,r)}static clearRes(e,t){e=ee.formatURL(e),Te._clearRes(e,t)}clearRes(e,t){e=ee.formatURL(e),Te._clearRes(e,t)}static _clearRes(e,t){let r=Te.loadedMap[e];if(r)if(t){if(r[1]==t)2==r.length?delete Te.loadedMap[e]:r[1]=void 0;else{let s=r.indexOf(t);if(-1===s)return;4==r.length&&null==r[0]?delete Te.loadedMap[e]:r.splice(s-1,2)}t instanceof G&&!t.destroyed&&t.destroy()}else if(delete Te.loadedMap[e],r.length>2)for(let e=1;e<r.length;e+=2){let t=r[e];t instanceof G&&!t.destroyed&&t.destroy()}else{let e=r[1];e instanceof G&&!e.destroyed&&e.destroy()}}clearTextureRes(e){e=ee.formatURL(e);let t=Te.loadedMap[e];if(!t)return;let r=t[1];if(r instanceof ie)r.disposeBitmap();else if(r instanceof oe)for(let e of r.textures)e.disposeBitmap()}static setGroup(e,t){e=ee.formatURL(e);let r=Te.groupMap[t];r||(r=Te.groupMap[t]=new Set),r.add(e)}static clearResByGroup(e){let t=Te.groupMap[e];if(t)for(let e of t)Te._clearRes(e)}clearUnLoaded(){if(0==this._queue.length)return;let e=this._queue.concat();this._queue.length=0;for(let t of e)t.onComplete(null)}cancelLoadByUrls(e){if(e)for(var t=0,r=e.length;t<r;t++)this.cancelLoadByUrl(e[t])}cancelLoadByUrl(e){e=ee.formatURL(e);let t=this._queue.findIndex(t=>t.url==e);if(-1!=t){let e=this._queue[t];this._queue.splice(t,1),e.onComplete(null)}}loadPackage(e,t,r){let s,i;return"string"==typeof t?(i=t,s=r):s=r||t,i?(i.endsWith("/")||(i+="/"),ee.basePaths[e.length>0?e+"/":e]=i,this._loadFileConfig(e,!0,s)):p.isPreview?Promise.resolve(!0):0===e.length?this._loadFileConfig(e,!0,s):new Promise(t=>{Te.downloader.package(e,s,(r,i)=>{var a;if(null!=i)return Te.warn(`Failed to load package '${e}'`,i),void t(!1);this._loadFileConfig(e,null===(a=null==r?void 0:r.loadScript)||void 0===a||a,s).then(t,()=>t(!1))})})}_loadFileConfig(e,t,r){return e.length>0&&(e+="/"),this.fetch(e+"fileconfig.json","json",r).then(r=>{if(null==r)return!1;if(this._parseFileConfig(r),!t)return!0;let s=Promise.resolve();for(let t of r.libs||[])s=s.then(()=>Y.loadLib(e+t,!1));return r.entry&&(s=s.then(()=>Y.loadLib(e+r.entry,!1))),s.then(()=>!0)})}_parseFileConfig(e){let t=[],r=e.files;for(let e in r)if(e.length>0)for(let s of r[e])t.push(e+"/"+s);else for(let s of r[e])t.push(s);if(e.hash){let r=0,s=ee.version;for(let i of e.hash)null!=i&&(s[t[r]]=i),r++}let s,i,a=e.config,n=a.length,o=0,l=0,h=0,u=0,d=0,c=J.inst.metaMap;for(;;){if(null==s){if(o>=n)break;i=a[o],s=i.i,Array.isArray(s)?d=s.length:(h=s,d=0,u=1),l=0}if(0==u){if(l>=d){o++,s=null;continue}u=s[l++],u>0?(h=u,u=0):u=-u}else u--;let e=t[h+u];switch(i.t){case 0:c[e]=i;break;case 1:ae.addAtlas(e,i.prefix,i.frames);break;case 2:J.inst.shaderNameMap[i.shaderName]=e;break;case 3:Te.preLoadedMap[ee.formatURL(e)]=i;break;case 4:ee.urlMapping[Q.getBaseName(e)]=i.br?e+".br":e}}}}Te.TEXT="text",Te.JSON="json",Te.XML="xml",Te.BUFFER="arraybuffer",Te.IMAGE="image",Te.SOUND="sound",Te.VIDEO="video",Te.ATLAS="atlas",Te.FONT="font",Te.TTF="ttf",Te.HIERARCHY="HIERARCHY",Te.MESH="MESH",Te.MATERIAL="MATERIAL",Te.TEXTURE2D="TEXTURE2D",Te.TEXTURECUBE="TEXTURE2D",Te.TEXTURE2DARRAY="TEXTURE2D",Te.ANIMATIONCLIP="ANIMATIONCLIP",Te.TERRAINHEIGHTDATA="TERRAINHEIGHTDATA",Te.TERRAINRES="TERRAIN",Te.SPINE="SPINE",Te.extMap={},Te.typeMap={},Te.hotReloadableFlags={},Te.assetTypeToLoadType={Image:Te.IMAGE,Texture2D:Te.TEXTURE2D,RenderTexture:Te.TEXTURE2D,TextureCube:Te.TEXTURECUBE,Prefab:Te.HIERARCHY,Material:Te.MATERIAL,Mesh:Te.MESH,Spine:Te.SPINE},Te.downloader=new ge,Te.groupMap={},Te.loadedMap={},Te.preLoadedMap={};class ye{constructor(){this.options={},this.onProgress=new B,this.onComplete=new B,this.progress=new le(e=>this.onProgress.invoke(e))}reset(){for(let e in this.options)delete this.options[e];this.onProgress.clear(),this.onComplete.clear(),this.progress.reset(),this.obsoluteInst=null,this.result=null}}const xe=[],Se={};class Ee{static regClass(e,t){Ee._classMap[e]=t}static getClass(e){return Ee._classMap[e]}static regRuntime(e,t){Ee._runtimeMap[e]=t}static getRuntime(e){return Ee._runtimeMap[e]}}function ve(){}Ee._classMap={},Ee._runtimeMap={};class De{}De.MAX_CLIP_SIZE=99999999;class we{}we.ACTIVE=1,we.ACTIVE_INHIERARCHY=2,we.AWAKED=4,we.DISPLAY=16,we.HAS_ZORDER=32,we.RENDERERS_CACHE=64,we.DISPLAYED_INSTAGE=128,we.CHECK_INPUT=512,we.DEMAND_TRANS_EVENT=1024,we.HAS_SCRIPT=2048,we.ESCAPE_DRAWING_TO_TEXTURE=4096,we.DISABLE_INNER_CLIPPING=8192,we.DISABLE_OUTER_CLIPPING=16384,we.FORCE_VISIBLE=32768,we.EDITING_NODE=65536,we.HIDE_BY_EDITOR=131072,we.LOCK_BY_EDITOR=262144,we.EDITING_ROOT_NODE=524288,we.FORCE_HIDDEN=1048576,we.NOT_IN_PAGE=2097152,we.ESCAPE_LAYOUT=4194304;class Re{}Re.HideInHierarchy=1,Re.HideInInspector=2,Re.DontSave=4,Re.HideAndDontSave=7,Re.HideGizmos=2048,Re.HideTransformTool=4096;class Ce{static equals(e,t){return s.nearEqual(e.a,t.a)&&s.nearEqual(e.b,t.b)&&s.nearEqual(e.c,t.c)&&s.nearEqual(e.d,t.d)&&s.nearEqual(e.tx,t.tx)&&s.nearEqual(e.ty,t.ty)}static extractTransformInfo(e){let{a:t,b:r,c:s,d:i,tx:a,ty:n}=e,o=a,l=n;const h=t*i-r*s<0?-1:1;let u=Math.sqrt(t*t+r*r),d=h*Math.sqrt(s*s+i*i),c=Q.toAngle(Math.atan2(r,t)),_=0,p=0;if(0!==u&&0!==d){const e=t/u,a=r/u,n=s/d,o=i/d,l=n*e+o*a,h=-n*a+o*e;_=Q.toAngle(Math.atan2(l,h));const c=t*s+r*i,g=Math.sqrt(t*t+r*r),m=Math.sqrt(s*s+i*i);if(0!==g&&0!==m){const e=c/(g*m),t=Math.max(-1,Math.min(1,e));p=Q.toAngle(Math.PI/2-Math.acos(t))}}return{x:o,y:l,scaleX:u,scaleY:d,rotation:c,skewX:_,skewY:p}}constructor(e=1,t=0,r=0,s=1,i=0,a=0,n=0){if(this._bTransform=!1,null!=Ce._createFun)return Ce._createFun(e,t,r,s,i,a,n);this.a=e,this.b=t,this.c=r,this.d=s,this.tx=i,this.ty=a,this._checkTransform()}identity(){return this.a=this.d=1,this.b=this.tx=this.ty=this.c=0,this._bTransform=!1,this}_checkTransform(){return this._bTransform=1!==this.a||0!==this.b||0!==this.c||1!==this.d}setTranslate(e,t){return this.tx=e,this.ty=t,this}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this._bTransform=!0,this}rotate(e){var t=Math.cos(e),r=Math.sin(e),s=this.a,i=this.c,a=this.tx;return this.a=s*t-this.b*r,this.b=s*r+this.b*t,this.c=i*t-this.d*r,this.d=i*r+this.d*t,this.tx=a*t-this.ty*r,this.ty=a*r+this.ty*t,this._bTransform=!0,this}skew(e,t){var r=Math.sin(e),s=Math.cos(e),i=Math.sin(t),a=Math.cos(t),n=this.a,o=this.c,l=this.tx;return this.a=a*n+r*this.b,this.b=i*n+s*this.b,this.c=a*o+r*this.d,this.d=i*o+s*this.d,this.tx=a*l+r*this.ty,this.ty=i*l+s*this.ty,this._bTransform=!0,this}invertTransformPoint(e){var t=this.a,r=this.b,s=this.c,i=this.d,a=this.tx,n=t*i-r*s,o=i/n,l=-r/n,h=-s/n,u=t/n,d=(s*this.ty-i*a)/n,c=-(t*this.ty-r*a)/n;return e.setTo(o*e.x+h*e.y+d,l*e.x+u*e.y+c)}transformPoint(e){return e.setTo(this.a*e.x+this.c*e.y+this.tx,this.b*e.x+this.d*e.y+this.ty)}transformPointN(e){return e.setTo(this.a*e.x+this.c*e.y,this.b*e.x+this.d*e.y)}getScaleX(){return 0===this.b?this.a:Math.sqrt(this.a*this.a+this.b*this.b)}getScaleY(){return 0===this.c?this.d:Math.sqrt(this.c*this.c+this.d*this.d)}invert(){var e=this.a,t=this.b,r=this.c,s=this.d,i=this.tx,a=e*s-t*r;return this.a=s/a,this.b=-t/a,this.c=-r/a,this.d=e/a,this.tx=(r*this.ty-s*i)/a,this.ty=-(e*this.ty-t*i)/a,this}setTo(e,t,r,s,i,a){return this.a=e,this.b=t,this.c=r,this.d=s,this.tx=i,this.ty=a,this}concat(e){var t=this.a,r=this.c,s=this.tx;return this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d,this.tx=s*e.a+this.ty*e.c+e.tx,this.ty=s*e.b+this.ty*e.d+e.ty,this}static mul(e,t,r){var s=e.a,i=e.b,a=e.c,n=e.d,o=e.tx,l=e.ty,h=t.a,u=t.b,d=t.c,c=t.d,_=t.tx,p=t.ty;return 0!==u||0!==d?(r.a=s*h+i*d,r.b=s*u+i*c,r.c=a*h+n*d,r.d=a*u+n*c,r.tx=h*o+d*l+_,r.ty=u*o+c*l+p):(r.a=s*h,r.b=i*c,r.c=a*h,r.d=n*c,r.tx=h*o+_,r.ty=c*l+p),r}static mul16(e,t,r){var s=e.a,i=e.b,a=e.c,n=e.d,o=e.tx,l=e.ty,h=t.a,u=t.b,d=t.c,c=t.d,_=t.tx,p=t.ty;return 0!==u||0!==d?(r[0]=s*h+i*d,r[1]=s*u+i*c,r[4]=a*h+n*d,r[5]=a*u+n*c,r[12]=h*o+d*l+_,r[13]=u*o+c*l+p):(r[0]=s*h,r[1]=i*c,r[4]=a*h,r[5]=n*c,r[12]=h*o+_,r[13]=c*l+p),r}scaleEx(e,t){var r=this.a,s=this.b,i=this.c,a=this.d;0!==s||0!==i?(this.a=e*r,this.b=e*s,this.c=t*i,this.d=t*a):(this.a=e*r,this.b=0*a,this.c=0*r,this.d=t*a),this._bTransform=!0}rotateEx(e){var t=Math.cos(e),r=Math.sin(e),s=this.a,i=this.b,a=this.c,n=this.d;0!==i||0!==a?(this.a=t*s+r*a,this.b=t*i+r*n,this.c=-r*s+t*a,this.d=-r*i+t*n):(this.a=t*s,this.b=r*n,this.c=-r*s,this.d=t*n),this._bTransform=!0}clone(){var e=new Ce;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e._bTransform=this._bTransform,e}cloneTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e._bTransform=this._bTransform,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e._bTransform=this._bTransform,e}setMatrix(e,t,r,s,i,a,n,o,l){i=Q.toRadian(i),a=Q.toRadian(a),n=Q.toRadian(n);const h=Math.cos(i),u=Math.sin(i),d=Math.cos(a),c=Math.sin(a),_=Math.cos(n),p=Math.sin(n);return this.a=(h*_-u*p)*r,this.b=(u*_+h*p)*r,this.c=(h*c-u*d)*s,this.d=(u*c+h*d)*s,this.tx=e-this.a*o-this.c*l,this.ty=t-this.b*o-this.d*l,this._checkTransform(),this}toString(){return this.a+","+this.b+","+this.c+","+this.d+","+this.tx+","+this.ty}destroy(){this.recover()}recover(){h.recover("Matrix",this.identity())}static create(){return h.getItemByClass("Matrix",Ce)}}Ce.EMPTY=new Ce,Ce.TEMP=new Ce,Ce._createFun=null;class Me{constructor(e){(null==e||e)&&(this.source=Y.createElement("canvas"))}clear(){this.source&&this.context.clearRect(0,0,this.source.width,this.source.height)}get context(){return this._ctx||(this._ctx=this.source.getContext("2d"))}set context(e){this._ctx=e}size(e,t){this.source&&(this.source.height=t,this.source.width=e)}}var be,Ae,Ie,Pe,Be,Le,Ne,Fe='#define SHADER_NAME BaseRender2DVS\n#include "Sprite2DVertex.glsl";\nvoid main(){vertexInfo info;getVertexInfo(info);v_texcoord=info.uv;v_color=info.color;\n#ifdef LIGHT2D_ENABLE\nlightAndShadow(info);\n#endif\ngl_Position=getPosition(info.pos);}';e.BlendEquationSeparate=void 0,(be=e.BlendEquationSeparate||(e.BlendEquationSeparate={}))[be.ADD=0]="ADD",be[be.SUBTRACT=1]="SUBTRACT",be[be.REVERSE_SUBTRACT=2]="REVERSE_SUBTRACT",be[be.MIN=3]="MIN",be[be.MAX=4]="MAX",e.BlendFactor=void 0,(Ae=e.BlendFactor||(e.BlendFactor={}))[Ae.Zero=0]="Zero",Ae[Ae.One=1]="One",Ae[Ae.SourceColor=2]="SourceColor",Ae[Ae.OneMinusSourceColor=3]="OneMinusSourceColor",Ae[Ae.DestinationColor=4]="DestinationColor",Ae[Ae.OneMinusDestinationColor=5]="OneMinusDestinationColor",Ae[Ae.SourceAlpha=6]="SourceAlpha",Ae[Ae.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",Ae[Ae.DestinationAlpha=8]="DestinationAlpha",Ae[Ae.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",Ae[Ae.SourceAlphaSaturate=10]="SourceAlphaSaturate",Ae[Ae.BlendColor=11]="BlendColor",Ae[Ae.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendType=void 0,(Ie=e.BlendType||(e.BlendType={}))[Ie.BLEND_DISABLE=0]="BLEND_DISABLE",Ie[Ie.BLEND_ENABLE_ALL=1]="BLEND_ENABLE_ALL",Ie[Ie.BLEND_ENABLE_SEPERATE=2]="BLEND_ENABLE_SEPERATE",e.CompareFunction=void 0,(Pe=e.CompareFunction||(e.CompareFunction={}))[Pe.Never=0]="Never",Pe[Pe.Less=1]="Less",Pe[Pe.Equal=2]="Equal",Pe[Pe.LessEqual=3]="LessEqual",Pe[Pe.Greater=4]="Greater",Pe[Pe.NotEqual=5]="NotEqual",Pe[Pe.GreaterEqual=6]="GreaterEqual",Pe[Pe.Always=7]="Always",Pe[Pe.Off=8]="Off",e.CullMode=void 0,(Be=e.CullMode||(e.CullMode={}))[Be.Off=0]="Off",Be[Be.Front=1]="Front",Be[Be.Back=2]="Back",e.FrontFace=void 0,(Le=e.FrontFace||(e.FrontFace={}))[Le.CW=0]="CW",Le[Le.CCW=1]="CCW",e.StencilOperation=void 0,(Ne=e.StencilOperation||(e.StencilOperation={}))[Ne.Keep=0]="Keep",Ne[Ne.Zero=1]="Zero",Ne[Ne.Replace=2]="Replace",Ne[Ne.IncrementSaturate=3]="IncrementSaturate",Ne[Ne.DecrementSaturate=4]="DecrementSaturate",Ne[Ne.Invert=5]="Invert",Ne[Ne.IncrementWrap=6]="IncrementWrap",Ne[Ne.DecrementWrap=7]="DecrementWrap";class Oe{static splitToWords(e,t){let r,s,i=[],a=-1,n=e.length;for(let o=0;o<n;o++)if(r=e.charAt(o)," \t=+-*/&%!<>()'\",;".indexOf(r)>=0){if(a>=0&&o-a>1&&(s=e.substring(a,o),i.push(s)),'"'==r||"'"==r){let t=e.indexOf(r,o+1);if(t<0)throw new Error("Sharder err:"+e);i.push(e.substring(o+1,t)),o=t,a=-1;continue}"("==r&&t&&i.length>0&&(s=i[i.length-1]+";","vec4;main;".indexOf(s)<0&&(t.useFuns+=s)),a=-1}else a<0&&(a=o);return a<n&&n-a>1&&(s=e.substring(a,n),i.push(s)),i}constructor(e){this.codes={},this.funs={},this.curUseID=-1,this.funnames="",this.script=e;let t,r,s=0;for(;s=e.indexOf("#begin",s),!(s<0);){for(r=s+5;!(r=e.indexOf("#end",r),r<0||"i"!==e.charAt(r+4));)r+=5;if(r<0)throw new Error("add include err,no #end:"+e);t=e.indexOf("\n",s);let i=Oe.splitToWords(e.substring(s,t),null);"code"==i[1]?this.codes[i[2]]=e.substring(t+1,r):"function"==i[1]&&(t=e.indexOf("function",s),t+=8,this.funs[i[3]]=e.substring(t+1,r),this.funnames+=i[3]+";"),s=r+1}}getWith(e=null){let t=e?this.codes[e]:this.script;if(!t)throw new Error("get with error:"+e);return t}getFunsScript(e){let t="";for(let r in this.funs)e.indexOf(r+";")>=0&&(t+=this.funs[r]);return t}}class Ue{constructor(e){this.childs=[],this.text="",this.useFuns="",this.z=0,this.includefiles=e}setParent(e){e.childs.push(this),this.z=e.z+1,this.parent=e}setCondition(e,t){e&&(this.conditionType=t,e=e.replace(/(\s*$)/g,""),this.condition=function(){return this[e]},this.condition.__condition=e)}toscript(e,t){return this._toscript(e,t,++Ue.__id)}_toscript(e,t,r){if(this.childs.length<1&&!this.text)return t;if(t.length,this.condition){var s=!!this.condition.call(e);if(2===this.conditionType&&(s=!s),!s&&Ue.__noCompileEnable)return t}if(!this.noCompile&&Ue.__noCompileEnable||this.text&&t.push(this.text),this.childs.length>0&&this.childs.forEach(function(s,i,a){s._toscript(e,t,r)}),this.includefiles.length>0&&this.useFuns.length>0)for(var i,a=0,n=this.includefiles.length;a<n;a++)this.includefiles[a].curUseID!=r&&(i=this.includefiles[a].file.getFunsScript(this.useFuns)).length>0&&(this.includefiles[a].curUseID=r,t[0]=i+t[0]);return t}}Ue.__id=1,Ue.__noCompileEnable=!0;const ke=new RegExp("\r","g"),Ge=new RegExp("[ \\t=\\+\\-*/&%!<>!%(),;\\|]","g"),Ve={Back:e.CullMode.Back,Front:e.CullMode.Front,Off:e.CullMode.Off},ze={Disable:e.BlendType.BLEND_DISABLE,All:e.BlendType.BLEND_ENABLE_ALL,Seperate:e.BlendType.BLEND_ENABLE_SEPERATE},He={Zero:e.BlendFactor.Zero,One:e.BlendFactor.One,SourceColor:e.BlendFactor.SourceColor,OneMinusSourceColor:e.BlendFactor.OneMinusSourceColor,DestinationColor:e.BlendFactor.DestinationColor,OneMinusDestinationColor:e.BlendFactor.OneMinusDestinationColor,SourceAlpha:e.BlendFactor.SourceAlpha,OneMinusSourceAlpha:e.BlendFactor.OneMinusSourceAlpha,DestinationAlpha:e.BlendFactor.DestinationAlpha,OneMinusDestinationAlpha:e.BlendFactor.OneMinusDestinationAlpha,SourceAlphaSaturate:e.BlendFactor.SourceAlphaSaturate,BlendColor:e.BlendFactor.BlendColor,OneMinusBlendColor:e.BlendFactor.OneMinusBlendColor},We={Add:e.BlendEquationSeparate.ADD,Subtract:e.BlendEquationSeparate.SUBTRACT,Reverse_substract:e.BlendEquationSeparate.REVERSE_SUBTRACT,Min:e.BlendEquationSeparate.MIN,Max:e.BlendEquationSeparate.MAX},Xe={Never:e.CompareFunction.Never,Less:e.CompareFunction.Less,Equal:e.CompareFunction.Equal,LessEqual:e.CompareFunction.LessEqual,Greater:e.CompareFunction.Greater,NotEqual:e.CompareFunction.NotEqual,GreaterEqual:e.CompareFunction.GreaterEqual,Always:e.CompareFunction.Always,Off:e.CompareFunction.Off},Ye={Keep:e.StencilOperation.Keep,Zero:e.StencilOperation.Zero,Replace:e.StencilOperation.Replace,IncrementSaturate:e.StencilOperation.IncrementSaturate,DecrementSaturate:e.StencilOperation.DecrementSaturate,Invert:e.StencilOperation.Invert,IncrementWrap:e.StencilOperation.IncrementWrap,DecrementWrap:e.StencilOperation.DecrementWrap};class qe{static addInclude(e,t,r){if(!t||0===t.length)return console.error("shader include file err:"+e),null;if(!r&&qe.includes[e]&&p.isPlaying)return console.warn("shader include file already exists:"+e),qe.includes[e];t=t.replace(ke,"");let s=new Oe(t);return qe.includes[e]=s,s}static compile(e,t,r){let s={vsNode:new Ue([]),psNode:new Ue([]),includeNames:new Set,defs:new Set},i=[];e=e.replace(ke,""),t=t.replace(ke,""),qe._compileToTree(s.vsNode,e,s.defs,i,r),qe._compileToTree(s.psNode,t,s.defs,i,r);for(let e of i)e.file?s.includeNames.add(e.name):console.warn(`ShaderCompile missing file ${e.name}`);return s}static compileAsync(e,t,r){let s={vsNode:new Ue([]),psNode:new Ue([]),includeNames:new Set,defs:new Set},i=[];return e=e.replace(ke,""),t=t.replace(ke,""),qe._compileToTree(s.vsNode,e,s.defs,i,r),qe._compileToTree(s.psNode,t,s.defs,i,r),this._loadIncludesDeep(s,i,0)}static compileCompute(e,t){let r={node:new Ue([]),includeNames:new Set,defs:new Set},s=[];e=e.replace(ke,""),qe._compileToTree(r.node,e,r.defs,s,t);for(let e of s)e.file?r.includeNames.add(e.name):console.warn(`ShaderCompile missing file ${e.name}`);return r}static compileComputeAsync(e,t){let r={node:new Ue([]),includeNames:new Set,defs:new Set},s=[];return e=e.replace(ke,""),qe._compileToTree(r.node,e,r.defs,s,t),this._loadIncludesDeep(r,s,0)}static _loadIncludesDeep(e,t,r){let s,i=t.length;for(let a=r;a<i;a++){let r=t[a];r.file?e.includeNames.add(r.name):(s||(s=[]),s.push(r))}return s?l.loader.load(s.map(e=>e.name)).then(r=>{let a=s.length;for(let i=0;i<a;i++){let a=s[i],n=r[i];if(n){e.includeNames.add(a.name);let r=n.getWith(a.codeName);a.node.condition?a.node.text=r:(qe._compileToTree(a.node,r,e.defs,t,ee.getPath(a.name)),a.node.text="")}else{let e=a.node.parent.childs;e.splice(e.indexOf(a.node),1)}}return t.length>i?qe._loadIncludesDeep(e,t,i):e}):Promise.resolve(e)}static _compileToTree(e,t,r,s,i){let a,n,o,l,h,u,d,c,_,p,g=t.split("\n");for(c=0;c<g.length;c++)if(o=g[c],!(o.length<1)&&(u=o.indexOf("//"),0!==u)){if(u>=0&&(o=o.substr(0,u)),(u=o.indexOf("#"))<0){n=e.childs[e.childs.length-1];let t=e.includefiles;if(n&&!n.name){t.length>0&&Oe.splitToWords(o,n),n.text+="\n"+o;continue}a=new Ue(t),a.text=o,a.noCompile=!0,t.length>0&&Oe.splitToWords(o,a),a.setParent(e);continue}for(a=new Ue(e.includefiles),a.text=o,a.noCompile=!0,l="#",p=u+1,_=o.length;p<_;p++){let e=o.charAt(p);if(" "===e||"\t"===e||"?"===e)break;l+=e}switch(a.name=l,l){case"#ifdef":case"#ifndef":for(a.src=o,a.noCompile=null!=o.match(/[!&|()=<>]/),a.noCompile?console.log("function():Boolean{return "+o.substr(u+a.name.length)+"}"):(d=o.replace(/^\s*/,"").split(/\s+/),a.setCondition(d[1],"#ifdef"===l?qe.IFDEF_YES:qe.IFDEF_ELSE),a.text=a.text),a.setParent(e),e=a,d=o.substr(p).split(Ge),p=0;p<d.length;p++)o=d[p],o.length&&r.add(o);break;case"#if":case"#elif":for(a.src=o,a.noCompile=!0,"#elif"==l&&(n=(e=e.parent).childs[e.childs.length-1],n.text=n.src,n.noCompile=!0,n.condition=null),a.setParent(e),e=a,d=o.substr(p).split(Ge),p=0;p<d.length;p++)o=d[p],o.length&&"defined"!=o&&r.add(o);break;case"#else":a.src=o,n=(e=e.parent).childs[e.childs.length-1],a.noCompile=n.noCompile,a.noCompile||(a.condition=n.condition,a.conditionType=n.conditionType==qe.IFDEF_YES?qe.IFDEF_ELSE:qe.IFDEF_YES),a.setParent(e),e=a;break;case"#endif":n=(e=e.parent).childs[e.childs.length-1],a.noCompile=n.noCompile,a.noCompile||(a.text=a.text),a.setParent(e);break;case"#include":d=Oe.splitToWords(o,null);let t,c=d[1];c.startsWith(".")?c=ee.join(i,c):c.startsWith("/")?c=ee.formatURL(c.substring(1)):(t=qe.includes[c],t||(c="internal/"+c)),t=qe.includes[c],!t&&qe.loadIncludeFileSync&&(qe.loadIncludeFileSync(c),t=qe.includes[c]);let _="with"==d[2]?d[3]:null;s.push({name:c,codeName:_,node:a,file:t}),a.setParent(e),(u=d[0].indexOf("?"))<0?(t&&(o=t.getWith(_),this._compileToTree(a,o,r,s,ee.getPath(c))),a.text=""):(a.setCondition(d[0].substr(u+1),qe.IFDEF_YES),t&&(a.text=t.getWith(_)));break;case"#import":d=Oe.splitToWords(o,null),h=d[1],a.includefiles.push({node:a,file:qe.includes[h],ofs:a.text.length});break;default:a.setParent(e)}}}static getRenderState(e,t){if(!e)return;t.cull=Ve[e.cull],t.blend=ze[e.blend],t.srcBlend=He[e.srcBlend],t.dstBlend=He[e.dstBlend],t.srcBlendRGB=He[e.srcBlendRGB],t.dstBlendRGB=He[e.dstBlendRGB],t.srcBlendAlpha=He[e.srcBlendAlpha],t.dstBlendAlpha=He[e.dstBlendAlpha],t.blendEquation=We[e.blendEquation],t.blendEquationRGB=We[e.blendEquationRGB],t.blendEquationAlpha=We[e.blendEquationAlpha],t.depthTest=Xe[e.depthTest],t.depthWrite=e.depthWrite,t.stencilRef=e.stencilRef,t.stencilTest=Xe[e.stencilTest],t.stencilWrite=e.stencilWrite,t.stencilWriteMask=e.stencilWriteMask,t.stencilReadMask=e.stencilReadMask;let r=e.stencilOp,s=r?r[0]:null,i=r?r[1]:null,a=r?r[2]:null,n=t.stencilOp;n.x=Ye[s],n.y=Ye[i],n.z=Ye[a],t.stencilOp=n,t.depthBias=e.depthBias,t.depthBiasConstant=e.depthBiasConstant,t.depthBiasSlopeScale=e.depthBiasSlopeScale,t.depthBiasClamp=e.depthBiasClamp}}qe.IFDEF_NO=0,qe.IFDEF_YES=1,qe.IFDEF_ELSE=2,qe.IFDEF_PARENT=3,qe.includes={};class $e{constructor(e=0,t=0){this.x=e,this.y=t}setValue(e,t){return this.x=e,this.y=t,this}static scale(e,t,r){r.x=e.x*t,r.y=e.y*t}static equals(e,t){return s.nearEqual(e.x,t.x)&&s.nearEqual(e.y,t.y)}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1]}toArray(){return[this.x,this.y]}writeTo(e,t=0){e[t+0]=this.x,e[t+1]=this.y}cloneTo(e){return e.x=this.x,e.y=this.y,e}static dot(e,t){return e.x*t.x+e.y*t.y}static normalize(e,t){var r=e.x,s=e.y,i=r*r+s*s;i>0&&(i=1/Math.sqrt(i),t.x=r*i,t.y=s*i)}static scalarLength(e){var t=e.x,r=e.y;return Math.sqrt(t*t+r*r)}static distance(e,t){let r=e.x-t.x,s=e.y-t.y;return Math.sqrt(r*r+s*s)}clone(){var e=new $e;return this.cloneTo(e),e}}$e.ZERO=new $e(0,0),$e.ONE=new $e(1,1),$e.TEMP=new $e;const Ke=new Float32Array([1,0,0,0,1,0,0,0,1]);class je{static createRotationQuaternion(e,t){var r=e.x,s=e.y,i=e.z,a=e.w,n=r*r,o=s*s,l=i*i,h=r*s,u=i*a,d=i*r,c=s*a,_=s*i,p=r*a,g=t.elements;g[0]=1-2*(o+l),g[1]=2*(h+u),g[2]=2*(d-c),g[3]=2*(h-u),g[4]=1-2*(l+n),g[5]=2*(_+p),g[6]=2*(d+c),g[7]=2*(_-p),g[8]=1-2*(o+n)}static createFromTranslation(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=1,r[5]=0,r[6]=e.x,r[7]=e.y,r[8]=1}static createMatrixFromValue(e,t,r=$e.ONE,s){var i=s.elements,a=Math.sin(t),n=Math.cos(t);i[0]=n*r.x,i[1]=a*r.x,i[2]=0,i[3]=-a*r.y,i[4]=n*r.y,i[5]=0,i[6]=e.x,i[7]=e.y,i[8]=1}static createFromRotation(e,t){var r=t.elements,s=Math.sin(e),i=Math.cos(e);r[0]=i,r[1]=s,r[2]=0,r[3]=-s,r[4]=i,r[5]=0,r[6]=0,r[7]=0,r[8]=1}static createFromScaling(e,t){var r=t.elements;r[0]=e.x,r[1]=0,r[2]=0,r[3]=0,r[4]=e.y,r[5]=0,r[6]=0,r[7]=0,r[8]=e.z}static createFromMatrix4x4(e,t){var r=e.elements,s=t.elements;s[0]=r[0],s[1]=r[1],s[2]=r[2],s[3]=r[4],s[4]=r[5],s[5]=r[6],s[6]=r[8],s[7]=r[9],s[8]=r[10]}static multiply(e,t,r){var s=e.elements,i=t.elements,a=r.elements,n=s[0],o=s[1],l=s[2],h=s[3],u=s[4],d=s[5],c=s[6],_=s[7],p=s[8],g=i[0],m=i[1],f=i[2],T=i[3],y=i[4],x=i[5],S=i[6],E=i[7],v=i[8];a[0]=g*n+m*h+f*c,a[1]=g*o+m*u+f*E,a[2]=g*l+m*d+f*p,a[3]=T*n+y*h+x*c,a[4]=T*o+y*u+x*_,a[5]=T*l+y*d+x*p,a[6]=S*n+E*h+v*c,a[7]=S*o+E*u+v*_,a[8]=S*l+E*d+v*p}constructor(e=!0){e&&(this.elements=Ke.slice())}cloneByArray(e){this.elements.set(e)}determinant(){var e=this.elements,t=e[0],r=e[1],s=e[2],i=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8];return t*(h*a-n*l)+r*(-h*i+n*o)+s*(l*i-a*o)}translate(e,t){var r=t.elements,s=this.elements,i=s[0],a=s[1],n=s[2],o=s[3],l=s[4],h=s[5],u=s[6],d=s[7],c=s[8],_=e.x,p=e.y;r[0]=i,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h,r[6]=_*i+p*o+u,r[7]=_*a+p*l+d,r[8]=_*n+p*h+c}rotate(e,t){var r=t.elements,s=this.elements,i=s[0],a=s[1],n=s[2],o=s[3],l=s[4],h=s[5],u=s[6],d=s[7],c=s[8],_=Math.sin(e),p=Math.cos(e);r[0]=p*i+_*o,r[1]=p*a+_*l,r[2]=p*n+_*h,r[3]=p*o-_*i,r[4]=p*l-_*a,r[5]=p*h-_*n,r[6]=u,r[7]=d,r[8]=c}scale(e,t){var r=t.elements,s=this.elements,i=e.x,a=e.y;r[0]=i*s[0],r[1]=i*s[1],r[2]=i*s[2],r[3]=a*s[3],r[4]=a*s[4],r[5]=a*s[5],r[6]=s[6],r[7]=s[7],r[8]=s[8]}invert(e){var t=e.elements,r=this.elements,s=r[0],i=r[1],a=r[2],n=r[3],o=r[4],l=r[5],h=r[6],u=r[7],d=r[8],c=d*o-l*u,_=-d*n+l*h,p=u*n-o*h,g=s*c+i*_+a*p;g&&(g=1/g,t[0]=c*g,t[1]=(-d*i+a*u)*g,t[2]=(l*i-a*o)*g,t[3]=_*g,t[4]=(d*s-a*h)*g,t[5]=(-l*s+a*n)*g,t[6]=p*g,t[7]=(-u*s+i*h)*g,t[8]=(o*s-i*n)*g)}transpose(e){var t=e.elements,r=this.elements;if(e===this){var s=r[1],i=r[2],a=r[5];t[1]=r[3],t[2]=r[6],t[3]=s,t[5]=r[7],t[6]=i,t[7]=a}else t[0]=r[0],t[1]=r[3],t[2]=r[6],t[3]=r[1],t[4]=r[4],t[5]=r[7],t[6]=r[2],t[7]=r[5],t[8]=r[8]}identity(){this.elements.set(Ke)}cloneTo(e){var t,r;(t=this.elements)!==(r=e.elements)&&r.set(t)}clone(){var e=new je(!1);return e.elements=this.elements.slice(),e}static lookAt(e,t,r,s){a.subtract(e,t,Qe),a.normalize(Qe,Qe),a.cross(r,Qe,Ze),a.normalize(Ze,Ze),a.cross(Qe,Ze,Je);var i=Qe,n=Ze,o=Je,l=s.elements;l[0]=n.x,l[3]=n.y,l[6]=n.z,l[1]=o.x,l[4]=o.y,l[7]=o.z,l[2]=i.x,l[5]=i.y,l[8]=i.z}static forwardLookAt(e,t,r,s){var i=Ze,a=Je,n=Qe;t.vsub(e,n).normalize(),r.cross(n,i).normalize(),n.cross(i,a);var o=s.elements;o[0]=i.x,o[1]=i.y,o[2]=i.z,o[3]=a.x,o[4]=a.y,o[5]=a.z,o[6]=n.x,o[7]=n.y,o[8]=n.z}}je.DEFAULT=new je,je.TEMP=new je;const Qe=new a,Ze=new a,Je=new a;class et{static createFromYawPitchRoll(e,t,r,s){var i=.5*r,a=.5*t,n=.5*e,o=Math.sin(i),l=Math.cos(i),h=Math.sin(a),u=Math.cos(a),d=Math.sin(n),c=Math.cos(n);s.x=c*h*l+d*u*o,s.y=d*u*l-c*h*o,s.z=c*u*o-d*h*l,s.w=c*u*l+d*h*o}static multiply(e,t,r){var s=e.x,i=e.y,a=e.z,n=e.w,o=t.x,l=t.y,h=t.z,u=t.w,d=i*h-a*l,c=a*o-s*h,_=s*l-i*o,p=s*o+i*l+a*h;r.x=s*u+o*n+d,r.y=i*u+l*n+c,r.z=a*u+h*n+_,r.w=n*u-p}static rotationAxisAngle(e,t,r){const s=a.TEMP;a.normalize(e,s),t*=.5;const i=Math.sin(t);r.x=s.x*i,r.y=s.y*i,r.z=s.z*i,r.w=Math.cos(t)}static arcTanAngle(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,t,r){a.subtract(t,e,tt),a.normalize(tt,tt),r.x=Math.asin(tt.y),r.y=et.arcTanAngle(-tt.z,-tt.x)}static createFromAxisAngle(e,t,r){t*=.5;var s=Math.sin(t);r.x=s*e.x,r.y=s*e.y,r.z=s*e.z,r.w=Math.cos(t)}static createFromMatrix4x4(e,t){var r,s,i=e.elements,a=i[0]+i[5]+i[10];a>0?(r=Math.sqrt(a+1),t.w=.5*r,r=.5/r,t.x=(i[6]-i[9])*r,t.y=(i[8]-i[2])*r,t.z=(i[1]-i[4])*r):i[0]>=i[5]&&i[0]>=i[10]?(s=.5/(r=Math.sqrt(1+i[0]-i[5]-i[10])),t.x=.5*r,t.y=(i[1]+i[4])*s,t.z=(i[2]+i[8])*s,t.w=(i[6]-i[9])*s):i[5]>i[10]?(s=.5/(r=Math.sqrt(1+i[5]-i[0]-i[10])),t.x=(i[4]+i[1])*s,t.y=.5*r,t.z=(i[9]+i[6])*s,t.w=(i[8]-i[2])*s):(s=.5/(r=Math.sqrt(1+i[10]-i[0]-i[5])),t.x=(i[8]+i[2])*s,t.y=(i[9]+i[6])*s,t.z=.5*r,t.w=(i[1]-i[4])*s)}static slerp(e,t,r,s){var i,a,n,o,l,h=e.x,u=e.y,d=e.z,c=e.w,_=t.x,p=t.y,g=t.z,m=t.w;return(a=h*_+u*p+d*g+c*m)<0&&(a=-a,_=-_,p=-p,g=-g,m=-m),1-a>1e-6?(i=Math.acos(a),n=Math.sin(i),o=Math.sin((1-r)*i)/n,l=Math.sin(r*i)/n):(o=1-r,l=r),s.x=o*h+l*_,s.y=o*u+l*p,s.z=o*d+l*g,s.w=o*c+l*m,s}static lerp(e,t,r,s){var i=1-r;et.dot(e,t)>=0?(s.x=i*e.x+r*t.x,s.y=i*e.y+r*t.y,s.z=i*e.z+r*t.z,s.w=i*e.w+r*t.w):(s.x=i*e.x-r*t.x,s.y=i*e.y-r*t.y,s.z=i*e.z-r*t.z,s.w=i*e.w-r*t.w),s.normalize(s)}static add(e,t,r){r.x=e.x+t.x,r.y=e.y+t.y,r.z=e.z+t.z,r.w=e.w+t.w}static dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}constructor(e=0,t=0,r=0,s=1){this.x=e,this.y=t,this.z=r,this.w=s}setValue(e,t,r,s){this.x=e,this.y=t,this.z=r,this.w=s}set(e,t,r,s){return this.x=e,this.y=t,this.z=r,this.w=s,this}scaling(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e}normalize(e){var t=this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w;t>0&&(t=1/Math.sqrt(t),e.x=this.x*t,e.y=this.y*t,e.z=this.z*t,e.w=this.w*t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}rotateX(e,t){e*=.5;var r=Math.sin(e),s=Math.cos(e);t.x=this.x*s+this.w*r,t.y=this.y*s+this.z*r,t.z=this.z*s-this.y*r,t.w=this.w*s-this.x*r}rotateY(e,t){e*=.5;var r=Math.sin(e),s=Math.cos(e);t.x=this.x*s-this.z*r,t.y=this.y*s+this.w*r,t.z=this.z*s+this.x*r,t.w=this.w*s-this.y*r}rotateZ(e,t){e*=.5;var r=Math.sin(e),s=Math.cos(e);t.x=this.x*s+this.y*r,t.y=this.y*s-this.x*r,t.z=this.z*s+this.w*r,t.w=this.w*s-this.z*r}getYawPitchRoll(e){a.transformQuat(a.ForwardRH,this,rt);let t=st,r=it;a.transformQuat(a.Up,this,t),et.angleTo(a.ZERO,rt,r),r.x==Math.PI/2?(r.y=et.arcTanAngle(t.z,t.x),r.z=0):r.x==-Math.PI/2?(r.y=et.arcTanAngle(-t.z,-t.x),r.z=0):(nt.createRotationY(-r.y,nt.TEMP),a.transformCoordinate(t,nt.TEMP,t),nt.createRotationX(-r.x,nt.TEMP),a.transformCoordinate(t,nt.TEMP,t),r.z=et.arcTanAngle(t.y,-t.x)),r.y<=-Math.PI&&(r.y=Math.PI),r.z<=-Math.PI&&(r.z=Math.PI),r.y>=Math.PI&&r.z>=Math.PI&&(r.y=0,r.z=0,r.x=Math.PI-r.x);var s=e;s.x=r.y,s.y=r.x,s.z=r.z}invert(e){var t=this.x,r=this.y,s=this.z,i=this.w,a=t*t+r*r+s*s+i*i,n=a?1/a:0;e.x=-t*n,e.y=-r*n,e.z=-s*n,e.w=i*n}identity(){this.x=0,this.y=0,this.z=0,this.w=1}fromArray(e,t=0){this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3]}cloneTo(e){this!==e&&(e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w)}clone(){var e=new et;return this.cloneTo(e),e}equals(e){return s.nearEqual(this.x,e.x)&&s.nearEqual(this.y,e.y)&&s.nearEqual(this.z,e.z)&&s.nearEqual(this.w,e.w)}static rotationLookAt(e,t,r){et.lookAt(a.ZERO,e,t,r)}static lookAt(e,t,r,s){je.lookAt(e,t,r,je.TEMP),et.rotationMatrix(je.TEMP,s)}static forwardLookAt(e,t,r,s){je.forwardLookAt(e,t,r,je.TEMP),et.rotationMatrix(je.TEMP,s)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}static invert(e,t){var r=e.lengthSquared();s.isZero(r)||(r=1/r,t.x=-e.x*r,t.y=-e.y*r,t.z=-e.z*r,t.w=e.w*r)}static rotationMatrix(e,t){var r,s,i=e.elements,a=i[0],n=i[1],o=i[2],l=i[3],h=i[4],u=i[5],d=i[6],c=i[7],_=i[8],p=a+h+_;p>0?(r=Math.sqrt(p+1),t.w=.5*r,r=.5/r,t.x=(u-c)*r,t.y=(d-o)*r,t.z=(n-l)*r):a>=h&&a>=_?(s=.5/(r=Math.sqrt(1+a-h-_)),t.x=.5*r,t.y=(n+l)*s,t.z=(o+d)*s,t.w=(u-c)*s):h>_?(s=.5/(r=Math.sqrt(1+h-a-_)),t.x=(l+n)*s,t.y=.5*r,t.z=(c+u)*s,t.w=(d-o)*s):(s=.5/(r=Math.sqrt(1+_-a-h)),t.x=(d+o)*s,t.y=(c+u)*s,t.z=.5*r,t.w=(n-l)*s)}}et.TEMP=new et,et.DEFAULT=new et,et.NAN=new et(NaN,NaN,NaN,NaN);const tt=new a,rt=new a,st=new a,it=new a,at=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class nt{static createRotationX(e,t){var r=t.elements,s=Math.sin(e),i=Math.cos(e);r[1]=r[2]=r[3]=r[4]=r[7]=r[8]=r[11]=r[12]=r[13]=r[14]=0,r[0]=r[15]=1,r[5]=r[10]=i,r[6]=s,r[9]=-s}static createRotationY(e,t){var r=t.elements,s=Math.sin(e),i=Math.cos(e);r[1]=r[3]=r[4]=r[6]=r[7]=r[9]=r[11]=r[12]=r[13]=r[14]=0,r[5]=r[15]=1,r[0]=r[10]=i,r[2]=-s,r[8]=s}static createRotationZ(e,t){var r=t.elements,s=Math.sin(e),i=Math.cos(e);r[2]=r[3]=r[6]=r[7]=r[8]=r[9]=r[11]=r[12]=r[13]=r[14]=0,r[10]=r[15]=1,r[0]=r[5]=i,r[1]=s,r[4]=-s}static createRotationYawPitchRoll(e,t,r,s){et.createFromYawPitchRoll(e,t,r,et.TEMP),nt.createRotationQuaternion(et.TEMP,s)}static createRotationAxis(e,t,r){var s=e.x,i=e.y,a=e.z,n=Math.cos(t),o=Math.sin(t),l=s*s,h=i*i,u=a*a,d=s*i,c=s*a,_=i*a,p=r.elements;p[3]=p[7]=p[11]=p[12]=p[13]=p[14]=0,p[15]=1,p[0]=l+n*(1-l),p[1]=d-n*d+o*a,p[2]=c-n*c-o*i,p[4]=d-n*d-o*a,p[5]=h+n*(1-h),p[6]=_-n*_+o*s,p[8]=c-n*c+o*i,p[9]=_-n*_-o*s,p[10]=u+n*(1-u)}static createRotationQuaternion(e,t){var r=t.elements,s=e.x,i=e.y,a=e.z,n=e.w,o=s*s,l=i*i,h=a*a,u=s*i,d=a*n,c=a*s,_=i*n,p=i*a,g=s*n;r[3]=r[7]=r[11]=r[12]=r[13]=r[14]=0,r[15]=1,r[0]=1-2*(l+h),r[1]=2*(u+d),r[2]=2*(c-_),r[4]=2*(u-d),r[5]=1-2*(h+o),r[6]=2*(p+g),r[8]=2*(c+_),r[9]=2*(p-g),r[10]=1-2*(l+o)}static createTranslate(e,t){var r=t.elements;r[4]=r[8]=r[1]=r[9]=r[2]=r[6]=r[3]=r[7]=r[11]=0,r[0]=r[5]=r[10]=r[15]=1,r[12]=e.x,r[13]=e.y,r[14]=e.z}static createScaling(e,t){var r=t.elements;r[0]=e.x,r[5]=e.y,r[10]=e.z,r[1]=r[4]=r[8]=r[12]=r[9]=r[13]=r[2]=r[6]=r[14]=r[3]=r[7]=r[11]=0,r[15]=1}static multiply(e,t,r){var s=t.elements,i=e.elements,a=r.elements,n=s[0],o=s[1],l=s[2],h=s[3],u=s[4],d=s[5],c=s[6],_=s[7],p=s[8],g=s[9],m=s[10],f=s[11],T=s[12],y=s[13],x=s[14],S=s[15],E=i[0],v=i[1],D=i[2],w=i[3],R=i[4],C=i[5],M=i[6],b=i[7],A=i[8],I=i[9],P=i[10],B=i[11],L=i[12],N=i[13],F=i[14],O=i[15];a[0]=n*E+o*R+l*A+h*L,a[1]=n*v+o*C+l*I+h*N,a[2]=n*D+o*M+l*P+h*F,a[3]=n*w+o*b+l*B+h*O,a[4]=u*E+d*R+c*A+_*L,a[5]=u*v+d*C+c*I+_*N,a[6]=u*D+d*M+c*P+_*F,a[7]=u*w+d*b+c*B+_*O,a[8]=p*E+g*R+m*A+f*L,a[9]=p*v+g*C+m*I+f*N,a[10]=p*D+g*M+m*P+f*F,a[11]=p*w+g*b+m*B+f*O,a[12]=T*E+y*R+x*A+S*L,a[13]=T*v+y*C+x*I+S*N,a[14]=T*D+y*M+x*P+S*F,a[15]=T*w+y*b+x*B+S*O}static createFromQuaternion(e,t){var r=t.elements,s=e.x,i=e.y,a=e.z,n=e.w,o=s+s,l=i+i,h=a+a,u=s*o,d=i*o,c=i*l,_=a*o,p=a*l,g=a*h,m=n*o,f=n*l,T=n*h;r[0]=1-c-g,r[1]=d+T,r[2]=_-f,r[3]=0,r[4]=d-T,r[5]=1-u-g,r[6]=p+m,r[7]=0,r[8]=_+f,r[9]=p-m,r[10]=1-u-c,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1}static createAffineTransformation(e,t,r,s){var i=s.elements,a=t.x,n=t.y,o=t.z,l=t.w,h=a+a,u=n+n,d=o+o,c=a*h,_=a*u,p=a*d,g=n*u,m=n*d,f=o*d,T=l*h,y=l*u,x=l*d,S=r.x,E=r.y,v=r.z;i[0]=(1-(g+f))*S,i[1]=(_+x)*S,i[2]=(p-y)*S,i[3]=0,i[4]=(_-x)*E,i[5]=(1-(c+f))*E,i[6]=(m+T)*E,i[7]=0,i[8]=(p+y)*v,i[9]=(m-T)*v,i[10]=(1-(c+g))*v,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1}static createLookAt(e,t,r,s){var i=s.elements,n=ot,o=lt,l=ht;a.subtract(e,t,l),a.normalize(l,l),a.cross(r,l,n),a.normalize(n,n),a.cross(l,n,o),i[3]=i[7]=i[11]=0,i[15]=1,i[0]=n.x,i[4]=n.y,i[8]=n.z,i[1]=o.x,i[5]=o.y,i[9]=o.z,i[2]=l.x,i[6]=l.y,i[10]=l.z,i[12]=-a.dot(n,e),i[13]=-a.dot(o,e),i[14]=-a.dot(l,e)}static createPerspective(e,t,r,s,i){var a=1/Math.tan(.5*e),n=r/(a/t),o=r/a;nt.createPerspectiveOffCenter(-n,n,-o,o,r,s,i)}static createPerspectiveOffCenter(e,t,r,s,i,a,n){var o=n.elements,l=a/(a-i);o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[12]=o[13]=o[15]=0,o[0]=2*i/(t-e),o[5]=2*i/(s-r),o[8]=(e+t)/(t-e),o[9]=(s+r)/(s-r),o[10]=-l,o[11]=-1,o[14]=-i*l}static createOrthoOffCenter(e,t,r,s,i,a,n){var o=n.elements,l=1/(a-i);o[1]=o[2]=o[3]=o[4]=o[6]=o[8]=o[7]=o[9]=o[11]=0,o[15]=1,o[0]=2/(t-e),o[5]=2/(s-r),o[10]=-l,o[12]=(e+t)/(e-t),o[13]=(s+r)/(r-s),o[14]=-i*l}constructor(e=1,t=0,r=0,s=0,i=0,a=1,n=0,o=0,l=0,h=0,u=1,d=0,c=0,_=0,p=0,g=1,m=null){if(0!=arguments.length){if(1!==arguments.length||null!==arguments[0]){var f=this.elements=m||new Float32Array(16);f[0]=e,f[1]=t,f[2]=r,f[3]=s,f[4]=i,f[5]=a,f[6]=n,f[7]=o,f[8]=l,f[9]=h,f[10]=u,f[11]=d,f[12]=c,f[13]=_,f[14]=p,f[15]=g}}else this.elements=at.slice()}getElementByRowColumn(e,t){if(e<0||e>3)throw new Error("row for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column for matrices run from 0 to 3, inclusive.");return this.elements[4*e+t]}setElementByRowColumn(e,t,r){if(e<0||e>3)throw new Error("row for matrices run from 0 to 3, inclusive.");if(t<0||t>3)throw new Error("column for matrices run from 0 to 3, inclusive.");this.elements[4*e+t]=r}setRotation(e){var t=e.x,r=e.y,s=e.z,i=e.w,a=t*t,n=r*r,o=s*s,l=t*r,h=s*i,u=s*t,d=r*i,c=r*s,_=t*i,p=this.elements;p[0]=1-2*(n+o),p[1]=2*(l+h),p[2]=2*(u-d),p[4]=2*(l-h),p[5]=1-2*(o+a),p[6]=2*(c+_),p[8]=2*(u+d),p[9]=2*(c-_),p[10]=1-2*(n+a)}setPosition(e){var t=this.elements;t[12]=e.x,t[13]=e.y,t[14]=e.z}equalsOtherMatrix(e){var t=this.elements,r=e.elements;return s.nearEqual(t[0],r[0])&&s.nearEqual(t[1],r[1])&&s.nearEqual(t[2],r[2])&&s.nearEqual(t[3],r[3])&&s.nearEqual(t[4],r[4])&&s.nearEqual(t[5],r[5])&&s.nearEqual(t[6],r[6])&&s.nearEqual(t[7],r[7])&&s.nearEqual(t[8],r[8])&&s.nearEqual(t[9],r[9])&&s.nearEqual(t[10],r[10])&&s.nearEqual(t[11],r[11])&&s.nearEqual(t[12],r[12])&&s.nearEqual(t[13],r[13])&&s.nearEqual(t[14],r[14])&&s.nearEqual(t[15],r[15])}decomposeTransRotScale(e,t,r){var s=dt;return this.decomposeTransRotMatScale(e,s,r)?(et.createFromMatrix4x4(s,t),!0):(t.identity(),!1)}decomposeTransRotMatScale(e,t,r){var i=this.elements,n=e,o=t.elements,l=r;n.x=i[12],n.y=i[13],n.z=i[14];var h=i[0],u=i[1],d=i[2],c=i[4],_=i[5],p=i[6],g=i[8],m=i[9],f=i[10],T=l.x=Math.sqrt(h*h+u*u+d*d),y=l.y=Math.sqrt(c*c+_*_+p*p),x=l.z=Math.sqrt(g*g+m*m+f*f);if(s.isZero(T)||s.isZero(y)||s.isZero(x))return o[1]=o[2]=o[3]=o[4]=o[6]=o[7]=o[8]=o[9]=o[11]=o[12]=o[13]=o[14]=0,o[0]=o[5]=o[10]=o[15]=1,!1;var S=ot;S.x=g/x,S.y=m/x,S.z=f/x;var E=lt;E.x=h/T,E.y=u/T,E.z=d/T;var v=ht;a.cross(S,E,v);var D=lt;return a.cross(v,S,D),o[3]=o[7]=o[11]=o[12]=o[13]=o[14]=0,o[15]=1,o[0]=D.x,o[1]=D.y,o[2]=D.z,o[4]=v.x,o[5]=v.y,o[6]=v.z,o[8]=S.x,o[9]=S.y,o[10]=S.z,o[0]*h+o[1]*u+o[2]*d<0&&(l.x=-T),o[4]*c+o[5]*_+o[6]*p<0&&(l.y=-y),o[8]*g+o[9]*m+o[10]*f<0&&(l.z=-x),!0}decomposeYawPitchRoll(e){var t=Math.asin(-this.elements[9]);e.y=t,Math.cos(t)>s.zeroTolerance?(e.z=Math.atan2(this.elements[1],this.elements[5]),e.x=Math.atan2(this.elements[8],this.elements[10])):(e.z=Math.atan2(-this.elements[4],this.elements[0]),e.x=0)}normalize(){var e=this.elements,t=e[0],r=e[1],s=e[2],i=Math.sqrt(t*t+r*r+s*s);if(!i)return e[0]=0,e[1]=0,void(e[2]=0);1!=i&&(i=1/i,e[0]=t*i,e[1]=r*i,e[2]=s*i)}transpose(){var e,t;return t=(e=this.elements)[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}invert(e){var t=this.elements,r=e.elements,s=t[0],i=t[1],a=t[2],n=t[3],o=t[4],l=t[5],h=t[6],u=t[7],d=t[8],c=t[9],_=t[10],p=t[11],g=t[12],m=t[13],f=t[14],T=t[15],y=s*l-i*o,x=s*h-a*o,S=s*u-n*o,E=i*h-a*l,v=i*u-n*l,D=a*u-n*h,w=d*m-c*g,R=d*f-_*g,C=d*T-p*g,M=c*f-_*m,b=c*T-p*m,A=_*T-p*f,I=y*A-x*b+S*M+E*C-v*R+D*w;0!==Math.abs(I)&&(I=1/I,r[0]=(l*A-h*b+u*M)*I,r[1]=(a*b-i*A-n*M)*I,r[2]=(m*D-f*v+T*E)*I,r[3]=(_*v-c*D-p*E)*I,r[4]=(h*C-o*A-u*R)*I,r[5]=(s*A-a*C+n*R)*I,r[6]=(f*S-g*D-T*x)*I,r[7]=(d*D-_*S+p*x)*I,r[8]=(o*b-l*C+u*w)*I,r[9]=(i*C-s*b-n*w)*I,r[10]=(g*v-m*S+T*y)*I,r[11]=(c*S-d*v-p*y)*I,r[12]=(l*R-o*M-h*w)*I,r[13]=(s*M-i*R+a*w)*I,r[14]=(m*x-g*E-f*y)*I,r[15]=(d*E-c*x+_*y)*I)}static billboard(e,t,r,i,n){a.subtract(e,t,ot);var o=a.scalarLengthSquared(ot);s.isZero(o)?(a.scale(i,-1,lt),lt.cloneTo(ot)):a.scale(ot,1/Math.sqrt(o),ot),a.cross(r,ot,ht),a.normalize(ht,ht),a.cross(ot,ht,ut);var l=ht,h=ut,u=ot,d=e,c=n.elements;c[0]=l.x,c[1]=l.y,c[2]=l.z,c[3]=0,c[4]=h.x,c[5]=h.y,c[6]=h.z,c[7]=0,c[8]=u.x,c[9]=u.y,c[10]=u.z,c[11]=0,c[12]=d.x,c[13]=d.y,c[14]=d.z,c[15]=1}identity(){this.elements.set(at)}isIdentity(){let e=function(e,t){return Math.abs(e-t)<1e-7},t=this.elements,r=nt.DEFAULT.elements;for(let s=0,i=t.length;s<i;s++)if(!e(t[s],r[s]))return!1;return!0}cloneTo(e){this.elements!==e.elements&&e.elements.set(this.elements)}cloneByArray(e){this.elements.set(e)}clone(){var e=new nt(null);return e.elements=this.elements.slice(),e}static translation(e,t){var r=t.elements;r[0]=r[5]=r[10]=r[15]=1,r[12]=e.x,r[13]=e.y,r[14]=e.z}getTranslationVector(e){var t=this.elements;e.x=t[12],e.y=t[13],e.z=t[14]}setTranslationVector(e){var t=this.elements,r=e;t[12]=r.x,t[13]=r.y,t[14]=r.z}getForward(e){var t=this.elements;e.x=-t[8],e.y=-t[9],e.z=-t[10]}setForward(e){var t=this.elements;t[8]=-e.x,t[9]=-e.y,t[10]=-e.z}getInvertFront(){this.decomposeTransRotScale(ot,et.TEMP,lt);var e=lt,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t}}nt.TEMP=new nt,nt.DEFAULT=new nt,nt.DEFAULTINVERT=new nt(-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),nt.ZERO=new nt(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const ot=new a,lt=new a,ht=new a,ut=new a,dt=new nt;class ct{constructor(){this._version=-1,this._block=null,this._uniform=null}_revalidate(){const e=this._owner;if(this._version===e._uboLayoutVersion)return null!=this._uniform;this._version=e._uboLayoutVersion;const t=e._getUniformBlockByProperty(this._index);return this._block=t,this._uniform=t?t.descriptor.uniforms.get(this._index):null,null!=this._uniform}setInt(e){return!!this._revalidate()&&(this._block._writeInt(this._uniform,e),!0)}setFloat(e){return!!this._revalidate()&&(this._block._writeFloat(this._uniform,e),!0)}setVector2(e){return!!this._revalidate()&&(this._block._writeVector2(this._uniform,e),!0)}setVector3(e){return!!this._revalidate()&&(this._block._writeVector3(this._uniform,e),!0)}setVector4(e){return!!this._revalidate()&&(this._block._writeVector4(this._uniform,e),!0)}setMatrix3x3(e){return!!this._revalidate()&&(this._block._writeMatrix3x3(this._uniform,e),!0)}setMatrix4x4(e){return!!this._revalidate()&&(this._block._writeMatrix4x4(this._uniform,e),!0)}setBuffer(e){return!!this._revalidate()&&(this._block._writeBuffer(this._uniform,e),!0)}setArray(e){return!!this._revalidate()&&(this._block._writeArrayBuffer(this._uniform,e),!0)}}var _t;function pt(e){return e==Ot.BLEND||e==Ot.BLEND_SRC||e==Ot.BLEND_DST||e==Ot.BLEND_SRC_RGB||e==Ot.BLEND_DST_RGB||e==Ot.BLEND_SRC_ALPHA||e==Ot.BLEND_DST_ALPHA||e==Ot.BLEND_EQUATION||e==Ot.BLEND_EQUATION_RGB||e==Ot.BLEND_EQUATION_ALPHA}function gt(e){return function(e){return e==Ot.DEPTH_TEST||e==Ot.DEPTH_WRITE||e==Ot.DEPTH_BIAS||e==Ot.DEPTH_BIAS_CONSTANT||e==Ot.DEPTH_BIAS_SLOPESCALE||e==Ot.DEPTH_BIAS_CLAMP}(e)||function(e){return e==Ot.STENCIL_TEST||e==Ot.STENCIL_WRITE||e==Ot.STENCIL_WRITE_MASK||e==Ot.STENCIL_READ_MASK||e==Ot.STENCIL_Ref||e==Ot.STENCIL_Op}(e)}function mt(e){return e==Ot.CULL}function ft(t,r){let s=!1;switch(r){case e.ShaderDataType.Int:case e.ShaderDataType.Float:s="number"==typeof t;break;case e.ShaderDataType.Bool:s="boolean"==typeof t;break;case e.ShaderDataType.Vector2:s=t instanceof $e;break;case e.ShaderDataType.Vector3:s=t instanceof a;break;case e.ShaderDataType.Vector4:s=t instanceof i;break;case e.ShaderDataType.Color:s=t instanceof y;break;case e.ShaderDataType.Matrix4x4:s=t instanceof nt;break;case e.ShaderDataType.Texture2D:case e.ShaderDataType.TextureCube:s=t instanceof V;break;case e.ShaderDataType.Buffer:s=t instanceof ArrayBuffer;break;case e.ShaderDataType.Matrix3x3:s=t instanceof je;break;default:s=!1}return s||console.warn("The setting value and Shader type do not match"),s}function Tt(t){switch(t){case e.ShaderDataType.Int:return 0;case e.ShaderDataType.Bool:return!1;case e.ShaderDataType.Float:return 0;case e.ShaderDataType.Vector2:return $e.ZERO;case e.ShaderDataType.Vector3:return a.ZERO;case e.ShaderDataType.Vector4:return i.ZERO;case e.ShaderDataType.Color:return y.BLACK;case e.ShaderDataType.Matrix4x4:return nt.DEFAULT;case e.ShaderDataType.Matrix3x3:return je.DEFAULT}return null}e.ShaderDataType=void 0,(_t=e.ShaderDataType||(e.ShaderDataType={}))[_t.None=0]="None",_t[_t.Int=1]="Int",_t[_t.Bool=2]="Bool",_t[_t.Float=3]="Float",_t[_t.Vector2=4]="Vector2",_t[_t.Vector3=5]="Vector3",_t[_t.Vector4=6]="Vector4",_t[_t.Vector4u=7]="Vector4u",_t[_t.Color=8]="Color",_t[_t.Matrix4x4=9]="Matrix4x4",_t[_t.Buffer=10]="Buffer",_t[_t.Matrix3x3=11]="Matrix3x3",_t[_t.ReadOnlyDeviceBuffer=12]="ReadOnlyDeviceBuffer",_t[_t.DeviceBuffer=13]="DeviceBuffer",_t[_t.StorageTexture2D=14]="StorageTexture2D",_t[_t.Texture2D=15]="Texture2D",_t[_t.Texture3D=16]="Texture3D",_t[_t.TextureCube=17]="TextureCube",_t[_t.Texture2DArray=18]="Texture2DArray";class yt{static getTargetCount(e){let t=0;for(const r of e){if(!r.startsWith(this.targetDefinePrefix))continue;const e=Number(r.substring(this.targetDefinePrefix.length));if(!Number.isSafeInteger(e)||e<1||t&&t!==e)throw new Error("Invalid MRT shader target count.");t=e}return t}static prepare(e,t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Invalid MRT shader target count.");const r=e.replace(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/g,e=>e.replace(/[^\r\n]/g," "));let s="laya_MRT_";for(;-1!==r.indexOf(s);)s+="x";const i=[],a=/^[ \t]*#(?:\\\r?\n|[^\r\n])*|[A-Za-z_]\w*|\d+|[^\s]/gm;let n,o=0,l=0,h=0,u=!1;const d=`\n#define ${s}LEGACY\n`;for(;n=a.exec(r);){const e=n[0].trim();if("#"!==e[0]){if(u||"gl_FragColor"!==e&&"pc_fragColor"!==e||i.push({position:n.index,text:d}),"gl_FragData"===e&&i.push({position:n.index,text:"\n#error LAYA_MRT does not support gl_FragData\n"}),"out"===e&&0===o&&0===l&&(u=!0),"("===e)l++;else if(")"===e)l--;else if("{"===e){if(u)throw new Error("LAYA_MRT output blocks are not supported.");o++}else if("}"===e)o--,0===o&&(h=a.lastIndex);else if(";"===e&&0===o&&0===l){if(u){const e=r.slice(h,a.lastIndex),n=/^\s*layout\s*\(\s*location\s*=\s*(\d+|[A-Za-z_]\w*)\s*\)\s*out\s+(?:(?:highp|mediump|lowp)\s+)?vec4\s+([A-Za-z_]\w*)\s*;\s*$/.exec(e);let o="\n";if(n&&"pc_fragColor"!==n[2]){const e=n[1];for(let r=0;r<t;r++){const t=`${s}HAS_${r}`;o+=`#if (${e}) == ${r}\n#ifdef ${t}\n#error Duplicate MRT output location\n#endif\n#define ${t}\n#endif\n`}}else o+="#error LAYA_MRT requires explicitly located vec4 outputs with non-reserved names\n";i.push({position:a.lastIndex,text:o})}h=a.lastIndex,u=!1}}else/^#\s*define\b/.test(e)&&/\b(gl_FragColor|pc_fragColor)\b/.test(e)&&i.push({position:n.index,text:d}),0!==o||u||(h=a.lastIndex)}let c=e;for(let e=i.length-1;e>=0;e--){const t=i[e];c=c.slice(0,t.position)+t.text+c.slice(t.position)}let _=`\n#undef main\n#if defined(${s}LEGACY) && defined(${s}HAS_0)\n#error LAYA_MRT legacy output conflicts with explicit location 0\n#endif\n`;for(let e=0;e<t;e++)_+=`#ifndef ${s}HAS_${e}\nlayout(location = ${e}) out highp vec4 ${s}color${e};\n#endif\n`;_+="void main() {\npc_fragColor = vec4(0.0);\n";for(let e=1;e<t;e++)_+=`#ifndef ${s}HAS_${e}\n${s}color${e} = vec4(0.0);\n#endif\n`;return _+=`${s}main();\n#ifdef LAYA_MRT_POST_MAIN_HOOK\nLAYA_MRT_POST_MAIN_HOOK();\n#endif\n#ifndef ${s}HAS_0\n${s}color0 = pc_fragColor;\n#endif\n}\n`,`highp vec4 pc_fragColor;\n#define gl_FragColor pc_fragColor\n#define main ${s}main\n${c}${_}`}static extract(e,t=!1){const r=e.replace(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/g,e=>e.replace(/[^\r\n]/g," ")),s=/^[ \t]*#(?:\\\r?\n|[^\r\n])*|[A-Za-z_]\w*|\d+|[^\s]/gm,i=new Set,a=new Set,n=[],o=[];let l,h=0,u=0,d=0,c=0,_=!1,p=!1;for(;l=s.exec(r);){const e=l[0].trim();if("#"!==e[0]){if("gl_FragData"===e||!t&&("gl_FragColor"===e||"pc_fragColor"===e))throw new Error("LAYA_MRT cannot use legacy/default fragment outputs; declare layout(location = N) out vec4 outputs.");if("out"===e&&0===h&&0===u&&(_=!0,p=0!==d),"("===e)u++;else if(")"===e)u--;else if("{"===e){if(_)throw new Error("LAYA_MRT output blocks are not supported.");h++}else if("}"===e)h--,0===h&&(c=s.lastIndex);else if(";"===e&&0===h&&0===u){if(_){if(p)throw new Error("LAYA_MRT output extraction requires preprocessed GLSL; found an unresolved #if branch.");const e=r.slice(c,s.lastIndex),t=/^\s*layout\s*\(\s*location\s*=\s*(\d+)\s*\)\s*out\s+(?:(highp|mediump|lowp)\s+)?vec4\s+([A-Za-z_]\w*)\s*;\s*$/.exec(e);if(!t)throw new Error("LAYA_MRT requires 'layout(location = N) out [precision] vec4 name;' with a literal non-negative integer location.");const l=Number(t[1]),h=t[3];if(!Number.isSafeInteger(l)||i.has(l))throw new Error(`LAYA_MRT has an invalid or duplicate output location ${t[1]}.`);if(a.has(h))throw new Error(`LAYA_MRT has a duplicate output name '${h}'.`);i.add(l),a.add(h),n.push(`layout(location = ${l}) out ${t[2]?t[2]+" ":""}vec4 ${h};`),o.push([c,s.lastIndex])}c=s.lastIndex,_=!1,p=!1}}else/^#\s*(if|ifdef|ifndef)\b/.test(e)?d++:/^#\s*endif\b/.test(e)&&d--,0!==h||_||(c=s.lastIndex)}if(!n.length||_)throw new Error("LAYA_MRT requires explicit fragment output declarations.");let g=e;for(let e=o.length-1;e>=0;e--){const[t,r]=o[e];g=g.slice(0,t)+g.slice(t,r).replace(/[^\r\n]/g," ")+g.slice(r)}return{declarations:n.join("\n"),source:g}}}yt.defineName="LAYA_MRT",yt.targetDefinePrefix="LAYA_MRT_TARGET_";class xt{constructor(e,t,r){this._owner=e,this.name=t,this._VS=r.vsNode,this._PS=r.psNode,this._defs=r.defs,this._validDefine=f.unitRenderModuleDataFactory.createDefineDatas();for(let e of r.defs)this._validDefine.add(Ot.getDefineByName(e));this._validDefine.add(Ot.getDefineByName("VBONEW")),this._validDefine.add(Ot.getDefineByName("VBONEI")),this._validDefine.add(Ot.getDefineByName(yt.defineName))}withCompile(e){return null}}class St extends xt{get pipelineMode(){return this._pipelineMode}set pipelineMode(e){this._pipelineMode=e,this.moduleData.pipelineMode=e}set nodeCommonMap(e){this.moduleData.nodeCommonMap=e}get nodeCommonMap(){return this.moduleData.nodeCommonMap}set additionShaderData(e){this.moduleData.additionShaderData=e}get additionShaderData(){return this.moduleData.additionShaderData}get statefirst(){return this._statefirst}set statefirst(e){this._statefirst=e,this.moduleData.statefirst=e}get attributeLocations(){return this.moduleData.attributeLocations}set attributeLocations(e){this.moduleData.attributeLocations=e}get renderState(){return this.moduleData.renderState}constructor(t,r){var s;super(t,t._owner.name,r),this._statefirst=!1,this.moduleData=f.unitRenderModuleDataFactory.createShaderPass(this),this.moduleData.validDefine=this._validDefine,this.moduleData.name=this.name;let i=null===(s=t._owner)||void 0===s?void 0:s.shaderType;i!==e.ShaderFeatureType.D2_TextureSV&&i!==e.ShaderFeatureType.D2_primitive&&i!==e.ShaderFeatureType.D2_BaseRenderNode2D||(this.moduleData.is2D=!0)}static createShaderInstance(e,t,r){Et.length=0,Ot._getNamesByDefineData(r,Et);let s={is2D:t,vs:e._VS,ps:e._PS,attributeMap:e._owner._attributeMap,uniformMap:e._owner._uniformMap,defineString:Et};return f.renderDeviceFactory.createShaderInstance(s,e)}withCompile(e,t=!1,r){if(void 0!==r){const t=Ot.getDefineByName(yt.defineName);r>0?e.add(t):e.remove(t)}else{const t=[];Ot._getNamesByDefineData(e,t),r=yt.getTargetCount(t)}if(this._mrtTargetDefines)for(const t of this._mrtTargetDefines.values())e.remove(t);if(r>0){this._mrtTargetDefines||(this._mrtTargetDefines=new Map);let t=this._mrtTargetDefines.get(r);t||(t=Ot.getDefineByName(yt.targetDefinePrefix+r),this._mrtTargetDefines.set(r,t),this._validDefine.add(t)),e.add(t)}var s=this.moduleData.getCacheShader(e);return s||(s=St.createShaderInstance(this,t,e),this.moduleData.setCacheShader(e,s),s)}withComplieByBin(e,t=!1,r){var s=this.moduleData.getCacheShader(e);return s||(this.moduleData.setCacheShader(e,s),null)}}const Et=[];class vt{get offset(){return this._offset}get elementFormat(){return this._elementFormat}get elementUsage(){return this._elementUsage}constructor(e,t,r){this._offset=e,this._elementFormat=t,this._elementUsage=r}}var Dt,wt,Rt,Ct,Mt,bt,At;e.RenderParams=void 0,(Dt=e.RenderParams||(e.RenderParams={}))[Dt.Max_Active_Texture_Count=0]="Max_Active_Texture_Count",Dt[Dt.Max_Uniform_Count=1]="Max_Uniform_Count",Dt[Dt.Max_AnisoLevel_Count=2]="Max_AnisoLevel_Count",Dt[Dt.MAX_Texture_Size=3]="MAX_Texture_Size",Dt[Dt.MAX_Texture_Image_Uint=4]="MAX_Texture_Image_Uint",Dt[Dt.SHADER_CAPAILITY_LEVEL=5]="SHADER_CAPAILITY_LEVEL",Dt[Dt.FLOAT=6]="FLOAT",Dt[Dt.UNSIGNED_BYTE=7]="UNSIGNED_BYTE",Dt[Dt.BYTE=8]="BYTE",Dt[Dt.UNSIGNED_SHORT=9]="UNSIGNED_SHORT",Dt[Dt.MaxComputeElement=10]="MaxComputeElement",Dt[Dt.Max_Color_Attachment_Count=11]="Max_Color_Attachment_Count",Dt[Dt.Max_Color_Attachment_Bytes_Per_Sample=12]="Max_Color_Attachment_Bytes_Per_Sample";class It{static __init__(){It._elementInfos={single:[1,f.renderEngine.getParams(e.RenderParams.FLOAT),0],vector2:[2,f.renderEngine.getParams(e.RenderParams.FLOAT),0],vector3:[3,f.renderEngine.getParams(e.RenderParams.FLOAT),0],vector4:[4,f.renderEngine.getParams(e.RenderParams.FLOAT),0],color:[4,f.renderEngine.getParams(e.RenderParams.FLOAT),0],byte4:[4,f.renderEngine.getParams(e.RenderParams.UNSIGNED_BYTE),0],byte3:[3,f.renderEngine.getParams(e.RenderParams.UNSIGNED_BYTE),0],byte2:[2,f.renderEngine.getParams(e.RenderParams.UNSIGNED_BYTE),0],byte:[1,f.renderEngine.getParams(e.RenderParams.UNSIGNED_BYTE),0],short2:[2,f.renderEngine.getParams(e.RenderParams.UNSIGNED_SHORT),0],short4:[4,f.renderEngine.getParams(e.RenderParams.UNSIGNED_SHORT),0],normalizedshort2:[2,f.renderEngine.getParams(e.RenderParams.UNSIGNED_SHORT),1],normalizedshort4:[4,f.renderEngine.getParams(e.RenderParams.UNSIGNED_SHORT),1],halfvector2:[2,f.renderEngine.getParams(e.RenderParams.FLOAT),0],halfvector4:[4,f.renderEngine.getParams(e.RenderParams.FLOAT),0],nbyte4:[4,f.renderEngine.getParams(e.RenderParams.BYTE),1],ubyte4:[4,f.renderEngine.getParams(e.RenderParams.UNSIGNED_BYTE),1]}}static getElementInfos(e){var t=It._elementInfos[e];if(t)return t;throw new C}}It.Single="single",It.Vector2="vector2",It.Vector3="vector3",It.Vector4="vector4",It.Color="color",It.Byte4="byte4",It.Byte3="byte3",It.Byte2="byte2",It.ByteOne="byte",It.Short2="short2",It.Short4="short4",It.NormalizedShort2="normalizedshort2",It.NormalizedShort4="normalizedshort4",It.HalfVector2="halfvector2",It.HalfVector4="halfvector4",It.NorByte4="nbyte4",It.NorUByte4="ubyte4";class Pt{}class Bt{get id(){return this._id}get vertexStride(){return this._vertexStride}get vertexElementCount(){return this._vertexElements.length}constructor(e,t){this._id=++Bt._uniqueIDCounter,this._vertexElementsDic={},this._vertexStride=e,this._vertexElements=t,this._VAElements=[];var r=t.length;this._shaderValues={};for(var s=0;s<r;s++){var i=t[s],a=i._elementUsage;this._vertexElementsDic[a]=i;var n=new Pt,o=It.getElementInfos(i._elementFormat);n.elementString=i._elementFormat,n.elementCount=o[0],n.elementType=o[1],n.normalized=o[2],n.vertexStride=this._vertexStride,n.elementOffset=i._offset,this._shaderValues[a]=n,this._VAElements.push({format:i._elementFormat,stride:i._offset,shaderLocation:a})}}getVertexElementByIndex(e){return this._vertexElements[e]}getVertexElementByUsage(e){return this._vertexElementsDic[e]}}Bt._uniqueIDCounter=1;class Lt{static __init__(){Lt.instanceWorldMatrixDeclaration=new Bt(80,[new vt(0,It.Vector4,Lt.MESH_WORLDMATRIX_ROW0),new vt(16,It.Vector4,Lt.MESH_WORLDMATRIX_ROW1),new vt(32,It.Vector4,Lt.MESH_WORLDMATRIX_ROW2),new vt(48,It.Vector4,Lt.MESH_WORLDMATRIX_ROW3),new vt(64,It.Vector4,Lt.MESH_CUSTOME2)]),Lt.instanceSimpleAnimatorDeclaration=new Bt(16,[new vt(0,It.Vector4,Lt.MESH_SIMPLEANIMATOR)]),Lt.instanceLightMapScaleOffsetDeclaration=new Bt(16,[new vt(0,It.Vector4,Lt.MESH_LIGHTMAPSCALEOFFSET)])}static getVertexDeclaration(e,t=!0){var r=Lt._vertexDeclarationMap[e+(t?"_0":"_1")];if(!r){for(var s=e.split(","),i=0,a=[],n=0,o=s.length;n<o;n++){var l;switch(s[n]){case"POSITION":l=new vt(i,It.Vector3,Lt.MESH_POSITION0),i+=12;break;case"NORMAL":l=new vt(i,It.Vector3,Lt.MESH_NORMAL0),i+=12;break;case"COLOR":l=new vt(i,It.Vector4,Lt.MESH_COLOR0),i+=16;break;case"UV":l=new vt(i,It.Vector2,Lt.MESH_TEXTURECOORDINATE0),i+=8;break;case"UV1":l=new vt(i,It.Vector2,Lt.MESH_TEXTURECOORDINATE1),i+=8;break;case"BLENDWEIGHT":l=new vt(i,It.Vector4,Lt.MESH_BLENDWEIGHT0),i+=16;break;case"BLENDINDICES":t?(l=new vt(i,It.Vector4,Lt.MESH_BLENDINDICES0),i+=16):(l=new vt(i,It.Byte4,Lt.MESH_BLENDINDICES0),i+=4);break;case"TANGENT":l=new vt(i,It.Vector4,Lt.MESH_TANGENT0),i+=16;break;case"NORMAL_BYTE":l=new vt(i,It.NorByte4,Lt.MESH_NORMAL0),i+=4;break;default:throw"VertexMesh: unknown vertex flag."}a.push(l)}r=new Bt(i,a),Lt._vertexDeclarationMap[e+(t?"_0":"_1")]=r}return r}}Lt.MESH_POSITION0=0,Lt.MESH_COLOR0=1,Lt.MESH_TEXTURECOORDINATE0=2,Lt.MESH_NORMAL0=3,Lt.MESH_TANGENT0=4,Lt.MESH_BLENDINDICES0=5,Lt.MESH_BLENDWEIGHT0=6,Lt.MESH_TEXTURECOORDINATE1=7,Lt.MESH_WORLDMATRIX_ROW0=8,Lt.MESH_WORLDMATRIX_ROW1=9,Lt.MESH_WORLDMATRIX_ROW2=10,Lt.MESH_WORLDMATRIX_ROW3=11,Lt.MESH_SIMPLEANIMATOR=12,Lt.MESH_LIGHTMAPSCALEOFFSET=13,Lt.MESH_CUSTOME0=12,Lt.MESH_CUSTOME1=13,Lt.MESH_CUSTOME2=14,Lt.MESH_CUSTOME3=15,Lt._vertexDeclarationMap={};class Nt{static regIncludeBindUnifrom(e,t,r){let s={},i=s[e]={};i.uniformMap=t,i.defaultValue=r,Object.assign(Nt.IncludeUniformMap,s)}constructor(t=Nt.DefaultAttributeMap,r={},s=null){this._flags={},this._passes=[],this.moduleData=f.unitRenderModuleDataFactory.createSubShader(),this._attributeMap=t,this._uniformDefaultValue=s,this._uniformMap=new Map;for(const t in r){const s=r[t];if("object"==typeof s&&null!==s)if(Ft(s)){let r=s;if(this.addUniform(t,r.type,{format:r.format,access:r.access}),r.type==e.ShaderDataType.Texture2D||r.type==e.ShaderDataType.TextureCube||r.type==e.ShaderDataType.Texture3D||r.type==e.ShaderDataType.Texture2DArray){let e=Ot.getDefineByName(`Gamma_${t}`),r=Ot.propertyNameToID(t);f.renderEngine.addTexGammaDefine(r,e)}}else{let e=s;for(const t in e){let r=e[t];if("object"==typeof r&&Ft(r)){let e=r;this.addUniform(t,e.type,{format:e.format,access:e.access})}else this.addUniform(t,r)}}else{let r=s;if(this.addUniform(t,r),r==e.ShaderDataType.Texture2D||r==e.ShaderDataType.TextureCube||r==e.ShaderDataType.Texture3D||r==e.ShaderDataType.Texture2DArray){let e=Ot.getDefineByName(`Gamma_${t}`),r=Ot.propertyNameToID(t);f.renderEngine.addTexGammaDefine(r,e)}}}this.moduleData.setUniformMap(this._uniformMap)}addUniform(t,r,s){let i=t,a=function(e){let t=e.lastIndexOf("]"),r=e.lastIndexOf("[");if(-1!=r&&t==e.length-1){let s=e.slice(r+1,t),i=parseInt(s);if(!isNaN(i)&&i>0)return i}return 0}(t);a>0&&(i=t.substring(0,t.lastIndexOf("[")));let n={id:Ot.propertyNameToID(i),propertyName:i,uniformtype:r,arrayLength:a,format:null==s?void 0:s.format,access:null==s?void 0:s.access};if(this._uniformMap.set(n.id,n),r==e.ShaderDataType.Texture2D||r==e.ShaderDataType.TextureCube||r==e.ShaderDataType.Texture3D||r==e.ShaderDataType.Texture2DArray){let e=Ot.getDefineByName(`Gamma_${t}`);f.renderEngine.addTexGammaDefine(n.id,e)}}addShaderPass(e,t,r="Forward"){return this._addShaderPass(qe.compile(e,t),r)}_addShaderPass(e,t="Forward"){var r=new St(this,e);return r.pipelineMode=t,this._passes.push(r),this._addIncludeUniform(e.includeNames),this.moduleData.addShaderPass(r.moduleData),r}_addIncludeUniform(e){for(let r of e)if(Nt.IncludeUniformMap[r]){let e=Nt.IncludeUniformMap[r],s=e.uniformMap,i=e.defaultValue;for(var t in s)this._uniformMap.has(Ot.propertyNameToID(t))||this.addUniform(t,s[t]);for(var t in i)this._uniformDefaultValue[t]||(this._uniformDefaultValue[t]=i[t])}}}function Ft(e){if(null===e||"object"!=typeof e||"number"!=typeof e.type)return!1;for(const t in e)if("type"!==t&&"format"!==t&&"access"!==t)return!1;return!0}Nt.IncludeUniformMap={},Nt.DefaultAttributeMap={a_Position:[Lt.MESH_POSITION0,e.ShaderDataType.Vector4],a_Normal:[Lt.MESH_NORMAL0,e.ShaderDataType.Vector3],a_Tangent0:[Lt.MESH_TANGENT0,e.ShaderDataType.Vector4],a_Texcoord0:[Lt.MESH_TEXTURECOORDINATE0,e.ShaderDataType.Vector2],a_Texcoord1:[Lt.MESH_TEXTURECOORDINATE1,e.ShaderDataType.Vector2],a_Color:[Lt.MESH_COLOR0,e.ShaderDataType.Vector4],a_BoneWeights:[Lt.MESH_BLENDWEIGHT0,e.ShaderDataType.Vector4],a_BoneIndices:[Lt.MESH_BLENDINDICES0,e.ShaderDataType.Vector4],a_WorldMat:[Lt.MESH_WORLDMATRIX_ROW0,e.ShaderDataType.Matrix4x4],a_SimpleTextureParams:[Lt.MESH_SIMPLEANIMATOR,e.ShaderDataType.Vector4],a_LightmapScaleOffset:[Lt.MESH_LIGHTMAPSCALEOFFSET,e.ShaderDataType.Vector4],a_WorldInvertFront:[Lt.MESH_CUSTOME2,e.ShaderDataType.Vector4]},e.ShaderFeatureType=void 0,(wt=e.ShaderFeatureType||(e.ShaderFeatureType={}))[wt.None=-1]="None",wt[wt.Default=0]="Default",wt[wt.D3=1]="D3",wt[wt.D2_primitive=2]="D2_primitive",wt[wt.D2_TextureSV=3]="D2_TextureSV",wt[wt.D2_BaseRenderNode2D=4]="D2_BaseRenderNode2D",wt[wt.PostProcess=5]="PostProcess",wt[wt.Sky=6]="Sky",wt[wt.Effect=7]="Effect";class Ot{static init(){Ot._configDefineValues=f.unitRenderModuleDataFactory.createDefineDatas(),Ot.SHADERDEFINE_REMAP_POSITIONZ=Ot.getDefineByName("REMAP_Z"),Ot.SHADERDEFINE_LOD_TEXTURE_SAMPLE=Ot.getDefineByName("LOD_TEXTURE_SAMPLE"),Ot.SHADERDEFINE_BREAK_TEXTURE_SAMPLE=Ot.getDefineByName("BREAK_TEXTURE_SAMPLE"),f.renderEngine._remapZ&&Ot._configDefineValues.add(Ot.SHADERDEFINE_REMAP_POSITIONZ),f.renderEngine._lodTextureSample&&Ot._configDefineValues.add(Ot.SHADERDEFINE_LOD_TEXTURE_SAMPLE),f.renderEngine._breakTextureSample&&Ot._configDefineValues.add(Ot.SHADERDEFINE_BREAK_TEXTURE_SAMPLE),Ot._compileDefineDatas=f.unitRenderModuleDataFactory.createDefineDatas()}static _getNamesByDefineData(e,t){return f.renderEngine.getNamesByDefineData(e,t),t}static getDefineByName(e){return f.renderEngine.getDefineByName(e)}static propertyNameToID(e){return f.renderEngine.propertyNameToID(e)}static propertyIDToName(e){return f.renderEngine.propertyIDToName(e)}static addInclude(e,t,r){qe.addInclude(e,t,r)}static compileShaderByDefineNames(e,t,r,s,i,a,n,o){var l=Ot.find(e);if(l){var h=l.getSubShaderAt(t);if(h){var u=h._passes[r];if(u){u.nodeCommonMap=i,u.additionShaderData=a,u.attributeLocations=new Set(o);var d=Ot._compileDefineDatas;Ot._configDefineValues.cloneTo(d);for(let e of s)d.add(Ot.getDefineByName(e));return u.withCompile(d,n),!0}}}return!1}static compileShaderByBin(e,t,r,s,i,a){var n=Ot.find(e);if(n){var o=n.getSubShaderAt(t);if(o){var l=o._passes[r];if(l.nodeCommonMap=i,l){var h=Ot._compileDefineDatas;h.clear();for(let e of s)h.add(Ot.getDefineByName(e));l.withComplieByBin(h,!1,a)}}}}static add(e,t=!1,r=!1){return Ot._preCompileShader[e]=new Ot(e,t,r)}static find(e){return Ot._preCompileShader[e]}static parse(e,t){var r;e.name||console.warn("shader name is empty",e),e.uniformMap||console.warn(`${e.name}: uniformMap is empty`);let s=Ot.add(e.name,e.enableInstancing,e.supportReflectionProbe);s._supportVolumetricGI=e.supportVolumetricGI,s.shaderType=e.shaderType,s.previewType=e.previewType;let i=new Nt(e.attributeMap?e.attributeMap:Nt.DefaultAttributeMap,e.uniformMap,e.defaultValue);s.addSubShader(i);let a=e.shaderPass;for(var n in a){let s=a[n];if(!s.VS){console.warn(`${e.name}: VS of pass ${n} is empty`);continue}if(!s.FS){console.warn(`${e.name}: FS of pass ${n} is empty`);continue}let o=i._addShaderPass(qe.compile(s.VS,s.FS,t),s.pipeline);o.statefirst=null!==(r=s.statefirst)&&void 0!==r&&r,qe.getRenderState(s.renderState,o.renderState)}return s}get name(){return this._name}constructor(t,r,s){this._enableInstancing=!1,this._supportReflectionProbe=!1,this._supportVolumetricGI=!1,this._subShaders=[],this.shaderType=e.ShaderFeatureType.None,this.previewType=null,this._name=t,this._enableInstancing=r,this._supportReflectionProbe=s}addSubShader(e){this._subShaders.push(e),e._owner=this,e.moduleData.enableInstance=this._enableInstancing,e.moduleData.shaderName=this._name}getSubShaderAt(e){return this._subShaders[e]}}Ot.PERIOD_CUSTOM=0,Ot.PERIOD_MATERIAL=1,Ot.PERIOD_SPRITE=2,Ot.PERIOD_CAMERA=3,Ot.PERIOD_SCENE=4,Ot._propertyNameMap={},Ot._preCompileShader={},Ot.debugMode=!1;class Ut{destroy(){}static __init__(){Ot.addInclude("ClipFrag.glsl","#if !defined(ClipFrag_lib)\n#define ClipFrag_lib\nvoid clip(){}\n#endif\n"),Ot.addInclude("ClipVertex.glsl","#if !defined(ClipVertex_lib)\n#define ClipVertex_lib\n#ifdef UNIFORMCLIP\nuniform vec2 u_clipOffset;\n#endif\nvoid clip(inout vec2 globalPos){\n#ifdef UNIFORMCLIP\nglobalPos+=u_clipOffset;\n#endif\n}\n#endif\n"),Ot.addInclude("Sprite2DFrag.glsl",'#include "ClipFrag.glsl";\nvec3 gammaToLinear(in vec3 value){return pow((value+0.055)/1.055,vec3(2.4));}vec4 gammaToLinear(in vec4 value){return vec4(gammaToLinear(value.rgb),value.a);}vec3 linearToGamma(in vec3 value){return vec3(mix(pow(value.rgb,vec3(0.41666))*1.055-vec3(0.055),value.rgb*12.92,vec3(lessThanEqual(value.rgb,vec3(0.0031308)))));}vec4 linearToGamma(in vec4 value){return vec4(linearToGamma(value.rgb),value.a);}vec4 transspaceColor(vec4 color){\n#ifndef GAMMATEXTURE\n#ifdef GAMMASPACE\ncolor.xyz=linearToGamma(color.xyz);\n#endif\n#else\n#ifndef GAMMASPACE\ncolor.xyz=gammaToLinear(color.xyz);\n#endif\n#endif\nreturn color;}\n#ifdef TEXTUREVS\nvarying vec4 v_texcoordAlpha;varying vec4 v_color;varying float v_useTex;varying float v_useClip;varying vec4 v_customs;\n#ifdef USE_TEX_ARRAY\nvarying float v_texLayer;uniform sampler2DArray u_spriteTextureArray;\n#else\nuniform sampler2D u_spriteTexture;\n#endif\n#ifdef FILLTEXTURE\nuniform vec4 u_TexRange;\n#endif\nvec4 getSpriteTextureColor(){vec2 uv;\n#ifdef FILLTEXTURE\nvec2 tileUV=fract(v_texcoordAlpha.xy);vec4 trimRect=v_customs;if(tileUV.x<trimRect.x||tileUV.x>trimRect.x+trimRect.z||tileUV.y<trimRect.y||tileUV.y>trimRect.y+trimRect.w)discard;vec2 contentUV=(tileUV-trimRect.xy)/trimRect.zw;uv=contentUV*u_TexRange.zw+u_TexRange.xy;\n#else\nuv=v_texcoordAlpha.xy;\n#endif\n#ifdef USE_TEX_ARRAY\nvec4 color=texture(u_spriteTextureArray,vec3(uv,v_texLayer));\n#else\nvec4 color=texture2D(u_spriteTexture,uv);\n#endif\nreturn transspaceColor(color);}void setglColor(in vec4 color){float useTex=step(1.0,v_useTex);color=color*useTex+(1.0-useTex);\n#if defined(UV_CLIP_GPU) && !defined(FILLTEXTURE)\nif(v_useClip>=1.0){vec2 uv=v_texcoordAlpha.xy;vec4 c=v_customs;if(uv.x<c.x||uv.x>c.x+c.z||uv.y<c.y||uv.y>c.y+c.w)discard;}\n#endif\ncolor.a*=v_color.w;vec4 transColor=v_color;\n#ifndef GAMMASPACE\ntransColor=gammaToLinear(v_color);\n#endif\ncolor.rgb*=transColor.rgb;gl_FragColor=color;}\n#endif\n#ifdef BASERENDER2D\nvarying vec2 v_texcoord;varying vec4 v_color;uniform sampler2D u_baseRender2DTexture;uniform vec4 u_baseRenderColor;uniform vec4 u_tilingOffset;\n#ifdef LIGHT2D_ENABLE\nvarying vec2 v_lightUV;uniform vec3 u_LightDirection;uniform vec4 u_LightAndShadow2DParam;uniform vec4 u_LightAndShadow2DAmbient;uniform sampler2D u_LightAndShadow2D;\n#ifdef LIGHT2D_SCENEMODE_ADD\nuniform sampler2D u_LightAndShadow2D_AddMode;\n#endif\n#ifdef LIGHT2D_SCENEMODE_SUB\nuniform sampler2D u_LightAndShadow2D_SubMode;\n#endif\n#ifdef LIGHT2D_NORMAL_PARAM\nuniform sampler2D u_normal2DTexture;uniform float u_normal2DStrength;\n#endif\nvoid lightAndShadow(inout vec4 color){\n#ifdef LIGHT2D_EMPTY\ncolor.rgb*=u_LightAndShadow2DAmbient.rgb;\n#else\nvec2 uv=v_lightUV;vec2 tt=step(vec2(0.0),uv)*step(uv,vec2(1.0));float side=tt.x*tt.y;vec3 ambient=color.rgb*u_LightAndShadow2DAmbient.rgb;color.rgb=color.rgb*texture2D(u_LightAndShadow2D,uv).rgb*side;side*=color.a;\n#ifdef LIGHT2D_SCENEMODE_ADD\ncolor.rgb=min(vec3(1.0),color.rgb+texture2D(u_LightAndShadow2D_AddMode,uv).rgb*side);\n#endif\n#ifdef LIGHT2D_SCENEMODE_SUB\ncolor.rgb=max(vec3(0.0),color.rgb-texture2D(u_LightAndShadow2D_SubMode,uv).rgb*side);\n#endif\n#ifdef LIGHT2D_NORMAL_PARAM\nvec3 dr=normalize(u_LightDirection);vec3 normal=normalize(texture2D(u_normal2DTexture,v_texcoord).rgb*2.0-1.0);color.rgb=color.rgb*((1.0-u_normal2DStrength)+abs(dot(dr,normal.rgb))*u_normal2DStrength);\n#endif\ncolor.rgb=min(vec3(1.0),color.rgb+ambient);\n#endif\n}\n#endif\nvoid setglColor(in vec4 color){color.a*=v_color.w;vec4 transColor=v_color;\n#ifndef GAMMASPACE\ntransColor=gammaToLinear(v_color);\n#endif\ncolor.rgb*=transColor.rgb;gl_FragColor=color;}vec2 transformUV(in vec2 texcoord,in vec4 tilingOffset){vec2 uv=texcoord*tilingOffset.zw+tilingOffset.xy;return uv;}\n#endif\n'),Ot.addInclude("Sprite2DVertex.glsl",'\n#include "ClipVertex.glsl";\n#include "Color.glsl";\n#ifdef CAMERA2D\nuniform mat3 u_view2D;\n#endif\n#ifdef SPRITE2DGLOBAL\n#endif\n#ifdef RENDERTEXTURE\nuniform vec3 u_InvertMat_0;uniform vec3 u_InvertMat_1;\n#endif\n#ifdef VERTEX_SIZE\nuniform vec4 u_vertexSize;\n#endif\nuniform vec3 u_NMatrix_0;uniform vec3 u_NMatrix_1;uniform vec2 u_size;varying vec4 v_color;void transfrom(vec2 pos,vec3 xDir,vec3 yDir,out vec2 outPos){outPos.x=xDir.x*pos.x+xDir.y*pos.y+xDir.z;outPos.y=yDir.x*pos.x+yDir.y*pos.y+yDir.z;}void getGlobalPos(in vec2 localPos,out vec2 globalPos){transfrom(localPos,u_NMatrix_0,u_NMatrix_1,globalPos);}void getProjectPos(in vec2 viewPos,out vec4 projectPos){projectPos=vec4((viewPos.x/u_size.x-0.5)*2.0,(0.5-viewPos.y/u_size.y)*2.0,0.,1.0);\n#ifdef INVERTY\nprojectPos.y=-projectPos.y;\n#endif\n}void getViewPos(in vec2 globalPos,out vec2 viewPos){\n#ifdef RENDERTEXTURE\nvec2 tempPos;transfrom(globalPos,u_InvertMat_0,u_InvertMat_1,tempPos);\n#ifdef CAMERA2D\nviewPos.xy=(u_view2D*vec3(tempPos,1.0)).xy+u_size/2.;\n#else\nviewPos.xy=tempPos;\n#endif\n#else\n#ifdef CAMERA2D\nviewPos.xy=(u_view2D*vec3(globalPos,1.0)).xy+u_size/2.;\n#else\nviewPos.xy=globalPos;\n#endif\n#endif\n}\n#ifdef TEXTUREVS\nstruct vertexInfo{vec2 pos;vec4 color;vec2 cliped;vec4 texcoordAlpha;float useTex;float useClip;vec4 customs;};uniform float u_VertAlpha;varying vec4 v_texcoordAlpha;varying float v_useTex;varying float v_useClip;varying vec4 v_customs;\n#ifdef USE_TEX_ARRAY\nvarying float v_texLayer;\n#endif\nvoid getVertexInfo(inout vertexInfo info){info.texcoordAlpha.xy=a_posuv.zw;info.color=a_attribColor;\n#ifdef VERTEXALPHA\ninfo.color.a*=a_attribFlags.z;\n#else\ninfo.color.a*=u_VertAlpha;\n#endif\ninfo.color.xyz*=info.color.a;info.useTex=a_attribFlags.r;info.useClip=a_attribFlags.g;info.customs=a_customs;vec2 pos;\n#ifdef VERTEX_SIZE\npos=(a_posuv.xy*u_vertexSize.zw)+u_vertexSize.xy;\n#else\npos=a_posuv.xy;\n#endif\ninfo.pos=pos;}vec4 getPosition(in vec2 positionOS){vec2 globalPos;\n#ifdef VERTEX_SIZE\ngetGlobalPos(positionOS,globalPos);\n#else\nglobalPos=positionOS;\n#endif\nclip(globalPos);vec2 viewPos;getViewPos(globalPos,viewPos);vec4 pos;getProjectPos(viewPos,pos);return pos;}\n#endif\n#ifdef BASERENDER2D\nvarying vec2 v_texcoord;uniform vec4 u_baseRenderColor;\n#ifdef UNITQUAD\nuniform vec2 u_baseRenderSize2D;\n#endif\nstruct vertexInfo{vec4 color;vec2 uv;vec2 pos;vec2 lightUV;};\n#ifdef LIGHT2D_ENABLE\nvarying vec2 v_lightUV;uniform vec4 u_LightAndShadow2DParam;void lightAndShadow(vertexInfo info){v_lightUV=info.lightUV;}void invertMat(inout vec3 v1,inout vec3 v2){float a1=v1.x;float b1=v2.x;float c1=v1.y;float d1=v2.y;float tx1=v1.z;float ty1=v2.z;float n=a1*d1-b1*c1;v1.x=d1/n;v2.x=-b1/n;v1.y=-c1/n;v2.y=a1/n;v1.z=(c1*ty1-d1*tx1)/n;v2.z=-(a1*ty1-b1*tx1)/n;}\n#endif\nvoid getVertexInfo(inout vertexInfo info){\n#ifdef UNITQUAD\ninfo.pos=a_position.xy*u_baseRenderSize2D;\n#else\ninfo.pos=a_position.xy;\n#endif\ninfo.color=vec4(1.0,1.0,1.0,1.0);\n#ifdef COLOR\ninfo.color=a_color;info.color.rgb*=a_color.a;\n#endif\nvec4 ucolor=linearToGamma(u_baseRenderColor);ucolor.rgb*=ucolor.a;info.color*=ucolor;\n#ifdef UV\ninfo.uv=a_uv;\n#endif\n#ifdef LIGHT2D_ENABLE\nvec2 global;getGlobalPos(info.pos,global);info.lightUV.x=(global.x-u_LightAndShadow2DParam.x)/u_LightAndShadow2DParam.z;info.lightUV.y=1.0-(global.y-u_LightAndShadow2DParam.y)/u_LightAndShadow2DParam.w;\n#endif\n}vec4 getPosition(in vec2 positionOS){vec2 globalPos;getGlobalPos(positionOS,globalPos);clip(globalPos);vec2 viewPos;getViewPos(globalPos,viewPos);vec4 pos;getProjectPos(viewPos,pos);return pos;}\n#endif\n'),Ot.addInclude("Color.glsl",'#if !defined(Color_lib)\n#define Color_lib\n#include "Math.glsl";\nvec3 linearToGamma(in vec3 value){return pow(value,vec3(1.0/2.2));}vec4 linearToGamma(in vec4 value){return vec4(linearToGamma(value.rgb),value.a);}vec3 gammaToLinear(in vec3 value){return pow(value,vec3(2.2));}vec4 gammaToLinear(in vec4 value){return vec4(gammaToLinear(value.rgb),value.a);}const float c_RGBDMaxRange=255.0;vec4 encodeRGBD(in vec3 color){float maxRGB=max(vecmax(color),FLT_EPS);float d=max(1.0,c_RGBDMaxRange/maxRGB);d=saturate(d/255.0);vec3 rgb=color.rgb*d;rgb=saturate(rgb);return vec4(rgb,d);}vec3 decodeRGBD(in vec4 rgbd){vec3 color=rgbd.rgb*(1.0/rgbd.a);return color;}vec4 encodeRGBM(in vec3 color,float range){color*=1.0/range;float maxRGB=max(vecmax(color),FLT_EPS);float m=ceil(maxRGB*255.0)/255.0;vec3 rgb=color.rgb*1.0/m;vec4 rgbm=vec4(rgb,m);return rgbm;}vec3 decodeRGBM(in vec4 rgbm,float range){return range*rgbm.rgb*rgbm.a;}\n#include "OutputTransform.glsl";\n#endif\n'),Ot.addInclude("Math.glsl","#if !defined(Math_lib)\n#define Math_lib\n#ifndef GRAPHICS_API_GLES3\nmat2 inverse(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverse(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverse(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}mat4 transpose(mat4 m){return mat4(m[0][0],m[1][0],m[2][0],m[3][0],m[0][1],m[1][1],m[2][1],m[3][1],m[0][2],m[1][2],m[2][2],m[3][2],m[0][3],m[1][3],m[2][3],m[3][3]);}mat3 transpose(mat3 m){return mat3(m[0][0],m[1][0],m[2][0],m[0][1],m[1][1],m[2][1],m[0][2],m[1][2],m[2][2]);}\n#endif\n#define PI 3.14159265359\n#define INVERT_PI 0.31830988618\n#define HALF_PI 1.570796327\n#define MEDIUMP_FLT_MAX 65504.0\n#define MEDIUMP_FLT_MIN 0.00006103515625\n#if defined(GL_FRAGMENT_PRECISION_HIGH)\n#define FLT_EPS 1e-5\n#define saturateMediump(x) x\n#else\n#define FLT_EPS MEDIUMP_FLT_MIN\n#define saturateMediump(x) min(x, MEDIUMP_FLT_MAX)\n#endif\n#define saturate(x) clamp(x, 0.0, 1.0)\nfloat pow2(float x){return x*x;}vec3 pow2(vec3 x){return x*x;}float pow5(float x){float x2=x*x;return x2*x2*x;}const float INVERT_LOG10=0.43429448190325176;float log10(float x){return log(x)*INVERT_LOG10;}float vecmax(const vec2 v){return max(v.x,v.y);}float vecmax(const vec3 v){return max(v.x,max(v.y,v.z));}float vecmax(const vec4 v){return max(max(v.x,v.y),max(v.z,v.w));}float vecmin(const vec2 v){return min(v.x,v.y);}float vecmin(const vec3 v){return min(v.x,min(v.y,v.z));}float vecmin(const vec4 v){return min(min(v.x,v.y),min(v.z,v.w));}vec3 SafeNormalize(in vec3 inVec){float dp3=max(0.001,dot(inVec,inVec));return inVec*inversesqrt(dp3);}vec3 normalScale(in vec3 normal,in float scale){normal*=vec3(scale,scale,1.0);return normalize(normal);}float acosFast(float x){float y=abs(x);float p=-0.1565827*y+1.570796;p*=sqrt(1.0-y);return x>=0.0 ? p : PI-p;}float acosFastPositive(float x){float p=-0.1565827*x+1.570796;return p*sqrt(1.0-x);}float interleavedGradientNoise(const highp vec2 w){const vec3 m=vec3(0.06711056,0.00583715,52.9829189);return fract(m.z*fract(dot(w,m.xy)));}vec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sinf=sin(halfAngle);float quaX=axis.x*sinf;float quaY=axis.y*sinf;float quaZ=axis.z*sinf;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}\n#endif\n"),Ot.addInclude("OutputTransform.glsl","#if !defined(OutputTransform_lib)\n#define OutputTransform_lib\nvec3 gammaCorrect(in vec3 color,float gammaValue){return pow(color,vec3(gammaValue));}vec4 gammaCorrect(in vec4 color){float gammaValue=1.0/2.2;return vec4(gammaCorrect(color.rgb,gammaValue),color.a);}\n#ifdef BRIDGE3D_CLIP\nuniform vec4 u_Bridge3DClipDir;uniform vec4 u_Bridge3DClipPos;\n#endif\nvec4 outputTransform(in vec4 color){\n#ifdef BRIDGE3D_CLIP\nvec2 fragPos=vec2(gl_FragCoord.x,u_Bridge3DClipPos.z-gl_FragCoord.y);vec2 clppos=fragPos-u_Bridge3DClipPos.xy;float clipw=length(u_Bridge3DClipDir.xy);float cliph=length(u_Bridge3DClipDir.zw);if(clipw>20000.0&&cliph>20000.0){}else{float cx=dot(clppos,u_Bridge3DClipDir.xy)/clipw/clipw;float cy=dot(clppos,u_Bridge3DClipDir.zw)/cliph/cliph;if(cx<0.0||cx>1.0||cy<0.0||cy>1.0)discard;}\n#endif\n#ifdef GAMMACORRECT\nreturn gammaCorrect(color);\n#else\nreturn color;\n#endif\n}\n#endif\n"),Ut.graphicsShader=Ot.add("Sprite2DTexture",!1,!1),Ut.graphicsShader.shaderType=e.ShaderFeatureType.D2_TextureSV;let t=new Nt(Ut.graphicsAttribute,{},{});Ut.graphicsShader.addSubShader(t),t.addShaderPass("#define SHADER_NAME TextureVS2D\n#ifdef CAMERA2D\nuniform mat3 u_view2D;\n#endif\n#ifdef SPRITE2DGLOBAL\n#endif\n#ifdef RENDERTEXTURE\nuniform vec3 u_InvertMat_0;uniform vec3 u_InvertMat_1;\n#endif\n#ifdef VERTEX_SIZE\nuniform vec4 u_vertexSize;uniform vec3 u_NMatrix_0;uniform vec3 u_NMatrix_1;\n#endif\n#ifdef UNIFORMCLIP\nuniform vec2 u_clipOffset;\n#endif\nuniform vec2 u_size;\n#ifndef VERTEXALPHA\nuniform float u_VertAlpha;\n#endif\nvarying vec4 v_texcoordAlpha;varying vec4 v_color;varying float v_useTex;\n#ifdef UV_CLIP_GPU\nvarying float v_useClip;\n#endif\n#if defined(UV_CLIP_GPU) || defined(FILLTEXTURE)\nvarying vec4 v_customs;\n#endif\n#ifdef USE_TEX_ARRAY\nvarying float v_texLayer;\n#endif\nvoid main(){vec4 color=a_attribColor;\n#ifdef VERTEXALPHA\ncolor.a*=a_attribFlags.z;\n#else\ncolor.a*=u_VertAlpha;\n#endif\ncolor.rgb*=color.a;v_texcoordAlpha=vec4(a_posuv.zw,0.0,0.0);v_color=color;v_useTex=a_attribFlags.r;\n#ifdef UV_CLIP_GPU\nv_useClip=a_attribFlags.g;\n#endif\n#if defined(UV_CLIP_GPU) || defined(FILLTEXTURE)\nv_customs=a_customs;\n#endif\n#ifdef USE_TEX_ARRAY\nv_texLayer=a_attribFlags.w;\n#endif\n#ifdef VERTEX_SIZE\nvec2 localPos=a_posuv.xy*u_vertexSize.zw+u_vertexSize.xy;vec2 globalPos=vec2(u_NMatrix_0.x*localPos.x+u_NMatrix_0.y*localPos.y+u_NMatrix_0.z,u_NMatrix_1.x*localPos.x+u_NMatrix_1.y*localPos.y+u_NMatrix_1.z);\n#else\nvec2 globalPos=a_posuv.xy;\n#endif\n#ifdef UNIFORMCLIP\nglobalPos+=u_clipOffset;\n#endif\n#ifdef RENDERTEXTURE\nvec2 viewSource=vec2(u_InvertMat_0.x*globalPos.x+u_InvertMat_0.y*globalPos.y+u_InvertMat_0.z,u_InvertMat_1.x*globalPos.x+u_InvertMat_1.y*globalPos.y+u_InvertMat_1.z);\n#else\nvec2 viewSource=globalPos;\n#endif\n#ifdef CAMERA2D\nvec2 viewPos=(u_view2D*vec3(viewSource,1.0)).xy+u_size/2.0;\n#else\nvec2 viewPos=viewSource;\n#endif\nvec4 pos=vec4((viewPos.x/u_size.x-0.5)*2.0,(0.5-viewPos.y/u_size.y)*2.0,0.0,1.0);\n#ifdef INVERTY\npos.y=-pos.y;\n#endif\ngl_Position=pos;}","#define SHADER_NAME TextureFS2D\n#if defined(GL_FRAGMENT_PRECISION_HIGH)\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nvarying vec4 v_texcoordAlpha;varying vec4 v_color;varying float v_useTex;\n#ifdef UV_CLIP_GPU\nvarying float v_useClip;\n#endif\n#if defined(UV_CLIP_GPU) || defined(FILLTEXTURE)\nvarying vec4 v_customs;\n#endif\n#ifdef USE_TEX_ARRAY\nvarying float v_texLayer;uniform sampler2DArray u_spriteTextureArray;\n#else\nuniform sampler2D u_spriteTexture;\n#endif\n#ifdef FILLTEXTURE\nuniform vec4 u_TexRange;\n#endif\nvec3 linearToGamma(in vec3 value){return vec3(mix(pow(value.rgb,vec3(0.41666))*1.055-vec3(0.055),value.rgb*12.92,vec3(lessThanEqual(value.rgb,vec3(0.0031308)))));}vec4 linearToGamma(in vec4 value){return vec4(linearToGamma(value.rgb),value.a);}vec3 gammaToLinear(in vec3 value){return pow((value+0.055)/1.055,vec3(2.4));}vec4 gammaToLinear(in vec4 value){return vec4(gammaToLinear(value.rgb),value.a);}void main(){\n#ifdef FILLTEXTURE\nvec2 tileUV=fract(v_texcoordAlpha.xy);vec4 trimRect=v_customs;if(tileUV.x<trimRect.x||tileUV.x>trimRect.x+trimRect.z||tileUV.y<trimRect.y||tileUV.y>trimRect.y+trimRect.w)discard;vec2 contentUV=(tileUV-trimRect.xy)/trimRect.zw;vec2 uv=contentUV*u_TexRange.zw+u_TexRange.xy;\n#else\nvec2 uv=v_texcoordAlpha.xy;\n#endif\n#ifdef USE_TEX_ARRAY\nvec4 color=texture(u_spriteTextureArray,vec3(uv,v_texLayer));\n#else\nvec4 color=texture2D(u_spriteTexture,uv);\n#endif\n#ifndef GAMMATEXTURE\n#ifdef GAMMASPACE\ncolor.rgb=linearToGamma(color.xyz);\n#endif\n#else\n#ifndef GAMMASPACE\ncolor.rgb=gammaToLinear(color.xyz);\n#endif\n#endif\nfloat useTex=step(1.0,v_useTex);color=color*useTex+(1.0-useTex);\n#if defined(UV_CLIP_GPU) && !defined(FILLTEXTURE)\nif(v_useClip>=1.0){vec2 srcUV=v_texcoordAlpha.xy;vec4 clipRect=v_customs;if(srcUV.x<clipRect.x||srcUV.x>clipRect.x+clipRect.z||srcUV.y<clipRect.y||srcUV.y>clipRect.y+clipRect.w)discard;}\n#endif\ncolor.a*=v_color.w;\n#ifdef GAMMASPACE\nvec4 transColor=v_color;\n#else\nvec4 transColor=vec4(gammaToLinear(v_color.rgb),v_color.a);\n#endif\ncolor.rgb*=transColor.rgb;gl_FragColor=color;}"),Ut.render2DNodeShader=Ot.add("baseRender2D",!1,!1),Ut.render2DNodeShader.shaderType=e.ShaderFeatureType.D2_BaseRenderNode2D,t=new Nt(Ut.Render2DNodeAttribute,{},{}),Ut.render2DNodeShader.addSubShader(t),t.addShaderPass(Fe,'#define SHADER_NAME BaseRender2DPS\n#if defined(GL_FRAGMENT_PRECISION_HIGH)\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "Sprite2DFrag.glsl";\nvoid main(){clip();vec2 texcoord=v_texcoord.xy*u_tilingOffset.zw+u_tilingOffset.xy;vec4 textureColor=texture2D(u_baseRender2DTexture,texcoord);\n#ifdef LIGHT2D_ENABLE\nlightAndShadow(textureColor);\n#endif\ntextureColor=transspaceColor(textureColor);setglColor(textureColor);}'),Ut.stencilShader=Ot.add("StencilMask2D",!1,!1),t=new Nt(Ut.Render2DNodeAttribute,{},{}),Ut.stencilShader.addSubShader(t),t.addShaderPass(Fe,"#define SHADER_NAME StencilMask2DFS\n#ifdef GL_ES\nprecision mediump float;\n#endif\nvoid main(){gl_FragColor=vec4(0.0);}")}}Ut._stencilMaskShaderMap=new Map,Ut.graphicsAttribute={a_posuv:[0,e.ShaderDataType.Vector4],a_attribColor:[1,e.ShaderDataType.Vector4],a_attribFlags:[2,e.ShaderDataType.Vector4],a_customs:[3,e.ShaderDataType.Vector4]},Ut.Render2DNodeAttribute={a_position:[0,e.ShaderDataType.Vector4],a_color:[1,e.ShaderDataType.Vector4],a_uv:[2,e.ShaderDataType.Vector2]},e.BufferTargetType=void 0,(Rt=e.BufferTargetType||(e.BufferTargetType={}))[Rt.ARRAY_BUFFER=1]="ARRAY_BUFFER",Rt[Rt.ELEMENT_ARRAY_BUFFER=2]="ELEMENT_ARRAY_BUFFER",Rt[Rt.UNIFORM_BUFFER=4]="UNIFORM_BUFFER",Rt[Rt.COPY_READ_BUFFER=8]="COPY_READ_BUFFER",Rt[Rt.COPY_WRITE_BUFFER=16]="COPY_WRITE_BUFFER",Rt[Rt.TRANSFORM_FEEDBACK_BUFFER=32]="TRANSFORM_FEEDBACK_BUFFER",e.BufferUsage=void 0,(Ct=e.BufferUsage||(e.BufferUsage={}))[Ct.Static=0]="Static",Ct[Ct.Dynamic=1]="Dynamic",Ct[Ct.Stream=2]="Stream",e.DrawType=void 0,(Mt=e.DrawType||(e.DrawType={}))[Mt.DrawArray=0]="DrawArray",Mt[Mt.DrawArrayInstance=1]="DrawArrayInstance",Mt[Mt.DrawArrayIndirect=2]="DrawArrayIndirect",Mt[Mt.DrawElement=3]="DrawElement",Mt[Mt.DrawElementInstance=4]="DrawElementInstance",Mt[Mt.DrawElementIndirect=5]="DrawElementIndirect",e.MeshTopology=void 0,(bt=e.MeshTopology||(e.MeshTopology={}))[bt.Points=0]="Points",bt[bt.Lines=1]="Lines",bt[bt.LineLoop=2]="LineLoop",bt[bt.LineStrip=3]="LineStrip",bt[bt.Triangles=4]="Triangles",bt[bt.TriangleStrip=5]="TriangleStrip",bt[bt.TriangleFan=6]="TriangleFan";class kt{static _buildDefineMap(){this._perElementDefineMap=[];const e=[kt.FILLTEXTURE,kt.GAMMATEXTURE,kt.VERTEXALPHA,kt.TEXTURESHADER,kt.PRIMITIVESHADER,kt.USE_TEX_ARRAY,kt.UNIFORMCLIP,kt.UV_CLIP_GPU,kt.VERTEX_SIZE],t=[kt.DEFINE_BIT_FILLTEXTURE,kt.DEFINE_BIT_GAMMATEXTURE,kt.DEFINE_BIT_VERTEXALPHA,kt.DEFINE_BIT_TEXTURESHADER,kt.DEFINE_BIT_PRIMITIVESHADER,kt.DEFINE_BIT_USE_TEX_ARRAY,kt.DEFINE_BIT_UNIFORMCLIP,kt.DEFINE_BIT_UV_CLIP_GPU,kt.DEFINE_BIT_VERTEX_SIZE];let r=e[0]._index;this._singleWord=!0;for(let s=0;s<e.length;s++)e[s]._index!==r&&(this._singleWord=!1),this._perElementDefineMap.push({define:e[s],bit:t[s]});this._singleWord&&(this._sharedIndex=r)}static getPerElementDefineBits(e){let t=0;for(let r=0;r<this._perElementDefineMap.length;r++){let s=this._perElementDefineMap[r];e.hasDefine(s.define)&&(t|=s.bit)}return t}static __init__(){kt.VERTEX_SIZE=Ot.getDefineByName("VERTEX_SIZE"),kt.FILLTEXTURE=Ot.getDefineByName("FILLTEXTURE"),kt.RENDERTEXTURE=Ot.getDefineByName("RENDERTEXTURE"),kt.UNIFORMCLIP=Ot.getDefineByName("UNIFORMCLIP"),kt.UV_CLIP_GPU=Ot.getDefineByName("UV_CLIP_GPU"),kt.GAMMASPACE=Ot.getDefineByName("GAMMASPACE"),kt.INVERTY=Ot.getDefineByName("INVERTY"),kt.GAMMATEXTURE=Ot.getDefineByName("GAMMATEXTURE"),kt.TEXTURESHADER=Ot.getDefineByName("TEXTUREVS"),kt.PRIMITIVESHADER=Ot.getDefineByName("PRIMITIVEMESH"),kt.VERTEXALPHA=Ot.getDefineByName("VERTEXALPHA"),kt.USE_TEX_ARRAY=Ot.getDefineByName("USE_TEX_ARRAY"),kt.SHADERDEFINE_CAMERA2D=Ot.getDefineByName("CAMERA2D"),kt.initSprite2DCommandEncoder(),this._buildDefineMap()}static initSprite2DCommandEncoder(){kt.UNIFORM_NMATRIX_0=Ot.propertyNameToID("u_NMatrix_0"),kt.UNIFORM_NMATRIX_1=Ot.propertyNameToID("u_NMatrix_1"),kt.UNIFORM_INVERTMAT_0=Ot.propertyNameToID("u_InvertMat_0"),kt.UNIFORM_INVERTMAT_1=Ot.propertyNameToID("u_InvertMat_1"),kt.UNIFORM_CLIPOFFSET=Ot.propertyNameToID("u_clipOffset"),kt.UNIFORM_SIZE=Ot.propertyNameToID("u_size"),kt.UNIFORM_TIME=Ot.propertyNameToID("u_Time"),kt.UNIFORM_VERTALPHA=Ot.propertyNameToID("u_VertAlpha"),kt.VIEW2D=Ot.propertyNameToID("u_view2D"),kt.UNIFORM_TIME=Ot.propertyNameToID("u_Time");const t=f.renderDeviceFactory.createGlobalUniformMap("Sprite2D");t.addShaderUniform(kt.UNIFORM_NMATRIX_0,"u_NMatrix_0",e.ShaderDataType.Vector3),t.addShaderUniform(kt.UNIFORM_NMATRIX_1,"u_NMatrix_1",e.ShaderDataType.Vector3),t.addShaderUniform(kt.UNIFORM_VERTALPHA,"u_VertAlpha",e.ShaderDataType.Float),t.addShaderUniform(kt.UNIFORM_CLIPOFFSET,"u_clipOffset",e.ShaderDataType.Vector2);let r=f.renderDeviceFactory.createGlobalUniformMap("Sprite2DPass");r.addShaderUniform(kt.UNIFORM_SIZE,"u_size",e.ShaderDataType.Vector2),r.addShaderUniform(kt.UNIFORM_TIME,"u_Time",e.ShaderDataType.Float),r.addShaderUniform(kt.UNIFORM_INVERTMAT_0,"u_InvertMat_0",e.ShaderDataType.Vector3),r.addShaderUniform(kt.UNIFORM_INVERTMAT_1,"u_InvertMat_1",e.ShaderDataType.Vector3),kt.UNIFORM_VERTEX_SIZE=Ot.propertyNameToID("u_vertexSize"),kt.UNIFORM_TEXRANGE=Ot.propertyNameToID("u_TexRange"),kt.UNIFORM_SPRITETEXTURE=Ot.propertyNameToID("u_spriteTexture"),kt.UNIFORM_SPRITETEXTURE_ARRAY=Ot.propertyNameToID("u_spriteTextureArray");const s=f.renderDeviceFactory.createGlobalUniformMap("Sprite2DGraphics");s.addShaderUniform(kt.UNIFORM_VERTEX_SIZE,"u_vertexSize",e.ShaderDataType.Vector4),s.addShaderUniform(kt.UNIFORM_TEXRANGE,"u_TexRange",e.ShaderDataType.Vector4),s.addShaderUniform(kt.UNIFORM_SPRITETEXTURE,"u_spriteTexture",e.ShaderDataType.Texture2D),s.addShaderUniform(kt.UNIFORM_SPRITETEXTURE_ARRAY,"u_spriteTextureArray",e.ShaderDataType.Texture2DArray);const i=new Float32Array([0,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,1,1,1,0,0,1,0,0,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1]),a=new Bt(40,[new vt(0,It.Vector4,0),new vt(16,It.Vector4,1),new vt(32,It.Vector2,2)]),n=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Static);n.vertexDeclaration=a,n.setDataLength(i.buffer.byteLength),n.setData(i.buffer,0,0,i.buffer.byteLength);const o=f.renderDeviceFactory.createBufferState();o.applyState([n],null);const l=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.TriangleStrip,e.DrawType.DrawArray);l.setDrawArrayParams(0,4),l.bufferState=o,kt._stencilGeo=l}}kt.SHADER_DEFINE_BITS=9,kt.TYPE_KEY_DEFINE_SHIFT=7,kt.TYPEKEY_CUSTOM_MATERIAL=16,kt.DEFINE_BIT_FILLTEXTURE=1<<kt.TYPE_KEY_DEFINE_SHIFT+0,kt.DEFINE_BIT_GAMMATEXTURE=1<<kt.TYPE_KEY_DEFINE_SHIFT+1,kt.DEFINE_BIT_VERTEXALPHA=1<<kt.TYPE_KEY_DEFINE_SHIFT+2,kt.DEFINE_BIT_TEXTURESHADER=1<<kt.TYPE_KEY_DEFINE_SHIFT+3,kt.DEFINE_BIT_PRIMITIVESHADER=1<<kt.TYPE_KEY_DEFINE_SHIFT+4,kt.DEFINE_BIT_USE_TEX_ARRAY=1<<kt.TYPE_KEY_DEFINE_SHIFT+5,kt.DEFINE_BIT_UNIFORMCLIP=1<<kt.TYPE_KEY_DEFINE_SHIFT+6,kt.DEFINE_BIT_UV_CLIP_GPU=1<<kt.TYPE_KEY_DEFINE_SHIFT+7,kt.DEFINE_BIT_VERTEX_SIZE=1<<kt.TYPE_KEY_DEFINE_SHIFT+8,kt._PER_ELEMENT_DEFINE_NAMES=["FILLTEXTURE","GAMMATEXTURE","VERTEXALPHA","TEXTURESHADER","PRIMITIVESHADER","USE_TEX_ARRAY","UNIFORMCLIP","UV_CLIP_GPU","VERTEX_SIZE"],kt._perElementDefineMap=null,kt._singleWord=!1,kt._sharedIndex=-1;class Gt{get cull(){return this._cull}set cull(e){this._cull=e}get blend(){return this._blend}set blend(e){this._blend=e}get srcBlend(){return this._srcBlend}set srcBlend(e){this._srcBlend=e}get dstBlend(){return this._dstBlend}set dstBlend(e){this._dstBlend=e}get srcBlendRGB(){return this._srcBlendRGB}set srcBlendRGB(e){this._srcBlendRGB=e}get dstBlendRGB(){return this._dstBlendRGB}set dstBlendRGB(e){this._dstBlendRGB=e}get srcBlendAlpha(){return this._srcBlendAlpha}set srcBlendAlpha(e){this._srcBlendAlpha=e}get dstBlendAlpha(){return this._dstBlendAlpha}set dstBlendAlpha(e){this._dstBlendAlpha=e}get blendEquation(){return this._blendEquation}set blendEquation(e){this._blendEquation=e}get blendEquationRGB(){return this._blendEquationRGB}set blendEquationRGB(e){this._blendEquationRGB=e}get blendEquationAlpha(){return this._blendEquationAlpha}set blendEquationAlpha(e){this._blendEquationAlpha=e}get depthTest(){return this._depthTest}set depthTest(e){this._depthTest=e}get depthWrite(){return this._depthWrite}set depthWrite(e){this._depthWrite=e}get stencilWrite(){return this._stencilWrite}set stencilWrite(e){this._stencilWrite=e}get stencilTest(){return this._stencilTest}set stencilTest(e){this._stencilTest=e}get stencilWriteMask(){return this._stencilWriteMask}set stencilWriteMask(e){this._stencilWriteMask=e}get stencilReadMask(){return this._stencilReadMask}set stencilReadMask(e){this._stencilReadMask=e}get stencilRef(){return this._stencilRef}set stencilRef(e){this._stencilRef=e}get stencilOp(){return this._stencilOp}set stencilOp(e){this._stencilOp=e}get depthBias(){return this._depthBias}set depthBias(e){this._depthBias=e}get depthBiasConstant(){return this._depthBiasConstant}set depthBiasConstant(e){this._depthBiasConstant=e}get depthBiasSlopeScale(){return this._depthBiasSlopeScale}set depthBiasSlopeScale(e){this._depthBiasSlopeScale=e}get depthBiasClamp(){return this._depthBiasClamp}set depthBiasClamp(e){this._depthBiasClamp=e}createObj(){}constructor(){this._stencilOp=new a,this.createObj(),this.cull=Gt.CULL_BACK,this.blend=Gt.BLEND_DISABLE,this.srcBlend=Gt.BLENDPARAM_ONE,this.dstBlend=Gt.BLENDPARAM_ZERO,this.srcBlendRGB=Gt.BLENDPARAM_ONE,this.dstBlendRGB=Gt.BLENDPARAM_ZERO,this.srcBlendAlpha=Gt.BLENDPARAM_ONE,this.dstBlendAlpha=Gt.BLENDPARAM_ZERO,this.blendEquation=Gt.BLENDEQUATION_ADD,this.blendEquationRGB=Gt.BLENDEQUATION_ADD,this.blendEquationAlpha=Gt.BLENDEQUATION_ADD,this.depthTest=Gt.DEPTHTEST_LEQUAL,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilReadMask=255,this.stencilRef=1,this.stencilTest=Gt.STENCILTEST_OFF,this.stencilWrite=!1,this.stencilOp=new a(Gt.STENCILOP_KEEP,Gt.STENCILOP_KEEP,Gt.STENCILOP_REPLACE),this.depthBias=!1,this.depthBiasConstant=0,this.depthBiasSlopeScale=0,this.depthBiasClamp=0}setNull(){this.cull=null,this.blend=null,this.srcBlend=null,this.dstBlend=null,this.srcBlendRGB=null,this.dstBlendRGB=null,this.srcBlendAlpha=null,this.dstBlendAlpha=null,this.blendEquation=null,this.blendEquationRGB=null,this.blendEquationAlpha=null,this.depthTest=null,this.depthWrite=null,this.stencilWriteMask=null,this.stencilReadMask=null,this.stencilRef=null,this.stencilTest=null,this.stencilWrite=null,this.stencilOp.set(null,null,null),this.depthBias=null,this.depthBiasConstant=null,this.depthBiasSlopeScale=null,this.depthBiasClamp=null}cloneTo(e){e.cull=this.cull,e.blend=this.blend,e.srcBlend=this.srcBlend,e.dstBlend=this.dstBlend,e.srcBlendRGB=this.srcBlendRGB,e.dstBlendRGB=this.dstBlendRGB,e.srcBlendAlpha=this.srcBlendAlpha,e.dstBlendAlpha=this.dstBlendAlpha,e.blendEquation=this.blendEquation,e.blendEquationRGB=this.blendEquationRGB,e.blendEquationAlpha=this.blendEquationAlpha,e.depthTest=this.depthTest,e.depthWrite=this.depthWrite,e.stencilWriteMask=this.stencilWriteMask,e.stencilReadMask=this.stencilReadMask,e.stencilRef=this.stencilRef,e.stencilTest=this.stencilTest,e.stencilWrite=this.stencilWrite,this.stencilOp.cloneTo(e.stencilOp),e.depthBias=this.depthBias,e.depthBiasConstant=this.depthBiasConstant,e.depthBiasSlopeScale=this.depthBiasSlopeScale,e.depthBiasClamp=this.depthBiasClamp}clone(){var e=new Gt;return this.cloneTo(e),e}}Gt.CULL_NONE=e.CullMode.Off,Gt.CULL_FRONT=e.CullMode.Front,Gt.CULL_BACK=e.CullMode.Back,Gt.BLEND_DISABLE=e.BlendType.BLEND_DISABLE,Gt.BLEND_ENABLE_ALL=e.BlendType.BLEND_ENABLE_ALL,Gt.BLEND_ENABLE_SEPERATE=e.BlendType.BLEND_ENABLE_SEPERATE,Gt.BLENDPARAM_ZERO=e.BlendFactor.Zero,Gt.BLENDPARAM_ONE=e.BlendFactor.One,Gt.BLENDPARAM_SRC_COLOR=e.BlendFactor.SourceColor,Gt.BLENDPARAM_ONE_MINUS_SRC_COLOR=e.BlendFactor.OneMinusSourceColor,Gt.BLENDPARAM_DST_COLOR=e.BlendFactor.DestinationColor,Gt.BLENDPARAM_ONE_MINUS_DST_COLOR=e.BlendFactor.OneMinusDestinationColor,Gt.BLENDPARAM_SRC_ALPHA=e.BlendFactor.SourceAlpha,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA=e.BlendFactor.OneMinusSourceAlpha,Gt.BLENDPARAM_DST_ALPHA=e.BlendFactor.DestinationAlpha,Gt.BLENDPARAM_ONE_MINUS_DST_ALPHA=e.BlendFactor.OneMinusDestinationAlpha,Gt.BLENDPARAM_SRC_ALPHA_SATURATE=e.BlendFactor.SourceAlphaSaturate,Gt.BLENDPARAM_BLENDCOLOR=e.BlendFactor.BlendColor,Gt.BLENDPARAM_BLEND_ONEMINUS_COLOR=e.BlendFactor.OneMinusBlendColor,Gt.BLENDEQUATION_ADD=e.BlendEquationSeparate.ADD,Gt.BLENDEQUATION_SUBTRACT=e.BlendEquationSeparate.SUBTRACT,Gt.BLENDEQUATION_REVERSE_SUBTRACT=e.BlendEquationSeparate.REVERSE_SUBTRACT,Gt.BLENDEQUATION_MIN=e.BlendEquationSeparate.MIN,Gt.BLENDEQUATION_MAX=e.BlendEquationSeparate.MAX,Gt.DEPTHTEST_OFF=e.CompareFunction.Off,Gt.DEPTHTEST_NEVER=e.CompareFunction.Never,Gt.DEPTHTEST_LESS=e.CompareFunction.Less,Gt.DEPTHTEST_EQUAL=e.CompareFunction.Equal,Gt.DEPTHTEST_LEQUAL=e.CompareFunction.LessEqual,Gt.DEPTHTEST_GREATER=e.CompareFunction.Greater,Gt.DEPTHTEST_NOTEQUAL=e.CompareFunction.NotEqual,Gt.DEPTHTEST_GEQUAL=e.CompareFunction.GreaterEqual,Gt.DEPTHTEST_ALWAYS=e.CompareFunction.Always,Gt.STENCILTEST_OFF=e.CompareFunction.Off,Gt.STENCILTEST_NEVER=e.CompareFunction.Never,Gt.STENCILTEST_LESS=e.CompareFunction.Less,Gt.STENCILTEST_EQUAL=e.CompareFunction.Equal,Gt.STENCILTEST_LEQUAL=e.CompareFunction.LessEqual,Gt.STENCILTEST_GREATER=e.CompareFunction.Greater,Gt.STENCILTEST_NOTEQUAL=e.CompareFunction.NotEqual,Gt.STENCILTEST_GEQUAL=e.CompareFunction.GreaterEqual,Gt.STENCILTEST_ALWAYS=e.CompareFunction.Always,Gt.STENCILOP_KEEP=e.StencilOperation.Keep,Gt.STENCILOP_ZERO=e.StencilOperation.Zero,Gt.STENCILOP_REPLACE=e.StencilOperation.Replace,Gt.STENCILOP_INCR=e.StencilOperation.IncrementSaturate,Gt.STENCILOP_INCR_WRAP=e.StencilOperation.IncrementWrap,Gt.STENCILOP_DECR=e.StencilOperation.DecrementSaturate,Gt.STENCILOP_DECR_WRAP=e.StencilOperation.DecrementWrap,Gt.STENCILOP_INVERT=e.StencilOperation.Invert,Gt.Default=new Gt,e.BlendMode=void 0,(At=e.BlendMode||(e.BlendMode={}))[At.invalid=0]="invalid",At[At.normal=1]="normal",At[At.add=2]="add",At[At.multiply=3]="multiply",At[At.screen=4]="screen",At[At.overlay=5]="overlay",At[At.light=6]="light",At[At.lighter=7]="lighter",At[At.mask=8]="mask",At[At.destinationOut=9]="destinationOut",At[At.addOld=10]="addOld",At[At.lighterOld=11]="lighterOld",At[At.sourceAlpha=12]="sourceAlpha";const Vt={[e.BlendMode.normal]:0,[e.BlendMode.add]:1,[e.BlendMode.multiply]:2,[e.BlendMode.screen]:3,[e.BlendMode.overlay]:4,[e.BlendMode.light]:5,[e.BlendMode.mask]:6,[e.BlendMode.destinationOut]:7,[e.BlendMode.lighter]:1,[e.BlendMode.lighterOld]:8,[e.BlendMode.addOld]:8,[e.BlendMode.sourceAlpha]:9};class zt{static _init_(){}static setShaderData(e,t,r=!0){switch(Vt[e]){case 1:case 3:case 5:t.setInt(Ot.BLEND_SRC,Gt.BLENDPARAM_ONE),t.setInt(Ot.BLEND_DST,Gt.BLENDPARAM_ONE);break;case 2:t.setInt(Ot.BLEND_SRC,Gt.BLENDPARAM_DST_COLOR),t.setInt(Ot.BLEND_DST,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA);break;case 6:t.setInt(Ot.BLEND_SRC,Gt.BLENDPARAM_ZERO),t.setInt(Ot.BLEND_DST,Gt.BLENDPARAM_SRC_ALPHA);break;case 7:t.setInt(Ot.BLEND_SRC,Gt.BLENDPARAM_ZERO),t.setInt(Ot.BLEND_DST,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA);break;case 9:t.setInt(Ot.BLEND_SRC,Gt.BLENDPARAM_SRC_ALPHA),t.setInt(Ot.BLEND_DST,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA);break;default:t.setInt(Ot.BLEND_SRC,r?Gt.BLENDPARAM_ONE:Gt.BLENDPARAM_SRC_ALPHA),t.setInt(Ot.BLEND_DST,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA)}}static initBlendMode(e){e.setBool(Ot.DEPTH_WRITE,!1),e.setInt(Ot.DEPTH_TEST,Gt.DEPTHTEST_OFF),e.setInt(Ot.BLEND,Gt.BLEND_ENABLE_ALL),e.setInt(Ot.BLEND_EQUATION,Gt.BLENDEQUATION_ADD),e.setInt(Ot.BLEND_SRC,Gt.BLENDPARAM_ONE),e.setInt(Ot.BLEND_DST,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA),e.setNumber(kt.UNIFORM_VERTALPHA,1),e.setInt(Ot.CULL,Gt.CULL_NONE)}}const Ht=2*Math.PI;function Wt(e){return e?e.width:0}function Xt(e){return e?e.height:0}function Yt(e){if(!e)return 1;let t=e.globalTrans.getMatrix();if(!t)return 1;let r=Math.sqrt(t.a*t.a+t.b*t.b),s=Math.sqrt(t.c*t.c+t.d*t.d);return Math.max(r||0,s||0)}function qt(e,t,r=20,s=5){let i=Math.max(0,e||0),a=isFinite(t)?Math.max(0,Math.abs(t)):1,n=s>0?s:5,o=Math.max(1,0|r),l=Math.max(o,Math.floor(i*a*Math.PI*2/n));return Math.min(2048,l)}function $t(e,t){e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=null==t[4]?t[2]:t[4],e[5]=null==t[5]?t[3]:t[5],e[6]=null==t[6]?t[0]:t[6],e[7]=null==t[7]?t[5]:t[7]}function Kt(e,t,r){let s=e+t;return s<=0||r>=s?0:Math.asin(Math.min(1,Math.max(0,(s-Math.max(0,r))/s)))}function jt(e,t,r,s,i,a,n,o,l){s<=0?e.push(t,r):i>a||Qt(e,t,r,s,i,a,qt(s,n,o,l))}function Qt(e,t,r,s,i,a,n){Jt(e,t+Math.cos(i)*s,r+Math.sin(i)*s);let o=Ht/n,l=Math.ceil(i/o)*o;for(Math.abs(l-i)<1e-7&&(l+=o);a-l>=o;)Jt(e,t+Math.cos(l)*s,r+Math.sin(l)*s),l+=o;Jt(e,t+Math.cos(a)*s,r+Math.sin(a)*s)}function Zt(e,t){if(!e)return!1;if(t&&e.length>=4){let t=e.length-2;e[t]===e[0]&&e[t+1]===e[1]&&(e.length-=2)}return e.length>=4}function Jt(e,t,r){let s=e.length-2;s>=0&&e[s]===t&&e[s+1]===r||e.push(t,r)}function er(e,t,r,s,i,a){if(e.length<2)return void Jt(e,t,r);let n=e[e.length-2]-t,o=e[e.length-1]-r,l=s-t,h=i-r,u=Math.sqrt(n*n+o*o),d=Math.sqrt(l*l+h*h);if(a<=0||u<=1e-5||d<=1e-5)return void Jt(e,t,r);n/=u,o/=u,l/=d,h/=d;let c=Math.max(-1,Math.min(1,n*l+o*h)),_=Math.acos(c);if(_<=1e-4||Math.PI-_<=1e-4)return void Jt(e,t,r);let p=a/Math.tan(.5*_);if(!isFinite(p)||p<=0)return void Jt(e,t,r);let g=t+n*p,m=r+o*p,f=t+l*p,T=r+h*p,y=n+l,x=o+h,S=Math.sqrt(y*y+x*x);if(S<=1e-5)return void Jt(e,t,r);y/=S,x/=S;let E=Math.sqrt(p*p+a*a),v=t+y*E,D=r+x*E;Jt(e,g,m);let w=Math.atan2(m-D,g-v),R=Math.atan2(T-D,f-v);if(n*h-o*l<0)for(;R<=w;)R+=Ht;else for(;R>=w;)R-=Ht;let C=(R-w)/32;for(let t=1;t<=32;t++){let r=w+C*t;Jt(e,v+Math.cos(r)*a,D+Math.sin(r)*a)}}function tr(r,s,i,a,n,o,l={stateKey:0,typeKey:0,textureKey:0,texture:null}){let h=r,u=!!h&&h.dimension===e.TextureDimension.Texture2DArray,d=!!h&&1!=h.gammaCorrection,c="gpu"===t.uvClipMode,_=kt.DEFINE_BIT_TEXTURESHADER;return _|=n?kt.DEFINE_BIT_VERTEX_SIZE:kt.DEFINE_BIT_VERTEXALPHA,c&&(_|=kt.DEFINE_BIT_UV_CLIP_GPU),i&&(_|=kt.DEFINE_BIT_FILLTEXTURE),d&&(_|=kt.DEFINE_BIT_GAMMATEXTURE),u&&(_|=kt.DEFINE_BIT_USE_TEX_ARRAY),o&&(rr(o,kt.FILLTEXTURE,i),rr(o,kt.GAMMATEXTURE,d),rr(o,kt.VERTEXALPHA,!n),rr(o,kt.TEXTURESHADER,!0),rr(o,kt.USE_TEX_ARRAY,u),rr(o,kt.UNIFORMCLIP,!1),rr(o,kt.UV_CLIP_GPU,c),rr(o,kt.VERTEX_SIZE,n)),l.stateKey=s,l.typeKey=s|(a?kt.TYPEKEY_CUSTOM_MATERIAL:0)|_,l.textureKey=h?h.id:0,l.texture=h,l}function rr(e,t,r){r?e.addDefine(t):e.removeDefine(t)}const sr={writeState:function(e){return e.dependency=0,e.layoutRefresh=0,e.scaleTessellationKey=0,e.isStateCommand=!0,e},writeSize:function(e,t,r){return e.dependency=t?1:0,e.layoutRefresh=t?r:0,e.scaleTessellationKey=0,e.isStateCommand=!1,e},writeScaleTessellation:function(e,t,r){return e.dependency=2|(t?1:0),e.layoutRefresh=t?2:0,e.scaleTessellationKey=r,e.isStateCommand=!1,e}},ir={ARC_MAX_SEGMENTS:2048,getOwnerWidth:Wt,getOwnerHeight:Xt,getOwnerMinSize:function(e){return Math.min(Wt(e),Xt(e))},getOwnerMaxScale:Yt,combineMatrix:function(e,t,r){return t?e.setTo(t.a,t.b,t.c,t.d,t.tx,t.ty):e.identity(),r&&Ce.mul(e,r,e),1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.tx&&0===e.ty?null:e},calcArcSegmentsWithScale:qt,calcArcSegments:function(e,t,r=20,s=5){return qt(e,Yt(t),r,s)},combineRoundRectSegments:function(e,t,r,s,i,a=20,n=5){let o=Yt(i),l=qt(e,o,a,n),h=qt(t,o,a,n),u=qt(r,o,a,n),d=qt(s,o,a,n),c=Math.imul(l,31)+h|0;return c=Math.imul(c,31)+u|0,Math.imul(c,31)+d|0},copyOffsetPoints:function(e,t,r,s){e.length=0;for(let i=0,a=t.length;i<a;i+=2)e.push(t[i]+r,t[i+1]+s)},offsetPoints:function(e,t,r){if(t||r)for(let s=0,i=e.length;s<i;s+=2)e[s]+=t,e[s+1]+=r},writeFillTextureGeometry:function(e,t,r,s,i,a,n,o,l,h){let u="repeat"===o||"repeat-x"===o?1:0,d="repeat"===o||"repeat-y"===o?1:0,c=l<0?t:t+l,_=h<0?r:r+h,p=t+s,g=r+i;return u||(p=Math.min(p,t+l+a)),d||(g=Math.min(g,r+h+n)),!(p<t||g<r||c>p||_>g)&&(e[0]=c,e[1]=_,e[2]=p-c,e[3]=g-_,e[4]=l<0?-l%a/a:0,e[5]=h<0?-h%n/n:0,e[6]=(p-t-l)/a,e[7]=(g-r-h)/n,e[8]=u,e[9]=d,e[10]=l,e[11]=h,!0)},makeCirclePath:function(e,t,r,s,i){e.length=0;for(let a=0;a<i;a++){let n=a/i*Ht;e.push(t+Math.cos(n)*s,r+Math.sin(n)*s)}},writeCircleFan:function(e,t,r,s,i,a){e.length=0,t.length=0,e.push(r,s);for(let t=0;t<a;t++){let n=t/a*Ht;e.push(r+Math.cos(n)*i,s+Math.sin(n)*i)}for(let e=0;e<a;e++)t.push(0,e+1,e+1===a?1:e+2)},writeTextQuad:function(e,t,r,s,i,a,n,o,l,h,u){let d=0!==o?Math.tan(o*Math.PI/180)*a:0,c=r+i,_=s+a,p=r+d,g=s,m=c+d,f=s,T=c,y=_,x=r,S=_;if(u&&h){let t=h.tx,r=h.ty;if(h._bTransform){let s=h.a,i=h.b,a=h.c,n=h.d;e[0]=p*s+g*a+t,e[1]=p*i+g*n+r,e[2]=m*s+f*a+t,e[3]=m*i+f*n+r,e[4]=T*s+y*a+t,e[5]=T*i+y*n+r,e[6]=x*s+S*a+t,e[7]=x*i+S*n+r}else e[0]=p+t,e[1]=g+r,e[2]=m+t,e[3]=f+r,e[4]=T+t,e[5]=y+r,e[6]=x+t,e[7]=S+r}else e[0]=p,e[1]=g,e[2]=m,e[3]=f,e[4]=T,e[5]=y,e[6]=x,e[7]=S;if(l)for(let t=0;t<8;t++)e[t]=Math.round(e[t]);$t(t,n)},writeTextureQuad:function(e,t,r,s,i){e[0]=0,e[1]=0,e[2]=r,e[3]=0,e[4]=r,e[5]=s,e[6]=0,e[7]=s,$t(t,i)},writeNineGridAxes:function(e,t,r,s,i,a,n,o){let l=Math.max(0,o[0]||0),h=Math.max(0,o[1]||0),u=Math.max(0,o[2]||0),d=Math.max(0,o[3]||0),c=Math.min(d,s),_=Math.max(c,s-Math.min(h,s-c)),p=Math.min(l,i),g=Math.max(p,i-Math.min(u,i-p));e[0]=t,e[1]=t+c,e[2]=t+_,e[3]=t+s,e[4]=r,e[5]=r+p,e[6]=r+g,e[7]=r+i,e[8]=0,e[9]=d,e[10]=Math.max(d,a-h),e[11]=a,e[12]=0,e[13]=l,e[14]=Math.max(l,n-u),e[15]=n},makeEllipsePath:function(e,t,r,s,i,a){e.length=0;for(let n=0;n<a;n++){let o=n/a*Ht;e.push(t+Math.cos(o)*s,r+Math.sin(o)*i)}},makePiePath:function(e,t,r,s,i,a,n){e.length=0,e.push(t,r),Qt(e,t,r,s,i,a,n)},makeRoundRectPath:function(e,t,r,s,i,a,n,o,l,h,u,d){a=Math.max(a||0,0),n=Math.max(n||0,0),o=Math.max(o||0,0),l=Math.max(l||0,0);let c=Kt(a,n,s),_=Kt(n,o,i),p=Kt(l,o,s),g=Kt(a,l,i);e.length=0,jt(e,t+a,r+a,a,Math.PI+g,1.5*Math.PI-c,d,h,u),jt(e,t+s-n,r+n,n,1.5*Math.PI+c,Ht-_,d,h,u),jt(e,t+s-o,r+i-o,o,_,.5*Math.PI-p,d,h,u),jt(e,t+l,r+i-l,l,.5*Math.PI+p,Math.PI-g,d,h,u)},collectDrawPathSubpaths:function(e,t,r,s,i){if(!e)return 0;let a=0,n=null,o=!1;for(let l=0,h=e.length;l<h;l++){let h=e[l];"moveTo"===h[0]?(Zt(n,o)&&(i[a]=o,a++),n=s[a]||(s[a]=[]),n.length=0,o=!1,Jt(n,h[1]+t,h[2]+r)):"lineTo"===h[0]?(n||(n=s[a]||(s[a]=[]),n.length=0),Jt(n,h[1]+t,h[2]+r)):"arcTo"===h[0]?(n||(n=s[a]||(s[a]=[]),n.length=0),er(n,h[1]+t,h[2]+r,h[3]+t,h[4]+r,h[5]||0)):"closePath"===h[0]&&(o=!0)}return Zt(n,o)&&(i[a]=o,a++),a}},ar={getUVClipRange:function(e){return"gpu"===t.uvClipMode&&e.uvrect?e.uvrect:null},writeTrimRange:function(e,t){let r=e.sourceWidth||e.width||1,s=e.sourceHeight||e.height||1;return t[0]=e.offsetX/r,t[1]=e.offsetY/s,t[2]=e.width/r,t[3]=e.height/s,t},writeUVRange:function(e,t){let r=e.uvrect;return r?(t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3]):(t[0]=0,t[1]=0,t[2]=1,t[3]=1),t}},nr={parseBlendMode:function(t){switch(t){case"add":return e.BlendMode.add;case"multiply":return e.BlendMode.multiply;case"screen":return e.BlendMode.screen;case"overlay":return e.BlendMode.overlay;case"light":return e.BlendMode.light;case"lighter":return e.BlendMode.lighter;case"mask":return e.BlendMode.mask;case"destinationOut":case"destination-out":return e.BlendMode.destinationOut;case"addOld":return e.BlendMode.addOld;case"lighterOld":return e.BlendMode.lighterOld;case"sourceAlpha":return e.BlendMode.sourceAlpha;default:return e.BlendMode.normal}},getDefaultSubShader:function(){return Ut.graphicsShader.getSubShaderAt(0)},getDefineBits:function(e,t=!1,r=!1){return tr(e,0,t,!1,r,null).typeKey},getRenderState:function(e,t,r=!1,s=!1,i=!1,a={stateKey:0,typeKey:0,textureKey:0,texture:null}){return tr(e,t,r,s,i,null,a)},syncShaderData:function(e,t,r,s=!1,i=!1,a=!1,n={stateKey:0,typeKey:0,textureKey:0,texture:null}){return tr(t,r,s,i,a,e,n)}},or="RestoreCmd";class lr{static create(){return h.getItemByClass(or,lr)}recover(){h.recover(or,this)}run(e){e.restore()}get cmdID(){return lr.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}lr.ID=or;class hr{static scanPList(e,t){let r=Math.floor(e.length/2);ur.length=r,r>cr.length&&(cr.length=r);for(let t=0;t<r;t++){let r=cr[t]||(cr[t]=new d);r.setTo(e[t+t],e[t+t+1]),ur[t]=r}let s=hr.scan(ur,ur);(t=t||[]).length=0;for(let e=0,r=s.length;e<r;e++)t.push(s[e].x,s[e].y);return t}static scan(e,t){let r=function(e){_r.clear(),dr.length=0;for(let t=e.length-1;t>=0;t--){let r=e[t],s=r.x+"_"+r.y;_r.has(s)||(_r.add(s),dr.push(r))}return dr}(e),s=r.length,i=0;for(let e=1;e<s;e++)(r[e].y<r[i].y||r[e].y==r[i].y&&r[e].x<r[i].x)&&(i=e);let a=r[0];r[0]=r[i],r[i]=a;for(let e=1;e<s-1;e++){i=e;for(let t=e+1;t<s;t++)(pr(r[t],r[i],r[0])>0||0==pr(r[t],r[i],r[0])&&gr(r[0],r[t])<gr(r[0],r[i]))&&(i=t);let t=r[e];r[e]=r[i],r[i]=t}if((t=t||[]).length=0,r.length<3)return t.push(...r),t;t.push(r[0],r[1],r[2]);for(let e=3;e<s;e++){for(;t.length>=2&&pr(r[e],t[t.length-1],t[t.length-2])>=0;)t.pop();t.push(r[e])}return t}}const ur=[],dr=[],cr=[],_r=new Set;function pr(e,t,r){return(e.x-r.x)*(t.y-r.y)-(t.x-r.x)*(e.y-r.y)}function gr(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)}const mr="SaveCmd";class fr{static create(){return h.getItemByClass(mr,fr)}recover(){h.recover(mr,this)}run(e){e.save()}get cmdID(){return fr.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}fr.ID=mr;class Tr{destroy(){this._cached=!1,this._bounds=null,this._bound2=null,h.recover("GraphicsBounds",this)}static create(){return h.getItemByClass("GraphicsBounds",Tr)}reset(){this._cached=!1}getBounds(e){return this._cached||(e._useSpriteRect?(this._bounds=(this._bounds||new te).setTo(0,0,e.owner.width,e.owner.height),this._bound2=this._bounds.getBoundPoints(this._bound2)):(this._bound2=this._getCmdPoints(e),this._bounds=te._getWrapRec(this._bound2,this._bounds)),this._cached=!0),this._bounds}getBoundPoints(e){return this.getBounds(e),this._bound2}_getCmdPoints(e){let t=this._bound2||(this._bound2=[]);t.length=0;let r=e.cmds,s=e.owner;if(0==r.length)return t;yr.allPoints=t,yr.width=s._width,yr.height=s._height,yr.matrix.identity();let i=Sr;i.length=0;for(let e=0,t=r.length;e<t;e++){let t=r[e];switch(t.cmdID){case fr.ID:i.push(yr.matrix),yr.matrix=yr.matrix.clone();break;case lr.ID:yr.matrix=i.pop();break;default:yr.points.length=0,t.getBounds?t.getBounds(yr):Er.setTo(s.x,s.y,s._width,s._height).getBoundPoints(yr.points),yr.points.length>0&&yr.flushPoints()}}if(t.length>200){let e=te._getWrapRec(t,Er);t.length=0,e.getBoundPoints(t)}else t.length>8&&hr.scanPList(t,t);return t}}const yr=new class{constructor(){this.points=[],this.matrix=new Ce}flushPoints(e,t,r){null==e&&(e=0),null==t&&(t=0),r?(this.matrix.copyTo(xr),xr.concat(r),r=xr):r=this.matrix;let s=this.points.length,i=d.TEMP;for(let a=0;a<s;a+=2)i.setTo(this.points[a]+e,this.points[a+1]+t),null==i.x&&(i.x=0),null==i.y&&(i.y=0),r.transformPoint(i),this.allPoints.push(i.x,i.y);this.points.length=0}concatMatrix(e){e.copyTo(xr),xr.concat(this.matrix),xr.copyTo(this.matrix)}},xr=new Ce,Sr=[],Er=new te;var vr,Dr,wr,Rr,Cr;class Mr{}vr=Mr,Mr.TEXT=1,Mr.AREA2D=2,Mr.CANVAS=8,Mr.POSTPROCESS=16,Mr.MASK=32,Mr.CLIP=64,Mr.GRAPHICS=256,Mr.RENDERNODE2D=2048,Mr.DRAW2RT=vr.CANVAS|vr.POSTPROCESS|vr.MASK,Mr.UPDATETRANS=vr.CANVAS|vr.POSTPROCESS|vr.MASK|vr.CLIP|vr.GRAPHICS|vr.RENDERNODE2D,e.RepaintFlag=void 0,(Dr=e.RepaintFlag||(e.RepaintFlag={}))[Dr.Normal=0]="Normal",Dr[Dr.Size=1]="Size",Dr[Dr.Graphics=2]="Graphics",Dr[Dr.ChildChange=4]="ChildChange",Dr[Dr.UpdateRT=7]="UpdateRT",e.TransformKind=void 0,(wr=e.TransformKind||(e.TransformKind={}))[wr.Pos=1]="Pos",wr[wr.Width=2]="Width",wr[wr.Height=4]="Height",wr[wr.Anchor=8]="Anchor",wr[wr.Scale=16]="Scale",wr[wr.Skew=32]="Skew",wr[wr.Rotation=64]="Rotation",wr[wr.Matrix=128]="Matrix",wr[wr.Size=6]="Size",wr[wr.Layout=30]="Layout",wr[wr.TRS=113]="TRS",e.BaseRender2DType=void 0,(Rr=e.BaseRender2DType||(e.BaseRender2DType={}))[Rr.empty=-1]="empty",Rr[Rr.baseRenderNode=0]="baseRenderNode",Rr[Rr.spine=1]="spine",Rr[Rr.particle=2]="particle",Rr[Rr.spineSimple=3]="spineSimple",Rr[Rr.graphics=4]="graphics",Rr[Rr.spinenormal=5]="spinenormal",Rr[Rr.sequenceFrame2D=6]="sequenceFrame2D",e.SubPassFlag=void 0,(Cr=e.SubPassFlag||(e.SubPassFlag={}))[Cr.PostProcess=1]="PostProcess",Cr[Cr.CacheAsBitmap=2]="CacheAsBitmap",Cr[Cr.Mask=4]="Mask",Cr[Cr.RenderTexture=8]="RenderTexture",Cr[Cr.RenderTextureContent=16]="RenderTextureContent",Cr[Cr.UPDATE_POSTPROCESS=25]="UPDATE_POSTPROCESS";const br="AlphaCmd";class Ar{static create(e){var t=h.getItemByClass(br,Ar);return t.alpha=e,t}recover(){h.recover(br,this)}run(e,t,r){e.alpha(this.alpha)}getBounds(e){}get cmdID(){return Ar.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}Ar.ID=br;const Ir=[-1,0,-1,2,4,3,-1,1,-1],Pr=[4,0,1,1,5,4,5,1,2,2,6,5,6,2,3,3,7,6,8,4,5,5,9,8,9,5,6,6,10,9,10,6,7,7,11,10,12,8,9,9,13,12,13,9,10,10,14,13,14,10,11,11,15,14],Br=[0,0,0,0],Lr=[0,0,0,0],Nr=[0,0,0,0],Fr=[0,0,0,0];function Or(e,t,r,s,i){const a=e.mainTex.sourceWidth,n=e.mainTex.sourceHeight,o=r.width/a,l=r.height/n,h=s.right,u=s.bottom;if(Br.length=0,Br.push(r.x,r.x+s.x*o,r.x+h*o,r.right),Lr.length=0,Lr.push(r.y,r.y+s.y*l,r.y+u*l,r.bottom),function(e,t,r,s,i,a){const n=e.mainTex;if(!n||n._dynamic)return;const o=n.uvrect;if(!o||0===o[0]&&0===o[1]&&1===o[2]&&1===o[3])return;const l=n.bitmap;if(!l||l.width<=0||l.height<=0)return;const h=o[0],u=o[1],d=h+o[2],c=u+o[3],_=Math.min(.5/l.width,.5*o[2]),p=Math.min(.5/l.height,.5*o[3]);kr(s.x)&&(i[0]=Gr(i[0],h,d,_),i[1]=Gr(i[1],h,d,_));kr(t-s.right)&&(i[2]=Gr(i[2],h,d,_),i[3]=Gr(i[3],h,d,_));kr(s.y)&&(a[0]=Gr(a[0],u,c,p),a[1]=Gr(a[1],u,c,p));kr(r-s.bottom)&&(a[2]=Gr(a[2],u,c,p),a[3]=Gr(a[3],u,c,p))}(e,a,n,s,Br,Lr),Nr[0]=t.x,t.width>=a-s.width)Nr[1]=Nr[0]+s.x,Nr[2]=t.right-(a-h),Nr[3]=t.right;else{const e=s.x/(a-h),r=Nr[0]+t.width*e/(1+e);Nr[1]=r,Nr[2]=r,Nr[3]=t.right}if(Fr[0]=t.y,t.height>=n-s.height)Fr[1]=Fr[0]+s.y,Fr[2]=t.bottom-(n-u),Fr[3]=t.bottom;else{const e=s.y/(n-u),r=Fr[0]+t.height*e/(1+e);Fr[1]=r,Fr[2]=r,Fr[3]=t.bottom}if(0===i){for(let t=0;t<4;t++)for(let r=0;r<4;r++)e.addVert(Nr[r],Fr[t],null,Br[r],Lr[t]);e.addTriangles(Pr)}else{const t=te.create(),r=te.create();let a=e.vertCount;for(let n=0;n<9;n++){const o=n%3,l=Math.floor(n/3),h=Ir[n];te.minMaxRect(Nr[o],Fr[l],Nr[o+1],Fr[l+1],t),te.minMaxRect(Br[o],Lr[l],Br[o+1],Lr[l+1],r),-1!==h&&i&1<<h?(a!==e.vertCount&&e.triangulateQuad(a),Ur(e,t,r,0===h||1===h||4===h?s.width:t.width,2===h||3===h||4===h?s.height:t.height,!0,!0),a=e.vertCount):e.addQuad(t,null,r)}a!==e.vertCount&&e.triangulateQuad(a),t.recover(),r.recover()}}function Ur(e,t,r,s,i,a,n){let o=a?Math.ceil(t.width/s)-1:0,l=n?Math.ceil(t.height/i)-1:0,h=t.width-o*s,u=t.height-l*i;const d=te.create(),c=te.create();let _=e.vertCount;for(let _=0;_<=o;_++)for(let p=0;p<=l;p++)d.setTo(t.x+_*s,t.y+p*i,_<o?s:h,p<l?i:u),c.setTo(r.x,r.y,_<o||!a?r.width:r.width*h/s,p<l||!n?r.height:r.height*u/i),e.addQuad(d,null,c);e.triangulateQuad(_),d.recover(),c.recover()}function kr(e){return Math.abs(e)<=1e-7}function Gr(e,t,r,s){return Vr(e,t)?t+s:Vr(e,r)?r-s:e}function Vr(e,t){return Math.abs(e-t)<=1e-7}class zr{constructor(e){if(this.arrColor=[],null==e||"none"==e)return this.strColor="#00000000",this.numColor=0,void(this.arrColor=[0,0,0,0]);Hr.parse(e),this.strColor="string"==typeof e?e:Hr.getStyleString(),Hr.writeTo(this.arrColor),this.numColor=Hr.getABGR()}static _initSaveMap(){zr._SAVE_SIZE=0,zr._SAVE={}}static create(e){let t=e+"",r=zr._SAVE[t];return null!=r?r:(zr._SAVE_SIZE>500&&zr._initSaveMap(),zr._SAVE_SIZE++,zr._SAVE[t]=new zr(e))}}zr._SAVE={},zr._SAVE_SIZE=0;const Hr=new y;class Wr{static lerp(e,t,r){return e*(1-r)+t*r}static repeat(e,t){return e-Math.floor(e/t)*t}static distance(e,t,r,s){return Math.sqrt(Math.pow(e-r,2)+Math.pow(t-s,2))}static clamp(e,t,r){return e<t?e=t:e>r&&(e=r),e}static clamp01(e){return isNaN(e)?e=0:e>1?e=1:e<0&&(e=0),e}static slerpQuaternionArray(e,t,r,s,i,a,n){var o,l,h,u,d,c=e[t+0],_=e[t+1],p=e[t+2],g=e[t+3],m=r[s+0],f=r[s+1],T=r[s+2],y=r[s+3];return(l=c*m+_*f+p*T+g*y)<0&&(l=-l,m=-m,f=-f,T=-T,y=-y),1-l>1e-6?(o=Math.acos(l),h=Math.sin(o),u=Math.sin((1-i)*o)/h,d=Math.sin(i*o)/h):(u=1-i,d=i),a[n+0]=u*c+d*m,a[n+1]=u*_+d*f,a[n+2]=u*p+d*T,a[n+3]=u*g+d*y,a}static getRotation(e,t,r,s){return Math.atan2(s-t,r-e)/Math.PI*180}static sortBigFirst(e,t){return e==t?0:t>e?1:-1}static sortSmallFirst(e,t){return e==t?0:t>e?-1:1}static sortNumBigFirst(e,t){return parseFloat(t)-parseFloat(e)}static sortNumSmallFirst(e,t){return parseFloat(e)-parseFloat(t)}static sortByKey(e,t=!1,r=!0){var s;return s=t?r?Wr.sortNumBigFirst:Wr.sortBigFirst:r?Wr.sortNumSmallFirst:Wr.sortSmallFirst,function(t,r){return s(t[e],r[e])}}static roundTo(e,t=3,r=1e-6){if(!isFinite(e))return e;const s=Math.pow(10,t),i=Math.round(e*s)/s;return Math.abs(i)<r?0:i}}var Xr;e.IndexFormat=void 0,(Xr=e.IndexFormat||(e.IndexFormat={}))[Xr.UInt8=0]="UInt8",Xr[Xr.UInt16=1]="UInt16",Xr[Xr.UInt32=2]="UInt32";class Yr{static __init__(){Yr.vertexDeclarition=new Bt(64,[new vt(0,It.Vector4,0),new vt(16,It.Vector4,1),new vt(32,It.Vector4,2),new vt(48,It.Vector4,3)]),Yr.stride=Yr.vertexDeclarition.vertexStride/4,t.useGraphics2DIndexUInt32&&f.renderEngine&&f.renderEngine.getCapable(e.RenderCapable.Element_Index_Uint32)?(Yr.GRAPHICS_INDEX_FORMAT=e.IndexFormat.UInt32,Yr.GRAPHICS_INDEX_BYTE_SIZE=4,Yr.GRAPHICS_INDEX_ARRAY_TYPE=Uint32Array,Yr.GRAPHICS_MAX_VERTEX=1048576):(Yr.GRAPHICS_INDEX_FORMAT=e.IndexFormat.UInt16,Yr.GRAPHICS_INDEX_BYTE_SIZE=2,Yr.GRAPHICS_INDEX_ARRAY_TYPE=Uint16Array,Yr.GRAPHICS_MAX_VERTEX=65536),Yr._factory=f.render2DRenderPassFactory.createGraphicsOp2DFactory(),p.isConch&&2!=window.conchConfig.getGraphicsAPI()&&Yr._syncNativeGraphics2D()}static _syncNativeGraphics2D(){const e=window.conchRTGraphicsBatch;e.clearGraphics2DVertexDeclaration();let t=Yr.vertexDeclarition._shaderValues;for(let r in t)e.setGraphics2DVertexDeclaration(parseInt(r),t[r]);e.setGraphics2DIndexFormat(Yr.GRAPHICS_INDEX_FORMAT,Yr.GRAPHICS_INDEX_BYTE_SIZE)}}Yr.GRAPHICS_INDEX_FORMAT=e.IndexFormat.UInt16,Yr.GRAPHICS_INDEX_BYTE_SIZE=2,Yr.GRAPHICS_INDEX_ARRAY_TYPE=Uint16Array,Yr.GRAPHICS_VERTEX_INIT_COUNT=32768,Yr.GRAPHICS_MAX_VERTEX=65536,Yr.stride=16,Yr._factory=null;class qr{constructor(){this._vp=0,this._ip=0,this.contentRect=new te,this.uvRect=new te,this.color=new y,this._vertices=this.resizeBuf(Float32Array,20),this._uvs=this.resizeBuf(Float32Array,20),this._colors=this.resizeBuf(Float32Array,40),this._indices=this.resizeBuf(Yr.GRAPHICS_INDEX_ARRAY_TYPE,30),this._vec=new $e}init(e){if(this.mainTex=e,e){let t=e.uvrect;if(e.width===e.sourceWidth&&e.height===e.sourceHeight)this.uvRect.setTo(t[0],t[1],t[2],t[3]);else{let r=t[2]/e.width,s=t[3]/e.height;this.uvRect.setTo(t[0]-e.offsetX*r,t[1]-e.offsetY*s,e.sourceWidth*r,e.sourceHeight*s)}}else this.uvRect.setTo(0,0,1,1);this.color.setValue(1,1,1,1),this._vp=0,this._ip=0}addVert(e,t,r,s,i){this.checkVBuf(2);let a=this._vp;this._vp+=2,this._vertices[a]=e,this._vertices[a+1]=t,this._uvs[a]=null!=s?s:Wr.lerp(this.uvRect.x,this.uvRect.right,(e-this.contentRect.x)/(this.contentRect.width||1)),this._uvs[a+1]=null!=i?i:Wr.lerp(this.uvRect.y,this.uvRect.bottom,(t-this.contentRect.y)/(this.contentRect.height||1)),(r||this.color).writeTo(this._colors,2*a)}addQuad(e,t,r){r?(this.addVert(e.x,e.y,t,r.x,r.y),this.addVert(e.right,e.y,t,r.right,r.y),this.addVert(e.right,e.bottom,t,r.right,r.bottom),this.addVert(e.x,e.bottom,t,r.x,r.bottom)):(this.addVert(e.x,e.y,t),this.addVert(e.right,e.y,t),this.addVert(e.right,e.bottom,t),this.addVert(e.x,e.bottom,t))}addTriangle(e,t,r){this.checkIBuf(3);let s=this._ip;this._ip+=3,this._indices[s]=e,this._indices[s+1]=t,this._indices[s+2]=r}addTriangles(e){this.checkIBuf(e.length);let t=this._indices,r=this._ip,s=e.length;this._ip+=s;for(let i=0;i<s;i++)t[r+i]=e[i]}triangulateQuad(e){let t=this._vp/2;e<0&&(e=t+e);let r=(t-e)/4*6;this.checkIBuf(r);let s=this._indices;for(let r=e,i=this._ip;r<t;r+=4,i+=6)s[i]=r,s[i+1]=r+1,s[i+2]=r+2,s[i+3]=r+2,s[i+4]=r+3,s[i+5]=r;this._ip+=r}getPos(e){return e<0&&(e=this._vp/2+e),e*=2,this._vec.setValue(this._vertices[e],this._vertices[e+1]),this._vec}get vertCount(){return this._vp/2}getVertices(){return new Float32Array(this._vertices.buffer,0,this._vp)}getUVs(){return new Float32Array(this._uvs.buffer,0,this._vp)}getColors(){return new Float32Array(this._colors.buffer,0,2*this._vp)}getIndices(){let e=Yr.GRAPHICS_INDEX_ARRAY_TYPE;return this._indices.constructor!==e&&(this._indices=this.resizeBuf(e,Math.max(this._indices.length,this._ip),this._indices)),new e(this._indices.buffer,0,this._ip)}checkVBuf(e){if(this._vp+e<this._vertices.length)return;let t=this._vp+Math.max(20,e);this._vertices=this.resizeBuf(Float32Array,t,this._vertices),this._uvs=this.resizeBuf(Float32Array,t,this._uvs),this._colors=this.resizeBuf(Float32Array,2*t,this._colors)}checkIBuf(e){let t=Yr.GRAPHICS_INDEX_ARRAY_TYPE;if(this._indices.constructor===t&&this._ip+e<this._indices.length)return;let r=Math.max(this._indices.length,this._ip+Math.max(30,e));this._indices=this.resizeBuf(t,r,this._indices)}resizeBuf(e,t,r){let s=new e(new ArrayBuffer(e.BYTES_PER_ELEMENT*t));return r&&s.set(r),s}}qr.pool=h.createPool(qr,(e,t)=>e.init(t));class $r{constructor(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}}class Kr{static earcut(e,t,r){r=r||2;var s,i,a,n,o,l,h,u=t&&t.length,d=u?t[0]*r:e.length,c=Kr.linkedList(e,0,d,r,!0),_=[];if(!c)return _;if(u&&(c=Kr.eliminateHoles(e,t,c,r)),e.length>80*r){s=a=e[0],i=n=e[1];for(var p=r;p<d;p+=r)(o=e[p])<s&&(s=o),(l=e[p+1])<i&&(i=l),o>a&&(a=o),l>n&&(n=l);h=0!==(h=Math.max(a-s,n-i))?1/h:0}return Kr.earcutLinked(c,_,r,s,i,h),_}static linkedList(e,t,r,s,i){var a,n;if(i===Kr.signedArea(e,t,r,s)>0)for(a=t;a<r;a+=s)n=Kr.insertNode(a,e[a],e[a+1],n);else for(a=r-s;a>=t;a-=s)n=Kr.insertNode(a,e[a],e[a+1],n);return n&&Kr.equals(n,n.next)&&(Kr.removeNode(n),n=n.next),n}static filterPoints(e,t){if(!e)return e;t||(t=e);var r,s=e;do{if(r=!1,s.steiner||!Kr.equals(s,s.next)&&0!==Kr.area(s.prev,s,s.next))s=s.next;else{if(Kr.removeNode(s),(s=t=s.prev)===s.next)break;r=!0}}while(r||s!==t);return t}static earcutLinked(e,t,r,s,i,a,n=null){if(e){!n&&a&&Kr.indexCurve(e,s,i,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Kr.isEarHashed(e,s,i,a):Kr.isEar(e))t.push(o.i/r),t.push(e.i/r),t.push(l.i/r),Kr.removeNode(e),e=l.next,h=l.next;else if((e=l)===h){n?1===n?(e=Kr.cureLocalIntersections(e,t,r),Kr.earcutLinked(e,t,r,s,i,a,2)):2===n&&Kr.splitEarcut(e,t,r,s,i,a):Kr.earcutLinked(Kr.filterPoints(e,null),t,r,s,i,a,1);break}}}static isEar(e){var t=e.prev,r=e,s=e.next;if(Kr.area(t,r,s)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(Kr.pointInTriangle(t.x,t.y,r.x,r.y,s.x,s.y,i.x,i.y)&&Kr.area(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}static isEarHashed(e,t,r,s){var i=e.prev,a=e,n=e.next;if(Kr.area(i,a,n)>=0)return!1;for(var o=i.x<a.x?i.x<n.x?i.x:n.x:a.x<n.x?a.x:n.x,l=i.y<a.y?i.y<n.y?i.y:n.y:a.y<n.y?a.y:n.y,h=i.x>a.x?i.x>n.x?i.x:n.x:a.x>n.x?a.x:n.x,u=i.y>a.y?i.y>n.y?i.y:n.y:a.y>n.y?a.y:n.y,d=Kr.zOrder(o,l,t,r,s),c=Kr.zOrder(h,u,t,r,s),_=e.nextZ;_&&_.z<=c;){if(_!==e.prev&&_!==e.next&&Kr.pointInTriangle(i.x,i.y,a.x,a.y,n.x,n.y,_.x,_.y)&&Kr.area(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(_=e.prevZ;_&&_.z>=d;){if(_!==e.prev&&_!==e.next&&Kr.pointInTriangle(i.x,i.y,a.x,a.y,n.x,n.y,_.x,_.y)&&Kr.area(_.prev,_,_.next)>=0)return!1;_=_.prevZ}return!0}static cureLocalIntersections(e,t,r){var s=e;do{var i=s.prev,a=s.next.next;!Kr.equals(i,a)&&Kr.intersects(i,s,s.next,a)&&Kr.locallyInside(i,a)&&Kr.locallyInside(a,i)&&(t.push(i.i/r),t.push(s.i/r),t.push(a.i/r),Kr.removeNode(s),Kr.removeNode(s.next),s=e=a),s=s.next}while(s!==e);return s}static splitEarcut(e,t,r,s,i,a){var n=e;do{for(var o=n.next.next;o!==n.prev;){if(n.i!==o.i&&Kr.isValidDiagonal(n,o)){var l=Kr.splitPolygon(n,o);return n=Kr.filterPoints(n,n.next),l=Kr.filterPoints(l,l.next),Kr.earcutLinked(n,t,r,s,i,a),void Kr.earcutLinked(l,t,r,s,i,a)}o=o.next}n=n.next}while(n!==e)}static eliminateHoles(e,t,r,s){var i,a,n,o,l,h=[];for(i=0,a=t.length;i<a;i++)n=t[i]*s,o=i<a-1?t[i+1]*s:e.length,(l=Kr.linkedList(e,n,o,s,!1))===l.next&&(l.steiner=!0),h.push(Kr.getLeftmost(l));for(h.sort(Kr.compareX),i=0;i<h.length;i++)Kr.eliminateHole(h[i],r),r=Kr.filterPoints(r,r.next);return r}static compareX(e,t){return e.x-t.x}static eliminateHole(e,t){if(t=Kr.findHoleBridge(e,t)){var r=Kr.splitPolygon(t,e);Kr.filterPoints(r,r.next)}}static findHoleBridge(e,t){var r,s=t,i=e.x,a=e.y,n=-1/0;do{if(a<=s.y&&a>=s.next.y&&s.next.y!==s.y){var o=s.x+(a-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(o<=i&&o>n){if(n=o,o===i){if(a===s.y)return s;if(a===s.next.y)return s.next}r=s.x<s.next.x?s:s.next}}s=s.next}while(s!==t);if(!r)return null;if(i===n)return r.prev;var l,h=r,u=r.x,d=r.y,c=1/0;for(s=r.next;s!==h;)i>=s.x&&s.x>=u&&i!==s.x&&Kr.pointInTriangle(a<d?i:n,a,u,d,a<d?n:i,a,s.x,s.y)&&((l=Math.abs(a-s.y)/(i-s.x))<c||l===c&&s.x>r.x)&&Kr.locallyInside(s,e)&&(r=s,c=l),s=s.next;return r}static indexCurve(e,t,r,s){var i=e;do{null===i.z&&(i.z=Kr.zOrder(i.x,i.y,t,r,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Kr.sortLinked(i)}static sortLinked(e){var t,r,s,i,a,n,o,l,h=1;do{for(r=e,e=null,a=null,n=0;r;){for(n++,s=r,o=0,t=0;t<h&&(o++,s=s.nextZ);t++);for(l=h;o>0||l>0&&s;)0!==o&&(0===l||!s||r.z<=s.z)?(i=r,r=r.nextZ,o--):(i=s,s=s.nextZ,l--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=s}a.nextZ=null,h*=2}while(n>1);return e}static zOrder(e,t,r,s,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}static getLeftmost(e){var t=e,r=e;do{t.x<r.x&&(r=t),t=t.next}while(t!==e);return r}static pointInTriangle(e,t,r,s,i,a,n,o){return(i-n)*(t-o)-(e-n)*(a-o)>=0&&(e-n)*(s-o)-(r-n)*(t-o)>=0&&(r-n)*(a-o)-(i-n)*(s-o)>=0}static isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Kr.intersectsPolygon(e,t)&&Kr.locallyInside(e,t)&&Kr.locallyInside(t,e)&&Kr.middleInside(e,t)}static area(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}static equals(e,t){return e.x===t.x&&e.y===t.y}static intersects(e,t,r,s){return!!(Kr.equals(e,t)&&Kr.equals(r,s)||Kr.equals(e,s)&&Kr.equals(r,t))||Kr.area(e,t,r)>0!=Kr.area(e,t,s)>0&&Kr.area(r,s,e)>0!=Kr.area(r,s,t)>0}static intersectsPolygon(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Kr.intersects(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}static locallyInside(e,t){return Kr.area(e.prev,e,e.next)<0?Kr.area(e,t,e.next)>=0&&Kr.area(e,e.prev,t)>=0:Kr.area(e,t,e.prev)<0||Kr.area(e,e.next,t)<0}static middleInside(e,t){var r=e,s=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next}while(r!==e);return s}static splitPolygon(e,t){var r=new $r(e.i,e.x,e.y),s=new $r(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,s.next=r,r.prev=s,a.next=s,s.prev=a,s}static insertNode(e,t,r,s){var i=new $r(e,t,r);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}static removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}static signedArea(e,t,r,s){for(var i=0,a=t,n=r-s;a<r;a+=s)i+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return i}}const jr=[{x:0,y:0,u:0,v:0,r:0,g:0,b:0,a:0,index:0},{x:0,y:0,u:0,v:0,r:0,g:0,b:0,a:0,index:0},{x:0,y:0,u:0,v:0,r:0,g:0,b:0,a:0,index:0}],Qr=new i;class Zr{static _resetBuffers(){const e=Zr._threadLocalContext;e.outVerticesLength=0,e.outIndicesLength=0,e.outUVsLength=0,e.outColorsLength=0,e.clipBuffer1Length=0,e.clipBuffer2Length=0}static _ensureBufferCapacity(e,t,r){if(e.length>=t&&e.constructor===r)return e;return new r(Math.max(t,Math.ceil(1.5*e.length)))}static clipTrianglesByUVRange(e,t,r,s,i,a=!0){Zr._resetBuffers();const n=Zr._threadLocalContext,o=Zr.EPSILON,l=s[0],h=s[1],u=s[0]+s[2],d=s[1]+s[3];let c=Qr;c.x=l-o,c.y=h-o,c.z=u+o,c.w=d+o;const _=r.length/2,p=new Uint8Array(_);let g=!0;for(let e=0;e<_;e++){const t=r[2*e],s=r[2*e+1];let i=0;t>=c.x&&(i|=1),t<=c.z&&(i|=2),s>=c.y&&(i|=4),s<=c.w&&(i|=8),p[e]=i,15!==i&&(g=!1)}if(g)return{vertices:e,indices:t,uvs:r,colors:i};const m=n.outVertices,f=n.outIndices,T=n.outUVs,y=n.outColors;let x=0;const S=e=>{const t=x++,r=n.outVerticesLength,s=n.outColorsLength;return m[r]=e.x,m[r+1]=e.y,T[r]=e.u,T[r+1]=e.v,y[s]=e.r,y[s+1]=e.g,y[s+2]=e.b,y[s+3]=e.a,n.outVerticesLength=r+2,n.outUVsLength=r+2,n.outColorsLength=s+4,t},E=(e,t)=>{switch(t){case 0:return e.u>=c.x;case 1:return e.u<=c.z;case 2:return e.v>=c.y;case 3:return e.v<=c.w}return!1},v=(e,t,r,s,i,a,n,o,l,h,u)=>{if(e[t]){let d=e[t];d.x=r,d.y=s,d.u=i,d.v=a,d.r=n,d.g=o,d.b=l,d.a=h,d.index=u}else e[t]={x:r,y:s,u:i,v:a,r:n,g:o,b:l,a:h,index:u}},D=(e,t,r,s,i)=>{let a;switch(r){case 0:if(Math.abs(t.u-e.u)<o)return!1;a=(l-e.u)/(t.u-e.u);break;case 1:if(Math.abs(t.u-e.u)<o)return!1;a=(u-e.u)/(t.u-e.u);break;case 2:if(Math.abs(t.v-e.v)<o)return!1;a=(h-e.v)/(t.v-e.v);break;case 3:if(Math.abs(t.v-e.v)<o)return!1;a=(d-e.v)/(t.v-e.v);break;default:return!1}return!(a<-o||a>1+o)&&(v(s,i,e.x+a*(t.x-e.x),e.y+a*(t.y-e.y),e.u+a*(t.u-e.u),e.v+a*(t.v-e.v),e.r+a*(t.r-e.r),e.g+a*(t.g-e.g),e.b+a*(t.b-e.b),e.a+a*(t.a-e.a),-1),!0)},w=(e,t)=>{let r=e,s=t,i=n.clipBuffer1;for(let e=0;e<4;e++){const t=e%2==0?n.clipBuffer1:n.clipBuffer2;let a=0;if(0===s)return{length:0,buffer:t};const o=1<<e;for(let i=0;i<s;i++){const n=r[i],l=r[(i+1)%s],h=n.index>=0?0!==(p[n.index]&o):E(n,e),u=l.index>=0?0!==(p[l.index]&o):E(l,e);h?(v(t,a++,n.x,n.y,n.u,n.v,n.r,n.g,n.b,n.a,n.index),u||D(n,l,e,t,a)&&a++):u&&D(n,l,e,t,a)&&a++}if(0===a)return{length:0,buffer:t};r=t,s=a,i=t,e%2==0?n.clipBuffer1Length=a:n.clipBuffer2Length=a}return{length:s,buffer:i}},R=(t,s)=>{let a=jr[t];return a.x=e[2*s],a.y=e[2*s+1],a.u=r[2*s],a.v=r[2*s+1],a.r=i[4*s],a.g=i[4*s+1],a.b=i[4*s+2],a.a=i[4*s+3],a.index=s,a},C=t.length/3;let M=jr;for(let e=0;e<C;e++){R(0,t[3*e]),R(1,t[3*e+1]),R(2,t[3*e+2]);const r=p[M[0].index],s=p[M[1].index],i=p[M[2].index];if(15===r&&15===s&&15===i){const e=S(M[0]),t=S(M[1]),r=S(M[2]);f[n.outIndicesLength++]=e,f[n.outIndicesLength++]=t,f[n.outIndicesLength++]=r;continue}const a=r|s|i;if(!(1&a&&2&a&&4&a&&8&a))continue;const o=w(M,3),l=o.length,h=o.buffer;if(!(l<3))if(3===l){const e=S(h[0]),t=S(h[1]),r=S(h[2]);f[n.outIndicesLength++]=e,f[n.outIndicesLength++]=t,f[n.outIndicesLength++]=r}else{const e=n.earcutData;let t=0;for(let r=0;r<l;r++)e[t++]=h[r].x,e[t++]=h[r].y;e.length=t;const r=Kr.earcut(e,null,2);if(r.length>0){const e=n.vertexIndices;for(let t=0;t<l;t++)e[t]=S(h[t]);for(let t=0;t<r.length;t+=3)f[n.outIndicesLength++]=e[r[t]],f[n.outIndicesLength++]=e[r[t+1]],f[n.outIndicesLength++]=e[r[t+2]]}}}if(a){n.verticesBuffer=Zr._ensureBufferCapacity(n.verticesBuffer,n.outVerticesLength,Float32Array),n.indicesBuffer=Zr._ensureBufferCapacity(n.indicesBuffer,n.outIndicesLength,Yr.GRAPHICS_INDEX_ARRAY_TYPE),n.uvsBuffer=Zr._ensureBufferCapacity(n.uvsBuffer,n.outUVsLength,Float32Array),n.colorsBuffer=Zr._ensureBufferCapacity(n.colorsBuffer,n.outColorsLength,Float32Array);for(let e=0;e<n.outVerticesLength;e++)n.verticesBuffer[e]=m[e];for(let e=0;e<n.outIndicesLength;e++)n.indicesBuffer[e]=f[e];for(let e=0;e<n.outUVsLength;e++)n.uvsBuffer[e]=T[e];for(let e=0;e<n.outColorsLength;e++)n.colorsBuffer[e]=y[e];return{vertices:n.verticesBuffer.subarray(0,n.outVerticesLength),indices:n.indicesBuffer.subarray(0,n.outIndicesLength),uvs:n.uvsBuffer.subarray(0,n.outUVsLength),colors:n.colorsBuffer.subarray(0,n.outColorsLength)}}{const e=new Float32Array(n.outVerticesLength),t=new Yr.GRAPHICS_INDEX_ARRAY_TYPE(n.outIndicesLength),r=new Float32Array(n.outUVsLength),s=new Float32Array(n.outColorsLength);for(let t=0;t<n.outVerticesLength;t++)e[t]=m[t];for(let e=0;e<n.outIndicesLength;e++)t[e]=f[e];for(let e=0;e<n.outUVsLength;e++)r[e]=T[e];for(let e=0;e<n.outColorsLength;e++)s[e]=y[e];return{vertices:e,indices:t,uvs:r,colors:s}}}}function Jr(e,t,r,s,i,a,n,o,l,h,u,d,c,_){const p=i.length/2,g=Yr.GRAPHICS_MAX_VERTEX;if(p<=g)return void e.drawTriangles(t,r,s,i,a,n,o,l,h,u,d,c,null!=_?_:void 0);const m=n.length/3;let f=0;for(;f<m;){const p=new Map;let T=0,y=f;for(;y<m;){let e=0;for(let t=0;t<3;t++)p.has(n[3*y+t])||e++;if(T+e>g)break;for(let e=0;e<3;e++){const t=n[3*y+e];p.has(t)||p.set(t,T++)}y++}const x=new Float32Array(2*T),S=new Float32Array(2*T),E=d?new Float32Array(4*T):null,v=_?new Float32Array(4*T):null,D=3*(y-f),w=new Yr.GRAPHICS_INDEX_ARRAY_TYPE(D);p.forEach((e,t)=>{x[2*e]=i[2*t],x[2*e+1]=i[2*t+1],S[2*e]=a[2*t],S[2*e+1]=a[2*t+1],d&&E&&(E[4*e]=d[4*t],E[4*e+1]=d[4*t+1],E[4*e+2]=d[4*t+2],E[4*e+3]=d[4*t+3]),_&&v&&(v[4*e]=_[4*t],v[4*e+1]=_[4*t+1],v[4*e+2]=_[4*t+2],v[4*e+3]=_[4*t+3])});for(let e=f;e<y;e++){const t=3*(e-f);w[t]=p.get(n[3*e]),w[t+1]=p.get(n[3*e+1]),w[t+2]=p.get(n[3*e+2])}e.drawTriangles(t,r,s,x,S,w,o,l,h,u,E,c,v),f=y}}Zr.EPSILON=1e-7,Zr._threadLocalContext={outVertices:[],outIndices:[],outUVs:[],outColors:[],clipBuffer1:[],clipBuffer2:[],earcutData:[],vertexIndices:[],outVerticesLength:0,outIndicesLength:0,outUVsLength:0,outColorsLength:0,clipBuffer1Length:0,clipBuffer2Length:0,verticesBuffer:new Float32Array(0),indicesBuffer:new Yr.GRAPHICS_INDEX_ARRAY_TYPE(0),uvsBuffer:new Float32Array(0),colorsBuffer:new Float32Array(0)};const es="Draw9GridTextureCmd";class ts{constructor(){this._texture=null,this.x=0,this.y=0,this.width=1,this.height=1,this.color=4294967295,this.percent=!0}static create(e,t,r,s,i,a,n,o){let l=h.getItemByClass(es,ts);return l.texture=e,l.x=t,l.y=r,l.width=s,l.height=i,l.sizeGrid=a,l.percent=n,l.color=null!=o?zr.create(o).numColor:4294967295,l}recover(){var e;null===(e=this._texture)||void 0===e||e._removeReference(),this._texture=null,h.recover(es,this)}get texture(){return this._texture}set texture(e){var t;e&&e._addReference(),null===(t=this._texture)||void 0===t||t._removeReference(),this._texture=e}run(e,r,s){if(this._texture){let i=this.sizeGrid||this._texture._sizeGrid||rs,a=this.x,n=this.y,o=this.width,l=this.height;this.percent&&e.sprite&&(a*=e.sprite.width,n*=e.sprite.height,o*=e.sprite.width,l*=e.sprite.height);let h=qr.pool.take(this._texture);h.contentRect.setTo(0,0,o,l),this.color&&h.color.setABGR(this.color);let u=te.create(),d=h.mainTex.sourceWidth,c=h.mainTex.sourceHeight;if(u.setTo(i[3],i[0],d-i[1]-i[3],c-i[0]-i[2]),Or(h,h.contentRect,h.uvRect,u,1===i[4]?255:0),this._texture.uvrect)if("cpu"===t.uvClipMode){const t=Zr.clipTrianglesByUVRange(h.getVertices(),h.getIndices(),h.getUVs(),this._texture.uvrect,h.getColors());Jr(e,this._texture,a+r,n+s,t.vertices,t.uvs,t.indices,null,1,null,null,t.colors,null)}else Jr(e,this._texture,a+r,n+s,h.getVertices(),h.getUVs(),h.getIndices(),null,1,null,null,h.getColors(),this._texture.uvrect);else Jr(e,this._texture,a+r,n+s,h.getVertices(),h.getUVs(),h.getIndices(),null,1,null,null,h.getColors(),null);qr.pool.recover(h)}}get cmdID(){return ts.ID}needsLayoutRepaint(){return 1}getGraphicsCommandInfo(e){return sr.writeSize(e,this.percent,2)}getBounds(e){let t=te.TEMP.setTo(this.x,this.y,this.width,this.height);this.percent&&t.scale(e.width,e.height),t.getBoundPoints(e.points)}}ts.ID=es;const rs=[0,0,0,0,0];Ee.regClass(es,ts);const ss="DrawCircleCmd";class is{constructor(){this.lineWidth=0}static create(e,t,r,s,i,a,n){var o=h.getItemByClass(ss,is);return o.x=e,o.y=t,o.radius=r,o.fillColor=s,o.lineColor=i,o.lineWidth=a,o.percent=n,o}recover(){this.fillColor=null,this.lineColor=null,h.recover(ss,this)}run(e,t,r){let s=this.lineWidth>=1&&this.lineColor?this.lineWidth/2:0;if(this.percent&&e.sprite){let i=e.sprite.width,a=e.sprite.height;e._drawCircle(this.x*i+t,this.y*a+r,this.radius*Math.min(i,a)-s,this.fillColor,this.lineColor,this.lineWidth,0)}else e._drawCircle(this.x+t,this.y+r,this.radius-s,this.fillColor,this.lineColor,this.lineWidth,0)}get cmdID(){return is.ID}needsLayoutRepaint(){return 1}getGraphicsCommandInfo(e,t){let r=this.lineWidth>=1&&this.lineColor?this.lineWidth/2:0,s=this.percent?this.radius*ir.getOwnerMinSize(t)-r:this.radius-r;return sr.writeScaleTessellation(e,this.percent,ir.calcArcSegments(s,t,40,5))}getBounds(e){let t=te.TEMP.setTo(this.x-this.radius,this.y-this.radius,this.radius+this.radius,this.radius+this.radius);this.percent&&t.scale(e.width,e.height),t.getBoundPoints(e.points)}}is.ID=ss,Ee.regClass(ss,is);class as{static getPoints(e,t=5,r=2,s){s=s||[];let i=e.length;if(i<2*(r+1))return s;switch(r){case 2:os=ds;break;case 3:os=cs;break;default:return[]}for(;ns.length<=r;)ns.push(new d);for(let t=0;t<2*r;t+=2)us(e[t],e[t+1]);for(let a=2*r;a<i;a+=2)us(e[a],e[a+1]),a/2%r==0&&_s(t,s);return s}static getRate(e,t,r,s,i){let a,n=function(e,t,r,s){return 100*(100*(100*(100*e+t)+r)+s)}(t,r,s,i),o=100*n+e;if(ls[o])return ls[o];var l;hs[n]?a=hs[n]:(l=[0,0,t,r,s,i,1,1],a=as.getPoints(l,100,3),hs[n]=a);let h=a.length;for(let t=0;t<h;t+=2)if(e<=a[t])return ls[o]=a[t+1],a[t+1];return ls[o]=1,1}}const ns=[new d,new d,new d];var os=ds;const ls={},hs={};function us(e,t){let r=ns.pop();r.setTo(e,t),ns.unshift(r)}function ds(e,t){var r=ns[2],s=ns[1],i=ns[0],a=Math.pow(1-e,2)*r.x+2*e*(1-e)*s.x+Math.pow(e,2)*i.x,n=Math.pow(1-e,2)*r.y+2*e*(1-e)*s.y+Math.pow(e,2)*i.y;t.push(a,n)}function cs(e,t){var r=ns[3],s=ns[2],i=ns[1],a=ns[0],n=Math.pow(1-e,3)*r.x+3*s.x*e*(1-e)*(1-e)+3*i.x*e*e*(1-e)+a.x*Math.pow(e,3),o=Math.pow(1-e,3)*r.y+3*s.y*e*(1-e)*(1-e)+3*i.y*e*e*(1-e)+a.y*Math.pow(e,3);t.push(n,o)}function _s(e,t){var r,s;for(s=1/(e=e>0?e:5),r=0;r<=1;r+=s)os(r,t)}const ps="DrawCurvesCmd";class gs{static create(e,t,r,s,i){var a=h.getItemByClass(ps,gs);return a.x=e,a.y=t,a.points=r,a.lineColor=s,a.lineWidth=i,a}recover(){this.points=null,this.lineColor=null,h.recover(ps,this)}run(e,t,r){this.points&&e.drawCurves(this.x+t,this.y+r,this.points,this.lineColor,this.lineWidth)}get cmdID(){return gs.ID}needsLayoutRepaint(){return 1}getGraphicsCommandInfo(e){return e.dependency=0,e.layoutRefresh=0,e.scaleTessellationKey=0,e.isStateCommand=!1,e}getBounds(e){as.getPoints(this.points,5,2,e.points),e.flushPoints(this.x,this.y)}}gs.ID=ps,Ee.regClass(ps,gs);const ms="DrawImageCmd";class fs{constructor(){this.color=4294967295}static create(e,t,r,s,i,a){let n=h.getItemByClass(ms,fs);return n.texture=e,e&&e._addReference(),n.x=null!=t?t:0,n.y=null!=r?r:0,n.width=null!=s?s:e.sourceWidth,n.height=null!=i?i:e.sourceHeight,n.color=null!=a?zr.create(a).numColor:4294967295,n}recover(){this.texture&&this.texture._removeReference(),this.texture=null,this._cacheData=null,h.recover(ms,this)}run(e,t,r){let s=this.texture;if(!s)return;let i=this.x,a=this.y,n=this.width,o=this.height,l=n/s.sourceWidth,h=o/s.sourceHeight;n=s.width*l,o=s.height*h,i+=s.offsetX*l,a+=s.offsetY*h,e.drawTexture(this.texture,i+t,a+r,n,o,this.color)}getBounds(e){te.TEMP.setTo(this.x,this.y,this.width,this.height).getBoundPoints(e.points)}get cmdID(){return fs.ID}}fs.ID=ms;const Ts="DrawLineCmd";class ys{constructor(){this.lineWidth=0}static create(e,t,r,s,i,a,n){var o=h.getItemByClass(Ts,ys);return o.fromX=e,o.fromY=t,o.toX=r,o.toY=s,o.lineColor=i,o.lineWidth=a,o.percent=n,o}recover(){h.recover(Ts,this)}run(e,t,r){let s=this.lineWidth<1||this.lineWidth%2==0?0:.5;if(this.percent&&e.sprite){let i=e.sprite.width,a=e.sprite.height;e._drawLine(t,r,this.fromX*i+s,this.fromY*a+s,this.toX*i+s,this.toY*a+s,this.lineColor,this.lineWidth,0)}else e._drawLine(t,r,this.fromX+s,this.fromY+s,this.toX+s,this.toY+s,this.lineColor,this.lineWidth,0)}get cmdID(){return ys.ID}needsLayoutRepaint(){return this.percent?1:0}getGraphicsCommandInfo(e){return sr.writeSize(e,this.percent,2)}getBounds(e){let t;t=.5*this.lineWidth;let r=this.fromX,s=this.fromY,i=this.toX,a=this.toY;this.percent&&(r*=e.width,s*=e.height,i*=e.width,a*=e.height),r==i?e.points.push(r+t,s,i+t,a,r-t,s,i-t,a):s==a?e.points.push(r,s+t,i,a+t,r,s-t,i,a-t):e.points.push(r,s,i,a)}}ys.ID=Ts,Ee.regClass(Ts,ys);const xs="DrawLinesCmd";class Ss{constructor(){this.lineWidth=0}static create(e,t,r,s,i){var a=h.getItemByClass(xs,Ss);return a.x=e,a.y=t,a.points=r,a.lineColor=s,a.lineWidth=i,a}recover(){this.points=null,this.lineColor=null,h.recover(xs,this)}run(e,t,r){let s=this.lineWidth<1||this.lineWidth%2==0?0:.5;this.points&&e._drawLines(this.x+s+t,this.y+s+r,this.points,this.lineColor,this.lineWidth,0)}getBounds(e){e.points.push(...this.points),e.flushPoints(this.x,this.y)}get cmdID(){return Ss.ID}}Ss.ID=xs,Ee.regClass(xs,Ss);const Es="DrawPathCmd";class vs{static create(e,t,r,s,i){var a=h.getItemByClass(Es,vs);return a.x=e,a.y=t,a.paths=r,a.brush=s,a.pen=i,a}recover(){this.paths=null,this.brush=null,this.pen=null,h.recover(Es,this)}run(e,t,r){this.paths&&e._drawPath(this.x+t,this.y+r,this.paths,this.brush,this.pen)}get cmdID(){return vs.ID}getBounds(e){let t=this.paths,r=t.length;for(let s=0;s<r;s++){let r=t[s];r.length>1&&(e.points.push(r[1],r[2]),r.length>3&&e.points.push(r[3],r[4]))}e.flushPoints(this.x,this.y)}}vs.ID=Es,Ee.regClass(Es,vs);const Ds="DrawPieCmd";class ws{constructor(){this.radius=0,this.lineWidth=0}static create(e,t,r,s,i,a,n,o){var l=h.getItemByClass(Ds,ws);return l.x=e,l.y=t,l.radius=r,l._startAngle=s,l._endAngle=i,l.fillColor=a,l.lineColor=n,l.lineWidth=o,l}recover(){this.fillColor=null,this.lineColor=null,h.recover(Ds,this)}run(e,t,r){let s=this.lineWidth>=1&&this.lineColor?this.lineWidth/2:0,i=this.lineColor?this.lineWidth:0;e._drawPie(this.x+s+t,this.y+s+r,this.radius-i,this._startAngle,this._endAngle,this.fillColor,this.lineColor,this.lineWidth,0)}get cmdID(){return ws.ID}needsLayoutRepaint(){return 1}getGraphicsCommandInfo(e,t){let r=this.lineColor?this.lineWidth:0;return sr.writeScaleTessellation(e,!1,ir.calcArcSegments(this.radius-r,t,20,5))}get startAngle(){return 180*this._startAngle/Math.PI}set startAngle(e){this._startAngle=e*Math.PI/180}get endAngle(){return 180*this._endAngle/Math.PI}set endAngle(e){this._endAngle=e*Math.PI/180}getBounds(e){let t=e.points,r=Math.PI/180,s=this.endAngle-this.startAngle,i=this.x,a=this.y,n=this.radius;if(s>=360||s<=-360)return t.push(i-n,a-n),t.push(i+n,a-n),t.push(i+n,a+n),void t.push(i-n,a+n);t.push(i,a);var o=s%360;o<0&&(o+=360);var l=this.startAngle+o,h=this.startAngle*r,u=l*r;t.push(i+n*Math.cos(h),a+n*Math.sin(h)),t.push(i+n*Math.cos(u),a+n*Math.sin(u));for(var d=90*Math.ceil(this.startAngle/90),c=90*Math.floor(l/90),_=d;_<=c;_+=90){var p=_*r;t.push(i+n*Math.cos(p),a+n*Math.sin(p))}}}ws.ID=Ds,Ee.regClass(Ds,ws);const Rs="DrawPolyCmd";class Cs{static create(e,t,r,s,i,a){var n=h.getItemByClass(Rs,Cs);return n.x=e,n.y=t,n.points=r,n.fillColor=s,n.lineColor=i,n.lineWidth=a,n}recover(){this.points=null,this.fillColor=null,this.lineColor=null,h.recover(Rs,this)}run(e,t,r){let s=this.points.length<=6,i=this.lineWidth>=1&&this.lineColor?this.lineWidth%2==0?0:.5:0;this.points&&e._drawPoly(this.x+i+t,this.y+i+r,this.points,this.fillColor,this.lineColor,this.lineWidth,s,0)}getBounds(e){e.points.push(...this.points),e.flushPoints(this.x,this.y)}get cmdID(){return Cs.ID}}Cs.ID=Rs,Ee.regClass(Rs,Cs);const Ms="DrawRectCmd";class bs{constructor(){this.x=0,this.y=0,this.width=1,this.height=1,this.lineWidth=0,this.percent=!0}static create(e,t,r,s,i,a,n,o){var l=h.getItemByClass(Ms,bs);return l.x=e,l.y=t,l.width=r,l.height=s,l.fillColor=i,l.lineColor=a,l.lineWidth=n,l.percent=o,l}recover(){this.fillColor=null,this.lineColor=null,h.recover(Ms,this)}run(e,t,r){let s=this.lineWidth>=1&&this.lineColor?this.lineWidth/2:0,i=this.lineColor?this.lineWidth:0;if(this.percent&&e.sprite){let a=e.sprite.width,n=e.sprite.height;e.drawRect(this.x*a+s+t,this.y*n+s+r,this.width*a-i,this.height*n-i,this.fillColor,this.lineColor,this.lineWidth)}else e.drawRect(this.x+s+t,this.y+s+r,this.width-i,this.height-i,this.fillColor,this.lineColor,this.lineWidth)}get cmdID(){return bs.ID}needsLayoutRepaint(){return this.percent?1:0}getGraphicsCommandInfo(e){return e.dependency=this.percent?1:0,e.layoutRefresh=this.percent?null!=this.fillColor&&null==this.lineColor?1:2:0,e.scaleTessellationKey=0,e.isStateCommand=!1,e}getBounds(e){let t=te.TEMP.setTo(this.x,this.y,this.width,this.height);this.percent&&t.scale(e.width,e.height),t.getBoundPoints(e.points)}}bs.ID=Ms,Ee.regClass(Ms,bs);const As="DrawTextureCmd";class Is{constructor(){this._texture=null,this.x=0,this.y=0,this.width=1,this.height=1,this.percent=!0,this.alpha=1,this.color=4294967295,this.uv=null}static create(e,t,r,s,i,a,n,o,l,u,d){let c=h.getItemByClass(As,Is);return c.texture=e,c.x=null!=t?t:0,c.y=null!=r?r:0,c.width=null!=s?s:e.sourceWidth,c.height=null!=i?i:e.sourceHeight,c.percent=d,c.matrix=a,c.alpha=null!=n?n:1,c.blendMode=l,c.uv=u,c.color=null!=o?zr.create(o).numColor:4294967295,c}recover(){this._texture&&this._texture._removeReference(),this._texture=null,this.matrix=null,this._cacheData=null,h.recover(As,this)}get texture(){return this._texture}set texture(e){var t;e&&e._addReference(),null===(t=this._texture)||void 0===t||t._removeReference(),this._texture=e}run(e,t,r){let s=this._texture;if(!s)return;let i=this.x,a=this.y,n=this.width,o=this.height;this.percent&&e.sprite&&(i*=e.sprite.width,a*=e.sprite.height,n*=e.sprite.width,o*=e.sprite.height);let l=n/s.sourceWidth,h=o/s.sourceHeight;n=s.width*l,o=s.height*h,i+=s.offsetX*l,a+=s.offsetY*h,e.drawTextureWithTransform(this._texture,i,a,n,o,this.matrix,t,r,this.alpha,this.blendMode,this.uv,this.color)}getBounds(e){let t=te.TEMP.setTo(this.x,this.y,this.width,this.height);this.percent&&t.scale(e.width,e.height),t.getBoundPoints(e.points)}get cmdID(){return Is.ID}needsLayoutRepaint(){return this.percent?1:0}getGraphicsCommandInfo(e){return e.dependency=this.percent?1:0,e.layoutRefresh=this.percent?this.matrix?2:1:0,e.scaleTessellationKey=0,e.isStateCommand=!1,e}}Is.ID=As,Ee.regClass(As,Is);const Ps="DrawTexturesCmd";class Bs{static create(e,t,r){var s=h.getItemByClass(Ps,Bs);return s.texture=e,e._addReference(),s.pos=t,s.colors=r||[],s}recover(){this.texture._removeReference(),this.texture=null,this.pos=null,this._cacheData=null,h.recover(Ps,this)}run(e,t,r){e.drawTextures(this.texture,this.pos,t,r,this.colors)}getBounds(e){if(this.texture){let t=this.texture.width,r=this.texture.height;for(let s=0,i=this.pos.length;s<i;s+=2){let i=this.pos[s],a=this.pos[s+1];te.TEMP.setTo(i,a,t,r).getBoundPoints(e.points)}}}get cmdID(){return Bs.ID}}Bs.ID=Ps;const Ls="DrawTrianglesCmd";class Ns{constructor(){this._texture=null,this.x=0,this.y=0,this._dynamic=null,this._tempUVs=null}static create(e,t,r,s,i,a,n,o,l,u){var d,c=h.getItemByClass(Ls,Ns);return c.texture=e,c.x=t,c.y=r,c.vertices=s,c.uvs=i,c.indices=a,c.matrix=n,c.alpha=null!=o?o:1,c.color=null!=l?zr.create(l).numColor:4294967295,c.blendMode=u,c._dynamic=null===(d=null==e?void 0:e._dynamic)||void 0===d?void 0:d.uv,c}static create2(e,t,r){var s,i=h.getItemByClass(Ls,Ns);return i.texture=e,i.x=0,i.y=0,i.mesh=t,i.color=null!=r?zr.create(r).numColor:4294967295,i._dynamic=null===(s=e._dynamic)||void 0===s?void 0:s.uv,i}recover(){var e;null===(e=this._texture)||void 0===e||e._removeReference(),this._texture=null,this.vertices=null,this.uvs=null,this.indices=null,this.matrix=null,this.mesh=null,this.colors=null,this._cacheData=null,this._dynamic=null,this._tempUVs=null,h.recover(Ls,this)}get texture(){return this._texture}set texture(e){var t;e&&e._addReference(),null===(t=this._texture)||void 0===t||t._removeReference(),this._texture=e}run(e,r,s){var i;if(this.mesh){let a=qr.pool.take(this.texture);a.contentRect.setTo(0,0,e.sprite.width,e.sprite.height),this.color&&a.color.setABGR(this.color);try{this.mesh.onPopulateMesh(a)}catch(e){console.error(e)}if(null===(i=this.texture)||void 0===i?void 0:i.uvrect)if("cpu"===t.uvClipMode){const t=Zr.clipTrianglesByUVRange(a.getVertices(),a.getIndices(),a.getUVs(),this.texture.uvrect,a.getColors());Jr(e,this.texture,this.x+r,this.y+s,t.vertices,t.uvs,t.indices,this.matrix,this.alpha,this.blendMode,null,t.colors,null)}else Jr(e,this.texture,this.x+r,this.y+s,a.getVertices(),a.getUVs(),a.getIndices(),this.matrix,this.alpha,this.blendMode,null,a.getColors(),this.texture.uvrect);else Jr(e,this.texture,this.x+r,this.y+s,a.getVertices(),a.getUVs(),a.getIndices(),this.matrix,this.alpha,this.blendMode,null,a.getColors(),null);qr.pool.recover(a)}else this.vertices&&this.uvs&&this.indices&&Jr(e,this.texture,this.x+r,this.y+s,this.vertices,this.uvs,this.indices,this.matrix,this.alpha,this.blendMode,this.color,this.colors,null)}get cmdID(){return Ns.ID}getGraphicsCommandInfo(e){return e.dependency=this.mesh?1:0,e.layoutRefresh=this.mesh?2:0,e.scaleTessellationKey=0,e.isStateCommand=!1,e}getBounds(e){te.TEMP.setTo(0,0,e.width,e.height).getBoundPoints(e.points)}}Ns.ID=Ls,Ee.regClass(Ls,Ns);const Fs=new Array(256),Os=new $e,Us=[],ks=[],Gs=[],Vs={vertices:Us,indices:ks,vertexCount:0,indexCount:0};class zs{static createLine2Geometry(e,t,r){return Us.length=0,ks.length=0,this.createLine2(e,ks,t,0,Us,r)?(Vs.vertexCount=Us.length/2,Vs.indexCount=ks.length,Vs.indexCount>0&&Vs.vertexCount>0?Vs:null):null}static createLine2(e,t,r,s,i,a){if(e.length<4)return null;let n=s;var o=Fs.length>e.length+2?Fs:new Array(e.length+2);o[0]=e[0],o[1]=e[1];var l=2,h=0,u=e.length;for(h=2;h<u;h+=2)Math.abs(e[h]-e[h-2])+Math.abs(e[h+1]-e[h-1])>.01&&(o[l++]=e[h],o[l++]=e[h+1]);let d=Math.abs(e[0]-o[l-2])+Math.abs(e[1]-o[l-1]);a&&d>0&&(d>1e-13?(o[l++]=e[0],o[l++]=e[1]):(o[l-2]=e[0],o[l-1]=e[1]));var c=i;let _=c.length;u=l/2;var p=r/2;let g,m,f=o[0],T=o[1],y=o[2],x=o[3];this.getNormal(f,T,y,x,p,Os),c.push(f-Os.x,T-Os.y,f+Os.x,T+Os.y);let S=Gs;S.length=0;let E=0;for(h=1;h<u-1;h++)f=o[2*(h-1)],T=o[2*(h-1)+1],y=o[2*h],x=o[2*h+1],g=o[2*(h+1)],m=o[2*(h+1)+1],E=this._setMiddleVertexs(f,T,y,x,g,m,p,c,Os,S,E);if(f=o[l-4],T=o[l-3],y=o[l-2],x=o[l-1],y==o[0]&&x==o[1]){g=o[2],m=o[3],E=this._setMiddleVertexs(f,T,y,x,g,m,p,c,Os,S,E);let e=c.length;c[_]=c[e-4],c[_+1]=c[e-3],c[_+2]=c[e-2],c[_+3]=c[e-1],S.push(E,E+1,1,E+1,1,0)}else this.getNormal(f,T,y,x,p,Os),c.push(y-Os.x,x-Os.y,y+Os.x,x+Os.y),S.push(E,E+1,E+2,E+1,E+2,E+3);for(let e=0,r=S.length;e<r;e++){const r=S[e]+n;t.push(r)}return c}static _setMiddleVertexs(e,t,r,s,i,a,n,o,l,h,u){this.getNormal(e,t,r,s,n,l);let d=e-l.x,c=t-l.y,_=r-l.x,p=s-l.y,g=e+l.x,m=t+l.y,f=r+l.x,T=s+l.y;this.getNormal(r,s,i,a,n,l);let y=r-l.x,x=s-l.y,S=i-l.x,E=a-l.y,v=r+l.x,D=s+l.y,w=i+l.x,R=a+l.y,C=1,M=zs.checkCrossPoint(d,c,_,p,y,x,S,E,o,g,m,w,R,r,s,n);return!1===M?this._createSimpleLineVertices(e,t,r,s,i,a,o,h,u,f,T,_,p):(C=zs.checkCrossPoint(g,m,f,T,v,D,w,R,o,d,c,S,E,r,s,n),!1===C?(o.splice(o.length-2*M,2*M),this._createSimpleLineVertices(e,t,r,s,i,a,o,h,u,f,T,_,p)):(2===C?(this._setTurnPoint(o,2),h.push(u,u+1,u+3,u+1,u+3,u+2),u+=2,h.push(u,u+1,u+2),u+=1):2===M?(h.push(u,u+1,u+2,u+1,u+2,u+4),u+=2,h.push(u,u+1,u+2),u+=1):(h.push(u,u+1,u+2,u+1,u+2,u+3),u+=2),u))}static angleBetweenPoints(e,t,r,s,i,a){const n=e-r,o=t-s,l=i-r,h=a-s,u=n*l+o*h,d=Math.hypot(n,o),c=Math.hypot(l,h);if(0===d||0===c)return 0;let _=u/(d*c);return _=Math.min(1,Math.max(-1,_)),Math.acos(_)}static _createSimpleLineVertices(e,t,r,s,i,a,n,o,l,h,u,d,c){return this.angleBetweenPoints(e,t,r,s,i,a)>Math.PI/2?(n.push(d,c,h,u),o.push(l,l+1,l+2,l+1,l+2,l+3),l+=2):(n.push(h,u,d,c),o.push(l,l+1,l+3,l+1,l+3,l+2),l+=2)}static _setTurnPoint(e,t=0){let r=e[e.length-2-t],s=e[e.length-1-t],i=e[e.length-4-t],a=e[e.length-3-t];e[e.length-2-t]=i,e[e.length-1-t]=a,e[e.length-4-t]=r,e[e.length-3-t]=s}static checkCrossPoint(e,t,r,s,i,a,n,o,l,h,u,d,c,_,p,g){const m=this.getCrossPoint(e,t,r,s,i,a,n,o,!0);if(m)return l.push(m.x,m.y),1;if(!1===m)return!1;if(this.getCrossPoint(h,u,e,t,i,a,n,o,!0))return!1;if(this.getCrossPoint(e,t,r,s,n,o,d,c,!0))return!1;const f=this.getCrossPoint(e,t,r,s,i,a,n,o);if(f){return Math.abs(this.getDistance(_,p,f.x,f.y))>1.5*g?(l.push(r,s),l.push(i,a),2):(l.push(f.x,f.y),1)}return!1}static getCrossPoint(e,t,r,s,i,a,n,o,l=!1){const h=r-e,u=s-t,d=n-i,c=o-a,_=h*c-d*u;if(Math.abs(_)<1e-10)return!1;const p=((i-e)*c-(a-t)*d)/_,g=((i-e)*u-(a-t)*h)/_;if(l){if(p<0||p>1)return null;if(g<0||g>1)return null}return{x:e+p*h,y:t+p*u}}static getDistance(e,t,r,s){return Math.sqrt((e-r)*(e-r)+(t-s)*(t-s))}static getNormal(e,t,r,s,i,a){a||(a=new $e);let n=s-t,o=e-r,l=Math.sqrt(n*n+o*o);return a.x=n/l*i,a.y=o/l*i,a}static createLineTriangle(e,t,r,s,i,a,n){var o=e.slice(),l=o.length,h=o[0],u=o[1],d=o[2],c=(o[2],0),_=0,p=0,g=0,m=l/2;if(!(m<=1)&&2!=m){for(var f=new Array(4*m),T=0,y=0,x=0;x<m-1;x++)h=o[y++],u=o[y++],d=o[y++],g=o[y++]-u,0!=(p=d-h)&&0!=g&&(c=Math.sqrt(p*p+g*g))>.001&&(f[_=4*T]=h,f[_+1]=u,f[_+2]=p/c,f[_+3]=g/c,T++);for(s?(h=o[l-2],u=o[l-1],d=o[0],g=o[1]-u,0!=(p=d-h)&&0!=g&&(c=Math.sqrt(p*p+g*g))>.001&&(f[_=4*T]=h,f[_+1]=u,f[_+2]=p/c,f[_+3]=g/c,T++)):(f[_=4*T]=h,f[_+1]=u,f[_+2]=p/c,f[_+3]=g/c,T++),y=0,x=0;x<m;x++)h=o[y],u=o[y+1],d=o[y+2],o[y+3]}}}class Hs extends z{constructor(e,t,r,s,i,a=!1,n=1,o=!1){super(e,t,s,i,a,n,!1,o),this.layerIndex=0,this.depth=r,this._createRenderTarget()}_createRenderTarget(){null!=this.depth&&(this._dimension=e.TextureDimension.Texture2DArray,this._renderTarget=f.textureContext.createRenderTargetArrayInternal(this.width,this.height,this.depth,this._format,this._depthStencilFormat,this._generateMipmap,this._gammaSpace,this._multiSamples),this._generateMipmap=this._renderTarget._generateMipmap,this._texture=this._renderTarget._textures[0])}bindLayer(e){this.layerIndex=e,f.textureContext.bindRenderTarget(this._renderTarget,e)}}class Ws{static clear(){this._idToRecord.clear(),this._groupKeyToArray.forEach(e=>{e.sharedRT.lock=!1,e.sharedRT.destroy()}),this._groupKeyToArray.clear()}static register(e,t){const r=this._getTexId(e);if(null==r)return;const s=t,i=this._idToRecord.get(r);i!==s&&(i&&this.unregister(e),this._idToRecord.set(r,s),s.refs++)}static unregister(e){const t=this._getTexId(e);if(null==t)return;const r=this._idToRecord.get(t);r&&(this._idToRecord.delete(t),r.refs--,r.refs<=0&&this._releaseRecord(r))}static resolve(e){const t=this._getTexId(e);return null==t?null:this._idToRecord.get(t)||null}static allocateLayerAsTexture(t,r,s=e.TextureFormat.R8G8B8A8,i=64,a=!1,n=e.RenderTargetFormat.None,o=!1){const l=`${t}x${r}_${s}_${n}_${o?1:0}_${a?1:0}`;let h,u=this._groupKeyToArray.get(l);if(!u){const e=new Hs(t,r,i,s,n,o,1,a);e.lock=!0,u={sharedRT:e,nextLayer:0,capacity:i,freeLayers:[],usedLayers:new Set},this._groupKeyToArray.set(l,u)}if(u.freeLayers.length>0)h=u.freeLayers.pop();else{if(u.nextLayer>=u.capacity)return null;h=u.nextLayer++}u.usedLayers.add(h);const d=new ie(u.sharedRT),c={array:u.sharedRT,sharedRT:u.sharedRT,layer:h,texture:d,uploadSubPixels:(e,t,r,s,i,a=0)=>{f.textureContext.setTexture3DSubPixelsData(u.sharedRT._texture,i,a,!1,e,t,h,r,s,1,!1,!1)},release:()=>this._releaseRecord(c),groupKey:l,refs:0,released:!1};return c}static _getTexId(e){var t;if(!e)return null;if(e instanceof ie){const r=e.bitmap;return null!==(t=null==r?void 0:r._id)&&void 0!==t?t:null}return"number"==typeof e.id?e.id:null}static _releaseRecord(e){if(e.released)return;e.released=!0,this._idToRecord.forEach((t,r)=>{t===e&&this._idToRecord.delete(r)}),e.refs=0,e.texture.destroy();const t=this._groupKeyToArray.get(e.groupKey);t&&(t.usedLayers.delete(e.layer),0===t.usedLayers.size?(this._groupKeyToArray.delete(e.groupKey),t.sharedRT.lock=!1,t.sharedRT.destroy()):t.freeLayers.push(e.layer))}}Ws._idToRecord=new Map,Ws._groupKeyToArray=new Map;const Xs="DrawEllipseCmd";class Ys{constructor(){this.lineWidth=0}static create(e,t,r,s,i,a,n,o){var l=h.getItemByClass(Xs,Ys);return l.x=e,l.y=t,l.width=r,l.height=s,l.fillColor=i,l.lineColor=a,l.lineWidth=n,l.percent=o,l}recover(){this.fillColor=null,this.lineColor=null,h.recover(Xs,this)}run(e,t,r){let s=this.lineWidth>=1&&this.lineColor?this.lineWidth/2:0;if(this.percent&&e.sprite){let i=e.sprite.width,a=e.sprite.height;e._drawEllipse(this.x*i+t,this.y*a+r,this.width*i-s,this.height*a-s,this.fillColor,this.lineColor,this.lineWidth)}else e._drawEllipse(this.x+t,this.y+r,this.width-s,this.height-s,this.fillColor,this.lineColor,this.lineWidth)}get cmdID(){return Ys.ID}needsLayoutRepaint(){return 1}getGraphicsCommandInfo(e,t){let r=this.lineWidth>=1&&this.lineColor?this.lineWidth/2:0,s=this.percent?this.width*ir.getOwnerWidth(t)-r:this.width-r;return sr.writeScaleTessellation(e,this.percent,ir.calcArcSegments(s,t,40,5))}getBounds(e){let t=te.TEMP.setTo(this.x-this.width,this.y-this.height,2*this.width,2*this.height);this.percent&&t.scale(e.width,e.height),t.getBoundPoints(e.points)}}Ys.ID=Xs,Ee.regClass(Xs,Ys);const qs="DrawRoundRectCmd";class $s{constructor(){this.x=0,this.y=0,this.width=1,this.height=1,this.lt=6,this.rt=6,this.lb=6,this.rb=6,this.lineWidth=0,this.percent=!0,this.minNum=20,this.segPixel=5}static create(e,t,r,s,i,a,n,o,l,u,d,c,_,p){var g=h.getItemByClass(qs,$s);return g.x=e,g.y=t,g.width=r,g.height=s,g.lt=i,g.rt=a,g.lb=n,g.rb=o,g.fillColor=l,g.lineColor=u,g.lineWidth=d,g.percent=c,null!=_&&(g.minNum=_),null!=p&&(g.segPixel=p),g}recover(){this.fillColor=null,this.lineColor=null,this.minNum=20,this.segPixel=5,h.recover(qs,this)}run(e,t,r){let s=this.lineWidth>=1&&this.lineColor?this.lineWidth/2:0,i=this.lineColor?this.lineWidth:0;if(this.percent&&e.sprite){let a=e.sprite.width,n=e.sprite.height;e._drawRoundRect(this.x*a+s+t,this.y*n+s+r,this.width*a-i,this.height*n-i,this.lt,this.rt,this.lb,this.rb,this.fillColor,this.lineColor,this.lineWidth,this.minNum,this.segPixel)}else e._drawRoundRect(this.x+s+t,this.y+s+r,this.width-i,this.height-i,this.lt,this.rt,this.lb,this.rb,this.fillColor,this.lineColor,this.lineWidth,this.minNum,this.segPixel)}get cmdID(){return $s.ID}needsLayoutRepaint(){return 1}getGraphicsCommandInfo(e,t){let r=Math.max(this.lt||0,0),s=Math.max(this.rt||0,0),i=Math.max(this.lb||0,0),a=Math.max(this.rb||0,0);return sr.writeScaleTessellation(e,this.percent,ir.combineRoundRectSegments(r,s,i,a,t,this.minNum||20,this.segPixel||5))}getBounds(e){let t=te.TEMP.setTo(this.x,this.y,this.width,this.height);this.percent&&t.scale(e.width,e.height),t.getBoundPoints(e.points)}}$s.ID=qs,Ee.regClass(qs,$s);const Ks="FillTextureCmd";class js{constructor(){this._texture=null,this.x=0,this.y=0,this.width=1,this.height=1,this.type="repeat",this.percent=!0,this.color=4294967295}static create(e,t,r,s,i,a,n,o,l){null==s&&(s=e.width),null==i&&(i=e.height);var u=h.getItemByClass(Ks,js);return u.texture=e,u.x=t,u.y=r,u.width=s,u.height=i,u.type=a,u.offset=n,u.color=null!=o?zr.create(o).numColor:4294967295,u.percent=l,u}recover(){this._texture&&this._texture._removeReference(),this._texture=null,this.offset=null,h.recover(Ks,this)}get texture(){return this._texture}set texture(e){var t;e&&e._addReference(),null===(t=this._texture)||void 0===t||t._removeReference(),this._texture=e}run(e,t,r){if(this.texture)if(this.percent&&e.sprite){let s=e.sprite.width,i=e.sprite.height;e.fillTexture(this.texture,this.x*s+t,this.y*i+r,this.width*s,this.height*i,this.type,this.offset||d.EMPTY,this.color)}else e.fillTexture(this.texture,this.x+t,this.y+r,this.width,this.height,this.type,this.offset||d.EMPTY,this.color)}getBounds(e){let t=te.TEMP.setTo(this.x,this.y,this.width,this.height);this.percent&&t.scale(e.width,e.height),t.getBoundPoints(e.points)}get cmdID(){return js.ID}needsLayoutRepaint(){return this.percent?1:0}getGraphicsCommandInfo(e){return e.dependency=this.percent?1:0,e.layoutRefresh=this.percent?this._canRefreshPercentLocally()?1:2:0,e.scaleTessellationKey=0,e.isStateCommand=!1,e}_canRefreshPercentLocally(){return"repeat"===this.type||"repeat-x"===this.type||"repeat-y"===this.type||"no-repeat"===this.type}}var Qs;js.ID=Ks,Ee.regClass(Ks,js),e.GraphicsOwnerTransformDependency=void 0,(Qs=e.GraphicsOwnerTransformDependency||(e.GraphicsOwnerTransformDependency={}))[Qs.None=0]="None",Qs[Qs.SizeLayout=1]="SizeLayout",Qs[Qs.ScaleTessellation=2]="ScaleTessellation",Qs[Qs.SpriteTextureSize=4]="SpriteTextureSize";const Zs=Yr.stride||16,Js=4*Zs,ei=Yr.GRAPHICS_MAX_VERTEX,ti=[0,0,1,1],ri=[0,0,1,1],si=new Array(12),ii=new Array(8),ai=new Array(8),ni=[0,2,1,0,3,2],oi=[0,1,2],li=new Ce,hi=[],ui=[],di=[],ci=[],_i=[],pi=new Array(16),gi=new Array(8),mi=new Array(8),fi=new te,Ti=[0,0,0,0,0],yi=2*Math.PI,xi={dependency:0,layoutRefresh:0,scaleTessellationKey:0,isStateCommand:!1};class Si{constructor(){this._curMat=new Ce,this._matrixChanged=!1,this.sprite=null,this._textRender=null,this._alpha=1,this._blendMode=e.BlendMode.normal,this._saveFrames=null,this._saveDepth=0,this._saveCapacity=0,this._mode=null,this._resolvedTextureSource=null,this._resolvedTextureResource=null,this._resolvedTextureLayer=0,this._ownerDependencyMask=e.GraphicsOwnerTransformDependency.None,this._textTextureSink=(e,t,r,s,i,a,n,o,l)=>this._appendTextTexture(e,t,r,s,i,a,n,o,l)}begin(t,r,s,i){this._mode=t,this.sprite=r,this._textRender=i,this._curMat.identity(),this._matrixChanged=!1,this._alpha=1,this._blendMode=null==s?e.BlendMode.normal:s,this._saveDepth=0,this._ownerDependencyMask=e.GraphicsOwnerTransformDependency.None}end(){this._mode.endCompile(),this._clearResolvedTexture(),this._mode=null,this.sprite=null,this._textRender=null,this._saveDepth=0}_loadState(e,t){let r=this._curMat;r.setTo(e[t],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5]),r._checkTransform(),this._matrixChanged=1!==r.a||0!==r.b||0!==r.c||1!==r.d||0!==r.tx||0!==r.ty,this._alpha=e[t+6],this._blendMode=e[t+7],this._saveDepth=0}alpha(e){this.globalAlpha*=e}compileCommand(t,r,s=null){if(!r)return;let i=this._mode,a=r._cacheData;if(s&&a&&"FrameAnimation"===a.kind)return this._loadState(a.state,0),i.beginCommand(t,r.cmdID,s),i._beginActiveCommandTextures(),this._clearResolvedTexture(),r.run(this,0,0),i.finalizeActiveCommandTextures(),void i.endCommand();switch(r.cmdID){case"AlphaCmd":case"ClipRectCmd":case"RestoreCmd":case"RotateCmd":case"SaveCmd":case"ScaleCmd":case"TransformCmd":case"TranslateCmd":return void r.run(this,0,0)}let n=xi;if(n.dependency=0,n.layoutRefresh=0,n.scaleTessellationKey=0,n.isStateCommand=!1,r.getGraphicsCommandInfo?r.getGraphicsCommandInfo(n,this.sprite):r.needsLayoutRepaint&&r.needsLayoutRepaint()>0&&(n.dependency=3),1&n.dependency&&(this._ownerDependencyMask|=e.GraphicsOwnerTransformDependency.SizeLayout),2&n.dependency&&(this._ownerDependencyMask|=e.GraphicsOwnerTransformDependency.ScaleTessellation),n.isStateCommand)return void r.run(this,0,0);a&&"FrameAnimation"===a.kind&&this._writeState(a.state,0);let o=i.opCount;switch(i.beginCommand(t,r.cmdID,s),i._beginActiveCommandTextures(),this._clearResolvedTexture(),r.cmdID){case wa.ID:r.emitTextureQuads(this,0,0,this._textTextureSink);break;case ts.ID:this._draw9GridTexture(r);break;case bs.ID:case Bs.ID:case js.ID:case Is.ID:case fs.ID:case ys.ID:case Ss.ID:case is.ID:case Ys.ID:case ws.ID:case Cs.ID:case $s.ID:case gs.ID:case vs.ID:case Ns.ID:r.run(this,0,0)}if(i.finalizeActiveCommandTextures(),i.endCommand(),a&&"FrameAnimation"===a.kind&&!s){let e=i.opCount-o;a.commandIndex=t,a.opStart=o,a.opCount=e,a.op=1===e&&1===i.getOp(o).kind?i.getOp(o):null}}getOwnerDependencyMask(){return this._ownerDependencyMask}drawTexture(e,t,r,s,i,a=4294967295){this._appendTextureQuad(e,t,r,s,i,null,a,1,null)}drawTextureWithTransform(e,t,r,s,i,a,n,o,l,h,u,d=4294967295){if(!a)return void this._appendTextureQuad(e,t+n,r+o,s,i,u,d,l,h);if(!this._mode._prepareTexture(e)||s<=0||i<=0)return;u=u||e._uv||e.uv||ie.DEF_UV;let c=li;c.setTo(a.a,a.b,a.c,a.d,a.tx+n,a.ty+o),Ce.mul(c,this._curMat,c),ir.writeTextureQuad(ii,ai,s,i,u);let _=this._resolveTextureResource(e);this._writeMesh(t,r,ii,ai,ni,null,_,this._resolvedTextureLayer,d,this._opAlpha(l),this._opBlend(h),c,ar.getUVClipRange(e))}drawTextures(e,t,r,s,i){let a=this._mode;if(!t||t.length<2||!a._prepareTexture(e)||e.width<=0||e.height<=0)return;let n=e._uv||e.uv||ie.DEF_UV,o=this._resolveTextureResource(e),l=this._matrixState();for(let a=0,h=0,u=t.length>>1;a<u;a++,h+=2)this._writeTextureQuad(t[h]+r,t[h+1]+s,e.width,e.height,n[0],n[1],null==n[4]?n[2]:n[4],null==n[5]?n[3]:n[5],i&&"number"==typeof i[a]?i[a]:4294967295,this._opAlpha(1),this._opBlend(),this._resolvedTextureLayer,l,o,ar.getUVClipRange(e))}drawRect(e,t,r,s,i,a,n){r<=0||s<=0||(null!=i&&this._writeSolidQuad(e,t,r,s,this._toABGR(i),this._opAlpha(1),this._opBlend(),this._matrixState()),null!=a&&n>0&&(hi.length=0,hi.push(e,t,e+r,t,e+r,t+s,e,t+s),this._appendLineMesh(hi,n,!0,this._toABGR(a))))}fillTexture(e,t,r,s,i,a,n,o){if(!this._mode._prepareTexture(e))return;let l=e.sourceWidth||e.width||1,h=e.sourceHeight||e.height||1,u=si;if(!ir.writeFillTextureGeometry(u,t,r,s,i,l,h,a,n?n.x:0,n?n.y:0))return;let d=this._resolveTextureResource(e),c=ar.writeUVRange(e,ti),_=ar.writeTrimRange(e,ri);this._writeFillTexture(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],c[0],c[1],c[2],c[3],o,this._opAlpha(1),this._opBlend(),this._resolvedTextureLayer,this._matrixState(),d,_)}_drawLine(e,t,r,s,i,a,n,o,l){null==n||o<=0||(hi.length=0,hi.push(r+e,s+t,i+e,a+t),this._appendLineMesh(hi,o,!1,this._toABGR(n)))}_drawLines(e,t,r,s,i,a){!r||r.length<4||null==s||i<=0||(ir.copyOffsetPoints(hi,r,e,t),this._appendLineMesh(hi,i,!1,this._toABGR(s)))}_drawCircle(e,t,r,s,i,a,n){if(r<=0)return;let o=ir.calcArcSegmentsWithScale(r,this._tessellationScale(),40,5);ir.makeCirclePath(hi,e,t,r,o),null!=s&&(ir.writeCircleFan(ui,di,e,t,r,o),this._writeColorMesh(ui,di,this._toABGR(s))),null!=i&&a>0&&this._appendLineMesh(hi,a,!0,this._toABGR(i))}_drawEllipse(e,t,r,s,i,a,n){if(r<=0||s<=0)return;let o=ir.calcArcSegmentsWithScale(r,this._tessellationScale(),40,5);ir.makeEllipsePath(hi,e,t,r,s,o),this._appendPathFillAndStroke(hi,i,a,n,!0)}_drawPie(e,t,r,s,i,a,n,o,l){if(r<=0)return;if(s>i){let e=s;s=i,i=e}i-s>yi&&(i=s+yi);let h=ir.calcArcSegmentsWithScale(r,this._tessellationScale(),20,5);ir.makePiePath(hi,e,t,r,s,i,h),this._appendPathFillAndStroke(hi,a,n,o,!0)}_drawPoly(e,t,r,s,i,a,n,o){!r||r.length<6||(ir.copyOffsetPoints(hi,r,e,t),this._appendPathFillAndStroke(hi,s,i,a,!0))}_drawRoundRect(e,t,r,s,i,a,n,o,l,h,u,d=20,c=5){r<=0||s<=0||(ir.makeRoundRectPath(hi,e,t,r,s,i,a,o,n,d||20,c||5,this._tessellationScale()),this._appendPathFillAndStroke(hi,l,h,u,!0))}drawCurves(e,t,r,s,i){!r||r.length<6||null==s||i<=0||(hi.length=0,as.getPoints(r,30,2,hi),hi.length<4||(ir.offsetPoints(hi,e,t),this._appendLineMesh(hi,i,!1,this._toABGR(s))))}_drawPath(e,t,r,s,i){let a=ir.collectDrawPathSubpaths(r,e,t,ci,_i);if(0===a)return;let n=s?s.fillStyle:null,o=i?i.strokeStyle:null,l=i&&null!=i.lineWidth?i.lineWidth:1;for(let e=0;e<a;e++)this._appendPathFillAndStroke(ci[e],n,o,l,_i[e])}drawTriangles(e,t,r,s,i,a,n,o,l,h,u,d){if(!s||!i||!a||s.length<2||a.length<=0)return;let c=this._mode,_=null,p=0;if(e){if(e instanceof ie){if(!c._prepareTexture(e))return;_=this._resolveTextureResource(e)}else{if(e.destroyed)return;_=this._resolveBaseTextureResource(e)}p=this._resolvedTextureLayer}this._writeMesh(t,r,s,i,a,u,_,p,null==h?4294967295:h,this._opAlpha(null==o?1:o),this._opBlend(l),ir.combineMatrix(li,n,this._curMat),d)}_appendTextureQuad(e,t,r,s,i,a,n,o,l){if(!this._mode._prepareTexture(e))return!1;a=a||e._uv||e.uv||ie.DEF_UV;let h=this._resolveTextureResource(e);return this._writeTextureQuad(t,r,s,i,a[0],a[1],null==a[4]?a[2]:a[4],null==a[5]?a[3]:a[5],n,this._opAlpha(o),this._opBlend(l),this._resolvedTextureLayer,this._matrixState(),h,ar.getUVClipRange(e)),!0}_appendTextTexture(e,t,r,s,i,a,n,o,l){if(!e||e.destroyed)return;this._mode;let h=this._resolveBaseTextureResource(e);a=a||ie.DEF_UV;let u=this._matrixState();if(!o&&l&&(!u||!u._bTransform)){let e=u?u.tx:0,a=u?u.ty:0,n=Math.round(t+s+e),o=Math.round(r+i+a);s=n-(t=Math.round(t+e)),i=o-(r=Math.round(r+a)),u=null}o||l&&u&&u._bTransform?(ir.writeTextQuad(gi,mi,t,r,s,i,a,o||0,l,this._curMat,this._matrixChanged),this._writeMesh(0,0,gi,mi,ni,null,h,this._resolvedTextureLayer,n,this._opAlpha(1),this._opBlend(),null,null)):this._writeTextureQuad(t,r,s,i,a[0],a[1],null==a[4]?a[2]:a[4],null==a[5]?a[3]:a[5],n,this._opAlpha(1),this._opBlend(),this._resolvedTextureLayer,u,h,null)}_draw9GridTexture(e){let r=e.texture;if(!this._mode._prepareTexture(r))return;let s=e.x,i=e.y,a=e.width,n=e.height;if(e.percent&&this.sprite&&(s*=this.sprite.width,i*=this.sprite.height,a*=this.sprite.width,n*=this.sprite.height),a<=0||n<=0)return;let o=e.sizeGrid||r._sizeGrid||Ti,l=this._resolveTextureResource(r);if(1===o[4]||r.uvrect&&"cpu"===t.uvClipMode)return void this._draw9GridMesh(e,s,i,a,n,o,l);let h=r.sourceWidth||r.width||1,u=r.sourceHeight||r.height||1,d=pi;ir.writeNineGridAxes(d,s,i,a,n,h,u,o);let c=r._uv||r.uv||ie.DEF_UV,_=c[0],p=c[1],g=null==c[4]?c[2]:c[4],m=null==c[5]?c[3]:c[5],f=this._resolvedTextureLayer,T=this._matrixState(),y=ar.getUVClipRange(r);for(let t=0;t<3;t++){let r=d[t+5]-d[t+4];if(!(r<=0))for(let s=0;s<3;s++){let i=d[s+1]-d[s];i<=0||this._writeTextureQuad(d[s],d[t+4],i,r,_+(g-_)*d[s+8]/h,p+(m-p)*d[t+12]/u,_+(g-_)*d[s+9]/h,p+(m-p)*d[t+13]/u,e.color,this._opAlpha(1),this._opBlend(),f,T,l,y)}}}_draw9GridMesh(e,r,s,i,a,n,o){let l=qr.pool.take(e.texture);l.contentRect.setTo(0,0,i,a),e.color&&l.color.setABGR(e.color);let h=l.mainTex.sourceWidth,u=l.mainTex.sourceHeight;fi.setTo(n[3],n[0],h-n[1]-n[3],u-n[0]-n[2]),Or(l,l.contentRect,l.uvRect,fi,1===n[4]?255:0);let d=l.getVertices(),c=l.getUVs(),_=l.getIndices(),p=l.getColors(),g=ar.getUVClipRange(e.texture);if(e.texture.uvrect&&"cpu"===t.uvClipMode){let t=Zr.clipTrianglesByUVRange(d,_,c,e.texture.uvrect,p);d=t.vertices,c=t.uvs,_=t.indices,p=t.colors,g=null}this._writeMesh(r,s,d,c,_,p,o,this._resolvedTextureLayer,e.color,this._opAlpha(1),this._opBlend(),this._matrixState(),g),qr.pool.recover(l)}_writeSpriteTextureOp(e,t,r){if(!e||!t||!r)return!1;this._clearResolvedTexture();let s=r.sourceWidth||r.width,i=r.sourceHeight||r.height,a=(t._isWidthSet?t._width:s)/(s||1),n=(t._isHeightSet?t._height:i)/(i||1),o=r._uv||r.uv||ie.DEF_UV,l=this._resolveTextureResource(r);return e.texture=l||null,e.writeRecord(r.offsetX*a,r.offsetY*n,r.width*a,r.height*n,o[0],o[1],null==o[4]?o[2]:o[4],null==o[5]?o[3]:o[5],4294967295,1,t._struct.blendMode,this._resolvedTextureLayer,null,ar.getUVClipRange(r)),!0}_resolveTextureResource(e){return this._resolveBaseTextureResource(e.bitmap)}_resolveBaseTextureResource(e){if(e===this._resolvedTextureSource)return this._resolvedTextureResource;let t=e,r=0,s=Ws.resolve(e);return s&&(t=s.array,r=0|s.layer),this._resolvedTextureSource=e,this._resolvedTextureResource=t,this._resolvedTextureLayer=r,t}_clearResolvedTexture(){this._resolvedTextureSource=null,this._resolvedTextureResource=null,this._resolvedTextureLayer=0}_writeTextureQuad(e,t,r,s,i,a,n,o,l,h,u,d,c,_,p=null){let g=this._mode,m=g.getTextureQuadTargetOp();if(5===m.kind||6===m.kind){let f=m;g._recordActiveMultiQuadTexture(f,_),f.addRecord(e,t,r,s,i,a,n,o,l,h,u,d||0,c,p)}else{let g=m;g.texture=_||null,g.writeRecord(e,t,r,s,i,a,n,o,l,h,u,d||0,c,p)}g._markTextureQuadWritten()}_writeSolidQuad(e,t,r,s,i,a,n,o){this._mode._appendOp(2).writeRecord(e,t,r,s,i,a,n,o)}_writeFillTexture(e,t,r,s,i,a,n,o,l,h,u,d,c,_,p,g,m,f,T,y,x,S,E){let v=this._mode._appendOp(3);v.texture=S||null,v.writeRecord(e,t,r,s,i,a,n,o,l,h,u,d,c,_,p,g,m,f,T,y||0,x,E)}_writeMesh(e,t,r,s,i,a,n,o,l,h,u,d,c=null,_=0,p=(r?r.length-_>>1:0),g=0,m=0,f=(i?i.length-m:0),T=0){if(!r||!i)return;let y=this._mode._appendOp(4);y.texture=n||null,y.writeMesh(e,t,r,_,p,s,g,i,m,f,a,T,l,h,u,o||0,d,c)}_appendLineMesh(e,t,r,s){if(!e||e.length<4||t<=0)return!1;let i=zs.createLine2Geometry(e,t,r);return!(!i||i.vertexCount<=0||i.indexCount<=0)&&(this._writeMesh(0,0,i.vertices,null,i.indices,null,null,0,s,this._opAlpha(1),this._opBlend(),this._matrixState(),null,0,i.vertexCount,0,0,i.indexCount),!0)}_appendPathFillAndStroke(e,t,r,s,i){let a=!1;if(null!=t){let r=Kr.earcut(e,null,2);r&&0!==r.length||6!==e.length||(r=oi),r&&r.length>0&&(this._writeColorMesh(e,r,this._toABGR(t)),a=!0)}return null!=r&&s>0&&(a=this._appendLineMesh(e,s,i,this._toABGR(r))||a),a}_writeColorMesh(e,t,r){this._writeMesh(0,0,e,null,t,null,null,0,r,this._opAlpha(1),this._opBlend(),this._matrixState())}_tessellationScale(){return Math.max(this.getCurrentScaleX(),this.getCurrentScaleY())}_matrixState(){let e=this._curMat;return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.tx&&0===e.ty?null:e}_opAlpha(e){return this.globalAlpha*(null==e?1:e)}_opBlend(t=null){let r=null==t?this.globalCompositeOperation:t;return"string"==typeof r?nr.parseBlendMode(r):null==r?e.BlendMode.normal:r}_toABGR(e){return"number"==typeof e?e:null!=e?zr.create(e).numColor:4294967295}get globalAlpha(){return this._alpha}set globalAlpha(e){this._alpha=Math.floor(1e3*e)/1e3}get globalCompositeOperation(){return this._blendMode}set globalCompositeOperation(e){null!=e&&(this._blendMode=e)}save(){this._ensureSaveCapacity(this._saveDepth+1);let e=8*this._saveDepth,t=this._curMat,r=this._saveFrames;r[e]=t.a,r[e+1]=t.b,r[e+2]=t.c,r[e+3]=t.d,r[e+4]=t.tx,r[e+5]=t.ty,r[e+6]=this._alpha,r[e+7]=this._blendMode,this._saveDepth++}restore(){if(this._saveDepth<=0)return;let e=8*--this._saveDepth,t=this._saveFrames;this._curMat.setTo(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]),this._curMat._checkTransform();let r=this._curMat;this._matrixChanged=1!==r.a||0!==r.b||0!==r.c||1!==r.d||0!==r.tx||0!==r.ty,this._alpha=t[e+6],this._blendMode=t[e+7]}translate(e,t){if(0===e&&0===t)return;let r=this._curMat;r._bTransform?(r.tx+=e*r.a+t*r.c,r.ty+=e*r.b+t*r.d):(r.tx=e,r.ty=t),this._matrixChanged=!0}transform(e,t,r,s,i,a){Ce.mul(Ce.TEMP.setTo(e,t,r,s,i,a),this._curMat,this._curMat),this._curMat._checkTransform(),this._matrixChanged=!0}rotate(e){this._curMat.rotateEx(e),this._matrixChanged=!0}scale(e,t){this._curMat.scaleEx(e,t),this._matrixChanged=!0}_transform(e,t,r){this.translate(t,r),this.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),this.translate(-t,-r)}_rotate(e,t,r){this.translate(t,r),this.rotate(e),this.translate(-t,-r)}_scale(e,t,r,s){this.translate(r,s),this.scale(e,t),this.translate(-r,-s)}getCurrentScaleX(){let e=this._curMat.getScaleX();if(this.sprite&&this.sprite.globalTrans){let t=this.sprite.globalTrans.getMatrix();e*=Math.hypot(t.a,t.b)}return Math.abs(e)}getCurrentScaleY(){let e=this._curMat.getScaleY();if(this.sprite&&this.sprite.globalTrans){let t=this.sprite.globalTrans.getMatrix();e*=Math.hypot(t.c,t.d)}return Math.abs(e)}_writeState(e,t){let r=this._curMat;e[t]=r.a,e[t+1]=r.b,e[t+2]=r.c,e[t+3]=r.d,e[t+4]=r.tx,e[t+5]=r.ty,e[t+6]=this._alpha,e[t+7]=this._blendMode}_ensureSaveCapacity(e){if(e<=this._saveCapacity)return;let t=Math.max(4,this._saveCapacity||0);for(;t<e;)t<<=1;let r=new Float64Array(8*t);this._saveFrames&&r.set(this._saveFrames),this._saveFrames=r,this._saveCapacity=t}}class Ei{static getSystemEndian(){if(!Ei._sysEndian){let e=new ArrayBuffer(2);new DataView(e).setInt16(0,256,!0),Ei._sysEndian=256===new Int16Array(e)[0]?Ei.LITTLE_ENDIAN:Ei.BIG_ENDIAN}return Ei._sysEndian}constructor(e){this._xd_=!0,this._allocated_=8,this._pos_=0,this._length=0,e?(this._u8d_=new Uint8Array(e),this._d_=new DataView(this._u8d_.buffer),this._length=this._d_.byteLength):this._resizeBuffer(this._allocated_)}get buffer(){let e=this._d_.buffer;return e.byteLength===this._length?e:e.slice(0,this._length)}get rawBuffer(){return this._d_.buffer}get endian(){return this._xd_?Ei.LITTLE_ENDIAN:Ei.BIG_ENDIAN}set endian(e){this._xd_=e===Ei.LITTLE_ENDIAN}set length(e){this._allocated_<e?this._resizeBuffer(this._allocated_=Math.floor(Math.max(e,2*this._allocated_))):this._allocated_>e&&this._resizeBuffer(this._allocated_=e),this._length=e}get length(){return this._length}_resizeBuffer(e){try{let t=new Uint8Array(e);null!=this._u8d_&&(this._u8d_.length<=e?t.set(this._u8d_):t.set(this._u8d_.subarray(0,e))),this._u8d_=t,this._d_=new DataView(t.buffer)}catch(t){throw new Error("Invalid typed array length:"+e)}}readString(){return this._rUTF(this.readUint16())}readTypedArray(e,t,r){let s=e+t;s=s>this._length?this._length:s;let i=new r(this._d_.buffer.slice(e,s));return this._pos_=s,i}readFloat32Array(e,t){return this.readTypedArray(e,t,Float32Array)}readUint8Array(e,t){return this.readTypedArray(e,t,Uint8Array)}readInt8Array(e,t){return this.readTypedArray(e,t,Int8Array)}readInt16Array(e,t){return this.readTypedArray(e,t,Int16Array)}readFloat32(){if(this._pos_+4>this._length)throw new M(this._pos_+4);var e=this._d_.getFloat32(this._pos_,this._xd_);return this._pos_+=4,e}readFloat64(){if(this._pos_+8>this._length)throw new M(this._pos_+8);var e=this._d_.getFloat64(this._pos_,this._xd_);return this._pos_+=8,e}writeFloat32(e){this._ensureWrite(this._pos_+4),this._d_.setFloat32(this._pos_,e,this._xd_),this._pos_+=4}writeFloat64(e){this._ensureWrite(this._pos_+8),this._d_.setFloat64(this._pos_,e,this._xd_),this._pos_+=8}readInt32(){if(this._pos_+4>this._length)throw new M(this._pos_+4);var e=this._d_.getInt32(this._pos_,this._xd_);return this._pos_+=4,e}readUint32(){if(this._pos_+4>this._length)throw new M(this._pos_+4);var e=this._d_.getUint32(this._pos_,this._xd_);return this._pos_+=4,e}writeInt32(e){this._ensureWrite(this._pos_+4),this._d_.setInt32(this._pos_,e,this._xd_),this._pos_+=4}writeUint32(e){this._ensureWrite(this._pos_+4),this._d_.setUint32(this._pos_,e,this._xd_),this._pos_+=4}readInt16(){if(this._pos_+2>this._length)throw new M(this._pos_+2);var e=this._d_.getInt16(this._pos_,this._xd_);return this._pos_+=2,e}readUint16(){if(this._pos_+2>this._length)throw new M(this._pos_+2);var e=this._d_.getUint16(this._pos_,this._xd_);return this._pos_+=2,e}writeUint16(e){this._ensureWrite(this._pos_+2),this._d_.setUint16(this._pos_,e,this._xd_),this._pos_+=2}writeInt16(e){this._ensureWrite(this._pos_+2),this._d_.setInt16(this._pos_,e,this._xd_),this._pos_+=2}readUint8(){if(this._pos_+1>this._length)throw new M(this._pos_+1);return this._u8d_[this._pos_++]}writeUint8(e){this._ensureWrite(this._pos_+1),this._d_.setUint8(this._pos_,e),this._pos_++}_getMatrix(){return this._readMatrix()}_readMatrix(){return new Ce(this.readFloat32(),this.readFloat32(),this.readFloat32(),this.readFloat32(),this.readFloat32(),this.readFloat32())}_rUTF(e){const t=this._pos_+e,r=this._u8d_,s=[],i=[];let a,n,o;for(;this._pos_<t;){if(a=r[this._pos_++],a<128)0!=a&&s.push(a);else if(a<224)s.push((63&a)<<6|127&r[this._pos_++]);else if(a<240)n=r[this._pos_++],s.push((31&a)<<12|(127&n)<<6|127&r[this._pos_++]);else{n=r[this._pos_++],o=r[this._pos_++];const e=(15&a)<<18|(127&n)<<12|(127&o)<<6|127&r[this._pos_++];if(e>=65536){const t=e-65536,r=55296|t>>10,i=56320|1023&t;s.push(r,i)}else s.push(e)}s.length>=4096&&(i.push(String.fromCharCode.apply(null,s)),s.length=0)}return 0===i.length?String.fromCharCode.apply(null,s):(s.length>0&&i.push(String.fromCharCode.apply(null,s)),i.join(""))}readCustomString(e){for(var t,r="",s=0,i=String.fromCharCode,a=this._u8d_;e>0;)if((t=a[this._pos_])<128)r+=i(t),this._pos_++,e--;else for(s=t-128,this._pos_++,e-=s;s>0;)t=a[this._pos_++],r+=i(a[this._pos_++]<<8|t),s--;return r}get pos(){return this._pos_}set pos(e){this._pos_=e}get bytesAvailable(){return this._length-this._pos_}clear(){this._pos_=0,this.length=0}writeUTFBytes(e){for(var t=0,r=(e+="").length;t<r;t++){var s=e.charCodeAt(t);if(s<=127)this.writeByte(s);else if(s<=2047)this._ensureWrite(this._pos_+2),this._u8d_.set([192|s>>6,128|63&s],this._pos_),this._pos_+=2;else if(s>=55296&&s<=56319){t++;const r=e.charCodeAt(t);if(!Number.isNaN(r)&&r>=56320&&r<=57343){const e=64+(1023&s),t=1023&r,i=240|e>>8&63,a=128|e>>2&63,n=128|(3&e)<<4|t>>6&15,o=128|63&t;this._ensureWrite(this._pos_+4),this._u8d_.set([i,a,n,o],this._pos_),this._pos_+=4}}else s<=65535?(this._ensureWrite(this._pos_+3),this._u8d_.set([224|s>>12,128|s>>6&63,128|63&s],this._pos_),this._pos_+=3):(this._ensureWrite(this._pos_+4),this._u8d_.set([240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s],this._pos_),this._pos_+=4)}}writeUTFString(e){var t=this.pos;this.writeUint16(1),this.writeUTFBytes(e);var r=this.pos-t-2;this._d_.setUint16(t,r,this._xd_)}writeUTFString32(e){var t=this.pos;this.writeUint32(1),this.writeUTFBytes(e);var r=this.pos-t-4;this._d_.setUint32(t,r,this._xd_)}readUTFString(){return this.readUTFBytes(this.readUint16())}readUTFString32(){return this.readUTFBytes(this.readUint32())}readUTFBytes(e){if(null==e&&(e=-1),0===e)return"";var t=this.bytesAvailable;if(e>t)throw new M(this._pos_+e);return e=e>0?e:t,this._rUTF(e)}writeByte(e){this._ensureWrite(this._pos_+1),this._d_.setInt8(this._pos_,e),this._pos_+=1}readByte(){if(this._pos_+1>this._length)throw new M(this._pos_+1);return this._d_.getInt8(this._pos_++)}_ensureWrite(e){this._length<e&&(this._length=e),this._allocated_<e&&(this.length=e)}writeArrayBuffer(e,t,r){if(null==t&&(t=0),null==r&&(r=0),t<0||r<0)throw new M(t+r);0==r&&(r=e.byteLength-t),this._ensureWrite(this._pos_+r);let s=new Uint8Array(e);this._u8d_.set(s.subarray(t,t+r),this._pos_),this._pos_+=r}readArrayBuffer(e){let t=this._u8d_.buffer.slice(this._pos_,this._pos_+e);return this._pos_=this._pos_+e,t}__getBuffer(){return this._d_.buffer}getByte(){return this.readByte()}getUint8(){return this.readUint8()}getInt16(){return this.readInt16()}getUint16(){return this.readUint16()}getInt32(){return this.readInt32()}getUint32(){return this.readUint32()}getFloat32(){return this.readFloat32()}getFloat64(){return this.readFloat64()}getUint8Array(e,t){return this.readUint8Array(e,t)}getInt16Array(e,t){return this.readInt16Array(e,t)}getFloat32Array(e,t){return this.readFloat32Array(e,t)}getUTFString(){return this.readUTFString()}getString(){return this.readString()}getCustomString(e){return this.readCustomString(e)}getUTFBytes(e=-1){return this.readUTFBytes(e)}}Ei.BIG_ENDIAN="bigEndian",Ei.LITTLE_ENDIAN="littleEndian",Ei._sysEndian=null;class vi{static __init__(){for(var e=0;e<256;++e){var t=e-127;t<-27?(Ci[0|e]=0,Ci[256|e]=32768,Mi[0|e]=24,Mi[256|e]=24):t<-14?(Ci[0|e]=1024>>-t-14,Ci[256|e]=1024>>-t-14|32768,Mi[0|e]=-t-1,Mi[256|e]=-t-1):t<=15?(Ci[0|e]=t+15<<10,Ci[256|e]=t+15<<10|32768,Mi[0|e]=13,Mi[256|e]=13):t<128?(Ci[0|e]=31744,Ci[256|e]=64512,Mi[0|e]=24,Mi[256|e]=24):(Ci[0|e]=31744,Ci[256|e]=64512,Mi[0|e]=13,Mi[256|e]=13)}for(bi[0]=0,e=1;e<1024;++e){var r=e<<13;for(t=0;!(8388608&r);)t-=8388608,r<<=1;r&=-8388609,t+=947912704,bi[e]=r|t}for(e=1024;e<2048;++e)bi[e]=939524096+(e-1024<<13);for(Ai[0]=0,e=1;e<31;++e)Ai[e]=e<<23;for(Ai[31]=1199570944,Ai[32]=2147483648,e=33;e<63;++e)Ai[e]=2147483648+(e-32<<23);for(Ai[63]=3347054592,Ii[0]=0,e=1;e<64;++e)Ii[e]=32===e?0:1024}static roundToFloat16Bits(e){wi[0]=e;var t=Ri[0],r=t>>23&511;return Ci[r]+((8388607&t)>>Mi[r])}static convertToNumber(e){var t=e>>10;return Ri[0]=bi[Ii[t]+(1023&e)]+Ai[t],wi[0]}}const Di=new ArrayBuffer(4),wi=new Float32Array(Di),Ri=new Uint32Array(Di),Ci=new Uint32Array(512),Mi=new Uint32Array(512),bi=new Uint32Array(2048),Ai=new Uint32Array(64),Ii=new Uint32Array(64);var Pi;e.FilterMode=void 0,(Pi=e.FilterMode||(e.FilterMode={}))[Pi.Point=0]="Point",Pi[Pi.Bilinear=1]="Bilinear",Pi[Pi.Trilinear=2]="Trilinear";const Bi=827611204,Li=861165636,Ni=877942852,Fi=894720068,Oi=131072;class Ui{constructor(e,t,r,s,i,a,n,o,l,h){this.width=e,this.height=t,this.mipmapCount=r,this.isCube=s,this.blockBytes=a,this.dataOffset=n,this.format=o,this.source=h,this.bpp=i,this.compressed=l}static getDDSTextureInfo(t){let r=new Int32Array(t,0,31),s=r[4],i=r[3],a=1;131072&r[2]&&(a=Math.max(1,r[7]));let n=r[21],o=!(4&~r[20]),l=!(64&~r[20]),h=(r[20]&Oi)===Oi,u=!(512&~r[28]),d=n===Bi||n===Li||n===Fi||n===Ni,c=e.TextureFormat.DXT1,_=r[1]+4,p=1;switch(n){case Bi:c=e.TextureFormat.DXT1,p=8;break;case Li:c=e.TextureFormat.DXT3,p=16;break;case Ni:case Fi:c=e.TextureFormat.DXT5,p=16;break;case 113:c=e.TextureFormat.R16G16B16A16,p=4;break;case 116:c=e.TextureFormat.R32G32B32A32,p=4;break;default:throw"Unsupported format "+(g=n,String.fromCharCode(255&g,g>>8&255,g>>16&255,g>>24&255))}var g;if(542327876!==r[0])throw"Invalid magic number in DDS header";if(!o&&!l&&!h)throw"Unsupported format, must contain a FourCC, RGB or LUMINANCE code";let m=f.renderEngine.getCapable(e.RenderCapable.COMPRESS_TEXTURE_S3TC)||f.renderEngine.getCapable(e.RenderCapable.COMPRESS_TEXTURE_S3TC_SRGB);if(d&&!m)throw"Compressed textures are not supported on this platform.";return new Ui(s,i,a,u,0,p,_,c,d,t)}}const ki=6408,Gi=6407,Vi=5121;class zi{static getLayaFormat(t,r,s,i){if(0!=t){if(t==ki&&32856==r&&s==Vi)return{format:e.TextureFormat.R8G8B8A8,sRGB:!1};if(t==ki&&35907==r&&s==Vi)return{format:e.TextureFormat.R8G8B8A8,sRGB:!0};if(t==ki&&34836==r&&5126==s)return{format:e.TextureFormat.R32G32B32A32,sRGB:!1};if(t==ki&&34842==r&&5131==s)return{format:e.TextureFormat.R16G16B16A16,sRGB:!1};if(t==Gi&&34837==r&&5126==s)return{format:e.TextureFormat.R32G32B32,sRGB:!1};if(t==Gi&&34843==r&&5131==s)return{format:e.TextureFormat.R16G16B16,sRGB:!1};if(t==Gi&&35905==r&&s==Vi)return{format:e.TextureFormat.R8G8B8,sRGB:!0};if(t==Gi&&32849==r&&s==Vi)return{format:e.TextureFormat.R8G8B8,sRGB:!1};throw"ktx: Unsupported UnCompressed image data."}switch(r){case 36196:return{format:e.TextureFormat.ETC1RGB,sRGB:!1};case 37496:return{format:e.TextureFormat.ETC2RGBA,sRGB:!1};case 37492:return{format:e.TextureFormat.ETC2RGB,sRGB:!1};case 37497:return{format:e.TextureFormat.ETC2SRGB_Alpha8,sRGB:!0};case 37493:return{format:e.TextureFormat.ETC2SRGB,sRGB:!0};case 37494:return{format:e.TextureFormat.ETC2RGB_Alpha1,sRGB:!1};case 37495:return{format:e.TextureFormat.ETC2SRGB_Alpha1,sRGB:!0};case 37808:return{format:e.TextureFormat.ASTC4x4,sRGB:!1};case 37812:return{format:e.TextureFormat.ASTC6x6,sRGB:!1};case 37815:return{format:e.TextureFormat.ASTC8x8,sRGB:!1};case 37819:return{format:e.TextureFormat.ASTC10x10,sRGB:!1};case 37821:return{format:e.TextureFormat.ASTC12x12,sRGB:!1};case 37840:return{format:e.TextureFormat.ASTC4x4SRGB,sRGB:!0};case 37844:return{format:e.TextureFormat.ASTC6x6SRGB,sRGB:!0};case 37847:return{format:e.TextureFormat.ASTC8x8SRGB,sRGB:!0};case 37851:return{format:e.TextureFormat.ASTC10x10SRGB,sRGB:!0};case 37853:return{format:e.TextureFormat.ASTC12x12SRGB,sRGB:!0};default:throw"KTX: UnSupported Compressed format."}}static getKTXTextureInfo(e){let t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&50===t[5]&&48===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])throw"ktx2 !";if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return zi.createKTX1Info(e);throw"ktx data wrong, not ktx1 or ktx2 buffer!"}static createKTX1Info(t){let r=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(t,12,13*r),i=67305985==s.getUint32(0,!0),a=s.getUint32(1*r,i),n=s.getUint32(2*r,i),o=s.getUint32(3*r,i),l=s.getUint32(4*r,i);s.getUint32(5*r,i);let h=s.getUint32(6*r,i),u=s.getUint32(7*r,i);s.getUint32(8*r,i);let d=s.getUint32(9*r,i),c=s.getUint32(10*r,i),_=s.getUint32(11*r,i),p=s.getUint32(12*r,i),g=zi.getLayaFormat(o,l,a,n),m=g.format,f=g.sRGB,T=e.TextureDimension.Tex2D;c>1&&d>1?T=e.TextureDimension.CubeArray:c>1&&d<=1?T=e.TextureDimension.Cube:c<=1&&d>1&&(T=e.TextureDimension.Texture2DArray);return new zi(t,0==o,f,T,h,u,m,_||1,p,64)}constructor(e,t,r,s,i,a,n,o,l,h){this.source=e,this.compress=t,this.sRGB=r,this.dimension=s,this.width=i,this.height=a,this.format=n,this.mipmapCount=o,this.bytesOfKeyValueData=l,this.headerOffset=h}}class Hi extends V{static __init__(){var t=new Uint8Array(4);if(t[0]=128,t[1]=128,t[2]=128,t[3]=255,Hi.grayTexture=new Hi(1,1,e.TextureFormat.R8G8B8A8,!1,!1),Hi.grayTexture.setPixelsData(t,!1,!1),Hi.grayTexture.lock=!0,Hi.grayTexture.name="Default_Gray",t[0]=255,t[1]=255,t[2]=255,t[3]=255,Hi.whiteTexture=new Hi(1,1,e.TextureFormat.R8G8B8A8,!1,!1),Hi.whiteTexture.setPixelsData(t,!1,!1),Hi.whiteTexture.lock=!0,Hi.whiteTexture.name="Default_White",t[0]=0,t[1]=0,t[2]=0,t[3]=255,Hi.blackTexture=new Hi(1,1,e.TextureFormat.R8G8B8A8,!1,!1),Hi.blackTexture.setPixelsData(t,!1,!1),Hi.blackTexture.lock=!0,Hi.blackTexture.name="Default_Black",f.renderEngine.getCapable(e.RenderCapable.TextureFormat_R16G16B16A16)){let t=new Uint16Array(4);t[0]=14336,t[1]=14336,t[2]=15360,t[3]=15360,Hi.normalTexture=new Hi(1,1,e.TextureFormat.R16G16B16A16,!1,!1,!1),Hi.normalTexture.setPixelsData(t,!1,!1)}else t[0]=128,t[1]=128,t[2]=255,t[3]=255,Hi.normalTexture=new Hi(1,1,e.TextureFormat.R8G8B8A8,!1,!1,!1),Hi.normalTexture.setPixelsData(t,!1,!1);Hi.normalTexture.lock=!0,Hi.normalTexture.name="Default_Normal",Hi.errorTexture=Hi.whiteTexture}static _SimpleAnimatorTextureParse(t,r=null,s=null){var i,a,n=new Ei(t);switch(n.readUTFString()){case"LAYAANIMATORTEXTURE:0000":var o,l=n.readInt32(),h=n.readInt32();i=new Float32Array(l*l*4),a=new Float32Array(n.readArrayBuffer(4*h)),i.set(a,0),(o=new Hi(l,l,e.TextureFormat.R32G32B32A32,!1,!1)).setPixelsData(i,!1,!1),o.filterMode=e.FilterMode.Point;break;case"LAYACOMPRESSANIMATORTEXTURE:0000":l=n.readInt32(),h=n.readInt32();if(i=new Uint16Array(n.readArrayBuffer(2*h)),f.renderEngine.getCapable(e.RenderCapable.TextureFormat_R16G16B16A16))(a=new Uint16Array(l*l*4)).set(i,0),(o=new Hi(l,l,e.TextureFormat.R16G16B16A16,!1,!1)).setPixelsData(a,!1,!1),o.filterMode=e.FilterMode.Point;else{console.log("The platform does not support 16-bit floating-point textures"),f.renderEngine.getCapable(e.RenderCapable.TextureFormat_R32G32B32A32)||console.error("The platform does not support 32-bit floating-point textures"),a=new Float32Array(l*l*4);for(var u=0,d=i.length;u<d;u++)a[u]=vi.convertToNumber(i[u]);(o=new Hi(l,l,e.TextureFormat.R32G32B32A32,!1,!1)).setPixelsData(a,!1,!1),o.filterMode=e.FilterMode.Point}break;default:throw"Laya3D:unknow version."}return o}static _parseImage(t,r=null,s=null){let i=s?s[2]:e.TextureFormat.R8G8B8A8,a=!s||s[3],n=!!s&&s[4],o=!!s&&s[5],l=!!r&&r.premultiplyAlpha,h=new Hi(t.width,t.height,i,a,n,o,l);return r?(h.setImageData(t,l,!1),h.setProperties(r)):h.setImageData(t,!1,!1),n&&(Y.canvas.size(t.width,t.height),Y.canvas.clear(),Y.context.drawImage(t,0,0,t.width,t.height),h._pixels=new Uint8Array(Y.context.getImageData(0,0,t.width,t.height).data.buffer)),h}static _parseDDS(e,t=null,r=null){let s=Ui.getDDSTextureInfo(e),i=!!r&&r[5],a=new Hi(s.width,s.height,s.format,s.mipmapCount>1,!1,i);return a.setDDSData(s),t&&(a.setProperties(t),a._premultiplyAlpha=t.premultiplyAlpha),a}static _parseKTX(e,t=null,r=null){var s,i;let a=zi.getKTXTextureInfo(e),n=(null===(s=null==r?void 0:r[3])||void 0===s||s)&&a.mipmapCount>1,o=null!==(i=null==r?void 0:r[5])&&void 0!==i?i:a.sRGB,l=new Hi(a.width,a.height,a.format,n,!1,o);return l.setKTXData(a),t&&(l.setProperties(t),l._premultiplyAlpha=t.premultiplyAlpha),l}static _parsePVR(e,t=null,r=null){throw new C}static load(e,t){l.loader.load(e,t,null,l.Loader.TEXTURE2D)}constructor(t,r,s,i=!0,a,n=!1,o=!1){super(t,r,s),this._canRead=!1,this._premultiplyAlpha=!1,this._dimension=e.TextureDimension.Tex2D,this._gammaSpace=n,this._canRead=a,this._premultiplyAlpha=o,this._texture=f.textureContext.createTextureInternal(this._dimension,t,r,s,i,n,o)}setImageData(e,t,r){let s=this._texture;f.textureContext.setTextureImageData(s,e,t,r)}setPixelsData(e,t,r){let s=this._texture;f.textureContext.setTexturePixelsData(s,e,t,r)}setSubPixelsData(e,t,r,s,i,a,n,o,l){let h=this._texture;f.textureContext.setTextureSubPixelsData(h,i,a,n,e,t,r,s,o,l)}setDDSData(e){let t=this._texture;f.textureContext.setTextureDDSData(t,e)}setKTXData(e){let t=this._texture;f.textureContext.setTextureKTXData(t,e)}setHDRData(e){let t=this._texture;f.textureContext.setTextureHDRData(t,e)}get defaultTexture(){return Hi.grayTexture}getPixels(){if(this._canRead&&this._pixels)return this._pixels;throw new Error("Texture2D: must set texture canRead is true.")}setProperties(e){e&&(null!=e.wrapModeU&&(this.wrapModeU=e.wrapModeU),null!=e.wrapModeV&&(this.wrapModeV=e.wrapModeV),null!=e.filterMode&&(this.filterMode=e.filterMode),null!=e.anisoLevel&&(this.anisoLevel=e.anisoLevel))}}Hi.TEXTURE2D="TEXTURE2D",Hi.grayTexture=null,Hi.whiteTexture=null,Hi.blackTexture=null,Hi.normalTexture=null,Hi.errorTexture=null;class Wi{static create(e){if(null!=e){let t=e instanceof zr?e:zr.create(e);return t._drawStyle||(t._drawStyle=new Wi(e))}return Wi.DEFAULT}constructor(e){this._color=null!=e?e instanceof zr?e:zr.create(e):zr.create(0)}equal(e){return"string"==typeof e?this._color.strColor===e:e instanceof zr&&this._color.numColor===e.numColor}}Wi.DEFAULT=Wi.create(0);class Xi{constructor(){this._lastOriX=0,this._lastOriY=0,this.paths=[],this._curPath=null}beginPath(e){this.paths.length=1,this._curPath=this.paths[0]=new Yi,this._curPath.convex=e}closePath(){this._curPath.loop=!0}newPath(){this._curPath=new Yi,this.paths.push(this._curPath)}addPoint(e,t){this._curPath.path.push(e,t)}push(e,t){this.pushOwned(e.slice(),t)}pushOwned(e,t){this._curPath?this._curPath.path.length>0&&(this._curPath=new Yi,this.paths.push(this._curPath)):(this._curPath=new Yi,this.paths.push(this._curPath));var r=this._curPath;r.path=e,r.convex=t}reset(){this.paths.length=0}}class Yi{constructor(){this.path=[],this.loop=!1,this.convex=!1}}class qi{constructor(){}static _createArray(){var e=[];return e._length=0,e}static _init(){var e=qi._namemap={};return e[qi.TYPE_ALPHA]="_alpha",e[qi.TYPE_FONT]="font",e[qi.TYPE_LINEWIDTH]="lineWidth",e[qi.TYPE_ENABLEMERGE]="_mergeID",e[qi.TYPE_MARK]=e[qi.TYPE_TRANSFORM]=e[qi.TYPE_TRANSLATE]=[],e[qi.TYPE_TEXTBASELINE]="textBaseline",e[qi.TYPE_TEXTALIGN]="textAlign",e[qi.TYPE_GLOBALCOMPOSITEOPERATION]="_nBlendType",e[qi.TYPE_SHADER]="shader",e[qi.TYPE_FILTERS]="filters",e}isSaveMark(){return!1}restore(e){this._dataObj[this._valueName]=this._value,qi.POOL[qi.POOL._length++]=this,this._newSubmit&&e.breakNextMerge()}static save(e,t,r,s){if((e._saveMark._saveuse&t)!==t){e._saveMark._saveuse|=t;var i=qi.POOL,a=i._length>0?i[--i._length]:new qi;a._value=r[a._valueName=qi._namemap[t]],a._dataObj=r,a._newSubmit=s;var n=e._save;n[n._length++]=a}}}qi.TYPE_ALPHA=1,qi.TYPE_STYLE=2,qi.TYPE_FONT=8,qi.TYPE_LINEWIDTH=256,qi.TYPE_MARK=1024,qi.TYPE_TRANSFORM=2048,qi.TYPE_TRANSLATE=4096,qi.TYPE_ENABLEMERGE=8192,qi.TYPE_TEXTBASELINE=16384,qi.TYPE_TEXTALIGN=32768,qi.TYPE_GLOBALCOMPOSITEOPERATION=65536,qi.TYPE_CLIPRECT=131072,qi.TYPE_CLIPRECT_STENCIL=262144,qi.TYPE_IBVB=524288,qi.TYPE_SHADER=1048576,qi.TYPE_FILTERS=2097152,qi.TYPE_FILTERS_TYPE=4194304,qi.POOL=qi._createArray(),qi._namemap=qi._init();class $i{constructor(){}isSaveMark(){return!1}restore(e){e["_"+this._key]=this._fillStyle,e._setSubmitKeyOther(this._other),$i.POOL[$i.POOL._length++]=this}static save(e,t){let r=e._saveMark;if((r._saveuse&qi.TYPE_STYLE)===qi.TYPE_STYLE)return;r._saveuse|=qi.TYPE_STYLE;let s=$i.POOL,i=s._length>0?s[--s._length]:new $i;i._fillStyle=e[t],i._other=e._getSubmitKeyOther(),i._key=t}}$i.POOL=qi._createArray();class Ki{constructor(){this._saveuse=0}isSaveMark(){return!0}restore(e){e._saveMark=this._preSaveMark,Ki.POOL[Ki.POOL._length++]=this}static Create(e){var t=Ki.POOL,r=t._length>0?t[--t._length]:new Ki;return r._saveuse=0,r._preSaveMark=e._saveMark,e._saveMark=r,r}}Ki.POOL=qi._createArray();class ji{constructor(){this._matrix=new Ce}isSaveMark(){return!1}restore(e){e._curMat=this._savematrix,e._matrixChanged=!1,ji.POOL[ji.POOL._length++]=this}static save(e){var t=e._saveMark;if((t._saveuse&qi.TYPE_TRANSFORM)!==qi.TYPE_TRANSFORM){t._saveuse|=qi.TYPE_TRANSFORM;var r=ji.POOL,s=r._length>0?r[--r._length]:new ji;s._savematrix=e._curMat,e._curMat=e._curMat.copyTo(s._matrix);var i=e._save;i[i._length++]=s}}}ji.POOL=qi._createArray();class Qi{constructor(){this._mat=new Ce}isSaveMark(){return!1}restore(e){this._mat.copyTo(e._curMat),Qi.POOL[Qi.POOL._length++]=this}static save(e){var t=Qi.POOL,r=t._length>0?t[--t._length]:new Qi;e._curMat.copyTo(r._mat);var s=e._save;s[s._length++]=r}}Qi.POOL=qi._createArray();class Zi{constructor(){this.clear()}clear(){this.blendShader=this.other=0}}class Ji{constructor(){this._id=0,this._renderType=0,this._key=new Zi,this.renderElement=null,this.textureHost=null,this.texArrayLayer=0,this.enableVertexSize=!1,this.fillTexture=!1,this._blend=null,this._texRange=new i,this._vertexSize=new i,this._id=++Ji.ID,this.toDefault()}get material(){return this._material}set material(e){this._material!=e&&(this._material&&this.renderElement&&this._material._removeOwnerElement(this.renderElement),this._material=e,this.renderElement&&(e?(this.renderElement.subShader=e.shader.getSubShaderAt(0),this.renderElement.materialShaderData=e.shaderData,e._setOwner2DElement(this.renderElement)):(this.renderElement.subShader=Ut.graphicsShader.getSubShaderAt(0),this.renderElement.materialShaderData=null)))}get u_TexRange(){return this._texRange}set u_TexRange(e){e?e.cloneTo(this._texRange):this._texRange.setValue(0,0,1,1)}get vertexSize(){return this._vertexSize}set vertexSize(e){e?e.cloneTo(this._vertexSize):this._vertexSize.setValue(0,0,0,0)}toDefault(){this._texRange.setValue(0,0,1,1),this._vertexSize.setValue(0,0,0,0),this.textureHost=null,this.texArrayLayer=0,this.enableVertexSize=!1,this.fillTexture=!1}clear(){this._key.clear(),this.toDefault(),this._blend=null,this.material=null}destroy(){this.clear(),this.renderElement&&Ji._pool.recover(this.renderElement),this.renderElement=null}update(e){let t=e.sprite._struct.blendMode,r=e._nBlendType;this._key.blendShader=r,this._blend=e.globalCompositeOperation!=t?r:null}}Ji._pool=h.createPool2(()=>{let e=f.render2DRenderPassFactory.createPrimitiveRenderElement2D();return e.renderStateIsBySprite=!1,e.nodeCommonMap=["Sprite2D"],e},(t,r)=>{r||null==r?(t.geometry=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.Triangles,e.DrawType.DrawElement),t.geometry.indexFormat=Yr.GRAPHICS_INDEX_FORMAT):t.geometry&&(t.geometry.destroy(),t.geometry=null)},e=>{e.geometry&&(e.geometry.clearRenderParams(),e.geometry.bufferState=null),e.materialShaderData=null,e.value2DShaderData=null,e.primitiveShaderData=null,e.globalShaderData=null,e.owner=null,e.subShader=null,e.renderStateIsBySprite=!1,e.typeKey=0,e.textureKey=0}),Ji.ID=1,Ji.RENDERBASE=new Ji;class ea{}function ta(e,t,r){let s=ea.standardFontSize;e.font=(r?"bold ":"")+s+"px "+t,e.setTransform(1,0,0,1,0,0),e.textBaseline="middle",e.lineWidth=0,e.fillStyle="red";let i=16;const a=[0,0,0,0];a[0]=s/2,a[1]=s/2,a[2]=s,a[3]=s,ra(e,"g",s,i,a),ra(e,"有",s,i,a);let n=Math.max(i-a[0],0),o=Math.max(i-a[1],0),l=a[2]-a[0]+1,h=a[3]-a[1]+1;return ra(e,"🤡",s,i,a,!0),{xoff:n,yoff:o,bbxw:l,bbxh:h,eoff:Math.max(i-a[1],0)-o,ebbxh:a[3]-a[1]+1}}function ra(e,t,r,s,i,a){let n=e.measureText(t).width,o=Math.floor(n+2*s),l=Math.floor(r+2*s);e.clearRect(0,0,o,l),e.fillText(t,s,s+r/2),function(e,t,r){let s=new Uint32Array(e.data.buffer);function i(e,t,r,i){let a=e.width*t+r;for(let e=r;e<i;e++)if(0!==s[a++])return!0;return!1}let a=e.width,n=e.height,o=0,l=t[1],h=0,u=l;if(i(e,l,0,a))for(;;){if(u=(l+h)/2|0,u+1>=l){t[1]=u;break}i(e,u,0,a)?l=u:h=u}if(t[3]>n)t[3]=n;else if(u=l=t[3],h=n,i(e,l,0,a))for(;;){if(u=(l+h)/2|0,u-1<=l){t[3]=u;break}i(e,u,0,a)?l=u:h=u}if(r)return;let d=t[0],c=a*t[1];for(u=t[1];u<t[3];u++){for(o=0;o<d;o++)if(0!==s[c+o]){d=o;break}c+=a}t[0]=d;let _=t[2];for(c=a*t[1],u=t[1];u<t[3];u++){for(o=_;o<a;o++)if(0!==s[c+o]){_=o;break}c+=a}t[2]=_}(e.getImageData(0,0,o,l),i,a)}var sa;ea.maxCanvasWidth=4096,ea.atlasWidth=1024,ea.atlasGridW=16,ea.standardFontSize=32,ea.noAtlas=!1,ea.forceSplitRender=!1,ea.forceWholeRender=!1,ea.scaleFontWithCtx=!0,ea.maxFontScale=3,ea.fontScale=1,ea.useTextureArray=!0,ea.premultiplyAlpha=!0,e.WrapMode=void 0,(sa=e.WrapMode||(e.WrapMode={}))[sa.Repeat=0]="Repeat",sa[sa.Clamp=1]="Clamp",sa[sa.Mirrored=2]="Mirrored";class ia{constructor(e,t,r){this.atlasWidth=e,this.atlasHeight=t,this.cellSize=r,this.cols=Math.floor(this.atlasWidth/this.cellSize),this.rows=Math.floor(this.atlasHeight/this.cellSize),this.freeCells=this.totalCells=this.cols*this.rows,this.columnHeights=new Uint8Array(this.cols)}allocate(e,t){if(e<=0||t<=0)return null;const r=this.cellSize,s=Math.ceil(e/r),i=Math.ceil(t/r);if(s<=0||i<=0)return null;if(s>this.cols||i>this.rows)return null;const a=this.cols,n=this.rows,o=this.columnHeights;let l=-1,h=Number.MAX_SAFE_INTEGER;e:for(let e=0;e<=a-s;e++){let t=0;for(let r=e;r<e+s;r++){const e=o[r];if(e>t&&(t=e),t+i>n)continue e}if(t<h&&(h=t,l=e,0===h))break}if(l<0)return null;const u=l*r,d=h*r,c=h+i;for(let e=l;e<l+s;e++){const t=o[e];o[e]=c,this.freeCells-=c-t}return{x:u,y:d,w:s*r,h:i*r,_cx:s,_cy:i}}reset(){this.freeCells!==this.totalCells&&(this.columnHeights.fill(0),this.freeCells=this.totalCells)}}class aa{constructor(e){this.fontMap=new Map,this.textAtlases=[],this.charMap=new Map,this.textMap=new Map,this.freeRegions=[],this.freeIsoTextures=[],this.owner=e;let t=Y.createElement("canvas");this.canvas=t,t.width=1024,t.height=512,Y.isDomSupported&&(t.style.left="-10000px",t.style.position="absolute",Y.document.body.appendChild(t)),this.ctx=t.getContext("2d",{willReadFrequently:!0}),l.systemTimer.loop(5e3,this,this.GC)}draw(e,t,r,s,i,a,n,o,l,h,u,d,c,_,p,g,m,f,T){let y=oa.test(e),x=this.getFont(s),S=a?x.bold:x.normal,E=i/ea.standardFontSize;da=Math.ceil(S.xoff*E),_a=y?Math.ceil(S.eoff*E):0,ca=Math.ceil(S.yoff*E)+_a,ua=Math.ceil((y?S.ebbxh:S.bbxh)*E),ha=ea.fontScale;let v=n?13:0,D=1e4*x.id+i+(a?"b":"")+(n?"i":"")+"_";u>0&&(g=!0);let w=0!==d||0!==c;D+=zr.create(o).numColor+"_",l>0&&(D+=zr.create(h).numColor+"_"+l+"_"),w&&(D+="shd_"+d+"_"+c+"_"+_+"_"+zr.create(p).numColor+"_");let R=this.ctx;R.font=(a?"bold ":"")+i+"px "+s,R.setTransform(ha,0,0,ha,0,0),R.textBaseline="middle",R.fillStyle=o,l>0&&(R.lineJoin="round",R.strokeStyle=h,R.lineWidth=l),w?(R.shadowOffsetX=d*ha,R.shadowOffsetY=c*ha,R.shadowBlur=_*ha,R.shadowColor=p):(R.shadowOffsetX=0,R.shadowOffsetY=0,R.shadowBlur=0),f||(f=[]);let C=4294967295;if(!g&&!ea.forceSplitRender||ea.forceWholeRender){let s=D+e,a=this.textMap.get(s);a&&a.ref++,f[0]&&this.free(f[0]),a||(null==m&&(m=R.measureText(e).width),a=this.drawOffscreen(R,e,m,i,l,n,!1,d,c),a.key=s,a.ref=1,this.textMap.set(s,a)),f[0]=a,T?T(a.tex,t+a.x,r+a.y,a.w,a.h,a.uv,C,v,!0):this.owner._inner_drawTexture(a.tex,a.tex.id,t+a.x,r+a.y,a.w,a.h,this.owner._curMat,a.uv,1,C,v,!0);for(let e=1,t=f.length;e<t;e++)this.free(f[e]);f.length=1}else{let s=this.owner._curMat;f.length>0&&this.freeRenderInfo(f);for(let a=0,o=e.length;a<o;a++){let h=e.charAt(a),_=h.charCodeAt(0);_>=55296&&_<=56319&&a+1<o&&(h+=e.charAt(++a));let p=D+h,g=this.charMap.get(p);if(!g){let e=R.measureText(h).width;g=this.drawOffscreen(R,h,e,i,l,n,!0,d,c),g.key=p,g.isChar=!0,this.charMap.set(p,g)}g.ref++,f.push(g);let m=h.length>1?4294967295:C;T?T(g.tex,t+g.x,r+g.y,g.w,g.h,g.uv,m,v,!0):this.owner._inner_drawTexture(g.tex,g.tex.id,t+g.x,r+g.y,g.w,g.h,s,g.uv,1,m,v,!0),t+=g.advance+l+u}}return f}drawOffscreen(e,t,r,s,i,a,n,o,l){let h=0,u=0,d=0,c=0;o>0?d=o:o<0&&(h=-o),l>0?c=l:l<0&&(u=-l);let _=s/3|0+i+Math.max(h,u),p=((_-da-i-h)*ha|0)-na,g=((_-ca-i-u)*ha|0)-na,m=s*(.08+(a?.231:0)),f=Math.ceil((r+da+2*i+h+d+m)*ha)+2*na,T=Math.ceil((ua+2*i+u+c+1)*ha)+2*na;f=Math.min(f,ea.maxCanvasWidth),T=Math.min(T,ea.maxCanvasWidth);let y=Math.min(f+Math.ceil(2*_*ha),ea.maxCanvasWidth),x=Math.min(T+Math.ceil(2*_*ha),ea.maxCanvasWidth);(y>this.canvas.width||x>this.canvas.height)&&this.resizeCanvas(e,y,x),e.clearRect(0,0,Math.ceil(y/ha),Math.ceil(x/ha)),i>0&&e.strokeText(t,_,_+s/2),e.fillText(t,_,_+s/2);let S=e.getImageData(p,g,f,T);if(ea.premultiplyAlpha){let e=S.data.length/4,t=S.data;for(let r=0;r<e;r++){let e=4*r,s=t[e+3]/255;s>0&&(t[e]=t[e]*s,t[e+1]=t[e+1]*s,t[e+2]=t[e+2]*s)}}let E={x:-da-i-h,y:-_a-i-u,w:(S.width-2*na)/ha,h:(S.height-2*na)/ha,advance:r,uv:new Array(8),tex:null,region:null,ref:0};return S.width>ea.atlasWidth||S.height>ea.atlasWidth||!n&&ea.noAtlas?(E.tex=this.createIsoTexture(S.width,S.height),this.setPixelsToTexture(S,E.tex,0,0,E.uv)):(E.region=this.addToAtlas(S.width,S.height),E.tex=E.region.owner.tex,this.setPixelsToTexture(S,E.tex,E.region.x,E.region.y,E.uv)),E}resizeCanvas(e,t,r){t=Math.min(512*Math.ceil(t/512),ea.maxCanvasWidth),r=Math.min(512*Math.ceil(r/512),ea.maxCanvasWidth);let s=e.font,i=e.fillStyle,a=e.strokeStyle,n=e.lineWidth,o=e.shadowOffsetX,l=e.shadowOffsetY,h=e.shadowBlur,u=e.shadowColor;this.canvas.width=t,this.canvas.height=r,e.setTransform(ha,0,0,ha,0,0),e.font=s,e.textBaseline="middle",e.lineJoin="round",e.fillStyle=i,e.strokeStyle=a,e.lineWidth=n,e.shadowOffsetX=o,e.shadowOffsetY=l,e.shadowBlur=h,e.shadowColor=u}createIsoTexture(e,t){let r=this.freeIsoTextures.findIndex(r=>null!=r&&r.width>=e&&r.width<=e+t&&r.height>=t&&r.height<=t+t);if(-1!==r){let e=this.freeIsoTextures[r];return this.freeIsoTextures[r]=null,++ga>50&&(this.freeIsoTextures=this.freeIsoTextures.filter(e=>null!=e),ga=0),e}return this.createTextTexture(e,t)}addToAtlas(e,t){let r,s=this.freeRegions.findIndex(r=>null!=r&&r.w>=e&&r.w<=e+t&&r.h>=t&&r.h<=t+t);if(-1!==s){let e=this.freeRegions[s];return this.freeRegions[s]=null,++pa>50&&(this.freeRegions=this.freeRegions.filter(e=>null!=e),pa=0),e.owner.ref++,e}for(let s of this.textAtlases)if(r=s.grid.allocate(e,t))return r.owner=s,s.ref++,r;let i=ea.atlasWidth,a={tex:this.createTextTexture(i,i),grid:new ia(i,i,ea.atlasGridW),ref:1};return this.textAtlases.push(a),r=a.grid.allocate(e,t),r.owner=a,r}createTextTexture(r,s){let i=new Hi(r,s,e.TextureFormat.R8G8B8A8,!1,!1,!0,!0);if(i.name="TextTexture",i.setPixelsData(null,!0,!1),i.lock=!0,i.filterMode=e.FilterMode.Bilinear,i.wrapModeU=e.WrapMode.Clamp,i.wrapModeV=e.WrapMode.Clamp,t.useTextureArray&&ea.useTextureArray){let t=!!f.renderEngine.gl;const a=Ws.allocateLayerAsTexture(r,s,e.TextureFormat.R8G8B8A8,64,!1,e.RenderTargetFormat.None,t);a&&(ea.premultiplyAlpha&&1===a.array.gammaCorrection&&(a.array._texture.gammaCorrection=2.2),Ws.register(i,a))}return i}setPixelsToTexture(e,t,r,s,i){let a=e.data;a instanceof Uint8ClampedArray&&(a=new Uint8Array(a.buffer));const n=Ws.resolve(t);n?n.uploadSubPixels(r,s,e.width,e.height,a):f.textureContext.setTextureSubPixelsData(t._texture,a,0,!1,r,s,e.width,e.height,!ea.premultiplyAlpha,!1);let o=(r+na)/t.width,l=(s+na)/t.height,h=(r+e.width-na)/t.width,u=(s+e.height-na)/t.height;i[0]=o,i[1]=l,i[2]=h,i[3]=l,i[4]=h,i[5]=u,i[6]=o,i[7]=u}freeRenderInfo(e){for(let t of e)this.free(t);e.length=0}free(e){if(e.ref--,!(e.ref>0)){if(e.isChar){if(0===e.ref)return;this.charMap.delete(e.key)}else this.textMap.delete(e.key);if(null!=e.region){let t=e.region.owner;if(t.ref--,0===t.ref)if(this.freeRegions.length>0&&(this.freeRegions=this.freeRegions.filter(e=>null!=e&&e.owner!==t)),pa=0,this.textAtlases.length>2&&-1!==this.textAtlases.findIndex(e=>0===e.ref)){this.destroyTextTexture(t.tex);let e=this.textAtlases.indexOf(t);this.textAtlases.splice(e,1)}else t.grid.reset();else this.freeRegions.push(e.region)}else this.freeIsoTextures.push(e.tex)}}getFontHeight(e,t,r){let s=this.getFont(e),i=t/ea.standardFontSize,a=r?s.bold:s.normal;return Math.ceil(a.bbxh*i)}getFont(e){let t=this.fontMap.get(e);return null==t&&(t={id:la++,normal:ta(this.ctx,e,!1),bold:ta(this.ctx,e,!0)},this.fontMap.set(e,t)),t}onFontScaleChanged(){this.textMap.clear(),ma.length=0;for(let[e,t]of this.charMap)0===t.ref?ma.push(t):t.ref--;for(let e of ma)this.free(e);this.charMap.clear()}GC(){if(this.freeIsoTextures.length>0){for(let e of this.freeIsoTextures)this.destroyTextTexture(e);this.freeIsoTextures.length=0,ga=0}ma.length=0;for(let[e,t]of this.charMap)0===t.ref&&ma.push(t);for(let e of ma)this.free(e)}destroyTextTexture(e){e&&(Ws.unregister(e),e.destroy())}}const na=1,oa=/[\uD800-\uDBFF][\uDC00-\uDFFF]/;var la=0,ha=1,ua=0,da=0,ca=0,_a=0,pa=0,ga=0,ma=[];class fa extends V{static get defaultTexture(){return this._defaultTexture}static __init__(){f.renderEngine.getCapable(e.RenderCapable.Texture3D)&&(this._defaultTexture=new fa(1,1,1,e.TextureFormat.R8G8B8A8,!1,!1,!1),this._defaultTexture.lock=!0,this._defaultTexture.setPixelsData(new Uint8Array([255,255,255,255]),!1,!1))}constructor(t,r,s,i,a=!0,n,o=!1){super(t,r,i),this._dimension=e.TextureDimension.Texture2DArray,this._gammaSpace=o,this.depth=s;let l=f.textureContext;this._texture=l.createTexture3DInternal(this._dimension,t,r,s,i,a,o,!1)}setImageData(e,t,r){let s=this._texture;f.textureContext.setTexture3DImageData(s,e,this.depth,t,r)}setPixelsData(e,t,r){let s=this._texture;f.textureContext.setTexture3DPixelsData(s,e,this.depth,t,r)}setSubPixelsData(e,t,r,s,i,a,n,o,l,h,u){let d=this._texture;f.textureContext.setTexture3DSubPixelsData(d,n,o,l,e,t,r,s,i,a,h,u)}}class Ta{addTexture(e){}onUpdate(){}shouldAddToDynamicAtlas(e){return!1}cleanupUnused(){}}const ya=new Ce;let xa;class Sa{constructor(){this._alpha=1,this._fillStyle=Wi.DEFAULT,this._strokeStyle=Wi.DEFAULT,this._tempUV=new Float32Array(8),this._drawTriUseAbsMatrix=!1,this._other=null,this._path=null,this._fillPathScratch=[],this._fillIndexScratch=[],this._drawState=new Ji,this._transedPoints=new Array(8),this._temp4Points=new Array(8),this._textureProcessor=new Ta,this._matrixChanged=!1,this._matBuffer=new Float32Array(6),this._lastMatScaleX=1,this._lastMatScaleY=1,this._lastMat_a=1,this._lastMat_b=0,this._lastMat_c=0,this._lastMat_d=1,this._nBlendType=e.BlendMode.normal,this._save=null,this._saveMark=null,this.sprite=null,this._lastTex=null,this._defTexture=null,this._defTexture=new ie(Hi.whiteTexture),this._textRender=new aa(this),this._other=Ea.DEFAULT,this._curMat=Ce.create(),this._save=[Ki.Create(this)],this._save.length=10,this.clear(),this.initDefalutMesh()}get lineJoin(){return""}set lineJoin(e){}get lineCap(){return""}set lineCap(e){}get miterLimit(){return""}set miterLimit(e){}transformByMatrix(e,t,r){this.transform(e.a,e.b,e.c,e.d,e.tx+t,e.ty+r)}drawRect(e,t,r,s,i,a,n){var o=this;null!=i&&(o.fillStyle=i,o.fillRect(e,t,r,s)),null!=a&&(o.strokeStyle=a,o.lineWidth=n,o.strokeRect(e,t,r,s))}alpha(e){this.globalAlpha*=e}_transform(e,t,r){this.translate(t,r),this.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),this.translate(-t,-r)}_rotate(e,t,r){this.translate(t,r),this.rotate(e),this.translate(-t,-r)}_scale(e,t,r,s){this.translate(r,s),this.scale(e,t),this.translate(-r,-s)}_drawLine(e,t,r,s,i,a,n,o,l){this.beginPath(),this.strokeStyle=n,this.lineWidth=o,this.moveTo(e+r,t+s),this.lineTo(e+i,t+a),this.stroke()}_drawLines(e,t,r,s,i,a){this.beginPath(),this.strokeStyle=s,this.lineWidth=i,this.addPath(r,!1,!1,e,t),this.stroke()}drawCurves(e,t,r,s,i){this.beginPath(),this.strokeStyle=s,this.lineWidth=i,this.moveTo(e+r[0],t+r[1]);for(var a=2,n=r.length;a<n;)this.quadraticCurveTo(e+r[a++],t+r[a++],e+r[a++],t+r[a++]);this.stroke()}_fillAndStroke(e,t,r,s=!1){null!=e&&(this.fillStyle=e,this.fill()),null!=t&&r>0&&(this.strokeStyle=t,this.lineWidth=r,this.stroke())}_drawCircle(e,t,r,s,i,a,n){this.beginPath(!0),this.arc(e,t,r,r,0,2*Math.PI,!1,!0,40),this.closePath(),this._fillAndStroke(s,i,a)}_drawEllipse(e,t,r,s,i,a,n){this.beginPath(!0),this.arc(e,t,r,s,0,2*Math.PI,!1,!0,40),this.closePath(),this._fillAndStroke(i,a,n)}_drawRoundRect(e,t,r,s,i,a,n,o,l,h,u,d=20,c=5){if(r<=0)return;if(s<=0)return;this.beginPath(!0);var _=this._getPath();if(0>=i)_.addPoint(e,t);else{let o=Math.PI,l=1.5*Math.PI;if(r<i+a){let e=i*(i+a-r)/(i+a),t=Math.sqrt(i*i-e*e),s=Math.atan2(t,e);l-=.5*Math.PI-s}if(s<i+n){let e=i*(i+n-s)/(i+n),t=Math.sqrt(i*i-e*e);o+=Math.atan2(e,t)}o>l||this.arc(e+i,t+i,i,i,o,l,!1,!0,d,c)}let p=e+r-a;if(0>=a)_.addPoint(p,t);else{let e=1.5*Math.PI,n=2*Math.PI;if(r<i+a){let t=a*(i+a-r)/(i+a),s=Math.sqrt(i*i-t*t),n=Math.atan2(s,t);e+=.5*Math.PI-n}if(s<a+o){let e=a*(a+o-s)/(a+o),t=Math.sqrt(a*a-e*e);n-=Math.atan2(e,t)}e>n||this.arc(p,t+a,a,a,e,n,!1,!0,d,c)}p=e+r-o;let g=t+s-o;if(0>=o)_.addPoint(p,g);else{let e=0,t=.5*Math.PI;if(r<n+o){let e=o*(n+o-r)/(n+o),s=Math.sqrt(n*n-e*e),i=Math.atan2(s,e);t-=.5*Math.PI-i}if(s<a+o){let t=o*(a+o-s)/(a+o),r=Math.sqrt(o*o-t*t);e+=Math.atan2(t,r)}e>t||this.arc(p,g,o,o,e,t,!1,!0,d,c)}if(p=e+n,g=t+s-n,0>=n)_.addPoint(p,g);else{let e=.5*Math.PI,t=Math.PI;if(r<n+o){let t=o*(n+o-r)/(n+o),s=Math.sqrt(n*n-t*t),i=Math.atan2(s,t);e+=.5*Math.PI-i}if(s<i+n){let e=n*(i+n-s)/(i+n),r=Math.sqrt(n*n-e*e);t-=Math.atan2(e,r)}e>t||this.arc(p,g,n,n,e,t,!1,!0,d,c)}this.closePath(),this._fillAndStroke(l,h,u)}_drawPie(e,t,r,s,i,a,n,o,l){this.beginPath(),this.moveTo(e,t),this.arc(e,t,r,r,s,i),this.closePath(),this._fillAndStroke(a,n,o)}_drawPoly(e,t,r,s,i,a,n,o){this.beginPath(),this.addPath(r,!0,n,e,t),this.closePath(),this._fillAndStroke(s,i,a,n)}_drawPath(e,t,r,s,i){this.beginPath();for(var a=0,n=r.length;a<n;a++){var o=r[a];switch(o[0]){case"moveTo":this.moveTo(e+o[1],t+o[2]);break;case"lineTo":this.lineTo(e+o[1],t+o[2]);break;case"arcTo":this.arcTo(e+o[1],t+o[2],e+o[3],t+o[4],o[5]);break;case"closePath":this.closePath()}}null!=s&&(this.fillStyle=s.fillStyle,this.fill()),null!=i&&(this.strokeStyle=i.strokeStyle,this.lineWidth=i.lineWidth||1,this.lineJoin=i.lineJoin,this.lineCap=i.lineCap,this.miterLimit=i.miterLimit,this.stroke())}destroy(){this.sprite=null,this._path=null,this._save=null}clear(){this._drawState.clear(),this._curMat.identity(),this._matrixChanged=!1,this._other=Ea.DEFAULT,this._other.clear(),this._alpha=1,this._nBlendType=e.BlendMode.normal,this._fillStyle=this._strokeStyle=Wi.DEFAULT,this._lastTex=null,this._saveMark=this._save[0],this._save._length=1}getCurrentScaleX(){let e=this.getMatScaleX();if(this.sprite&&this.sprite.globalTrans){const t=this.sprite.globalTrans.getMatrix();e*=Math.hypot(t.a,t.b)}return Math.abs(e)}getCurrentScaleY(){let e=this.getMatScaleY();if(this.sprite&&this.sprite.globalTrans){const t=this.sprite.globalTrans.getMatrix();e*=Math.hypot(t.c,t.d)}return Math.abs(e)}getMatScaleX(){return this._lastMat_a===this._curMat.a&&this._lastMat_b===this._curMat.b||(this._lastMatScaleX=this._curMat.getScaleX(),this._lastMat_a=this._curMat.a,this._lastMat_b=this._curMat.b),this._lastMatScaleX}getMatScaleY(){return this._lastMat_c===this._curMat.c&&this._lastMat_d===this._curMat.d||(this._lastMatScaleY=this._curMat.getScaleY(),this._lastMat_c=this._curMat.c,this._lastMat_d=this._curMat.d),this._lastMatScaleY}set fillStyle(e){this._fillStyle.equal(e)||($i.save(this,"fillStyle"),this._fillStyle=Wi.create(e))}get fillStyle(){return this._fillStyle}set globalAlpha(e){(e=Math.floor(1e3*e)/1e3)!=this._alpha&&(qi.save(this,qi.TYPE_ALPHA,this,!1),this._alpha=e)}get globalAlpha(){return this._alpha}set textAlign(e){this._other.textAlign===e||(this._other=this._other.make(),qi.save(this,qi.TYPE_TEXTALIGN,this._other,!1),this._other.textAlign=e)}get textAlign(){return this._other.textAlign}set textBaseline(e){this._other.textBaseline===e||(this._other=this._other.make(),qi.save(this,qi.TYPE_TEXTBASELINE,this._other,!1),this._other.textBaseline=e)}get textBaseline(){return this._other.textBaseline}set globalCompositeOperation(e){null==e||this._nBlendType===e||(qi.save(this,qi.TYPE_GLOBALCOMPOSITEOPERATION,this,!0),this._drawState.clear(),this._nBlendType=e)}get globalCompositeOperation(){return this._nBlendType}set strokeStyle(e){this._strokeStyle.equal(e)||($i.save(this,"strokeStyle"),this._strokeStyle=Wi.create(e))}get strokeStyle(){return this._strokeStyle}translate(e,t){0===e&&0===t||(Qi.save(this),this._curMat._bTransform?(ji.save(this),this._curMat.tx+=e*this._curMat.a+t*this._curMat.c,this._curMat.ty+=e*this._curMat.b+t*this._curMat.d):(this._curMat.tx=e,this._curMat.ty=t),this._matrixChanged=!0)}set lineWidth(e){this._other.lineWidth===e||(this._other=this._other.make(),qi.save(this,qi.TYPE_LINEWIDTH,this._other,!1),this._other.lineWidth=e)}get lineWidth(){return this._other.lineWidth}save(){this._save[this._save._length++]=Ki.Create(this)}restore(){var e=this._save._length,t=this._nBlendType;if(!(e<1)){for(var r=e-1;r>=0;r--){var s=this._save[r];if(s.restore(this),s.isSaveMark())return void(this._save._length=r)}t!=this._nBlendType&&this.breakNextMerge()}}_fillRect(e,t,r,s,i){if(this.transformQuad(e,t,r,s,0,this._curMat,this._transedPoints),!this.clipedOff(this._transedPoints)){this._resetDrawState()._key.other=-1}}fillRect(e,t,r,s,i=null){var a=i?Wi.create(i):this._fillStyle,n=this.mixRGBandAlpha(a._color.numColor);this._fillRect(e,t,r,s,n)}fillTexture(e,t,r,s,i,a,n,o){this._getImageSource(e)&&this._fillTexture(e,e.width,e.height,e.uvrect,t,r,s,i,a,n.x,n.y,o)}_fillTexture(e,t,r,s,a,n,o,l,h,u,d,c){var _=!0,p=!0;switch(h){case"repeat":break;case"repeat-x":p=!1;break;case"repeat-y":_=!1;break;case"no-repeat":_=p=!1}var g=this._temp4Points,m=0,f=0,T=0,y=0,x=0,S=0;if(u<0?(T=a,m=-u%t/t):T=a+u,d<0?(y=n,f=-d%r/r):y=n+d,x=a+o,S=n+l,!_&&(x=Math.min(x,a+u+t)),!p&&(S=Math.min(S,n+d+r)),!(x<a||S<n||T>x||y>S)){var E=(x-a-u)/t,v=(S-n-d)/r;if(this.transformQuad(T,y,x-T,S-y,0,this._curMat,this._transedPoints),g[0]=m,g[1]=f,g[2]=E,g[3]=f,g[4]=E,g[5]=v,g[6]=m,g[7]=v,!this.clipedOff(this._transedPoints)){let t=this._resetDrawState(),r=t;r.fillTexture=!0,i.TEMP.setValue(s[0],s[1],s[2],s[3]),r.u_TexRange=i.TEMP,t.textureHost=e}this.breakNextMerge()}}_resetDrawState(){let e=this._drawState;return e.clear(),e.update(this),e}drawTexture(e,t,r,s,i,a=4294967295){this._drawTextureM(e,t,r,s,i,null,1,null,a)}drawTextures(e,t,r,s,i){if(this._getImageSource(e))for(var a=t.length/2,n=0,o=e.bitmap.id,l=0;l<a;l++){const a="number"==typeof i[l]?i[l]:4294967295;this._inner_drawTexture(e,o,t[n++]+r,t[n++]+s,0,0,null,null,1,a)}}_drawTextureM(e,t,r,s,i,a,n,o,l){return!!this._getImageSource(e)&&this._inner_drawTexture(e,e.bitmap.id,t,r,s,i,a,o,n,l)}_inner_drawTexture(e,t,r,s,i,a,n,o,l,h,u,d){if(i=i||e.width,a=a||e.height,i<=0||a<=0)return!1;null==u&&(u=0);var c=this._drawState,_=c._key;o=o||e._uv;var p=this._transedPoints;if(this.transformQuad(r,s,i,a,u,n||this._curMat,p),d){var g=Math.round;p[0]=g(p[0]),p[1]=g(p[1]),p[2]=g(p[2]),p[3]=g(p[3]),p[4]=g(p[4]),p[5]=g(p[5]),p[6]=g(p[6]),p[7]=g(p[7])}let m=t>=0&&_.other===t&&_.blendShader===this._nBlendType;if(this._lastTex=e,!m){let r=c=this._resetDrawState(),s=Ws.resolve(e);s&&s.array instanceof fa?(r.textureHost=s.array,r.texArrayLayer=0|s.layer,c._key.other=s.array.id):(r.textureHost=e,c._key.other=t)}return!0}clipedOff(e){return!1}transformQuad(e,t,r,s,i,a,n){var o=0;0!=i&&(o=Math.tan(i*Math.PI/180)*s);var l=e+r,h=t+s,u=a.tx,d=a.ty,c=a.a,_=a.b,p=a.c,g=a.d,m=e+o,f=t,T=l+o,y=t,x=l,S=h,E=e,v=h;a!==this._curMat||this._matrixChanged?a._bTransform?(n[0]=m*c+f*p+u,n[1]=m*_+f*g+d,n[2]=T*c+y*p+u,n[3]=T*_+y*g+d,n[4]=x*c+S*p+u,n[5]=x*_+S*g+d,n[6]=E*c+v*p+u,n[7]=E*_+v*g+d):(n[0]=m+u,n[1]=f+d,n[2]=T+u,n[3]=y+d,n[4]=x+u,n[5]=S+d,n[6]=E+u,n[7]=v+d):(n[0]=m,n[1]=f,n[2]=T,n[3]=y,n[4]=x,n[5]=S,n[6]=E,n[7]=v)}breakNextMerge(){this._drawState.clear()}_getSubmitKeyOther(){return this._drawState._key.other}_setSubmitKeyOther(e){this._drawState._key.other=e}drawTextureWithTransform(t,r,s,i,a,n,o,l,h,u,d,c=4294967295){var _,p,g=this._curMat;if(null!=u&&("string"==typeof u&&(u=null!==(_=e.BlendMode[u])&&void 0!==_?_:"destination-out"===u?e.BlendMode.destinationOut:0),p=this.globalCompositeOperation,this.globalCompositeOperation=u),!n)return this._drawTextureM(t,r+o,s+l,i,a,g,h,d,c),void(null!=u&&(this.globalCompositeOperation=p));ya.a=n.a,ya.b=n.b,ya.c=n.c,ya.d=n.d,ya.tx=n.tx+o,ya.ty=n.ty+l,ya._checkTransform(),n&&g._bTransform?(Ce.mul(ya,g,ya),ya._checkTransform(),n=ya):(ya.tx+=g.tx,ya.ty+=g.ty,n=ya),this._drawTextureM(t,r,s,i,a,n,h,d,c),null!=u&&(this.globalCompositeOperation=p)}drawTriangles(t,r,s,i,a,n,o,l,h,u,d,c,_){var p,g;if(t&&!this._getImageSource(t))return;null==l&&(l=1),null==u&&(u=4294967295);let m=null;if(null!=h&&("string"==typeof h&&(h=null!==(p=e.BlendMode[h])&&void 0!==p?p:"destination-out"===h?e.BlendMode.destinationOut:0),m=this.globalCompositeOperation,this.globalCompositeOperation=h),i.length/2<=0||n.length<=0)return void(null!=h&&(this.globalCompositeOperation=m));var f=t instanceof ie?t.bitmap:t;let T=this._drawState;var y=T._key;if(!((!f||y.other===f.id)&&y.blendShader===this._nBlendType)){T=this._resetDrawState();let e=Ws.resolve(t);e&&e.array instanceof fa?(T.textureHost=e.array,T.texArrayLayer=0|e.layer):T.textureHost=t,T._key.other=e?e.array.id:null!==(g=null==f?void 0:f.id)&&void 0!==g?g:-1}this._mixRGBandAlpha(u,this._alpha*l),this._drawTriUseAbsMatrix?this._curMat==o&&this._matrixChanged&&this._curMat:(o?(ya.a=o.a,ya.b=o.b,ya.c=o.c,ya.d=o.d,ya.tx=o.tx+r,ya.ty=o.ty+s):(ya.a=1,ya.b=0,ya.c=0,ya.d=1,ya.tx=r,ya.ty=s),Ce.mul(ya,this._curMat,ya),ya._checkTransform()),null!=h&&(this.globalCompositeOperation=m)}transform(e,t,r,s,i,a){ji.save(this),Ce.mul(Ce.TEMP.setTo(e,t,r,s,i,a),this._curMat,this._curMat),this._curMat._checkTransform(),this._matrixChanged=!0}rotate(e){ji.save(this),this._curMat.rotateEx(e),this._matrixChanged=!0}scale(e,t){ji.save(this),this._curMat.scaleEx(e,t),this._matrixChanged=!0}beginPath(e=!1){this._getPath().beginPath(e)}closePath(){this._path.closePath()}addPath(e,t,r,s,i){let a=e.length,n=new Array(a+(t&&a>5&&(e[a-2]!=e[0]||e[a-1]!=e[1])?2:0));for(let t=0;t<a-1;t+=2)n[t]=e[t]+s,n[t+1]=e[t+1]+i;n.length>a&&(n[a]=n[0],n[a+1]=n[1]),this._getPath().pushOwned(n,r)}fill(){var e,t=this._getPath();this._resetDrawState(),this.mixRGBandAlpha(this._fillStyle._color.numColor);let r=this._curMat;for(var s=0,i=t.paths.length;s<i;s++){var a=t.paths[s],n=a.path.length/2;if(n<3||3===n&&!a.convex)continue;let i,u,d,c,_=a.path,p=this._fillPathScratch;if(p.length=_.length,this._matrixChanged)if(r._bTransform)for(let e=0;e<n;e++)i=e<<1,u=i+1,d=_[i],c=_[u],p[i]=r.a*d+r.c*c+r.tx,p[u]=r.b*d+r.d*c+r.ty;else for(let e=0;e<n;e++)i=e<<1,u=i+1,p[i]=_[i]+r.tx,p[u]=_[u]+r.ty;else for(let e=0;e<_.length;e++)p[e]=_[e];if(a.convex){var o=n-2;(e=this._fillIndexScratch).length=3*o;for(var l=0,h=0;h<o;h++)e[l++]=0,e[l++]=h+1,e[l++]=h+2}else e=Kr.earcut(p,null,2)}}stroke(){if(!(this.lineWidth<=0)){this.mixRGBandAlpha(this.strokeStyle._color.numColor);var e=this._getPath();this._resetDrawState(),this._matrixChanged&&this._curMat;for(var t=0,r=e.paths.length;t<r;t++){var s=e.paths[t];if(s.path.length<=0)continue;zs.createLine2Geometry(s.path,this.lineWidth,s.loop)}}}moveTo(e,t){var r=this._getPath();r.newPath(),r._lastOriX=e,r._lastOriY=t,r.addPoint(e,t)}lineTo(e,t){var r=this._getPath();Math.abs(e-r._lastOriX)<.001&&Math.abs(t-r._lastOriY)<.001||(r._lastOriX=e,r._lastOriY=t,r.addPoint(e,t))}arcTo(e,t,r,s,i){var a=0,n=0,o=0,l=this._path._lastOriX-e,h=this._path._lastOriY-t,u=Math.sqrt(l*l+h*h);if(!(u<=1e-6)){var d=l/u,c=h/u,_=r-e,p=s-t,g=_*_+p*p,m=Math.sqrt(g);if(!(m<=1e-6)){var f=_/m,T=p/m,y=d+f,x=c+T,S=Math.sqrt(y*y+x*x);if(!(S<=1e-6)){var E=y/S,v=x/S,D=Math.acos(E*d+v*c),w=Math.PI/2-D,R=(u=i*Math.tan(w))*d+e,C=u*c+t,M=Math.sqrt(u*u+i*i),b=e+E*M,A=t+v*M,I=0,P=0;if(d*T-c*f>=0){var B=2*w/Sa.SEGNUM;I=Math.sin(B),P=Math.cos(B)}else B=2*-w/Sa.SEGNUM,I=Math.sin(B),P=Math.cos(B);var L=this._path._lastOriX,N=this._path._lastOriY,F=R,O=C;(Math.abs(F-this._path._lastOriX)>.1||Math.abs(O-this._path._lastOriY)>.1)&&(n=F,o=O,L=F,N=O,this._path._lastOriX=n,this._path._lastOriY=o,this._path.addPoint(n,o));var U=R-b,k=C-A;for(a=0;a<Sa.SEGNUM;a++){var G=U*P+k*I,V=-U*I+k*P;n=G+b,o=V+A,(Math.abs(L-n)>.1||Math.abs(N-o)>.1)&&(this._path._lastOriX=n,this._path._lastOriY=o,this._path.addPoint(n,o),L=n,N=o),U=G,k=V}}}}}arc(e,t,r,s,i,a,n=!1,o=!0,l=20,h=5){i>a&&([i,a]=[a,i]);var u=this.getCurrentScaleX(),d=this.getCurrentScaleY(),c=r*(u>d?u:d),_=2*Math.PI*c;let p=0|Math.max(_/h,l),g=2*Math.PI/p;var m=this._getPath();let f=e+Math.cos(i)*r,T=t+Math.sin(i)*s;f==this._path._lastOriX&&T==this._path._lastOriY||m.addPoint(f,T);let y=Math.ceil(i/g)*g;for(;a-y>=g;)f=e+Math.cos(y)*r,T=t+Math.sin(y)*s,m.addPoint(f,T),y+=g;f=e+Math.cos(a)*r,T=t+Math.sin(a)*s,f==this._path._lastOriX&&T==this._path._lastOriY||m.addPoint(f,T)}quadraticCurveTo(e,t,r,s){for(var i=as.getPoints([this._path._lastOriX,this._path._lastOriY,e,t,r,s],30,2),a=0,n=i.length/2;a<n;a++)this.lineTo(i[2*a],i[2*a+1]);this.lineTo(r,s)}mixRGBandAlpha(e){return this._mixRGBandAlpha(e,this._alpha)}_mixRGBandAlpha(e,t){if(t>=1)return e;var r=(4278190080&e)>>>24;return 0!=r?r*=t:r=255*t,16777215&e|r<<24}strokeRect(e,t,r,s,i=0){if(this.lineWidth>0){var a=this.mixRGBandAlpha(this.strokeStyle._color.numColor),n=this.lineWidth/2;this._fillRect(e-n,t-n,r+this.lineWidth,this.lineWidth,a),this._fillRect(e-n,t-n+s,r+this.lineWidth,this.lineWidth,a),this._fillRect(e-n,t+n,this.lineWidth,s-this.lineWidth,a),this._fillRect(e-n+r,t+n,this.lineWidth,s-this.lineWidth,a)}}drawParticle(e,t,r){}_getPath(){return this._path||(this._path=new Xi)}_getImageSource(e){let t=this.sprite;return e._getSource(function(){t&&(t._graphics?t._graphics.repaint():t.repaint())})}initDefalutMesh(){if(!this.def_geometry){let t=4*Yr.stride,r=new Float32Array(t),s=new Float32Array(t),i=ie.DEF_UV,a=ie.INV_UV,n=[0,0,1,0,1,1,0,1],o=0;for(let e=0;e<4;e++){let t=e*Yr.stride;s[t]=r[t]=n[o],s[t+1]=r[t+1]=n[o+1],r[t+2]=i[o],r[t+3]=i[o+1],s[t+2]=a[o],s[t+3]=a[o+1],s[t+4]=r[t+4]=1,s[t+5]=r[t+5]=1,s[t+6]=r[t+6]=1,s[t+7]=r[t+7]=1,s[t+8]=r[t+8]=255,o+=2}let l=function(){let e=Yr.GRAPHICS_INDEX_ARRAY_TYPE;return xa&&xa.constructor===e||(xa=new e([0,2,1,0,3,2])),xa}(),h=f.renderDeviceFactory.createIndexBuffer(e.BufferUsage.Static);h.indexType=Yr.GRAPHICS_INDEX_FORMAT,h.indexCount=l.length,h._setIndexDataLength(l.byteLength),h._setIndexData(l,0);let u=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Static);u.vertexDeclaration=Yr.vertexDeclarition,u.setDataLength(r.byteLength),u.setData(r.buffer,0,0,r.byteLength);let d=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Static);d.vertexDeclaration=Yr.vertexDeclarition,d.setDataLength(s.byteLength),d.setData(s.buffer,0,0,s.byteLength),this.def_geometry=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.Triangles,e.DrawType.DrawElement);let c=f.renderDeviceFactory.createBufferState();c.applyState([u],h),this.def_geometry.bufferState=c,this.def_geometry.indexFormat=Yr.GRAPHICS_INDEX_FORMAT,this.def_geometry.setDrawElemenParams(6,0),this.inv_geometry=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.Triangles,e.DrawType.DrawElement);let _=f.renderDeviceFactory.createBufferState();_.applyState([d],h),this.inv_geometry.bufferState=_,this.inv_geometry.indexFormat=Yr.GRAPHICS_INDEX_FORMAT,this.inv_geometry.setDrawElemenParams(6,0)}}}Sa.SEGNUM=32;class Ea{constructor(){this.lineWidth=1}clear(){this.lineWidth=1,this.textAlign=this.textBaseline=null}make(){return this===Ea.DEFAULT?new Ea:this}}Ea.DEFAULT=new Ea;class va{static __init__(){va.runner=new Sa,va.compileContext=new Si,va.rendercontext2D=f.render2DRenderPassFactory.createRenderContext2D()}get basePass(){return this._basePass}constructor(){this._basePass=f.render2DRenderPassFactory.createRender2DPass(),this._manager=f.render2DRenderPassFactory.createRender2DPassManager(),this._basePass.doClearColor=!1,this._basePass.priority=0,this.addPass(this._basePass)}addPass(e){this._manager.addPass(e)}removePass(e){this._manager.removePass(e)}apply(t,r=va.renderTime){let s=performance.now();this._manager.apply(t,r),f.statAgent.recordTimeData(e.StatElement.T_2DPass,performance.now()-s)}clear(){this._manager.clear()}}va.renderTime=0;const Da="FillTextCmd";class wa{constructor(){this.x=0,this.y=0,this.color="#ffffff",this.strokeColor="#000000",this.stroke=0,this.align="left",this.fontSize=20,this.letterSpacing=0,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0,this.shadowColor="#000000"}static create(e,t,r,s,i,a,n,o){let l=h.getItemByClass(Da,wa);return l.text=null,l.x=t,l.y=r,l.font=s,l.color=null!=i?i:"#ffffff",l.stroke=null!=n?n:0,l.strokeColor=null!=o?o:"#000000",l.text=e,l.align=null!=a?a:"left",l.singleCharRender=!1,l._preMeasuredWidth=null,l.letterSpacing=0,l.shadowOffsetX=0,l.shadowOffsetY=0,l.shadowBlur=0,l.shadowColor="#000000",l}get font(){return this._font||(this._font=(this.bold?"bold ":"")+this.fontSize+"px "+(this.fontFamily?this.fontFamily:t.defaultFont)),this._font}set font(e){if(this._font=e,!e)return this.fontFamily=null,void(this.fontSize=t.defaultFontSize);let r=e.split(" "),s=r.length;if(s<2)return 1==s&&r[0].indexOf("px")>0&&(this.fontSize=parseInt(r[0])),void(this.fontFamily=null);let i=-1;for(let t=0;t<s;t++)if(r[t].indexOf("px")>0||r[t].indexOf("pt")>0){i=t,this.fontSize=parseInt(r[t]),this.fontSize<=0&&(console.debug("font parse error:"+e),this.fontSize=20);break}let a=i+1,n=r[a];for(a++;a<s;a++)n+=" "+r[a];this.fontFamily=n.split(",")[0],this.italic=r.indexOf("italic")>=0,this.bold=r.indexOf("bold")>=0}recover(){h.recover(Da,this),this._preMeasuredWidth=null,this._renderInfo&&va.runner._textRender.freeRenderInfo(this._renderInfo)}get cmdID(){return wa.ID}run(e,t,r){this._renderText(e,t,r)}emitTextureQuads(e,t,r,s){this._renderText(e,t,r,s)}_renderText(e,r,s,i){if(!this.text)return void(this._renderInfo&&e._textRender.freeRenderInfo(this._renderInfo));let a=this.getTextWidth();switch(this.align){case"center":r-=a/2;break;case"right":r-=a}this._renderInfo=e._textRender.draw(this.text,this.x+r,this.y+s,this.fontFamily?this.fontFamily:t.defaultFont,this.fontSize,this.bold,this.italic,this.color,this.stroke,this.strokeColor,this.letterSpacing,this.shadowOffsetX,this.shadowOffsetY,this.shadowBlur,this.shadowColor,this.singleCharRender,a,this._renderInfo,i)}getTextWidth(){if(null!=this._preMeasuredWidth)return this._preMeasuredWidth;let e=Y.context;return e.font=this.font,e.measureText(this.text).width}getBounds(e){let t=this.getTextWidth(),r=this.x,s=this.y;switch(this.align){case"center":r-=t/2;break;case"right":r-=t}r-=4,s-=this.fontSize/2;let i=this.fontSize*(.08+(this.italic?.231:0));te.TEMP.setTo(r,s,t+8+i,2*this.fontSize).getBoundPoints(e.points)}}wa.ID=Da,Ee.regClass(Da,wa);const Ra="RotateCmd";class Ca{static create(e,t,r){var s=h.getItemByClass(Ra,Ca);return s.angle=e,s.pivotX=t,s.pivotY=r,s}recover(){h.recover(Ra,this)}run(e,t,r){e._rotate(this.angle,this.pivotX+t,this.pivotY+r)}getBounds(e){Ma.identity(),Ma.translate(-this.pivotX,-this.pivotY),Ma.rotate(this.angle),Ma.translate(this.pivotX,this.pivotY),e.concatMatrix(Ma)}get cmdID(){return Ca.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}Ca.ID=Ra;const Ma=new Ce,ba="ScaleCmd";class Aa{static create(e,t,r,s){var i=h.getItemByClass(ba,Aa);return i.scaleX=e,i.scaleY=t,i.pivotX=r,i.pivotY=s,i}recover(){h.recover(ba,this)}run(e,t,r){e._scale(this.scaleX,this.scaleY,this.pivotX+t,this.pivotY+r)}getBounds(e){Ia.identity(),Ia.translate(-this.pivotX,-this.pivotY),Ia.scale(this.scaleX,this.scaleY),Ia.translate(this.pivotX,this.pivotY),e.concatMatrix(Ia)}get cmdID(){return Aa.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}Aa.ID=ba;const Ia=new Ce,Pa="TransformCmd";class Ba{static create(e,t,r){var s=h.getItemByClass(Pa,Ba);return s.matrix=e,s.pivotX=t,s.pivotY=r,s}recover(){this.matrix=null,h.recover(Pa,this)}run(e,t,r){e._transform(this.matrix,this.pivotX+t,this.pivotY+r)}getBounds(e){La.identity(),La.translate(-this.pivotX,-this.pivotY),La.concat(this.matrix),La.translate(this.pivotX,this.pivotY),e.concatMatrix(La)}get cmdID(){return Ba.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}Ba.ID=Pa;const La=new Ce,Na="TranslateCmd";class Fa{static create(e,t){var r=h.getItemByClass(Na,Fa);return r.tx=e,r.ty=t,r}recover(){h.recover(Na,this)}run(e){e.translate(this.tx,this.ty)}getBounds(e){Oa.identity(),Oa.translate(this.tx,this.ty),e.concatMatrix(Oa)}get cmdID(){return Fa.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}Fa.ID=Na;const Oa=new Ce;class Ua{static get FPS(){return f.statAgent.getElementData(e.StatElement.CT_FPS)}static show(t,s,i){if(Ua._statUI||(Ua._statUI=new Ua._statUIClass),this.hide(),i&&(Ua.elements.length=0,Ua.elements.push(...i)),0===Ua.elements.length){const t=r.statEnum;if(t){for(let r in t)t[r]&&Ua.elements.push(e.StatElement[r]);Ua.elements.sort()}}0===Ua.elements.length&&Ua.elements.push(...ka),Ua._show=!0,Ua._statUI.show(t,s),l.systemTimer.frameLoop(1,null,Ua.loop)}static hide(){Ua._show&&(Ua._show=!1,Ua._statUI.hide(),l.systemTimer.clear(null,Ua.loop))}static loop(){Ua._show&&Ua._statUI.update()}static render(){Ua._show&&Ua._statUI.render()}}Ua.elements=[],Ua.loopCount=0,Ua.render2DCount=0,Ua.enableShadow=!0,Ua.enableMulLight=!0,Ua.enableLight=!0,Ua.enableCameraCMD=!0,Ua.enablePostprocess=!0,Ua.enableSkin=!0,Ua.enableTransparent=!0,Ua.enableParticle=!0,Ua.enableAnimatorUpdate=!0,Ua.enablePhysicsUpdate=!0,Ua.enablemsaa=!0,Ua.enableOpaque=!0,Ua.enableSpine=!0;const ka=[e.StatElement.CT_FPS,e.StatElement.T_Frame_Time,e.StatElement.C_Sprite2DCount,e.StatElement.C_Sprite3DCount,e.StatElement.CT_DrawCall,e.StatElement.CT_Triangle,e.StatElement.C_BaseRenderCount,e.StatElement.C_SkinnedMeshRenderCount,e.StatElement.C_ShurikenParticleRenderCount,e.StatElement.T_CullMain,e.StatElement.CT_OpaqueDrawCall,e.StatElement.CT_TransDrawCall,e.StatElement.CT_ShadowDrawCall,e.StatElement.CT_DepthCastDrawCall,e.StatElement.CT_Instancing_DrawCall,e.StatElement.M_GPUMemory,e.StatElement.M_AllTexture,e.StatElement.M_RenderTexture,e.StatElement.M_GPUBuffer];window.Stat=Ua;class Ga{static add2DGlobalUniformData(e,t,r){f.renderDeviceFactory.createGlobalUniformMap("Sprite2DGlobal").addShaderUniform(e,t,r)}get useSpriteState(){return this._useSpriteState}set useSpriteState(e){var t;this._useSpriteState!=e&&(this._useSpriteState=e,this.owner&&(null===(t=this.owner._graphicsRenderer)||void 0===t||t._materialChanged(),this.owner.repaint()))}constructor(){this.owner=null,this._useSpriteState=!0,this._useSpriteRect=!1,this._cmds=[],this._graphicBounds=null,this._modified=-1,this._layoutRepaintCount=0,this.needCache=!1,this._pendingCommandChange=0}destroy(){this.owner&&this.owner._graphics===this&&this.owner.setGraphics(null,!1);for(let e of this._cmds)e.lock||e.recover();this._cmds.length=0,this._material&&(this._material._removeReference(),this._material=null),this._graphicBounds&&this._graphicBounds.destroy(),this._graphicBounds=null,this.owner=null}clear(e,t){if(0===this._cmds.length)return;let r=this._cmds.length;if(e||null==e)for(let e of this._cmds)e.lock||e==t||e.recover();t?(this._cmds[0]=t,this._cmds.length=1,this._layoutRepaintCount=0,t.needsLayoutRepaint&&(this._layoutRepaintCount=t.needsLayoutRepaint())):(this._cmds.length=0,this._layoutRepaintCount=0),this._commandsChanged(0,r,t?1:0)}_repaint(){this.repaint()}repaint(){var t;this._modified=Ua.loopCount,null===(t=this._graphicBounds)||void 0===t||t.reset(),this.owner&&(this.owner._ensureGraphicsRenderer().invalidateGraphicsState(),this.owner.repaint(e.RepaintFlag.Graphics))}_ownerSizeChanged(){var e;null===(e=this._graphicBounds)||void 0===e||e.reset()}_commandsChanged(e,t,r){let s=t===r?1:2;s<=this._pendingCommandChange||(this._pendingCommandChange=s,this._commitCommandsChanged(t,r))}_commandsCommitted(){this._pendingCommandChange=0}_commitCommandsChanged(e,t){var r;this._modified=Ua.loopCount,null===(r=this._graphicBounds)||void 0===r||r.reset();let s=this.owner;s&&(s._ensureGraphicsRenderer()._commandsChanged(e,t),s.repaint())}getLayoutRepaintCount(){return this._layoutRepaintCount}get cmds(){return this._cmds}set cmds(e){let t=this._cmds.length;this._cmds.length>0&&this._cmds.filter(t=>!e.includes(t)).forEach(e=>{e.lock||e.recover()}),this._layoutRepaintCount=0;for(let t of e)t.needsLayoutRepaint&&(this._layoutRepaintCount+=t.needsLayoutRepaint());this._cmds=e,this._commandsChanged(0,t,e.length)}addCmd(e,t){if(null==e)throw new Error("null cmd");let r=this._cmds.length,s=null==t||t>=r?r:t<0?Math.max(0,r+t):t;return s>=this._cmds.length?this._cmds.push(e):this._cmds.splice(s,0,e),e.needsLayoutRepaint&&(this._layoutRepaintCount+=e.needsLayoutRepaint()),this._commandsChanged(s,0,1),e}removeCmd(e,t){let r=this.cmds.indexOf(e);-1!=r&&(this._cmds.splice(r,1),e.needsLayoutRepaint&&(this._layoutRepaintCount-=e.needsLayoutRepaint()),this._commandsChanged(r,1,0)),t&&(e.lock=!1,e.recover())}replaceCmd(e,t,r){let s=this._cmds.indexOf(e),i=-1!==s&&null!=t;return-1!==s&&e&&e.needsLayoutRepaint&&(this._layoutRepaintCount-=e.needsLayoutRepaint()),null!=t?(-1!==s?(e&&e._cacheData&&"FrameAnimation"===e._cacheData.kind&&e.cmdID===t.cmdID&&(t._cacheData=e._cacheData),this._cmds[s]=t):this._cmds.push(t),t.needsLayoutRepaint&&(this._layoutRepaintCount+=t.needsLayoutRepaint()),i?this._commandsChanged(s,1,1):this._commandsChanged(this._cmds.length-1,0,1)):-1!=s&&(this._cmds.splice(s,1),this._commandsChanged(s,1,0)),e&&r&&(e.lock=!1,e.recover()),t}patchFrameAnimationCmd(e,t){var r;let s=e&&e._cacheData,i=s?s.commandIndex:-1;if(!s||"FrameAnimation"!==s.kind||s.graphics!==this||i<0||this._cmds[i]!==e||!t||e.cmdID!==t.cmdID||!this.owner)return!1;let a=this.owner._graphicsRenderer;t._cacheData=s;let n=a?a._patchTextureQuadCommand(s,e,t):-1;return-1!==n&&(e.needsLayoutRepaint&&(this._layoutRepaintCount-=e.needsLayoutRepaint()),this._cmds[i]=t,t.needsLayoutRepaint&&(this._layoutRepaintCount+=t.needsLayoutRepaint()),1===n&&(null===(r=this._graphicBounds)||void 0===r||r.reset(),this.owner.repaint()),!0)}preRegisterFrameAnimationCmds(e){var t;if(!this.owner||!e||0===e.length)return;let r=-1;for(let t=0;t<e.length&&r<0;t++)r=this._cmds.indexOf(e[t]);if(r<0)return;let s={kind:"FrameAnimation",graphics:this,commandIndex:r,state:new Float64Array(8),opStart:-1,opCount:0,op:null};for(let t=0;t<e.length;t++)e[t]._cacheData=s;null===(t=this.owner._graphicsRenderer)||void 0===t||t._preRegisterTextureQuadCommands(e)}getBounds(){return this._graphicBounds||(this._graphicBounds=Tr.create()),this._graphicBounds.getBounds(this)}getBoundPoints(){return this._graphicBounds||(this._graphicBounds=Tr.create()),this._graphicBounds.getBoundPoints(this)}get material(){return this._material}set material(t){var r;t&&!t.checkType(e.ShaderFeatureType.D2_TextureSV)||this._material!=t&&(this._material&&this._material._removeReference(),this._material=t,null!=t&&t._addReference(),this.owner&&(null===(r=this.owner._graphicsRenderer)||void 0===r||r._materialChanged(),this.owner.repaint()))}drawImage(e,t=0,r=0,s=null,i=null,a=null){return e&&e.bitmap?this.addCmd(fs.create(e,t,r,s,i,a)):null}drawTexture(e,t=0,r=0,s=null,i=null,a=null,n=1,o=null,l=null,h){return!e||n<.01?null:e.bitmap?this.addCmd(Is.create(e,t,r,s,i,a,n,o,l,h)):null}drawTextures(e,t,r){return e?this.addCmd(Bs.create(e,t,r)):null}drawTriangles(e,t,r,s,i,a,n=null,o=1,l=null,h=null){return this.addCmd(Ns.create(e,t,r,s,i,a,n,o,l,h))}fillTexture(e,t,r,s=0,i=0,a="repeat",n=null,o=null,l=!1){return e&&e.bitmap?this.addCmd(js.create(e,t,r,s,i,a,n||d.EMPTY,o,l)):null}clipRect(e,t,r,s){return console.warn("Graphics.clipRect is deprecated and no longer supported. Use Sprite.scrollRect so clipping is handled by the render struct."),null}fillText(e,t,r,s,i,a){return this.addCmd(wa.create(e,t,r,s,i,a,0,""))}fillBorderText(e,t,r,s,i,a,n,o){return this.addCmd(wa.create(e,t,r,s,i,a,n,o))}strokeText(e,t,r,s,i,a,n){return this.addCmd(wa.create(e,t,r,s,null,n,a,i))}alpha(e){return this.addCmd(Ar.create(e))}transform(e,t=0,r=0){return this.addCmd(Ba.create(e,t,r))}rotate(e,t=0,r=0){return this.addCmd(Ca.create(e,t,r))}scale(e,t,r=0,s=0){return this.addCmd(Aa.create(e,t,r,s))}translate(e,t){return this.addCmd(Fa.create(e,t))}save(){return this.addCmd(fr.create())}restore(){return this.addCmd(lr.create())}replaceTextColor(e){let t=this._cmds;for(let r=t.length-1;r>-1;r--){let s=t[r];switch(s.cmdID){case wa.ID:s.color=e;break;case fs.ID:s.color=null!=e?zr.create(e).numColor:4294967295}}this.repaint()}loadImage(e,t=0,r=0,s=null,i=null,a=null){let n=l.loader.getRes(e);n?(this.drawImage(n,t,r,s,i),a&&a.call(this.owner)):l.loader.load(e).then(e=>{this.drawImage(e,t,r,s,i),a&&a.call(this.owner)})}drawLine(e,t,r,s,i,a=1){return this.addCmd(ys.create(e,t,r,s,i,a))}drawLines(e,t,r,s,i=1){return!r||r.length<4?null:this.addCmd(Ss.create(e,t,r,s,i))}drawCurves(e,t,r,s,i=1){return this.addCmd(gs.create(e,t,r,s,i))}drawRect(e,t,r,s,i,a=null,n=1,o){return this.addCmd(bs.create(e,t,r,s,i,a,n,o))}drawRoundRect(e,t,r,s,i,a,n,o,l,h=null,u=1,d,c,_){return this.addCmd($s.create(e,t,r,s,i,a,n,o,l,h,u,d,c,_))}drawCircle(e,t,r,s,i=null,a=1,n){return this.addCmd(is.create(e,t,r,s,i,a,n))}drawEllipse(e,t,r,s,i,a,n,o){return this.addCmd(Ys.create(e,t,r,s,i,a,n,o))}drawPie(e,t,r,s,i,a,n=null,o=1){return this.addCmd(ws.create(e,t,r,Q.toRadian(s),Q.toRadian(i),a,n,o))}drawPoly(e,t,r,s,i=null,a=1){return this.addCmd(Cs.create(e,t,r,s,i,a))}drawPath(e,t,r,s=null,i=null){return this.addCmd(vs.create(e,t,r,s,i))}draw9Grid(e,t=0,r=0,s=0,i=0,a,n){this.addCmd(ts.create(e,t,r,s,i,a,!1,n))}}const Va=[],za=we.ACTIVE,Ha=we.DISPLAY;class Wa extends N{get url(){return this._url}set url(e){this._url=e}get hideFlags(){return this._hideFlags}set hideFlags(e){this._hideFlags=e}get is3D(){return 1===this._nodeType}get destroyed(){return this._destroyed}constructor(){super(),this._bits=0,this._reactiveBits=0,this._hideFlags=0,this._parent=null,this._destroyed=!1,this._nodeType=0,this.name="",this._bits=za,this._reactiveBits=Ha,this._children=[],this._$children=this._children,this._$container=this,this._initialize()}_initialize(){this._extra={}}_setBit(e,t){return 0===(this._bits&e)!=!t&&(t?this._bits|=e:this._bits&=~e,0!=(e&this._reactiveBits)&&this._onSetBit(e,t),!0)}_getBit(e){return 0!==(this._bits&e)}_onSetBit(e,t){if(0!==(e&we.DISPLAY)){let e=this._parent,t=l.stage,r=this===t;for(;e;){if(0!==(e._bits&we.DISPLAY)){r=0!==(e._bits&we.DISPLAYED_INSTAGE);break}if(e===t){r=!0;break}e=e._parent}this._setBit(we.DISPLAYED_INSTAGE,r)}}_setBitUp(e){let t=this;for(t._setBit(e,!0),t=t._parent;t;){if(0!==(t._bits&e))return;t._setBit(e,!0),t=t._parent}}onStartListeningToType(e){e!==c.DISPLAY&&e!==c.UNDISPLAY||0!==(this._bits&we.DISPLAY)||this._setBitUp(we.DISPLAY)}bubbleEvent(e,t){let r=[];r.length=0;let s,i=this;for(;i;)i.activeInHierarchy&&r.push(i),i=i._parent;t instanceof c&&(s=t,s._stopped=!1);for(let i of r)if(s){if(s.setTo(e,i,this),i.event(e,t),s._stopped)break}else i.event(e,t)}hasHideFlag(e){return 0!=(this._hideFlags&e)}destroy(e=!0){if(!this._destroyed){this._destroyed=!0,this.destroyAllComponent(),this._parent&&this._parent._removeChild(this);for(let t=0,r=this._children.length;t<r;t++){let t=this._children[0];this._children.shift(),t&&(t._setParent(null),e&&t.destroy())}this.onDestroy(),this.offAll()}}onDestroy(){}destroyChildren(){for(let e=0,t=this._$children.length;e<t;e++)this._$children[0].destroy(!0)}get children(){return this._$children}addChild(e){return this.addChildAt(e,this._$children.length)}addChildren(...e){let t=0,r=e.length;for(;t<r;)this.addChildAt(e[t++],this._$children.length)}addChildAt(e,t){if(t>=0&&t<=this._$children.length)return e._$parent===this?this.setChildIndex(e,t):(e._parent&&e._parent.removeChild(e),this._$children.splice(t,0,e),e._$parent=this,e._setParent(this._$container,t)),e;throw new M(t)}getChildIndex(e){return this._$children.indexOf(e)}getChild(e,t){for(let t of this._$children)if(t.name===e)return t;return null}getChildByName(e,t){return this.getChild(e,t)}getChildAt(e,t){if(e>=0&&e<this.numChildren)return this._$children[e];throw new M(e)}getChildByPath(e,t){let r,s=e.split("."),i=s.length,a=this;for(let e=0;e<i&&(r=a.getChild(s[e],t),r);++e)a=r;return r}findChild(e,t){for(let r of this._$children){if(r.name==e)return r;if(!r.url&&(r=r.findChild(e,t),r))return r}return null}setChildIndex(e,t){let r=this._$children.indexOf(e);if(r<0)throw new Error("not a child of this node");return this._setChildIndex(e,r,t),e}setChildIndexBefore(e,t){let r=this._$children.indexOf(e);if(-1==r)throw new Error("not a child of this node");return r<t?this._setChildIndex(e,r,t-1):this._setChildIndex(e,r,t)}_setChildIndex(e,t,r){let s=this._$children.length;return r>s&&(r=s),t==r?t:(this._$children.splice(t,1),r>=this._$children.length?this._$children.push(e):this._$children.splice(r,0,e),this._$container._childChanged(),r)}_childChanged(e){}removeChild(e,t){let r=this._$children.indexOf(e);return-1===r?(console.warn("not a child of this node"),e):(this._$children.splice(r,1),e._setParent(null),t&&e.destroy(),e)}removeSelf(){return this._parent&&this._parent._removeChild(this),this}removeChildByName(e,t){let r=this.getChild(e);return r&&this.removeChild(r,t),r}removeChildAt(e,t){let r=this._$children[e];return this._$children.splice(e,1),r._setParent(null),t&&r.destroy(),r}removeChildren(e,t,r){e=e||0,null==t&&(t=-1),(t<0||t>=this._$children.length)&&(t=this._$children.length-1);for(let s=e;s<=t;++s)this.removeChildAt(e,r)}replaceChild(e,t){let r=this._$children.indexOf(t);if(-1==r)throw new Error("not a child of this node");return this.removeChildAt(r),this.addChildAt(e,r)}_setContainer(e){this._$container=e,this._$children=e._children}_addChild(e,t){let r=this._children;if(null==t&&(t=r.length),t>=0&&t<=r.length){if(e._parent===this){let s=r.indexOf(e);r.splice(s,1),t>=r.length?r.push(e):r.splice(t,0,e),this._childChanged(e)}else e._parent&&e._parent.removeChild(e),r.splice(t,0,e),e._$parent=this,e._setParent(this,t);return e}throw new M(t)}_removeChild(e){let t=this._children.indexOf(e);return-1===t?(console.warn("not a child of this node"),e):(this._children.splice(t,1),e._setParent(null),e)}get numChildren(){return this._$children.length}get parent(){return this._$parent}isAncestorOf(e){if(!e)return!1;let t=e._parent;for(;t;){if(t==this)return!0;t=t._parent}return!1}_setParent(e,t=-1){if(e)this._parent=e,this._onAdded(),this.event(c.ADDED),0!==(this._bits&we.DISPLAY)&&(this._setBitUp(we.DISPLAY),e.displayedInStage&&this._displayChild(this,!0)),e._childChanged(this);else{this._onRemoved(),this.event(c.REMOVED);let e=this._parent;0!==(this._bits&we.DISPLAY)&&this._displayChild(this,!1),this._parent=null,this._$parent=null,e._destroyed||e._childChanged(this)}}get displayedInStage(){return 0===(this._bits&we.DISPLAY)&&this._setBitUp(we.DISPLAY),0!==(this._bits&we.DISPLAYED_INSTAGE)}_setDisplay(e){0!==(this._bits&we.DISPLAYED_INSTAGE)!==e&&(this._setBit(we.DISPLAYED_INSTAGE,e),e?this.event(c.DISPLAY):this.event(c.UNDISPLAY))}_displayChild(e,t){for(let r of e._children)0!==(r._bits&we.DISPLAY)&&(r._children.length>0?this._displayChild(r,t):r._setDisplay(t));e._setDisplay(t)}contains(e){if(e===this)return!0;for(;e;){if(e._parent===this)return!0;e=e._parent}return!1}timerLoop(e,t,r,s=null,i=!0,a=!1){this.timer.loop(e,t,r,s,i,a)}timerOnce(e,t,r,s=null,i=!0){this.timer._create(!1,!1,e,t,r,s,i)}frameLoop(e,t,r,s=null,i=!0){this.timer._create(!0,!0,e,t,r,s,i)}frameOnce(e,t,r,s=null,i=!0){this.timer._create(!0,!1,e,t,r,s,i)}clearTimer(e,t){this.timer.clear(e,t)}callLater(e,t=null){this.timer.callLater(this,e,t)}runCallLater(e){this.timer.runCallLater(this,e)}get scene(){return this._scene}get stage(){return l.stage}get active(){return 0!==(this._bits&we.ACTIVE)}set active(e){var t;if(e=!!e,0!==(this._bits&we.ACTIVE)!==e){if(this._activeChangeScripts&&0!==this._activeChangeScripts.length)throw new Error("recursive set active");this._setBit(we.ACTIVE,e),(null===(t=this._parent)||void 0===t?void 0:t.activeInHierarchy)&&0==(this._bits&we.NOT_IN_PAGE)&&this._processActive(e,!0)}}get activeInHierarchy(){return 0!==(this._bits&we.ACTIVE_INHIERARCHY)}_onActive(){}_onInActive(){}_onActiveInScene(){}_onInActiveInScene(){}onAwake(){}onEnable(){}onDisable(){}_parse(e,t){}_setBelongScene(e){if(!this._scene||this._scene!=e){this._scene=e,this._onActiveInScene();for(let t of this._children)t._setBelongScene(e)}}_setUnBelongScene(){if(this._scene!==this){this._onInActiveInScene(),this._scene=null;for(let e of this._children)e._setUnBelongScene()}}_processActive(e,t){this._activeChangeScripts||(this._activeChangeScripts=[]);let r=this._activeChangeScripts;e?this._activeHierarchy(r,t):this._inActiveHierarchy(r,t);for(let t=0,s=r.length;t<s;t++){let s=r[t];s.owner&&s._setActive(e)}r.length=0}_activeHierarchy(e,t){if(this._setBit(we.ACTIVE_INHIERARCHY,!0),this._components)for(let t=0,r=this._components.length;t<r;t++){let r=this._components[t];r._isScript()?r._enabled&&e.push(r):r._setActive(!0)}this._onActive();for(let r of this._children)0!==(r._bits&we.ACTIVE)&&0===(r._bits&we.NOT_IN_PAGE)&&r._activeHierarchy(e,t);0===(this._bits&we.AWAKED)&&(this._setBit(we.AWAKED,!0),this.onAwake()),this.onEnable()}_inActiveHierarchy(e,t){if(this._onInActive(),this._components)for(let t=0,r=this._components.length;t<r;t++){let r=this._components[t];r._isScript()?r._enabled&&e.push(r):r._setActive(!1)}this._setBit(we.ACTIVE_INHIERARCHY,!1);for(let r of this._children)0!==(r._bits&we.ACTIVE_INHIERARCHY)&&r._inActiveHierarchy(e,t);this.onDisable()}_onAdded(){if(this._activeChangeScripts&&0!==this._activeChangeScripts.length)throw new Error("recursive set active");{let e=this._parent.scene;e&&this._setBelongScene(e),this._parent.activeInHierarchy&&0!==(this._bits&we.ACTIVE)&&0===(this._bits&we.NOT_IN_PAGE)&&this._processActive(!0)}}_onRemoved(){if(this._activeChangeScripts&&0!==this._activeChangeScripts.length)throw new Error("recursive set active");this._parent.activeInHierarchy&&0!==(this._bits&we.ACTIVE)&&0===(this._bits&we.NOT_IN_PAGE)&&this._processActive(!1),this._parent.scene&&this._setUnBelongScene()}_addComponentInstance(e){var t;e._singleton&&this.getComponent(e.constructor)?console.warn("the component is singleton, can't add the second one.",e):(this._components||(this._components=[]),this._components.push(e),e._setOwner(this),this.activeInHierarchy&&e._setActive(!0),null===(t=this._componentsChanged)||void 0===t||t.call(this,e,0))}_destroyComponent(e){var t;if(!this._components)return;let r=this._components.indexOf(e);-1!=r&&(this._components.splice(r,1),e._destroy(),null===(t=this._componentsChanged)||void 0===t||t.call(this,e,1))}destroyAllComponent(){var e;if(this._components){for(let e=0,t=this._components.length;e<t;e++){let t=this._components[e];t&&!t.destroyed&&t._destroy()}this._components.length=0,null===(e=this._componentsChanged)||void 0===e||e.call(this,null,2)}}_cloneTo(e,t,r){if(this._components)for(let t=0,r=this._components.length;t<r;t++){let r=e.addComponent(this._components[t].constructor);this._components[t]._cloneTo(r)}}addComponentInstance(e){if(e.owner)throw new Error("the component is belong to other node.");return this._addComponentInstance(e),e}addComponent(e){let t=h.createByClass(e);if(!t)throw new Error("missing "+e.toString());return this._addComponentInstance(t),t}getComponent(e){if(this._components)for(let t=0,r=this._components.length;t<r;t++){let r=this._components[t];if(r instanceof e)return r}return null}get components(){return this._components||Va}getComponents(e){let t=[];if(this._components)for(let r=0,s=this._components.length;r<s;r++){let s=this._components[r];s instanceof e&&(t=t||[],t.push(s))}return t}get timer(){return this._scene?this._scene.timer:l.timer}onAfterDeserialize(){}}class Xa extends V{static __init__(){Xa._empty=new Xa(1,1,e.RenderTargetFormat.R8G8B8,e.RenderTargetFormat.None),Xa._empty.width=0,Xa._empty.height=0,Xa._empty.lock=!0}static createFromPool(e,t,r,s,i=1){for(let a=Xa._pool.length-1;a>=0;a--){let n=Xa._pool[a];if(n.destroyed){Xa._pool.splice(a,1);let e=n._renderTarget?n._renderTarget.gpuMemory/1024/1024:0;Xa._poolMemory-=e,Xa._poolTimeouts.delete(n._id);continue}if(n.width==e&&n.height==t&&n.getColorFormat()==r&&n.depthStencilFormat==s&&n._multiSamples==i)return n._inPool=!1,Xa._pool.splice(a,1),Xa._poolMemory-=n._renderTarget.gpuMemory/1024/1024,Xa._poolTimeouts.delete(n._id),n}let a=new Xa(e,t,r,s,i);return a.lock=!0,a}static recoverToPool(e){e._inPool||e.destroyed||(Xa._pool.push(e),Xa._poolMemory+=e._renderTarget.gpuMemory/1024/1024,e._inPool=!0,Xa._poolTimeouts.set(e.id,performance.now()),Xa._cleanupExcess())}static clearPool(){if(!(Xa._poolMemory<256)){for(var e in Xa._pool)Xa._pool[e].destroy();Xa._pool=[],Xa._poolMemory=0,Xa._poolTimeouts.clear()}}static cleanupExpired(){let e=Ua.loopCount;if(e-Xa._lastCleanupFrame<Xa.cleanupFrameInterval)return-1;Xa._lastCleanupFrame=e;let t=Xa.cleanupTimeout,r=performance.now(),s=0;for(let e=Xa._pool.length-1;e>=0;e--){let i=Xa._pool[e],a=Xa._poolTimeouts.get(i.id);a&&r-a>t&&(Xa._pool.splice(e,1),Xa._poolMemory-=i._renderTarget.gpuMemory/1024/1024,Xa._poolTimeouts.delete(i.id),i.destroy(),s++)}return s}static _cleanupExcess(){if(Xa._poolMemory<=Xa.maxPoolMemory)return;let e=[];for(let t=0;t<Xa._pool.length;t++){let r=Xa._pool[t],s=Xa._poolTimeouts.get(r.id);void 0!==s&&e.push({rt:r,time:s})}e.sort((e,t)=>e.time-t.time);for(let t=0;t<e.length;t++){let r=e[t].rt;if(Xa._poolMemory<=Xa.maxPoolMemory)break;let s=Xa._pool.indexOf(r);if(s>=0){Xa._pool.splice(s,1);let e=r._renderTarget?r._renderTarget.gpuMemory/1024/1024:0;Xa._poolMemory-=e,Xa._poolTimeouts.delete(r.id),r.destroy()}}}static get currentActive(){return Xa._currentActive}get depthStencilFormat(){return this._depthStencilFormat}get defaultTexture(){return Hi.grayTexture}getIsReady(){return!0}getColorFormat(){return this._colorFormat}get sourceWidth(){return this._width}get sourceHeight(){return this._height}get offsetX(){return 0}get offsetY(){return 0}constructor(t,r,s=e.RenderTargetFormat.R8G8B8,i=e.RenderTargetFormat.None,a=1){super(t,r,s),this._mgrKey=0,this._invertY=!1,this._inPool=!1,this._colorFormat=s,this._depthStencilFormat=i,this._multiSamples=a,0!=t&&0!=r&&this._create(),this.lock=!0}get isCube(){return this._renderTarget._isCube}get samples(){return this._renderTarget._samples}get generateMipmap(){return this._renderTarget._generateMipmap}_start(){throw new C}_end(){throw new C}_create(){this._renderTarget=f.textureContext.createRenderTargetInternal(this.width,this.height,this._colorFormat,this.depthStencilFormat,!1,!1,this._multiSamples,!1),this._renderTarget._texturesResolve?(this._texture=this._renderTarget._texturesResolve[0],this._renderTarget._textures[0].gammaCorrection=2.2):this._texture=this._renderTarget._textures[0],this._texture.gammaCorrection=2.2}clear(e=0,t=0,r=0,s=1){Xa._clearColor.r=e,Xa._clearColor.g=t,Xa._clearColor.b=r,Xa._clearColor.a=s,Xa._clear=!0}getData(t,r,s,i){const a=s*i*4;let n;switch(this._renderTarget.colorFormat){case e.RenderTargetFormat.R8G8B8:case e.RenderTargetFormat.R8G8B8A8:n=new Uint8Array(a);break;case e.RenderTargetFormat.R16G16B16A16:n=new Float32Array(a);break;default:throw new Error("getData is not supported "+this._renderTarget.colorFormat.toString()+"format")}return f.textureContext.readRenderTargetPixelData(this._renderTarget,t,r,s,i,n),n}getDataAsync(e,t,r,s,i){return f.textureContext.readRenderTargetPixelDataAsync(this._renderTarget,e,t,r,s,i)}recycle(){}_disposeResource(){this._renderTarget&&this._renderTarget.dispose()}}Xa._pool=[],Xa._poolMemory=0,Xa._poolTimeouts=new Map,Xa.cleanupTimeout=3e4,Xa.cleanupFrameInterval=360,Xa.maxPoolMemory=128,Xa._lastCleanupFrame=0,Xa._clearColor=new y(0,0,0,0),Xa._clear=!1;var Ya={linear:Ka,linearNone:Ka,linearIn:function(e,t,r,s){return r*e/s+t},linearInOut:function(e,t,r,s){return r*e/s+t},linearOut:function(e,t,r,s){return r*e/s+t},bounceIn:function(e,t,r,s){return r-Ya.bounceOut(s-e,0,r,s)+t},bounceInOut:function(e,t,r,s){return e<.5*s?.5*Ya.bounceIn(2*e,0,r,s)+t:.5*Ya.bounceOut(2*e-s,0,r,s)+.5*r+t},bounceOut:function(e,t,r,s){return(e/=s)<1/2.75?r*(7.5625*e*e)+t:e<2/2.75?r*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?r*(7.5625*(e-=2.25/2.75)*e+.9375)+t:r*(7.5625*(e-=2.625/2.75)*e+.984375)+t},backIn:function(e,t,r,s,i=1.70158){return r*(e/=s)*e*((i+1)*e-i)+t},backInOut:function(e,t,r,s,i=1.70158){return(e/=.5*s)<1?.5*r*(e*e*((1+(i*=1.525))*e-i))+t:r/2*((e-=2)*e*((1+(i*=1.525))*e+i)+2)+t},backOut:function(e,t,r,s,i=1.70158){return r*((e=e/s-1)*e*((i+1)*e+i)+1)+t},elasticIn:function(e,t,r,s,i=0,a=0){var n;if(0==e)return t;if(1==(e/=s))return t+r;a||(a=.3*s);!i||r>0&&i<r||r<0&&i<-r?(i=r,n=a/4):n=a/$a*Math.asin(r/i);return-i*Math.pow(2,10*(e-=1))*Math.sin((e*s-n)*$a/a)+t},elasticInOut:function(e,t,r,s,i=0,a=0){var n;if(0==e)return t;if(2==(e/=.5*s))return t+r;a||(a=s*(.3*1.5));!i||r>0&&i<r||r<0&&i<-r?(i=r,n=a/4):n=a/$a*Math.asin(r/i);return e<1?i*Math.pow(2,10*(e-=1))*Math.sin((e*s-n)*$a/a)*-.5+t:i*Math.pow(2,-10*(e-=1))*Math.sin((e*s-n)*$a/a)*.5+r+t},elasticOut:function(e,t,r,s,i=0,a=0){var n;if(0==e)return t;if(1==(e/=s))return t+r;a||(a=.3*s);!i||r>0&&i<r||r<0&&i<-r?(i=r,n=a/4):n=a/$a*Math.asin(r/i);return i*Math.pow(2,-10*e)*Math.sin((e*s-n)*$a/a)+r+t},strongIn:function(e,t,r,s){return r*(e/=s)*e*e*e*e+t},strongInOut:function(e,t,r,s){return(e/=.5*s)<1?.5*r*e*e*e*e*e+t:.5*r*((e-=2)*e*e*e*e+2)+t},strongOut:function(e,t,r,s){return r*((e=e/s-1)*e*e*e*e+1)+t},sineInOut:function(e,t,r,s){return.5*-r*(Math.cos(Math.PI*e/s)-1)+t},sineIn:function(e,t,r,s){return-r*Math.cos(e/s*qa)+r+t},sineOut:function(e,t,r,s){return r*Math.sin(e/s*qa)+t},quintIn:function(e,t,r,s){return r*(e/=s)*e*e*e*e+t},quintInOut:function(e,t,r,s){return(e/=.5*s)<1?.5*r*e*e*e*e*e+t:.5*r*((e-=2)*e*e*e*e+2)+t},quintOut:function(e,t,r,s){return r*((e=e/s-1)*e*e*e*e+1)+t},quartIn:function(e,t,r,s){return r*(e/=s)*e*e*e+t},quartInOut:function(e,t,r,s){return(e/=.5*s)<1?.5*r*e*e*e*e+t:.5*-r*((e-=2)*e*e*e-2)+t},quartOut:function(e,t,r,s){return-r*((e=e/s-1)*e*e*e-1)+t},cubicIn:function(e,t,r,s){return r*(e/=s)*e*e+t},cubicInOut:function(e,t,r,s){return(e/=.5*s)<1?.5*r*e*e*e+t:.5*r*((e-=2)*e*e+2)+t},cubicOut:function(e,t,r,s){return r*((e=e/s-1)*e*e+1)+t},quadIn:function(e,t,r,s){return r*(e/=s)*e+t},quadInOut:function(e,t,r,s){return(e/=.5*s)<1?.5*r*e*e+t:.5*-r*(--e*(e-2)-1)+t},quadOut:function(e,t,r,s){return-r*(e/=s)*(e-2)+t},expoIn:function(e,t,r,s){return 0==e?t:r*Math.pow(2,10*(e/s-1))+t-.001*r},expoInOut:function(e,t,r,s){return 0==e?t:e==s?t+r:(e/=.5*s)<1?.5*r*Math.pow(2,10*(e-1))+t:.5*r*(2-Math.pow(2,-10*--e))+t},expoOut:function(e,t,r,s){return e==s?t+r:r*(1-Math.pow(2,-10*e/s))+t},circIn:function(e,t,r,s){return-r*(Math.sqrt(1-(e/=s)*e)-1)+t},circInOut:function(e,t,r,s){return(e/=.5*s)<1?.5*-r*(Math.sqrt(1-e*e)-1)+t:.5*r*(Math.sqrt(1-(e-=2)*e)+1)+t},circOut:function(e,t,r,s){return r*Math.sqrt(1-(e=e/s-1)*e)+t}};const qa=.5*Math.PI,$a=2*Math.PI;function Ka(e,t,r,s){return r*e/s+t}class ja{constructor(e){this._props=e,this.nums=[]}get(e){let t=this._props.find(t=>t.name==e);if(!t)throw new Error(`Property '${e}' is not in tween.`);return this.read(t.type,t.offset)}set(e,t){let r=this._props.find(t=>t.name==e);if(!r)throw new Error(`Property '${e}' is not in tween.`);this.write(r.type,r.offset,t)}getAt(e){let t=this._props[e];if(!t)throw new M(e);return this.read(t.type,t.offset)}setAt(e,t){let r=this._props[e];if(!r)throw new M(e);this.write(r.type,r.offset,t)}get count(){return this._props.length}copy(e){return this.nums.length=0,this.nums.push(...e.nums),this}read(e,t){switch(e){case 0:return this.nums[t];case 1:return!!this.nums[t];case 2:return y.hexToString(this.nums[t]);default:return e.read(this.nums,t)}}write(e,t,r){switch(e){case 0:this.nums[t]=r;break;case 1:this.nums[t]=r?1:0;break;case 2:this.nums[t]=y.stringToHex(r);break;default:t===this.nums.length?e.write(this.nums,r):(Qa.length=0,e.write(Qa,r),Qa.forEach((e,r)=>this.nums[t+r]=e))}}}const Qa=[];function Za(e,t){t.writeTo(e,e.length)}const Ja=Symbol(),en=new $e;$e.prototype[Ja]={write:Za,read:(e,t)=>en.setValue(e[t],e[t+1])};const tn=new a;a.prototype[Ja]={write:Za,read:(e,t)=>tn.setValue(e[t],e[t+1],e[t+2])};const rn=new i;i.prototype[Ja]={write:Za,read:(e,t)=>rn.setValue(e[t],e[t+1],e[t+2],e[t+3])};const sn=new y;y.prototype[Ja]={write:Za,read:(e,t)=>sn.setValue(e[t],e[t+1],e[t+2],e[t+3])};const an=new d;d.prototype[Ja]={write:(e,t)=>{e.push(t.x,t.y)},read:(e,t)=>an.setTo(e[t],e[t+1])};class nn{static create(e){let t=nn._pool.take();return hn[ln++]=t,t.owner=e,t}static getTween(e){return un.get(e)}static isTweening(e){if(null==e)return!1;for(let t=0;t<ln;t++){let r=hn[t];if(r&&r.target==e&&!r._killed)return!0}return!1}static getTweens(e,t){if(t=t||[],null==e)return t;let r=ln;for(let s=0;s<r;s++){let r=hn[s];r&&r.target==e&&!r._killed&&t.push(r.owner)}return t}static kill(e,t){let r=un.get(e);return!(!r||r._killed)&&(r.kill(t),!0)}static killAll(e,t){if(null==e)return!1;let r=!1,s=ln;for(let i=0;i<s;i++){let s=hn[i];s&&s.target==e&&!s._killed&&(s.kill(t),r=!0)}return r}constructor(){this.props=[],this.easeArgs=[],this.interpArgs=[],this.startValue=new ja(this.props),this.endValue=new ja(this.props),this.value=new ja(this.props),this.deltaValue=new ja(this.props)}go(e,t,r){let s=dn.take();this.props.push(s),s.name=e,s.offset=this.startValue.nums.length,this._active?(s.renewFlags=0,void 0===t&&(t=this.target[e]),void 0===r&&(r=this.target[e])):s.renewFlags=void 0===t?1:void 0===r?2:0;const i=null!=t?typeof t:typeof r;let a;return"number"===i?s.type=0:"string"===i?s.type=2:"object"==i&&null!=(a=null!=t?t[Ja]:r[Ja])?s.type=a:s.type=1,this.startValue.write(s.type,s.offset,void 0!==t?t:r),this.endValue.write(s.type,s.offset,void 0!==r?r:t),this}get normalizedTime(){return this._normalizedTime}get breaking(){return 1==this._ended}get remainTime(){return this.breakpoint>=0?this.delay+this.breakpoint-this._elapsedTime:this.repeat>=0?this.delay+this.duration*(this.repeat+1)-this._elapsedTime:this.delay+2*this.duration-this._elapsedTime}activate(){this._active=!0,this._startFrame=l.timer.currFrame;for(let e of this.props)1==e.renewFlags?this.startValue.write(e.type,e.offset,this.target[e.name]):2==e.renewFlags&&this.endValue.write(e.type,e.offset,this.target[e.name])}seek(e){if(!this._killed){if(this._elapsedTime=e,this._elapsedTime<this.delay){if(!this._started)return;this._elapsedTime=this.delay}this.update2()}}kill(e){this._killed||(e?(0==this._ended&&(this._elapsedTime=0,this._elapsedTime=this.remainTime,this.update2()),this.callCompleteCallback()):this.onCompleteResolvers&&this.onCompleteResolvers.forEach(e=>e()),this._killed=!0)}init(){++on<1&&(on=1),this.id=on,un.set(this.id,this),this.name=null,this.delay=0,this.duration=0,this.breakpoint=-1,this.startValue.nums.length=0,this.endValue.nums.length=0,this.value.nums.length=0,this.ease=Ya.linear,this.easeArgs.length=0,this.timeScale=1,this.snapping=!1,this.repeat=0,this.yoyo=!1,this.interp=null,this.interpArgs.length=0,this._started=!1,this.paused=!1,this._killed=!1,this._startFrame=l.timer.currFrame,this._elapsedTime=0,this._normalizedTime=0,this._ended=0,this._active=!1}reset(){this.id=-1,this.owner=null,this.target=null,this.lifecycleOwner=null,this.userData=null,dn.recover(this.props),this.onStart=this.onUpdate=this.onComplete=this.onCompleteResolvers=null,this.onStartCaller=this.onUpdateCaller=this.onCompleteCaller=null}update(e){if(1!=this.timeScale&&(e*=this.timeScale),0!=e){if(0!=this._ended)return this.callCompleteCallback(),void(this._killed=!0);this._elapsedTime+=e,this.update2(),0!=this._ended&&(this._killed||(this.callCompleteCallback(),this._killed=!0))}}update2(){if(this._ended=0,!this._started){if(this._elapsedTime<this.delay)return;if(this._started=!0,this.value.copy(this.startValue),this.deltaValue.nums.length=this.startValue.nums.length,this.deltaValue.nums.fill(0),this.callStartCallback(),this._killed)return}let e=!1,t=this.duration,r=this._elapsedTime-this.delay;if(this.breakpoint>=0&&r>=this.breakpoint&&(r=this.breakpoint,this._ended=2),0!=this.repeat){let s=Math.floor(r/t);r-=t*s,this.yoyo&&(e=s%2==1),this.repeat>0&&this.repeat-s<0&&(this.yoyo&&(e=this.repeat%2==1),r=t,this._ended=1)}else r>=t&&(r=t,this._ended=1);let s=t>0?this.ease(e?t-r:r,0,1,t,...this.easeArgs):1;this._normalizedTime=s;let i=this.startValue.nums,a=this.endValue.nums,n=this.value.nums,o=this.deltaValue.nums;if(n.fill(0),o.fill(0),this.interp){this.interp(s,i,a,n,...this.interpArgs);for(let e=0,t=i.length;e<t;e++){let t=n[e];this.snapping&&(t=Math.round(t)),o[e]=t-n[e]}}else for(let e=0,t=i.length;e<t;e++){let t=i[e],r=t+(a[e]-t)*s;this.snapping&&(r=Math.round(r)),o[e]=r-n[e],n[e]=r}if(null!=this.target)for(let e of this.props)if(e.name){let t=1===e.type?1===this._ended?this.endValue.read(e.type,e.offset):this.startValue.read(e.type,e.offset):this.value.read(e.type,e.offset);if((0===e.type||1===e.type||2===e.type)&&this.target[e.name]===t)continue;this.target[e.name]=t}this.callUpdateCallback()}callStartCallback(){if(this.onStart)try{this.onStart.call(this.onStartCaller,this)}catch(e){console.error("error in start callback > ",e)}}callUpdateCallback(){if(this.onUpdate)try{this.onUpdate.call(this.onUpdateCaller,this)}catch(e){console.error("error in update callback > ",e)}}callCompleteCallback(){if(this.onComplete)try{this.onComplete.call(this.onCompleteCaller,this)}catch(e){console.error("error in complete callback > ",e)}this.onCompleteResolvers&&this.onCompleteResolvers.forEach(e=>e())}static _runAll(){var e;let t=ln;if(0==t)return;let r=l.timer.currFrame,s=l.timer.delta,i=l.timer.unscaledDelta,a=-1;for(let n=0;n<t;n++){let t=hn[n];null==t?-1==a&&(a=n):t._killed?(un.delete(t.id),null===(e=t.owner)||void 0===e||e._check(),nn._pool.recover(t),hn[n]=null,-1==a&&(a=n)):(t.target&&t.target.destroyed||t.lifecycleOwner&&t.lifecycleOwner.destroyed?t._killed=!0:!t.paused&&t._active&&t.update(t._startFrame==r?0:t.ignoreEngineTimeScale?i:s),-1!=a&&(hn[a]=t,hn[n]=null,a++))}if(a>=0){if(ln!=t){let e=t;t=ln-t;for(let r=0;r<t;r++)hn[a++]=hn[e],hn[e]=null,e++}ln=a}}static _getMap(){return un}}nn._pool=h.createPool(nn,e=>e.init(),e=>e.reset());var on=0,ln=0;const hn=[],un=new Map,dn=h.createPool(Object);class cn{static create(e,t){let r=cn._pool.take();return r._target=e,r._lo=t,r}static isTweening(e){return nn.isTweening(e)}static getTween(e){return _n.length=0,this.getTweens(e,_n),_n.length>0?_n[0]:null}static getTweens(e,t){return nn.getTweens(e,t)}static kill(e){e&&e.kill()}static clear(e){e&&e.kill()}static killAll(e,t){return nn.killAll(e,t)}static clearAll(e){cn.killAll(e)}static to(e,t,r,s,i,a,n){n&&cn.killAll(e);let o=cn.create(e);return cn.tweenLegacy(o.cur(!0),t,r,s,i,a,!0),o}static from(e,t,r,s,i,a,n){n&&cn.killAll(e);let o=cn.create(e);return cn.tweenLegacy(o.cur(!0),t,r,s,i,a,!1),o}static tweenLegacy(e,t,r,s,i,a,n){e.duration=r;for(let r in t){if("ease"==r||"easeArgs"==r||"update"==r||"complete"==r)continue;let s=t[r];r in e.target&&(n?e.go(r,e.target[r],s):e.go(r,s,e.target[r]))}t.ease&&(e.ease=t.ease,t.easeArgs&&e.easeArgs.push(...t.easeArgs)),t.update&&(e.onUpdate=t.update.runWith,e.onUpdateCaller=t.update),t.complete&&(e.onComplete=t.complete.runWith,e.onCompleteCaller=t.complete),null!=s&&(e.ease=s),null!=a&&(e.delay=a),i&&(e.onComplete=i.runWith,e.onCompleteCaller=i)}to(e,t){return this.cur(!0).go(e,void 0,t),this}from(e,t){return this.cur(!0).go(e,t,void 0),this}go(e,t,r){return this.cur(!0).go(e,t,r),this}chain(e,t){return void 0!==e&&(this._target=e,this._lo=t),0==this._queue.length||(null!=this._par&&(this._queue.push(-2),this._par=null),this._cur=nn.create(this),this._cur.target=this._target,this._cur.lifecycleOwner=this._lo,this._queue.push(this._cur.id)),this}parallel(e,t){return 0==this._queue.length?(void 0!==e&&(this._target=e,this._lo=t),this):(null==this._par&&(this._queue.push(-1),this._par=this._cur),this._cur=nn.create(this),void 0!==e?(this._cur.target=e,this._cur.lifecycleOwner=t):(this._cur.target=this._par.target,this._cur.lifecycleOwner=this._par.lifecycleOwner),this._cur.duration=this._par.duration,this._par._active&&this._cur.activate(),this._queue.push(this._cur.id),this)}delay(e){return this.cur(!1).delay=e,this}duration(e){return this.cur(!1).duration=e,this}breakpoint(e){return this.cur(!1).breakpoint=e,this}ease(e,...t){let r=this.cur(!1);return r.ease="string"==typeof e?Ya[e]:e,r.easeArgs.length=0,t&&r.easeArgs.push(...t),this}interp(e,...t){let r=this.cur(!1);return r.interp=e,r.interpArgs.length=0,t&&r.interpArgs.push(...t),this}repeat(e,t){let r=this.cur(!1);return r.repeat=e,r.yoyo=t,this}timeScale(e){return this.cur(!1).timeScale=e,this}ignoreEngineTimeScale(e){return this.cur(!1).ignoreEngineTimeScale=e,this}snapping(e){return this.cur(!1).snapping=e,this}userData(e){return this.cur(!1).userData=e,this}name(e){return this.cur(!1).name=e,this}onUpdate(e,t){let r=this.cur(!1);return r.onUpdate=e,r.onUpdateCaller=t,this}onStart(e,t){let r=this.cur(!1);return r.onStart=e,r.onStartCaller=t,this}then(e,t){let r=this.cur(!1);return r.onComplete=e,r.onCompleteCaller=t,this}waitForCompletion(){return new Promise(e=>{let t=this.cur(!1);t.onCompleteResolvers||(t.onCompleteResolvers=[]),t.onCompleteResolvers.push(e)})}seek(e){return this.cur(!1).seek(e),this}pause(){return pn(this._queue,e=>e.paused=!0),this}resume(){return pn(this._queue,e=>e.paused=!1),this}findTweener(e){for(let t=0,r=this._queue.length;t<r;t++){if(t<0)continue;let r=nn.getTween(this._queue[t]);if(r&&r.name==e)return r}return null}kill(e){if(0==this._queue.length)return;let t;for(let e of this._queue)if(e>0){let r=nn.getTween(e);r&&(r._killed||(t||(t=[]),t.push(r)),r.owner=null)}this._head=-1,this._cur=null,this._queue.length=0,null!=t&&t.forEach(t=>t.kill(e))}get completed(){return this._head>=0&&0===this._queue.length}complete(){this.kill(!0)}clear(){this.kill(!1)}recover(){this.kill(!1),cn._pool.recover(this)}constructor(){this._queue=[],this._head=-1}cur(e){if(!this._cur){if(-1!=this._head){if(!e)throw new Error("Tween has been started. clear first!");this.kill(!1)}this._cur=nn.create(this),this._cur.target=this._target,this._cur.lifecycleOwner=this._lo,this._cur.activate(),this._queue.push(this._cur.id)}return this._cur}_check(){this._cur&&(this._head=0,this._cur=null);let e=this._head,t=this._queue.length;for(;e<t;e++){let r=this._queue[e];if(r<0)continue;let s=nn.getTween(r);if(s&&!s._killed){if(s._active)break;if(s.activate(),-1==this._queue[e+1])for(let r=e+2;r<t;r++){let t=this._queue[r];if(t<0)break;let s=nn.getTween(t);s&&!s._killed?s.activate():this._queue[e]=-3}break}this._queue[e]=-3}this._head=e,e>=t&&(this._queue.length=0)}static shake(e,t,r,s,i){if(1==e)s.length=0,s.push(...t);else{let r=i*(1-e)*(Math.random()>.5?1:-1);for(let e=0;e<t.length;e++)s[e]=t[e]+r}}static seperateChannel(e,t,r,s,i){i=i||3;for(let a=0;a<t.length;a++)s[a]=gn(e,t[a],r[a],i)}static useCurvePath(e,t,r,s,i){let a=i.getPointAt(e);s[0]=a.x,s.length>1&&(s[1]=a.y),s.length>2&&(s[2]=a.z)}}cn._pool=h.createPool(cn);const _n=[];function pn(e,t){for(let r of e)if(r>0){let e=nn.getTween(r);e&&!e._killed&&t(e)}}function gn(e,t,r,s){let i=0;for(let a=0;a<s;a++){let s=8*a,n=t>>s&255;i+=n+((r>>s&255)-n)*e<<s}return i}class mn{constructor(e){this.ratio=.92,this.maxOffset=60,this.hasInertia=!1,this.elasticDistance=0,this.elasticBackTime=300,this.autoStart=!1,this._testing=!1,this._dragging=!1,this.target=e,this.area=new te,this._points=[],this.target.on(c.MOUSE_DOWN,this,this.onMouseDown)}get dragging(){return this._dragging}start(e){this.reset(),this._touchId=l.InputManager.lastTouchId,this._dragging=!0,this._testing=!1,this._elasticRateX=this._elasticRateY=1;let t=this.target._parent.getMousePoint();this._points.length=0,this._points.push(t.x,t.y,performance.now()),this._data=e,l.stage.on(c.MOUSE_MOVE,this,this.onMouseMove),l.stage.on(c.MOUSE_UP,this,this.onMouseUp)}reset(){this._dragging=!1,this._testing=!1,this._data=null,l.systemTimer.clear(this,this.tweenMove),l.stage.off(c.MOUSE_MOVE,this,this.onMouseMove),l.stage.off(c.MOUSE_UP,this,this.onMouseUp),null!=this._tween&&(this._tween.kill(),this._tween=null)}stop(){this._dragging?(this._dragging=!1,this._testing?this.reset():(this.moveTarget(0,0),this.clear(!0))):this.reset()}onMouseDown(){!this.autoStart||this._dragging||this._testing||(this.start(),this._testing=!0)}onMouseMove(e){if(!this._testing&&!this._dragging)return;if(this._touchId!=e.touchId)return;let t=this.target._parent.getMousePoint(),r=t.x,s=t.y,i=r-this._points[this._points.length-3],a=s-this._points[this._points.length-2];if(this._testing){if(Math.abs(i*l.stage._canvasTransform.getScaleX())<1&&Math.abs(a*l.stage._canvasTransform.getScaleY())<1)return;if(this._dragging=!0,this.target.event(c.DRAG_START,this._data),!this._dragging)return;this._testing=!1}let n=performance.now();for(;this._points.length>0&&this._points[2]<n-100;)this._points.splice(0,3);this._points.push(r,s,n),this.moveTarget(i*this._elasticRateX,a*this._elasticRateY),this.target.event(c.DRAG_MOVE,this._data)}onMouseUp(e){if(this._dragging){if(this._touchId==e.touchId)if(this.hasInertia){let e=mn.computeVelocity(this._points,this.maxOffset);this._points[0]=e.x,this._points[1]=e.y,this._dragging=!1,l.systemTimer.frameLoop(1,this,this.tweenMove)}else!this.area.isEmpty()&&this.elasticDistance>0?this.checkElastic():this.clear()}else this.reset()}moveTarget(e,t){let r=this.target._x+e,s=this.target._y+t;if(this.area.isEmpty())this.target.pos(r,s);else if(this.elasticDistance>0&&this._dragging){this.target.pos(r,s);let e=this.checkArea();this._elasticRateX=Math.max(0,1-Math.abs(e.x)/this.elasticDistance),this._elasticRateY=Math.max(0,1-Math.abs(e.y)/this.elasticDistance)}else{let i=this.checkArea(e,t);this.target.pos(r+i.x,s+i.y)}}checkArea(e=0,t=0){let r,s,i=te.TEMP.setTo(this.target.x+e-this.target.pivotX,this.target.y+t-this.target.pivotY,this.target.width,this.target.height);return r=i.x<this.area.x?this.area.x-i.x:i.right>this.area.right?this.area.right-i.right:0,s=i.y<this.area.y?this.area.y-i.y:i.bottom>this.area.bottom?this.area.bottom-i.bottom:0,fn.setTo(r,s)}checkElastic(){let e=this.checkArea();0!=e.x||0!=e.y?(this._tween=cn.create(this.target).duration(this.elasticBackTime).ease(Ya.sineOut).then(()=>this.clear()),0!=e.x&&this._tween.to("x",this.target.x+e.x),0!=e.y&&this._tween.to("y",this.target.y+e.y)):this.clear()}tweenMove(){let e=Math.pow(this.ratio,l.timer.delta/16.6),t=this.ratio*(1-e)/(1-this.ratio),r=this._points[0]*t*this._elasticRateX,s=this._points[1]*t*this._elasticRateY;this._points[0]=r,this._points[1]=s,r=r<0?Math.ceil(r):Math.floor(r),s=s<0?Math.ceil(s):Math.floor(s),Math.abs(r)<1&&Math.abs(s)<1||this._elasticRateX<.5||this._elasticRateY<.5?(l.systemTimer.clear(this,this.tweenMove),!this.area.isEmpty()&&this.elasticDistance>0?this.checkElastic():this.clear()):(this.moveTarget(r,s),this.target.event(c.DRAG_MOVE,this._data))}clear(e){let t=this._data;this.reset(),this.target.event(c.DRAG_END,[t,e])}static computeVelocity(e,t){let r=performance.now();for(;e.length>0&&e[2]<r-100;)e.splice(0,3);let s=e.length/3,i=0,a=0,n=0;for(let t=1;t<s;t++)i+=e[3*t]-e[3*t-3],a+=e[3*t+1]-e[3*t-2],n+=e[3*t+2]-e[3*t-1];return 0!=n?(n/=16.6,i/=n,a/=n):i=a=0,null!=t&&(Math.abs(i)>t&&(i=i>0?t:-t),Math.abs(a)>t&&(a=a>0?t:-t)),fn.setTo(i,a),fn}}const fn=new d;class Tn{static getGlobalRecByPoints(e,t,r,s,i,a){let n,o;n=d.create().setTo(t,r),n=e.localToGlobal(n),o=d.create().setTo(s,i),o=e.localToGlobal(o);let l=te._getWrapRec([n.x,n.y,o.x,o.y],a);return n.recover(),o.recover(),l}static getGlobalPosAndScale(e){let t=te.create();Tn.getGlobalRecByPoints(e,0,0,1,1,t);let r={x:t.x,y:t.y,scaleX:t.width,scaleY:t.height};return t.recover(),r}static getTransformRelativeToWindow(e,t,r){let s=l.stage,i=Tn.getGlobalPosAndScale(e),a=Ce.create();s._canvasTransform.copyTo(a);let n=a.tx,o=a.ty;a.rotate(-Math.PI/180*s.canvasDegree),a.scale(s.clientScaleX,s.clientScaleY);let h,u,d,c,_=s.canvasDegree%180!=0;return _?(h=r+i.y,u=t+i.x,h*=a.d,u*=a.a,90==s.canvasDegree?(h=n-h,u+=o):(h+=n,u=o-u)):(h=t+i.x,u=r+i.y,h*=a.a,u*=a.d,h+=n,u+=o),_?(d=a.d*i.scaleY,c=a.a*i.scaleX):(d=a.a*i.scaleX,c=a.d*i.scaleY),a.recover(),i.x=Math.round(h),i.y=Math.round(u),i.scaleX=Math.round(1e5*d)/1e5,i.scaleY=Math.round(1e5*c)/1e5,i}static fitDOMElementInArea(e,t,r,s,i,a){e._fitLayaAirInitialized||(e._fitLayaAirInitialized=!0,W.browser.setStyleTransformOrigin(e.style,"left top"),e.style.position="absolute");let n=Tn.getTransformRelativeToWindow(t,r,s);W.browser.setStyleTransform(e.style,"scale("+n.scaleX+","+n.scaleY+") rotate("+l.stage.canvasDegree+"deg)"),e.style.width=i+"px",e.style.height=a+"px",e.style.left=n.x+"px",e.style.top=n.y+"px"}static localToGlobalRect(e,t,r){r=r||te.create();let s=e.localToGlobal(d.TEMP.setTo(t.x,t.y)),i=s.x,a=s.y;return e.localToGlobal(s.setTo(t.right,t.bottom)),r.setTo(i,a,s.x-i,s.y-a)}static globalToLocalRect(e,t,r){r=r||te.create();let s=e.globalToLocal(d.TEMP.setTo(t.x,t.y)),i=s.x,a=s.y;return e.globalToLocal(s.setTo(t.right,t.bottom)),r.setTo(i,a,s.x-i,s.y-a)}static transformRect(e,t,r,s){if(r=r||l.stage,xn.length=0,t.getBoundPoints(xn),r===e._parent)for(let t=0,r=xn.length;t<r;t+=2){let r=e.toParentPoint(d.TEMP.setTo(xn[t],xn[t+1]));xn[t]=r.x,xn[t+1]=r.y}else for(let t=0,s=xn.length;t<s;t+=2){let s=e.localToGlobal(d.TEMP.setTo(xn[t],xn[t+1]));r.globalToLocal(s),xn[t]=s.x,xn[t+1]=s.y}return te._getWrapRec(xn,s)}static getRect(e,t,r){return r=r||te.create(),null==t||t?r.setTo(0,0,e.width,e.height):e.getSelfBounds(r),r.x-=e.pivotX,r.y-=e.pivotY,e.scrollRect&&(r.x-=e.scrollRect.x,r.y-=e.scrollRect.y),r.x=Math.floor(r.x),r.y=Math.floor(r.y),r.width=Math.floor(r.width),r.height=Math.floor(r.height),r.width<0&&(r.width=0),r.height<0&&(r.height=0),r}static setRect(e,t){e.size(t.width,t.height),e.pos(t.x+e.pivotX,t.y+e.pivotY)}static getChildrenBounds(e,t,r,s,i){(i=i||new te).setTo(0,0,0,0);let a=t?e._children:e._$children;for(let e of a){if(r&&!e._struct.enabled)continue;let a=e.width,n=e.height;if(s||(a*=Math.abs(e._scaleX),n*=Math.abs(e._scaleY)),i.union(yn.setTo(e._x-a*e._anchorX,e._y-n*e._anchorY,a,n),i),t&&e._children.length>0){let a=Tn.getChildrenBounds(e,t,r,s);a.x+=e._x,a.y+=e._y,i.union(a,i)}}return i}}const yn=new te,xn=[];class Sn{get hideFlags(){return this._hideFlags}set hideFlags(e){this._hideFlags=e}constructor(){var e;this._hideFlags=0,this._status=0,this._enabled=!0,this._id=vn++,this._singleton=null===(e=Object.getPrototypeOf(this)._$singleton)||void 0===e||e,this._initialize()}_initialize(){this._extra={}}hasHideFlag(e){return 0!=(this._hideFlags&e)}get id(){return this._id}get enabled(){return this._enabled}set enabled(e){this._enabled!=e&&(this._enabled=e,this.owner&&this._setActive(e&&this.owner.activeInHierarchy))}get awaked(){return this._status>0}get destroyed(){return 4==this._status}_isScript(){return!1}_resetComp(){this._enabled=!0,this._status=0,this._enableState=!1,this.owner=null}_setOwner(e){if(0!=this._status)throw new Error("reuse a destroyed component");this.owner=e,this._isScript()&&e._setBit(we.HAS_SCRIPT,!0),this._onAdded(),this.onAdded()}_onAdded(){}_onAwake(){}_onEnable(){this.onEnable()}_onDisable(){this.onDisable()}_onDestroy(){}_parse(e,t=null){}_parseInteractive(e=null,t=null){}_cloneTo(e){}_setActive(e){var t;e?(0==this._status&&(this._status=1,(p.isPlaying||this.runInEditor)&&(this._onAwake(),this.onAwake())),this._enabled&&!this._enableState&&(this._enableState=!0,(p.isPlaying||this.runInEditor)&&(this._driver=(null===(t=this.owner._scene)||void 0===t?void 0:t._componentDriver)||l.stage._componentDriver,this._driver.add(this),p.isPlaying&&this._isScript()&&this.setupScript(),this._onEnable()))):this._enableState&&(this._enableState=!1,(p.isPlaying||this.runInEditor)&&(this._driver&&this._driver.remove(this),l.stage.offAllCaller(this),this._onDisable()))}setupScript(){}destroy(){4!=this._status&&(this.owner?this.owner._destroyComponent(this):this.destroyed||this._destroy(!0))}_destroy(e){var t;e?(p.isPlaying||this.runInEditor)&&(this._onDestroy(),this.onDestroy(),this.onReset&&(this.onReset(),null===(t=this.owner)||void 0===t||t.offAllCaller(this),this._resetComp(),h.recoverByClass(this))):(this._setActive(!1),this._status=4,(p.isPlaying||this.runInEditor)&&(this._driver||l.stage._componentDriver)._toDestroys.add(this),this._driver=null)}onAdded(){}onAwake(){}onEnable(){}onDisable(){}onDestroy(){}}var En,vn=0;e.Render2DOrderMode=void 0,(En=e.Render2DOrderMode||(e.Render2DOrderMode={}))[En.elementIndex=0]="elementIndex",En[En.ysort=1]="ysort";class Dn extends Sn{static initBaseRender2DCommandEncoder(){Dn.BASERENDER2DCOLOR=Ot.propertyNameToID("u_baseRenderColor"),Dn.BASERENDER2DTEXTURE=Ot.propertyNameToID("u_baseRender2DTexture"),Dn.TILINGOFFSET=Ot.propertyNameToID("u_tilingOffset"),Dn.BASERENDERSIZE=Ot.propertyNameToID("u_baseRenderSize2D"),Dn.NORMAL2DTEXTURE=Ot.propertyNameToID("u_normal2DTexture"),Dn.NORMAL2DSTRENGTH=Ot.propertyNameToID("u_normal2DStrength"),Dn.SHADERDEFINE_BASERENDER2D=Ot.getDefineByName("BASERENDER2D"),Dn.SHADERDEFINE_LIGHT2D_ENABLE=Ot.getDefineByName("LIGHT2D_ENABLE"),Dn.SHADERDEFINE_LIGHT2D_EMPTY=Ot.getDefineByName("LIGHT2D_EMPTY"),Dn.SHADERDEFINE_LIGHT2D_ADDMODE=Ot.getDefineByName("LIGHT2D_SCENEMODE_ADD"),Dn.SHADERDEFINE_LIGHT2D_SUBMODE=Ot.getDefineByName("LIGHT2D_SCENEMODE_SUB"),Dn.SHADERDEFINE_LIGHT2D_NORMAL_PARAM=Ot.getDefineByName("LIGHT2D_NORMAL_PARAM"),Dn.SHADERDEFINE_UNITQUAD=Ot.getDefineByName("UNITQUAD");const t=f.renderDeviceFactory.createGlobalUniformMap("BaseRender2D");t.addShaderUniform(kt.UNIFORM_NMATRIX_0,"u_NMatrix_0",e.ShaderDataType.Vector3),t.addShaderUniform(kt.UNIFORM_NMATRIX_1,"u_NMatrix_1",e.ShaderDataType.Vector3),t.addShaderUniform(Dn.BASERENDER2DCOLOR,"u_baseRenderColor",e.ShaderDataType.Color),t.addShaderUniform(Dn.BASERENDER2DTEXTURE,"u_baseRender2DTexture",e.ShaderDataType.Texture2D),t.addShaderUniform(Dn.TILINGOFFSET,"u_tilingOffset",e.ShaderDataType.Vector4),t.addShaderUniform(Dn.BASERENDERSIZE,"u_baseRenderSize2D",e.ShaderDataType.Vector2),t.addShaderUniform(Dn.NORMAL2DTEXTURE,"u_normal2DTexture",e.ShaderDataType.Texture2D),t.addShaderUniform(Dn.NORMAL2DSTRENGTH,"u_normal2DStrength",e.ShaderDataType.Float),t.addShaderUniform(kt.UNIFORM_CLIPOFFSET,"u_clipOffset",e.ShaderDataType.Vector2)}static _setRenderElement2DMaterial(e,t){e.subShader=t._shader.getSubShaderAt(0),t._setOwner2DElement(e),e.materialShaderData=t._shaderValues}static _removeRenderElement2DMaterial(e,t){t&&!t.destroyed&&t._removeOwnerElement(e)}get renderLayer(){return this._renderLayer}set renderLayer(e){this._renderLayer=e}get rect(){return this._boundsChange&&(this._boundsChange=!1),this._rect}get boundsChange(){return this._boundsChange}set boundsChange(e){this._boundsChange=e}_getcommonUniformMap(){return["BaseRender2D"]}_transformChange(){this.boundsChange=!0}_changeMaterialReference(e,t){e&&e._removeReference(),t&&t._addReference()}constructor(){super(),this._renderType=e.BaseRender2DType.baseRenderNode,this._renderUpdateMask=0,this._layer=0,this._rtsize=new $e,this._lightReceive=!1,this._lightUpdateMark=0,this._lightRecord=!1,this._renderLayer=1,this._rect=new i,this._boundsChange=!1,this._renderid=Dn._uniqueIDCounter++,this._renderType=e.BaseRender2DType.baseRenderNode,this._ordingMode=e.Render2DOrderMode.elementIndex,this._renderHandle=this._createRenderHandle()}getRenderUpdateMode(){return this._lightReceive}_onAdded(){this.owner._initShaderData(),this.owner.renderNode2D=this,this._struct=this.owner._struct,this._spriteShaderData=this._struct.spriteShaderData,this.owner._struct.renderDataHandler=this._renderHandle,this.owner._struct.renderElements=this._renderElements,this.owner._struct.renderType=this._renderType,this.owner._updateStruct(),this._initDefaultRenderData&&this._initDefaultRenderData()}_onEnable(){this.owner.renderNode2D=this,super._onEnable(),this.owner.globalTrans._spTransChanged(e.TransformKind.TRS),this._lightReceive&&this._addRenderToLightManager()}_onDisable(){this.owner.renderNode2D=null,this._lightReceive&&this._removeRenderFromLightManager(),super._onDisable()}_getElementMaterial(e){return this._materials[e]||this._materials[0]}_onDestroy(){for(let e=0,t=this._renderElements.length;e<t;e++){let t=this._renderElements[e];t&&Dn._removeRenderElement2DMaterial(t,this._getElementMaterial(e))}this._struct.renderElements=[];for(var e=0,t=this._materials.length;e<t;e++){let t=this._materials[e];t&&!t.destroyed&&t._removeReference()}this._renderHandle.destroy()}_getRenderHandle(){return this._renderHandle}_createRenderHandle(){return f.render2DRenderPassFactory.create2DBaseRenderDataHandle()}_isMaterialVaild(e){return!0}get layer(){return this._layer}set layer(e){if(this._layer!==e){if(!(e>=0&&e<=30))throw new Error("Layer value must be 0-30.");this._removeRenderFromLightManager(),this._layer=e,this._addRenderToLightManager(),this._resetUpdateMark()}}get lightReceive(){return this._lightReceive}set lightReceive(e){e!==this._lightReceive&&(this._lightReceive=e,e?this._addRenderToLightManager():this._removeRenderFromLightManager(),this._renderHandle.lightReceive=e,this._resetUpdateMark())}_resetUpdateMark(){this._lightUpdateMark=0}_notifyDataChange(){var e;null===(e=this.owner)||void 0===e||e.repaint()}_updateLight(){if(!this.lightReceive||!this.owner.scene||!this.owner.scene._light2DManager)return;const e=this.owner.scene._light2DManager,t=e._getLayerUpdateMark(this.layer);this._lightUpdateMark!==t&&(this._lightUpdateMark=t,e._updateShaderDataByLayer(this.layer,this.owner._struct.spriteShaderData))}_addRenderToLightManager(){if(this.owner.scene){let e=this.owner.scene._light2DManager;e&&!this._lightRecord&&(e.addRender(this),this._lightRecord=!0)}}_removeRenderFromLightManager(){if(this.owner.scene){const e=this.owner.scene._light2DManager;e&&this._lightRecord&&(e.removeRender(this),this._lightRecord=!1)}}get sharedMaterial(){return this._materials[0]}set sharedMaterial(e){if(e&&!this._isMaterialVaild(e))return;const t=this._materials[0];t!==e&&(this._renderElements[0]&&Dn._removeRenderElement2DMaterial(this._renderElements[0],this._getElementMaterial(0)),this._materials[0]=e,this._changeMaterialReference(t,e),this._renderElements[0]&&Dn._setRenderElement2DMaterial(this._renderElements[0],this._getElementMaterial(0)))}_getRenderElements(){return this._renderElements}getRenderID(){return this._renderid}clear(){this._renderElements.length=0}}Dn._uniqueIDCounter=0;class wn{constructor(e,t){this.anyDirty=!1,this.baseSlot=e<<8;const r=t.createChunkBuffers(e,256,8);this.localTrs=r.localTrs,this.localAlpha=r.localAlpha,this.localFlags=r.localFlags,this.world=r.world,this.parent=r.parent,this.childCount=r.childCount,this.childrenInline=r.childrenInline,this.selfDirtyM=r.selfDirtyM,this.treeDirtyM=r.treeDirtyM,this.selfDirtyA=r.selfDirtyA,this.treeDirtyA=r.treeDirtyA,this.selfDirtyC=r.selfDirtyC,this.treeDirtyC=r.treeDirtyC,this.slotGen=r.slotGen,this.matrixFrame=r.matrixFrame,this.alphaFrame=r.alphaFrame,this.cullingFrame=r.cullingFrame,this.parent.fill(-1)}}const Rn=Math.PI/180,Cn=new Float32Array(6),Mn=new Float32Array(6),bn=new Float32Array(6),An=new Float32Array(6);function In(e,t,r){const s=e[t+0],i=e[t+1],a=e[t+2],n=e[t+3],o=e[t+4]*Rn,l=e[t+5]*Rn,h=e[t+6]*Rn,u=e[t+7],d=e[t+8],c=Math.cos(o),_=Math.sin(o),p=Math.cos(l),g=Math.sin(l),m=Math.cos(h),f=Math.sin(h),T=(c*m-_*f)*a,y=(_*m+c*f)*a,x=(c*g-_*p)*n,S=(_*g+c*p)*n;r[0]=T,r[1]=y,r[2]=x,r[3]=S,r[4]=s-T*u-x*d,r[5]=i-y*u-S*d}function Pn(e,t,r,s,i,a,n,o){const l=e[0],h=e[1],u=e[2],d=e[3],c=e[4],_=e[5];0!==r||0!==s?(o[0]=l*t+h*s,o[1]=l*r+h*i,o[2]=u*t+d*s,o[3]=u*r+d*i,o[4]=t*c+s*_+a,o[5]=r*c+i*_+n):(o[0]=l*t,o[1]=h*i,o[2]=u*t,o[3]=d*i,o[4]=t*c+a,o[5]=i*_+n)}class Bn{static get instance(){return this._instance||(this._instance=new Bn(f.render2DRenderPassFactory.createTransform2DMemoryFactory()))}constructor(e){this.chunks=[],this._count=0,this._freeList=[],this._spilled=[],this._freeSpilledIdx=[],this._owners=[],this._dirtyRoots=new Set,this._stack=[],this._curFrame=0,this._chainScratch=[],this._mem=e,this._control=e.createControlBuffer(4);const t=e.createChangedBuffers(256);this._changedSlots=t.slots,this._changedMasks=t.masks,this._changedCap=256}get dirtyM(){return 0!==this._control[0]}get dirtyA(){return 0!==this._control[1]}get dirtyC(){return 0!==this._control[2]}get changedSlots(){return this._changedSlots}get changedMasks(){return this._changedMasks}get changedCount(){return this._control[3]}alloc(){let e;this._freeList.length>0?e=this._freeList.pop():(e=this._count++,this._ensureChunk(e));const t=this.chunks[e>>8],r=255&e,s=9*r;t.localTrs[s+0]=0,t.localTrs[s+1]=0,t.localTrs[s+2]=1,t.localTrs[s+3]=1,t.localTrs[s+4]=0,t.localTrs[s+5]=0,t.localTrs[s+6]=0,t.localTrs[s+7]=0,t.localTrs[s+8]=0,t.localAlpha[r]=1,t.localFlags[r]=0;const i=8*r;return t.world[i+0]=1,t.world[i+1]=0,t.world[i+2]=0,t.world[i+3]=1,t.world[i+4]=0,t.world[i+5]=0,t.world[i+6]=1,t.world[i+7]=0,t.parent[r]=-1,t.childCount[r]=0,this._mark(t,r,7),e}free(e){const t=this._parentOf(e);-1!==t&&this._removeChild(t,e);const r=this.chunks[e>>8],s=255&e;r.parent[s]=-1,r.childCount[s]=0;const i=s>>5,a=~(1<<(31&s));r.selfDirtyM[i]&=a,r.selfDirtyA[i]&=a,r.selfDirtyC[i]&=a,r.slotGen[s]=r.slotGen[s]+1&65535,this._owners[e]=null,this._freeList.push(e)}genOf(e){return this.chunks[e>>8].slotGen[255&e]}setOwner(e,t){this._owners[e]=t}getOwner(e){return this._owners[e]}_ensureChunk(e){const t=e>>8;for(;this.chunks.length<=t;)this.chunks.push(new wn(this.chunks.length,this._mem));const r=this.chunks.length<<8;if(r>this._changedCap){const e=this._mem.createChangedBuffers(r);this._changedSlots=e.slots,this._changedMasks=e.masks,this._changedCap=r}}getParent(e){return this._parentOf(e)}setParent(e,t){const r=this._parentOf(e);r!==t&&(-1!==r&&this._removeChild(r,e),this.chunks[e>>8].parent[255&e]=t,-1!==t&&this._addChild(t,e),this.markDirty(e,7))}_parentOf(e){return this.chunks[e>>8].parent[255&e]}debugChildrenOf(e){const t=this.chunks[e>>8],r=255&e,s=t.childCount[r],i=8*r,a=[];if(s<=8)for(let e=0;e<s;e++)a.push(t.childrenInline[i+e]);else{const e=this._spilled[t.childrenInline[i+0]];for(let t=0;t<s;t++)a.push(e[t])}return a}_addChild(e,t){const r=this.chunks[e>>8],s=255&e,i=r.childCount[s],a=8*s;if(i<8)r.childrenInline[a+i]=t;else if(8===i){const e=new Array(9);for(let t=0;t<8;t++)e[t]=r.childrenInline[a+t];e[8]=t,r.childrenInline[a+0]=this._allocSpill(e)}else this._spilled[r.childrenInline[a+0]].push(t);r.childCount[s]=i+1}_removeChild(e,t){const r=this.chunks[e>>8],s=255&e,i=r.childCount[s],a=8*s;if(i<=8){for(let e=0;e<i;e++)if(r.childrenInline[a+e]===t){r.childrenInline[a+e]=r.childrenInline[a+i-1];break}r.childCount[s]=i-1}else{const e=r.childrenInline[a+0],n=this._spilled[e];for(let e=0;e<n.length;e++)if(n[e]===t){n[e]=n[n.length-1],n.pop();break}const o=i-1;if(r.childCount[s]=o,8===o){for(let e=0;e<8;e++)r.childrenInline[a+e]=n[e];this._freeSpill(e)}}}_allocSpill(e){if(this._freeSpilledIdx.length>0){const t=this._freeSpilledIdx.pop();return this._spilled[t]=e,t}return this._spilled.push(e),this._spilled.length-1}_freeSpill(e){this._spilled[e]=null,this._freeSpilledIdx.push(e)}writeTRS(e,t,r){const s=this.chunks[e>>8],i=255&e;s.localTrs[9*i+t]=r,this._mark(s,i,1)}writeTRSAll(e,t,r,s,i,a,n,o,l,h){const u=this.chunks[e>>8],d=255&e,c=9*d;u.localTrs[c+0]=t,u.localTrs[c+1]=r,u.localTrs[c+2]=s,u.localTrs[c+3]=i,u.localTrs[c+4]=a,u.localTrs[c+5]=n,u.localTrs[c+6]=o,u.localTrs[c+7]=l,u.localTrs[c+8]=h,this._mark(u,d,1)}readTRS(e,t){return this.chunks[e>>8].localTrs[9*(255&e)+t]}writeAlpha(e,t){const r=this.chunks[e>>8],s=255&e;r.localAlpha[s]=t,this._mark(r,s,2)}readAlpha(e){return this.chunks[e>>8].localAlpha[255&e]}writeCulling(e,t){const r=this.chunks[e>>8],s=255&e;t?r.localFlags[s]|=1:r.localFlags[s]&=-2,this._mark(r,s,4)}readCulling(e){return!!(1&this.chunks[e>>8].localFlags[255&e])}markDirty(e,t){this._mark(this.chunks[e>>8],255&e,t)}_mark(e,t,r){const s=t>>5,i=1<<(31&t),a=this._control;1&r&&(e.selfDirtyM[s]|=i,a[0]=1),2&r&&(e.selfDirtyA[s]|=i,a[1]=1),4&r&&(e.selfDirtyC[s]|=i,a[2]=1),e.anyDirty=!0}update(e){this._curFrame=e,Bn.sweeper?Bn.sweeper.update(this,e):this._MainSweep()}_MainSweep(){const e=this._control;e[3]=0,(e[0]||e[1]||e[2])&&(this._dirtyRoots.clear(),e[0]&&this._markChannel(1),e[1]&&this._markChannel(2),e[2]&&this._markChannel(4),this._sweep(),this._clearDirty(),e[0]=e[1]=e[2]=0)}_markChannel(e){const t=this.chunks;for(let r=0;r<t.length;r++){const s=t[r];if(!s.anyDirty)continue;const i=1===e?s.selfDirtyM:2===e?s.selfDirtyA:s.selfDirtyC;for(let t=0;t<8;t++){let r=i[t];for(;0!==r;){const i=r&-r,a=31-Math.clz32(i);r&=r-1,this._bubble(s.baseSlot+(t<<5)+a,e)}}}}_bubble(e,t){let r=this._parentOf(e);if(-1!==r)for(;;){if(this._testTree(r,t))return;this._setTree(r,t);const e=this._parentOf(r);if(-1===e)return void this._dirtyRoots.add(r);r=e}else this._dirtyRoots.add(e)}_testTree(e,t){const r=this.chunks[e>>8],s=255&e,i=s>>5,a=1<<(31&s);return 0!==((1===t?r.treeDirtyM:2===t?r.treeDirtyA:r.treeDirtyC)[i]&a)}_setTree(e,t){const r=this.chunks[e>>8],s=255&e,i=s>>5,a=1<<(31&s);1===t?r.treeDirtyM[i]|=a:2===t?r.treeDirtyA[i]|=a:r.treeDirtyC[i]|=a,r.anyDirty=!0}_sweep(){const e=this._stack;let t=0;for(const r of this._dirtyRoots)e[t++]=r<<3;const r=this.chunks;for(;t>0;){const s=e[--t],i=s>>>3,a=7&s,n=r[i>>8],o=255&i,l=o>>5,h=1<<(31&o),u=n.selfDirtyM[l]&h,d=n.treeDirtyM[l]&h,c=n.selfDirtyA[l]&h,_=n.treeDirtyA[l]&h,p=n.selfDirtyC[l]&h,g=n.treeDirtyC[l]&h,m=1&a||u,f=2&a||c,T=4&a||p;if(!(m||f||T||d||_||g))continue;const y=n.parent[o];let x=1,S=0,E=0,v=1,D=0,w=0,R=1,C=0;if(-1!==y){const e=r[y>>8],t=8*(255&y);x=e.world[t+0],S=e.world[t+1],E=e.world[t+2],v=e.world[t+3],D=e.world[t+4],w=e.world[t+5],R=e.world[t+6],C=1&e.world[t+7]?1:0}const M=8*o,b=n.world,A=this._curFrame;let I=0;if(m&&(In(n.localTrs,9*o,Cn),Pn(Cn,x,S,E,v,D,w,Mn),b[M+0]===Mn[0]&&b[M+1]===Mn[1]&&b[M+2]===Mn[2]&&b[M+3]===Mn[3]&&b[M+4]===Mn[4]&&b[M+5]===Mn[5]||(b[M+0]=Mn[0],b[M+1]=Mn[1],b[M+2]=Mn[2],b[M+3]=Mn[3],b[M+4]=Mn[4],b[M+5]=Mn[5],n.matrixFrame[o]=A,I|=1)),f){const e=R*n.localAlpha[o];b[M+6]!==e&&(b[M+6]=e,n.alphaFrame[o]=A,I|=2)}if(T){const e=(1&n.localFlags[o]?1:0)|C,t=b[M+7],r=-2&t|(e?1:0);t!==r&&(b[M+7]=r,n.cullingFrame[o]=A,I|=4)}if(0!==I){const e=this._control[3];this._changedSlots[e]=i,this._changedMasks[e]=I,this._control[3]=e+1}if(0!==I||d||_||g){const r=n.childCount[o];if(r>0){const s=8*o;if(r<=8)for(let i=0;i<r;i++)e[t++]=n.childrenInline[s+i]<<3|I;else{const i=this._spilled[n.childrenInline[s+0]];for(let s=0;s<r;s++)e[t++]=i[s]<<3|I}}}}}_clearDirty(){const e=this.chunks;for(let t=0;t<e.length;t++){const r=e[t];r.anyDirty&&(r.selfDirtyM.fill(0),r.treeDirtyM.fill(0),r.selfDirtyA.fill(0),r.treeDirtyA.fill(0),r.selfDirtyC.fill(0),r.treeDirtyC.fill(0),r.anyDirty=!1)}}readWorldMatrix(e,t){const r=8*(255&e),s=this.chunks[e>>8].world;t[0]=s[r+0],t[1]=s[r+1],t[2]=s[r+2],t[3]=s[r+3],t[4]=s[r+4],t[5]=s[r+5]}getWorldAlpha(e){return this.chunks[e>>8].world[8*(255&e)+6]}getRelativeWorldAlpha(e,t,r){if(t===e)return 1;if(!r){const r=this.getWorldAlpha(t);if(r>1e-6)return this.getWorldAlpha(e)/r}let s=1,i=e;for(;-1!==i&&i!==t;){const e=this.chunks[i>>8];s=Math.fround(s*e.localAlpha[255&i]),i=e.parent[255&i]}return s}getWorldCulling(e){return!!(1&this.chunks[e>>8].world[8*(255&e)+7])}getMatrixFrame(e){return e<0?this._curFrame:this.chunks[e>>8].matrixFrame[255&e]}getAlphaFrame(e){return e<0?this._curFrame:this.chunks[e>>8].alphaFrame[255&e]}getCullingFrame(e){return e<0?this._curFrame:this.chunks[e>>8].cullingFrame[255&e]}computeWorldMatrix(e,t){const r=this._chainScratch;r.length=0;let s=e;for(;-1!==s;)r.push(s),s=this._parentOf(s);let i=bn,a=An;const n=r[r.length-1];In(this.chunks[n>>8].localTrs,9*(255&n),Cn),i[0]=Cn[0],i[1]=Cn[1],i[2]=Cn[2],i[3]=Cn[3],i[4]=Cn[4],i[5]=Cn[5];for(let e=r.length-2;e>=0;e--){const t=r[e];In(this.chunks[t>>8].localTrs,9*(255&t),Cn),Pn(Cn,i[0],i[1],i[2],i[3],i[4],i[5],Mn),a[0]=Mn[0],a[1]=Mn[1],a[2]=Mn[2],a[3]=Mn[3],a[4]=Mn[4],a[5]=Mn[5];const s=i;i=a,a=s}t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5]}computeWorldAlpha(e){let t=1,r=e;for(;-1!==r;){const e=this.chunks[r>>8];t=Math.fround(t*e.localAlpha[255&r]),r=e.parent[255&r]}return t}computeWorldCulling(e){let t=e;for(;-1!==t;){const e=this.chunks[t>>8],r=255&t;if(1&e.localFlags[r])return!0;t=e.parent[r]}return!1}}Bn.sweeper=null;class Ln{constructor(e){this.slot=-1,this._modifiedFrame=0,this._hasChangedListener=!1,this._sp=e,this._cache=!0;const t=Bn.instance;this.slot=t.alloc(),t.setOwner(this.slot,e),this._notifyRenderSpriteTransChange()}get cache(){return this._cache}set cache(e){this._cache=e}getMatrix(){const e=this._matrix||(this._matrix=new Ce),t=Bn.instance,r=this.slot;return t.dirtyM?t.computeWorldMatrix(r,On):t.readWorldMatrix(r,On),e.a=On[0],e.b=On[1],e.c=On[2],e.d=On[3],e.tx=On[4],e.ty=On[5],e._checkTransform(),e}getMatrixInv(e){return this.getMatrix().copyTo(e),e.invert(),e}get x(){return this.getPos(Nn).x}get y(){return this.getPos(Nn).y}getSceneMatrix(e){return this._sp.scene?(this._sp.scene.globalTrans.getMatrixInv(Fn).copyTo(e),Ce.mul(this.getMatrix(),e,e),e):this.getMatrix()}getScenePos(e){return this._sp.scene?this._sp.scene.globalTrans.getMatrixInv(Fn).transformPoint(this.getPos(e)):this.getPos(e)}getSceneScale(e){if(e.x=this.scaleX,e.y=this.scaleY,this._sp.scene){const t=this._sp.scene.globalTrans.getMatrix();e.x/=t.getScaleX(),e.y/=t.getScaleY()}return e}getSceneRotation(){let e=this.rotation;return this._sp.scene&&(e-=this._sp.scene.globalTrans.rotation),e}getPos(e){return this._cache?this.getMatrix().transformPoint(e.setTo(this._sp.pivotX,this._sp.pivotY)):(this._sp.localToGlobal(e.setTo(0,0),!1,null),e)}setPos(e,t){let r=this._sp;if(this._cache&&r._parent instanceof po){let s=r._parent.globalTrans.getMatrix().invertTransformPoint(Nn.setTo(e,t));r.pos(s.x,s.y)}else{Nn.setTo(e,t);let s=r.globalToLocal(Nn,!1,null);s=r.toParentPoint(s),r.pos(s.x,s.y)}}get rotation(){let e=this._sp;return e._parent&&e._parent!==e._scene?e._rotation+e._parent.globalTrans.rotation:e._rotation}set rotation(e){if(e==this.rotation)return;let t=this._sp;t._parent&&t._parent!==t._scene?t.rotation=e-t._parent.globalTrans.rotation:t.rotation=e}get scaleX(){return this.getMatrix().getScaleX()}get scaleY(){return this.getMatrix().getScaleY()}get globalAlpha(){const e=Bn.instance,t=this.slot;return e.dirtyA?e.computeWorldAlpha(t):e.getWorldAlpha(t)}get invertGlobalAlpha(){const e=this.globalAlpha;return e>1e-6?1/e:0}_notifyRenderSpriteTransChange(){this._sp._renderType&Mr.UPDATETRANS&&(l.stage._tranMatrixUpdateList.add(this._sp),this._modifiedFrame=Ua.loopCount)}_spTransChanged(e){const t=this._sp;Bn.instance.writeTRSAll(this.slot,t._x,t._y,t._scaleX,t._scaleY,t._rotation,t._skewX,t._skewY,t._pivotX,t._pivotY),this._notifyRenderSpriteTransChange()}localToGlobal(e,t){return this._cache?this.getMatrix().transformPoint(Nn.setTo(this._sp.pivotX+e,this._sp.pivotY+t)):this._sp.localToGlobal(Nn.setTo(e,t))}globalToLocal(e,t){if(this._cache){let r=this.getMatrix().invertTransformPoint(Nn.setTo(e,t));return r.x-=this._sp.pivotX,r.y-=this._sp.pivotY,r}return this._sp.globalToLocal(Nn.setTo(e,t))}destroy(){-1!==this.slot&&(Bn.instance.free(this.slot),this.slot=-1),this._sp=null,this._matrix=null}}Ln.CHANGED="globalTransChanged";const Nn=new d,Fn=new Ce,On=new Float32Array(6);class Un{constructor(){this._renderElement=null,this._spriteShaderData=null,this._primitiveShaderData=null,this._handle=null,this._blendMode=-1,this._textureHost=null,this._vertexSize=new i,this._rtRect=new te,this._oriRect=new te,this._needUpdateVertexSize=!0,this._renderElements=[],this._scaleX=1,this._scaleY=1,this._spriteShaderData=f.renderDeviceFactory.createShaderData(),this._primitiveShaderData=f.renderDeviceFactory.createShaderData(),this._initPrimitiveShaderData(),this._handle=f.render2DRenderPassFactory.createSubStructRenderDataHandle(),this._renderElement=f.render2DRenderPassFactory.createPrimitiveRenderElement2D(),this._renderElement.value2DShaderData=this._spriteShaderData,this._renderElement.subShader=Ut.graphicsShader.getSubShaderAt(0),this._renderElement.primitiveShaderData=this._primitiveShaderData,this._renderElement.nodeCommonMap=["Sprite2D"],this._renderElement.geometry=va.runner.inv_geometry,this._renderElement.renderStateIsBySprite=!1,this._renderElement.noBatch=!0,zt.initBlendMode(this._spriteShaderData),this._renderElements=[this._renderElement]}_initPrimitiveShaderData(){let e=this._primitiveShaderData;e.addDefine(kt.TEXTURESHADER),e.addDefine(kt.VERTEX_SIZE),"gpu"===t.uvClipMode&&e.addDefine(kt.UV_CLIP_GPU),e.setTexture(kt.UNIFORM_SPRITETEXTURE,Hi.whiteTexture),zt.initBlendMode(e)}bind(t,r,s){this._sprite=t,this._subRenderPass=r,this._subStruct=s,this._subStruct.spriteShaderData=this._spriteShaderData,this._subStruct.renderType=e.BaseRender2DType.graphics,s.renderDataHandler=this._handle,s.renderMatrix=t.globalTrans.getMatrix(),s.renderElements=this._renderElements,this._renderElement.owner=this._subStruct,this._syncRenderElementKeys()}_updateRenderOffset(e,t,r,s){e.equals(this._rtRect)&&t.equals(this._oriRect)&&r===this._scaleX&&s===this._scaleY||(this._needUpdateVertexSize=!0),e.cloneTo(this._rtRect),t.cloneTo(this._oriRect),this._scaleX=r,this._scaleY=s;let i=this._subRenderPass,a=i.offsetMatrix,n=this._sprite;n.mask?this._updateLogicMatrix(n.mask,n.globalTrans.getMatrix(),e.x,e.y,a):n._maskParent&&n.transform?this._updateLogicMatrix(n,n.globalTrans.getMatrix(),e.x,e.y,a):(this._handle.logicMatrix=null,a.identity(),a.tx=e.x,a.ty=e.y),a.scale(1/r,1/s),i.offsetMatrix=a}_updateLogicMatrix(e,t,r,s,i){this._logicMatrix||(this._logicMatrix=new Ce);let a=this._logicMatrix,n=e.globalTrans.getMatrix(),o=(e.parent?e.parent:e._maskParent).globalTrans.getMatrix();o.copyTo(a);let l=e.x-e._pivotX,h=e.y-e._pivotY;a.tx=l*o.a+h*o.c+o.tx,a.ty=l*o.b+h*o.d+o.ty,a.copyTo(i),Ce.mul(a,t.copyTo(Ce.TEMP).invert(),a),this._handle.logicMatrix=this._logicMatrix,i.tx=r*i.a+s*i.c+i.tx,i.ty=r*i.b+s*i.d+i.ty,Ce.mul(n,i.invert(),i),i.invert()}_clearRenderTexture(){this._textureHost&&(this._primitiveShaderData.setTexture(kt.UNIFORM_SPRITETEXTURE,Hi.whiteTexture),this._textureHost=null)}_updateRenderTexture(e,t){var r;this._handle.mask=null===(r=this._sprite.mask)||void 0===r?void 0:r._struct,this._blendMode!==this._subStruct.blendMode&&(this._blendMode=this._subStruct.blendMode,zt.setShaderData(this._subStruct.blendMode,this._spriteShaderData),zt.setShaderData(this._subStruct.blendMode,this._primitiveShaderData),this._syncRenderElementKeys()),(this._textureHost!=t||this._needUpdateVertexSize)&&(this._textureHost=t,this._updateTextureState(t),this._updateVertexSize(t),this._needUpdateVertexSize=!1)}_updateTextureState(e){this._primitiveShaderData.setTexture(kt.UNIFORM_SPRITETEXTURE,e||Hi.whiteTexture),e&&1!=e.gammaCorrection?this._primitiveShaderData.addDefine(kt.GAMMATEXTURE):this._primitiveShaderData.removeDefine(kt.GAMMATEXTURE),this._syncRenderElementKeys()}_syncRenderElementKeys(){let e=kt.getPerElementDefineBits(this._primitiveShaderData);this._renderElement.typeKey=this._subStruct?this._subStruct.blendMode|e:e,this._renderElement.textureKey=this._textureHost?this._textureHost._id:0}_updateVertexSize(e){let t=this._rtRect,r=this._vertexSize;r.x=t.x/this._scaleX,r.y=t.y/this._scaleY;let s=e?e.sourceWidth:0,i=e?e.sourceHeight:0;s>0&&i>0?(r.x=(t.x-(s-t.width)/2)/this._scaleX,r.y=(t.y-(i-t.height)/2)/this._scaleY,r.z=s/this._scaleX,r.w=i/this._scaleY):(r.z=t.width/this._scaleX,r.w=t.height/this._scaleY),this._primitiveShaderData.setVector(kt.UNIFORM_VERTEX_SIZE,r)}destroy(){this._renderElement.geometry=null,this._renderElement.primitiveShaderData=null,this._renderElement.value2DShaderData=null,this._renderElement.destroy(),this._renderElement=null,this._renderElements.length=0,this._primitiveShaderData.destroy(),this._spriteShaderData.destroy(),this._primitiveShaderData=null,this._spriteShaderData=null,this._handle.destroy(),this._handle=null,this._subRenderPass=null,this._subStruct=null,this._sprite=null}}const kn=[],Gn=[],Vn=[];let zn=new Int32Array(32),Hn=new Uint8Array(8);const Wn="$spriteTexture";class Xn{constructor(t,r){this._renderer=t,this.ops=[],this._activeIndex=-1,this._activeId="",this._activeOp=null,this._targetOp=null,this._targetWrote=!1,this._lastTargetWrote=!1,this._activeMultiQuad=null,this._drawImageOp=null,this._drawImageLastIndex=-2,this._reuseOps=!1,this._oldOpCount=0,this._topologyChanged=!1,this._textures=new Map,this._spriteTexture=null,this._spriteOp=null,this._spriteOpIndex=-1,this._ownerDependencyMask=e.GraphicsOwnerTransformDependency.None,this._dataHandle=f.render2DRenderPassFactory.createGraphicsCommandStreamDataHandle(),this._dataHandle.setGraphicsHandleUpdateBuffer(r)}get opCount(){return this.ops.length}getDataHandle(){return this._dataHandle}getOp(e){return this.ops[e]}getOwnerTransformDependencyMask(){return this._ownerDependencyMask}beginCommand(e,t,r=null){let s=!r&&t===fs.ID;s&&e===this._drawImageLastIndex+1||this._flushDrawImageGroup(),this._activeIndex=e,this._activeId=t,this._activeOp=s?this._drawImageOp:null,this._targetOp=r,this._targetWrote=!1}endCommand(){this._activeId!==fs.ID||this._targetOp||(this._drawImageOp=this._activeOp,this._drawImageLastIndex=this._activeIndex),this._lastTargetWrote=this._targetWrote,this._activeIndex=-1,this._activeId="",this._activeOp=null,this._targetOp=null,this._targetWrote=!1}getTextureQuadTargetOp(){return this._targetOp?this._targetOp:this._activeId===fs.ID||this._activeId===Bs.ID||this._activeId===ts.ID?this._activeOp||this._appendOp(5):this._activeId===wa.ID?this._activeOp||this._appendOp(6):this._appendOp(1)}_appendOp(e){let t=null,r=this.ops.length;if(this._reuseOps&&r<this._oldOpCount){let s=Gn[r];s&&s.kind===e&&s.commandIndex===this._activeIndex&&s.canUpdate(this._activeId)&&(t=s,Gn[r]=null,t.resetRecords(),t.setCommandIndex(this._activeIndex))}return t||(t=this._createOp(e),this._reuseOps&&(this._topologyChanged=!0)),this.ops.push(t),this._activeOp=t,t}_createOp(e){let t=Yr._factory;switch(e){case 1:return t.createTextureQuadOp(this._activeIndex,this._activeId);case 2:return t.createSolidQuadOp(this._activeIndex,this._activeId);case 3:return t.createFillTextureOp(this._activeIndex,this._activeId);case 5:return t.createMultiQuadOp(this._activeIndex,this._activeId);case 6:return t.createTextOp(this._activeIndex,this._activeId);default:return t.createMeshOp(this._activeIndex,this._activeId)}}_beginActiveCommandTextures(){this._activeId===fs.ID&&this._activeOp===this._drawImageOp&&this._activeMultiQuad===this._drawImageOp||(this._activeMultiQuad=null,Vn.length=0)}finalizeActiveCommandTextures(){(this._activeId!==fs.ID||this._targetOp)&&this._flushActiveMultiQuad()}_flushActiveMultiQuad(){this._activeMultiQuad&&this._activeMultiQuad.setTextures(Vn,Vn.length),this._activeMultiQuad=null,Vn.length=0}_flushDrawImageGroup(){this._drawImageOp&&(this._flushActiveMultiQuad(),this._drawImageOp=null,this._drawImageLastIndex=-2)}endCompile(){this._flushDrawImageGroup()}_recordActiveMultiQuadTexture(e,t){this._activeMultiQuad&&this._activeMultiQuad!==e&&this.finalizeActiveCommandTextures(),this._activeMultiQuad||(this._activeMultiQuad=e,Vn.length=0),Vn[e.recordCount]=t||null}_markTextureQuadWritten(){this._targetOp&&(this._targetWrote=!0)}_prepareTexture(e,t=!1){return!(!e||e.destroyed)&&(t?this._setSpriteTexture(e):this._targetOp||this._addTextureIndex(e,this._activeIndex),!!e.valid||(this._renderer.requestTextureRecovery(e),!1))}_addTextureIndex(e,t){let r=this._textures.get(e.id);if(!r)return r={texture:e,indices:t},this._textures.set(e.id,r),void(e!==this._spriteTexture&&e.on(c.CHANGE,this,this._onTextureChange,[e]));let s=r.indices;-1!==s?"number"==typeof s?s!==t&&(r.indices=[s,t]):s.indexOf(t)<0&&s.push(t):r.indices=t}_removeTextureIndex(e,t){let r=this._textures.get(e.id);if(!r||r.texture!==e)return;let s=r.indices;if("number"!=typeof s){let e=s.indexOf(t);if(e<0)return;if(s.splice(e,1),s.length>1)return;if(1===s.length)return void(r.indices=s[0])}else if(s!==t)return;r.indices=-1}_deleteTextureEntry(e){this._textures.delete(e.texture.id),e.texture!==this._spriteTexture&&e.texture.off(c.CHANGE,this,this._onTextureChange)}_clearCommandTextures(){this._textures.forEach(this._detachCommandTexture,this),this._textures.clear()}_detachCommandTexture(e){e.texture!==this._spriteTexture&&e.texture.off(c.CHANGE,this,this._onTextureChange)}_prepareTextureIndex(e){e?this._textures.forEach(this._markTextureUnused):this._clearCommandTextures()}_markTextureUnused(e){e.indices=-1}_pruneTextureIndex(){this._textures.size<=64||this._textures.forEach(this._pruneTextureEntry,this)}_pruneTextureEntry(e){-1===e.indices&&this._deleteTextureEntry(e)}_setSpriteTexture(e){if(this._spriteTexture===e)return;let t=this._spriteTexture;this._spriteTexture=e,this._textures.has(e.id)||e.on(c.CHANGE,this,this._onTextureChange,[e]),t&&!this._textures.has(t.id)&&t.off(c.CHANGE,this,this._onTextureChange)}clearSpriteTextureDependency(){let e=this._spriteTexture;this._spriteTexture=null,this._spriteOp=null,this._spriteOpIndex=-1,e&&!this._textures.has(e.id)&&e.off(c.CHANGE,this,this._onTextureChange)}_onTextureChange(e){let t=this._textures.get(e.id);(e===this._spriteTexture||t&&t.texture===e&&-1!==t.indices)&&(e.valid||this._renderer.requestTextureRecovery(e),this._renderer._scheduleGraphicsRebuild())}_ensureRebuildCapacity(e){if(e<=Hn.length)return;let t=Math.max(8,Hn.length);for(;t<e;)t<<=1;zn=new Int32Array(4*t),Hn=new Uint8Array(t)}_beginRebuild(){let e=this.ops.length;if(this._oldOpCount=e,this._reuseOps=e>0,this._topologyChanged=!1,this._reuseOps){this._ensureRebuildCapacity(e),Gn.length=e;for(let t=0;t<e;t++){let e=this.ops[t];Gn[t]=e,e.writeStructureSignature(zn,4*t),Hn[t]=1&e.dirtyFlags?1:0}}else Gn.length=0;this.ops.length=0,this._spriteOp=null,this._spriteOpIndex=-1}_finishRebuild(){if(!this._reuseOps)return this._topologyChanged=this._topologyChanged||this.ops.length>0,this._topologyChanged;this.ops.length!==this._oldOpCount&&(this._topologyChanged=!0);for(let e=0;e<this._oldOpCount;e++){let t=Gn[e];if(t)t.destroy(),this._topologyChanged=!0;else{let t=this.ops[e];Hn[e]||!t.matchesStructureSignature(zn,4*e)?(this._topologyChanged=!0,t.markDirty(1)):t.clearStructureDirty()}Gn[e]=null,Hn[e]=0}return Gn.length=0,this._reuseOps=!1,this._topologyChanged}rebuild(e){let t=this._renderer,r=t.owner,s=t.graphics;this._prepareTextureIndex(this.ops.length>0),this._beginRebuild(),t._syncGraphicsOwnerSize();let i=va.compileContext;if(i.begin(this,r,r._struct.blendMode,e._textRender),s){let e=s.cmds;for(let t=0,r=e.length;t<r;t++)i.compileCommand(t,e[t])}this._ownerDependencyMask=i.getOwnerDependencyMask(),r._texture?this._appendSpriteTexture(i):this.clearSpriteTextureDependency(),i.end(),this._pruneTextureIndex();let a=this._finishRebuild(),n=0;for(let e=0,t=this.ops.length;e<t;e++)n|=this.ops[e].dirtyFlags;t._syncGraphicsOps(t._mapGraphicsOpDirtyFlags(n),0,this.ops.length,!0,a)}_appendSpriteTexture(e){let t=this._renderer.owner,r=t._texture;if(this.beginCommand(-1,Wn),this._prepareTexture(r,!0)){let s=this._appendOp(1);e._writeSpriteTextureOp(s,t,r),this._spriteOp=s,this._spriteOpIndex=this.ops.length-1}this.endCommand()}patchSpriteTexture(){let e=this._renderer.owner,t=e._texture,r=this._spriteOp;if(!t||!r||this.ops[this._spriteOpIndex]!==r)return!1;let s=va.compileContext,i=va.runner;s.begin(this,e,e._struct.blendMode,i._textRender),this.beginCommand(-1,Wn,r);let a=this._prepareTexture(t,!0)&&s._writeSpriteTextureOp(r,e,t);if(this.endCommand(),s.end(),!a)return!1;let n=this._renderer._mapGraphicsOpDirtyFlags(r.dirtyFlags);return 0!==n&&this._renderer._syncGraphicsOps(n,this._spriteOpIndex,1,!1,!1),!0}patchFrameAnimation(e,t,r){let s=e.op,i=e.opStart;if(!s||r.matrix||1!==e.opCount||this.ops[i]!==s||1!==s.kind)return-1;let a=this._renderer.owner,n=va.runner,o=va.compileContext;if(o.begin(this,a,a._struct.blendMode,n._textRender),o.compileCommand(e.commandIndex,r,s),o.end(),!this._lastTargetWrote)return-1;t.texture!==r.texture&&(this._removeTextureIndex(t.texture,e.commandIndex),this._addTextureIndex(r.texture,e.commandIndex));let l=this._renderer._mapGraphicsOpDirtyFlags(s.dirtyFlags);return 0===l?0:(this._renderer._syncGraphicsOps(l,i,1,!1,!1),1)}markSubmitted(e=0,t=this.ops.length,r=!1){let s=Math.min(e+t,this.ops.length);for(let t=Math.max(0,e);t<s;t++){let e=this.ops[t];r?e.dirtyFlags=0:e.clearDirty()}}clear(t=!1){this._clearCommandTextures(),this.clearSpriteTextureDependency();for(let e=0,t=this.ops.length;e<t;e++)this.ops[e].destroy();this.ops.length=0,this._ownerDependencyMask=e.GraphicsOwnerTransformDependency.None,t&&this._dataHandle.syncGraphicsOps(kn)}clearTextureDependencies(){this._clearCommandTextures(),this.clearSpriteTextureDependency()}deactivate(){this._dataHandle.deactivateGraphicsOps()}destroy(){this.clear(),this._dataHandle.destroy(),this._dataHandle=null,this._renderer=null}}class Yn{static classify(e,t){let r=t&&t.cmds,s=r?r.length:0;if(e)return 0===s?4:0;if(1!==s)return 0;let i=r[0];switch(i.cmdID){case Is.ID:case fs.ID:return 1;case js.ID:{let e=i.type;return"repeat"===e||"repeat-x"===e||"repeat-y"===e||"no-repeat"===e?2:0}case bs.ID:{let e=i;return null!=e.fillColor&&(null==e.lineColor||e.lineWidth<=0)?3:0}}return 0}constructor(e,t){this._renderer=e,this._dataHandle=null,this._payloadBuffer=null,this._payloadInt32=null,this._payloadFloat32=null,this._submittedPayload=null,this._submittedResource=null,this._submittedResourceInternal=null,this._submitted=!1,this._texture=null,this._resource=null,this._dependsOnSize=!1,this._payloadBuffer=new ArrayBuffer(128),this._payloadInt32=new Int32Array(this._payloadBuffer),this._payloadFloat32=new Float32Array(this._payloadBuffer),this._submittedPayload=new Int32Array(32),this._dataHandle=f.render2DRenderPassFactory.createGraphicsSingleQuadDataHandle(),this._dataHandle.setGraphicsHandleUpdateBuffer(t),this._dataHandle.setSingleQuadPayloadBuffer(this._payloadBuffer)}getDataHandle(){return this._dataHandle}getDependsOnSize(){return this._dependsOnSize}render(e,t){if(4===t)return this._renderSpriteTexture();let r=e.cmds[0],s=r._cacheData;switch(s&&"FrameAnimation"===s.kind&&(s.commandIndex=0,s.opStart=-1,s.opCount=0,s.op=null),t){case 1:return this._renderTextureCommand(r);case 2:return this._renderFillTextureCommand(r);default:return this._renderSolidQuadCommand(r)}}patchFrameAnimation(e){return this._renderTextureCommand(e)?1:0}clear(){this._clearTextureRef(),this._dependsOnSize=!1,this._submitted=!1,this._submittedResource=null,this._submittedResourceInternal=null}deactivate(){this._dataHandle.deactivateSingleQuad()}destroy(){this.clear(),this._dataHandle.destroy(),this._dataHandle=null,this._payloadBuffer=null,this._payloadInt32=null,this._payloadFloat32=null,this._submittedPayload=null,this._renderer=null}_renderSpriteTexture(){let e=this._renderer.owner,t=e._texture,r=this._prepareTexture(t);this._beginPayload(1,0,4294967295,e._struct.blendMode,1,r);let s=this._payloadFloat32,i=t.sourceWidth||t.width||1,a=t.sourceHeight||t.height||1,n=(e._isWidthSet?e._width:i)/i,o=(e._isHeightSet?e._height:a)/a;s[6]=t.offsetX*n,s[7]=t.offsetY*o,s[8]=t.width*n,s[9]=t.height*o;let l=t._uv||t.uv||ie.DEF_UV;return this._writeUV(l),s[26]=1,s[27]=1,this._submitPayload(!1)}_renderTextureCommand(e){let t=e.texture,r=this._prepareTexture(t),s=this._renderer.owner,i=e.cmdID===Is.ID?e:null,a=(i&&i.percent?1:0)|(i&&i.matrix?2:0),n=i&&i.blendMode?nr.parseBlendMode(i.blendMode):s._struct.blendMode;this._beginPayload(1,a,null==e.color?4294967295:e.color,n,i?i.alpha:1,r);let o=this._payloadFloat32;o[6]=e.x,o[7]=e.y,o[8]=e.width,o[9]=e.height;let l=i?i.uv||(null==t?void 0:t._uv)||ie.DEF_UV:(null==t?void 0:t._uv)||ie.DEF_UV;this._writeUV(l);let h=t&&(t.sourceWidth||t.width)||1,u=t&&(t.sourceHeight||t.height)||1;o[24]=t?t.offsetX/h:0,o[25]=t?t.offsetY/u:0,o[26]=t?t.width/h:1,o[27]=t?t.height/u:1;let d=i&&i.matrix;return o[18]=d?d.a:1,o[19]=d?d.b:0,o[20]=d?d.c:0,o[21]=d?d.d:1,o[22]=d?d.tx:0,o[23]=d?d.ty:0,this._submitPayload(!(!i||!i.percent))}_renderFillTextureCommand(e){let t=e.texture,r=this._prepareTexture(t),s="repeat"===e.type||"repeat-x"===e.type,i="repeat"===e.type||"repeat-y"===e.type,a=(e.percent?1:0)|(s?4:0)|(i?8:0);this._beginPayload(2,a,null==e.color?4294967295:e.color,this._renderer.owner._struct.blendMode,1,r);let n=this._payloadFloat32;n[6]=e.x,n[7]=e.y,n[8]=e.width,n[9]=e.height,n[24]=e.offset?e.offset.x:0,n[25]=e.offset?e.offset.y:0;let o=t&&(t.sourceWidth||t.width)||1,l=t&&(t.sourceHeight||t.height)||1;n[26]=o,n[27]=l,n[18]=t?t.offsetX/o:0,n[19]=t?t.offsetY/l:0,n[20]=t?t.width/o:1,n[21]=t?t.height/l:1;let h=t&&t.uvrect;return n[28]=h?h[0]:0,n[29]=h?h[1]:0,n[30]=h?h[2]:1,n[31]=h?h[3]:1,this._submitPayload(!!e.percent)}_renderSolidQuadCommand(e){this._clearTextureRef();let t="number"==typeof e.fillColor?e.fillColor:zr.create(e.fillColor).numColor;this._beginPayload(3,e.percent?1:0,t,this._renderer.owner._struct.blendMode,1,0);let r=this._payloadFloat32;return r[6]=e.x,r[7]=e.y,r[8]=e.width,r[9]=e.height,this._submitPayload(!!e.percent)}_beginPayload(e,t,r,s,i,a){let n=this._payloadInt32,o=this._payloadFloat32;n.fill(0),n[0]=e,n[1]=t,n[2]=r,n[3]=s,n[4]=a,o[5]=i,o[18]=1,o[21]=1}_submitPayload(e){this._dependsOnSize=e,this._renderer._syncGraphicsOwnerSize();let t=this._resource?this._resource._texture:null,r=!this._submitted,s=r||this._submittedResource!==this._resource||this._submittedResourceInternal!==t,i=!this._submittedResource&&!!this._resource,a=r||this._submittedPayload[0]!==this._payloadInt32[0]||this._submittedPayload[3]!==this._payloadInt32[3],n=r;for(let e=0;!n&&e<32;e++)n=this._submittedPayload[e]!==this._payloadInt32[e];if(!n&&!s)return!1;let o=n?2:0;return s&&(o|=4),i&&(o|=2),a&&(o|=8),this._renderer._publishSingleQuadInputs(o),this._submittedPayload.set(this._payloadInt32),this._submittedResource=this._resource,this._submittedResourceInternal=t,this._submitted=this._dataHandle.syncSingleQuad(this._resource),this._submitted}_writeUV(e){let t=this._payloadFloat32;t[10]=e[0],t[11]=e[1],t[12]=e[2],t[13]=e[3],t[14]=null==e[4]?e[2]:e[4],t[15]=null==e[5]?e[3]:e[5],t[16]=null==e[6]?e[0]:e[6],t[17]=null==e[7]?t[15]:e[7]}_prepareTexture(e){this._syncTextureRef(e),this._resource=null;let t=0;if(e&&!e.destroyed&&e.valid){this._resource=e.bitmap;let r=Ws.resolve(this._resource);r&&(this._resource=r.array,t=0|r.layer)}else e&&this._renderer.requestTextureRecovery(e);return t}_syncTextureRef(e){this._texture!==e&&(this._clearTextureRef(),this._texture=e,e&&e.on(c.CHANGE,this,this._onTextureChange))}_clearTextureRef(){let e=this._texture;this._texture=null,this._resource=null,e&&e.off(c.CHANGE,this,this._onTextureChange)}_onTextureChange(){this._renderer._scheduleGraphicsPayloadUpdate()}}class qn{constructor(e){this.graphics=null,this._dirty=39,this._mode=0,this._singleKind=0,this._hasSpriteTexture=!1,this._activeHandle=null,this._singleMode=null,this._streamMode=null,this._handleBuffer=null,this._handleInt32=null,this._handleFloat32=null,this._transformMask=0,this._recoveringTextureIds=new Set,this._destroyed=!1,this.owner=e,this._struct=e._struct,this._handleBuffer=new ArrayBuffer(40),this._handleInt32=new Int32Array(this._handleBuffer),this._handleFloat32=new Float32Array(this._handleBuffer)}setGraphics(e){this.graphics!==e&&(this.graphics=e,this._mark(39))}_checkDisplay(){this._mark(1)}invalidateGraphicsState(){this._mark(35)}_materialChanged(){this._dirty|=4}_commandsChanged(e,t){let r=!(e===t)||!this.graphics||this.graphics.cmds.length<=1;this._mark(r?35:34)}_mark(e){this._dirty|=e,this.owner._renderNode||(this.owner._renderType|=Mr.GRAPHICS)}_spriteTextureChanged(){let e=!!this.owner._texture!==this._hasSpriteTexture,t=!e&&0===this._dirty&&(1===this._mode||2===this._mode);return this._mark(e?51:t?18:50),t}_scheduleGraphicsRebuild(){return this._mark(34),this.owner._struct.setRepaint(),this.owner.repaint(),!0}_scheduleGraphicsPayloadUpdate(){return this._mark(2),this.owner._struct.setRepaint(),this.owner.repaint(),!0}_ensureSingle(){return this._singleMode||(this._singleMode=new Yn(this,this._handleBuffer))}_ensureStream(){return this._streamMode||(this._streamMode=new Xn(this,this._handleBuffer))}_resolveMode(){let e=this.owner,t=this.graphics?this.graphics.cmds.length:0,r=0,s=0;this._hasSpriteTexture=!!e._texture,!e._renderNode&&(e._texture||t>0)&&(s=Yn.classify(e._texture,this.graphics),r=s?1:2),this._singleKind=s,r!==this._mode&&this._switchMode(r),this._dirty&=-2}_switchMode(t){this._deactivateCurrentMode(),this._handleInt32[2]=0,this._activeHandle=1===t?this._ensureSingle().getDataHandle():2===t?this._ensureStream().getDataHandle():null,this._mode=t,this._dirty|=38;let r=this._struct;if(0===t)return r.renderDataHandler=null,r.renderElements=qn._emptyList,r.renderType=-1,void(this.owner._renderType&=~Mr.GRAPHICS);let s=!r.renderDataHandler;r.renderDataHandler=this._activeHandle,r.renderType=e.BaseRender2DType.graphics,this.owner._renderType|=Mr.GRAPHICS,s&&this.owner._updateStruct()}_deactivateCurrentMode(){1===this._mode?(this._singleMode.deactivate(),this._singleMode.clear()):2===this._mode&&(this._streamMode.deactivate(),this._streamMode.clear(!0))}_render(e){var t,r;if(!this._destroyed&&0!==this._dirty){if(1&this._dirty&&this._resolveMode(),0===this._mode)return this._dirty=0,null===(t=this.graphics)||void 0===t||t._commandsCommitted(),void this._syncTransformInterest();if(this.owner._initShaderData(),8&this._dirty&&this._applySizeChange(),4&this._dirty&&this._syncMaterial(),1===this._mode)26&this._dirty&&this._singleMode.render(this.graphics,this._singleKind);else if(48&this._dirty){let t=this._streamMode;!(32&this._dirty)&&!!(16&this._dirty)&&t.patchSpriteTexture()||t.rebuild(e)}this._dirty=0,null===(r=this.graphics)||void 0===r||r._commandsCommitted(),this._syncTransformInterest()}}_applySizeChange(){this._syncGraphicsOwnerSize()&&1===this._mode&&this._singleMode.getDependsOnSize()&&this._publishSingleQuadInputs(1),2===this._mode&&(this.owner._texture||this.graphics&&this.graphics.getLayoutRepaintCount()>0)&&(this._dirty|=32)}_ownerSizeChanged(){var t;0!==(this._transformMask&e.TransformKind.Size)&&(null===(t=this.graphics)||void 0===t||t._ownerSizeChanged(),this._dirty|=10,this.owner.repaint())}_onOwnerWorldTransformChanged(){this._mark(34),this.owner.repaint()}_syncTransformInterest(){let t=0;if(1===this._mode&&this._singleMode.getDependsOnSize())t=e.TransformKind.Size;else if(2===this._mode){let r=this._streamMode.getOwnerTransformDependencyMask();(this.owner._texture||0!==(r&e.GraphicsOwnerTransformDependency.SizeLayout))&&(t|=e.TransformKind.Size),0!==(r&e.GraphicsOwnerTransformDependency.ScaleTessellation)&&(t|=e.TransformKind.Scale)}if(t===this._transformMask)return;let r=0!==(this._transformMask&e.TransformKind.Scale),s=0!==(t&e.TransformKind.Scale);r&&!s&&this.owner.off(Ln.CHANGED,this,this._onOwnerWorldTransformChanged),this._transformMask=t,!r&&s&&this.owner.on(Ln.CHANGED,this,this._onOwnerWorldTransformChanged)}_patchTextureQuadCommand(e,t,r){return 0===this._dirty&&e&&e.graphics===this.graphics?1===this._mode?this._singleMode.patchFrameAnimation(r):2===this._mode?this._streamMode.patchFrameAnimation(e,t,r):-1:-1}_preRegisterTextureQuadCommands(e){for(let t=0,r=e?e.length:0;t<r;t++){let r=e[t].texture;r&&!r.valid&&this.requestTextureRecovery(r)}}getNeedRenderUpdate(){return!this._destroyed&&0!==this._dirty}_syncMaterial(){let e=this._activeHandle,t=this.graphics?this.graphics.material:null,r=!this.graphics||this.graphics._useSpriteState,s=t?t.shader.getSubShaderAt(0):nr.getDefaultSubShader();e.setGraphicsMaterialState(s,t?t.shaderData:null,r),this._dirty&=-5}_syncGraphicsOwnerSize(){let e=this._handleFloat32[5],t=this._handleFloat32[6];return this._handleFloat32[5]=this.owner.width,this._handleFloat32[6]=this.owner.height,e!==this._handleFloat32[5]||t!==this._handleFloat32[6]}_publishSingleQuadInputs(e){this._handleInt32[2]|=e,this._handleInt32[7]++}_mapGraphicsOpDirtyFlags(e){if(1&e)return 14;let t=0;return 2&e&&(t|=2),4&e&&(t|=4),16&e&&(t|=8),t}_syncGraphicsOps(e,t=0,r=-1,s=!0,i=s){let a=this._ensureStream(),n=a.getDataHandle();r<0&&(r=a.ops.length);let o=this._submitDirty(e,t,r,i);i||!n.autoGraphicsDirtySync?(n.syncGraphicsOps(a.ops),s?a.markSubmitted():a.markSubmitted(t,r)):o&&(s?a.markSubmitted(0,a.ops.length,!0):a.markSubmitted(t,r,!0))}_submitDirty(e,t,r,s){if(0===e&&!s)return!1;let i=this._handleInt32;t=Math.max(0,0|t),r=Math.max(0,Math.min(0|r,this._streamMode.ops.length-t));let a=i[0];if(i[1]!==a){let s=i[3],a=i[4];if(s>=0&&a>0){r=Math.max(s+a,t+r)-(t=Math.min(s,t)),e|=i[2]}}return i[2]=e,i[3]=t,i[4]=r,s&&i[8]++,i[0]=a+1,!0}requestTextureRecovery(e){if(this._destroyed||e.destroyed||e.valid)return;let t=e.bitmap;if(!t||!t.url||this._recoveringTextureIds.has(e.id))return;let r=this._recoveringTextureIds;r.add(e.id),e.recoverBitmap(()=>{r.delete(e.id),!this._destroyed&&e.valid&&this._scheduleGraphicsRebuild()})}destroy(){var e,t;this._destroyed||(this._destroyed=!0,this.owner.off(Ln.CHANGED,this,this._onOwnerWorldTransformChanged),this._deactivateCurrentMode(),this._struct.renderDataHandler=null,this._struct.renderElements=qn._emptyList,this._struct.renderType=-1,null===(e=this._streamMode)||void 0===e||e.destroy(),null===(t=this._singleMode)||void 0===t||t.destroy(),this._recoveringTextureIds.clear(),this.graphics=null,this._activeHandle=null,this._streamMode=null,this._singleMode=null,this.owner=null)}}qn._emptyList=[];class $n{static colorEffect2DShaderInit(){let t={a_PositionTexcoord:[0,e.ShaderDataType.Vector4]},r={u_centerScale:e.ShaderDataType.Vector2,u_MainTex:e.ShaderDataType.Texture2D,u_colorMat:e.ShaderDataType.Matrix4x4,u_colorAlpha:e.ShaderDataType.Vector4},s=Ot.add("ColorEffect2D");s.shaderType=e.ShaderFeatureType.PostProcess;let i=new Nt(t,r);s.addSubShader(i);let a=i.addShaderPass("#define SHADER_NAME colorEffect2D\nvarying vec2 v_Texcoord0;void main(){gl_Position=vec4((a_PositionTexcoord.x)*u_centerScale.x,(a_PositionTexcoord.y)*u_centerScale.y,0.0,1.0);v_Texcoord0=a_PositionTexcoord.zw;\n#ifdef INVERTY\ngl_Position.y=-gl_Position.y;\n#endif\n}",'#define SHADER_NAME colorEffect2D\n#include "Color.glsl"\n#include "OutputTransform.glsl";\nvarying vec2 v_Texcoord0;void main(){vec4 mainColor=texture2D(u_MainTex,v_Texcoord0);gl_FragColor=mainColor;\n#ifdef COLORFILTER\nmat4 alphaMat=u_colorMat;alphaMat[0][3]*=gl_FragColor.a;alphaMat[1][3]*=gl_FragColor.a;alphaMat[2][3]*=gl_FragColor.a;gl_FragColor=gl_FragColor*alphaMat;gl_FragColor+=u_colorAlpha/255.0*gl_FragColor.a;\n#endif\ngl_FragColor=outputTransform(gl_FragColor);}');a.statefirst=!0,a.renderState.depthWrite=!1,a.renderState.depthTest=Gt.DEPTHTEST_OFF,a.renderState.blend=Gt.BLEND_ENABLE_ALL,a.renderState.blendEquation=Gt.BLENDEQUATION_ADD,a.renderState.srcBlend=Gt.BLENDPARAM_ONE,a.renderState.dstBlend=Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,a.renderState.cull=Gt.CULL_NONE}static blurEffect2DShaderInit(){let t={a_PositionTexcoord:[0,e.ShaderDataType.Vector4]},r={u_centerScale:e.ShaderDataType.Vector2,u_MainTex:e.ShaderDataType.Texture2D,u_strength_sig2_2sig2_gauss1:e.ShaderDataType.Vector4,u_blurInfo:e.ShaderDataType.Vector2},s=Ot.add("BlurEffect2D");s.shaderType=e.ShaderFeatureType.PostProcess;let i=new Nt(t,r);s.addSubShader(i);let a=i.addShaderPass("\n#define SHADER_NAME blurEffect2D\nvarying vec2 v_Texcoord0;void main(){gl_Position=vec4((a_PositionTexcoord.x)*u_centerScale.x,(a_PositionTexcoord.y)*u_centerScale.y,0.0,1.0);v_Texcoord0=a_PositionTexcoord.zw;\n#ifdef INVERTY\ngl_Position.y=-gl_Position.y;\n#endif\n}",'\n#define SHADER_NAME blurEffect2D\n#include "Color.glsl"\n#include "OutputTransform.glsl";\nvec4 transspaceColor(vec4 color){\n#ifndef GAMMATEXTURE\n#ifdef GAMMASPACE\ncolor.xyz=linearToGamma(color.xyz);\n#endif\n#else\n#ifndef GAMMASPACE\ncolor.xyz=gammaToLinear(color.xyz);\n#endif\n#endif\nreturn color;}varying vec2 v_Texcoord0;float getGaussian(float x,float y){return u_strength_sig2_2sig2_gauss1.w*exp(-(x*x+y*y)/u_strength_sig2_2sig2_gauss1.z);}vec4 blur(){const float blurw=9.0;vec4 vec4Color=vec4(0.0,0.0,0.0,0.0);vec2 halfsz=vec2(blurw,blurw)/2.0/u_blurInfo;vec2 startpos=v_Texcoord0.xy-halfsz;vec2 ctexcoord=startpos;vec2 step=1.0/u_blurInfo;for(float y=0.0;y<=blurw;++y){ctexcoord.x=startpos.x;for(float x=0.0;x<=blurw;++x){vec4Color+=texture2D(u_MainTex,ctexcoord)*getGaussian(x-blurw/2.0,y-blurw/2.0);ctexcoord.x+=step.x;}ctexcoord.y+=step.y;}return vec4Color;}void main(){gl_FragColor=blur();}');a.statefirst=!0,a.renderState.depthWrite=!1,a.renderState.depthTest=Gt.DEPTHTEST_OFF,a.renderState.blend=Gt.BLEND_ENABLE_ALL,a.renderState.blendEquation=Gt.BLENDEQUATION_ADD,a.renderState.srcBlend=Gt.BLENDPARAM_ONE,a.renderState.dstBlend=Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,a.renderState.cull=Gt.CULL_NONE}static glow2DShaderInit(){let t={a_PositionTexcoord:[0,e.ShaderDataType.Vector4]},r={u_centerScale:e.ShaderDataType.Vector2,u_MainTex:e.ShaderDataType.Texture2D,u_color:e.ShaderDataType.Vector4,u_blurInfo1:e.ShaderDataType.Vector4,u_blurInfo2:e.ShaderDataType.Vector4},s=Ot.add("glow2D");s.shaderType=e.ShaderFeatureType.PostProcess;let i=new Nt(t,r);s.addSubShader(i);let a=i.addShaderPass("#define SHADER_NAME glow2D\nvarying vec2 v_Texcoord0;void main(){gl_Position=vec4((a_PositionTexcoord.x)*u_centerScale.x,(a_PositionTexcoord.y)*u_centerScale.y,0.0,1.0);v_Texcoord0=a_PositionTexcoord.zw;\n#ifdef INVERTY\ngl_Position.y=-gl_Position.y;\n#endif\n}",'#define SHADER_NAME glow2D\n#include "OutputTransform.glsl";\nvarying vec2 v_Texcoord0;void main(){const float c_BlurRadius=12.0;const float c_PairedRadius=6.0;const float c_KernelWeight=25.0*25.0;const float c_LegacyIntensity=1.21;vec2 textureSize=u_blurInfo2.xy;vec2 filterOffset=-u_blurInfo1.zw/textureSize;vec2 filterScale=u_blurInfo1.xy/textureSize/c_BlurRadius;float alpha=0.0;for(float y=-c_PairedRadius;y<=c_PairedRadius;++y){float sampleY=y==0.0 ? 0.0 : sign(y)*(abs(y)*2.0-0.5);float weightY=y==0.0 ? 1.0 : 2.0;for(float x=-c_PairedRadius;x<=c_PairedRadius;++x){float sampleX=x==0.0 ? 0.0 : sign(x)*(abs(x)*2.0-0.5);float weightX=x==0.0 ? 1.0 : 2.0;vec2 sampleOffset=vec2(sampleX,sampleY)*filterScale;alpha+=texture2D(u_MainTex,v_Texcoord0.xy+filterOffset+sampleOffset).a*weightX*weightY;}}alpha=alpha/c_KernelWeight*u_blurInfo2.z*c_LegacyIntensity;gl_FragColor=vec4(u_color.rgb,alpha);gl_FragColor.rgb*=gl_FragColor.a;}');a.statefirst=!0,a.renderState.depthWrite=!1,a.renderState.depthTest=Gt.DEPTHTEST_OFF,a.renderState.blend=Gt.BLEND_ENABLE_ALL,a.renderState.blendEquation=Gt.BLENDEQUATION_ADD,a.renderState.srcBlend=Gt.BLENDPARAM_ONE,a.renderState.dstBlend=Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,a.renderState.cull=Gt.CULL_NONE}}const Kn=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];class jn{static restoreTempArray(){Kn[0]=1,Kn[1]=0,Kn[4]=0,Kn[5]=1,Kn[12]=0,Kn[13]=0}static clear(){jn.worldAlpha=1}}var Qn;jn.worldMatrix4=Kn,jn.worldMatrix=new Ce,jn.matWVP=null,jn.worldAlpha=1,jn.worldScissorTest=!1,jn.width=0,jn.height=0,jn.InvertY=!1,e.MaterialRenderMode=void 0,(Qn=e.MaterialRenderMode||(e.MaterialRenderMode={}))[Qn.RENDERMODE_OPAQUE=0]="RENDERMODE_OPAQUE",Qn[Qn.RENDERMODE_CUTOUT=1]="RENDERMODE_CUTOUT",Qn[Qn.RENDERMODE_TRANSPARENT=2]="RENDERMODE_TRANSPARENT",Qn[Qn.RENDERMODE_ADDTIVE=3]="RENDERMODE_ADDTIVE",Qn[Qn.RENDERMODE_ALPHABLENDED=4]="RENDERMODE_ALPHABLENDED",Qn[Qn.RENDERMODE_CUSTOME=5]="RENDERMODE_CUSTOME";class Zn extends G{static load(e,t){l.loader.load(e,t,null,Te.MATERIAL)}static __initDefine__(){Zn.SHADERDEFINE_ALPHATEST=Ot.getDefineByName("ALPHATEST"),Zn.SHADERDEFINE_MAINTEXTURE=Ot.getDefineByName("MAINTEXTURE"),Zn.SHADERDEFINE_ADDTIVEFOG=Ot.getDefineByName("ADDTIVEFOG"),Zn.ALPHATESTVALUE=Ot.propertyNameToID("u_AlphaTestValue"),Ot.CULL=Ot.propertyNameToID("s_Cull"),Ot.BLEND=Ot.propertyNameToID("s_Blend"),Ot.BLEND_SRC=Ot.propertyNameToID("s_BlendSrc"),Ot.BLEND_DST=Ot.propertyNameToID("s_BlendDst"),Ot.BLEND_SRC_RGB=Ot.propertyNameToID("s_BlendSrcRGB"),Ot.BLEND_DST_RGB=Ot.propertyNameToID("s_BlendDstRGB"),Ot.BLEND_SRC_ALPHA=Ot.propertyNameToID("s_BlendSrcAlpha"),Ot.BLEND_DST_ALPHA=Ot.propertyNameToID("s_BlendDstAlpha"),Ot.BLEND_EQUATION=Ot.propertyNameToID("s_BlendEquation"),Ot.BLEND_EQUATION_RGB=Ot.propertyNameToID("s_BlendEquationRGB"),Ot.BLEND_EQUATION_ALPHA=Ot.propertyNameToID("s_BlendEquationAlpha"),Ot.DEPTH_TEST=Ot.propertyNameToID("s_DepthTest"),Ot.DEPTH_WRITE=Ot.propertyNameToID("s_DepthWrite"),Ot.STENCIL_WRITE_MASK=Ot.propertyNameToID("s_StencilWriteMask"),Ot.STENCIL_READ_MASK=Ot.propertyNameToID("s_StencilReadMask"),Ot.STENCIL_Ref=Ot.propertyNameToID("s_StencilRef"),Ot.STENCIL_TEST=Ot.propertyNameToID("s_StencilTest"),Ot.STENCIL_WRITE=Ot.propertyNameToID("s_StencilWrite"),Ot.STENCIL_Op=Ot.propertyNameToID("s_StencilOp"),Ot.DEPTH_BIAS=Ot.propertyNameToID("s_DepthBias"),Ot.DEPTH_BIAS_CONSTANT=Ot.propertyNameToID("s_DepthBiasConstant"),Ot.DEPTH_BIAS_SLOPESCALE=Ot.propertyNameToID("s_DepthBiasSlopeScale"),Ot.DEPTH_BIAS_CLAMP=Ot.propertyNameToID("s_DepthBiasClamp")}get renderQueue(){return this._renderQueue}set renderQueue(e){this._renderQueue=e,this._notifyOwnerElements()}_setOwner3DElement(e){this.ownerElements.add(e),e.materialShaderData=this._shaderValues,e.materialRenderQueue=this.renderQueue,e.subShader=this._shader.getSubShaderAt(0),e.materialId=this.id}_setOwner2DElement(e){this.ownerElements.add(e),e.materialShaderData=this._shaderValues,e.subShader=this._shader.getSubShaderAt(0)}_removeOwnerElement(e){this.ownerElements.delete(e)}_notifyOwnerElements(){this.ownerElements.forEach(e=>{e.materialId?this._setOwner3DElement(e):this._setOwner2DElement(e)})}get shaderData(){return this._shaderValues}get alphaTestValue(){return this._shaderValues.getNumber(Zn.ALPHATESTVALUE)}set alphaTestValue(e){this._shaderValues.setNumber(Zn.ALPHATESTVALUE,e)}get alphaTest(){return this.shaderData.hasDefine(Zn.SHADERDEFINE_ALPHATEST)}set alphaTest(e){e?this._shaderValues.addDefine(Zn.SHADERDEFINE_ALPHATEST):this._shaderValues.removeDefine(Zn.SHADERDEFINE_ALPHATEST)}addDefine(e){this._shaderValues.addDefine(e)}removeDefine(e){this._shaderValues.removeDefine(e)}setDefine(e,t){t?this._shaderValues.addDefine(e):this._shaderValues.removeDefine(e)}hasDefine(e){return this._shaderValues.hasDefine(e)}get depthWrite(){return this._shaderValues.getBool(Ot.DEPTH_WRITE)}set depthWrite(e){this._shaderValues.setBool(Ot.DEPTH_WRITE,e)}get cull(){return this._shaderValues.getInt(Ot.CULL)}set cull(e){this._shaderValues.setInt(Ot.CULL,e)}get blend(){return this._shaderValues.getInt(Ot.BLEND)}set blend(e){this._shaderValues.setInt(Ot.BLEND,e)}get blendSrc(){return this._shaderValues.getInt(Ot.BLEND_SRC)}set blendSrc(e){this._shaderValues.setInt(Ot.BLEND_SRC,e)}get blendDst(){return this._shaderValues.getInt(Ot.BLEND_DST)}set blendDst(e){this._shaderValues.setInt(Ot.BLEND_DST,e)}get blendSrcAlpha(){return this._shaderValues.getInt(Ot.BLEND_SRC_ALPHA)}set blendSrcAlpha(e){this._shaderValues.setInt(Ot.BLEND_SRC_ALPHA,e)}get blendSrcRGB(){return this._shaderValues.getInt(Ot.BLEND_SRC_RGB)}set blendSrcRGB(e){this._shaderValues.setInt(Ot.BLEND_SRC_RGB,e)}get blendDstRGB(){return this._shaderValues.getInt(Ot.BLEND_DST_RGB)}set blendDstRGB(e){this._shaderValues.setInt(Ot.BLEND_DST_RGB,e)}get blendDstAlpha(){return this._shaderValues.getInt(Ot.BLEND_DST_ALPHA)}set blendDstAlpha(e){this._shaderValues.setInt(Ot.BLEND_DST_ALPHA,e)}get blendEquation(){return this._shaderValues.getInt(Ot.BLEND_EQUATION)}set blendEquation(e){this._shaderValues.setInt(Ot.BLEND_EQUATION,e)}get blendEquationRGB(){return this._shaderValues.getInt(Ot.BLEND_EQUATION_RGB)}set blendEquationRGB(e){this._shaderValues.setInt(Ot.BLEND_EQUATION_RGB,e)}get blendEquationAlpha(){return this._shaderValues.getInt(Ot.BLEND_EQUATION_ALPHA)}set blendEquationAlpha(e){this._shaderValues.setInt(Ot.BLEND_EQUATION_ALPHA,e)}get depthTest(){return this._shaderValues.getInt(Ot.DEPTH_TEST)}set depthTest(e){this._shaderValues.setInt(Ot.DEPTH_TEST,e)}get stencilTest(){return this._shaderValues.getInt(Ot.STENCIL_TEST)}set stencilTest(e){this._shaderValues.setInt(Ot.STENCIL_TEST,e)}get stencilWrite(){return this._shaderValues.getBool(Ot.STENCIL_WRITE)}set stencilWrite(e){this._shaderValues.setBool(Ot.STENCIL_WRITE,e)}get stencilWriteMask(){return this._shaderValues.getInt(Ot.STENCIL_WRITE_MASK)}set stencilWriteMask(e){this._shaderValues.setInt(Ot.STENCIL_WRITE_MASK,e)}get stencilReadMask(){return this._shaderValues.getInt(Ot.STENCIL_READ_MASK)}set stencilReadMask(e){this._shaderValues.setInt(Ot.STENCIL_READ_MASK,e)}get stencilRef(){return this._shaderValues.getInt(Ot.STENCIL_Ref)}set stencilRef(e){this._shaderValues.setInt(Ot.STENCIL_Ref,e)}get stencilOp(){return this._shaderValues.getVector3(Ot.STENCIL_Op)}set stencilOp(e){this._shaderValues.setVector3(Ot.STENCIL_Op,e)}get depthBias(){return this._shaderValues.getBool(Ot.DEPTH_BIAS)}set depthBias(e){this._shaderValues.setBool(Ot.DEPTH_BIAS,e)}get depthBiasConstant(){return this._shaderValues.getNumber(Ot.DEPTH_BIAS_CONSTANT)}set depthBiasConstant(e){this._shaderValues.setNumber(Ot.DEPTH_BIAS_CONSTANT,e)}get dephtBiasSlopeScale(){return this._shaderValues.getNumber(Ot.DEPTH_BIAS_SLOPESCALE)}set dephtBiasSlopeScale(e){this._shaderValues.setNumber(Ot.DEPTH_BIAS_SLOPESCALE,e)}get depthBiasClamp(){return this._shaderValues.getNumber(Ot.DEPTH_BIAS_CLAMP)}set depthBiasClamp(e){this._shaderValues.setNumber(Ot.DEPTH_BIAS_CLAMP,e)}get MaterialProperty(){let e={};var t=this._shaderValues.getData();for(let r in t)e[f.renderEngine.propertyIDToName(parseInt(r))]=t[r];return e}get MaterialDefine(){let e=new Array,t=this._shaderValues.getDefineData();return Ot._getNamesByDefineData(t,e),e}get materialRenderMode(){return this._matRenderNode}set materialRenderMode(t){switch(this._matRenderNode=t,t){case e.MaterialRenderMode.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=Zn.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.blend=Gt.BLEND_DISABLE,this.depthTest=Gt.DEPTHTEST_LESS;break;case e.MaterialRenderMode.RENDERMODE_CUTOUT:this.renderQueue=Zn.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.blend=Gt.BLEND_DISABLE,this.depthTest=Gt.DEPTHTEST_LESS;break;case e.MaterialRenderMode.RENDERMODE_TRANSPARENT:this.renderQueue=Zn.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.blend=Gt.BLEND_ENABLE_ALL,this.blendSrc=Gt.BLENDPARAM_SRC_ALPHA,this.blendDst=Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=Gt.DEPTHTEST_LESS;break;case e.MaterialRenderMode.RENDERMODE_ADDTIVE:this.renderQueue=Zn.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.blend=Gt.BLEND_ENABLE_ALL,this.blendSrc=Gt.BLENDPARAM_SRC_ALPHA,this.blendDst=Gt.BLENDPARAM_ONE,this.depthTest=Gt.DEPTHTEST_LESS,this._shaderValues.addDefine(Zn.SHADERDEFINE_ADDTIVEFOG);break;case e.MaterialRenderMode.RENDERMODE_ALPHABLENDED:this.renderQueue=Zn.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.blend=Gt.BLEND_ENABLE_ALL,this.blendSrc=Gt.BLENDPARAM_SRC_ALPHA,this.blendDst=Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=Gt.DEPTHTEST_LESS,this._shaderValues.removeDefine(Zn.SHADERDEFINE_ADDTIVEFOG);break;case e.MaterialRenderMode.RENDERMODE_CUSTOME:break;default:console.warn(`Material : renderMode value error - (${t}).`)}}constructor(){super(),this.ownerElements=new Set,this._shaderValues=f.renderDeviceFactory.createShaderData(this),this.renderQueue=Zn.RENDERQUEUE_OPAQUE,this._matRenderNode=0,this.alphaTest=!1,this.cull=Gt.CULL_BACK,this.blend=Gt.BLEND_DISABLE,this.blendSrc=Gt.BLENDPARAM_ONE,this.blendDst=Gt.BLENDPARAM_ZERO,this.blendSrcRGB=Gt.BLENDPARAM_ONE,this.blendDstRGB=Gt.BLENDPARAM_ZERO,this.blendSrcAlpha=Gt.BLENDPARAM_ONE,this.blendDstAlpha=Gt.BLENDPARAM_ZERO,this.blendEquation=Gt.BLENDEQUATION_ADD,this.blendEquationRGB=Gt.BLENDEQUATION_ADD,this.blendEquationAlpha=Gt.BLENDEQUATION_ADD,this.depthTest=Gt.DEPTHTEST_LEQUAL,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilReadMask=255,this.stencilRef=1,this.stencilTest=Gt.STENCILTEST_OFF,this.stencilWrite=!1,this.stencilOp=new a(Gt.STENCILOP_KEEP,Gt.STENCILOP_KEEP,Gt.STENCILOP_REPLACE),this.depthBias=!1,this.depthBiasConstant=0,this.dephtBiasSlopeScale=0,this.depthBiasClamp=0,this.destroyedImmediately=t.destroyResourceImmediatelyDefault}_disposeResource(){this._shaderValues.destroy(),this._shaderValues=null,this.ownerElements.clear()}get shader(){return this._shader}effectiveProperty(){return this._shader.getSubShaderAt(0)._uniformMap}setShaderName(e){this._shader=Ot.find(e),this._shader||(console.warn(`Material: unknown shader name '${e}'`),this._shader=Ot.find("BLINNPHONG")),this.shaderData.clearDefine(),this.shaderData.clearData();let t=this._shader.getSubShaderAt(0),r=t._uniformDefaultValue,s=t._uniformMap;this.applyUniformDefaultValue(s,r),this._notifyOwnerElements()}applyUniformDefaultValue(e,t){e.forEach((e,r)=>{if(e.arrayLength<=0){let r=e.uniformtype,s=e.propertyName;if(t&&null!=t[s]){let e=t[s];this.setShaderData(s,r,e)}else{let e=Tt(r);e&&this.setShaderData(s,r,e)}}})}getBoolByIndex(e){return this.shaderData.getBool(e)}setBoolByIndex(e,t){this.shaderData.setBool(e,t)}getBool(e){let t=Ot.propertyNameToID(e);return this.getBoolByIndex(t)}setBool(e,t){let r=Ot.propertyNameToID(e);this.setBoolByIndex(r,t)}getFloatByIndex(e){return this.shaderData.getNumber(e)}setFloatByIndex(e,t){this.shaderData.setNumber(e,t)}getFloat(e){let t=Ot.propertyNameToID(e);return this.getFloatByIndex(t)}setFloat(e,t){let r=Ot.propertyNameToID(e);this.setFloatByIndex(r,t)}getIntByIndex(e){return this.shaderData.getInt(e)}setIntByIndex(e,t){this.shaderData.setInt(e,t)}getInt(e){let t=Ot.propertyNameToID(e);return this.getIntByIndex(t)}setInt(e,t){let r=Ot.propertyNameToID(e);this.setIntByIndex(r,t)}getVector2ByIndex(e){return this.shaderData.getVector2(e)}setVector2ByIndex(e,t){this.shaderData.setVector2(e,t)}getVector2(e){let t=Ot.propertyNameToID(e);return this.getVector2ByIndex(t)}setVector2(e,t){let r=Ot.propertyNameToID(e);this.setVector2ByIndex(r,t)}getVector3ByIndex(e){return this.shaderData.getVector3(e)}setVector3ByIndex(e,t){this.shaderData.setVector3(e,t)}getVector3(e){let t=Ot.propertyNameToID(e);return this.getVector3ByIndex(t)}setVector3(e,t){let r=Ot.propertyNameToID(e);this.setVector3ByIndex(r,t)}setVector4ByIndex(e,t){this.shaderData.setVector(e,t)}getVector4ByIndex(e){return this.shaderData.getVector(e)}setVector4(e,t){let r=Ot.propertyNameToID(e);this.setVector4ByIndex(r,t)}getVector4(e){let t=Ot.propertyNameToID(e);return this.getVector4ByIndex(t)}getColorByIndex(e){return this.shaderData.getColor(e)}setColorByIndex(e,t){this.shaderData.setColor(e,t)}getColor(e){let t=Ot.propertyNameToID(e);return this.shaderData.getColor(t)}setColor(e,t){let r=Ot.propertyNameToID(e);this.setColorByIndex(r,t)}getMatrix4x4ByIndex(e){return this.shaderData.getMatrix4x4(e)}setMatrix4x4ByIndex(e,t){this.shaderData.setMatrix4x4(e,t)}getMatrix4x4(e){let t=Ot.propertyNameToID(e);return this.getMatrix4x4ByIndex(t)}setMatrix4x4(e,t){let r=Ot.propertyNameToID(e);this.setMatrix4x4ByIndex(r,t)}getMatrix3x3ByIndex(e){return this.shaderData.getMatrix3x3(e)}setMatrix3x3ByIndex(e,t){this.shaderData.setMatrix3x3(e,t)}getMatrix3x3(e){let t=Ot.propertyNameToID(e);return this.getMatrix3x3ByIndex(t)}setMatrix3x3(e,t){let r=Ot.propertyNameToID(e);this.setMatrix3x3ByIndex(r,t)}setTextureByIndex(e,t){p.isConch?(this.shaderData.setTexture(e,t),t&&!t._texture&&t.once(c.READY,this,this.reSetTexture,[e,t])):this.shaderData.setTexture(e,t)}reSetTexture(e,t){this.setTextureByIndex(e,t)}getTextureByIndex(e){return this.shaderData.getTexture(e)}setTexture(e,t){let r=Ot.propertyNameToID(e);this.setTextureByIndex(r,t)}getTexture(e){let t=Ot.propertyNameToID(e);return this.getTextureByIndex(t)}setDeviceBufferByIndex(e,t){this.shaderData.setDeviceBuffer(e,t)}getDeviceBufferByIndex(e){return this.shaderData.getStorageBuffer(e)}setDeviceBuffer(e,t){let r=Ot.propertyNameToID(e);this.setDeviceBufferByIndex(r,t)}getDeviceBuffer(e){let t=Ot.propertyNameToID(e);return this.getDeviceBufferByIndex(t)}getBufferByIndex(e){return this.shaderData.getBuffer(e)}setBufferByIndex(e,t){this.shaderData.setBuffer(e,t)}getBuffer(e){let t=Ot.propertyNameToID(e);return this.getBufferByIndex(t)}setBuffer(e,t){let r=Ot.propertyNameToID(e);this.setBufferByIndex(r,t)}setShaderDataByIndex(e,t,r){this.shaderData.setShaderData(e,t,r)}setShaderData(e,t,r){let s=Ot.propertyNameToID(e);this.setShaderDataByIndex(s,t,r)}getShaderData(e,t){let r=Ot.propertyNameToID(e);return this.getShaderDataByIndex(r,t)}getShaderDataByIndex(e,t){return this._shaderValues.getShaderData(e,t)}cloneTo(e){e.name=this.name,e.renderQueue=this.renderQueue,e.setShaderName(this._shader._name),this._shaderValues.cloneTo(e._shaderValues)}clone(){var e=new Zn;return this.cloneTo(e),e}checkType(t){if(this._shader&&this._shader.shaderType===e.ShaderFeatureType.None)return!0;let r=this._shader&&this._shader.shaderType==t;return r||console.warn("This Renderer expect Material shader type is "+e.ShaderFeatureType[t]+", but the Material shader type is "+e.ShaderFeatureType[this._shader.shaderType]+"."),r}get _defineDatas(){return this._shaderValues.getDefineData()}oldparseEndEvent(){}}Zn.RENDERQUEUE_OPAQUE=2e3,Zn.RENDERQUEUE_ALPHATEST=2450,Zn.RENDERQUEUE_TRANSPARENT=3e3;class Jn{static getVertexDeclaration(e,t=!0){let r=[];for(let o=0,l=e.length;o<l;o++){let l=e[o],h=Jn._vertexDeclarationMap[l+(t?"_0":"_1")];if(!h){var s=l.split(","),i=0,a=[];for(let e=0,r=s.length;e<r;e++){var n;switch(s[e]){case"POSITION":n=new vt(i,It.Vector3,Lt.MESH_POSITION0),i+=12;break;case"COLOR":n=new vt(i,It.Vector4,Lt.MESH_COLOR0),i+=16;break;case"UV":n=new vt(i,It.Vector2,Lt.MESH_TEXTURECOORDINATE0),i+=8;break;case"BLENDWEIGHT":n=new vt(i,It.Vector4,Lt.MESH_BLENDWEIGHT0),i+=16;break;case"BLENDINDICES":t?(n=new vt(i,It.Vector4,Lt.MESH_BLENDINDICES0),i+=16):(n=new vt(i,It.Byte4,Lt.MESH_BLENDINDICES0),i+=4);break;default:throw"VertexMesh: unknown vertex flag."}a.push(n)}h=new Bt(i,a),Jn._vertexDeclarationMap[l+(t?"_0":"_1")]=h}r.push(h)}return r}static getMeshDefine(e,t){t.length=0;let r=e._vertexBuffers;for(var s=0,i=r.length;s<i;s++){let e=r[s].vertexDeclaration._vertexElements;for(const r of e)switch(r.elementUsage){case Lt.MESH_COLOR0:t.push(Ot.getDefineByName("COLOR"));break;case Lt.MESH_TEXTURECOORDINATE0:t.push(Ot.getDefineByName("UV"))}}}}Jn._vertexDeclarationMap={};class eo extends G{static createMesh2DByPrimitive(t,r,s,i,a,n=!1){let o=new eo;o.canRead=n;let l=[],h=[];for(var u=0,d=t.length;u<d;u++){let s=t[u],i=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Dynamic);i.vertexDeclaration=r[u],i.setDataLength(s.buffer.byteLength),i.setData(s.buffer,0,0,s.buffer.byteLength),l.push(i),h[u]=s.buffer}let c=f.renderDeviceFactory.createIndexBuffer(e.BufferUsage.Dynamic);c._setIndexDataLength(s.buffer.byteLength),c._setIndexData(s,0),c.indexCount=s.length,c.indexType=i,o._vertexCount=t.length>0?t[0].byteLength/r[0].vertexStride:0,o._setBuffers(l,c);let _=[];for(u=0;u<a.length;u++){let t=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.Triangles,e.DrawType.DrawElement);t.bufferState=o._bufferState,t.setDrawElemenParams(a[u].length,a[u].start),t.indexFormat=i,_.push(t)}return o._setSubMeshes(_),n&&(o._vertices=h,o._indices=s),o}get vertexBuffers(){return this._vertexBuffers}get indexBuffer(){return this._indexBuffer}get vertexCount(){return this._vertexCount}get indexCount(){return this._indexBuffer.indexCount}get subMeshCount(){return this._subMeshes.length}get indexFormat(){return this._indexFormat}constructor(){super(),this._instanceBufferStateType=0,this._vertexBuffers=null,this._indexBuffer=null,this._vertexCount=0,this._indexFormat=e.IndexFormat.UInt16,this.canRead=!1,this._vertices=null,this._indices=null,this._bufferState=f.renderDeviceFactory.createBufferState(),this._subMeshes=[],this.destroyedImmediately=t.destroyResourceImmediatelyDefault}_disposeResource(){for(let e=0,t=this._subMeshes.length;e<t;e++)this._subMeshes[e].destroy();for(let e=0,t=this._vertexBuffers.length;e<t;e++)this._vertexBuffers[e].destroy();this._indexBuffer&&this._indexBuffer.destroy(),this._bufferState.destroy(),this._instanceBufferState&&this._instanceBufferState.destroy(),this._instanceWorldVertexBuffer&&this._instanceWorldVertexBuffer.destroy(),this._instanceSimpleAniVertexBuffer&&this._instanceSimpleAniVertexBuffer.destroy(),this._setCPUMemory(0),this._setGPUMemory(0),this._bufferState=null,this._instanceBufferState=null,this._vertexBuffers=null,this._indexBuffer=null,this._subMeshes=null,this._indexBuffer=null}_setSubMeshes(e){this._subMeshes=e}_setBuffers(e,t){var r=this._bufferState;this._vertexBuffers=e,this._indexBuffer=t,r.applyState(e,t)}getSubMesh(e){return this._subMeshes[e]}setVertices(e){for(let t=0,r=e.length;t<r;t++)e[t]&&this._vertexBuffers[t]&&this._vertexBuffers[t].setData(e[t],0,0,e[t].byteLength);this.canRead&&(this._vertices=e)}getVertices(){if(this.canRead&&this._vertices)return this._vertices;throw new Error("Can't getVertices without the canRead flag, or if the canRead flag is false before setVertices!")}setVertexByIndex(e,t,r=0){this._vertexBuffers[t].setData(e,r,0,e.byteLength)}setIndices(t){var r;t instanceof Uint32Array?r=e.IndexFormat.UInt32:t instanceof Uint16Array?r=e.IndexFormat.UInt16:t instanceof Uint8Array&&(r=e.IndexFormat.UInt8);let s=this._indexBuffer;s.indexCount<t.length&&console.error("Mesh2D:set indices buffer large than ori indices");var i=!1;(this._indexFormat!==r||s.indexCount<t.length)&&(s.destroy(),i=!0,this._indexBuffer=s=f.renderDeviceFactory.createIndexBuffer(e.BufferUsage.Static),this._indexBuffer._setIndexDataLength(t.byteLength),s.indexCount=t.length,s.indexType=r);const a=t.BYTES_PER_ELEMENT,n=4*Math.ceil(t.byteLength/4),o=s.indexCount*a;if(n>t.byteLength&&n<=o){const e=new Uint8Array(n);e.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),s.setData(e.buffer,0,0,e.byteLength)}else s._setIndexData(t,0);i&&this._bufferState.applyState(this._bufferState._vertexBuffers,s),this.canRead&&(this._indices=t)}getIndices(){if(this.canRead&&this._indices)return this._indices;throw new Error("Can't getIndices without the canRead flag, or if the canRead flag is false before setIndices!")}}class to extends Dn{static __init__(){if(to.mesh2DDefaultMaterial)return;to.mesh2DDefaultMaterial=new Zn,to.mesh2DDefaultMaterial.setShaderName("baseRender2D"),to.mesh2DDefaultMaterial.setBoolByIndex(Ot.DEPTH_WRITE,!1),to.mesh2DDefaultMaterial.setIntByIndex(Ot.DEPTH_TEST,Gt.DEPTHTEST_OFF),to.mesh2DDefaultMaterial.setIntByIndex(Ot.BLEND,Gt.BLEND_ENABLE_ALL),to.mesh2DDefaultMaterial.setIntByIndex(Ot.BLEND_EQUATION,Gt.BLENDEQUATION_ADD),to.mesh2DDefaultMaterial.setIntByIndex(Ot.BLEND_SRC,Gt.BLENDPARAM_ONE),to.mesh2DDefaultMaterial.setIntByIndex(Ot.BLEND_DST,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA),to.mesh2DDefaultMaterial.setFloatByIndex(kt.UNIFORM_VERTALPHA,1),to.mesh2DDefaultMaterial.setIntByIndex(Ot.CULL,Gt.CULL_NONE),to.mesh2DDefaultMaterial.lock=!0;let t=Jn.getVertexDeclaration(["POSITION,UV"]),r=new Float32Array([0,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1,0,0,1]),s=new Uint16Array([0,1,2,0,2,3]);to.defaultQuadMesh=eo.createMesh2DByPrimitive([r],t,s,e.IndexFormat.UInt16,[{start:0,length:6}])}_createRenderHandle(){return f.render2DRenderPassFactory.createMesh2DRenderDataHandle()}_initDefaultRenderData(){this.color=new y,this.tilingOffset=new i(0,0,1,1),this.texture=null,this._applyUnitQuad(this._useUnitQuad)}_isMaterialVaild(t){return t.checkType(e.ShaderFeatureType.D2_BaseRenderNode2D)}renderUpdate(e){this._updateLight()}set useUnitQuad(e){this._useUnitQuad!==e&&this._applyUnitQuad(e)}get useUnitQuad(){return this._useUnitQuad}set sharedMesh(e){this._sharedMesh!=e&&(this._sharedMesh&&this._sharedMesh._removeReference(),e&&(e._vertexBuffers?e._addReference():(e=null,console.warn("not a 2D mesh"))),this._sharedMesh=e,this._applyUnitQuad(!e))}get sharedMesh(){return this._sharedMesh}set color(e){this._renderHandle.baseColor=e,this._notifyDataChange()}get color(){return this._renderHandle.baseColor}set size(e){e.cloneTo(this._size),this._spriteShaderData.setVector2(Dn.BASERENDERSIZE,this._size),this._notifyDataChange()}get size(){return this._size}set tilingOffset(e){this._tilingOffset=e,this._updateTilingOffset(),this._notifyDataChange()}get tilingOffset(){return this._tilingOffset}_updateTilingOffset(){let e=this._renderHandle.tilingOffset;null==this._tilingOffset?e.setValue(this._textureTilingOffset.x,this._textureTilingOffset.y,this._textureTilingOffset.z,this._textureTilingOffset.w):e.setValue(this._tilingOffset.x*this._textureTilingOffset.z+this._textureTilingOffset.x,this._tilingOffset.y*this._textureTilingOffset.w+this._textureTilingOffset.y,this._tilingOffset.z*this._textureTilingOffset.z,this._tilingOffset.w*this._textureTilingOffset.w),this._renderHandle.tilingOffset=e}set texture(e){if(this._texture instanceof ie&&this._texture._removeReference(),this._texture=e,e instanceof ie){if(e._addReference(),e.uv!==ie.DEF_UV){console.warn("Texture uv is not default, it will affect the tiling offset.");let t=e.uvrect[2]/e.width,r=e.uvrect[3]/e.height;this._textureTilingOffset.setValue(e.uvrect[0]-e.offsetX*t,e.uvrect[1]-e.offsetY*r,e.sourceWidth*t,e.sourceHeight*r)}else this._textureTilingOffset.setValue(0,0,1,1);e=e.bitmap}else this._textureTilingOffset.setValue(0,0,1,1);this._updateTilingOffset(),this._renderHandle.baseTexture=e,this._notifyDataChange()}get texture(){return this._texture}set normalTexture(e){this._renderHandle.normal2DTexture=e,this._notifyDataChange()}get normalTexture(){return this._renderHandle.normal2DTexture}set normalStrength(e){this._renderHandle.normal2DStrength=e,this._notifyDataChange()}get normalStrength(){return this._renderHandle.normal2DStrength}set sharedMaterial(e){super.sharedMaterial=e,this._changeMesh(),this._notifyDataChange()}get sharedMaterial(){return this._materials[0]}_getElementMaterial(e){return this._materials[e]||to.mesh2DDefaultMaterial}_applyUnitQuad(e){this._useUnitQuad=e,e?this._spriteShaderData.addDefine(Dn.SHADERDEFINE_UNITQUAD):this._spriteShaderData.removeDefine(Dn.SHADERDEFINE_UNITQUAD),this._changeMesh(),this._notifyDataChange()}_changeMesh(){let e=this._useUnitQuad?to.defaultQuadMesh:this._sharedMesh,t=new Array;if(this._activeMesh){Jn.getMeshDefine(this._activeMesh,t);for(var r=0,s=t.length;r<s;r++)this._spriteShaderData.removeDefine(t[r]);t.length=0}if(e){Jn.getMeshDefine(e,t);for(r=0,s=t.length;r<s;r++)this._spriteShaderData.addDefine(t[r])}this._activeMesh=e;let i=e?e.subMeshCount:0;if(i<this._renderElements.length){for(r=this._renderElements.length,s=i;s<r;r--){let e=this._renderElements[r-1];Dn._removeRenderElement2DMaterial(e,this._getElementMaterial(r-1)),e.destroy()}this._renderElements.length=i}for(r=0,s=i;r<s;r++){let t=this._renderElements[r];t||(t=this._renderElements[r]=f.render2DRenderPassFactory.createRenderElement2D()),t.geometry=e.getSubMesh(r),t.value2DShaderData=this._spriteShaderData,Dn._setRenderElement2DMaterial(t,this._getElementMaterial(r)),t.renderStateIsBySprite=!1,t.nodeCommonMap=this._getcommonUniformMap(),t.owner=this._struct}this._struct.renderElements=this._renderElements}constructor(){super(),this._useUnitQuad=!1,this._textureTilingOffset=new i(0,0,1,1),this._size=new $e(1,1),this._renderElements=[],this._materials=[]}}class ro{constructor(){this._commandBuffer=null}recover(){this._commandBuffer=null,this._context=null}destroy(){this._commandBuffer=null,this._context=null}}class so extends ro{static __initBlitShader__(){let t={a_PositionTexcoord:[0,e.ShaderDataType.Vector4]},r={u_OffsetScale:e.ShaderDataType.Vector4,u_MainTex:e.ShaderDataType.Texture2D,u_MainTex_TexelSize:e.ShaderDataType.Vector4},s=Ot.add("Blit2DCMD");s.shaderType=e.ShaderFeatureType.PostProcess;let i=new Nt(t,r);s.addSubShader(i);let a=i.addShaderPass("\n #define SHADER_NAME Blit2DVS\n\n varying vec2 v_Texcoord0;\n\n void main()\n {\n gl_Position = vec4(u_OffsetScale.x * 2.0 - 1.0 + (a_PositionTexcoord.x + 1.0) * u_OffsetScale.z, (1.0 - ((u_OffsetScale.y * 2.0 - 1.0 + (-a_PositionTexcoord.y + 1.0) * u_OffsetScale.w) + 1.0) / 2.0) * 2.0 - 1.0, 0.0, 1.0);\n\n v_Texcoord0 = a_PositionTexcoord.zw;\n\n #ifdef INVERTY\n gl_Position.y = -gl_Position.y;\n #endif\n }\n ",'\n #define SHADER_NAME Blit2DFS\n\n #include "Color.glsl";\n\n varying vec2 v_Texcoord0;\n\n void main()\n {\n vec4 mainColor = texture2D(u_MainTex, v_Texcoord0);\n #ifdef Gamma_u_MainTex\n mainColor = gammaToLinear(mainColor);\n #endif // Gamma_u_AlbedoTexture\n gl_FragColor = mainColor;\n gl_FragColor = outputTransform(gl_FragColor);\n }\n ');a.statefirst=!0,a.renderState.depthWrite=!1,a.renderState.depthTest=Gt.DEPTHTEST_OFF,a.renderState.blend=Gt.BLEND_ENABLE_ALL,a.renderState.blendEquation=Gt.BLENDEQUATION_ADD,a.renderState.srcBlend=Gt.BLENDPARAM_ONE,a.renderState.dstBlend=Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA,a.renderState.cull=Gt.CULL_NONE}static __initGeometryElement__(){let t=new Float32Array([1,1,1,1,1,-1,1,0,-1,1,0,1,-1,-1,0,0]),r=new Bt(16,[new vt(0,It.Vector4,0)]),s=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Dynamic);s.vertexDeclaration=r,s.setDataLength(t.buffer.byteLength),s.setData(t.buffer,0,0,t.buffer.byteLength);let i=f.renderDeviceFactory.createBufferState();i.applyState([s],null);let a=so.QuadGeometry=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.TriangleStrip,e.DrawType.DrawArray);a.setDrawArrayParams(0,4),a.bufferState=i,so.__initInvertGeometryElement__()}static __initInvertGeometryElement__(){let t=new Float32Array([1,1,1,0,1,-1,1,1,-1,1,0,0,-1,-1,0,1]),r=new Bt(16,[new vt(0,It.Vector4,0)]),s=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Dynamic);s.vertexDeclaration=r,s.setDataLength(t.buffer.byteLength),s.setData(t.buffer,0,0,t.buffer.byteLength);let i=f.renderDeviceFactory.createBufferState();i.applyState([s],null);let a=so.InvertQuadGeometry=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.TriangleStrip,e.DrawType.DrawArray);a.setDrawArrayParams(0,4),a.bufferState=i}static __init__(){so.__initBlitShader__(),so.__initGeometryElement__(),so._blitShaderData=f.renderDeviceFactory.createShaderData(),so._defaultShader=Ot.find("Blit2DCMD")}static create(e,t,r=null,s=null,i=null,a=!1){so._blitShaderData||so.__init__();let n=so._pool.take();return n.source=e,n.dest=t,n.offsetScale=r,n.setshader(s,i),n._renderElement.geometry=a?so.InvertQuadGeometry:so.QuadGeometry,n}constructor(){super(),this._source=null,this._dest=null,this._offsetScale=new i,this._shader=null,this._shaderData=null,this._renderElement=f.render2DRenderPassFactory.createRenderElement2D(),this._blitQuadCMDData=f.render2DRenderPassFactory.createBlit2DQuadCMDData(),this._blitQuadCMDData.element=this._renderElement,this._renderElement.geometry=so.QuadGeometry,this._renderElement.nodeCommonMap=null,this._renderElement.renderStateIsBySprite=!1}get offsetScale(){return this._offsetScale}set offsetScale(e){e?e.cloneTo(this._offsetScale):so._defaultOffsetScale.cloneTo(this._offsetScale),this._blitQuadCMDData.offsetScale=this._offsetScale}get source(){return this._source}set source(e){this._source=e,this._blitQuadCMDData.source=e?e._texture:Hi.blackTexture._texture}get dest(){return this._dest}set dest(e){this._dest=e,this._blitQuadCMDData.dest=e?e._renderTarget:null}set shaderData(e){this._shaderData=e||so._blitShaderData,this._renderElement.materialShaderData=this._shaderData}getRenderCMD(){return this._blitQuadCMDData}setshader(e,t){this._shader=e||so._defaultShader,this.shaderData=t,this._renderElement.subShader=this._shader.getSubShaderAt(0)}destroy(){this._commandBuffer=null,this._context=null}recover(){super.recover(),so._pool.recover(this)}}so._defaultOffsetScale=new i(0,0,1,1),so._pool=h.createPool(so);class io extends ro{static create(e,t,r,s,i){let a=io._pool.take();return a.mesh=e,a.material=i||to.mesh2DDefaultMaterial,a.texture=r,a.color=s,a._setMatrix(t),a}constructor(){super(),this._renderElements=[],this._meshDefines=[],this._renderColor=new y(1,1,1,1),this._textureTilingOffset=new i(0,0,1,1),this._tilingOffset=new i(0,0,1,1),this._drawElementData=f.render2DRenderPassFactory.createDraw2DElementCMDData(),this._shaderData=f.renderDeviceFactory.createShaderData(),this._shaderData.addDefine(Dn.SHADERDEFINE_BASERENDER2D),this._needUpdateElement=!0,this._matrix=new Ce}_setMatrix(e){e?e.copyTo(this._matrix):Ce.EMPTY.copyTo(this._matrix);let t=this._matrix,r=a.TEMP;r.x=t.a,r.y=t.c,r.z=t.tx,this._shaderData.setVector3(kt.UNIFORM_NMATRIX_0,r),r.x=t.b,r.y=t.d,r.z=t.ty,this._shaderData.setVector3(kt.UNIFORM_NMATRIX_1,r)}set material(e){e!=this.material&&(this._material&&this._material._removeReference(),this._material=e,this._material&&this._material._addReference(),this._needUpdateElement=!0)}get material(){return this._material}set mesh(e){if(e!=this.mesh){for(let e=0,t=this._meshDefines.length;e<t;e++)this._shaderData.removeDefine(this._meshDefines[e]);if(this._meshDefines.length=0,this._mesh&&this._mesh._removeReference(),e){e._addReference(),Jn.getMeshDefine(e,this._meshDefines);for(let e=0,t=this._meshDefines.length;e<t;e++)this._shaderData.addDefine(this._meshDefines[e])}this._mesh=e,this._needUpdateElement=!0}}get mesh(){return this._mesh}set texture(e){let t;if(this._texture instanceof ie&&this._texture._removeReference(),this._texture=e,e instanceof ie){if(e._addReference(),e.uv!==ie.DEF_UV){let t=e.uvrect[2]/e.width,r=e.uvrect[3]/e.height;this._textureTilingOffset.setValue(e.uvrect[0]-e.offsetX*t,e.uvrect[1]-e.offsetY*r,e.sourceWidth*t,e.sourceHeight*r)}else this._textureTilingOffset.setValue(0,0,1,1);t=e.bitmap}else this._textureTilingOffset.setValue(0,0,1,1),t=e||Hi.whiteTexture;1!=t.gammaCorrection?this._shaderData.addDefine(kt.GAMMATEXTURE):this._shaderData.removeDefine(kt.GAMMATEXTURE),this._tilingOffset.setValue(this._textureTilingOffset.x,this._textureTilingOffset.y,this._textureTilingOffset.z,this._textureTilingOffset.w),this._shaderData.setVector(Dn.TILINGOFFSET,this._tilingOffset),this._shaderData.setTexture(Dn.BASERENDER2DTEXTURE,t)}get texture(){return this._texture}set color(e){this._color=e;let t=this._renderColor;t.setValue(e.r,e.g,e.b,e.a),this._shaderData.setColor(Dn.BASERENDER2DCOLOR,t)}get color(){return this._color}getRenderCMD(){return this._drawElementData}run(){if(this._needUpdateElement){let e=this._renderElements.length,t=this._mesh.subMeshCount,r=Math.max(e,t);for(let e=0;e<r;e++){let t=this._mesh.getSubMesh(e),r=this._renderElements[e];t?(r||(r=this._renderElements[e]=f.render2DRenderPassFactory.createRenderElement2D()),r.nodeCommonMap=["BaseRender2D"],r.geometry=t,r.renderStateIsBySprite=!1,r.value2DShaderData=this._shaderData,r.materialShaderData=this._material.shaderData,r.subShader=this._material._shader.getSubShaderAt(0)):r.destroy()}this._renderElements.length=r,this._drawElementData.setRenderelements(this._renderElements),this._needUpdateElement=!1}}recover(){io._pool.recover(this),super.recover(),this.material=null,this.texture=null,this.mesh=null}destroy(){super.destroy(),this.mesh=null,this.material=null,this.texture=null,this._shaderData.destroy(),this._shaderData=null}}io._pool=h.createPool(io);class ao extends ro{static create(e,t=null){let r=ao._pool.take();return r.renderElement=e,r._setMatrix(t),r}get renderElement(){return this._renderElement}set renderElement(e){this._renderElement=e,this._drawElementCMDData.setRenderelements([this._renderElement])}constructor(){super(),this._drawElementCMDData=f.render2DRenderPassFactory.createDraw2DElementCMDData()}_setMatrix(e){if(this._matreix=e?e.clone():null,this._matreix&&this.renderElement.nodeCommonMap&&-1!=this.renderElement.nodeCommonMap.indexOf("BaseRender2D")){let e=a.TEMP;e.x=this._matreix.a,e.y=this._matreix.c,e.z=this._matreix.tx,this._renderElement.value2DShaderData.setVector3(kt.UNIFORM_NMATRIX_0,e),e.x=this._matreix.b,e.y=this._matreix.d,e.z=this._matreix.ty,this._renderElement.value2DShaderData.setVector3(kt.UNIFORM_NMATRIX_1,e)}}run(){}recover(){super.recover(),ao._pool.recover(this)}getRenderCMD(){return this._drawElementCMDData}destroy(){this._renderElement=null,this._drawElementCMDData=null}}ao._pool=h.createPool(ao);class no extends ro{static create(e,t,r,s=!0,i=0,a=0){let n=no._pool.take();return n.renderTexture=e,n._setRenderTargetCMD.clearColor=t,n._setRenderTargetCMD.clearColorValue=r,n._setRenderTargetCMD.invertY=s,n._setRenderTargetCMD.viewportX=i,n._setRenderTargetCMD.viewportY=a,n}get renderTexture(){return this._renderTexture}set renderTexture(e){this._renderTexture=e,e?(this._setRenderTargetCMD.size.setValue(e.width,e.height),this._setRenderTargetCMD.rt=e._renderTarget):(this._setRenderTargetCMD.size.setValue(jn.width,jn.height),this._setRenderTargetCMD.rt=null)}constructor(){super(),this._renderTexture=null,this._setRenderTargetCMD=f.render2DRenderPassFactory.createSetRendertarget2DCMD()}run(){}getRenderCMD(){return this._setRenderTargetCMD}recover(){no._pool.recover(this),this._renderTexture=null}}no._pool=h.createPool(no);class oo extends ro{static create(e,t,r,s){let i=oo._pool.take();return i.setDest(e),i._setRenderDataCMD.propertyID=t,i._setRenderDataCMD.dataType=s,i._setRenderDataCMD.value=r,i}constructor(){super(),this._globalMode=!1,this._setRenderDataCMD=f.render2DRenderPassFactory.createSetRenderDataCMD()}getRenderCMD(){return this._setRenderDataCMD}setDest(e){this._setRenderDataCMD.dest=e}recover(){oo._pool.recover(this),this._globalMode=!1}}oo._pool=h.createPool(oo);class lo extends ro{static create(e,t,r){let s=lo._pool.take();return s.setDest(e),s._setRenderDefineCMD.add=r,s._setRenderDefineCMD.define=t,s}constructor(){super(),this._globalMode=!1,this._setRenderDefineCMD=f.render2DRenderPassFactory.createSetShaderDefineCMD()}setDest(e){this._setRenderDefineCMD.dest=e}getRenderCMD(){return this._setRenderDefineCMD}recover(){lo._pool.recover(this),this._globalMode=!1}}lo._pool=h.createPool(lo);class ho{constructor(e){this._scene=null,this._renderCMDs=[],this.cacheData={},this._cacheViewport=new i,this._name=e,this.shaderData=f.renderDeviceFactory.createShaderData(),this._context=va.rendercontext2D,this._commands=[]}getName(){return this._name}_cacheContextState(){this.cacheData.rt=this._context.getRenderTarget(),this.cacheData.pipeline=this._context.pipelineMode,this.cacheData.invertY=this._context.invertY,this._context.getOffscreenView(this._cacheViewport)}_recoverContextState(){let e=this._cacheViewport;this._context.setOffscreenView(e.z,e.w,e.x,e.y),this._context.setRenderTarget(this.cacheData.rt,!1,y.BLACK),this._context.pipelineMode=this.cacheData.pipeline,this._context.invertY=this.cacheData.invertY}apply(e=!0,t=!0){this.shaderData.clearData();let r=this._context.passData;r&&r.getDefineData()?r.cloneTo(this.shaderData):this.shaderData.setVector2(kt.UNIFORM_SIZE,$e.TEMP.setValue(jn.width,jn.height)),this._context.passData=this.shaderData,t&&this._cacheContextState();for(var s=0,i=this._commands.length;s<i;s++){let e=this._commands[s];e.run&&e.run()}e&&this._context.runCMDList(this._renderCMDs),this._context.passData=r,t&&this._recoverContextState()}applyOne(e=!0){if(e&&this._cacheContextState(),this._commands.length){var t=this._commands.shift();t.run&&t.run(),t.getRenderCMD&&this._context.runOneCMD(this._renderCMDs.shift()),t.recover()}return e&&this._recoverContextState(),this._commands.length>0}clear(e=!0){if(e)for(var t=0,r=this._commands.length;t<r;t++)this._commands[t].recover();this._commands.length=0,this._renderCMDs.length=0}getCommandsSize(){return this._commands.length}setShaderDataValue(e,t,r,s){if(!ft(s,r))return;let i=oo.create(e,t,s,r);i._globalMode=!1,this._commands.push(i),i._commandBuffer=this,i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalShaderDataValue(e,t,r){if(!ft(r,t))return;if(!this._scene||!this._scene._specialManager)return;let s=oo.create(this._scene._specialManager._shaderData,e,r,t);s._globalMode=!0,this._commands.push(s),s._commandBuffer=this,s.getRenderCMD&&this._renderCMDs.push(s.getRenderCMD())}setShaderDefine(e,t,r){let s=lo.create(e,t,r);s._globalMode=!1,this._commands.push(s),s._commandBuffer=this,s.getRenderCMD&&this._renderCMDs.push(s.getRenderCMD())}blitTextureQuad(e,t,r,s,i,a){let n=so.create(e,t,r,s,i,a);this._commands.push(n),n._commandBuffer=this,n.getRenderCMD&&this._renderCMDs.push(n.getRenderCMD())}blitTextureBlur(e,t,r){}setRenderTarget(e,t,r=y.BLACK,s=!0,i=0,a=0){let n=no.create(e,t,r,s,i,a);this._commands.push(n),n._commandBuffer=this,n.getRenderCMD&&this._renderCMDs.push(n.getRenderCMD())}drawRenderElement(e,t){let r=ao.create(e,t);this._commands.push(r),r._commandBuffer=this,r.getRenderCMD&&this._renderCMDs.push(r.getRenderCMD())}drawMesh(e,t,r,s,i){let a=io.create(e,t,r||Hi.whiteTexture,s||y.WHITE,i||to.mesh2DDefaultMaterial);this._commands.push(a),a._commandBuffer=this,a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}drawQuad(){}drawLine(){}addCacheCommand(e){this._scene&&(e instanceof oo&&e._commandBuffer&&e.setDest(this._scene._specialManager._shaderData),e instanceof lo&&e._commandBuffer&&e.setDest(this._scene._specialManager._shaderData)),this._commands.push(e),e._commandBuffer=this,e.getRenderCMD&&this._renderCMDs.push(e.getRenderCMD())}}class uo extends N{static postRenderAll(){uo._pendingPostRender.forEach(e=>e._afterRender()),uo._pendingPostRender.clear()}static init(){$n.colorEffect2DShaderInit(),$n.blurEffect2DShaderInit(),$n.glow2DShaderInit()}get enabled(){return this._enabled}set enabled(e){this._enabled!=e&&(this._enabled=e,this._onChangeRender())}constructor(){super(),this._effects=[],this._enabled=!0,this._hasCleanRT=!1,this._context=new co,this._context.compositeShaderData=f.renderDeviceFactory.createShaderData(null),this._context.command=new ho}get owner(){return this._owner}set owner(e){this._owner&&(this._owner._renderType&=~Mr.POSTPROCESS),this._owner=e,this._owner&&this._effects.length>0&&this._enabled&&(this._owner._renderType|=Mr.POSTPROCESS)}_checkEnabled(){if(0===this._effects.length||!this._enabled)return!1;for(let e=0;e<this._effects.length;e++)if(this._effects[e].active)return!0;return!1}_onChangeRender(){this._owner&&(this._checkEnabled()?this._owner._renderType|=Mr.POSTPROCESS:(this._owner._renderType&=~Mr.POSTPROCESS,this.clearCMD()),this._owner.setSubpassFlag(e.SubPassFlag.PostProcess),this._owner.repaint(e.RepaintFlag.Graphics))}getEffect(e){return this._effects.find(t=>t instanceof e)||null}setResource(e){this._context.source=e}getDestRT(){return this._context.destination}get effects(){return this._effects}set effects(e){this._effects.filter(t=>!e.includes(t)).forEach(e=>e.destroy()),this._effects.length=0;for(let t=0,r=e.length;t<r;t++)e[t]&&this.addEffect(e[t]);this._onChangeRender()}addEffect(e){return e.destroyed?(console.error("the target effect is destroyed",e),null):e.singleton&&this.getEffect(e.constructor)?(console.error("the target effect is a singleton",e),null):(this._effects.push(e),e.effectInit(this),this._onChangeRender(),e)}removeEffect(e){let t=this._effects.indexOf(e);-1!==t&&(this._effects.splice(t,1),e.destroy(),this._onChangeRender())}_render(){var e,t;this._context.indirectTarget=this._context.source,this._context.destination=this._context.source;for(var r=0,s=this._effects.length;r<s;r++){let e=this._effects[r];e.active&&!e.destroyed&&(e.render(this._context),this._context.indirectTarget=this._context.destination)}this._hasCleanRT=!1,null===(t=null===(e=this._owner)||void 0===e?void 0:e._oriRenderPass)||void 0===t||t.updatePostProcess(),uo._pendingPostRender.add(this)}_afterRender(){if(!this._hasCleanRT){for(let e=0,t=this._effects.length;e<t;e++)this._effects[e].clearRT(this._context);this._hasCleanRT=!0}}clear(){this.recoverAllRTS();for(let e=0;e<this._effects.length;e++)this._effects[e].destroy();this._effects.length=0,this._onChangeRender()}clearCMD(){this._context.command.clear(),this._releaseInputTextureBindings()}_releaseInputTextureBindings(){for(let e=0,t=this._effects.length;e<t;e++)this._effects[e].releaseInputTextureBindings()}recoverAllRTS(){this.clearCMD(),this._context.destination=null;for(let e of this._effects)e.clearRT(this._context);this._context.source=null,this._context.indirectTarget=null,this._context.destination=null,this._hasCleanRT=!0,uo._pendingPostRender.delete(this)}apply(){this._hasCleanRT&&(this.clearCMD(),this._render(),this._hasCleanRT=!1),this._context._apply(),this._releaseInputTextureBindings();for(let e=0,t=this._effects.length;e<t;e++){this._effects[e].clearRT(this._context)}this._hasCleanRT=!0}destroy(){this.recoverAllRTS(),this.owner=null,this._context.compositeShaderData.destroy(),this._context.compositeShaderData=null,this._effects.forEach(e=>e.destroy()),this._effects.length=0}}uo._pendingPostRender=new Set;class co{constructor(){this.deferredReleaseTextures=[],this.oriOffset=new $e}getRenderTexture(e,t,r,s){return Xa.createFromPool(e,t,r,s)}_apply(){this.command.apply(!0)}}const _o=we.NOT_IN_PAGE;new Ce;class po extends Wa{constructor(){super(),this._x=0,this._y=0,this._width=0,this._height=0,this._scaleX=1,this._scaleY=1,this._skewX=0,this._skewY=0,this._pivotX=0,this._pivotY=0,this._anchorX=0,this._anchorY=0,this._rotation=0,this._alpha=1,this._blendMode=e.BlendMode.invalid,this._visible=!0,this._mouseState=0,this._zOrder=0,this._renderType=0,this._subpassUpdateFlag=0,this.mouseThrough=!1,this.hitTestPrior=!1,this._autosize=!1,this._repaint=-1,this._repaintCount=-1,this._previousType=0,this._sizeFlag=0,this._cacheAsBmp=!1,this._layer=0,this._ownPostProcess=!1,this._manualRender=!1,this._struct=f.render2DRenderPassFactory.createRenderStruct2D(),this._struct.owner=this,this._globalTrans=new Ln(this),this._struct.transSlot=this._globalTrans.slot}_onActive(){super._onActive(),f.statAgent.recordCountData(e.StatElement.C_Sprite2DCount,1)}_onInActive(){super._onInActive(),f.statAgent.recordCountData(e.StatElement.C_Sprite2DCount,-1)}_initShaderData(){this._shaderData||(this._shaderData=f.renderDeviceFactory.createShaderData(),zt.initBlendMode(this._shaderData),zt.setShaderData(this._struct.blendMode,this._shaderData),this._struct.spriteShaderData=this._shaderData,this._struct.isRenderStruct=!0)}destroy(e=!0){super.destroy(e),this._texture&&(this._texture._removeReference(),this._texture=null),this._oriRenderPass&&(l.stage.passManager.removePass(this._oriRenderPass),this._oriRenderPass.postProcess&&(this._oriRenderPass.postProcess.destroy(),this._oriRenderPass.postProcess=null),this._oriRenderPass.destroy(),this._oriRenderPass=null),this._subStructRender&&(this._subStructRender.destroy(),this._subStructRender=null),this._graphicsRenderer&&(this._graphicsRenderer.destroy(),this._graphicsRenderer=null),this._drawOriRT&&(this._drawOriRT!==Xa._empty&&Xa.recoverToPool(this._drawOriRT),this._drawOriRT=null),this.setGraphics(null),this._struct&&(this._struct.destroy(),this._struct=null),this._globalTrans&&(this._globalTrans.destroy(),this._globalTrans=null)}get parent(){return this._$parent}get scene(){return this._scene}get x(){return this._x}set x(e){this.pos(e,this._y)}get y(){return this._y}set y(e){this.pos(this._x,e)}get width(){return this._autosize?this.getSelfBounds(go).width:1&this._sizeFlag?this._width:this.measureWidth()}set width(e){this.size(e,2&this._sizeFlag?this._height:null)}get height(){return this._autosize?this.getSelfBounds(go).height:2&this._sizeFlag?this._height:this.measureHeight()}set height(e){this.size(1&this._sizeFlag?this._width:null,e)}get _isWidthSet(){return!!(1&this._sizeFlag)}get _isHeightSet(){return!!(2&this._sizeFlag)}measureWidth(){return this._texture?this._texture.width:0}measureHeight(){return this._texture?this._texture.height:0}_isMaterialVaild(t){return t.checkType(e.ShaderFeatureType.D2_TextureSV)}get displayWidth(){return this.width*this.scaleX}get displayHeight(){return this.height*this.scaleY}get scaleX(){return this._scaleX}set scaleX(e){this.scale(e,this._scaleY)}get scaleY(){return this._scaleY}set scaleY(e){this.scale(this._scaleX,e)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._transChanged(e.TransformKind.Rotation))}get skewX(){return this._skewX}set skewX(e){this.skew(e,this._skewY)}get skewY(){return this._skewY}set skewY(e){this.skew(this._skewX,e)}get transform(){if(!this._tfChanged)return this._transform;this._tfChanged=!1;let e=this._transform||(this._transform=new Ce),t=this._scaleX,r=this._scaleY,s=this._skewX,i=this._skewY,a=this._rotation;if(a||1!==t||1!==r||0!==s||0!==i){e._bTransform=!0;let n=.0174532922222222*(a-s),o=.0174532922222222*(a+i),l=Math.cos(o),h=Math.sin(o),u=Math.sin(n),d=Math.cos(n);e.a=t*l,e.b=t*h,e.c=-r*u,e.d=r*d,e.tx=e.ty=0}else e.identity();return e}set transform(t){this._tfChanged=!1;let r=this._transform||(this._transform=new Ce);if(t!==r&&t.copyTo(r),t){let s=Ce.extractTransformInfo(t);this._x=s.x,this._y=s.y,this._scaleX=s.scaleX,this._scaleY=s.scaleY,this._skewX=s.skewX,this._skewY=s.skewY,this._rotation=s.rotation,r.tx=r.ty=0,this._transChanged(e.TransformKind.TRS)}this.parentRepaint()}get globalTrans(){return this._globalTrans}get pivotX(){return this._pivotX}set pivotX(e){this.pivot(e,this._pivotY)}get pivotY(){return this._pivotY}set pivotY(e){this.pivot(this._pivotX,e)}get anchorX(){return this._anchorX}set anchorX(e){this.anchor(e,this._anchorY)}get anchorY(){return this._anchorY}set anchorY(e){this.anchor(this._anchorX,e)}get alpha(){return this._alpha}set alpha(e){e=e<0?0:e>1?1:e,this._alpha!==e&&(this._alpha=e,Bn.instance.writeAlpha(this._globalTrans.slot,e),this.repaint())}get visible(){return this._visible}set visible(e){this._visible!==e&&(this._visible=e,this._processVisible())}get blendMode(){return 0===this._blendMode?null:e.BlendMode[this._blendMode]}set blendMode(t){let r=e.BlendMode[t];"number"!=typeof r&&(r="destination-out"===t?e.BlendMode.destinationOut:0),this._blendMode!=r&&(this._blendMode=r,this._initShaderData(),this._struct.blendMode=this._blendMode,this.repaint(e.RepaintFlag.Graphics))}get layer(){return this._layer}set layer(e){if(this._layer!==e){if(!(e>=0&&e<=30))throw new Error("Layer value must be 0-30.");this._layer=e,this._struct.renderLayer=1<<e}}_ensureGraphicsRenderer(){return this._graphicsRenderer||(this._graphicsRenderer=new qn(this),this._graphics&&this._graphicsRenderer.setGraphics(this._graphics)),this._graphicsRenderer}get graphics(){return this._graphics||(this.graphics=new Ga,this._ownGraphics=!0),this._graphics}set graphics(e){this.setGraphics(e,!1)}setGraphics(t,r){let s=this._graphics;this._graphics=null,s&&(this._ownGraphics?s.destroy():s.owner=null),this._ownGraphics=r,this._graphics=t,t?(t.owner=this,this._graphicsRenderer?this._graphicsRenderer.setGraphics(t):(t.cmds.length>0||this._texture)&&this._ensureGraphicsRenderer()):(this._graphicsRenderer&&(this._texture?this._graphicsRenderer.setGraphics(null):(this._graphicsRenderer.destroy(),this._graphicsRenderer=null)),this._texture||(this._renderType&=~Mr.GRAPHICS)),this.repaint(e.RepaintFlag.Graphics)}get filters(){return this._filterArr}set filters(e){if(e!==this._filterArr){if(e&&0===e.length&&(e=null),this._filterArr=e,e){let e=this.getPostProcess(!0);e.clear();for(let t of this._filterArr)e.addEffect(t.getEffect())}else this.postProcess=null;this.repaint()}}getPostProcess(e=!0){if(!this._oriRenderPass||!this._oriRenderPass.postProcess){if(!e)return null;this.postProcess=new uo,this._ownPostProcess=!0}return this._oriRenderPass.postProcess}get postProcess(){return this.getPostProcess(!1)}set postProcess(t){var r;if(null===(r=this._oriRenderPass)||void 0===r?void 0:r.postProcess){if(this._oriRenderPass.postProcess===t)return;this._ownPostProcess?(this._oriRenderPass.postProcess.destroy(),this._ownPostProcess=!1):this._oriRenderPass.postProcess.owner=null,this._oriRenderPass.postProcess=null,this.setSubpassFlag(e.SubPassFlag.PostProcess)}t&&(this._manualRender&&this._setManualRender(!1),this._oriRenderPass||this.createSubRenderPass(),t.owner=this,this._oriRenderPass.postProcess=t,this.setSubpassFlag(e.SubPassFlag.PostProcess))}get cacheAs(){return this._cacheAsBmp?"bitmap":"none"}set cacheAs(t){let r="bitmap"===t;r!==this._cacheAsBmp&&(r&&this._manualRender&&this._setManualRender(!1),this._cacheAsBmp=r,r?this._renderType|=Mr.CANVAS:this._renderType&=~Mr.CANVAS,this.setSubpassFlag(e.SubPassFlag.CacheAsBitmap),this.repaint(e.RepaintFlag.Graphics))}get mask(){return this._mask}set mask(t){if(t==this||t&&this._mask==t&&t._maskParent==this)return;if(t&&t.isAncestorOf(this))throw new Error("Mask cannot be ancestor of the masked object");t&&this._manualRender&&this._setManualRender(!1);let r=this._mask;r&&(r.cacheAs="none",r._maskParent=null),this._mask=t,t?(t._maskParent=this,t.cacheAs="bitmap",this._renderType|=Mr.MASK):this._renderType&=~Mr.MASK,t&&t._syncTransParent(),r&&r._syncTransParent(),this.setSubpassFlag(e.SubPassFlag.Mask),this.repaint()}_setManualRender(e){e!==this._manualRender&&(this._manualRender=e,e?this._enableManualRender():this._disableManualRender())}_enableManualRender(){this._renderType&Mr.DRAW2RT&&(this._cacheAsBmp&&(this.cacheAs="none"),this._mask&&(this.mask=null)),this._ensureSubPassBase(),this._subStruct.manualRender=!0,this._struct.subStruct=this._subStruct,this._subStruct.enabled=!0,this._oriRenderPass.enable=!1}_disableManualRender(){this._subStruct&&(this._subStruct.manualRender=!1,this._subStruct.enabled=!1,this._struct.subStruct=null,this._struct.setRepaint())}clearSubpassFlag(e){this._subpassUpdateFlag&=~e}setSubpassFlag(e){this._subpassUpdateFlag|=e,this._needUpdateSubpass()&&(this.stage._subpassUpdateList.add(this),this._globalTrans._notifyRenderSpriteTransChange())}_needUpdateSubpass(){let e=this._maskParent||this;return e.displayedInStage&&e._struct.enabled}get scrollRect(){return this._scrollRect}set scrollRect(t){null==this._scrollRect&&null==t||(this._scrollRect=t,t?this._renderType|=Mr.CLIP:this._renderType&=~Mr.CLIP,this._struct.setClipRect(t),this._oriRenderPass&&(this._oriRenderPass.repaint=!0),this._globalTrans._spTransChanged(e.TransformKind.Layout),this.repaint())}get viewport(){return null}set viewport(e){}set drawCallOptimize(t){this._struct.dcOptimize!==t&&(this._struct.dcOptimize=t,this._struct.setRepaint(),this.parentRepaint(),t&&this._globalTrans._spTransChanged(e.TransformKind.Layout))}get drawCallOptimize(){return this._struct.dcOptimize}set enableCulling(t){this._struct.enableCulling!==t&&(this._struct.enableCulling=t,this._struct.setRepaint(),this.parentRepaint(),t&&this._globalTrans._spTransChanged(e.TransformKind.Layout))}get enableCulling(){return this._struct.enableCulling}get hitArea(){return this._hitArea}set hitArea(e){this._hitArea=e}get mouseEnabled(){return 2===this._mouseState}set mouseEnabled(e){let t=e?2:1;this._mouseState!==t&&(this._mouseState=t,2===t&&this.setMouseEnabledUp())}setMouseEnabledUp(){let e=this._parent;for(;e&&e!==l.stage&&0===e._mouseState&&e._setBit(we.CHECK_INPUT,!0);)e=e._parent}getMousePoint(){return this.globalToLocal(mo.setTo(l.stage.mouseX,l.stage.mouseY))}get mouseX(){return this.getMousePoint().x}get mouseY(){return this.getMousePoint().y}get globalScaleX(){return this.globalTrans.scaleX}get globalScaleY(){return this.globalTrans.scaleY}get zOrder(){return this._zOrder}set zOrder(e){this._zOrder!=e&&(this._zOrder=e,this._parent&&(e&&this._parent._setBit(we.HAS_ZORDER,!0),l.systemTimer.callLater(this._parent,this.updateZOrder)))}get zIndex(){return this._struct.zIndex}set zIndex(e){this._struct.zIndex!==e&&(this._struct.zIndex=e,this.parentRepaint())}get stackingRoot(){return this._struct.stackingRoot}set stackingRoot(e){this._struct.stackingRoot=e}updateZOrder(){let e=this._$children;if(!e||e.length<2)return;let t,r,s,i,a=1,n=e.length,o=this._struct.children;for(;a<n;){for(t=a,s=e[t],i=o[t],r=e[t]._zOrder;--t>-1&&e[t]._zOrder>r;)e[t+1]=e[t],o[t+1]=o[t];e[t+1]=s,o[t+1]=i,a++}this._struct.children=o;let l=this._setBit(we.HAS_ZORDER,!1);this._childChanged(),l&&this._setBit(we.HAS_ZORDER,!0)}get texture(){return this._texture}set texture(t){if(this._texture==t)return;this._texture&&this._texture._removeReference(),this._texture=t,t&&t._addReference();let r=t?this._ensureGraphicsRenderer():this._graphicsRenderer,s=r&&r._spriteTextureChanged();this.repaint(s?0:e.RepaintFlag.Graphics)}get material(){var e;return null===(e=this._graphics)||void 0===e?void 0:e.material}set material(e){e&&!this._isMaterialVaild(e)||null==this._graphics&&null==e||(this.graphics.material=e)}get renderNode2D(){return this._renderNode}set renderNode2D(e){this._renderNode=e,e?(e.renderUpdate&&this._struct.setRenderUpdateCallback(e.renderUpdate.bind(e)),this._renderType|=Mr.RENDERNODE2D):(this._struct.setRenderUpdateCallback(null),this._renderType&=~Mr.RENDERNODE2D),this._graphics&&this._graphics.repaint()}get autoSize(){return this._autosize}set autoSize(e){this._autosize=e}pos(t,r){return this._x==t&&this._y==r||(this._x=t,this._y=r,this._transChanged(e.TransformKind.Pos)),this}pivot(t,r){if(this._pivotX!=t||this._pivotY!=r){this._pivotX=t,this._pivotY=r;let s=this.width;0!=s&&(this._anchorX=t/s),s=this.height,0!=s&&(this._anchorY=r/s),this._transChanged(e.TransformKind.Anchor)}return this}anchor(t,r){return this._anchorX==t&&this._anchorY==r||(this._anchorX=t,this._anchorY=r,this._pivotX=t*this.width,this._pivotY=r*this.height,this._transChanged(e.TransformKind.Anchor)),this}size(t,r){let s,i;return null==t?(s=!!(1&this._sizeFlag),this._sizeFlag&=-2):(s=this._width!=t||!(1&this._sizeFlag),this._width=t,this._pivotX=this._anchorX*t,this._sizeFlag|=1),null==r?(i=!!(2&this._sizeFlag),this._sizeFlag&=-3):(i=this._height!=r||!(2&this._sizeFlag),this._height=r,this._pivotY=this._anchorY*r,this._sizeFlag|=2),(s||i)&&this._transChanged((s?e.TransformKind.Width:0)|(i?e.TransformKind.Height:0)),this}scale(t,r){return this._scaleX===t&&this._scaleY===r||(this._scaleX=t,this._scaleY=r,this._transChanged(e.TransformKind.Scale)),this}skew(t,r){return this._skewX===t&&this._skewY===r||(this._skewX=t,this._skewY=r,this._transChanged(e.TransformKind.Skew)),this}_transChanged(t){var r,s;if(this._destroyed)return;this._oriRenderPass&&(this._oriRenderPass.repaint=!0);const i=this._struct.inheritedEnableCulling||this._struct.inheritedDcOptimize;let a=this._parent,n=a&&a._struct?a._struct.pass:null,o=i||!(!n||!n.renderTexture);t!==e.TransformKind.Pos&&t!==e.TransformKind.Anchor?(this._tfChanged=!0,0!==(this._renderType&Mr.DRAW2RT)?this.repaint():o&&this.parentRepaint(i)):o&&this.parentRepaint(i),null===(r=this._maskParent)||void 0===r||r.repaint(e.RepaintFlag.ChildChange),0!==(t&e.TransformKind.Size)&&(null===(s=this._graphicsRenderer)||void 0===s||s._ownerSizeChanged()),(0!==(t&e.TransformKind.TRS)||0!==(t&e.TransformKind.Anchor)||0!==(t&e.TransformKind.Size)&&(0!==this._anchorX||0!==this._anchorY||this._struct.inheritedDcOptimize))&&(this._globalTrans._spTransChanged(t),this._getBit(we.DEMAND_TRANS_EVENT)&&To(this))}drawToCanvas(e,t,r,s){return po.drawToCanvas(this,e,t,r,s)}static drawToCanvas(e,t,r,s,i){let a=po.drawToRenderTexture2D(e,t,r,s,i,null);for(var n=a.getData(0,0,t,r),o=new ImageData(t,r),l=4*t,h=o.data,u=r-1,d=u*l,c=0;u>=0;u--)h.set(n.subarray(c,c+l),d),d-=l,c+=l;let _=new Me;return _.size(t,r),_.context.putImageData(o,0,0),a.destroy(),_}drawToTexture(e,t,r,s,i=null,a=!0){return po.drawToTexture(this,e,t,r,s,i,a)}static drawToTexture(e,t,r,s,i,a=null,n=!0){return po.drawToRenderTexture2D(e,t,r,s,i,a,n)}drawToRenderTexture2D(e,t,r,s,i,a,n,o,l=1,h=1){return po.drawToRenderTexture2D(this,e,t,r,s,i,a,n,o,l,h)}static drawToRenderTexture2D(t,r,s,i,a,n,o,l,h,u=1,d=1){var c;let _=n||new Xa(r,s,e.RenderTargetFormat.R8G8B8A8);_._invertY=l,f.renderEngine._screenInvertY&&(_._invertY=!_._invertY);let p=new va,g=p.basePass;h&&(g.setClearColor(h.r,h.g,h.b,h.a),g.doClearColor=!0);let{root:m,subPasses:T}=t.prepareOSR();for(let e of T)p.addPass(e);g.renderTexture=_,g.root=m;let y=g.offsetMatrix;y.identity();let x=t.transform;x&&x.copyTo(y),y.scale(u,d),y.invert(),y.tx=-i,y.ty=-a,g.offsetMatrix=y;let S=null===(c=t._struct.globalRenderData)||void 0===c?void 0:c.globalShaderData,E=!1;return S&&S.hasDefine(kt.SHADERDEFINE_CAMERA2D)&&(E=!0,S.removeDefine(kt.SHADERDEFINE_CAMERA2D)),p.apply(va.rendercontext2D),E&&S.addDefine(kt.SHADERDEFINE_CAMERA2D),p.clear(),g.destroy(),_}prepareOSR(){let t=va.runner,r=new Set;const s=function(i){if(i._struct&&i._struct.enabled){if(i._subpassUpdateFlag)if(i._manualRender)i._subpassUpdateFlag=0;else if(i.updateSubRenderPassState(),i._oriRenderPass){let t=i.updateRenderTexture(),r=i._drawOriRT;if(r){i._oriRenderPass.renderTexture=r,i.mask?i._oriRenderPass.mask=i.mask._struct:i._oriRenderPass.mask=null,t&&(i._oriRenderPass.renderTexture=r);let s=i._renderType&Mr.POSTPROCESS?i.postProcess:null;s&&r!=Xa._empty&&((t||i._subpassUpdateFlag&e.SubPassFlag.UPDATE_POSTPROCESS)&&(s.setResource(r),s.clearCMD(),s._render()),s.enabled&&(r=s._context.destination)),i._subStructRender._updateRenderTexture(i._drawOriRT,r),i._subpassUpdateFlag=0}else i.setSubRenderPassState(!1)}i._struct&&(i._updateStruct(),i._struct.pass&&r.add(i._struct.pass)),i._graphicsRenderer&&i._graphicsRenderer._render(t);for(let e=0,t=i._children.length;e<t;e++)s(i._children[e])}};return s(this),{root:this._oriRenderPass&&this._oriRenderPass.enable?this._subStruct:this._struct,subPasses:Array.from(r).filter(e=>e.priority>0)}}hitTestPoint(e,t){let r=this.globalToLocal(mo.setTo(e,t));return e=r.x,t=r.y,(this._hitArea?this._hitArea:this._isWidthSet&&this._isHeightSet?go.setTo(0,0,this._width,this._height):this.getGraphicBounds(!1,go)).contains(e,t,this)}setSelfBounds(e){this._userBounds=e}getBounds(e){return e=this.getSelfBounds(e,!0),Tn.transformRect(this,e,this._parent,e)}getSelfBounds(e,t){var r;if(null==t&&(t=!0),null!=this._userBounds)return this._userBounds.clone(e);if(null==this._scrollRect||this._getBit(we.DISABLE_INNER_CLIPPING)){if(!t&&(null===(r=this._oriRenderPass)||void 0===r?void 0:r.enable))return this._subStructRender._rtRect.clone(e);if(e=this.getGraphicBounds(!1,e),t&&this._children.length>0){let t=te.create();for(let r of this._children)r._struct.enabled&&r._maskParent!=this&&(r.getBounds(t),e.union(t,e));t.recover()}return e}return this._scrollRect.clone(e)}getGraphicBounds(e,t){if(t?t.setTo(0,0,0,0):t=new te,null!=this._graphics&&t.union(this._graphics.getBounds(),t),null!=this._texture){let e=this._texture,r=this._isWidthSet?this._width:e.sourceWidth,s=this._isHeightSet?this._height:e.sourceHeight;if(0!==e.sourceWidth&&0!==e.sourceHeight){let i=r/e.sourceWidth,a=s/e.sourceHeight;t.union(go.setTo(e.offsetX*i,e.offsetY*a,e.width*i,e.height*a),t)}else t.union(go.setTo(0,0,r,s),t)}if(null!=this._renderNode){let e=this._renderNode.rect;te.minMaxRect(e.x,e.y,e.z,e.w,go),t.union(go,t),go.setTo(0,0,this._width,this._height),t.union(go,t)}return t}localToGlobal(e,t,r){t&&(e=new d(e.x,e.y));let s=this;for(r=r||l.stage;s&&!s._destroyed&&s!=r;)e=s.toParentPoint(e),s=s._parent;return e}globalToLocal(e,t,r){t&&(e=new d(e.x,e.y));let s=this;for(fo.length=0,r=r||l.stage;s&&!s._destroyed&&s!=r;)fo.push(s),s=s._parent;let i=fo.length-1;for(;i>=0;)s=fo[i],e=s.fromParentPoint(e),i--;return e}toParentPoint(e){var t;if(!e)return e;e.x-=this.pivotX,e.y-=this.pivotY,null===(t=this.transform)||void 0===t||t.transformPoint(e),e.x+=this._x,e.y+=this._y;let r=this._scrollRect;return r&&(e.x-=r.x*this._scaleX,e.y-=r.y*this._scaleY),e}fromParentPoint(e){var t;if(!e)return e;e.x-=this._x,e.y-=this._y;var r=this._scrollRect;return r&&(e.x+=r.x*this._scaleX,e.y+=r.y*this._scaleY),null===(t=this.transform)||void 0===t||t.invertTransformPoint(e),e.x+=this.pivotX,e.y+=this.pivotY,e}loadImage(e,t){if(e){let r=l.loader.getRes(e);r?(this.texture=r,t&&t.run()):(this._skinBaseUrl&&(e=ee.formatURL(e,this._skinBaseUrl)),l.loader.load(e).then(e=>{this.texture=e,t&&t.run()}))}else this.texture=null,t&&t.run();return this}static fromImage(e){return(new po).loadImage(e)}reCache(){(this._cacheAsBmp||this._mask)&&this.repaint()}getRepaint(){return this._repaint}repaint(t){this._destroyed||((this._repaint<Ua.loopCount||this._repaint===Ua.loopCount&&this._repaintCount<Ua.render2DCount||!this._previousType)&&(this._repaint=Ua.loopCount,this._repaintCount=Ua.render2DCount,this._previousType=this._renderType,this._struct.setRepaint(),this.stage._graphicUpdateList.add(this),this.parentRepaint(),this._renderType&Mr.DRAW2RT&&(!this._drawOriRT||this._drawOriRT===Xa._empty||this._subpassUpdateFlag||t&e.RepaintFlag.UpdateRT||this.transform&&this._maskParent)&&this.setSubpassFlag(e.SubPassFlag.RenderTexture),this._renderType&Mr.GRAPHICS&&(t&e.RepaintFlag.Graphics&&this._graphicsRenderer&&this._graphicsRenderer.invalidateGraphicsState(),this._globalTrans._notifyRenderSpriteTransChange())),this._maskParent&&(this._maskParent.setSubpassFlag(e.SubPassFlag.Mask),this._maskParent.repaint(t)))}_needGraphicsUpdate(){var e;return!this._destroyed&&this._struct.enabled&&!!(null===(e=this._graphicsRenderer)||void 0===e?void 0:e.getNeedRenderUpdate())&&!(!this.displayedInStage&&!this._maskParent)}clearRepaint(){this._repaint=-1,this._repaintCount=-1}_needRepaint(){return!!(this._repaint>=Ua.loopCount&&this._repaintCount>=f.renderEngine._framePassCount&&0===this._previousType)}parentRepaint(t=!0){let r=this._parent;if(!r)return;let s=r._struct,i=s?s.pass:null;s&&i&&(i.renderTexture?(r.parentRepaint(),r._renderType&Mr.DRAW2RT&&!r._needRepaint()&&(r.setSubpassFlag(e.SubPassFlag.RenderTexture),s.setRepaint())):t&&s.setRepaint())}get dragSupport(){return this._dragSupport||(this._dragSupport=new mn(this))}startDrag(e,t,r,s,i,a){let n=this.dragSupport;null!=e?n.area.copyFrom(e):n.area.reset(),n.hasInertia=!!t,null!=r&&(n.elasticDistance=r),null!=s&&(n.elasticBackTime=s),null!=a&&(n.ratio=a),n.start(i)}stopDrag(){this._dragSupport&&this._dragSupport.stop()}onAfterDeserialize(){super.onAfterDeserialize(),p.isPlaying&&(this._gcmds&&(this.graphics.cmds=this._gcmds,delete this._gcmds),this._filters&&(this.filters=this._filters,delete this._filters)),2===this._mouseState&&this.setMouseEnabledUp()}onStartListeningToType(e){super.onStartListeningToType(e),c.isMouseEvent(e)?0===this._mouseState&&(this._setBit(we.CHECK_INPUT,!0),this.setMouseEnabledUp()):e===c.TRANSFORM_CHANGED?this._setDemandTransEvent():e===Ln.CHANGED&&(this._globalTrans._hasChangedListener=!0)}_setDemandTransEvent(){this._setBit(we.DEMAND_TRANS_EVENT,!0),this.setDemandTransEventUp()}setDemandTransEventUp(){let e=this._parent;for(;e&&e!==l.stage&&e._setBit(we.DEMAND_TRANS_EVENT,!0);)e=e._parent}_refreshDemandTransEventUp(){let e=this;for(;e&&e!==l.stage;){let t=e.hasListener(c.TRANSFORM_CHANGED);if(!t)for(let r of e._children)if(r instanceof po&&r._getBit(we.DEMAND_TRANS_EVENT)){t=!0;break}if(!e._setBit(we.DEMAND_TRANS_EVENT,t))break;e=e._parent instanceof po?e._parent:null}}_processVisible(e){null==e&&(e=!(this._parent instanceof po)||this._parent._struct.enabled);let t=e&&this._visible&&!this._getBit(_o),r=!1;return this._struct&&this._struct.enabled!==t&&(r=!0,this._struct.enabled=t,t?this.repaint():this._struct.setRepaint(),this.parentRepaint(),this._checkSubRenderPass(),this._refreshRenderPass(),this._processChildrenVisible(t)),r}_processChildrenVisible(e){for(let t of this._children)t instanceof po&&t._processVisible(e)}_setUnBelongScene(){null!=this._ownerArea&&(this._ownerArea=null),super._setUnBelongScene()}_setBelongScene(e){super._setBelongScene(e),this._findOwnerArea()}_findOwnerArea(){let e=this;for(;e&&e!==this._scene&&e!==l.stage;){if(e._globalRenderData){this._ownerArea=e;break}e=e._parent}}_setStructParent(e,t){let r=this._struct;r&&r.parent&&(r.parent.removeChild(r),r.parent=null),e&&e._struct&&e._struct.addChild(r,t)}_ensureSubPassBase(){if(this._oriRenderPass)return;let e=f.render2DRenderPassFactory.createRender2DPass();e.root=this._struct,e.enable=!1,e.setClearColor(0,0,0,0);let t=f.render2DRenderPassFactory.createRenderStruct2D();t.owner=this,t.pass=e,this._subStruct=t,this._oriRenderPass=e,t.transSlot=this._globalTrans.slot}_ensureSubStructRender(){this._subStructRender||(this._subStructRender=new Un,this._subStructRender.bind(this,this._oriRenderPass,this._subStruct))}createSubRenderPass(){this._ensureSubPassBase(),this._ensureSubStructRender()}updateRenderTexture(){let r=te.create(),s=te.create();this._mask?(Tn.getRect(this._mask,!1,r),this._mask.transform&&r.transform(this._mask.transform,r),r.x+=this._mask._pivotX,r.y+=this._mask._pivotY):(Tn.getRect(this,!1,r),this._maskParent&&this.transform&&r.transform(this.transform,r),r.x+=this._pivotX,r.y+=this._pivotY);let i=1,a=1,n=this._drawOriRT,o=this._subStructRender._rtRect,h=t.isSpriteRenderTextureAntialias&&f.renderEngine.getCapable(e.RenderCapable.MSAA)?4:1;if(r.width=Wr.roundTo(r.width),r.height=Wr.roundTo(r.height),r.cloneTo(s),t.useRetinalCanvas&&(i=l.stage._scaleX,a=l.stage._scaleY,r.x=r.x*i,r.y=r.y*a),r.width=Math.ceil(r.width*i),r.height=Math.ceil(r.height*a),n){if(o.width===r.width&&o.height===r.height&&(n===Xa._empty||n.samples===h))return this._subStructRender._updateRenderOffset(r,s,i,a),r.recover(),s.recover(),!1;n!==Xa._empty&&Xa.recoverToPool(n)}if(this._subStructRender._updateRenderOffset(r,s,i,a),0===r.width||0===r.height)this._drawOriRT=Xa._empty;else{let t=Xa.createFromPool(r.width,r.height,e.RenderTargetFormat.R8G8B8A8,e.RenderTargetFormat.DEPTHSTENCIL_24_8,h);t._invertY=f.renderEngine._screenInvertY,this._drawOriRT=t}return r.recover(),s.recover(),!0}updateSubRenderPassState(){this.setSubRenderPassState(0!==(this._renderType&Mr.DRAW2RT))}_updateStruct(){if(this._destroyed)return;let e=this._struct,t=e.rect;if(this._struct.inheritedEnableCulling||this._struct.inheritedDcOptimize){let r=e.renderMatrix;this.getSelfBounds(t,!1),t.transform(r,t),e.rect=t}else e.rect.reset();this._subStruct&&(t.cloneTo(this._subStruct.rect),this._subStruct.rect=this._subStruct.rect)}setSubRenderPassState(t){if(!this._oriRenderPass){if(!t)return;this.createSubRenderPass()}t&&!this._oriRenderPass.enable?(this._struct.pass=this._oriRenderPass,this._struct.subStruct=this._subStruct,this._subStruct.enabled=!0,this._maskParent&&(this._subStruct.blendMode=e.BlendMode.mask)):!t&&this._oriRenderPass&&this._oriRenderPass.enable&&(this._subStruct.enabled=!1,this._subStruct.blendMode=this._blendMode,this._struct.subStruct=null,this._struct.pass=null,this._struct.setRepaint()),this._oriRenderPass.enable=t,this._refreshRenderPass()}_setParent(t,r=-1){let s=this._parent instanceof po?this._parent:null;this._globalTrans._spTransChanged(e.TransformKind.TRS),this._setStructParent(t,r),super._setParent(t,r),this._syncTransParent(),this._processVisible(),t&&(2===this._mouseState||0===this._mouseState&&this._getBit(we.CHECK_INPUT))&&!t._getBit(we.CHECK_INPUT)&&this.setMouseEnabledUp(),s&&s!==t&&this._getBit(we.DEMAND_TRANS_EVENT)&&s._refreshDemandTransEventUp(),t&&this._getBit(we.DEMAND_TRANS_EVENT)&&!t._getBit(we.DEMAND_TRANS_EVENT)&&this.setDemandTransEventUp()}_syncTransParent(){const e=this._globalTrans.slot;if(-1===e)return;let t=-1;const r=this._parent;r instanceof po?t=r._globalTrans.slot:this._maskParent&&(t=this._maskParent._globalTrans.slot),Bn.instance.setParent(e,t)}_checkSubRenderPass(){this._needUpdateSubpass()?(this._subpassUpdateFlag||this._renderType&Mr.DRAW2RT&&(!this._drawOriRT||this._drawOriRT===Xa._empty))&&this.setSubpassFlag(e.SubPassFlag.RenderTexture):this._subpassUpdateFlag&&l.stage._subpassUpdateList.delete(this),this._mask&&this._mask._checkSubRenderPass()}_refreshRenderPass(){if(this._oriRenderPass){this._needUpdateSubpass()&&this._oriRenderPass.enable&&this._renderType&Mr.DRAW2RT?l.stage.passManager.addPass(this._oriRenderPass):(this._oriRenderPass.postProcess&&this._oriRenderPass.postProcess.recoverAllRTS(),this._drawOriRT&&this._drawOriRT!==Xa._empty&&(this._subStructRender._clearRenderTexture(),Xa.recoverToPool(this._drawOriRT),this._subStructRender._clearRenderTexture()),this._drawOriRT=null,this._oriRenderPass.repaint=!0,l.stage.passManager.removePass(this._oriRenderPass))}this._mask&&(this._mask._refreshRenderPass(),this._mask.displayedInStage||this._mask.repaint(e.RepaintFlag.Graphics))}_setDisplay(e){super._setDisplay(e),this._needGraphicsUpdate()&&(this.stage._graphicUpdateList.add(this),this._globalTrans._notifyRenderSpriteTransChange()),this._checkSubRenderPass(),this._refreshRenderPass()}_setChildIndex(e,t,r){let s=super._setChildIndex(e,t,r);return e._struct&&e._parent._struct.updateChildIndex(e._struct,t,s),s}_childChanged(t){super._childChanged(t),t&&t._zOrder&&this._setBit(we.HAS_ZORDER,!0),this._getBit(we.HAS_ZORDER)&&l.systemTimer.callLater(this,this.updateZOrder),this.repaint(e.RepaintFlag.ChildChange)}_addComponentInstance(e){var t;e instanceof Dn&&(null===(t=this._components)||void 0===t?void 0:t.some(e=>e instanceof Dn))?console.warn(`${this.name} add RenderNode2D invalid, one sprite can only add one RenderNode`):super._addComponentInstance(e)}}const go=new te,mo=new d,fo=[];function To(e){e.event(c.TRANSFORM_CHANGED);for(let t of e._children)t._getBit(we.DEMAND_TRANS_EVENT)&&To(t)}var yo=!0;const xo=new d,So=new te,Eo=[],vo=[];var Do;class wo{constructor(){this._touches=[],this._touchPool=[],this._mouseTouch=new Co(this._touches),this._pressKeys=new Set,this._keyEvent=new c,this._keyEvent._touches=this._touches}static get inst(){return Do}static getTouchPos(e){var t;return null==e&&(e=wo.lastTouchId),(null===(t=Do.getTouch(e))||void 0===t?void 0:t.pos)||Do._mouseTouch.pos}static get touchTarget(){return Do._touchTarget}static get touches(){return Do._touches}static get touchCount(){return Do._touches.length}static cancelClick(e){null==e&&(e=wo.lastTouchId);let t=Do.getTouch(e);t&&(t.clickCancelled=!0)}static hasKeyDown(e){return Do._pressKeys.has(e)}static __init__(){let e=Do=new wo;e._stage=l.stage;let t=Y.mainCanvas.source,r={passive:!1};t.oncontextmenu=()=>!1,t.addEventListener("mousedown",t=>{Y.onIE||t.cancelable&&t.preventDefault(),e.handleMouse(t,0)},r),t.addEventListener("mouseup",t=>{t.cancelable&&t.preventDefault(),e.handleMouse(t,1)},r),t.addEventListener("mousemove",t=>{t.cancelable&&t.preventDefault(),e.handleMouse(t,2)},r),t.addEventListener("mouseout",t=>{e.handleMouse(t,3)},r),t.addEventListener("touchstart",t=>{yo||W.textInput.target||t.cancelable&&t.preventDefault(),e.handleTouch(t,0)},r),t.addEventListener("touchend",t=>{yo||W.textInput.target||t.cancelable&&t.preventDefault(),yo=!1,e.handleTouch(t,1)},r),t.addEventListener("touchmove",t=>{t.cancelable&&t.preventDefault(),e.handleTouch(t,2)},r),t.addEventListener("touchcancel",t=>{t.cancelable&&t.preventDefault(),e.handleTouch(t,3)},r),t.addEventListener("wheel",t=>{e.handleMouse(t,4)},r),"function"==typeof t.setPointerCapture&&(t.addEventListener("pointerdown",e=>{t.setPointerCapture(e.pointerId)}),t.addEventListener("pointerup",e=>{t.releasePointerCapture(e.pointerId)},!0));let s=Y.document;s.addEventListener("keydown",t=>{e.handleKeys(t)},!0),s.addEventListener("keypress",t=>{e.handleKeys(t)},!0),s.addEventListener("keyup",t=>{e.handleKeys(t)},!0),Y.window.addEventListener("blur",()=>{e._pressKeys.clear()})}handleMouse(e,t){this._eventType=t,this._nativeEvent=e,wo.lastTouchId=0;let r=performance.now();if(null!=this._lastTouchTime&&r-this._lastTouchTime<100)return;let s=this._mouseTouch;xo.setTo(e.pageX||e.clientX,e.pageY||e.clientY),this._stage._canvasTransform.invertTransformPoint(xo),wo.mouseX=xo.x,wo.mouseY=xo.y;let i=xo.x/this._stage.clientScaleX,a=xo.y/this._stage.clientScaleY;if(s.event.nativeEvent=e,3!=t&&wo.mouseEventsEnabled){s.target=this._touchTarget=this.getNodeUnderPoint(i,a);let e=Math.round(i),t=Math.round(a);if((e!=s.pos.x||t!=s.pos.y)&&(wo.lastMouseTime=r,s.pos.setTo(e,t),s.move(),wo.mouseEventsEnabled)){s.bubble(c.MOUSE_MOVE);for(let e of s.downTargets)if(s.event._stopped=!1,e.event(c.MOUSE_DRAG,s.event),s.event._stopped)break}}else s.target=this._touchTarget=null;if(s.lastRollOver!=s.target&&this.handleRollOver(s),0==t)s.began||(s.begin(),this._touches[0]=s,s.event.button=e.button,s.downButton=e.button,wo.onMouseDownCapture.invoke(s.touchId),wo.mouseEventsEnabled&&(0==e.button?s.bubble(c.MOUSE_DOWN):s.bubble(c.RIGHT_MOUSE_DOWN)));else if(1==t){if(s.began&&e.button==s.downButton){if(s.end(),this._touches.length=0,s.event.button=e.button,wo.mouseEventsEnabled){if(0==e.button?s.bubble(c.MOUSE_UP):s.bubble(c.RIGHT_MOUSE_UP),s.moved)for(let e of s.downTargets)e.event(c.MOUSE_DRAG_END,s.event);let t=s.clickTest();t&&(0==e.button?(s.event.isDblClick=2==s.clickCount,s.bubble(c.CLICK,t),2==s.clickCount&&s.bubble(c.DOUBLE_CLICK,t),s.event.isDblClick=!1):(s.event.isDblClick=2==s.clickCount,s.bubble(c.RIGHT_CLICK,t),s.event.isDblClick=!1))}s.event.button=0}}else 4==t&&wo.mouseEventsEnabled&&(s.event.delta=.025*e.deltaY,s.bubble(c.MOUSE_WHEEL),s.event.delta=0)}handleTouch(e,t){this._eventType=t,this._nativeEvent=e,this._lastTouchTime=performance.now();let r=e.changedTouches;for(let s=0;s<r.length;++s){let i=r[s];if(!wo.multiTouchEnabled&&this._touches.length>0&&this._touches[0].touchId!=i.identifier)continue;xo.setTo(i.pageX,i.pageY),this._stage._canvasTransform.invertTransformPoint(xo),wo.mouseX=xo.x,wo.mouseY=xo.y;let a=xo.x/this._stage.clientScaleX,n=xo.y/this._stage.clientScaleY,o=this.getTouch(i.identifier,0==t);if(o){if(o.event.nativeEvent=e,o.event.touchId=o.touchId,wo.lastTouchId=o.touchId,3!=t&&wo.mouseEventsEnabled){o.target=this._touchTarget=this.getNodeUnderPoint(a,n),wo.lastMouseTime=this._lastTouchTime;let e=Math.round(a),r=Math.round(n);if((Math.abs(e-o.pos.x)>1.5||Math.abs(r-o.pos.y)>1.5)&&(o.pos.setTo(e,r),2==t&&(o.move(),wo.mouseEventsEnabled))){o.bubble(c.MOUSE_MOVE);for(let e of o.downTargets)if(o.event._stopped=!1,e.event(c.MOUSE_DRAG,o.event),o.event._stopped)break}}else o.target=this._touchTarget=null;if(o.lastRollOver!=o.target&&this.handleRollOver(o),0==t)o.began||(o.begin(),wo.onMouseDownCapture.invoke(o.touchId),wo.mouseEventsEnabled&&o.bubble(c.MOUSE_DOWN));else if(1==t||3==t){if(o.began){if(o.end(),wo.mouseEventsEnabled){if(o.bubble(c.MOUSE_UP),o.moved)for(let e of o.downTargets)e.event(c.MOUSE_DRAG_END,o.event);if(3!=t){let e=o.clickTest();null!=e&&(o.event.isDblClick=2==o.clickCount,o.bubble(c.CLICK,e),2==o.clickCount&&o.bubble(c.DOUBLE_CLICK,e),o.event.isDblClick=!1)}}o.target=null,this.handleRollOver(o)}o.reset(),this._touches.splice(this._touches.indexOf(o),1),this._touchPool.push(o)}}}}getTouch(e,t){let r=this._touches.find(t=>t.touchId==e);return r||!t||(r=this._touchPool.length>0?this._touchPool.pop():new Co(this._touches),r.touchId=e,this._touches.push(r)),r}handleKeys(e){let t=e.type,r=e.keyCode;if("keydown"===t?(0!=r&&this._pressKeys.add(r),this._pressKeys.add(e.key)):"keyup"===t&&(0!=r&&this._pressKeys.delete(r),this._pressKeys.delete(e.key)),this._keyEvent.nativeEvent=e,this._keyEvent._defaultPrevented=!1,wo.keyEventsEnabled){let e=this._stage.focus&&this._stage.focus.displayedInStage?this._stage.focus:this._stage,r=e;for(;r;)r.event(t,this._keyEvent.setTo(t,r,e)),r=r._parent}this._keyEvent._defaultPrevented&&e.preventDefault(),this._keyEvent.nativeEvent=null}getNodeUnderPoint(e,t){let r=this.getSpriteUnderPoint(this._stage,e,t);return r||(r=this.getSprite3DUnderPoint(e,t)),r||this._stage}getSpriteUnderPoint(e,t,r){0!==(e._renderType&Mr.AREA2D)&&p.isPlaying&&!wo._previewFlag&&(e.localToView(t,r,d.TEMP),t=d.TEMP.x,r=d.TEMP.y);let s=e._scrollRect;if(s&&!e._getBit(we.DISABLE_INNER_CLIPPING)&&(So.setTo(s.x,s.y,s.width,s.height),!So.contains(t,r)))return null;let i=e._getBit(we.EDITING_NODE);if(!i&&e.hitTestPrior&&!e.mouseThrough&&e!=this._stage&&!this.hitTest(e,t,r))return null;for(let s=e._children.length-1;s>-1;s--){let a=e._children[s],n=i||a._getBit(we.EDITING_NODE);if(!a._destroyed&&1!==a._nodeType&&(n?!a.hasHideFlag(Re.HideInHierarchy)||a.mouseThrough:2===a._mouseState||0===a._mouseState&&a._getBit(we.CHECK_INPUT)||wo._previewFlag)&&a._struct.enabled){xo.setTo(t,r),a.fromParentPoint(xo);let e=this.getSpriteUnderPoint(a,xo.x,xo.y);if(e)return e}}if(wo._previewFlag&&(e._getBit(we.LOCK_BY_EDITOR)||e._getBit(we.HIDE_BY_EDITOR)||e.hasHideFlag(Re.HideInHierarchy)))return null;if(i){if(!e._getBit(we.LOCK_BY_EDITOR)&&!e.hasHideFlag(Re.HideInHierarchy)&&this.hitTest(e,t,r,i))return e}else if(e!=this._stage&&(e.hitTestPrior&&!e.mouseThrough||this.hitTest(e,t,r)))return e;return null}getSprite3DUnderPoint(e,t){return null}hitTest(e,t,r,s){let i=!1;e._scrollRect&&(t-=e._scrollRect.x,r-=e._scrollRect.y);let a=e._hitArea,n=e.mouseThrough;return s&&(a=null,n=!1),a?a.contains(t,r,e):((e.width>0&&e.height>0||n||a)&&(i=n?e.getGraphicBounds(!1,te.TEMP).contains(t,r):(a||So.setTo(0,0,e.width,e.height)).contains(t,r,e)),i)}handleRollOver(e){if(!wo.mouseEventsEnabled)return void(e.lastRollOver=e.target);Eo.length=0,vo.length=0;let t=e.lastRollOver;for(;t;)vo.push(t),t=t._parent;for(e.lastRollOver=e.target,t=e.target;t;){let e=vo.indexOf(t);if(-1!=e){vo.splice(e,vo.length-e);break}Eo.push(t),t=t._parent}let r=vo.length;if(r>0){for(let s=0;s<r;s++)t=vo[s],t._destroyed||t.event(c.MOUSE_OUT,e.event.setTo(c.MOUSE_OUT,t,t));vo.length=0}if(r=Eo.length,r>0){for(let s=0;s<r;s++)t=Eo[s],t.activeInHierarchy&&t.event(c.MOUSE_OVER,e.event.setTo(c.MOUSE_OVER,t,t));Eo.length=0}}}wo.multiTouchEnabled=!0,wo.mouseEventsEnabled=!0,wo.keyEventsEnabled=!0,wo.clickTestThreshold=10,wo.mouseX=0,wo.mouseY=0,wo.lastMouseTime=0,wo.lastTouchId=0,wo.onMouseDownCapture=new B,wo._previewFlag=!1;const Ro={};class Co{constructor(e){this.downPos=new d,this.downTargets=[],this.bubbleChain=[],this.event=new c,this.event._touches=e,this.pos=this.event.touchPos,this.touchId=0,this.reset()}begin(){if(this.began=!0,this.clickCancelled=!1,this.moved=!1,this.downPos.copy(this.pos),this.downTargets.length=0,this.target){let e=this.target;for(;e;)this.downTargets.push(e),e=e._parent}}move(){this.moved=!0;let e=Math.abs(this.pos.x-this.downPos.x)*l.stage._canvasTransform.getScaleX(),t=Math.abs(this.pos.y-this.downPos.y)*l.stage._canvasTransform.getScaleY();(e>wo.clickTestThreshold||t>wo.clickTestThreshold)&&(this.clickCancelled=!0)}end(){this.began=!1;let e=performance.now(),t=Ro[this.touchId];t||(t={pos:new d,time:0,button:0},Ro[this.touchId]=t),0==this.downTargets.length||this.clickCancelled||Math.abs(this.pos.x-this.downPos.x)>wo.clickTestThreshold||Math.abs(this.pos.y-this.downPos.y)>wo.clickTestThreshold?(this.clickCancelled=!0,t.time=0,this.clickCount=1):(e-t.time<350&&Math.abs(this.pos.x-t.pos.x)<wo.clickTestThreshold&&Math.abs(this.pos.y-t.pos.y)<wo.clickTestThreshold&&t.button==this.event.button?this.clickCount=2:this.clickCount=1,t.time=e,t.pos.copy(this.pos),t.button=this.event.button)}clickTest(){if(this.clickCancelled)return this.downTargets.length=0,null;let e=this.downTargets[0];if(e.activeInHierarchy)return this.downTargets.length=0,e;for(e=this.target;e;){if(-1!=this.downTargets.indexOf(e)&&e.activeInHierarchy)break;e=e._parent}return this.downTargets.length=0,e}reset(){this.pos.setTo(0,0),this.touchId=0,this.clickCount=0,this.began=!1,this.moved=!1,this.target=null,this.downTargets.length=0,this.lastRollOver=null,this.clickCancelled=!1,this.downButton=0}bubble(e,t){let r=this.bubbleChain;r.length=0;let s=t=t||this.target||l.stage;for(;s;)s.activeInHierarchy&&r.push(s),s=s._parent;let i=this.event;i._stopped=!1;for(let s of r)if(i.setTo(e,s,t),s.event(e,i),i._stopped){if(e===c.MOUSE_DOWN||e===c.RIGHT_MOUSE_DOWN){let e=this.downTargets.indexOf(s);-1!=e&&this.downTargets.splice(e+1,this.downTargets.length-e-1)}break}if(e===c.MOUSE_UP||e===c.RIGHT_MOUSE_UP)for(let s of this.downTargets)if(s&&-1==r.indexOf(s)&&(i.setTo(e,s,t),s.event(e,i),i&&i._stopped))break}}class Mo{constructor(){this._onUpdates=new Set,this._onLateUpdates=new Set,this._onAfterSceneUpdates=new Set,this._onPreRenders=new Set,this._onPostRenders=new Set,this._toStarts=new Set,this._toDestroys=new Set}callStart(){for(let e of this._toStarts)if(2==e._status){e._status=3;try{e.onStart()}catch(e){this.onError(e)}}this._toStarts.clear()}callUpdate(){let t=performance.now();for(let e of this._onUpdates)if(3==e._status)try{e.onUpdate()}catch(e){this.onError(e)}f.statAgent.recordTimeData(e.StatElement.T_ScriptUpdateTime,performance.now()-t)}callLateUpdate(){let t=performance.now();for(let e of this._onLateUpdates)if(3==e._status)try{e.onLateUpdate()}catch(e){this.onError(e)}f.statAgent.recordTimeData(e.StatElement.T_ScriptLateUpdateTime,performance.now()-t)}callAfterSceneUpdate(){for(let e of this._onAfterSceneUpdates)if(3==e._status)try{e.onAfterSceneUpdate()}catch(e){this.onError(e)}}callPreRender(){for(let e of this._onPreRenders)if(3==e._status)try{e.onPreRender()}catch(e){this.onError(e)}}callPostRender(){for(let e of this._onPostRenders)if(3==e._status)try{e.onPostRender()}catch(e){this.onError(e)}}callDestroy(){for(let e of this._toDestroys)try{e._destroy(!0)}catch(e){this.onError(e)}this._toDestroys.clear()}add(e){1==e._status&&(e.onStart?(e._status=2,this._toStarts.add(e)):e._status=3),e.onUpdate&&this._onUpdates.add(e),e.onLateUpdate&&this._onLateUpdates.add(e),e.onAfterSceneUpdate&&this._onAfterSceneUpdates.add(e),e.onPreRender&&this._onPreRenders.add(e),e.onPostRender&&this._onPostRenders.add(e)}remove(e){2==e._status&&(e._status=1),e.onUpdate&&this._onUpdates.delete(e),e.onLateUpdate&&this._onLateUpdates.delete(e),e.onAfterSceneUpdate&&this._onAfterSceneUpdates.delete(e),e.onPreRender&&this._onPreRenders.delete(e),e.onPostRender&&this._onPostRenders.delete(e)}destroy(){}onError(e){console.error(e)}}var bo,Ao=0;class Io{static get paused(){return Io._paused}static set paused(e){var t,r,s;Io._paused!==e&&(Io._paused=e,e||(null===(t=l.systemTimer)||void 0===t||t._markResumed(),null===(r=l.physicsTimer)||void 0===r||r._markResumed(),null===(s=l.timer)||void 0===s||s._markResumed()))}static __init__(){Io.frameInterval=1e3/t.FPS;let e=0;W.browser.on("visibilitychange",t=>{t?0!=e&&window.clearInterval(e):e=window.setInterval(Io.loop,1e3)}),Io.startLoop()}static startLoop(){let e=null,r=!0,s=0,i=0;window.requestAnimationFrame(function a(n){null!=n&&null===W.g||(n=performance.now());let o=Io.frameInterval;r&&(s=Math.floor(n/o)*o,r=!1);let l=i+n-e;(l+1>=o||!t.fixedFrames)&&(i=Math.min(l-o,o),e=n,Io.lastFrame=Math.floor((n-s)/o),Io.loop(n)),window.requestAnimationFrame(a)})}static loop(e){if(Ao++,Io.forceOnce)Io.stepMode=!0,Io.forceOnce=!1;else{if(Io.paused)return void Io._syncTimersOnPause(e);let t=!0;if(null!=Io.predicate)t=Io.predicate(e);else switch(Io.throttleMode){case 1:t=Ao%(l.stage._visible?2:5)==0;break;case 2:t=e-wo.lastMouseTime<2e3||Ao%(l.stage._visible?2:5)==0;break;case 3:t=e-Io.frameStartTime>=1e3}if(!t)return}Io.frameStartTime=e,f.statAgent.startFrameLogic(e),l.stage.render(e),f.statAgent.endFrameLogic(e),Io.stepMode=!1}static vsyncTime(){return Io.lastFrame*Io.frameInterval}static _syncTimersOnPause(e){var t,r,s;null===(t=l.systemTimer)||void 0===t||t._syncTimestamp(e),null===(r=l.physicsTimer)||void 0===r||r._syncTimestamp(e),null===(s=l.timer)||void 0===s||s._syncTimestamp(e)}static get canvas(){return Y.mainCanvas.source}}Io.frameInterval=1e3/60,Io.lastFrame=0,Io.frameStartTime=0,Io.throttleMode=0,Io.predicate=null,Io._paused=!1,Io.forceOnce=!1,Io.stepMode=!1;class Po{constructor(e,t){this.scale=1,this.currFrame=0,this.delta=0,this.unscaledDelta=0,this._map={},this._handlers=[],this._wasJustResumed=!1,(e||null==e)&&Po.gSysTimer&&Po.gSysTimer.frameLoop(1,this,this._update),this.currTimer=performance.now(),this._lastTimer=performance.now(),this._greedy=!!t}get totalTime(){return this._lastTimer}_update(e){if(null==e&&(e=performance.now()),this.scale<=0)return this._lastTimer=e,void(this.delta=0);let t=this.currFrame=this.currFrame+this.scale;Io.stepMode||this._wasJustResumed?(this.unscaledDelta=Io.frameInterval,this._lastTimer=e,this._wasJustResumed=!1):(this.unscaledDelta=e-this._lastTimer,this._lastTimer=e);let r=this.unscaledDelta>3e4;this.delta=this.unscaledDelta*this.scale;let s=this.currTimer=this.currTimer+this.delta,i=this._handlers,a=0;for(let e=0,n=i.length-1;e<=n;e++){let o=i[e];if(o.method){let e=o.userFrame?t:s;if(e>=o.exeTime)if(o.repeat)if(!o.jumpFrame||r)o.exeTime+=o.delay,o.run(!1),e>o.exeTime&&(o.exeTime+=Math.ceil((e-o.exeTime)/o.delay)*o.delay);else for(;e>=o.exeTime;)o.exeTime+=o.delay,o.run(!1);else o.run(!0)}else a++;e===n&&this._greedy&&(n=i.length-1)}(a>30||t%200==0)&&this._clearHandlers()}_clearHandlers(){let e=this._handlers,t=0;for(let r=0,s=e.length;r<s;r++){let s=e[r];null!==s.method?t!==r?e[t++]=s:t++:(this._map[s.key]==s&&delete this._map[s.key],s.clear(),Po._pool.push(s))}e.length=t}_create(e,t,r,s,i,a,n){let o=Q.getGID(s,i);if(null==n||n){let n=this._map[o];if(n)return n.repeat=t,n.userFrame=e,n.delay=r,n.caller=s,n.method=i,n.args=a,n.exeTime=r+(e?this.currFrame:this.currTimer+(performance.now()-this._lastTimer)*this.scale),n}let l=Po._pool.length>0?Po._pool.pop():new Bo;return l.key=o,l.repeat=t,l.userFrame=e,l.delay=r,l.caller=s,l.method=i,l.args=a,l.exeTime=r+(e?this.currFrame:this.currTimer+(performance.now()-this._lastTimer)*this.scale),this._map[o]=l,this._handlers.push(l),l}once(e,t,r,s,i){this._create(!1,!1,e,t,r,s,i)}loop(e,t,r,s,i,a){let n=this._create(!1,!0,e,t,r,s,i);n&&(n.jumpFrame=a)}frameOnce(e,t,r,s,i){this._create(!0,!1,e,t,r,s,i)}frameLoop(e,t,r,s,i){this._create(!0,!0,e,t,r,s,i)}toString(){return" handlers:"+this._handlers.length+" pool:"+Po._pool.length}clear(e,t){let r=this._map[Q.getGID(e,t)];r&&r.clear()}clearAll(e){if(e)for(let t=0,r=this._handlers.length;t<r;t++){let r=this._handlers[t];r.caller===e&&r.clear()}}callLater(e,t,r){Po.callLaters._create(!1,!1,0,e,t,r,!0).exeTime=0}runCallLater(e,t,r){!Po.callLaters.runTimer(e,t)&&r&&t.apply(e)}clearCallLater(e,t){Po.callLaters.clear(e,t)}runTimer(e,t){let r=this._map[Q.getGID(e,t)];return!(!r||null==r.method)&&(this._map[r.key]=null,r.run(!0),!0)}pause(){this.scale=0}resume(){this.scale=1}destroy(){for(let e=0,t=this._handlers.length;e<t;e++){this._handlers[e].clear()}this._handlers.length=0}_syncTimestamp(e){this._lastTimer=e}_markResumed(){this._wasJustResumed=!0}}Po.gSysTimer=null,Po.callLaters=new Po(!1,!0),Po._pool=[];class Bo{clear(){this.caller=null,this.method=null,this.args=null}run(e){let t=this.caller;if(t&&t.destroyed)return this.clear();let r=this.method,s=this.args;e&&this.clear(),null!=r&&(s?r.apply(t,s):r.call(t))}}class Lo{static start(e){let t=Lo._getProfiler();return!!t&&(t.ZoneStart(e),!0)}static end(e){e&&Lo._profiler.ZoneEnd()}static get enabled(){return!!Lo._getProfiler()}static _getProfiler(){if(!Lo._inited){let e="undefined"!=typeof window?window:globalThis,t=e&&e.conchProfiler;Lo._profiler=t&&t.ZoneStart&&t.ZoneEnd&&(!t.isEnabled||t.isEnabled())?t:null,Lo._inited=!0}return Lo._profiler}}Lo._inited=!1;class No extends po{constructor(){super(),this.offset=new d,this.designWidth=0,this.designHeight=0,this.canvasRotation=!1,this.canvasDegree=0,this.renderingEnabled=!0,this.screenAdaptationEnabled=!0,this._canvasTransform=new Ce,this._scene3Ds=[],this._scene2Ds=[],this._screenMode="none",this._scaleMode="noscale",this._alignV="top",this._alignH="left",this._bgColor="gray",this._wgColor=new y(0,0,0,0),this._needUpdateCanvasSize=!1,this._graphicUpdateList=new Set,this._subpassUpdateList=new Set,this._tranMatrixUpdateList=new Set,this.mouseEnabled=!0,this.hitTestPrior=!0,this._setBit(we.DISPLAYED_INSTAGE,!0),this._setBit(we.ACTIVE_INHIERARCHY,!0),this._isFocused=!0,this._transform=new Ce,this._componentDriver=new Mo,this.passManager=new va,W.browser.on(c.FOCUS,()=>{this._isFocused||(this._isFocused=!0,this.event(c.FOCUS),this.event(c.FOCUS_CHANGE))}),W.browser.on(c.BLUR,()=>{this._isFocused&&(this._isFocused=!1,this.event(c.BLUR),this.event(c.FOCUS_CHANGE))}),W.browser.on(c.VISIBILITY_CHANGE,e=>{this.renderingEnabled=e,this.event(c.VISIBILITY_CHANGE,e)}),W.browser.on(c.RESIZE,()=>{W.textInput.target||this.screenAdaptationEnabled&&(this.event(c.WILL_RESIZE),this.updateCanvasSize(!0))}),W.browser.on(c.ORIENTATION_CHANGE,e=>{this.screenAdaptationEnabled&&(this.event(c.WILL_RESIZE),this.updateCanvasSize(!0))}),this.passManager.basePass.root=this._struct,this._struct.pass=this.passManager.basePass}_transChanged(t){super._transChanged(t),0!=(t&e.TransformKind.Size)&&(this.designWidth=this._width,this.designHeight=this._height,this.updateCanvasSize(!0))}measureWidth(){return this.needUpdateCanvasSize(),this._width}measureHeight(){return this.needUpdateCanvasSize(),this._height}get isFocused(){return this._isFocused}get isVisibility(){return W.browser.getVisibility()}updateCanvasSize(e){e?this._needUpdateCanvasSize||(this._needUpdateCanvasSize=!0,l.systemTimer.callLater(this,this.updateCanvasSize)):this.setScreenSize(Y.clientWidth*Y.pixelRatio,Y.clientHeight*Y.pixelRatio)}needUpdateCanvasSize(){this._needUpdateCanvasSize&&this.updateCanvasSize()}setScreenSize(e,r){var s;this._needUpdateCanvasSize=!1;let i=Y.pixelRatio;if(e/=i,r/=i,i<=0||!Number.isFinite(e)||!Number.isFinite(r)||e<=1||r<=1)return;if(this._screenMode!==No.SCREEN_NONE){let t=e/r<1?No.SCREEN_VERTICAL:No.SCREEN_HORIZONTAL;if(this.canvasRotation=t!==this._screenMode,this.canvasRotation){let t=r;r=e,e=t}}else this.canvasRotation=!1;let a=Y.mainCanvas,n=this._canvasTransform.identity(),o=this._scaleMode,h=this.designWidth,u=this.designHeight,d=1;switch(Y.isDomSupported||o!==No.SCALE_NOSCALE&&o!=No.SCALE_SHOWALL&&o!==No.SCALE_NOBORDER||(o=No.SCALE_FIXED_AUTO),o){case No.SCALE_NOSCALE:break;case No.SCALE_FULL:h=e,u=r;break;case No.SCALE_SHOWALL:d=Math.min(e/h,r/u);break;case No.SCALE_NOBORDER:d=Math.max(e/h,r/u);break;case No.SCALE_FIXED_WIDTH:case No.SCALE_FIXED_HEIGHT:case No.SCALE_FIXED_AUTO:o===No.SCALE_FIXED_WIDTH||o===No.SCALE_FIXED_AUTO&&e/r<h/u?(d=e/h,u=r/d):(d=r/u,h=e/d)}if(this._width=h,this._height=u,!t.useRetinalCanvas&&Y.isDomSupported||(h*=d,u*=d,d=1,i>4&&Y.isDomSupported&&(i=4),h*=i,u*=i,d/=i),n.scale(d,d),Y.isDomSupported){let t=0,s=0;t=this._alignH===No.ALIGN_LEFT?0:this._alignH===No.ALIGN_RIGHT?e-h*d:.5*(e-h*d),s=this._alignV===No.ALIGN_TOP?0:this._alignV===No.ALIGN_BOTTOM?r-u*d:.5*(r-u*d),t+=this.offset.x,s+=this.offset.y,n.translate(Math.round(t),Math.round(s))}if(this.canvasRotation?this._screenMode===No.SCREEN_HORIZONTAL?(n.rotate(Math.PI/2),n.translate(r,0),this.canvasDegree=90):(n.rotate(-Math.PI/2),n.translate(0,e),this.canvasDegree=-90):this.canvasDegree=0,n.a=Oo(n.a),n.d=Oo(n.d),n.tx=Oo(n.tx),n.ty=Oo(n.ty),h=Math.round(h),u=Math.round(u),a.size(h,u),Y.isDomSupported){let e=Y.mainCanvas.source.style;W.browser.setStyleTransformOrigin(e,"0px 0px 0px"),W.browser.setStyleTransform(e,"matrix("+n.toString()+")"),e.width=h+"px",e.height=u+"px",n.translate(parseInt(e.left)||0,parseInt(e.top)||0)}if(this.scale(Oo(h/this._width),Oo(u/this._height)),jn.width=h,jn.height=u,null===(s=window.Laya3D)||void 0===s||s._changeWebGLSize(h,u),f.renderEngine.resizeOffScreen(h,u),ea.scaleFontWithCtx){let e=Math.min(Math.max(1,l.stage.scaleX,l.stage.scaleY),ea.maxFontScale);if(e=.2*Math.ceil(e/.2),ea.fontScale!==e){ea.fontScale=e,va.runner._textRender.onFontScaleChanged();(e=>{for(let t of e._children)0!==(t._renderType&Mr.TEXT)&&t.repaint()})(this)}}this.visible=!0,this.repaint(),this.event(c.RESIZE)}get scaleMode(){return this._scaleMode}set scaleMode(e){this._scaleMode!=e&&(this._scaleMode=e,this.updateCanvasSize(!0))}get alignH(){return this.needUpdateCanvasSize(),this._alignH}set alignH(e){this._alignH!=e&&(this._alignH=e,this.updateCanvasSize(!0))}get alignV(){return this.needUpdateCanvasSize(),this._alignV}set alignV(e){this._alignV!=e&&(this._alignV=e,this.updateCanvasSize(!0))}get bgColor(){return this._bgColor}set bgColor(e){if(this._bgColor=e,e){let t=zr.create(e).arrColor;this._wgColor.setValue(t[0],t[1],t[2],t[3])}else this._wgColor.setValue(0,0,0,0);Y.isDomSupported&&(Y.mainCanvas.source.style.background=null!=e?e:"none")}get mouseX(){return Math.round(wo.mouseX/this.clientScaleX)}get mouseY(){return Math.round(wo.mouseY/this.clientScaleY)}getMousePoint(){return d.TEMP.setTo(this.mouseX,this.mouseY)}get clientScaleX(){return this._scaleX}get clientScaleY(){return this._scaleY}get screenMode(){return this._screenMode}set screenMode(e){this._screenMode=e}getTimeFromFrameStart(){return performance.now()-Io.frameStartTime}get visible(){return super.visible}set visible(e){super.visible=e,Y.isDomSupported&&(Y.mainCanvas.source.style.visibility=e?"visible":"hidden")}render(t){var r;let s=Lo.start("stage/call_laters");if(!this._visible)return Po.callLaters._update(t),Lo.end(s),Ua.loopCount++,this._runComponents(),s=Lo.start("stage/update_timers"),this._updateTimers(t),void Lo.end(s);if(Po.callLaters._update(t),Lo.end(s),Ua.loopCount++,va.renderTime+=.001*((null===(r=l.timer)||void 0===r?void 0:r.delta)||0),s=Lo.start("stage/start_frame"),f.renderEngine.startFrame(),Lo.end(s),this.renderingEnabled){s=Lo.start("stage/run_components"),this._runComponents(),Lo.end(s),s=Lo.start("stage/scene_update");for(let e=0,t=this._scene2Ds.length;e<t;e++)this._scene2Ds[e]._update();for(let e=0,t=this._scene3Ds.length;e<t;e++)this._scene3Ds[e]._update();this._preRender2d(),Lo.end(s),s=Lo.start("stage/pre_render"),this._componentDriver.callPreRender(),Lo.end(s),va.rendercontext2D.setRenderTarget(null,!0,this._wgColor),s=Lo.start("stage/render3d");let t=performance.now();for(let e=0,t=this._scene3Ds.length;e<t;e++)this._scene3Ds[e].renderSubmit();f.statAgent.recordTimeData(e.StatElement.T_AllRender3D,performance.now()-t),Lo.end(s),s=Lo.start("stage/render2d"),t=performance.now(),this._render2d(),f.statAgent.recordTimeData(e.StatElement.T_AllRender2D,performance.now()-t),Lo.end(s),s=Lo.start("stage/post_render"),this._componentDriver.callPostRender(),Lo.end(s)}else this._runComponents();s=Lo.start("stage/update_timers"),this._updateTimers(t),Lo.end(s),s=Lo.start("stage/stat_render"),Ua.render(),Lo.end(s),s=Lo.start("stage/end_frame"),f.renderEngine.endFrame(),Lo.end(s)}_preRender2d(){for(let e=0,t=this._scene2Ds.length;e<t;e++)this._scene2Ds[e].render(0,0);const t=Bn.instance;t.update(Ua.loopCount);const r=t.changedSlots,s=t.changedMasks;for(let i=0,a=t.changedCount;i<a;i++){if(!(1&s[i]))continue;const a=t.getOwner(r[i]);a&&(a._globalTrans._notifyRenderSpriteTransChange(),a._globalTrans._hasChangedListener&&a.event(Ln.CHANGED,e.TransformKind.Matrix))}for(let t of this._subpassUpdateList){if(t._destroyed||!t._subpassUpdateFlag)continue;if(t.updateSubRenderPassState(),!t._oriRenderPass||!t._oriRenderPass.enable){t._subpassUpdateFlag=0;continue}let r=t.updateRenderTexture(),s=t._drawOriRT;if(!s){t.setSubRenderPassState(!1);continue}t.mask?t._oriRenderPass.mask=t.mask._struct:t._oriRenderPass.mask=null,r&&(t._oriRenderPass.renderTexture=s);let i=t._renderType&Mr.POSTPROCESS?t._oriRenderPass.postProcess:null;i&&s!=Xa._empty&&((r||t._subpassUpdateFlag&e.SubPassFlag.UPDATE_POSTPROCESS)&&(i.setResource(s),i.clearCMD(),i._render()),i.enabled&&(s=i._context.destination)),t._subStructRender._updateRenderTexture(t._drawOriRT,s),t._subpassUpdateFlag=0}this._updateMatrixList(this._tranMatrixUpdateList,Ua.loopCount)}_render2d(){var e,t;for(let t of this._graphicUpdateList)t._needGraphicsUpdate()&&(null===(e=t._graphicsRenderer)||void 0===e||e._render(va.runner));va.renderTime+=.001*((null===(t=l.timer)||void 0===t?void 0:t.delta)||0),this.passManager.apply(va.rendercontext2D,va.renderTime),uo.postRenderAll(),this._graphicUpdateList.clear(),this._subpassUpdateList.clear(),this._tranMatrixUpdateList.clear(),Xa.cleanupExpired(),Ua.render2DCount++}_updateMatrixList(e,t){for(let t of e)t._updateStruct()}_runComponents(){this._componentDriver.callStart(),this._componentDriver.callUpdate(),this._componentDriver.callLateUpdate(),this._componentDriver.callDestroy()}_updateTimers(e){let t=Lo.start("stage/timer_system");l.systemTimer._update(e),Lo.end(t),t=Lo.start("stage/timer_physics"),l.physicsTimer._update(e),Lo.end(t),t=Lo.start("stage/timer_user"),l.timer._update(e),Lo.end(t),t=Lo.start("stage/tween"),nn._runAll(),Lo.end(t)}set fullScreenEnabled(e){let t=Y.mainCanvas.source;e?(t.addEventListener("mousedown",Fo),t.addEventListener("touchstart",Fo),W.browser.on("fullscreenchange",this,this.fullScreenChanged)):(t.removeEventListener("mousedown",Fo),t.removeEventListener("touchstart",Fo),W.browser.off("fullscreenchange",this,this.fullScreenChanged))}fullScreenChanged(){this.event(c.FULL_SCREEN_CHANGE)}setResolution(e,t,r=!1){return W.browser.setResolution(e,t,r)}setWindowedFullscreen(e){return W.browser.setWindowedFullscreen(e)}exitFullscreen(){W.browser.exitFullscreen()}get frameRate(){return 0===Io.throttleMode?"fast":1===Io.throttleMode?"slow":2===Io.throttleMode?"mouse":"sleep"}set frameRate(e){Io.throttleMode="slow"===e?1:"mouse"===e?2:"sleep"===e?3:0}}function Fo(){W.browser.requestFullscreen();let e=Y.mainCanvas.source;e.removeEventListener("mousedown",Fo),e.removeEventListener("touchstart",Fo)}function Oo(e){return Math.abs(e)<1e-6?0:Math.abs(1-e)<.001?e>0?1:-1:e}No.SCALE_NOSCALE="noscale",No.SCALE_SHOWALL="showall",No.SCALE_NOBORDER="noborder",No.SCALE_FULL="full",No.SCALE_FIXED_WIDTH="fixedwidth",No.SCALE_FIXED_HEIGHT="fixedheight",No.SCALE_FIXED_AUTO="fixedauto",No.ALIGN_LEFT="left",No.ALIGN_RIGHT="right",No.ALIGN_CENTER="center",No.ALIGN_TOP="top",No.ALIGN_MIDDLE="middle",No.ALIGN_BOTTOM="bottom",No.SCREEN_NONE="none",No.SCREEN_HORIZONTAL="horizontal",No.SCREEN_VERTICAL="vertical",No.FRAME_FAST="fast",No.FRAME_SLOW="slow",No.FRAME_MOUSE="mouse",No.FRAME_SLEEP="sleep";class Uo extends V{static get defaultTexture(){return this._defaultTexture}static __init__(){f.renderEngine.getCapable(e.RenderCapable.Texture3D)&&(this._defaultTexture=new Uo(1,1,1,e.TextureFormat.R8G8B8A8,!1,!1),this._defaultTexture.lock=!0,this._defaultTexture.setPixelsData(new Uint8Array([255,255,255,255])))}constructor(t,r,s,i,a=!0,n=!1){super(t,r,i),this._dimension=e.TextureDimension.Tex3D,this.depth=s,this._gammaSpace=n;let o=f.textureContext;this._texture=o.createTexture3DInternal(this._dimension,t,r,s,i,a,n,!1)}setPixelsData(e){let t=this._texture;f.textureContext.setTexture3DPixelsData(t,e,this.depth,!1,!1)}setSubPixelsData(e,t,r,s,i,a,n,o,l){let h=this._texture;f.textureContext.setTexture3DSubPixelsData(h,n,o,l,e,t,r,s,i,a,!1,!1)}}e.TextureCubeFace=void 0,(bo=e.TextureCubeFace||(e.TextureCubeFace={}))[bo.PositiveX=0]="PositiveX",bo[bo.NegativeX=1]="NegativeX",bo[bo.PositiveY=2]="PositiveY",bo[bo.NegativeY=3]="NegativeY",bo[bo.PositiveZ=4]="PositiveZ",bo[bo.NegativeZ=5]="NegativeZ";const ko=new Uint8Array(4);class Go extends V{static get blackTexture(){return Go._blackTexture}static get grayTexture(){return Go._grayTexture}static get whiteTexture(){return Go._whiteTexture}static get errorTexture(){return Go._errorTexture}static __init__(){var t=new Go(1,e.TextureFormat.R8G8B8A8,!1),r=new Go(1,e.TextureFormat.R8G8B8A8,!1),s=new Go(1,e.TextureFormat.R8G8B8A8,!1),i=ko;i[0]=0,i[1]=0,i[2]=0,i[3]=255,t.setPixelsData([i,i,i,i,i,i],!1,!1),t.lock=!0,i[0]=128,i[1]=128,i[2]=128,i[3]=255,r.setPixelsData([i,i,i,i,i,i],!1,!1),r.lock=!0,i[0]=255,i[1]=255,i[2]=255,i[3]=255,s.setPixelsData([i,i,i,i,i,i],!1,!1),s.lock=!0,Go._grayTexture=r,Go._blackTexture=t,Go._whiteTexture=s,Go._errorTexture=s}constructor(t,r,s=!0,i=!1,a=!1){super(t,t,r),this._dimension=e.TextureDimension.Cube,this._texture=f.textureContext.createTextureInternal(this._dimension,t,t,r,s,i,a)}setImageData(e,t,r){let s=!1,i=e.findIndex(e=>null!=e);if(-1!=i){let t=e[i];e.every(e=>null!=e&&e.width==t.width&&e.height==t.height)||(s=!0)}else s=!0;let a=this._texture;if(s){let e=ko;f.textureContext.setCubePixelsData(a,[e,e,e,e,e,e],t,r)}else f.textureContext.setCubeImageData(a,e,t,r)}setPixelsData(e,t,r){let s=this._texture;f.textureContext.setCubePixelsData(s,e,t,r)}updateSubPixelsData(e,t,r,s,i,a,n,o,l){let h=this._texture;f.textureContext.setCubeSubPixelData(h,e,a,n,t,r,s,i,o,l)}setDDSData(e){let t=this._texture;f.textureContext.setCubeDDSData(t,e)}setKTXData(e){let t=this._texture;f.textureContext.setCubeKTXData(t,e)}get defaultTexture(){return Go.grayTexture}}class Vo{static __init__(){l.stage.on(c.BLUR,()=>{zo.autoStopMusic&&zo._musicChannel&&!zo._musicChannel.paused&&W.media.resumeUntilGotFocus(zo._musicChannel)})}static get musicVolume(){return zo._musicVolume}static set musicVolume(e){(e=Wr.clamp(e,0,1))!==zo._musicVolume&&(zo._musicVolume=e,zo._musicChannel&&(zo._musicChannel.volume=zo._musicChannel.volume))}static get soundVolume(){return zo._soundVolume}static set soundVolume(e){if((e=Wr.clamp(e,0,1))!==zo._soundVolume){zo._soundVolume=e;for(let e of zo._channels)e!==zo._musicChannel&&(e.volume=e.volume)}}static get muted(){return zo._muted}static set muted(e){(e=!!e)!==zo._muted&&(zo._muted=e,this.updateMutedStatus())}static get soundMuted(){return zo._soundMuted}static set soundMuted(e){(e=!!e)!==zo._soundMuted&&(zo._soundMuted=e,this.updateMutedStatus())}static get musicMuted(){return zo._musicMuted}static set musicMuted(e){(e=!!e)!==zo._musicMuted&&(zo._musicMuted=e,this.updateMutedStatus())}static playSound(e,t,r,s,i){if(!e)return null;"number"==typeof s&&(i=s);let a=W.media.createSoundChannel(e,!1);return a._isMusic=!1,a.loops=null!=t?t:1,a.startTime=null!=i?i:0,a.playbackRate=this.playbackRate,a.volume=1,a.muted=zo._soundMuted||zo._muted,a.completeHandler=r,a.play(),a}static playMusic(e,t,r,s){if(zo._musicChannel&&(zo._musicChannel.stop(),zo._musicChannel=null),!e)return null;let i=W.media.createSoundChannel(e,zo.useAudioMusic);return i._isMusic=!0,i.loops=null!=t?t:1,i.startTime=null!=s?s:0,i.playbackRate=this.playbackRate,i.volume=1,i.muted=zo._musicMuted||zo._muted,i.completeHandler=r,i.play(),i}static stopSound(e){for(let t of zo._channels)t.url==e&&(t.stop(),t===zo._musicChannel&&(zo._musicChannel=null))}static stopAll(){zo._musicChannel=null;for(let e of zo._channels)e.stop()}static stopAllSound(){for(let e of zo._channels)e!==zo._musicChannel&&e.stop()}static stopMusic(){zo._musicChannel&&zo._musicChannel.stop(),zo._musicChannel=null}static setSoundVolume(e,t){if(t){let r=this.findChannel(t);r&&(r.volume=e)}else this.soundVolume=e}static setMusicVolume(e){this.musicVolume=e}static findChannel(e){for(let t of zo._channels)if(t.url==e)return t;return null}static getAllChannels(){return Array.from(zo._channels)}static updateMutedStatus(){let e=zo._muted||zo._soundMuted,t=zo._muted||zo._musicMuted;for(let r of zo._channels)r===zo._musicChannel?r.muted=t:r.muted=e}static addChannel(e){zo._channels.add(e),e._isMusic&&(zo._musicChannel=e)}static removeChannel(e){zo._channels.delete(e),e===zo._musicChannel&&(zo._musicChannel=null)}}Vo.playbackRate=1,Vo.useAudioMusic=!0,Vo.autoStopMusic=!0,Vo._muted=!1,Vo._soundMuted=!1,Vo._musicMuted=!1,Vo._musicVolume=1,Vo._soundVolume=1,Vo._musicChannel=null,Vo._channels=new Set;const zo=Vo;var Ho;e.SequenceFrame2DVertex=void 0,(Ho=e.SequenceFrame2DVertex||(e.SequenceFrame2DVertex={}))[Ho.PositionUV=0]="PositionUV",Ho[Ho.Matrix0=1]="Matrix0",Ho[Ho.Matrix1=2]="Matrix1",Ho[Ho.Runtime=3]="Runtime",Ho[Ho.Playback=4]="Playback",Ho[Ho.SizeTiles=5]="SizeTiles",Ho[Ho.ColorUnit=6]="ColorUnit",Ho[Ho.UVRect=7]="UVRect";class Wo{static __init__(){if(Wo._inited)return;Wo._inited=!0;const t={a_SequenceFramePositionUV:[e.SequenceFrame2DVertex.PositionUV,e.ShaderDataType.Vector4],a_SequenceFrameMatrix0:[e.SequenceFrame2DVertex.Matrix0,e.ShaderDataType.Vector4],a_SequenceFrameMatrix1:[e.SequenceFrame2DVertex.Matrix1,e.ShaderDataType.Vector4],a_SequenceFrameRuntime:[e.SequenceFrame2DVertex.Runtime,e.ShaderDataType.Vector4],a_SequenceFramePlayback:[e.SequenceFrame2DVertex.Playback,e.ShaderDataType.Vector4],a_SequenceFrameSizeTiles:[e.SequenceFrame2DVertex.SizeTiles,e.ShaderDataType.Vector4],a_SequenceFrameColorUnit:[e.SequenceFrame2DVertex.ColorUnit,e.ShaderDataType.Vector4],a_SequenceFrameUVRect:[e.SequenceFrame2DVertex.UVRect,e.ShaderDataType.Vector4]},r=Ot.add("SequenceFrame2D",!0,!1);r.shaderType=e.ShaderFeatureType.Default;const s=new Nt(t,{},{});r.addSubShader(s),s.addShaderPass('#define SHADER_NAME SequenceFrame2DVS\n#include "Sprite2DVertex.glsl";\nvarying vec2 v_texcoord;uniform float u_Time;struct sequenceFrameVertexInfo{vec2 pos;vec2 uv;vec4 color;vec2 lightUV;};void getSequenceFrameGlobalPosition(in vec2 positionOS,out vec2 globalPos){transfrom(positionOS,a_SequenceFrameMatrix0.xyz,a_SequenceFrameMatrix1.xyz,globalPos);}vec4 getSequenceFramePosition(in vec2 rawGlobalPos){vec2 globalPos=rawGlobalPos;clip(globalPos);vec2 viewPos;getViewPos(globalPos,viewPos);vec4 projectPos;getProjectPos(viewPos,projectPos);return projectPos;}\n#ifdef LIGHT2D_ENABLE\nvarying vec2 v_lightUV;uniform vec4 u_LightAndShadow2DParam;void getSequenceFrameLightUV(in vec2 globalPos,out vec2 lightUV){lightUV.x=(globalPos.x-u_LightAndShadow2DParam.x)/u_LightAndShadow2DParam.z;lightUV.y=1.0-(globalPos.y-u_LightAndShadow2DParam.y)/u_LightAndShadow2DParam.w;}void applySequenceFrameLightUV(in sequenceFrameVertexInfo info){v_lightUV=info.lightUV;}\n#endif\nvoid getSequenceFrameVertexInfo(inout sequenceFrameVertexInfo info){float unitPixels=max(a_SequenceFrameColorUnit.w,0.0001);vec2 sourceFramePixels=max(a_SequenceFrameSizeTiles.xy,vec2(1.0));vec2 displaySize=sourceFramePixels/max(max(sourceFramePixels.x,sourceFramePixels.y),0.0001)*unitPixels;vec2 localOffset=a_SequenceFramePositionUV.xy*displaySize;info.pos=localOffset+vec2(a_SequenceFrameMatrix0.w,a_SequenceFrameMatrix1.w);float elapsedAge=max(u_Time-a_SequenceFrameRuntime.x,0.0);float lifeTime=max(a_SequenceFramePlayback.y,0.0001);float playbackState=a_SequenceFrameRuntime.w;float runningAge=mix(elapsedAge,mod(elapsedAge,lifeTime),step(1.5,playbackState));float age=clamp(mix(a_SequenceFrameRuntime.z,runningAge,step(0.5,playbackState)),0.0,lifeTime);float alpha=clamp(a_SequenceFrameRuntime.y,0.0,1.0);float startFrame=max(a_SequenceFramePlayback.x,0.0);float cycles=max(a_SequenceFramePlayback.z,0.0);float tilesX=max(floor(a_SequenceFrameSizeTiles.z+0.5),1.0);float tilesY=max(floor(a_SequenceFrameSizeTiles.w+0.5),1.0);float frameCount=max(floor(a_SequenceFramePlayback.w+0.5),1.0);float normalizedAge=min(age/lifeTime,0.999999);float frame=mod(floor(normalizedAge*cycles*frameCount)+floor(startFrame),frameCount);float indexX=floor(mod(frame,tilesX));float indexY=floor(frame/tilesX);vec2 gridUV=vec2(1.0/tilesX,1.0/tilesY);vec2 innerFrameUV=(a_SequenceFramePositionUV.zw*max(sourceFramePixels-vec2(1.0),vec2(0.0))+vec2(0.5))/sourceFramePixels;vec2 frameUV=(innerFrameUV+vec2(indexX,indexY))*gridUV;info.uv=a_SequenceFrameUVRect.xy+frameUV*a_SequenceFrameUVRect.zw;vec4 renderColor=linearToGamma(vec4(a_SequenceFrameColorUnit.rgb,alpha));renderColor.rgb*=renderColor.a;info.color=renderColor;}void main(){sequenceFrameVertexInfo info;getSequenceFrameVertexInfo(info);v_texcoord=info.uv;v_color=info.color;vec2 globalPos;getSequenceFrameGlobalPosition(info.pos,globalPos);\n#ifdef LIGHT2D_ENABLE\ngetSequenceFrameLightUV(globalPos,info.lightUV);applySequenceFrameLightUV(info);\n#endif\ngl_Position=getSequenceFramePosition(globalPos);}','#define SHADER_NAME SequenceFrame2DFS\n#if defined(GL_FRAGMENT_PRECISION_HIGH)\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "Sprite2DFrag.glsl";\nvarying vec2 v_texcoord;varying vec4 v_color;uniform sampler2D u_baseRender2DTexture;\n#ifdef LIGHT2D_ENABLE\nvarying vec2 v_lightUV;uniform vec3 u_LightDirection;uniform vec4 u_LightAndShadow2DAmbient;uniform sampler2D u_LightAndShadow2D;\n#ifdef LIGHT2D_SCENEMODE_ADD\nuniform sampler2D u_LightAndShadow2D_AddMode;\n#endif\n#ifdef LIGHT2D_SCENEMODE_SUB\nuniform sampler2D u_LightAndShadow2D_SubMode;\n#endif\n#ifdef LIGHT2D_NORMAL_PARAM\nuniform sampler2D u_normal2DTexture;uniform float u_normal2DStrength;\n#endif\nvoid applySequenceFrameLight(inout vec4 color){\n#ifdef LIGHT2D_EMPTY\ncolor.rgb*=u_LightAndShadow2DAmbient.rgb;\n#else\nvec2 uv=v_lightUV;vec2 tt=step(vec2(0.0),uv)*step(uv,vec2(1.0));float side=tt.x*tt.y;vec3 ambient=color.rgb*u_LightAndShadow2DAmbient.rgb;color.rgb=color.rgb*texture2D(u_LightAndShadow2D,uv).rgb*side;side*=color.a;\n#ifdef LIGHT2D_SCENEMODE_ADD\ncolor.rgb=min(vec3(1.0),color.rgb+texture2D(u_LightAndShadow2D_AddMode,uv).rgb*side);\n#endif\n#ifdef LIGHT2D_SCENEMODE_SUB\ncolor.rgb=max(vec3(0.0),color.rgb-texture2D(u_LightAndShadow2D_SubMode,uv).rgb*side);\n#endif\n#ifdef LIGHT2D_NORMAL_PARAM\nvec3 dr=normalize(u_LightDirection);vec3 normal=normalize(texture2D(u_normal2DTexture,v_texcoord).rgb*2.0-1.0);color.rgb=color.rgb*((1.0-u_normal2DStrength)+abs(dot(dr,normal.rgb))*u_normal2DStrength);\n#endif\ncolor.rgb=min(vec3(1.0),color.rgb+ambient);\n#endif\n}\n#endif\nvoid setSequenceFrameColor(in vec4 color){color.a*=v_color.w;vec4 transColor=v_color;\n#ifndef GAMMASPACE\ntransColor=gammaToLinear(v_color);\n#endif\ncolor.rgb*=transColor.rgb;gl_FragColor=color;}void main(){clip();vec4 textureColor=texture2D(u_baseRender2DTexture,v_texcoord);\n#ifdef LIGHT2D_ENABLE\napplySequenceFrameLight(textureColor);\n#endif\nsetSequenceFrameColor(textureColor);}'),Wo.baseDeclaration=new Bt(16,[new vt(0,It.Vector4,e.SequenceFrame2DVertex.PositionUV)]),Wo.runtimeDeclaration=new Bt(4*Wo.RUNTIME_FLOAT_STRIDE,[new vt(0,It.Vector4,e.SequenceFrame2DVertex.Matrix0),new vt(16,It.Vector4,e.SequenceFrame2DVertex.Matrix1),new vt(32,It.Vector4,e.SequenceFrame2DVertex.Runtime)]),Wo.configDeclaration=new Bt(4*Wo.CONFIG_FLOAT_STRIDE,[new vt(0,It.Vector4,e.SequenceFrame2DVertex.Playback),new vt(16,It.Vector4,e.SequenceFrame2DVertex.SizeTiles),new vt(32,It.Vector4,e.SequenceFrame2DVertex.ColorUnit),new vt(48,It.Vector4,e.SequenceFrame2DVertex.UVRect)]);const i=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),a=new Uint16Array([0,1,2,0,2,3]),n=Wo._vbs=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Static);n.vertexDeclaration=Wo.baseDeclaration,n.instanceBuffer=!1,n.setDataLength(i.byteLength),n.setData(i.buffer,0,0,i.byteLength);const o=Wo._ibs=f.renderDeviceFactory.createIndexBuffer(e.BufferUsage.Static);o._setIndexDataLength(a.byteLength),o._setIndexData(a,0)}}Wo.RUNTIME_FLOAT_STRIDE=12,Wo.CONFIG_FLOAT_STRIDE=16,Wo.INSTANCE_FLOAT_STRIDE=Wo.RUNTIME_FLOAT_STRIDE+Wo.CONFIG_FLOAT_STRIDE,Wo._inited=!1;class Xo extends Dn{static __init__(){if(Xo.defaultMaterial)return;Wo.__init__();const e=Xo.defaultMaterial=new Zn;e.lock=!0,e.setShaderName("SequenceFrame2D"),e.setBoolByIndex(Ot.DEPTH_WRITE,!1),e.setIntByIndex(Ot.DEPTH_TEST,Gt.DEPTHTEST_OFF),e.setIntByIndex(Ot.BLEND,Gt.BLEND_ENABLE_ALL),e.setIntByIndex(Ot.BLEND_EQUATION,Gt.BLENDEQUATION_ADD),e.setIntByIndex(Ot.BLEND_SRC,Gt.BLENDPARAM_ONE),e.setIntByIndex(Ot.BLEND_DST,Gt.BLENDPARAM_ONE_MINUS_SRC_ALPHA),e.setIntByIndex(Ot.CULL,Gt.CULL_NONE)}static _allocateInstanceID(e){const t=Xo._freeInstanceIDs.length>0?Xo._freeInstanceIDs.pop():Xo._nextInstanceID++;return Xo._ensureInstanceCapacity(t+1),Xo._activeRenderers[t]=e,t}static _releaseInstanceID(e){e<0||(Xo._activeRenderers[e]=null,Xo._freeInstanceIDs.push(e))}static _ensureInstanceCapacity(e){var t;if(e<=Xo._instanceCapacity)return;let r=Xo._instanceCapacity||256;for(;r<e;)r<<=1;const s=new Float32Array(r*Wo.RUNTIME_FLOAT_STRIDE),i=new Float32Array(r*Wo.CONFIG_FLOAT_STRIDE);s.set(Xo._runtimeDataBuffer),i.set(Xo._configDataBuffer),Xo._runtimeDataBuffer=s,Xo._configDataBuffer=i,Xo._instanceCapacity=r;const a=Xo._activeRenderers;for(let e=0,r=a.length;e<r;e++)null===(t=a[e])||void 0===t||t._bindInstanceDataViews()}get cycles(){return this._cycles}set cycles(e){e=Math.max(0,e||0),this._cycles!==e&&(this._cycles=e,this._markConfigDirty())}get tiles(){return this._tiles}set tiles(e){const t=e?Math.max(1,Math.floor(e.x||1)):1,r=e?Math.max(1,Math.floor(e.y||1)):1;this._tiles.x===t&&this._tiles.y===r||(this._tiles.setValue(t,r),this._markConfigDirty(!0))}get startFrame(){return this._startFrame}set startFrame(e){e=Math.max(0,Math.floor(e||0)),this._startFrame!==e&&(this._startFrame=e,this._markConfigDirty())}get lifeTime(){return this._lifeTime}set lifeTime(e){e=Math.max(1e-4,e||1e-4),this._lifeTime!==e&&(this._lifeTime=e,this._elapsedTime=Math.min(this._getPlaybackAge(),e),this._startTime=this._getCurrentTime()-this._elapsedTime,this._needRuntimeUpload=!0,this._markConfigDirty())}get playOnAwake(){return this._playOnAwake}set playOnAwake(e){this._playOnAwake=!!e}get loop(){return this._loop}set loop(e){this._loop=!!e,this._needRuntimeUpload=!0,this._notifyDataChange()}get autoDestroyAtComplete(){return this._autoDestroyAtComplete}set autoDestroyAtComplete(e){this._autoDestroyAtComplete=!!e}get unitPixels(){return this._unitPixels}set unitPixels(e){e=Math.max(1e-4,e||1e-4),this._unitPixels!==e&&(this._unitPixels=e,this._markConfigDirty(!0))}get color(){return this._color}set color(e){(e||y.WHITE).cloneTo(this._color),this._needRuntimeUpload=!0,this._markConfigDirty()}get texture(){return this._texture}set texture(e){this._texture instanceof ie&&this._texture._removeReference(),this._texture=e,e instanceof ie?(e._addReference(),this._baseRender2DTexture=e.bitmap||Hi.whiteTexture,this._textureUVRect.setValue(e.uvrect[0],e.uvrect[1],e.uvrect[2],e.uvrect[3])):(this._baseRender2DTexture=e||Hi.whiteTexture,this._textureUVRect.setValue(0,0,1,1)),this._applyTextureToShaderData(this._baseRender2DTexture),this._markConfigDirty(!0)}get isPlaying(){return this._playing}get sharedMaterial(){return this._materials[0]}set sharedMaterial(e){if(e&&!this._isMaterialVaild(e))return;const t=this._materials[0];if(t===e)return;const r=this._renderElements[0];r&&Dn._removeRenderElement2DMaterial(r,this._getElementMaterial(0)),this._materials[0]=e,t&&t._removeReference(),e&&e._addReference(),r&&Dn._setRenderElement2DMaterial(r,this._getElementMaterial(0)),this._notifyDataChange()}get activeInstanceCount(){return this._activeInstanceCount}get instanceID(){return this._instanceID}get runtimeBufferData(){return this._runtimeBufferData}get configBufferData(){return this._configBufferData}get configVersion(){return this._configVersion}_copyRuntimeDataRange(e,t,r,s){const i=Wo.RUNTIME_FLOAT_STRIDE,a=r*i;e.set(Xo._runtimeDataBuffer.subarray(a,a+s*i),t)}_copyConfigDataRange(e,t,r,s){const i=Wo.CONFIG_FLOAT_STRIDE,a=r*i;e.set(Xo._configDataBuffer.subarray(a,a+s*i),t)}_uploadRuntimeDataRange(e,t,r){const s=4*Wo.RUNTIME_FLOAT_STRIDE;e.setData(Xo._runtimeDataBuffer.buffer,0,t*s,r*s)}_uploadConfigDataRange(e,t,r){const s=4*Wo.CONFIG_FLOAT_STRIDE;e.setData(Xo._configDataBuffer.buffer,0,t*s,r*s)}_ensureInstanceID(){this._instanceID>=0||(this._instanceID=Xo._allocateInstanceID(this),this._bindInstanceDataViews(),this._needRuntimeUpload=!0,this._needConfigUpload=!0,this._renderGeometry&&(this._renderGeometry.instanceCount=this._activeInstanceCount))}_releaseInstanceID(){this._instanceID<0||(Xo._releaseInstanceID(this._instanceID),this._instanceID=-1,this._activeInstanceCount=0,this._runtimeBufferData=null,this._configBufferData=null,this._lastMatrix.fill(NaN),this._lastAlpha=NaN,this._renderGeometry&&(this._renderGeometry.instanceCount=0))}_bindInstanceDataViews(){if(this._instanceID<0)return;const e=Wo.RUNTIME_FLOAT_STRIDE,t=Wo.CONFIG_FLOAT_STRIDE,r=this._instanceID*e,s=this._instanceID*t;this._runtimeBufferData=Xo._runtimeDataBuffer.subarray(r,r+e),this._configBufferData=Xo._configDataBuffer.subarray(s,s+t)}_setInstanceActive(e){const t=e&&this._instanceID>=0?1:0;this._activeInstanceCount!==t?(this._activeInstanceCount=t,this._renderGeometry&&(this._renderGeometry.instanceCount=t)):this._renderGeometry&&(this._renderGeometry.instanceCount=t)}constructor(){super(),this._cycles=1,this._tiles=new $e(1,1),this._startFrame=0,this._lifeTime=1,this._playOnAwake=!0,this._loop=!1,this._autoDestroyAtComplete=!1,this._unitPixels=50,this._color=new y(1,1,1,1),this._textureUVRect=new i(0,0,1,1),this._elapsedTime=0,this._startTime=0,this._playing=!1,this._paused=!1,this._needRuntimeUpload=!0,this._needConfigUpload=!0,this._configVersion=0,this._instanceID=-1,this._lastMatrix=new Float32Array([NaN,NaN,NaN,NaN,NaN,NaN]),this._lastAlpha=NaN,this._activeInstanceCount=0,this._renderType=e.BaseRender2DType.sequenceFrame2D,this._renderElements=[],this._materials=[]}_getElementMaterial(e){return this._materials[e]||Xo.defaultMaterial}_isMaterialVaild(t){return t.checkType(e.ShaderFeatureType.Default)}_getcommonUniformMap(){return["BaseRender2D"]}_initDefaultRenderData(){Xo.__init__(),this._spriteShaderData.removeDefine(Dn.SHADERDEFINE_BASERENDER2D),this._initRender(),this.texture=this._texture||Hi.whiteTexture,this._needConfigUpload=!0,this._needRuntimeUpload=!0}play(e=!0){var t;this._renderGeometry&&this.enabled&&(null===(t=this.owner)||void 0===t?void 0:t.activeInHierarchy)&&this._ensureInstanceID();const r=this._getCurrentTime();this._elapsedTime=e?0:this._getPlaybackAge(r),this._startTime=r-this._elapsedTime,this._playing=!0,this._paused=!1,this._setInstanceActive(!0),this._markRuntimeDirty()}pause(){if(this._playing&&!this._paused)return this._elapsedTime=this._getPlaybackAge(),this._paused=!0,void this._markRuntimeDirty();this._paused=!0}resume(){this._playing&&this._paused&&(this._startTime=this._getCurrentTime()-this._elapsedTime,this._paused=!1,this._markRuntimeDirty())}stop(e=!0){const t=this._getPlaybackAge();this._playing=!1,this._paused=!1,this._elapsedTime=e?0:t,this._startTime=this._getCurrentTime()-this._elapsedTime,this._setInstanceActive(!1),this._markRuntimeDirty()}renderUpdate(e){if(!this._renderGeometry)return;const t=this._getCurrentTime();this._playing&&!this._paused&&!this._loop&&t-this._startTime>=this._lifeTime&&this._completePlayback(),this._needConfigUpload&&(this._needConfigUpload=!1,this._updateConfigData()),this._activeInstanceCount>0&&(this._needRuntimeUpload||this.boundsChange||this._isRuntimeStateDirty())?(this._needRuntimeUpload=!1,this._updateRuntimeData()):this._activeInstanceCount<=0&&(this._needRuntimeUpload=!1,this.boundsChange=!1),this._updateLight()}onEnable(){this._ensureInstanceID(),p.isPlaying||this._setInstanceActive(!0),p.isPlaying&&this._playOnAwake?this.play(!0):this._markRuntimeDirty()}onDisable(){this.stop(!0),this._releaseInstanceID()}onDestroy(){var e,t,r,s,i;this._releaseInstanceID(),this._texture instanceof ie&&this._texture._removeReference(),null===(e=this._runtimeVertexBuffer)||void 0===e||e.destroy(),null===(t=this._configVertexBuffer)||void 0===t||t.destroy(),null===(s=null===(r=this._renderGeometry)||void 0===r?void 0:r.bufferState)||void 0===s||s.destroy(),null===(i=this._renderGeometry)||void 0===i||i.destroy(),this._runtimeVertexBuffer=null,this._configVertexBuffer=null,this._renderGeometry=null,this._runtimeBufferData=null,this._configBufferData=null,this._texture=null,this._baseRender2DTexture=null}_cloneTo(e){super._cloneTo(e),e.cycles=this._cycles,e.tiles=this._tiles,e.startFrame=this._startFrame,e.lifeTime=this._lifeTime,e.playOnAwake=this._playOnAwake,e.loop=this._loop,e.autoDestroyAtComplete=this._autoDestroyAtComplete,e.unitPixels=this._unitPixels,e.color=this._color,e.texture=this._texture}_canBatchWith(e){return this._baseRender2DTexture===e._baseRender2DTexture}_markRuntimeDirty(){this._needRuntimeUpload=!0,this._notifyDataChange()}_markConfigDirty(e=!1){this._needConfigUpload=!0,this._configVersion++,e&&(this.boundsChange=!0),this._notifyDataChange()}_getCurrentTime(){return va.renderTime}_getPlaybackAge(e=this._getCurrentTime()){const t=this._playing&&!this._paused?e-this._startTime:this._elapsedTime;return this._playing&&!this._paused&&this._loop?(t%this._lifeTime+this._lifeTime)%this._lifeTime:Math.min(Math.max(t,0),this._lifeTime)}_completePlayback(){this._elapsedTime=this._lifeTime,this._playing=!1,this._paused=!1,this._setInstanceActive(!1),this._needRuntimeUpload=!1,this._notifyDataChange();const e=this.owner;null==e||e.event(c.COMPLETE),this._autoDestroyAtComplete&&e&&!e.destroyed&&l.timer.callLater(e,e.destroy,[!0])}_isRuntimeStateDirty(){const e=this.owner._globalTrans.getMatrix(),t=this._color.a*this._struct.globalAlpha,r=this._lastMatrix;return e.a!==r[0]||e.b!==r[1]||e.c!==r[2]||e.d!==r[3]||e.tx!==r[4]||e.ty!==r[5]||t!==this._lastAlpha}_initRender(){this._resizeInstanceBuffers();const t=this._renderGeometry=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.Triangles,e.DrawType.DrawElementInstance);t.bufferState=f.renderDeviceFactory.createBufferState(),t.indexFormat=e.IndexFormat.UInt16,t.setDrawElemenParams(6,0),t.instanceCount=this._activeInstanceCount,t.bufferState.applyState([Wo._vbs,this._runtimeVertexBuffer,this._configVertexBuffer],Wo._ibs);const r=f.render2DRenderPassFactory.createRenderElement2D();r.geometry=t,r.value2DShaderData=this._spriteShaderData,r.renderStateIsBySprite=!1,r.nodeCommonMap=this._getcommonUniformMap(),r.owner=this._struct,r._sequenceFrame2DRender=this,Dn._setRenderElement2DMaterial(r,this._getElementMaterial(0)),this._renderElements[0]=r,this._struct.renderElements=this._renderElements}_resizeInstanceBuffers(){this._runtimeVertexBuffer||(this._runtimeVertexBuffer=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Dynamic)),this._configVertexBuffer||(this._configVertexBuffer=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Dynamic)),this._runtimeVertexBuffer.vertexDeclaration=Wo.runtimeDeclaration,this._runtimeVertexBuffer.instanceBuffer=!0,this._configVertexBuffer.vertexDeclaration=Wo.configDeclaration,this._configVertexBuffer.instanceBuffer=!0;const t=Wo.RUNTIME_FLOAT_STRIDE,r=Wo.CONFIG_FLOAT_STRIDE;this._runtimeVertexBuffer.setDataLength(4*t),this._configVertexBuffer.setDataLength(4*r),this._bindInstanceDataViews(),this._renderGeometry&&this._renderGeometry.bufferState.applyState([Wo._vbs,this._runtimeVertexBuffer,this._configVertexBuffer],Wo._ibs)}_applyTextureToShaderData(e){this._spriteShaderData&&e&&(this._spriteShaderData.setTexture(Dn.BASERENDER2DTEXTURE,e),1!==e.gammaCorrection?this._spriteShaderData.addDefine(kt.GAMMATEXTURE):this._spriteShaderData.removeDefine(kt.GAMMATEXTURE))}_updateRuntimeData(){if(this._activeInstanceCount<=0)return this._renderGeometry&&(this._renderGeometry.instanceCount=0),void(this.boundsChange=!1);this._ensureInstanceID();const e=this.owner._globalTrans.getMatrix(),t=this._runtimeBufferData,r=this._color.a*this._struct.globalAlpha,s=this._lastMatrix;t[0]=s[0]=e.a,t[1]=s[2]=e.c,t[2]=s[4]=e.tx,t[3]=0,t[4]=s[1]=e.b,t[5]=s[3]=e.d,t[6]=s[5]=e.ty,t[7]=0,t[8]=this._startTime,t[9]=this._lastAlpha=r,t[10]=this._getPlaybackAge(),t[11]=this._playing&&!this._paused?this._loop?2:1:0,this._setInstanceActive(!0),this._runtimeVertexBuffer.setData(t.buffer,0,t.byteOffset,4*Wo.RUNTIME_FLOAT_STRIDE),this.boundsChange=!1}_updateConfigData(){this._ensureInstanceID();const e=Math.max(1,Math.floor(this._tiles.x||1)),t=Math.max(1,Math.floor(this._tiles.y||1)),r=e*t,s=Math.max(1e-4,this._unitPixels),i=this._texture instanceof ie?this._texture:this._baseRender2DTexture,a=(i&&i.width?i.width:s*e)/e,n=(i&&i.height?i.height:s*t)/t,o=Math.max(a,n,1e-4),l=a/o*s,h=n/o*s,u=this._configBufferData;u[0]=this._startFrame,u[1]=this._lifeTime,u[2]=this._cycles,u[3]=r,u[4]=a,u[5]=n,u[6]=e,u[7]=t,u[8]=this._color.r,u[9]=this._color.g,u[10]=this._color.b,u[11]=s,u[12]=this._textureUVRect.x,u[13]=this._textureUVRect.y,u[14]=this._textureUVRect.z,u[15]=this._textureUVRect.w,this._configVertexBuffer.setData(u.buffer,0,u.byteOffset,4*Wo.CONFIG_FLOAT_STRIDE),this._rect.setValue(.5*-l,.5*-h,.5*l,.5*h),this.boundsChange=!1}}Xo._instanceCapacity=0,Xo._nextInstanceID=0,Xo._freeInstanceIDs=[],Xo._activeRenderers=[],Xo._runtimeDataBuffer=new Float32Array(0),Xo._configDataBuffer=new Float32Array(0);class Yo extends Sn{constructor(){super(),this._top=null,this._bottom=null,this._left=null,this._right=null,this._centerX=null,this._centerY=null,this.runInEditor=!0,this.hideFlags|=Re.HideAndDontSave}onReset(){this._top=this._bottom=this._left=this._right=this._centerX=this._centerY=null}_onEnable(){this.owner.parent?this._onAdded():this.owner.once(c.ADDED,this,this._onAdded)}_onDisable(){this.owner.off(c.ADDED,this,this._onAdded),this.owner.parent&&this.owner.parent.off(c.RESIZE,this,this._onParentResize)}_onAdded(){this.owner.parent&&this.owner.parent.on(c.RESIZE,this,this._onParentResize),this.resetLayoutX(),this.resetLayoutY()}_onParentResize(){var e=this.resetLayoutX(),t=this.resetLayoutY();(e||t)&&this.owner.event(c.RESIZE)}resetLayoutX(){var e=this.owner;if(!e)return!1;var t=e.parent;if(t)if(null!=this._centerX)e.x=Math.round(.5*(t.width-e.displayWidth)+this._centerX+e.pivotX*e.scaleX);else if(null!=this._left){if(e.x=Math.round(this._left+e.pivotX*e.scaleX),null!=this._right){if(!t._width)return!1;var r=(t._width-this._left-this._right)/(e.scaleX||.01);if(r!=e._width)return e.width=r,!0}}else null!=this._right&&(e.x=Math.round(t.width-e.displayWidth-this._right+e.pivotX*e.scaleX));return!1}resetLayoutY(){var e=this.owner;if(!e)return!1;var t=e.parent;if(t)if(null!=this._centerY)e.y=Math.round(.5*(t.height-e.displayHeight)+this._centerY+e.pivotY*e.scaleY);else if(null!=this._top){if(e.y=Math.round(this._top+e.pivotY*e.scaleY),null!=this._bottom){if(!t._height)return!1;var r=(t._height-this._top-this._bottom)/(e.scaleY||.01);if(r!=e._height)return e.height=r,!0}}else null!=this._bottom&&(e.y=Math.round(t.height-e.displayHeight-this._bottom+e.pivotY*e.scaleY));return!1}resetLayout(){this.owner&&(this.resetLayoutX(),this.resetLayoutY())}get top(){return this._top}set top(e){isNaN(e)&&(e=null),this._top!=e&&(this._top=e,this.resetLayoutY())}get bottom(){return this._bottom}set bottom(e){isNaN(e)&&(e=null),this._bottom!=e&&(this._bottom=e,this.resetLayoutY())}get left(){return this._left}set left(e){isNaN(e)&&(e=null),this._left!=e&&(this._left=e,this.resetLayoutX())}get right(){return this._right}set right(e){isNaN(e)&&(e=null),this._right!=e&&(this._right=e,this.resetLayoutX())}get centerX(){return this._centerX}set centerX(e){isNaN(e)&&(e=null),this._centerX!=e&&(this._centerX=e,this.resetLayoutX())}get centerY(){return this._centerY}set centerY(e){isNaN(e)&&(e=null),this._centerY!=e&&(this._centerY=e,this.resetLayoutY())}}Yo.EMPTY=null,Yo.EMPTY=new Yo;class qo{constructor(){this.componentElementMap=new Map,this._shaderData=f.renderDeviceFactory.createShaderData(null),qo.SPRITE2DGLOBAL||(qo.SPRITE2DGLOBAL=Ot.getDefineByName("SPRITE2DGLOBAL")),this._shaderData.addDefine(qo.SPRITE2DGLOBAL)}}const $o={scene3d:null,sharedCamera:null,applyData(e){},finalizeSetup(){},destroy(){},_onAdded(){},_onRemoved(){}};class Ko extends po{static regManager(e,t){Ko.componentManagerMap.set(e,t)}static __init__(){(Ko.scene2DUniformMap=f.renderDeviceFactory.createGlobalUniformMap("Sprite2DGlobal")).addShaderUniform(kt.VIEW2D,"u_view2D",e.ShaderDataType.Matrix3x3)}get bridge3DInternal(){return this._bridge3DInternal}get bridge3D(){return this._bridge3D}set bridge3D(e){this._bridge3D!==e&&(this._bridge3D=e,this._bridge3DInternal.applyData(e))}constructor(){super(),this.autoDestroyAtClosed=!1,this._bridge3DInternal=$o,this._componentElementDatasMap={},this._specialManager=new qo,this._timer=l.timer,this._widget=Yo.EMPTY,this._area2Ds=new Set,this._scene=this,Ko.componentManagerMap.forEach((e,t)=>{this._specialManager.componentElementMap.set(t,new e(this))}),this._globalRenderData=f.render2DRenderPassFactory.create2DGlobalRenderDataHandle(),this._globalRenderData.globalShaderData=this._shaderData=this._specialManager._shaderData,this._globalRenderData.renderLayerMask=-1,this._struct.globalRenderData=this._globalRenderData,this._struct.spriteShaderData=this._shaderData,zt.initBlendMode(this._shaderData),this._bridge3DInternal=Ko.bridge3DInternalHandler(this)}get componentElementDatasMap(){return this._componentElementDatasMap}set componentElementDatasMap(e){this._componentElementDatasMap=e,this._specialManager.componentElementMap.forEach((e,t)=>{this._componentElementDatasMap[t]&&e.Init(this._componentElementDatasMap[t])})}_update(){var e=.001*l.timer.delta;this._specialManager.componentElementMap.forEach(t=>{t.update(e)})}getComponentElementManager(e){return this._specialManager.componentElementMap.get(e)}getNodeByID(e){return this._idMap?this._idMap[e]:null}open(e,t){(null==e||e)&&Ko.closeAll(),Ko.root.addChild(this),this._scene3D&&l.stage.addChildAt(this._scene3D,0),this.onOpened(t)}onOpened(e){}close(e=null){this.onClosed(e),this.autoDestroyAtClosed?(this.destroy(),this._scene3D&&this._scene3D.destroy()):(this.removeSelf(),this._scene3D&&this._scene3D.removeSelf())}onClosed(e){}onAfterDeserialize(){super.onAfterDeserialize(),this._bridge3DInternal.finalizeSetup()}destroy(e=!0){super.destroy(e),this._bridge3DInternal.destroy(),this._bridge3DInternal=$o,this._bridge3D=null,this._scene3D&&(this._scene3D.destroy(),this._scene3D=null),this._idMap=null,Ko.unDestroyedScenes.delete(this),this._specialManager.componentElementMap.forEach(e=>{e.destroy()})}get timer(){return this._timer}set timer(e){this._timer=e}get scene3D(){return this._scene3D}get top(){return this._widget.top}set top(e){e!=this._widget.top&&(this._getWidget().top=e)}get bottom(){return this._widget.bottom}set bottom(e){e!=this._widget.bottom&&(this._getWidget().bottom=e)}get left(){return this._widget.left}set left(e){e!=this._widget.left&&(this._getWidget().left=e)}get right(){return this._widget.right}set right(e){e!=this._widget.right&&(this._getWidget().right=e)}get centerX(){return this._widget.centerX}set centerX(e){e!=this._widget.centerX&&(this._getWidget().centerX=e)}get centerY(){return this._widget.centerY}set centerY(e){e!=this._widget.centerY&&(this._getWidget().centerY=e)}render(e,t){this._preRenderUpdate(e,t);for(let e of this._area2Ds)e.render()}setglobalRenderData(e,t,r){this._shaderData&&this._shaderData.setShaderData(e,t,r);for(let s of this._area2Ds)s._globalShaderData.setShaderData(e,t,r)}_preRenderUpdate(e,t){this._specialManager._shaderData,this._light2DManager&&this._light2DManager.preRenderUpdate()}_transChanged(t){super._transChanged(t),0!=(t&e.TransformKind.Layout)&&this.callLater(this._sizeChanged)}_sizeChanged(){this.event(c.RESIZE),this._widget!==Yo.EMPTY&&this._widget.resetLayout()}_onAdded(){super._onAdded(),l.stage._scene2Ds.push(this),this._bridge3DInternal._onAdded()}_onRemoved(){super._onRemoved();let e=l.stage._scene2Ds.indexOf(this);l.stage._scene2Ds.splice(e,1),this._bridge3DInternal._onRemoved()}freshLayout(){this.refreshLayout()}refreshLayout(){this._widget!=Yo.EMPTY&&this._widget.resetLayout()}_getWidget(){return this._widget===Yo.EMPTY&&(this._widget=this.addComponent(Yo)),this._widget}static get root(){let e=Ko._root;return e||(e=Ko._root=l.stage.addChild(new po),e.name="root",e.mouseThrough=!0,e.hideFlags|=Re.HideTransformTool,l.stage.on("resize",null,()=>{e.size(l.stage.width,l.stage.height),e.event(c.RESIZE)}),e.size(l.stage.width,l.stage.height),e.event(c.RESIZE)),e}static load(e,t,r){return Ko._load(e,r?e=>r.runWith(e):null).then(e=>(t&&t.runWith(e),e))}static open(e,t,r,s,i){if("function"==typeof s&&(i=s,s=null),"function"==typeof r&&(s=r,r=null),i instanceof he){let e=i;i=t=>e.runWith(t)}return Ko._load(e,i).then(e=>(e.open(t,r),s instanceof he?s.runWith(e):s&&s(e),e))}static _load(e,t){return Ko.showLoadingPage(),l.loader.load(e,null,e=>{Ko._loadPage&&Ko._loadPage.event("progress",e),t&&t(e)}).then(t=>{if(Ko.hideLoadingPage(),!t)throw new Error("Can not find scene:"+e);let r,s=[],i=t.create(null,s);if(s.length>0&&console.warn(`Error loading ${e}: \n${s.join("\n")}`),i instanceof Ko)r=i;else{if(1!==i._nodeType)throw new Error("Not a scene:"+e);r=new Ko,r.left=r.right=r.top=r.bottom=0,r._scene3D=i}return r._scene3D&&(r._scene3D._scene2D=r),Ko.unDestroyedScenes.add(r),r})}static close(e,t){let r=!1;for(let s of Ko.unDestroyedScenes)if(s&&s.parent&&s.url===e&&(null==t||s.name==t)){s.close(),r=!0;break}return r}static closeAll(){let e=Ko.root;for(let r=0,s=e.numChildren;r<s;r++){var t=e.getChildAt(0);t instanceof Ko?t.close():t.removeSelf()}}static destroy(e,t){let r=!1;for(let s of Ko.unDestroyedScenes)if(s.url===e&&(null==t||s.name==t)&&!s._destroyed){s.destroy(),r=!0;break}return r}static gc(){G.destroyUnusedResources()}static setLoadingPage(e){Ko._loadPage=e}static showLoadingPage(e=null,t=500){Ko._loadPage&&(l.systemTimer.clear(null,Ko._showLoading),l.systemTimer.clear(null,Ko._hideLoading),l.systemTimer.once(t,null,Ko._showLoading,[e],!1))}static _showLoading(e){l.stage.addChild(Ko._loadPage),Ko._loadPage instanceof Ko&&Ko._loadPage.onOpened(e)}static _hideLoading(){Ko._loadPage instanceof Ko?Ko._loadPage.close():Ko._loadPage.removeSelf()}static hideLoadingPage(e=500){Ko._loadPage&&(l.systemTimer.clear(null,Ko._showLoading),l.systemTimer.clear(null,Ko._hideLoading),l.systemTimer.once(e,null,Ko._hideLoading))}}Ko.unDestroyedScenes=new Set,Ko.componentManagerMap=new Map,Ko.bridge3DInternalHandler=function(){return $o};class jo{static init(...t){if(jo._inited)return Promise.resolve();let r;jo._inited=!0,r="number"==typeof t[0]?{designWidth:t[0],designHeight:t[1]}:t[0],l.systemTimer=jo.systemTimer=Po.gSysTimer=e.systemTimer=new Po(!1),l.timer=jo.timer=e.timer=new Po(!1),l.physicsTimer=jo.physicsTimer=e.physicsTimer=new Po(!1),l.loader=jo.loader=e.loader=new Te,W.__init__();let s=[];s.push(()=>((Y.mainCanvas=new Me(!1)).source=W.browser.createMainCanvas(),Y.canvas=new Me(!0),Y.context=Y.canvas.context,W.browser.start())),p.beforeInit&&s.push(()=>p.beforeInit(r)),s.push(async()=>{for(let e=0;e<jo._beforeInitCallbacks.length;e++)await jo._beforeInitCallbacks[e](r)}),s.push(()=>f.renderDeviceFactory.createEngine(null,Y.offscreenMainCanvas||Y.mainCanvas)),s.push(()=>jo.initRender2D(r));let i=window.Laya3D;i&&s.push(()=>i.__init__()),s.push(()=>Promise.all(jo._initCallbacks.map(e=>e()))),s.push(()=>{let e=Promise.resolve();for(let t of jo._afterInitCallbacks)e=e.then(t);return e}),p.afterInit&&s.push(()=>p.afterInit());let a=Promise.resolve();for(let e of s)a=a.then(e);return a}static initRender2D(r){W.browser.onInitRender(),e.stage=window.stage=l.stage=jo.stage=new No,e.stage.size(r.designWidth,r.designHeight),r.scaleMode&&(e.stage.scaleMode=r.scaleMode),r.screenMode&&(e.stage.screenMode=r.screenMode),r.alignV&&(e.stage.alignV=r.alignV),r.alignH&&(e.stage.alignH=r.alignH),t.isAlpha?e.stage.bgColor="#00000000":r.backgroundColor&&(e.stage.bgColor=r.backgroundColor),It.__init__(),Lt.__init__(),Ot.init(),Yr.__init__(),kt.__init__(),Io.__init__(),Ut.__init__(),zt._init_(),Hi.__init__(),Xa.__init__(),Go.__init__(),fa.__init__(),Uo.__init__(),vi.__init__(),Ko.__init__(),va.__init__(),Dn.initBaseRender2DCommandEncoder(),so.__init__(),uo.init(),Zn.__initDefine__(),to.__init__(),Xo.__init__(),wo.__init__(),Vo.__init__()}static alertGlobalError(e){e?W.browser.captureGlobalError(jo._onGlobalError):W.browser.captureGlobalError(null)}static _onGlobalError(e){var t;let r="Something went wrong\n"+(e.message||e.reason)+"\n"+(e.stack||(null===(t=e.error)||void 0===t?void 0:t.stack));Qo++<5?W.browser.alert(r):console.error(r)}static addInitCallback(e){jo._initCallbacks.push(e)}static addBeforeInitCallback(e){jo._beforeInitCallbacks.push(e)}static addAfterInitCallback(e){jo._afterInitCallbacks.push(e)}static importNative(e){if(!p.isConch)return null;let t=window.$DLL_PATHS[e],r=window.importNative(t||e);if(!r)throw new Error(`failed to load ${e}`);return r}}jo.stage=null,jo.systemTimer=null,jo.physicsTimer=null,jo.timer=null,jo.loader=null,jo._inited=!1,jo._initCallbacks=[],jo._beforeInitCallbacks=[],jo._afterInitCallbacks=[];var Qo=0;l.Laya=jo,l.Loader=Te,l.InputManager=wo;var Zo=jo.init;e.stage=void 0,e.systemTimer=void 0,e.physicsTimer=void 0,e.timer=void 0,e.loader=void 0;var Jo=jo.alertGlobalError,el=jo.addInitCallback,tl=jo.addBeforeInitCallback,rl=jo.addAfterInitCallback,sl=jo.importNative;const il=new Set(["x","y","width","height","controllers","relations","gears"]);class al{static parse(e,t,r){let s=null==r;r=r||[];let i,a,n,o,l,h,u,d,c={},_=[],p=[],g=[],m=[];function f(e,t){for(let r of e._$child)if(r._$child){let e=T(r,t);f(r,r._$prefab?e:t),_.push(r),p.push(e)}else{let e=T(r,t);_.push(r),p.push(e)}}function T(e,t){let s,i;if(i=e._$override){if(t&&n)if(Array.isArray(i)){s=t;for(let e=0,r=i.length;e<r;e++){let r=n.get(s);if(s=null==r?void 0:r[i[e]],!s)break;if(s==t){s=null;break}}}else{let r=n.get(t);r&&(s=r[e._$override],s==t&&(s=null))}}else{if(i=e._$prefab){let t=Te.getRes(ee.getResURLByUUID(i),Te.HIERARCHY);if(t){n||(n=new Map);let i=[],a=e._$id;if(l)for(let e=0,t=l.length;e<t;e++){let r=l[e];r&&r.length>0?i[e]=r.filter(r=>{let s=r._$override||r._$parent;return Array.isArray(s)&&s.length>t-e&&s[t-e-1]==a}):i[e]=r}i.push(e._$child),s=t.create({inPrefab:!0,prefabNodeDict:n,overrideData:i},r)}}else if(i=e._$type){let t=Ee.getClass(i);if(t)try{s=new t}catch(e){r.push(e)}else r.push(new Error(`missing node type '${i}' (in ${e.name||"noname"})`))}s&&(c[e._$id]=s,2===s._nodeType&&(u=!0))}return s}function y(e,t,r=0){if(!t)return e;let s=null==n?void 0:n.get(e);if(!s)return null;if(Array.isArray(t)){let e;for(let i=r,a=t.length;i<a;i++){if(!s)return null;if(e=s[t[i]],!e)break;s=n.get(e)}return e}return s[t]}if(t&&(a=t.inPrefab,a&&(n=t.prefabNodeDict),o=t.skinBaseUrl,l=t.overrideData),e._$type||e._$prefab){let s,a=e._$runtime;a&&(h=!0,a.startsWith("res://")&&(a=a.substring(6)),a=Ee.getClass(a),a||r.push(new Error(`missing runtime class '${e._$runtime}'`))),t&&t.runtime&&(a=t.runtime),a?(s=new a,s instanceof Wa||(r.push(new Error(`runtime class invalid - '${a}', must derive from Node`)),s=null),c[e._$id]=s):s=T(e,null),s&&(e._$child&&f(e,e._$prefab?s:null),_.push(e),p.push(s),s instanceof Ko&&(i=s))}else e._$child&&f(e,null);let x=_.length,S=0,E=[];for(let e=0;e<x;e++){let t=_[e],r=p[e],s=t._$child;if(s){let e=s.length;if(r)if(t._$prefab)for(let t=0;t<e;t++){let s=S-e+t,i=g[s];if(i&&!i.parent){let e=E[s],t=y(r,e._$parent);if(t){let r=e._$index;null!=r&&r<t.numChildren?t.addChildAt(i,r):t.addChild(i)}else r.addChildAt(i,0)}}else for(let t=0;t<e;t++){let s=g[S-e+t];s&&(r===i&&s.is3D?i._scene3D=s:r.addChild(s))}S-=e}g[S]=r,E[S]=t,S++}g.length=S,g=g.filter(e=>null!=e);let v=g[0],D=[];for(let e=0;e<x;e++){let t=_[e]._$comp;if(!t)continue;let s=p[e];if(s)for(let i of t){let t,a=i._$override;if(i._$override){let e=Ee.getClass(a);t=e?s.getComponent(e):s.components.find(e=>e._extra.storeId==a)}else{let a=Ee.getClass(i._$type);if(a){if(i._$id||(t=s.getComponent(a)),!t)try{t=s.addComponent(a),t._extra.storeId=i._$id}catch(e){r.push(e)}}else r.push(new Error(`missing component type '${i._$type}' (in ${_[e].name||"noname"})`))}t&&D.push(i,t)}}const w=new ul;w.errors=r,w.getNodeByRef=function(e){if(Array.isArray(e)){let t=c[e[0]];return t&&e.length>1?y(t,e,1):t}return c[e]},w.getNodeData=function(e){let t=p.indexOf(e),r=_[t];return e.removeSelf(),m.push(r._$id),p[t]=null,l?(void 0===d&&(d=pl.bakeOverrideData(l)),d?pl.applyOverrideData(r,d):r):r};for(let e=0;e<x;e++){let t=_[e],r=p[e];!r||2!==r._nodeType&&r!==i||w.decodeObjBounds(t,r)}if(u){2===v._nodeType&&(v.sourceWidth=v.width,v.sourceHeight=v.height);for(let e=0;e<x;e++){let t=_[e],r=p[e];if(r&&2===r._nodeType){let e=t.relations;null!=e&&(null!=t._$prefab?r._addRelations(w.decodeObj(e)):r.relations=w.decodeObj(e))}}}for(let e=0;e<x;e++){let t=_[e],s=p[e];if(s&&(null!=o&&0===s._nodeType&&(s._skinBaseUrl=o),w.decodeObj(t,s,2===s._nodeType||s===i?il:null),h&&t._$var&&s.name))try{v[s.name]=s}catch(e){r.push(e)}}let R=D.length;for(let e=0;e<R;e+=2){let t=D[e],r=D[e+1];w.decodeObj(t,r)}if(u){for(let e=0;e<x;e++){let t=_[e],r=p[e];if(r&&2===r._nodeType){let e=t.gears;null!=e&&(null!=t._$prefab?r._addGears(w.decodeObj(e)):r.gears=w.decodeObj(e))}}if(!(2!==v._nodeType||n&&n.has(v)))try{v._onConstruct(a)}catch(e){r.push(e)}}for(let e of m){let t=c[e];t._destroyed||t.destroy(),delete c[e]}return a&&n&&v&&n.set(v,c),s&&r.length>0&&r.forEach(e=>console.error(e)),g}static collectResourceLinks(e,t){let r,s={},i=[],a=!0;function n(e,r,n){if(!e)return"";r=r||void 0,Q.isUUID(e)?e="res://"+e:n||(e=ee.join(t,e));let o=s[e];return void 0===o?(i.push({url:e,type:r,preload:a}),s[e]=[r]):-1===o.indexOf(r)&&(i.push({url:e,type:r,preload:a}),o.push(r)),e}function o(e){if(null==e._$uuid){if(null!=e._$prefab)e._$prefab=n(e._$prefab,Te.HIERARCHY);else if(null!=(r=e._$type))if(r.endsWith(".bp"))n(r,null,!0);else if(p.isPreview&&Q.isUUID(r)){let e=Ee.getClass(r);(null==e||e._$loadable)&&n("res://"+r,null)}l(e)}else e._$uuid=n(e._$uuid,Te.assetTypeToLoadType[e._$type])}function l(e){for(let t in e){let r=e[t];if(null!=r)if(Array.isArray(r)){for(let e of r)if(null!=e)if("object"==typeof e)o(e);else if("string"==typeof e&&e.startsWith("i18n:")){let t=e.indexOf(":",5);-1!=t&&n(J.inst.getI18nSettingsURL(e.substring(5,t)),null)}}else if("object"==typeof r)o(r);else if("string"==typeof r&&r.startsWith("i18n:")){let e=r.indexOf(":",5);-1!=e&&n(J.inst.getI18nSettingsURL(r.substring(5,e)),null)}}}if(e._$preloads){let t=e._$preloadTypes,r=0;for(let s of e._$preloads)t&&t[r]?n(s,Te.assetTypeToLoadType[t[r]],!0):n(s,null,!0),r++}return a=!1,l(e),i}}class nl extends G{constructor(){super(!1),this.fromDCC=!1,this._traceDeps=!0}onLoad(){return G._idResourcesMap[this._id]=this,this}create(e,t){return null}static instantiate(e,t){return l.loader.load(e,Te.HIERARCHY).then(e=>e.create())}}var ol,ll=nl;class hl extends nl{constructor(e,t){super(),this.api=e||hl.v3,this.data=t}create(e,t){let r=Ee.getRuntime(this.url);r&&(e?e.runtime||(e=Object.assign({runtime:r},e)):e={runtime:r});let s=this.api.parse(this.data,e,t);return Array.isArray(s)?(1==s.length&&(s[0].url=this.url),s[0]):(s.url=this.url,s)}}hl.v3=al,hl.v2=null;class ul{constructor(){this.getNodeByRef=dl,this.getNodeData=dl}static decodeObj(e,t){return cl.errors=null,cl.getNodeByRef=dl,cl.getNodeData=dl,cl.decodeObj(e,t)}decodeObj(e,t,r){pl.isDeserializing=!0;try{return this._decode(e,t,r)}finally{pl.isDeserializing=!1}}decodeObjBounds(e,t){pl.isDeserializing=!0;try{let r=e.x,s=e.y;void 0!==r&&void 0!==s?t.pos(r,s):void 0!==r?t.x=r:void 0!==s&&(t.y=s),r=e.width,s=e.height,void 0!==r&&void 0!==s?t.size(r,s):void 0!==r?t.width=r:void 0!==s&&(t.height=s),r=e.controllers,void 0!==r&&(t.controllers=this._decode(r))}finally{pl.isDeserializing=!1}}_decode(e,t,r){if(null==e)return null;if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let s=e[r];if(null!=s)try{t[r]=this._decode(s)}catch(e){this.errors?this.errors.push(e):console.error(e),t[r]=null}else t[r]=null}return t}if("object"==typeof e){if(null!=e._$uuid){let t=ee.getResURLByUUID(e._$uuid);return l.loader.getRes(t,Te.assetTypeToLoadType[e._$type])}if(null!=e._$ref){let t=this.getNodeByRef(e._$ref);if(!t)return null;if(e._$type){let r=Ee.getClass(e._$type);return r?t.getComponent(r):null}if(void 0!==e._$ctrl){let r=ol||(ol=Ee.getClass("ControllerRef"));return r?new r(t,e._$ctrl):null}return t}let s=e._$type;if("any"===s)return e._$type?e.value:e;let i=_l[s];if(null!=i)return e._$type?new i(e.value):new i(e);if(!t){let e=Ee.getClass(s);if(!e)return null;t=new e}for(let s in e){if(s.startsWith("_$")||r&&r.has(s))continue;let i=e[s];if(null==i||"object"!=typeof i||Array.isArray(i)||i._$type||i._$uuid||i._$ref)try{let e=this._decode(i);t[s]=e,null!=e&&null!=i&&i._$tmpl&&(t[i._$tmpl]=new hl(null,this.getNodeData(e)))}catch(e){this.errors?this.errors.push(e):console.error(e)}else{let e=t[s];if(e)try{this._decode(i,e)}catch(e){this.errors?this.errors.push(e):console.error(e)}}}if(t.onAfterDeserialize)try{pl._data=e,t.onAfterDeserialize()}catch(e){this.errors?this.errors.push(e):console.error(e)}return t}return e}}function dl(...e){return null}const cl=new ul,_l={Int8Array:Int8Array,Uint8Array:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};class pl{static hasProp(...e){for(let t of e)if(void 0!==pl._data[t])return!0;return!1}static decodeObj(e,t){return ul.decodeObj(e,t)}static getLoadTypeByEngineType(e){return Te.assetTypeToLoadType[e]}static bakeOverrideData(e){let t=null;for(let r=e.length,s=r-1;s>=0;s--){let i=e[s];if(i&&i.length>0)for(let e of i){let i,a=e._$override||e._$parent;if(Array.isArray(a)?i=a[r-s-1]:s===r-1&&(i=a),null!=i){t||(t={});let a=t[i];a||(t[i]=a=[]),a.push(r-s,e)}}}return t}static applyOverrideData(e,t){return function e(r){if(t[r._$id])return!0;let s=r._$child;return!(!s||!s.find(t=>e(t)))}(e)&&(e=function e(t){let r=Object.assign({},t),s=r._$child;s&&(r._$child=s.map(t=>e(t)));let i=r._$comp;return i&&(r._$comp=i.map(e=>Object.assign({},e))),r}(e),function e(r){let s=r._$child;if(s)for(let t of s)t._$id&&e(t);let i=t[r._$id];if(i)for(let e=0;e<i.length;e+=2){let t,a=i[e],n=i[e+1];if(t=n._$override){let e;if(Array.isArray(t))if(a===t.length-1){let i=t[a];s?e=s.find(e=>e._$override==i):r._$child=s=[],e||(e={_$override:i},s.push(e))}else if(a<t.length-1){let i=t.slice(a);s?e=s.find(e=>{let t=e._$override;return Array.isArray(t)&&ml(t,i)}):r._$child=s=[],e||(e={_$override:i},s.push(e))}else e=r;else e=r;if(gl(e,n),n._$comp){let t=e._$comp;t||(e._$comp=t=[]);for(let e of n._$comp){let r=e._$type||e._$override,s=t.find(e=>e._$override==r||e._$type==r||e._$id==r);s||(s={},e._$type?s._$type=r:s._$override=r,t.push(s)),gl(s,e)}}}else if(t=n._$parent){let e;if(s||(r._$child=s=[]),a<t.length){e=a===t.length-1?t[a]:t.slice(a);let r=Object.assign({},n);r._$parent=e,s.push(r)}else{let e=Object.assign({},n);delete e._$parent,r._$prefab?s.push(e):(delete e._$index,n._$index<s.length?s.splice(n._$index,0,e):s.push(e))}}}}(e)),e}}function gl(e,t){for(let r in t){if(r.startsWith("_$"))continue;let s=t[r];if(null==s||"object"!=typeof s||Array.isArray(s)||(s._$type||s._$uuid||s._$ref))e[r]=s;else{let t=e[r];null!=t&&"object"==typeof t?(e[r]=t=Object.assign({},t),gl(t,s)):e[r]=s}}}function ml(e,t){if(e.length===t.length){for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}return!1}var fl,Tl,yl;pl.isDeserializing=!1,e.AnimationWrapMode=void 0,(fl=e.AnimationWrapMode||(e.AnimationWrapMode={}))[fl.Positive=0]="Positive",fl[fl.Reverse=1]="Reverse",fl[fl.PingPong=2]="PingPong",e.AnimationStretchMode=void 0,(Tl=e.AnimationStretchMode||(e.AnimationStretchMode={}))[Tl.None=0]="None",Tl[Tl.Fill=1]="Fill",Tl[Tl.ResizeToFit=2]="ResizeToFit";class xl extends Sn{constructor(){super(),this.repeatDelay=0,this.frameDelaysLoop=!1,this.timeScale=1,this._wrapMode=0,this._loop=!0,this._frame=0,this._autoPlay=!0,this._stretchMode=0,this._source="",this._playing=!1,this._activeStart=0,this._count=0,this._rangeStart=0,this._rangeEnd=-1,this._index=0,this._elapsed=0,this._loadId=0,this.interval=t.animationInterval,this._frames=[],this._drawCmds=[],this._delays=[],this._offset=new d,this._color=new y(1,1,1,1),this._singleton=!1,this.runInEditor=!0}get frame(){return p.isPlaying?this._frame:this._index}set frame(e){var t;e=Math.floor(e),Number.isFinite(e)||(e=0),this._count>0&&(e=Math.max(0,Math.min(e,this._count-1))),this._index=this._frame=e,this.drawFrame(),(null===(t=this._labels)||void 0===t?void 0:t[e])&&this.owner.event(c.LABEL,this._labels[e])}get rangeStart(){return this._rangeStart}set rangeStart(e){e=Number.isFinite(e)?Math.max(0,Math.floor(e)):0,this._rangeStart!==e&&(this._rangeStart=e,this.updateActiveRange(!0))}get rangeEnd(){return this._rangeEnd}set rangeEnd(e){e=Number.isFinite(e)?Math.max(-1,Math.floor(e)):-1,this._rangeEnd!==e&&(this._rangeEnd=e,this.updateActiveRange(!0))}get count(){return this._count}get frames(){return this._frames}set frames(t){var r,s;this._drawCmd&&(null===(r=this.owner._graphics)||void 0===r||r.removeCmd(this._drawCmd),this._drawCmd=null);for(let e of this._drawCmds)e.lock=!1,e.recover();if(this._drawCmds.length=0,this._frames.length=0,null===(s=this.owner._graphics)||void 0===s||s.preRegisterFrameAnimationCmds(null),null!=t&&t.length>0){this._frames.push(...t);let r=0,s=0;this._stretchMode===e.AnimationStretchMode.None&&(r=this._offset.x,s=this._offset.y);let i=this._stretchMode===e.AnimationStretchMode.Fill;for(let e of t){let t=i?Is.create(e,0,0,1,1,null,1,null,null,null,!0):Is.create(e,r,s);t.lock=!0,this._drawCmds.push(t)}this.updateActiveRange(!1),this._elapsed=0,this._wrapMode===e.AnimationWrapMode.Reverse?this._frame=this._count-1:(this._reversed=!1,this._frame=this._index>0&&this._index<this._count?this._index:0),this.updateSizeToFit(),this.drawFrame(),this.owner.graphics.preRegisterFrameAnimationCmds(this._drawCmds)}else this._activeStart=0,this._count=0}get frameDelays(){return this._delays}get isPlaying(){return this._playing}get autoPlay(){return this._autoPlay}set autoPlay(e){this._autoPlay=e,this.enabled&&(e?this.play():this.stop())}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!=t&&(this._wrapMode=t,this._playing&&(t===e.AnimationWrapMode.Reverse?this._reversed=!0:t===e.AnimationWrapMode.Positive&&(this._reversed=!1)))}get loop(){return this._loop}set loop(e){this._loop!=e&&(this._loop=e,e&&!this._playing&&this._autoPlay&&this.play())}get stretchMode(){return this._stretchMode}set stretchMode(t){if(!this._changingSize&&this._stretchMode!=t&&(this._stretchMode=t,this._count>0)){if(this._stretchMode===e.AnimationStretchMode.ResizeToFit){let e=this.width,t=this.height;(e>0&&t>0||p.isPlaying)&&(this._changingSize=!0,this.owner.size(e,t),this._changingSize=!1)}this.applyStretchMode(),this.drawFrame()}}get offset(){return this._offset}set offset(e){this._offset.copy(e),this.applyStretchMode(),this.drawFrame()}get color(){return this._color}set color(e){this._color=e,this.drawFrame()}get width(){return this._count>0?this._frames[this._activeStart].sourceWidth:0}get height(){return this._count>0?this._frames[this._activeStart].sourceHeight:0}updateActiveRange(t){let r=this._frames.length;if(0===r)this._activeStart=0,this._count=0;else{let e=Math.min(this._rangeStart,r-1),t=-1===this._rangeEnd?r-1:Math.min(Math.max(this._rangeEnd,e),r-1);this._activeStart=e,this._count=t-e+1}t?(this._reversed=this._wrapMode===e.AnimationWrapMode.Reverse,this._index=this._frame=this._reversed&&this._count>0?this._count-1:0,this._elapsed=0,this.owner&&(this.updateSizeToFit(),this.drawFrame())):this._count>0&&(this._frame=Math.max(0,Math.min(this._frame,this._count-1)),this._index=Math.max(0,Math.min(this._index,this._count-1)))}updateSizeToFit(){if(this._stretchMode!==e.AnimationStretchMode.ResizeToFit)return;let t=this.width,r=this.height;(t>0&&r>0||p.isPlaying)&&(this._changingSize=!0,this.owner.size(t,r),this._changingSize=!1)}applyStretchMode(){if(this._stretchMode===e.AnimationStretchMode.Fill)for(let e of this._drawCmds)e.x=e.y=0,e.width=e.height=1,e.percent=!0;else{let t=0,r=0;this._stretchMode===e.AnimationStretchMode.None&&(t=this._offset.x,r=this._offset.y);for(let e of this._drawCmds)e.x=t,e.y=r,e.texture&&(e.width=e.texture.sourceWidth,e.height=e.texture.sourceHeight),e.percent=!1}}play(){this._playing||(this._playing=!0,this._elapsed=0,this._reversed=this._wrapMode===e.AnimationWrapMode.Reverse)}stop(){this._playing=!1,p.isPlaying||(this._frame=this._index,this.drawFrame())}_onEnable(){this._autoPlay&&this.play()}_onDestroy(){super._onDestroy(),this.frames=null,this._atlas&&(this.owner._getBit(we.EDITING_NODE)&&this._atlas.off("reload",this,this.onAtlasReload),this._atlas=null)}onUpdate(){var t,r;if(!this._playing||0==this._count)return;let s=l.timer.delta;s>100&&(s=100),1!=this.timeScale&&(s*=this.timeScale);let i=this._frame,a=this._activeStart+i;this._elapsed+=s;let n=this.interval;if(this._reversed?n+=i>0?this.getFrameDelay(a-1):this.repeatDelay:(n+=this.getFrameDelay(a),i===this._count-1&&(n+=this.repeatDelay)),this._elapsed<n)return;this._elapsed-=n,this._elapsed>this.interval&&(this._elapsed=this.interval);let o=!1;if(1===this._count)return this._loop?(this.drawFrame(),(null===(t=this._labels)||void 0===t?void 0:t[0])&&this.owner.event(c.LABEL,this._labels[0])):this._playing=!1,void this.owner.event(c.COMPLETE);this._reversed?(i--,i<0&&(this._loop?(this._wrapMode===e.AnimationWrapMode.PingPong?(this._reversed=!1,i=1):i=this._count-1,o=!0):(i=0,this._playing=!1,o=!0))):(i++,i>this._count-1&&(this._loop?(this._wrapMode===e.AnimationWrapMode.PingPong?(this._reversed=!0,i=Math.max(0,this._count-2)):i=0,o=!0):(i=this._count-1,this._playing=!1,o=!0))),this._frame=i,this._playing&&(this.drawFrame(),(null===(r=this._labels)||void 0===r?void 0:r[i])&&this.owner.event(c.LABEL,this._labels[i])),o&&this.owner.event(c.COMPLETE)}getFrameDelay(e){return 0===this._delays.length?0:(this.frameDelaysLoop&&(e%=this._delays.length),this._delays[e]||0)}drawFrame(){let e=this._drawCmds[this._activeStart+this._frame];e&&(e.color=this._color.getABGR());let t=this.owner.graphics;e!=this._drawCmd?this._drawCmd&&e&&t.patchFrameAnimationCmd(this._drawCmd,e)?this._drawCmd=e:this._drawCmd=t.replaceCmd(this._drawCmd,e):this._drawCmd&&t.patchFrameAnimationCmd(this._drawCmd,this._drawCmd)}get source(){return this._source}set source(e){null==e&&(e=""),this._source=e,this.load()}get images(){return this._images}set images(e){this._images=e,this.load()}load(){this._atlas&&(this.owner._getBit(we.EDITING_NODE)&&this._atlas.off("reload",this,this.onAtlasReload),this._atlas=null),this._source?this.loadAtlas(this._source):this._images&&this._images.length>0?this.loadImages(this._images):this.onLoaded(null,++this._loadId)}loadImages(e){let t=++this._loadId,r=e.map(e=>Te.getRes(e));return-1===r.indexOf(null)?(this.frames=r,this.owner.event(c.LOADED)):l.loader.load(e).then(e=>{t!=this._loadId||this.destroyed||(this.frames=e,this.owner.event(c.LOADED))}),this}loadAtlas(e){let t=++this._loadId,r=pl.isDeserializing?null:Te.getRes(e,Te.ATLAS);return r?this.onLoaded(r,t):l.loader.load(e,Te.ATLAS).then(e=>this.onLoaded(e,t)),this}setAtlas(e){this.onLoaded(e,++this._loadId)}onLoaded(e,t){var r,s,i;if(t==this._loadId&&!this.destroyed){if(this._atlas=e,e){this.owner._getBit(we.EDITING_NODE)&&this._atlas.on("reload",this,this.onAtlasReload);let t=e.animation;t&&(this.interval=t.interval,this.repeatDelay=null!==(r=t.repeatDelay)&&void 0!==r?r:0,this.frameDelaysLoop=null!==(s=t.frameDelaysLoop)&&void 0!==s&&s,this.wrapMode=null!==(i=t.wrapMode)&&void 0!==i?i:0,this._delays.length=0,t.frameDelays&&this._delays.push(...t.frameDelays)),this.frames=e.frames}else this.frames=null;this.owner.event(c.LOADED)}}onAtlasReload(){this.onLoaded(this._atlas,this._loadId)}}class Sl extends po{constructor(){super(),this._comp=this.addComponent(xl),this._comp.hideFlags|=Re.HideAndDontSave,this._comp.autoPlay=!1}get loop(){return this._comp.loop}set loop(e){this._comp.loop=e}get wrapMode(){return this._comp.wrapMode}set wrapMode(e){this._comp.wrapMode=e}get interval(){return this._comp.interval}set interval(e){this._comp.interval=e}get rangeStart(){return this._comp.rangeStart}set rangeStart(e){this._comp.rangeStart=e}get rangeEnd(){return this._comp.rangeEnd}set rangeEnd(e){this._comp.rangeEnd=e}get index(){return this._comp.frame}set index(e){this._comp.frame=e}get count(){return this._comp.count}get source(){return this._comp.source}set source(e){this._comp.source=e}get images(){return this._comp.images}set images(e){this._comp.images=e}get isPlaying(){return this._comp.isPlaying}set autoPlay(e){this._comp.autoPlay=e}get autoPlay(){return this._comp.autoPlay}play(e,t,r=""){r&&this._setFramesFromCache(r,!0),null!=e&&(this._comp.frame="string"==typeof e?this.getFrameByLabel(e):e),null!=t&&(this._comp.loop=t),this._comp.play()}clear(){return this._comp.stop(),this._comp.frames=null,this._labels=null,this}stop(){this._comp.stop()}gotoAndStop(e){this.index="string"==typeof e?this.getFrameByLabel(e):e,this.stop()}addLabel(e,t){this._labels||(this._labels=[],this._comp._labels=this._labels),this._labels[t]=e}removeLabel(e){if(!e)return this._labels=null,void(this._comp._labels=null);if(this._labels)for(let t=0,r=this._labels.length;t<r;t++)this._labels[t]==e&&delete this._labels[t]}loadImages(e){return this._comp.images=e,this}loadAtlas(e){return this._comp.source=e,this}getFrameByLabel(e){if(!this._labels)return 0;let t=this._labels.indexOf(e);return-1!=t?t:0}static createFrames(e,t){Sl.framesMap[t]=e,l.loader.load(e)}static clearCache(e){delete Sl.framesMap[e]}_setFramesFromCache(e,t=!1){let r=Sl.framesMap[e];return r?(this.images=r,!0):(t&&console.log("ani not found:",e),!1)}}Sl.framesMap={};class El extends G{static loadFont(e,t){l.loader.load(e,Te.FONT).then(e=>{t&&t.runWith(e)})}constructor(){super(!1),this.dict={},this.fontSize=12,this.autoScaleSize=!1,this.tint=!0,this.maxWidth=0,this.lineHeight=12,this.letterSpacing=0}parseFont(e,t){var r;if(null==e||null==t)return;this.texture=t,t._addReference();let s=e.getNode("info");this.fontSize=s.getAttrInt("size",12),this.autoScaleSize=s.getAttrBool("autoScaleSize"),this.lineHeight=s.getAttrInt("lineHeight",this.fontSize),0==this.lineHeight&&(this.lineHeight=this.fontSize);let i=s.getAttrString("padding","").split(",");this.padding=[parseInt(i[0]),parseInt(i[1]),parseInt(i[2]),parseInt(i[3])];let a=(null===(r=e.getNode("chars"))||void 0===r?void 0:r.elements("char"))||[],n=0,o=this.dict;for(let e=0,r=a.length;e<r;e++){let r=a[e],s=r.getAttrInt("id"),i=r.getAttrInt("xoffset")/1,l=r.getAttrInt("yoffset")/1,h=r.getAttrInt("xadvance")/1,u=r.getAttrInt("x"),d=r.getAttrInt("y"),c=r.getAttrInt("width"),_=r.getAttrInt("height"),p=ie.create(t,u,d,c,_,i,l);0==h&&(h=c),h+=this.letterSpacing,n=Math.max(n,h),o[s]={x:0,y:0,width:c,height:_,advance:h,texture:p}}this.maxWidth=n>0?n:this.fontSize,o[32]||(o[32]={x:0,y:0,advance:Math.floor(.5*this.fontSize)+this.letterSpacing})}_disposeResource(){var e;if(this.texture){for(let t in this.dict)null===(e=this.dict[t].texture)||void 0===e||e.destroy();this.texture._removeReference(),this.dict=null,this.texture=null,this.padding=null}}getTextWidth(e,t){let r=0;for(let s=0,i=e.length;s<i;s++){let i=this.dict[e.charCodeAt(s)];if(i){let e=this.autoScaleSize?t/this.fontSize:1;r+=Math.round(i.advance*e)}}return r}getMaxWidth(e){return null!=e&&this.autoScaleSize?Math.round(this.maxWidth*(e/this.fontSize)):this.maxWidth}getMaxHeight(e){return null!=e&&this.autoScaleSize?Math.round(this.lineHeight*(e/this.fontSize)):this.lineHeight}}class vl{constructor(){this.font="",this.fontSize=12,this.color="#000000",this.bold=!1,this.italic=!1,this.underline=!1,this.strikethrough=!1,this.align="left",this.valign="top",this.alignItems="middle",this.leading=2,this.letterSpacing=0,this.stroke=0,this.strokeColor="#000000",this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0,this.shadowColor="#000000"}}e.HtmlElementType=void 0,(yl=e.HtmlElementType||(e.HtmlElementType={}))[yl.Text=0]="Text",yl[yl.Link=1]="Link",yl[yl.Image=2]="Image",yl[yl.Input=3]="Input",yl[yl.Select=4]="Select",yl[yl.Object=5]="Object",yl[yl.LinkEnd=6]="LinkEnd";class Dl{constructor(){this.style=new vl}getAttr(e){return null==this._attrs?null:this._attrs[e]}setAttr(e,t){null==this._attrs&&(this._attrs={}),this._attrs[e]=t}getAttrString(e,t){return ue.getString(this._attrs,e,t)}getAttrInt(e,t){return ue.getInt(this._attrs,e,t)}getAttrFloat(e,t){return ue.getFloat(this._attrs,e,t)}getAttrBool(e,t){return ue.getBool(this._attrs,e,t)}fetchAttributes(){this._attrs=Object.assign({},ce.attributes)}reset(){this.name=null,this.text=null,this.obj&&(this.obj.release(),h.recoverByClass(this.obj),this.obj=null),this._attrs=null}static getFromPool(t){let r;return r=this.pool.length>0?this.pool.pop():new Dl,r.type=t,r.type==e.HtmlElementType.Text||r._attrs||(r._attrs={}),r}static returnToPool(e){if(Array.isArray(e)){for(let t of e)t.reset();this.pool.push(...e),e.length=0}else e.reset(),this.pool.push(e)}}Dl.pool=[];class wl{constructor(){this._v=0,this.obj=new po}get element(){return this._element}get width(){return this.obj.width}get height(){return this.obj.height}create(e,t){this._owner=e,this._element=t,this._owner.objContainer.addChild(this.obj);let r=this._element.getAttrString("src");r&&this.loadTexture(r)}loadTexture(e){let t=this._element.getAttrInt("width",-1),r=this._element.getAttrInt("height",-1);-1!=t&&(this.obj.width=t),-1!=r&&(this.obj.height=r),this._w=t,this._h=r;let s=Te.getRes(e);if(s)this.onLoaded(s,++this._v);else{let t=++this._v;l.loader.load(e,{silent:!0}).then(e=>this.onLoaded(e,t,!0))}}onLoaded(t,r,s){if(!this._owner||this.obj.destroyed)return;if(r!=this._v)return;let i=this.obj,a=this._ani;t instanceof ie?(i.texture=t,a&&a.setAtlas(null),-1==this._w&&(i.width=t.sourceWidth),-1==this._h&&(i.height=t.sourceHeight)):t instanceof oe?(i.texture=null,a||(a=this._ani=i.addComponent(xl),a.stretchMode=e.AnimationStretchMode.Fill,a.autoPlay=!0,a.loop=!0),a.setAtlas(t),-1==this._w&&(i.width=a.width),-1==this._h&&(i.height=a.height)):(i.texture=null,a&&a.setAtlas(null),-1==this._w&&(i.width=0),-1==this._h&&(i.height=0)),s&&this._owner.refreshLayout()}pos(e,t){this.obj.pos(e,t)}release(){this.obj.removeSelf(),this.obj.offAll(),this.obj.texture=null,this._ani&&this._ani.setAtlas(null),this._owner=null,this._element=null,this._v++}destroy(){this.obj.destroy()}}class Rl{constructor(){this._shape=new po,this._shape.hitArea=this,this._shape.on(c.CLICK,()=>{this._owner.bubbleEvent(c.LINK,this._element.getAttrString("href"))}),this._rects=[],this._rectCnt=0}get element(){return this._element}get width(){return 0}get height(){return 0}create(e,t){this._owner=e,this._element=t,this._owner.objContainer.addChild(this._shape)}resetArea(){this._rectCnt=0}addRect(e,t,r,s){let i=this._rects[this._rectCnt];i||(i=this._rects[this._rectCnt]=new te),this._rectCnt++,i.setTo(e,t,r,s)}contains(e,t){for(let r=0;r<this._rectCnt;r++)if(this._rects[r].contains(e,t))return!0;return!1}pos(e,t){}release(){this._shape.removeSelf(),this._owner=null,this._element=null}destroy(){this._shape.destroy()}}class Cl{constructor(){this.linkUnderline=Cl.defaultLinkUnderline,this.linkColor=Cl.defaultLinkColor}}Cl.defaultLinkUnderline=!0,Cl.defaultLinkColor=null,Ee.regClass("HtmlParseOptions",Cl);const Ml=new Array,bl=new Array;class Al{constructor(){this._styleStack=new Array,this._style=new vl,this._options=new Cl}parse(t,r,s,i){null==i&&(i=this._options),this._elements=s,this._styleStackTop=0,Object.assign(this._style,r),this._style.colorChanged=!1;let a,n=0,o=i.ignoreWhiteSpace,l=!1;for(ce.begin(t,!0);ce.nextTag();)switch(0==n&&(a=ce.getText(o),a.length>0&&(l&&"\n"==a[0]&&(a=a.substring(1)),this.appendText(a))),l=!1,ce.tagName){case"b":ce.tagType==e.XMLTagType.Start?(this.pushStyle(),this._style.bold=!0):this.popStyle();break;case"i":ce.tagType==e.XMLTagType.Start?(this.pushStyle(),this._style.italic=!0):this.popStyle();break;case"u":ce.tagType==e.XMLTagType.Start?(this.pushStyle(),this._style.underline=!0):this.popStyle();break;case"strike":ce.tagType==e.XMLTagType.Start?(this.pushStyle(),this._style.strikethrough=!0):this.popStyle();break;case"font":if(ce.tagType==e.XMLTagType.Start){this.pushStyle(),this._style.fontSize=ue.getInt(ce.attributes,"size",this._style.fontSize);let e=ce.getAttribute("color");null!=e&&(this._style.color=e,this._style.colorChanged=!0);let t=ce.getAttribute("stroke");null!=t&&(this._style.stroke=parseInt(t)||0);let r=ce.getAttribute("strokecolor");null!=r&&(this._style.strokeColor=r)}else ce.tagType==e.XMLTagType.End&&this.popStyle();break;case"br":this.appendText("\n");break;case"img":if(ce.tagType==e.XMLTagType.Start||ce.tagType==e.XMLTagType.Void){let t=Dl.getFromPool(e.HtmlElementType.Image);t.fetchAttributes(),t.name=t.getAttrString("name"),t.style.align=this._style.align,t.style.underline=this._style.underline,t.style.underlineColor=this._style.underlineColor,this._elements.push(t)}break;case"a":if(ce.tagType==e.XMLTagType.Start){this.pushStyle(),this._style.underline=this._style.underline||i.linkUnderline,this._style.colorChanged||null==i.linkColor||(this._style.color=i.linkColor);let t=Dl.getFromPool(e.HtmlElementType.Link);t.fetchAttributes(),t.name=t.getAttrString("name"),t.style.align=this._style.align,this._elements.push(t)}else if(ce.tagType==e.XMLTagType.End){this.popStyle();let t=Dl.getFromPool(e.HtmlElementType.LinkEnd);this._elements.push(t)}break;case"input":{let t=Dl.getFromPool(e.HtmlElementType.Input);t.fetchAttributes(),t.name=t.getAttrString("name"),Object.assign(t.style,this._style),this._elements.push(t)}break;case"select":if(ce.tagType==e.XMLTagType.Start||ce.tagType==e.XMLTagType.Void){let t=Dl.getFromPool(e.HtmlElementType.Select);if(t.fetchAttributes(),ce.tagType==e.XMLTagType.Start){for(Ml.length=0,bl.length=0;ce.nextTag()&&"select"!=ce.tagName;)"option"==ce.tagName&&(ce.tagType==e.XMLTagType.Start||ce.tagType==e.XMLTagType.Void?bl.push(ue.getString(ce.attributes,"value","")):Ml.push(ce.getText()));t.setAttr("items",Ml.slice()),t.setAttr("values",bl.slice())}t.name=t.getAttrString("name"),Object.assign(t.style,this._style),this._elements.push(t)}break;case"p":ce.tagType==e.XMLTagType.Start?(this.pushStyle(),this._style.align=ce.getAttribute("align"),this.isNewLine()||this.appendText("\n")):ce.tagType==e.XMLTagType.End&&(this.appendText("\n"),l=!0,this.popStyle());break;case"ui":case"div":case"li":ce.tagType==e.XMLTagType.Start?this.isNewLine()||this.appendText("\n"):(this.appendText("\n"),l=!0);break;case"html":case"body":o=!0;break;case"head":case"style":case"script":case"form":ce.tagType==e.XMLTagType.Start?n++:ce.tagType==e.XMLTagType.End&&n--}0==n&&(a=ce.getText(o),a.length>0&&(l&&"\n"==a[0]&&(a=a.substring(1)),this.appendText(a))),this._elements=null}pushStyle(){let e;this._styleStack.length<=this._styleStackTop?(e=new vl,this._styleStack.push(e)):e=this._styleStack[this._styleStackTop],Object.assign(e,this._style),this._styleStackTop++}popStyle(){if(this._styleStackTop>0){let e=this._styleStack[this._styleStackTop-1];Object.assign(this._style,e),this._styleStackTop--}}isNewLine(){if(this._elements.length>0){let t=this._elements[this._elements.length-1];return!(!t||t.type!=e.HtmlElementType.Text)&&t.text.endsWith("\n")}return!0}appendText(t){let r;this._elements.length>0&&(r=this._elements[this._elements.length-1],r.type==e.HtmlElementType.Text&&function(e,t){for(let r in e)if(!r.startsWith("_")&&e[r]!=t[r])return!1;return!0}(r.style,this._style))?r.text+=t:(r=Dl.getFromPool(e.HtmlElementType.Text),r.text=t,Object.assign(r.style,this._style),this._elements.push(r))}}Al.defaultParser=new Al,Al.classMap={[e.HtmlElementType.Image]:wl,[e.HtmlElementType.Link]:Rl};class Il{constructor(){this._readPos=0,this.defaultImgWidth=0,this.defaultImgHeight=0,this._handlers={},this._handlers.url=this.onTag_URL,this._handlers.img=this.onTag_IMG,this._handlers.b=this.onTag_B,this._handlers.i=this.onTag_I,this._handlers.u=this.onTag_U,this._handlers.sup=this.onTag_Simple,this._handlers.sub=this.onTag_Simple,this._handlers.color=this.onTag_COLOR,this._handlers.font=this.onTag_FONT,this._handlers.size=this.onTag_SIZE,this._handlers.stroke=this.onTag_STROKE}onTag_URL(e,t,r){return t?"</a>":null!=r?'<a href="'+r+'">':'<a href="'+this.getTagText()+'">'}onTag_IMG(e,t,r){if(t)return null;var s=this.getTagText(!0);return s?this.defaultImgWidth?'<img src="'+s+'" width="'+this.defaultImgWidth+'" height="'+this.defaultImgHeight+'"/>':'<img src="'+s+'"/>':null}onTag_B(e,t,r){return t?"</b>":"<b>"}onTag_I(e,t,r){return t?"</i>":"<i>"}onTag_U(e,t,r){return t?"</u>":"<u>"}onTag_Simple(e,t,r){return t?"</"+e+">":"<"+e+">"}onTag_COLOR(e,t,r){return t?"</font>":(this.lastColor=r,'<font color="'+r+'">')}onTag_FONT(e,t,r){return t?"</font>":'<font face="'+r+'">'}onTag_SIZE(e,t,r){return t?"</font>":(this.lastSize=r,'<font size="'+r+'">')}onTag_STROKE(e,t,r){if(t)return"</font>";if(null!=r){let e=r.split(","),t=e[0],s=e.length>1?e[1]:null,i='<font stroke="'+t+'"';return s&&(i+=' strokeColor="'+s+'"'),i+=">",i}return'<font stroke="1">'}getTagText(e){for(var t,r=this._readPos,s="";-1!=(t=this._text.indexOf("[",r));){if(92!=this._text.charCodeAt(t-1)){s+=this._text.substring(r,t);break}s+=this._text.substring(r,t-1),s+="[",r=t+1}return-1==t?null:(e&&(this._readPos=t),s)}parse(e,t){this._text=e,this.lastColor=null,this.lastSize=null;for(var r,s,i,a,n,o,l,h=0,u="";-1!=(r=e.indexOf("[",h));)if(r>0&&92==e.charCodeAt(r-1))u+=e.substring(h,r-1),u+="[",h=r+1;else{if(u+=e.substring(h,r),h=r,-1==(r=e.indexOf("]",h)))break;i="/"==e.charAt(h+1),a=e.substring(i?h+2:h+1,r),this._readPos=r+1,n=null,o=null,-1!=(s=a.indexOf("="))&&(n=a.substring(s+1),a=a.substring(0,s)),a=a.toLowerCase(),null!=(l=this._handlers[a])?t||null!=(o=l.call(this,a,i,n))&&(u+=o):u+=e.substring(h,this._readPos),h=this._readPos}return h<e.length&&(u+=e.substring(h)),this._text=null,u}}Il.defaultParser=new Il;class Pl extends po{constructor(){super(),this._overflow=Pl.VISIBLE,this._singleCharRender=!1,this._prompt="",this._wordWrap=!1,this._asPassword=!1,this._textWidth=0,this._textHeight=0,this._html=!1,this._ubb=!1,this._maxWidth=0,this._hideText=!1,this._renderType|=Mr.TEXT,this._textStyle=new vl,this._textStyle.fontSize=t.defaultFontSize,this._text="",this.font="",this._elements=[],this._lines=[],this._padding=[0,0,0,0],this._fontSizeScale=1,this.graphics._useSpriteRect=!1}static registerBitmapFont(e,t){t._addReference(),Pl._bitmapFonts[e]=t}static unregisterBitmapFont(e,t=!0){let r=Pl._bitmapFonts[e];r&&(r._removeReference(),t&&r.destroy(),delete Pl._bitmapFonts[e])}destroy(e=!0){Nl(this._lines),Dl.returnToPool(this._elements),this._bgDrawCmd&&(this._bgDrawCmd.lock=!1),super.destroy(e)}measureWidth(){return this.typeset(),this._textWidth}measureHeight(){return this.typeset(),this._textHeight}_transChanged(t){super._transChanged(t),0!=(t&e.TransformKind.Size)&&(null!=this._scrollRect&&this._updateScrollRect(),this._updatingLayout?this.drawBg():this.markChanged())}_updateScrollRect(){let e=this._scrollRect||new te,t=this._isWidthSet?this._width:this._textWidth,r=this._isHeightSet?this._height:this._textHeight;e.setTo(0,0,Math.max(0,t-this._padding[1]),Math.max(0,r-this._padding[2])),this.scrollRect=e}get textWidth(){return this.typeset(),this._textWidth}get textHeight(){return this.typeset(),this._textHeight}get text(){return this._text}set text(e){null==e?e="":"string"!=typeof e&&(e=""+e),!this.ignoreLang&&Pl.langPacks&&(e=Pl.langPacks[e]||e),this._text!=e&&(this._text=e,this.markChanged(),this.event(c.CHANGE))}changeText(e){this.text=e}get font(){return this._textStyle.font}set font(e){if(this._textStyle.font=e,e||(e=t.defaultFont)||(e="Arial"),this._realFont=e,this._bitmapFont=Pl._bitmapFonts[e],this._bitmapFont)this._text&&this.markChanged();else if(e&&(Q.getFileExtension(e)||e.startsWith("res://"))){let t=l.loader.getRes(e);if(!t||t.obsolute){this._realFont="Arial";let t=this._textStyle.font;l.loader.load(e).then(e=>{this._textStyle.font==t&&e&&(e instanceof El?this._bitmapFont=e:this._realFont=e.family,this._text&&this.markChanged())})}else t instanceof El?this._bitmapFont=t:this._realFont=t.family,this._text&&this.markChanged()}else this._realFont=Y.onIPhone&&t.fontFamilyMap[e]||e,this._text&&this.markChanged()}get realFont(){return this._realFont}get fontSize(){return this._textStyle.fontSize}set fontSize(e){this._textStyle.fontSize!=e&&(this._textStyle.fontSize=e,this.markChanged())}get color(){return this._textStyle.color}set color(e){this._textStyle.color!=e&&(this._textStyle.color=e,this._isChanged||this._html||this._ubb?this.markChanged():this._graphics.replaceTextColor(this._textStyle.color))}get bold(){return this._textStyle.bold}set bold(e){this._textStyle.bold!=e&&(this._textStyle.bold=e,this.markChanged())}get italic(){return this._textStyle.italic}set italic(e){this._textStyle.italic!=e&&(this._textStyle.italic=e,this.markChanged())}get align(){return this._textStyle.align}set align(e){this._textStyle.align!=e&&(this._textStyle.align=e,this.markChanged())}get valign(){return this._textStyle.valign}set valign(e){this._textStyle.valign!=e&&(this._textStyle.valign=e,this.markChanged())}get alignItems(){return this._textStyle.alignItems}set alignItems(e){this._textStyle.alignItems!=e&&(this._textStyle.alignItems=e,this.markChanged())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!=e&&(this._wordWrap=e,this.markChanged())}get leading(){return this._textStyle.leading}set leading(e){this._textStyle.leading!=e&&(this._textStyle.leading=e,this.markChanged())}get letterSpacing(){return this._textStyle.letterSpacing}set letterSpacing(e){this._textStyle.letterSpacing!=e&&(this._textStyle.letterSpacing=e,this.markChanged())}get shadowOffsetX(){return this._textStyle.shadowOffsetX}set shadowOffsetX(e){this._textStyle.shadowOffsetX!==e&&(this._textStyle.shadowOffsetX=e,this.markChanged())}get shadowOffsetY(){return this._textStyle.shadowOffsetY}set shadowOffsetY(e){this._textStyle.shadowOffsetY!==e&&(this._textStyle.shadowOffsetY=e,this.markChanged())}get shadowBlur(){return this._textStyle.shadowBlur}set shadowBlur(e){this._textStyle.shadowBlur!==e&&(this._textStyle.shadowBlur=e,this.markChanged())}get shadowColor(){return this._textStyle.shadowColor}set shadowColor(e){this._textStyle.shadowColor!=e&&(this._textStyle.shadowColor=e,this.markChanged())}get padding(){return this._padding}set padding(e){if("string"==typeof e){let t=e.split(",");this._padding.length=0;for(let e=0;e<4;e++){let r=parseFloat(t[e]);isNaN(r)&&(r=0),this._padding.push(r)}}else this._padding=e;this.markChanged()}get bgColor(){return this._bgColor}set bgColor(e){this._bgColor=e,this.drawBg()}get borderColor(){return this._borderColor}set borderColor(e){this._borderColor=e,this.drawBg()}get stroke(){return this._textStyle.stroke}set stroke(e){this._textStyle.stroke!=e&&(this._textStyle.stroke=e,this.markChanged())}get strokeColor(){return this._textStyle.strokeColor}set strokeColor(e){this._textStyle.strokeColor!=e&&(this._textStyle.strokeColor=e,this.markChanged())}get overflow(){return this._overflow}set overflow(e){this._overflow!=e&&(this._overflow=e,e==Pl.HIDDEN||e==Pl.SCROLL?this._updateScrollRect():this.scrollRect=null,this.markChanged())}get underline(){return this._textStyle.underline}set underline(e){this._textStyle.underline!=e&&(this._textStyle.underline=e,this.markChanged())}get underlineColor(){return this._textStyle.underlineColor}set underlineColor(e){this._textStyle.underlineColor!=e&&(this._textStyle.underlineColor=e,this.markChanged())}get strikethrough(){return this._textStyle.strikethrough}set strikethrough(e){this._textStyle.strikethrough!=e&&(this._textStyle.strikethrough=e,this.markChanged())}get strikethroughColor(){return this._textStyle.strikethroughColor}set strikethroughColor(e){this._textStyle.strikethroughColor!=e&&(this._textStyle.strikethroughColor=e,this.markChanged())}get singleCharRender(){return this._singleCharRender}set singleCharRender(e){this._singleCharRender!==e&&(this._singleCharRender=e,this.markChanged())}get html(){return this._html}set html(e){this._html!=e&&(this._html=e,this.markChanged())}get ubb(){return this._ubb}set ubb(e){this._ubb!=e&&(this._ubb=e,this.markChanged())}get maxWidth(){return this._maxWidth}set maxWidth(e){this._maxWidth!=e&&(this._maxWidth=e,this.markChanged())}get htmlParseOptions(){return this._htmlParseOptions}set htmlParseOptions(e){this._htmlParseOptions=e}get templateVars(){return this._templateVars}set templateVars(e){(this._templateVars||e)&&(this._templateVars=!0===e?{}:!1===e?null:e,this.markChanged())}setVar(e,t){return this._templateVars||(this._templateVars={}),this._templateVars[e]=t,this.markChanged(),this}get scrollX(){return this._scrollPos?this._scrollPos.x:0}set scrollX(e){if(this.typeset(),!this._scrollPos)return;let t=this.maxScrollX;e=(e=e<0?0:e)>t?t:e,this._scrollPos.x=e,this.renderText()}get scrollY(){return this._scrollPos?this._scrollPos.y:0}set scrollY(e){if(this.typeset(),!this._scrollPos)return;let t=this.maxScrollY;e=(e=e<0?0:e)>t?t:e,this._scrollPos.y=e,this.renderText()}get maxScrollX(){let e=this.textWidth-this._width;return e<0?0:e}get maxScrollY(){let e=this.textHeight-this._height;return e<0?0:e}get lines(){return this.typeset(),this._lines}markChanged(){this._isChanged||(this._isChanged=!0,l.systemTimer.callLater(this,this._typeset))}typeset(e){(this._isChanged||e)&&l.systemTimer.runCallLater(this,this._typeset,!0)}refreshLayout(){l.systemTimer.callLater(this,this.doLayout)}get objContainer(){return this._objContainer||(this._objContainer=new po,this._objContainer.hideFlags|=Re.HideAndDontSave,this.addChild(this._objContainer)),this._objContainer}hideText(e){this._hideText=e,e?this.graphics.clear(!0,this._bgDrawCmd):(this.markChanged(),this.typeset())}_typeset(){if(this._isChanged=!1,this._hideText||this._destroyed)return;Dl.returnToPool(this._elements),this._objContainer&&this._objContainer.removeChildren();let t,r=this._text;if(this._onTranslate&&(r=this._onTranslate(r,this._templateVars)),!r&&this._prompt&&(r=this._prompt,this._onTranslate&&(r=this._onTranslate(r,null,1)),t=!0),!r)return this.graphics.clear(!0,this._bgDrawCmd),this._textWidth=this._textHeight=0,this._scrollPos=null,void(this._onPostLayout&&(this._updatingLayout=!0,this._onPostLayout(),this._updatingLayout=!1));let s,i=this._html;if(r=r.replace(Gl,"\n"),this._parseEscapeChars&&(r=r.replace(Vl,Xl)),!t&&this._templateVars&&(r=Q.parseTemplate(r,this._templateVars)),this._ubb&&(r=Il.defaultParser.parse(r),i=!0),!t&&this._asPassword&&(r=Pl._passwordChar.repeat(r.length)),t&&(s=this._textStyle.color,this._textStyle.color=this._promptColor),i)Al.defaultParser.parse(r,this._textStyle,this._elements,this._htmlParseOptions);else{let t=Dl.getFromPool(e.HtmlElementType.Text);Object.assign(t.style,this._textStyle),t.text=r,this._elements.push(t)}t&&(this._textStyle.color=s),this.doLayout()}doLayout(){if(this._destroyed)return;this._updatingLayout=!0,this._fontSizeScale=1;let t,r=this._wordWrap||this._overflow==Pl.ELLIPSIS,s=this._wordWrap,i=this._padding,a=this._textStyle.letterSpacing;if(t=this._isWidthSet?this._width-i[3]-i[1]:Number.MAX_VALUE,this._maxWidth>0){let e=this._maxWidth-i[3]-i[1];(!r||e<t)&&(t=e),r=!0}let n,o,l,u,c,_,p,g,m=this._isHeightSet?this._height-i[0]-i[2]:Number.MAX_VALUE,f="middle"==this._textStyle.alignItems?1:"bottom"==this._textStyle.alignItems?2:0,T=this._bitmapFont,y=va.runner._textRender,x=e=>T?T.getTextWidth(e,p)+a*e.length:Y.context.measureText(e).width+a*e.length,S=(e,t,r)=>{if(T)return T.getTextWidth(e,r)+a*e.length;{let r=Y.context.font;Y.context.font=t;let s=Y.context.measureText(e).width+a*e.length;return Y.context.font=r,s}},E=(e,t)=>{p=Math.floor(t.fontSize*this._fontSizeScale),0==p&&(p=1),T?(c=T.getMaxWidth(p),_=T.getMaxHeight(p)):(Y.context.font=g=(t.bold?"bold ":"")+p+"px "+this._realFont,c=p,_=y.getFontHeight(this._realFont,p,t.bold));let s=e.split("\n");if(r)for(let e=0,r=s.length;e<r;e++){let i=s[e];i.length>0&&C(i,t),e!=r-1&&R()}else for(let e=0,r=s.length;e<r;e++){let i=s[e];i.length>0&&v(i,t,null),e!=r-1&&R()}},v=(e,t,r)=>{let s=Bl.length>0?Bl.pop():{};s.x=n,s.y=o,"string"==typeof e?(r||(r=x(e)),s.text=e,s.ctxFont=g,s.fontSize=p,s.width=r,s.height=_):(s.obj=e,s.width=e.width,s.height=e.height,e.width>0&&(s.x++,s.width+=2)),s.style=t,s.linkEnd=!1,s.next=null,s.prev=u,n+=Math.round(s.width),u?u.next=s:l.cmd=s,u=s},D=e=>{for(;e.linkEnd&&e.next;)e=e.next;if(e)for(e.prev.next=null;e;){let t=e.next;e.x=n,e.y=o,e.next=null,e.prev=u,n+=Math.round(e.width),u?u.next=e:l.cmd=e,u=e,e=t}},w=(e,t)=>{if(ql(e.text.charCodeAt(t))&&t--,0==t)return!1;let r=e.text.substring(t);e.text=e.text.substring(0,t),e.width=S(e.text,e.ctxFont,e.fontSize);let s=Bl.length>0?Bl.pop():{};return s.text=r,s.style=e.style,s.ctxFont=e.ctxFont,s.fontSize=e.fontSize,s.width=S(r,e.ctxFont,e.fontSize),s.height=e.height,s.next=e.next,s.prev=e,e.next=s,!0},R=e=>{if(n=0,l){let e=0,t=0,r=l.cmd;for(;r;)r.height>e&&(e=r.height),t+=r.width,r=r.next;for(r=l.cmd;r;)r.y=1==f?Math.floor(.5*(e-r.height)):2==f?Math.floor(e-r.height):0,r=r.next;0==e&&(e=_),e++,l.height=e,l.width=Math.round(t),o+=l.height+Math.floor(this._textStyle.leading*this._fontSizeScale)}return e?null:(l=Ll.length>0?Ll.pop():{},l.x=0,l.y=o,this._lines.push(l),u=null,l)},C=(e,r)=>{let i=Math.max(0,t-n),a=x(e);if(a<=i)return void v(e,r,a);let o,l,h=0,d=0,_=0,p=Ol.test(e);T||p||(h=Math.floor(i/c),0!=h&&(d=x(e.substring(0,h))));let g=e.length;for(let c=h;c<g;c++){let m=e.charAt(c),f=m.charCodeAt(0);if(p&&Yl(f)&&c+1<g&&(m+=e.charAt(c+1)),a=x(m),d+=a,d<=i||c===_&&0===n){m.length>1&&c++;continue}let T=e.substring(_,c);if(d-=a,s&&(f>=65&&f<=90||f>=97&&f<=122||f>=48&&f<=57||(o=kl.includes(f)))){let r=T.length>0?(l=Ul.exec(T))?l.index:null:0;if(r>0)r>T.length-Wl&&(c=_+r,T=e.substring(_,c),d=null,a=null);else if(null!=r&&null!=u){let e=u,r=T.length,s=!1;for(;e;){if(e.width>0){if(null!=e.obj)break;l=Ul.exec(e.text);let t=e.text.length;if(null==l){R(),o&&0==r?w(e,t-1)?D(e.next):e.x>0&&D(e):null!=e.next&&D(e.next),s=!0;break}if(l.index>0){l.index>t-(Wl-r)&&(R(),w(e,l.index),D(e.next),s=!0);break}if(r+=t,r>=Wl)break}e=e.prev}if(s&&(i=t-n,d+a<i)){d+=a;continue}}else if(o){let t=p&&c>=1&&ql(e.charCodeAt(c-1))?2:1;(c-t>_||n>0)&&(c-=t,T=e.substring(_,c),d=null,a=null)}}T.length>0&&v(T,r,d),R(),_=c,i=t,d=null,h>1?c+=h-1:null!=a?(d=a,m.length>1&&c++):p&&Yl(e.charCodeAt(c))&&c++,null==d&&c<g-1&&(d=x(e.substring(_,c+1)))}v(e.substring(_,g),r)},M=()=>{let e=0,t=0;for(let t of this._lines)t.width>e&&(e=t.width);e>0&&(e+=i[1]+i[3]),this._textWidth=e;let r=this._lines[this._lines.length-1];r&&(t=r.y+r.height),t>0&&(t+=i[0]+i[2]),this._textHeight=t},b=()=>{n=o=c=_=0,l=null,u=null,Nl(this._lines),R();let s=this._elements;for(let i=0,a=s.length;i<a;i++){let a=s[i];if(a.type==e.HtmlElementType.Text)E(a.text,a.style);else if(a.type==e.HtmlElementType.LinkEnd)u&&(u.linkEnd=!0);else{let e=a.obj;if(!e){let t=Al.classMap[a.type];t&&(e=h.createByClass(t),e.create(this,a),a.obj=e)}if(e){if(r){let r=t-n;e.width>0&&r<e.width+1&&n>0&&R()}v(e,a.style)}}}R(!0),M()};if(b(),this._overflow==Pl.SHRINK){if(this._lines.length>1&&this._textHeight>m){let e=0,r=this._textStyle.fontSize;this._fontSizeScale=Math.sqrt(m/this._textHeight);let s=Math.floor(this._fontSizeScale*this._textStyle.fontSize);for(;b(),this._textWidth>t||this._textHeight>m?r=s:e=s,r-e>1||r!=e&&s==r;)s=e+(r-e)/2,this._fontSizeScale=s/this._textStyle.fontSize}else if(this._textWidth>t&&(this._fontSizeScale=t/this._textWidth,b(),this._textWidth>t)){let e=Math.floor(this._textStyle.fontSize*this._fontSizeScale);e--,this._fontSizeScale=e/this._textStyle.fontSize,b()}}else if(this._overflow==Pl.ELLIPSIS&&(this._textWidth>t||this._textHeight>m||!this._wordWrap&&this._lines.length>1)){let e;!this._wordWrap&&this._lines.length>1?e=1:(e=this._lines.findIndex(e=>e.y+e.height>m),0===e&&(e=1));let r=!1;-1!=e&&this._lines.length>e&&(Nl(this._lines.splice(e,this._lines.length-e),!0),r=!0),l=this._lines[this._lines.length-1];let s,i,a=l.cmd,n=!1;for(;a;){if(s=a.next,a.obj||(i=a),n)Fl(a,!0),Bl.push(a);else if(!s&&r||a.x+a.width>t-10){if(a.obj)Fl(a,!0),a.text=Hl,i?(a.ctxFont=i.ctxFont,a.fontSize=i.fontSize,a.height=i.height,a.style=i.style):(a.ctxFont=g,a.fontSize=p,a.height=_,a.style=this._textStyle);else{let e=a.x+a.width-t,r=e<5?2:e<10?1:0,s=a===l.cmd?1:0,i=a.text.length;for(;i>s&&r>0;)ql(a.text.charCodeAt(i-1))&&i--,i--,r--;a.text=a.text.substring(0,i)+Hl}a.width=S(a.text,a.ctxFont,a.fontSize),a.next=null,n=!0,R(!0)}a=s}(n||r)&&M()}this._onPostLayout&&this._onPostLayout();let A="center"==this._textStyle.align?1:"right"==this._textStyle.align?2:0;if(0!=A&&this._isWidthSet){let e=this._width-i[3]-i[1];for(let t of this._lines){let r=0;1==A?r=Math.floor(.5*(e-t.width)):2==A&&(r=e-t.width),r>0&&(t.x=r)}}if(this._isHeightSet&&this._textHeight<this._height){let e=0;if("middle"===this._textStyle.valign?e=Math.floor(.5*(this._height-this._textHeight)):"bottom"===this._textStyle.valign&&(e=this._height-this._textHeight),e>0)for(let t of this._lines)t.y+=e}if(this._overflow==Pl.SCROLL&&(this._isWidthSet&&this._textWidth>this._width||this._isHeightSet&&this._textHeight>this._height))if(this._scrollPos){let e=this.maxScrollX,t=this.maxScrollY;this._scrollPos.x>e&&(this._scrollPos.x=e),this._scrollPos.y>t&&(this._scrollPos.y=t)}else this._scrollPos=new d(0,0);else this._scrollPos=null;if(this._objContainer)if(this._objContainer.size(this._width,this._height),this._scrollPos||this._overflow==Pl.HIDDEN&&this._objContainer.numChildren>0){let e=this._objContainer.scrollRect||new te,t=this._isWidthSet?this._width:this._textWidth,r=this._isHeightSet?this._height:this._textHeight;this._objContainer.scrollRect=e.setTo(0,0,Math.max(0,t-i[1]),Math.max(0,r-i[2]))}else this._objContainer.scrollRect=null;this._updatingLayout=!1,this.renderText()}renderText(){let t=this.graphics;t.clear(!0,this._bgDrawCmd),this._fontGlobalScale=ea.fontScale;let r,s,i=this._padding,a=i[3],n=i[0],o=this._bitmapFont,l=this._scrollPos,h=this._isWidthSet?this._width:this._textWidth,u=(this._isHeightSet?this._height:this._textHeight)-i[2],d=this._overflow==Pl.HIDDEN||this._overflow==Pl.SCROLL,c=this._textStyle.letterSpacing,_=0!==this._textStyle.shadowOffsetX||0!==this._textStyle.shadowOffsetY,p=Math.max(0,h-i[1]),g=0,m=0,f=this._lines,T=f.length;for(let i=0;i<T;i++){let h=f[i];g=a+h.x,m=n+h.y,l&&(g-=l.x,m-=l.y);let T=d&&(m+h.height<=n||m>=u),y=h.cmd;for(;y;){if(y.linkEnd&&r&&(r.addRect(s,m,g+y.x+y.width-s,h.height),r=null),y.obj)y.obj.pos(g+y.x,m+y.y),y.obj.element.type==e.HtmlElementType.Link&&(r=y.obj,r.resetArea(),s=g+y.x);else if(!T)if(o){let e=0,r=y.text,s=o.tint?y.style.color:"#FFFFFF",i=Math.floor((o.autoScaleSize?y.style.fontSize:o.fontSize)*this._fontSizeScale)/o.fontSize;for(let a=0,n=r.length;a<n;a++){let n=r.charCodeAt(a),l=o.dict[n];l&&(l.texture&&t.drawImage(l.texture,g+y.x+e+l.x*i,m+y.y+l.y*i,l.width*i,l.height*i,s),e+=Math.round(l.advance*i)+c)}}else{let e=wa.create(y.text,g+y.x,m+y.y,null,y.style.color,null,y.style.stroke,y.style.strokeColor);e.fontFamily=this._realFont,e.fontSize=y.fontSize,e.bold=y.style.bold,e.italic=y.style.italic,e.letterSpacing=c,_&&(e.shadowOffsetX=this._textStyle.shadowOffsetX,e.shadowOffsetY=this._textStyle.shadowOffsetY,e.shadowColor=this._textStyle.shadowColor,e.shadowBlur=this._textStyle.shadowBlur),e.singleCharRender=this._singleCharRender,e._preMeasuredWidth=y.width,t.addCmd(e)}if(!T&&y.width>0){if(y.style.underline){let e=Math.max(1,y.fontSize/16);t.drawLine(g+y.x,m+h.height-e,g+y.x+y.width,m+h.height-e,y.style.underlineColor||y.style.color,e)}if(y.style.strikethrough){let e=Math.max(1,y.fontSize/16),r=g+y.x,s=m+h.height/2-e|0,i=4;t.drawLine(r-i,s,r+y.width+i,s,y.style.strikethroughColor||y.style.color,e)}}y=y.next}r&&(r.addRect(s,m,p-s,h.height),s=a)}d&&this._updateScrollRect()}drawBg(){let e=this._bgDrawCmd;if(this._bgColor||this._borderColor){e||(e=new bs,e.x=e.y=0,e.width=e.height=1,e.percent=!0,e.lock=!0,this._bgDrawCmd=e),e.fillColor=this._bgColor,e.lineColor=this._borderColor,e.lineWidth=this._borderColor?1:0;let t=this.graphics.cmds,r=t.indexOf(e);0!==r?(-1!==r&&t.splice(r,1),t.unshift(e),this.graphics.cmds=t):this.graphics.repaint()}else e&&(this.graphics.removeCmd(e,!0),this._bgDrawCmd=null)}_setParent(e,t=-1){super._setParent(e,t),e&&null!=this._fontGlobalScale&&this._fontGlobalScale!==ea.fontScale&&this.repaint()}}Pl.VISIBLE="visible",Pl.SCROLL="scroll",Pl.HIDDEN="hidden",Pl.SHRINK="shrink",Pl.ELLIPSIS="ellipsis",Pl.RightToLeft=!1,Pl._passwordChar="●",Pl._bitmapFonts={};const Bl=[],Ll=[];function Nl(e,t){for(let r of e){let e=r.cmd;for(;e;)Fl(e,t),Bl.push(e),e=e.next;r.cmd=null}Ll.push(...e),e.length=0}function Fl(e,t){e.obj&&(t&&(e.obj.element.obj=null,e.obj.release(),h.recoverByClass(e.obj)),e.obj=null)}const Ol=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,Ul=/[a-zA-Z0-9\!-\+\/_]+$/,kl=Array.from(".,,。、!!;;”’))]】}》").map(e=>e.charCodeAt(0)),Gl=/\r\n/g,Vl=/\\(\w)/g,zl={"\\n":"\n","\\t":"\t"},Hl="…",Wl=20;function Xl(e){var t;return null!==(t=zl[e])&&void 0!==t?t:e}function Yl(e){return e>=55296&&e<=56319}function ql(e){return e>=56320&&e<=57343}class $l extends Pl{constructor(){super(),this.confirmType="done",this.maxChars=0,this._multiline=!1,this._editable=!0,this._width=100,this._height=20,this._type="text",this._promptColor="#a9a9a9",this.overflow=Pl.SCROLL,this.valign="middle",this.mouseEnabled=!0}get multiline(){return this._multiline}set multiline(e){this._multiline!=e&&(this._multiline=e,this.wordWrap=e,this.valign=e?"top":"middle")}get focus(){return W.textInput.target===this}set focus(e){e?W.textInput.begin(this):this===W.textInput.target&&W.textInput.end()}get text(){return W.textInput.target===this&&W.textInput.syncText(),super.text}set text(e){null==e?e="":"string"!=typeof e&&(e=""+e),W.textInput.target===this?(W.textInput.setText(e),this.event(c.CHANGE)):(this._multiline||(e=e.replace(/\r?\n/g,"")),super.text=e)}get editable(){return this._editable}set editable(e){this._editable=e}get prompt(){return this._prompt}set prompt(e){null==e&&(e=""),this._prompt!=e&&(this._prompt=e,this.markChanged())}get localizedPrompt(){var e;let t=(null===(e=Pl.langPacks)||void 0===e?void 0:e[this._prompt])||this._prompt;return this._onTranslate&&(t=this._onTranslate(t,null,1)),t}get promptColor(){return this._promptColor}set promptColor(e){this._promptColor!=e&&(this._promptColor=e,this.markChanged())}get type(){return this._type}set type(e){this._asPassword="password"===e,this._type=e,this.markChanged()}setSelection(e,t){W.textInput.setSelectionFor(this,e,t)}select(){this.setSelection(0,-1)}}$l.TYPE_TEXT="text",$l.TYPE_PASSWORD="password",$l.TYPE_EMAIL="email",$l.TYPE_URL="url",$l.TYPE_NUMBER="number",$l.TYPE_RANGE="range",$l.TYPE_DATE="date",$l.TYPE_MONTH="month",$l.TYPE_WEEK="week",$l.TYPE_TIME="time",$l.TYPE_DATE_TIME="datetime",$l.TYPE_DATE_TIME_LOCAL="datetime-local",$l.TYPE_SEARCH="search";class Kl extends Sn{constructor(){super(),this._loop=1}get source(){return this._source}set source(e){var t;this._source=e,e?(null===(t=this.owner)||void 0===t?void 0:t.activeInHierarchy)&&(this._autoPlay||this._channel)&&p.isPlaying&&this.play(this._loop):this.stop()}get isMusic(){return this._isMusic}set isMusic(e){this._isMusic=e}get loop(){return this._loop}set loop(e){this._loop=e}get autoPlay(){return this._autoPlay}set autoPlay(e){var t;this._autoPlay=e,(null===(t=this.owner)||void 0===t?void 0:t.activeInHierarchy)&&e&&!this._channel&&p.isPlaying&&this.play(this._loop)}play(e,t,r){this._source&&((null==e||isNaN(e))&&(e=this._loop),this.stop(),this._isMusic?this._channel=Vo.playMusic(this._source,e,t,r):this._channel=Vo.playSound(this._source,e,t,r))}stop(){this._channel&&this._channel.stop(),this._channel=null}_onEnable(){this._autoPlay&&!this._channel&&this.play(this._loop),super._onEnable()}_onDisable(){this.stop(),super._onDisable()}}class jl extends po{constructor(){super(),this._comp=this.addComponent(Kl),this._comp.hideFlags|=Re.HideAndDontSave,p.isPlaying&&(this.on(c.ADDED,()=>{this.target=this.parent}),this.on(c.REMOVED,()=>{this.target=null}))}get source(){return this._comp.source}set source(e){this._comp.source=e}get isMusic(){return this._comp.isMusic}set isMusic(e){this._comp.isMusic=e}get loop(){return this._comp.loop}set loop(e){this._comp.loop=e}get autoPlay(){return this._comp.autoPlay}set autoPlay(e){this._comp.autoPlay=e}play(e,t,r){this._comp.play(e,t,r)}stop(){this._comp.stop()}_setPlayAction(e,t,r,s=!0){this[r]&&e&&(s?e.on(t,this,this[r]):e.off(t,this,this[r]))}_setPlayActions(e,t,r,s=!0){if(!e)return;if(!t)return;let i=t.split(","),a=i.length;for(let t=0;t<a;t++)this._setPlayAction(e,i[t],r,s)}set playEvent(e){this._playEvents=e,e&&this._tar&&this._setPlayActions(this._tar,e,"play")}set target(e){this._tar&&(this._setPlayActions(this._tar,this._playEvents,"play",!1),this._setPlayActions(this._tar,this._stopEvents,"stop",!1)),this._tar=e,this._tar&&(this._setPlayActions(this._tar,this._playEvents,"play",!0),this._setPlayActions(this._tar,this._stopEvents,"stop",!0))}set stopEvent(e){this._stopEvents=e,e&&this._tar&&this._setPlayActions(this._tar,e,"stop")}}class Ql extends Sn{constructor(){super(),this.options={controls:!1,objectFit:"contain"},this.mode="decoder",this._autoPlay=!1,this._loop=!1,this._volume=1,this._muted=!1,this._playbackRate=1,this._allowBackground=!1,this._paused=!1,this.runInEditor=!0}get player(){return this._api}get source(){return this._source}set source(e){var t;this._source=e,e?(null===(t=this.owner)||void 0===t?void 0:t.activeInHierarchy)&&this._load():this._unload()}get autoPlay(){return this._autoPlay}set autoPlay(e){this._autoPlay=e,this._api&&p.isPlaying&&(e?this._api.play():this._api.pause())}get allowBackground(){return this._allowBackground}set allowBackground(e){this._allowBackground=e,this._api&&(this._api.allowBackground=e)}get currentTime(){var e;return null===(e=this._api)||void 0===e?void 0:e.currentTime}set currentTime(e){this._api&&(this._api.currentTime=e)}get readyState(){var e,t;return null!==(t=null===(e=this._vtex)||void 0===e?void 0:e.readyState)&&void 0!==t?t:0}get videoWidth(){var e;return null===(e=this._vtex)||void 0===e?void 0:e.videoWidth}get videoHeight(){var e;return null===(e=this._vtex)||void 0===e?void 0:e.videoHeight}get duration(){var e;return null===(e=this._api)||void 0===e?void 0:e.duration}get ended(){var e;return null===(e=this._api)||void 0===e?void 0:e.ended}get loop(){return this._loop}set loop(e){this._loop=e,this._api&&(this._api.loop=e)}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._api&&(this._api.playbackRate=e)}get volume(){return this._volume}set volume(e){this._volume=e,this._api&&(this._api.volume=e)}get muted(){return this._muted}set muted(e){this._muted=e,this._api&&(this._api.muted=e)}get paused(){return this._paused}get videoTexture(){return this._vtex}play(){this._api&&(this._paused=!1,this._api.play())}pause(){this._paused=!0,this._api&&this._api.pause()}_load(){let e,t;"player"===(p.isPlaying?this.mode:"decoder")?(e=this._player||W.media.createVideoPlayer(),e||(t=W.media.createVideoTexture())):(t=this._vtex||W.media.createVideoTexture(),t||(e=W.media.createVideoPlayer())),e?(this._player!==e&&(this._player=e,this._player.attachTo(this.owner),this._player.options=this.options),this._vtex&&(this._vtex.destroy(),this._vtex=null,this.owner.graphics.removeCmd(this._textureCmd,!0),this._textureCmd=null)):(this._vtex!==t&&(this._vtex=t,this._vtex.on(c.READY,this,this._vtReady),this._vtex.on("videoUpdate",this.owner,this.owner.reCache),this._textureCmd||(this._textureCmd=Is.create(new ie,0,0,1,1,null,null,null,null,null,!0),this._textureCmd.lock=!0,this.owner.graphics.addCmd(this._textureCmd))),this._player&&(this._player.destroy(),this._player=null)),this._api=e||t,this._api.loop=this._loop,this._api.volume=this._volume,this._api.muted=this._muted,this._api.playbackRate=this._playbackRate,this._api.allowBackground=this._allowBackground,this._autoPlay&&!this._paused&&p.isPlaying?this._api.play():this._api.pause(),this._api.load(this._source)}_vtReady(){var e;this._textureCmd.texture.setTo(this._vtex),null===(e=this.owner)||void 0===e||e.graphics.repaint()}_unload(){var e;this._vtex&&(this._vtex.off(c.READY,this,this._vtReady),this._vtex.off("videoUpdate",this.owner,this.owner.reCache),this._vtex.destroy(),this._vtex=null,this.owner.graphics.removeCmd(this._textureCmd,!0),this._textureCmd=null),null===(e=this._player)||void 0===e||e.destroy(),this._player=null,this._api=null}_onEnable(){!this._api&&this._source&&this._load(),super._onEnable()}_onDisable(){this._unload(),super._onDisable()}_onDestroy(){this._unload(),super._onDestroy()}}class Zl extends po{constructor(){super(),this._comp=this.addComponent(Ql),this._comp.hideFlags|=Re.HideAndDontSave}get options(){return this._comp.options}get mode(){return this._comp.mode}set mode(e){this._comp.mode=e}get player(){return this._comp.player}get source(){return this._comp.source}set source(e){this._comp.source=e}get autoPlay(){return this._comp.autoPlay}set autoPlay(e){this._comp.autoPlay=e}get allowBackground(){return this._comp.allowBackground}set allowBackground(e){this._comp.allowBackground=e}get currentTime(){return this._comp.currentTime}set currentTime(e){this._comp.currentTime=e}get readyState(){return this._comp.readyState}get videoWidth(){return this._comp.videoWidth}get videoHeight(){return this._comp.videoHeight}get duration(){return this._comp.duration}get ended(){return this._comp.ended}get loop(){return this._comp.loop}set loop(e){this._comp.loop=e}get playbackRate(){return this._comp.playbackRate}set playbackRate(e){this._comp.playbackRate=e}get volume(){return this._comp.volume}set volume(e){this._comp.volume=e}get muted(){return this._comp.muted}set muted(e){this._comp.muted=e}get paused(){return this._comp.paused}load(e){this._comp.source=e}play(){this._comp.play()}pause(){this._comp.pause()}reload(){this._comp.source=this._comp.source}canPlayType(e){return W.media.canPlayType(e)}get currentSrc(){return this._comp.source}get videoTexture(){return this._comp.videoTexture}set videoTexture(e){this.source=e?e.source:null}}var Jl,eh,th,rh,sh,ih;e.AnimatorUpdateMode=void 0,(Jl=e.AnimatorUpdateMode||(e.AnimatorUpdateMode={}))[Jl.Normal=0]="Normal",Jl[Jl.LowFrame=1]="LowFrame",Jl[Jl.UnScaleTime=2]="UnScaleTime";class ah extends Sn{constructor(){super(),this._speed=1,this._updateMode=e.AnimatorUpdateMode.Normal,this._lowUpdateDelty=20,this._isPlaying=!0,this._isPlayBack=!1,this._ownerMap=null}get speed(){return this._speed}set speed(e){this._speed=e}get isPlaying(){return this._isPlaying}_setClipDatasToNode(e,t,r){for(var s=e._realtimeDatas,i=e._clip._nodes,a=0,n=i.count;a<n;a++)if(null!=s[a]){var o=i.getNodeByIndex(a),l=this.getOwner(o);l&&this._applyAniData(l,t,r,s[a])}}_applyAniData(e,t,r,s){var i=e.pro;if(i&&i.ower){var a=i.isMat,n=a?i.ower:null;if(a)return void this._applyMatData(n,i,t,r,s);if(t&&"number"==typeof s)i.ower[i.key]=i.defVal+r*s,i.parentOwer&&null!=i.parentKey&&(i.parentOwer[i.parentKey]=i.ower);else if("number"==typeof s)i.ower[i.key]=r*s,i.parentOwer&&null!=i.parentKey&&(i.parentOwer[i.parentKey]=i.ower);else if("object"==typeof s)s.pos&&(i.ower.x=s.pos.x,i.ower.y=s.pos.y),null!=s.rotation&&(i.ower.rotation=s.rotation.z);else{if("string"==typeof s&&s.startsWith("tres://")){let e=s.replace("tres://",""),t=Te.getRes(e,Te.IMAGE);if(!t)return void l.loader.load(e,{type:Te.IMAGE}).then(e=>{this.destroyed||(i.ower[i.key]=e,i.parentOwer&&null!=i.parentKey&&(i.parentOwer[i.parentKey]=i.ower))});s=t}i.ower[i.key]=s,i.parentOwer&&null!=i.parentKey&&(i.parentOwer[i.parentKey]=i.ower)}}}_applyMatData(e,t,r,s,i){var a=t.key,n=t.matComp;if(n&&"number"==typeof i){var o=r?(t.defVal||0)+s*i:s*i;if("r"===n||"g"===n||"b"===n||"a"===n){var h=e.getColor(a);h&&(h[n]=o,e.setColor(a,h))}else{var u=e.getVector4(a);u&&(u[n]=o,e.setVector4(a,u))}}else if("number"==typeof i){var d=r?(t.defVal||0)+s*i:s*i;e.setFloat(a,d)}else if("boolean"==typeof i)e.setBool(a,i);else if("string"==typeof i)if(i.startsWith("tres://")){let t=i.replace("tres://",""),r=Te.getRes(t,Te.IMAGE);r?e.setTexture(a,r):l.loader.load(t,{type:Te.IMAGE}).then(t=>{this.destroyed||e.setTexture(a,t)})}else e.setTexture(a,i)}_updateDefVal(){this._ownerMap&&this._ownerMap.forEach(e=>{var t=e.pro;if(t&&t.ower)if(t.isMat){var r=t.ower;if(t.matComp){var s=r.getColor(t.key);if(s)t.defVal=s[t.matComp];else{var i=r.getVector4(t.key);i&&(t.defVal=i[t.matComp])}}else t.defVal=r.getFloat(t.key)}else t.parentOwer&&null!=t.parentKey?(t.ower=t.parentOwer[t.parentKey],t.defVal=t.ower?t.ower[t.key]:null):t.defVal=t.ower[t.key]})}getOwner(e){var t;if(this._ownerMap&&(t=this._ownerMap.get(e)))return t;for(var r=this.owner,s=0,i=e.ownerPathCount;s<i;s++){var a=e.getOwnerPathByIndex(s);if(""!=a&&!(r=r.getChild(a)))break}if(t={ower:r},r){var n=r,o=e.propertyCount;if(1==o){var l=e.getPropertyByIndex(0);t.pro={ower:r,key:l,defVal:r[l]}}else for(var h=void 0,u=void 0,d=0;d<o;d++){l=e.getPropertyByIndex(d);if(n instanceof Zn){var c=l,_=d+1<o?e.getPropertyByIndex(d+1):void 0,p=null;if(_){var g=n.getColor(c);if(g)p=g[_];else{var m=n.getVector4(c);m&&(p=m[_])}}else p=n.getFloat(c);t.pro={ower:n,key:c,defVal:p,parentOwer:h,parentKey:u,isMat:!0,matComp:_};break}if(d==o-1||null==n){t.pro={ower:n,key:l,defVal:n?n[l]:null,parentOwer:h,parentKey:u};break}if(h=n,u=l,"_gcmds"===l&&null==n[l]&&n.graphics&&(n=n.graphics,u=l="cmds"),null==n[l]&&r==n){n=null;var f=Ee.getClass(l);f&&(n=r.getComponent(f))}else n=n[l]}}return null==this._ownerMap&&(this._ownerMap=new Map),this._ownerMap.set(e,t),t}_updateClipDatas(e,t,r){var s=e._clip,i=s._duration,a=e.clipStart*i+r._normalizedPlayTime*r._duration,n=e._currentFrameIndices;let o=r._frontPlay;s._evaluateClipDatasRealTime(a,n,t,o,e._realtimeDatas)}_updatePlayerTime(e,t,r,s){t._playAllTime+=Math.abs(r);const i=e.clipEnd-e.clipStart;var a=e._clip._duration*i,n=t._elapsedTime,o=n+r;t._lastElapsedTime=n,t._elapsedTime=o;var l=o/a%1;const h=l<0?l+1:l;t._normalizedPlayTime=h,t._duration=a;let u=Math.floor(Math.abs(n)/a),d=Math.floor(Math.abs(o)/a);e.yoyo&&(this._isPlayBack=0!=Math.floor(d)%2,this._isPlayBack&&(t._normalizedPlayTime=1-t._normalizedPlayTime),u=Math.floor(u/2),d=Math.floor(d/2)),0<s&&s<=d&&(t._finish=!0,e.yoyo?t._normalizedPlayTime=0:t._normalizedPlayTime=1);const c=u!=d;return c&&(this._updateDefVal(),e._eventLoop()),e._eventStateUpdate(t._normalizedPlayTime),c}_updateStateFinish(e,t){t._finish&&e._eventExit()}_eventScript(e,t,r,s){let i=this.owner.components;if(s)for(let s=0,a=e.length;s<a;s++){let a=e[s];if(a.time>t&&a.time<=r)for(let e=0,t=i.length;e<t;e++){let t=i[e];if(t._isScript()){let e=t[a.eventName];e&&e.apply(t,a.params)}}else if(a.time>r)break}else for(let s=e.length-1;s>=0;s--){let a=e[s];if(a.time<t&&a.time>=r)for(let e=0,t=i.length;e<t;e++){let t=i[e];if(t._isScript()){let e=t[a.eventName];e&&e.apply(t,a.params)}}else if(a.time<r)break}}_updateEventScript(e,t){let r=e._clip,s=r._animationEvents;if(!s||0==s.length)return;let i=r._duration;var a=t.animatorState.clipStart*i+t._normalizedPlayTime*t._duration;let n=t._frontPlay;0>t._currentState.speed&&(n=!n),this._isPlayBack&&(n=!n);let o=t._parentPlayTime,l=t._parentPlayTime;if(null==l&&(l=n?i*t.animatorState.clipStart:i*t.animatorState.clipEnd),n){if(a<l){const e=t.animatorState.clipStart*i+t._duration;this._eventScript(s,l,e,!0),l=t.animatorState.clipStart*i}}else if(a>l){const e=t.animatorState.clipStart*i;this._eventScript(s,l,e,!1),l=t.animatorState.clipStart*i+t._duration}this._eventScript(s,l,a,n),o==t._parentPlayTime&&(t._parentPlayTime=a)}_applyUpdateMode(t){let r;switch(this._updateMode){case e.AnimatorUpdateMode.Normal:r=t;break;case e.AnimatorUpdateMode.LowFrame:r=Ua.loopCount%this._lowUpdateDelty==0?t*this._lowUpdateDelty:0;break;case e.AnimatorUpdateMode.UnScaleTime:r=0;break;default:r=t}return r}resetAdditiveBaseValues(){this._ownerMap&&this._ownerMap.clear()}}class nh{get duration(){return this._duration}get animatorState(){return this._currentState}constructor(){this._currentState=null,this._frontPlay=!0}_resetPlayState(e,t){this._finish=!1,this._startPlayTime=e,this._elapsedTime=e,this._lastElapsedTime=e,this._duration=t,this._lastIsFront=!0,this._parentPlayTime=null,this._playNum=0,this._playAllTime=0;var r=this._elapsedTime/t%1;this._normalizedPlayTime=r<0?r+1:r,this._frontPlay=!0}_cloneTo(e){e._finish=this._finish,e._startPlayTime=this._startPlayTime,e._elapsedTime=this._elapsedTime,e._lastElapsedTime=this._lastElapsedTime,e._duration=this._duration,e._playNum=this._playNum,e._parentPlayTime=this._parentPlayTime,e._normalizedPlayTime=this._normalizedPlayTime,e._lastIsFront=this._lastIsFront,e._frontPlay=this._frontPlay,e._playAllTime=this._playAllTime}}class oh{constructor(e){this._referenceCount=0,this._playStateInfo=new nh,this._crossPlayStateInfo=new nh,this._crossMark=0,this._srcCrossClipNodeIndices=[],this._destCrossClipNodeIndices=[],this._crossDuration=0,this._crossElapsedTime=0,this._crossNodes=[],this._crossDefaultValues=[],this._crossValues=[],this._crossFixedValues=[],this.playOnWake=!0,this.defaultWeight=1,this.blendingMode=oh.BLENDINGMODE_OVERRIDE,this.enable=!0,this._states=[],this._playType=-1,this.name=e}get states(){return this._states}set states(e){if(this._states!==e){for(let e=this.states.length-1;e>=0;e--)this.removeState(this.states[e]);for(let t=e.length-1;t>=0;t--)this.addState(e[t])}}get defaultStateName(){return this._defaultState?this._defaultState.name:null}set defaultStateName(e){if(this._defaultState=this.getStateByName(e),null==this._defaultState)if(0==this._states.length)this._defaultStateNameCatch=e;else for(var t=this._states.length-1;t>=0;t--)if(this._states[t].name==e){this._defaultState=this._states[t];break}}get defaultState(){return this._defaultState}set defaultState(e){this._defaultState=e}_removeClip(e,t,r){e.splice(t,1)}_getReferenceCount(){return this._referenceCount}_addReference(e){for(var t=0,r=this._states.length;t<r;t++)this._states[t]._addReference(e);this._referenceCount+=e}_removeReference(e=1){for(var t=0,r=this._states.length;t<r;t++)this._states[t]._removeReference(e);this._referenceCount-=e}_clearReference(){this._removeReference(-this._referenceCount)}getCurrentPlayState(){return this._playStateInfo}getStateByName(e){for(let t=this._states.length-1;t>=0;t--)if(this._states[t].name==e)return this._states[t];return null}addState(e){var t=e.name;if(this.getStateByName(t))throw new Error("AnimatorControllerLayer:this stat's name has exist.");this._states.push(e),t==this._defaultStateNameCatch&&(this._defaultState=e,this._defaultStateNameCatch=null)}removeState(e){for(var t=this._states,r=-1,s=0,i=t.length;s<i;s++)if(t[s]===e){r=s;break}-1!=r&&this._removeClip(t,r,e)}clone(){var e=new oh(this.name);return this.cloneTo(e),e}cloneTo(e){e.name=this.name}destroy(){this._crossNodes.length=this._crossDefaultValues.length=this._crossValues.length=this._crossFixedValues.length=0,this._removeReference();for(var e=0,t=this._states.length;e<t;e++)this._states[e].destroy();this._states.length=0}}oh.BLENDINGMODE_OVERRIDE=0,oh.BLENDINGMODE_ADDTIVE=1,e.AniParmType=void 0,(eh=e.AniParmType||(e.AniParmType={}))[eh.Float=0]="Float",eh[eh.Bool=1]="Bool",eh[eh.Trigger=2]="Trigger",e.AniStateConditionType=void 0,(th=e.AniStateConditionType||(e.AniStateConditionType={}))[th.Number=0]="Number",th[th.Bool=1]="Bool",th[th.Trigger=2]="Trigger",e.AniStateConditionNumberCompressType=void 0,(rh=e.AniStateConditionNumberCompressType||(e.AniStateConditionNumberCompressType={}))[rh.Less=0]="Less",rh[rh.Greater=1]="Greater";class lh{static parse(e){let t=e,r=t.controllerLayers;null==r&&(r=[]);let s=[];for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.states;a||(a=[],i.states=a),i.defaultStateName=null;let n=this.checkStates(a,s,t);n?i.defaultStateName=n.enterName:r.splice(e,1)}return{ret:t,clipsID:s}}static checkStates(e,t,r){let s=null,i=null;for(let a=e.length-1;a>=0;a--){let n=e[a];n.states?null==this.checkStates(n.states,t,r)?e.splice(a,1):(null==s&&(s=[]),s.push(n)):"-1"==n.id?i=n:"-2"==n.id||"-3"==n.id||(null==n.clip||null==n.clip._$uuid||""==n.clip._$uuid?e.splice(a,1):(0>t.indexOf(n.clip._$uuid)&&t.push(n.clip._$uuid),this.checkNext(n,e,r),null==s&&(s=[]),s.push(n)))}let a=null;if(s&&i){let e=this.checkDefault(i,s);null!=e&&(a={states:s,enterName:e})}return a}static checkNext(e,t,r){let s=e.soloTransitions;if(s)for(let e=s.length-1;e>=0;e--){let i=s[e],a=this.getStateByID(t,i.id);!a||null==a.clip&&"-3"!=a.id&&null==a.states?s.splice(e,1):(i.name=a.name,i.conditions=this.checkConditions(i.conditions,r))}}static checkConditions(t,r){if(!t||0==t.length||null==r.animatorParams||0==r.animatorParams.length)return[];let s=r.animatorParams;for(let r=t.length-1;r>=0;r--){let i=t[r],a=null;for(let e=s.length-1;e>=0;e--)if(s[e].id==i.id){a=s[e];break}if(null==a)t.splice(r,1);else if(i.name=a.name,a.type==e.AniParmType.Float){let e=Number(i.checkValue);isNaN(e)&&(i.checkValue=0),e=Number(i.type),isNaN(e)&&(i.type=0)}}return t}static checkDefault(e,t){let r=e.soloTransitions,s=null;r&&0<r.length&&(s=r[0].id);let i=null;if(null!=s&&(i=this.getStateByID(t,s)),null!=i&&(null!=i.clip||null!=i.states))return i.name;for(let e=t.length-1;e>=0;e--)if(t[e].clip)return t[e].name;return null}static getStateByID(e,t){if(e)for(let r=e.length-1;r>=0;r--)if(e[r].id==t)return e[r];return null}}e.CurveType=void 0,(sh=e.CurveType||(e.CurveType={}))[sh.CRSpline=0]="CRSpline",sh[sh.Bezier=1]="Bezier",sh[sh.CubicBezier=2]="CubicBezier",sh[sh.Straight=3]="Straight",e.RotationType=void 0,(ih=e.RotationType||(e.RotationType={}))[ih.NoRotation=0]="NoRotation",ih[ih.RotateAlongPathCurve=1]="RotateAlongPathCurve",ih[ih.RotateAlongMotionPath=2]="RotateAlongMotionPath";class hh{constructor(){this.pos=new a,this.c1=new a,this.c2=new a,this.curve=0,this.smooth=!0}static create(e,t,r,s){let i=uh.take();return i.pos.set(e,t,r),i.curve=s||0,i}recover(){uh.recover(this)}clone(){let e=uh.take();return this.pos.cloneTo(e.pos),this.c1.cloneTo(e.c1),this.c2.cloneTo(e.c2),e.curve=this.curve,e.smooth=this.smooth,e}_reset(){this.pos.set(0,0,0),this.c1.set(0,0,0),this.c2.set(0,0,0),this.curve=0,this.smooth=!0}}const uh=h.createPool(hh,null,e=>e._reset());class dh{constructor(){this._segments=[],this._points=[],this._curPt=new a,this._parPosCatch=new a}get length(){return this._fullLength}create(...t){this._segments.length=0;let r=this._points;gh.recover(this._points),this._fullLength=0,this._cacheT=null,this.rotationType=null,this._parPos=null;let s=t.length;if(0==s)return;let i=[],n=t[0];this.rotationType=n.rotationType,n.curve==e.CurveType.CRSpline&&i.push(n.pos.cloneTo(gh.take()));for(let o=1;o<s;o++){let s=t[o];if(n.curve!=e.CurveType.CRSpline){let t={};t.type=n.curve,t.smooth=n.smooth,t.ptStart=r.length,n.curve==e.CurveType.Straight?(t.ptCount=2,r.push(n.pos.cloneTo(gh.take())),r.push(s.pos.cloneTo(gh.take())),t.length=a.distance(n.pos,s.pos)):n.curve==e.CurveType.Bezier?(t.ptCount=3,r.push(n.pos.cloneTo(gh.take())),r.push(s.pos.cloneTo(gh.take())),r.push(n.c1.cloneTo(gh.take())),t.length=this.estimateBezierLength(t.ptStart,t.ptCount)):n.curve==e.CurveType.CubicBezier&&(t.ptCount=4,r.push(n.pos.cloneTo(gh.take())),r.push(s.pos.cloneTo(gh.take())),r.push(n.c1.cloneTo(gh.take())),r.push(n.c2.cloneTo(gh.take())),t.length=this.estimateBezierLength(t.ptStart,t.ptCount)),this._fullLength+=t.length,this._segments.push(t)}s.curve!=e.CurveType.CRSpline?i.length>0&&(i.push(s.pos.cloneTo(gh.take())),this.createSplineSegment(i)):i.push(s.pos.cloneTo(gh.take())),n=s}i.length>1&&this.createSplineSegment(i)}estimateBezierLength(e,t,r=10){let s=0,i=new a,n=new a;this.onBezierCurve(e,t,0,i);for(let o=1;o<=r;o++){let l=o/r;this.onBezierCurve(e,t,l,n),s+=a.distance(i,n),n.cloneTo(i)}return s}createSplineSegment(t){let r=t.length;t.splice(0,0,t[0].cloneTo(gh.take())),t.push(t[r].cloneTo(gh.take())),t.push(t[r].cloneTo(gh.take())),r+=3;let s={};s.type=e.CurveType.CRSpline,s.ptStart=this._points.length,s.ptCount=r,this._points.push(...t),s.length=0;for(let e=1;e<r;e++)s.length+=a.distance(t[e-1],t[e]);this._fullLength+=s.length,this._segments.push(s),t.length=0}clear(){this._segments.length=0,this._points.length=0}getRotationAt(t,r,s){if(!this.rotationType)return null;if(e.RotationType.RotateAlongMotionPath===this.rotationType){const e=function(e,t){if(!e)return null;let r=new a;a.subtract(t,e,r);const s=1e-4,i=Math.abs(r.z)<s;if(i){let e=180*Math.atan2(r.y,r.x)/Math.PI;return new a(0,0,e)}{a.normalize(r,r);let e=180*Math.atan2(r.x,r.z)/Math.PI,t=Math.sqrt(r.x*r.x+r.z*r.z),s=180*Math.atan2(-r.y,t)/Math.PI;return new a(s,e,0)}}(this._parPos,this._curPt);return this._parPos||(this._parPos=this._parPosCatch),this._curPt.cloneTo(this._parPos),e}s||(s=new a);let i=new a;t=Wr.clamp01(t);let n=this._segments.length;if(0==n)return s.set(0,0,0),s;if(0==t){let e=this._segments[0];this.getTangentAtSegment(e,0,i)}else if(1==t){let e=this._segments[n-1];this.getTangentAtSegment(e,1,i)}else for(let e=0,r=t*this._fullLength;e<n;e++){let t=this._segments[e];if(r-=t.length,r<0){let e=1+r/t.length;this.getTangentAtSegment(t,e,i);break}}return this.tangentToEulerAngles(i,s,r),s}tangentToEulerAngles(e,t,r){if(r){let r=180*Math.atan2(e.y,e.x)/Math.PI;t.set(0,0,r)}else{let r=180*Math.atan2(e.x,e.z)/Math.PI,s=Math.sqrt(e.x*e.x+e.z*e.z),i=180*Math.atan2(-e.y,s)/Math.PI,a=0;t.set(i,r,a)}}getTangentAtSegment(t,r,s){let i=this._points;t.type==e.CurveType.Straight?(a.subtract(i[t.ptStart+1],i[t.ptStart],s),a.normalize(s,s)):t.type==e.CurveType.Bezier||t.type==e.CurveType.CubicBezier?this.getBezierTangent(t.ptStart,t.ptCount,r,s):t.type==e.CurveType.CRSpline&&this.getCRSplineTangent(t.ptStart,t.ptCount,r,s)}getBezierTangent(e,t,r,s){let i=this._points,n=i[e],o=i[e+1],l=i[e+2];if(4==t){let t=i[e+3],h=1-r;a.subtract(l,n,ch),a.scale(ch,3*h*h,ch),a.subtract(t,l,_h),a.scale(_h,6*h*r,_h),a.subtract(o,t,ph),a.scale(ph,3*r*r,ph),a.add(ch,_h,s),a.add(s,ph,s)}else{let e=1-r;a.subtract(l,n,ch),a.scale(ch,2*e,ch),a.subtract(o,l,_h),a.scale(_h,2*r,_h),a.add(ch,_h,s)}a.normalize(s,s)}getCRSplineTangent(e,t,r,s){let i=Math.floor(r*(t-4))+e,n=this._points,o=n[i],l=n[i+1],h=n[i+2],u=n[i+3],d=1==r?1:Wr.repeat(r*(t-4),1),c=.5*(-3*d*d+4*d-1),_=.5*(9*d*d-10*d),p=.5*(-9*d*d+8*d+1),g=.5*(3*d*d-2*d);s.x=o.x*c+l.x*_+h.x*p+u.x*g,s.y=o.y*c+l.y*_+h.y*p+u.y*g,s.z=o.z*c+l.z*_+h.z*p+u.z*g,a.normalize(s,s)}getPointAt(e){let t=this._curPt;if((e=Wr.clamp01(e))===this._cacheT)return t;t.set(0,0,0),this._cacheT=e;let r=this._segments.length;if(0==r)return t;let s=this._points;if(1==e){let e=this._segments[r-1];return this.getPointOnSegment(e,1,s,t),t}for(let i=0,a=e*this._fullLength;i<r;i++){let e=this._segments[i];if(a-=e.length,a<0){let r=1+a/e.length;this.getPointOnSegment(e,r,s,t);break}}return t}get segmentCount(){return this._segments.length}getAnchorsInSegment(e,t){null==t&&(t=[]);let r=this._points,s=this._segments[e];for(let e=0;e<s.ptCount;e++)t.push(r[s.ptStart+e]);return t}getPointsInSegment(t,r,s,i,n,o){null==i&&(i=[]),o&&!isNaN(o)||(o=.1);let l=this._points;n&&n.push(r);let h=this._segments[t];if(h.type==e.CurveType.Straight){let e=new a;a.lerp(l[h.ptStart],l[h.ptStart+1],r,e),i.push(e),e=new a,a.lerp(l[h.ptStart],l[h.ptStart+1],s,e),i.push(e)}else{let t;t=h.type==e.CurveType.Bezier||h.type==e.CurveType.CubicBezier?this.onBezierCurve:this.onCRSplineCurve,i.push(t.call(this,h.ptStart,h.ptCount,r,new a));let l=Math.min(h.length*o,50);for(let e=0;e<=l;e++){let o=e/l;o>r&&o<s&&(i.push(t.call(this,h.ptStart,h.ptCount,o,new a)),n&&n.push(o))}i.push(t.call(this,h.ptStart,h.ptCount,s,new a))}return n&&n.push(s),i}getAllPoints(e,t,r){null==e&&(e=[]),r&&!isNaN(r)||(r=.1);for(let s=0,i=this._segments.length;s<i;s++)this.getPointsInSegment(s,0,1,e,t,r);return e}getPointOnSegment(t,r,s,i){t.type==e.CurveType.Straight?a.lerp(s[t.ptStart],s[t.ptStart+1],r,i):t.type==e.CurveType.Bezier||t.type==e.CurveType.CubicBezier?this.onBezierCurve(t.ptStart,t.ptCount,r,i):this.onCRSplineCurve(t.ptStart,t.ptCount,r,i)}onCRSplineCurve(e,t,r,s){let i=Math.floor(r*(t-4))+e,a=this._points,n=a[i],o=a[i+1],l=a[i+2],h=a[i+3],u=1==r?1:Wr.repeat(r*(t-4),1),d=((2-u)*u-1)*u*.5,c=.5*((3*u-5)*u*u+2),_=((-3*u+4)*u+1)*u*.5,p=(u-1)*u*u*.5;return s.x=n.x*d+o.x*c+l.x*_+h.x*p,s.y=n.y*d+o.y*c+l.y*_+h.y*p,s.z=n.z*d+o.z*c+l.z*_+h.z*p,s}onBezierCurve(e,t,r,s){let i=1-r,n=this._points,o=n[e],l=n[e+1],h=n[e+2];if(4==t){let t=n[e+3];a.add(o.scale(i*i*i,ch),h.scale(3*i*i*r,_h),_h),a.add(t.scale(3*i*r*r,ch),l.scale(r*r*r,ph),ph),a.add(_h,ph,s)}else a.add(o.scale(i*i,ch),h.scale(2*i*r,_h),ch),a.add(ch,l.scale(r*r,_h),s);return s}}const ch=new a,_h=new a,ph=new a,gh=h.createPool(a,null,e=>e.set(0,0,0));class mh extends ah{constructor(){super(),this._controllerLayers=[],this._parameters={}}get controller(){return this._controller}set controller(e){this._controller&&this._controller._removeReference(),this._controller=e,e&&(e._addReference(),e.updateTo(this))}get parameters(){return this._parameters}set parameters(e){this._parameters=e}_switchState(e,t){e&&e._eventSwitch(t)}_updatePlayer(e,t,r,s,i){const a=this._updatePlayerTime(e,t,r,s);this._applyTransition(i,e._eventtransition(t._normalizedPlayTime,this.parameters,a))}_applyTransition(e,t){return!!t&&this.crossFade(t.destState.name,e,t.transstartoffset,t.transduration)}gotoAndStopByFrame(e,t,r){var s=this._controllerLayers[t];if(s){var i=s.getStateByName(e);if(!i||!i._clip)return;let a=r/(i._clip._duration*i._clip._frameRate);1<a&&(a=1),this.gotoAndStop(e,t,a)}}getControllerLayer(e=0){return this._controllerLayers[e]}gotoAndStop(e,t,r){var s=this._controllerLayers[t];if(s){var i=s.getStateByName(e);if(!i||!i._clip)return;var a=s._playStateInfo,n=a._currentState,o=i._clip._duration,l=i._clip._duration*(i.clipEnd-i.clipStart);this._clearCrossFade(s),this._updateDefVal(),a._resetPlayState(o*r,l),a._normalizedPlayTime=r,s._playType=0,n!==i&&(a._currentState=i,this._switchState(n,i)),i._eventStart(this,t);let h=s.blendingMode!=oh.BLENDINGMODE_OVERRIDE;this._updateClipDatas(i,h,a),this._setClipDatasToNode(i,h,s.defaultWeight),this.stop()}}play(e,t=0,r=Number.NEGATIVE_INFINITY){if(this._checkEnterIndex){let e=this._checkEnterIndex.indexOf(t);0<=e&&this._checkEnterIndex.splice(e,1)}this._isPlaying=!0;var s=this._controllerLayers[t];if(s){var i=s.defaultState;if(!e&&!i)throw new Error("Animator:must have default clip value,please set clip property.");var a=s._playStateInfo,n=a._currentState,o=e?s.getStateByName(e):i;if(!o._clip)return;var l=o._clip._duration,h=o._clip._duration*(o.clipEnd-o.clipStart);this._clearCrossFade(s),this._updateDefVal(),n!==o?(r!==Number.NEGATIVE_INFINITY?a._resetPlayState(l*r,h):a._resetPlayState(0,h),s._playType=0,a._currentState=o):r!==Number.NEGATIVE_INFINITY?(a._resetPlayState(l*r,h),s._playType=0):a._resetPlayState(l*o.clipStart,h),s._playType=0,this._switchState(n,o),o._eventStart(this,t)}}stop(){this._isPlaying=!1}onUpdate(){if(this._isPlaying){if(this._checkEnterIndex)for(let t=this._checkEnterIndex.length-1;t>=0;t--){let r=this._checkEnterIndex[t];if(this._controllerLayers[r]._enterTransition.check(0,this.parameters,!0)){var e=this.getDefaultState(r);this.play(null,r,e.cycleOffset)}}var t=this.owner.timer.delta/1e3;if(t=this._applyUpdateMode(t),0!=this.speed&&0!=t)for(n=0,o=this._controllerLayers.length;n<o;n++){if((l=this._controllerLayers[n]).enable){h=l._playStateInfo;var r=l.blendingMode!=oh.BLENDINGMODE_OVERRIDE;switch(l._playType){case 0:u=h._currentState;var s=this._speed*u.speed,i=h._finish,a=u.loop;if(-1>=a)a=u._clip.islooping?0:1;let e=1;if(h._frontPlay||(e=-1),i?this._applyTransition(n,u._eventtransition(h._normalizedPlayTime,this.parameters,!1)):this._updatePlayer(u,h,t*s*e,a,n),0!==l._playType){i||(this._updateEventScript(u,h),this._updateStateFinish(u,h)),1!==l._playType&&2!==l._playType||this._updateCrossFade(l,n,0);break}u=(h=l._playStateInfo)._currentState,this._updateClipDatas(u,r,h),i||(this._setClipDatasToNode(u,r,l.defaultWeight),this._updateEventScript(u,h)),i||this._updateStateFinish(u,h);break;case 1:case 2:this._updateCrossFade(l,n,t)}}}else for(var n=0,o=this._controllerLayers.length;n<o;n++){var l,h;if((l=this._controllerLayers[n]).enable)if((h=l._playStateInfo)._finish&&0==l._playType){var u=h._currentState;this._applyTransition(n,u._eventtransition(h._normalizedPlayTime,this.parameters,!1))}}}}_clearCrossFade(e){e._crossMark++,e._crossNodes.length=e._crossDefaultValues.length=e._crossValues.length=e._crossFixedValues.length=0,e._srcCrossClipNodeIndices.length=e._destCrossClipNodeIndices.length=0,e._crossPlayStateInfo._currentState=null}_blendValue(e,t,r){if("number"==typeof e&&"number"==typeof t)return e+(t-e)*r;if(e&&t&&"object"==typeof e&&"object"==typeof t){const s=(e,t)=>e&&t?new a(e.x+(t.x-e.x)*r,e.y+(t.y-e.y)*r,e.z+(t.z-e.z)*r):r<1?e:t;return{pos:s(e.pos,t.pos),rotation:s(e.rotation,t.rotation)}}return r<1?e:t}_advanceCrossState(e,t,r,s){const i=e._crossMark,a=t._currentState,n=t._finish;if(!n&&0!==r){const s=a.loop<=-1?a._clip.islooping?0:1:a.loop;if(this._updatePlayerTime(a,t,r*this._speed*a.speed*(t._frontPlay?1:-1),s),i!==e._crossMark)return!1}if(this._updateClipDatas(a,s,t),!n&&0!==r){if(this._updateEventScript(a,t),i!==e._crossMark)return!1;this._updateStateFinish(a,t)}return i===e._crossMark}_updateCrossFade(e,t,r){const s=e._crossMark,i=e._playStateInfo,a=e._crossPlayStateInfo,n=i._currentState,o=a._currentState,l=e.blendingMode!==oh.BLENDINGMODE_OVERRIDE;if(1===e._playType&&!this._advanceCrossState(e,i,r,l))return;const h=a._elapsedTime;if(!this._advanceCrossState(e,a,r,l))return;e._crossElapsedTime+=Math.abs(r*this._speed);const u=Math.min(e._crossElapsedTime/e._crossDuration,1);for(let t=0;t<e._crossNodes.length;t++){const r=e._srcCrossClipNodeIndices[t],i=e._destCrossClipNodeIndices[t],a=e._crossDefaultValues[t],h=2===e._playType?e._crossFixedValues[t]:r<0?a:n._realtimeDatas[r],d=i<0?a:o._realtimeDatas[i],c=this._blendValue(null==h?a:h,null==d?a:d,u);e._crossValues[t]=c;const _=this.getOwner(e._crossNodes[t]);if(_&&null!=c&&this._applyAniData(_,l,e.defaultWeight,c),s!==e._crossMark)return}if(1===u){const t=i._finish;a._cloneTo(i),i._currentState=o,e._playType=0,this._clearCrossFade(e);const r=e._crossMark;if(t||n===o||n._eventExit(),r!==e._crossMark)return}const d=a._duration,c=Math.floor(Math.abs(h)/d)!==Math.floor(Math.abs(a._elapsedTime)/d);this._applyTransition(t,o._eventtransition(a._normalizedPlayTime,this.parameters,c))}addControllerLayer(e){this._controllerLayers.push(e)}crossFade(e,t=0,r=Number.NEGATIVE_INFINITY,s){var i=this._controllerLayers[t];if(i){var n=i.getStateByName(e);if(n&&n._clip){const o=i._playStateInfo,l=o._currentState;if(!(l&&s>0&&Number.isFinite(s)))return this.play(e,t,r),!0;const h=l._clip._duration*(l.clipEnd-l.clipStart)*s;if(!(h>0))return this.play(e,t,r),!0;const u=i.blendingMode!==oh.BLENDINGMODE_OVERRIDE,d=1===i._playType||2===i._playType,c=d||l===n,_=d?i._crossNodes.slice():[],p=d?i._crossValues.slice():[],g=d?i._crossDefaultValues.slice():[],m=d?i._crossPlayStateInfo._currentState:l,f=d&&i._crossPlayStateInfo._finish;this._updateClipDatas(l,u,o);const T=l._clip._nodes,y=n._clip._nodes;if(!d)for(let e=0;e<T.count;e++)_.push(T.getNodeByIndex(e));const x=new Set(_.map(e=>e.fullPath));for(let e=0;e<y.count;e++){const t=y.getNodeByIndex(e);x.has(t.fullPath)||(_.push(t),x.add(t.fullPath))}this._clearCrossFade(i),i._crossNodes=_;for(let e=0;e<_.length;e++){const t=_[e],r=l._clip._nodesDic[t.fullPath],s=n._clip._nodesDic[t.fullPath],o=r?r._indexInList:-1,h=s?s._indexInList:-1,m=this.getOwner(t);let f=g[e];if(null==f&&m&&m.pro){const e=t.keyFramesCount>0&&t.getKeyframeByIndex(0).data.val instanceof dh,r=e?m.pro.ower:m.pro.defVal;f=e&&r?{pos:new a(r.x,r.y,0),rotation:new a(0,0,r.rotation||0)}:r,u&&"number"==typeof f&&(f=0)}const T=o<0?f:l._realtimeDatas[o];i._srcCrossClipNodeIndices[e]=o,i._destCrossClipNodeIndices[e]=h,i._crossDefaultValues[e]=f,i._crossFixedValues[e]=d&&e<p.length?p[e]:T,i._crossValues[e]=c?i._crossFixedValues[e]:T}const S=i._crossPlayStateInfo,E=n._clip._duration;if(S._resetPlayState(r===Number.NEGATIVE_INFINITY?0:E*r,E*(n.clipEnd-n.clipStart)),S._currentState=n,i._crossDuration=h,i._crossElapsedTime=0,i._playType=c?2:1,this._isPlaying=!0,this._checkEnterIndex){const e=this._checkEnterIndex.indexOf(t);e>=0&&this._checkEnterIndex.splice(e,1)}return d&&m!==l&&!f&&m._eventExit(),this._switchState(m,n),n._eventStart(this,t),!0}console.warn("Invalid animation state "+e+".")}return!1}onAfterDeserialize(){let e=this.controllerLayers;if(e&&null==this.controller){delete this.controllerLayers,this._controllerLayers.length=0;for(let t of e)this.addControllerLayer(t)}}onEnable(){if(this._checkEnterIndex?this._checkEnterIndex.length=0:this._checkEnterIndex=[],this._isPlaying)for(var e=0,t=this._controllerLayers.length;e<t;e++)if(this._controllerLayers[e].playOnWake){var r=this.getDefaultState(e);if(r){let t=this._controllerLayers[e]._enterTransition;t?(this._isPlaying=!0,t.check(0,this.parameters,!0)?this.play(null,e,r.cycleOffset):this._checkEnterIndex.push(e)):this.play(null,e,r.cycleOffset)}}}getDefaultState(e=0){return this._controllerLayers[e].defaultState}setParamsTrigger(t){const r=this._parameters[t];r&&r.type===e.AniParmType.Trigger?r.value=!0:this._parameters[t]={name:t,type:e.AniParmType.Trigger,value:!0}}setParamsNumber(t,r){const s=this._parameters[t];s&&s.type===e.AniParmType.Float?s.value=r:this._parameters[t]={name:t,type:e.AniParmType.Float,value:r}}setParamsBool(t,r){const s=this._parameters[t];s&&s.type===e.AniParmType.Bool?s.value=r:this._parameters[t]={name:t,type:e.AniParmType.Bool,value:r}}getParamsvalue(e){let t=this._parameters[e];return t?t.value:null}onDestroy(){this._controller&&(this._controller._removeReference(),this._controller=null);for(var e=0,t=this._controllerLayers.length;e<t;e++)this._controllerLayers[e].destroy();this._controllerLayers.length=0,this._isPlaying=!1,this._parameters=null}}class fh extends N{constructor(){super(...arguments),this._referenceCount=0,this._clip=null,this._currentFrameIndices=null,this.cycleOffset=0,this.speed=1,this.clipStart=0,this.clipEnd=1,this.loop=-1,this.yoyo=!1,this.transitions=[],this.soloTransitions=[],this._scripts=null,this._realtimeDatas=[]}get clip(){return this._clip}set clip(e){if(this._clip!=e){if(this._clip&&this._referenceCount>0&&this._clip._removeReference(this._referenceCount),e){var t=e._nodes.count;this._currentFrameIndices=new Int16Array(t),this._resetFrameIndices(),this._referenceCount>0&&e._addReference(this._referenceCount),this._realtimeDatas.length=t}this._clip=e}}_eventStateUpdate(e){if(this.event(fh.EVENT_OnStateUpdate,e),this._scripts)for(var t=0,r=this._scripts.length;t<r;t++)this._scripts[t].onStateUpdate(e)}_eventStart(e,t){if(this.event(fh.EVENT_OnStateEnter),this._scripts)for(var r=0,s=this._scripts.length;r<s;r++)this._scripts[r].setPlayScriptInfo(e,t,this),this._scripts[r].onStateEnter()}_eventExit(){if(this.event(fh.EVENT_OnStateExit),this._scripts)for(let e=0,t=this._scripts.length;e<t;e++)this._scripts[e].onStateExit()}_eventSwitch(e){if(this.event(fh.EVENT_OnStateSwitch,e),this._scripts)for(let t=0,r=this._scripts.length;t<r;t++)this._scripts[t].onStateSwitch&&this._scripts[t].onStateSwitch(e)}_eventLoop(){if(this.event(fh.EVENT_OnStateLoop),this._scripts)for(let e=0,t=this._scripts.length;e<t;e++)this._scripts[e].onStateLoop&&this._scripts[e].onStateLoop()}_eventtransition(e,t,r){let s=this.soloTransitions.length;if(s>0){for(var i=0;i<s;i++)if(this.soloTransitions[i].check(e,t,r))return this.soloTransitions[i];return null}let a=this.transitions.length;for(i=0;i<a;i++)if(this.transitions[i].check(e,t,r))return this.transitions[i];return null}_resetFrameIndices(){for(var e=0,t=this._currentFrameIndices.length;e<t;e++)this._currentFrameIndices[e]=-1}_getReferenceCount(){return this._referenceCount}_addReference(e){this._clip&&this._clip._addReference(e),this._referenceCount+=e}_removeReference(e){this._clip&&this._clip._removeReference(e),this._referenceCount-=e}_clearReference(){this._removeReference(-this._referenceCount)}addScript(e){var t=new e;return this._scripts=this._scripts||[],this._scripts.push(t),t}getScript(e){if(this._scripts)for(var t=0,r=this._scripts.length;t<r;t++){var s=this._scripts[t];if(s instanceof e)return s}return null}getScripts(e){var t=null;if(this._scripts)for(var r=0,s=this._scripts.length;r<s;r++){var i=this._scripts[r];i instanceof e&&(t=t||[]).push(i)}return t}clone(){var e=new fh;return this.cloneTo(e),e}cloneTo(e){e.name=this.name,e.speed=this.speed,e.clip=this._clip}destroy(){this._clip=null,this._currentFrameIndices=null,this._scripts=null,this._realtimeDatas.length=0}}fh.EVENT_OnStateEnter="OnStartEnter",fh.EVENT_OnStateUpdate="OnStateUpdate",fh.EVENT_OnStateExit="OnStateExit",fh.EVENT_OnStateSwitch="OnStateSwitch",fh.EVENT_OnStateLoop="OnStateLoop";class Th{constructor(){this._ownerPath=[],this._propertys=[],this._keyFrames=[]}get keyFramesCount(){return this._keyFrames.length}_setOwnerPathCount(e){this._ownerPath.length=e}_setOwnerPathByIndex(e,t){this._ownerPath[e]=t}_setPropertyCount(e){this._propertys.length=e}_setPropertyByIndex(e,t){this._propertys[e]=t}_setKeyframeCount(e){this._keyFrames.length=e}_joinOwnerPath(e){return this._ownerPath.join(e)}_joinProperty(e){return this._propertys.join(e)}getKeyframeByIndex(e){return this._keyFrames[e]}get ownerPathCount(){return this._ownerPath.length}get propertyCount(){return this._propertys.length}getOwnerPathByIndex(e){return this._ownerPath[e]}getPropertyByIndex(e){return this._propertys[e]}}class yh{clone(){var e=new yh;return this.cloneTo(e),e}cloneTo(e){e.time=this.time}}yh.defaultWeight=.33333;class xh{constructor(){}}class Sh{static READ_DATA(){this._DATA.offset=this._reader.readUint32(),this._DATA.size=this._reader.readUint32()}static READ_BLOCK(){for(var e=this._BLOCK.count=this._reader.readUint16(),t=this._BLOCK.blockStarts=[],r=this._BLOCK.blockLengths=[],s=0;s<e;s++)t.push(this._reader.readUint32()),r.push(this._reader.readUint32())}static READ_STRINGS(){var e=this._reader.readUint32(),t=this._reader.readUint16(),r=this._reader.pos;this._reader.pos=e+this._DATA.offset;for(var s=0;s<t;s++)this._strings[s]=this._reader.readUTFString();this._reader.pos=r}static parse(e,t,r){this._clip=e,this._reader=t,this._version=r,this.READ_DATA(),this.READ_BLOCK(),this.READ_STRINGS();for(var s=0,i=this._BLOCK.count;s<i;s++){var a=t.readUint16(),n=this._strings[a],o=this["READ_"+n];if(!o)throw new Error("model file err,no this function:"+a+" "+n);o.call(this)}this._version=null,this._reader=null,this._clip=null,this._strings.length=0}static timeToFrame(e,t){return Math.round(e*t)}static createPathPoints(e){const t=[];for(var r=0,s=e.length;r<s;r++){const s=e[r],i=new hh;i.pos.x=s.pos.x,i.pos.y=s.pos.y,i.pos.z=s.pos.z,i.c1.x=s.c1.x,i.c1.y=s.c1.y,i.c1.z=s.c1.z,i.c2.x=s.c2.x,i.c2.y=s.c2.y,i.c2.z=s.c2.z,i.curve=s.curve,i.rotationType=s.rotationType,t.push(i)}return t}static READ_ANIMATIONS2D(){var e,t,r,s=this._reader,i=this._clip,a=[],n=s.readUint16();for(a.length=n,e=0;e<n;e++)a[e]=s.readFloat32();i._duration=a[s.readInt16()],i.islooping=!!s.readByte(),i._frameRate=s.readInt16();var o=s.readInt16(),l=i._nodes;l.count=o;var h=i._nodesMap={},u=i._nodesDic={};for(e=0;e<o;e++){r=new Th,l.setNodeByIndex(e,r),r._indexInList=e;var d=s.readUint16();for(r._setOwnerPathCount(d),t=0;t<d;t++)r._setOwnerPathByIndex(t,this._strings[s.readUint16()]);var c=r._joinOwnerPath("/"),_=h[c];_||(h[c]=_=[]),_.push(r);var p=s.readUint16();for(r._setPropertyCount(p),t=0;t<p;t++)r._setPropertyByIndex(t,this._strings[s.readUint16()]);var g=c+"."+r._joinProperty(".");u[g]=r,r.fullPath=g,r.nodePath=c;var m=s.readUint16();for(t=0;t<m;t++){var f=new yh;f.time=a[s.readUint16()],f.data={f:this.timeToFrame(f.time,i._frameRate),val:0},1==s.readByte()&&(f.data.tweenType=this._strings[s.readUint16()]),1==s.readByte()&&(f.data.tweenInfo={},f.data.tweenInfo.inTangent=a[s.readUint16()],f.data.tweenInfo.outTangent=a[s.readUint16()],1==s.readByte()&&(f.data.tweenInfo.inWeight=a[s.readUint16()]),1==s.readByte()&&(f.data.tweenInfo.outWeight=a[s.readUint16()]));var T=s.readByte();if(0==T)f.data.val=a[s.readUint16()];else if(1==T)f.data.val=this._strings[s.readUint16()];else if(2==T)f.data.val=!!s.readByte();else if(3==T){const e=JSON.parse(s.readUTFString());if(Array.isArray(e)){const t=new dh;f.data.val=t,t._$data=e,t.create(...this.createPathPoints(e))}else f.data.val=e}if(1==s.readByte())try{f.data.extend=JSON.parse(this._strings[s.readUint16()])}catch(e){}r._keyFrames.push(f)}}var y=s.readUint16();for(e=0;e<y;e++){var x=new xh;x.time=a[s.readUint16()],x.eventName=this._strings[s.readUint16()];var S=[],E=s.readUint16();for(E>0&&(x.params=S=[]),t=0;t<E;t++){switch(s.readByte()){case 0:S.push(!!s.readByte());break;case 1:S.push(s.readInt32());break;case 2:S.push(a[s.readUint16()]);break;case 3:S.push(this._strings[s.readUint16()]);break;default:throw new Error("unknown type.")}}i.addEvent(x)}}}Sh._strings=[],Sh._DATA={offset:0,size:0},Sh._BLOCK={count:0};class Eh{constructor(){this._nodes=[]}get count(){return this._nodes.length}set count(e){this._nodes.length=e}getNodeByIndex(e){return this._nodes[e]}setNodeByIndex(e,t){this._nodes[e]=t}}class vh extends G{static _parse(e){var t=new vh,r=new Ei(e),s=r.readUTFString();if("LAYAANIMATION2D:01"!==s)throw"unknown animationClip version.";return Sh.parse(t,r,s),t}constructor(){super(),this._nodes=new Eh,this._animationEvents=[]}duration(){return this._duration}_evaluateClipDatasRealTime(e,t,r,s,i){for(var a=this._nodes,n=0,o=a.count;n<o;n++){var l,h=a.getNodeByIndex(n)._keyFrames,u=h.length;if(0!=u){var d=t[n];if(s)for(-1!=d&&e<h[d].time&&(d=-1,t[n]=d),l=d+1;l<u&&!(h[l].time>e);)d++,l++,t[n]=d;else for((l=d+1)!=u&&e>h[l].time&&(d=u-1,t[n]=d),l=d+1;d>-1&&!(h[d].time<e);)d--,l--,t[n]=d;var c=l==u;if(-1!=d){var _=h[d];if(c)_.data.val instanceof dh?i[n]={pos:_.data.val.getPointAt(0),rotation:_.data.val.getRotationAt(0,!0)}:i[n]=_.data.val;else{var p,g=h[l],m=g.time-_.time;p=0!==m?(e-_.time)/m:0,i[n]=this._getTweenVal(_,g,p,m)}}else h[0].data.val instanceof dh?i[n]={pos:h[0].data.val.getPointAt(0),rotation:h[0].data.val.getRotationAt(0,!0)}:i[n]=h[0].data.val;r&&"number"==typeof h[0].data.val&&(i[n]=i[n]-h[0].data.val)}}}_getTweenVal(e,t,r,s){var i=e.data,a=t.data;if(i.val instanceof dh)return{pos:i.val.getPointAt(r),rotation:i.val.getRotationAt(r,!0)};if("number"!=typeof i.val||"number"!=typeof a.val)return i.val;var n=function(e){if(!e)return null;let t=Dh[e];t||(e=(e=e.replace("_Ease","")).charAt(0).toLowerCase()+e.substring(1),t=Ya[e],null!=t&&(Dh[e]=t));return t}(i.tweenType),o=i.val,l=a.val;if(null!=n)return n(r,o,l-o,1);var h,u=0,d=0,c=NaN,_=NaN;return null!=i.tweenInfo&&(u=i.tweenInfo.outTangent,c=i.tweenInfo.outWeight),null!=a.tweenInfo&&(d=a.tweenInfo.inTangent,_=a.tweenInfo.inWeight),(isNaN(c)||0>=c)&&(c=yh.defaultWeight),(isNaN(_)||0>=_)&&(_=yh.defaultWeight),isNaN(u)&&(u=0),isNaN(d)&&(d=0),Math.abs(u)==Number.MAX_VALUE&&(u=0>u?-1/0:1/0),Math.abs(d)==Number.MAX_VALUE&&(d=0>d?-1/0:1/0),h=!i.tweenInfo&&!a.tweenInfo||yh.defaultWeight==_&&yh.defaultWeight==c?function(e,t,r,s,i,a){if(Math.abs(e)==1/0||Math.abs(t)==1/0)return r;var n=i*i,o=n*i,l=o-2*n+i,h=o-n;return(2*o-3*n+1)*r+l*e*a+h*t*a+(-2*o+3*n)*s}(u,d,o,l,r,s):this.hermiteCurveSplineWeight(o,e.time,c,u,l,t.time,_,d,r),h}_binarySearchEventIndex(e){for(var t,r=0,s=this._animationEvents.length-1;r<=s;){t=r+s>>1;var i=this._animationEvents[t].time;if(i==e)return t;i>e?s=t-1:r=t+1}return r}hermiteCurveSplineWeight(e,t,r,s,i,a,n,o,l){let h=222e-18,u=l,d=e,c=r,_=n,p=a-t,g=i-d;g=Math.max(Math.abs(g),h)*(g<0?-1:1);let m=s,f=o;if(!Number.isFinite(m)||!Number.isFinite(f))return e;m=m*p/g,f=f*p/g;let T=1-_,y=.5,x=0;if(Math.abs(c-.33333334)<1e-4&&Math.abs(_-.33333334)<1e-4)y=u,x=1-y;else for(;;){x=1-y;let e=3*x*x*y*c+3*x*y*y*T+y*y*y-u;if(Math.abs(e)<=2.5*h)break;let t=3*x*x*c+6*x*y*(T-c)+3*y*y*(1-T),r=6*x*(T-2*c)+6*y*(1-2*T+c);y-=(6*e*t*t-3*e*e*r)/(6*t*t*t-6*e*t*r+e*e*(18*c-18*T+6))}return(3*x*x*y*c*m+3*x*y*y*(1-_*f)+y*y*y)*g+d}addEvent(e){var t=this._binarySearchEventIndex(e.time);this._animationEvents.splice(t,0,e)}}const Dh={};class wh{}var Rh,Ch,Mh;e.AniConditionType=void 0,(Rh=e.AniConditionType||(e.AniConditionType={}))[Rh.Greater=0]="Greater",Rh[Rh.Less=1]="Less",Rh[Rh.Equals=2]="Equals",Rh[Rh.NotEqual=3]="NotEqual";class bh{}class Ah extends G{constructor(){super(),this._traceDeps=!0}}class Ih{static conditionNameToID(e){if(null!=Ih._conditionNameMap[e])return Ih._conditionNameMap[e];var t=this._propertyNameCounter++;return this._conditionNameMap[e]=t,this._conditionNameMap[t]=e,t}static conditionIDToName(e){return this._conditionNameMap[e]}constructor(e=null){e&&(this._id=Ih.conditionNameToID(e),this._name=e)}get id(){return this._id}get name(){return this._name}set name(e){this._id=Ih.conditionNameToID(e),this._name=e}get type(){return this._type}checkState(e){return!1}}Ih._conditionNameMap={},Ih._propertyNameCounter=0;class Ph extends Ih{constructor(t){super(t),this._numberValue=0,this._numberCompareFlag=e.AniStateConditionNumberCompressType.Greater,this._type=e.AniStateConditionType.Number}get numberValue(){return this._numberValue}set numberValue(e){this._numberValue=e}get compareFlag(){return this._numberCompareFlag}set compareFlag(e){this._numberCompareFlag=e}checkState(t){return e.AniStateConditionNumberCompressType.Greater==this._numberCompareFlag?t>this._numberValue:t<this._numberValue}}class Bh extends Ih{constructor(t){super(t),this._compareFlag=!0,this._type=e.AniStateConditionType.Bool}get compareFlag(){return this._compareFlag}set compareFlag(e){this._compareFlag=e}checkState(e){return this._compareFlag==e}}class Lh extends Ih{constructor(t){super(t),this._type=e.AniStateConditionType.Trigger}checkState(e){return e}}class Nh{constructor(){this.conditions=[],this.exitByTime=!0,this.exitTime=1,this.transduration=0,this.transstartoffset=0,this.mute=!1}addCondition(e){-1==this.conditions.indexOf(e)&&this.conditions.push(e)}removeCondition(e){let t=this.conditions.indexOf(e);-1!=t&&this.conditions.splice(t,0)}check(t,r,s){if(this.mute)return!1;if(this.exitByTime&&t<this.exitTime&&!s)return!1;if(!this.conditions||0===this.conditions.length)return!0;if(this.isAndOperEnabled){for(let t=0;t<this.conditions.length;t++){const s=this.conditions[t];if(!s.checkState(r[s.name].value))return!1;s.type===e.AniStateConditionType.Trigger&&(r[s.name].value=!1)}return!0}for(let t=0;t<this.conditions.length;t++){const s=this.conditions[t];if(s.checkState(r[s.name].value))return s.type===e.AniStateConditionType.Trigger&&(r[s.name].value=!1),!0}return!1}}class Fh extends G{constructor(e){super();let t=lh.parse(e);this.data=t.ret,this.clipsID=t.clipsID}getLayers(){let e=this.data.controllerLayers,t=[];for(let r=e.length-1;r>=0;r--){let s=e[r],i=new oh(s.name);t.unshift(i);for(let e in s)if("name"!=e&&"states"!=e&&null!=s[e])try{i[e]=s[e]}catch(e){console.error(e)}this.getState(s.states,i,this.data)}return t}createState(e,t,r){if(!e)return null;let s={},i=null;for(let a=e.length-1;a>=0;a--){let n=e[a],o=n.states;if(o){let e=this.createState(o,t,r);e&&(t[n.id]=e.states[e.id]);continue}if(0>Number(n.id)){if("-1"==n.id){let e=n.soloTransitions;e&&0<e.length&&(i=e[0].id)}continue}let l=new fh;t[n.id]=l,s[n.id]=l;for(let e in n)try{if("scripts"==e){let t=n[e];if(t&&Array.isArray(t))for(let e=t.length-1;e>=0;e--){let r=t[e];r&&0==r.indexOf("res://")&&(r=r.substring(6));let s=Ee.getClass(r);s&&l.addScript(s)}continue}if("soloTransitions"==e)continue;null!=n[e]&&(l[e]=n[e])}catch(e){}r.addState(l)}return{id:i,states:s}}getState(e,t,r){if(e){let s={};this.createState(e,s,t),this.setTransitions(e,s,t,r)}}setExitTransition(e,t,r,s,i){for(let a in e){let n=r[a];if(n){let o=n.transitions,l=n.soloTransitions,h=e[a];for(let e=t.length-1;e>=0;e--){let n=t[e];if("-3"!=n.id)for(let e=h.length-1;e>=0;e--){let t=h[e],i=new Nh;i.destState=r[n.id],n.conditions&&this.addConditions(n.conditions,i,s),t.conditions&&this.addConditions(t.conditions,i,s);for(let e in n)"solo"!=e&&"id"!=e&&"conditions"!=e&&(i[e]=n[e]);n.solo?l.unshift(i):o.unshift(i)}else null==i[a]&&(i[a]=[]),i[a].push(n)}}}}_getAnimatorTransition2D(e,t,r){let s=new Nh;t[e.id]&&(s.destState=t[e.id]),e.conditions&&this.addConditions(e.conditions,s,r);for(let t in e)"solo"!=t&&"id"!=t&&"conditions"!=t&&(s[t]=e[t]);return s}setTransitions(e,t,r,s,i){if(!e)return null;let a={};for(let i=e.length-1;i>=0;i--){let n=e[i];if(n.states){let e=this.setTransitions(n.states,t,r,s,n);if(e){let r=n.soloTransitions;r&&this.setExitTransition(e,r,t,s,a)}}}for(let n=e.length-1;n>=0;n--){let o=e[n];if(o.states)continue;if("-1"==o.id){if(o.soloTransitions&&0<o.soloTransitions.length){null==i?(r.defaultState=t[o.soloTransitions[0].id],r._enterTransition=this._getAnimatorTransition2D(o.soloTransitions[0],t,s)):t[i.id]=t[o.soloTransitions[0].id];continue}}else{if("-2"==o.id){let e=o.soloTransitions;if(e)for(let r=e.length-1;r>=0;r--){let i=e[r];if(t[i.id])for(let e in t){let r=t[e],a=this._getAnimatorTransition2D(i,t,s);i.solo?r.soloTransitions.unshift(a):r.transitions.unshift(a)}}continue}if("-3"==o.id)continue}let l=o.soloTransitions;if(l&&t[o.id]){let e=t[o.id].transitions,r=t[o.id].soloTransitions;for(let i=l.length-1;i>=0;i--){let n=l[i];if("-3"==n.id){null==a[o.id]&&(a[o.id]=[]),a[o.id].push(n);continue}let h=this._getAnimatorTransition2D(n,t,s);n.solo?r.unshift(h):e.unshift(h)}}}return a}addConditions(t,r,s){let i=s.animatorParams;if(null!=i&&0!=i.length)for(let s=0,a=t.length;s<a;s++){let a,n=t[s],o=null;for(let e=i.length-1;e>=0;e--)if(i[e].id==n.id){o=i[e];break}if(null==o)return;if(o.type==e.AniParmType.Bool){let e=new Bh(o.name);e.compareFlag=Boolean(n.checkValue),a=e}else if(o.type==e.AniParmType.Float){let e=new Ph(o.name);e.numberValue=Number(n.checkValue),e.compareFlag=n.type,a=e}else if(o.type==e.AniParmType.Trigger){a=new Lh(o.name)}r.addCondition(a)}}updateTo(e){let t=e._controllerLayers;for(let e=0,r=t.length;e<r;e++)t[e].destroy();t.length=0;let r=this.getLayers();for(let t=0,s=r.length;t<s;t++)e.addControllerLayer(r[t]);let s=this.data.animatorParams;if(s){let t={};for(let e=s.length-1;e>=0;e--){let r=s[e],i=new wh;i.name=r.name,i.type=r.type,i.value=r.val,t[r.name]=i}e.parameters=t}}}class Oh extends Sn{_isScript(){return!0}setupScript(){let e,t=this.owner;(e=this.onTriggerEnter)&&t.on(c.TRIGGER_ENTER,this,e),(e=this.onTriggerStay)&&t.on(c.TRIGGER_STAY,this,e),(e=this.onTriggerExit)&&t.on(c.TRIGGER_EXIT,this,e),(e=this.onCollisionEnter)&&t.on(c.COLLISION_ENTER,this,e),(e=this.onCollisionStay)&&t.on(c.COLLISION_STAY,this,e),(e=this.onCollisionExit)&&t.on(c.COLLISION_EXIT,this,e),(e=this.onJointBreak)&&t.on(c.JOINT_BREAK,this,e),(e=this.onMouseDown)&&t.on(c.MOUSE_DOWN,this,e),(e=this.onMouseUp)&&t.on(c.MOUSE_UP,this,e),(e=this.onRightMouseDown)&&t.on(c.RIGHT_MOUSE_DOWN,this,e),(e=this.onRightMouseUp)&&t.on(c.RIGHT_MOUSE_UP,this,e),(e=this.onMouseMove)&&t.on(c.MOUSE_MOVE,this,e),(e=this.onMouseDrag)&&t.on(c.MOUSE_DRAG,this,e),(e=this.onMouseDragEnd)&&t.on(c.MOUSE_DRAG_END,this,e),(e=this.onMouseOver)&&t.on(c.MOUSE_OVER,this,e),(e=this.onMouseOut)&&t.on(c.MOUSE_OUT,this,e),(e=this.onMouseClick)&&t.on(c.CLICK,this,e),(e=this.onMouseDoubleClick)&&t.on(c.DOUBLE_CLICK,this,e),(e=this.onMouseRightClick)&&t.on(c.RIGHT_CLICK,this,e),(e=this.onKeyDown)&&l.stage.on(c.KEY_DOWN,this,e),(e=this.onKeyPress)&&l.stage.on(c.KEY_PRESS,this,e),(e=this.onKeyUp)&&l.stage.on(c.KEY_UP,this,e)}}class Uh{static parse(e,t,r,s){Uh._mesh=r,Uh._subMeshes=s,Uh._version=t,Uh._readData=e,Uh.READ_DATA(),Uh.READ_BLOCK(),Uh.READ_STRINGS();for(var i=0,a=Uh._BLOCK.count;i<a;i++){Uh._readData.pos=Uh._BLOCK.blockStarts[i];var n=Uh._readData.readUint16(),o=Uh._strings[n],l=Uh["READ_"+o];null==l?console.warn("model file err,no this function:"+n+" "+o):l.call(null)}Uh._strings.length=0,Uh._readData=null,Uh._version=null,Uh._mesh=null,Uh._subMeshes=null}static _readString(){return Uh._strings[Uh._readData.readUint16()]}static READ_DATA(){Uh._DATA.offset=Uh._readData.readUint32(),Uh._DATA.size=Uh._readData.readUint32()}static READ_BLOCK(){for(var e=Uh._BLOCK.count=Uh._readData.readUint16(),t=Uh._BLOCK.blockStarts=[],r=Uh._BLOCK.blockLengths=[],s=0;s<e;s++)t.push(Uh._readData.readUint32()),r.push(Uh._readData.readUint32())}static READ_STRINGS(){var e=Uh._readData.readUint32(),t=Uh._readData.readUint16(),r=Uh._readData.pos;Uh._readData.pos=e+Uh._DATA.offset;for(var s=0;s<t;s++)Uh._strings[s]=Uh._readData.readUTFString();Uh._readData.pos=r}static READ_MESH(){var t,r=0,s=Uh._readString(),i=Uh._readData,a=i.rawBuffer,n=i.readInt16(),o=Uh._DATA.offset,l=Uh._mesh;let h=[];var u=0;let d=[];for(t=0;t<n;t++){var c=o+i.readUint32(),_=i.readUint32(),p=Uh._readString(),g=Lt.getVertexDeclaration(p,!1),m=a.slice(c,c+_);d[t]=m;var T=f.renderDeviceFactory.createVertexBuffer(e.BufferUsage.Static);T.vertexDeclaration=g,T.setDataLength(_),T.setData(m,0,0,_),u=_/g.vertexStride,r+=_,h[t]=T}l._indexFormat=u>65535?e.IndexFormat.UInt32:e.IndexFormat.UInt16;var y,x,S=o+i.readUint32(),E=i.readUint32();l.indexFormat==e.IndexFormat.UInt32?(y=new Uint32Array(a.slice(S,S+E)),x=4):(y=new Uint16Array(a.slice(S,S+E)),x=2);var v=f.renderDeviceFactory.createIndexBuffer(e.BufferUsage.Static);return v.indexType=l.indexFormat,v.indexCount=E/x,v._setIndexDataLength(E),v._setIndexData(y,0),l._setBuffers(h,v),l.canRead=!0,l._vertices=d,l._indices=y,r+=y.byteLength,l._setCPUMemory(r),l._setGPUMemory(r),l.name=s,!0}static READ_SUBMESH(){var t=Uh._readData,r=f.renderDeviceFactory.createRenderGeometryElement(e.MeshTopology.Triangles,e.DrawType.DrawElement);t.readInt16();let s=Uh._mesh;r.bufferState=s._bufferState,r.indexFormat=s.indexFormat;for(var i=t.readUint16(),a=0;a<i;a++){let e=t.readUint32(),s=t.readUint32();r.setDrawElemenParams(s,e)}return Uh._subMeshes.push(r),!0}}Uh._BLOCK={count:0},Uh._DATA={offset:0,size:0},Uh._strings=[];class kh{load(e){let t=J.inst.getSubAssetURL(e.url,e.uuid,null,"lm");return e.loader.fetch(t,"arraybuffer",e.progress.createCallback(),e.options).then(t=>t?this._parse(e,t):null)}_parse(e,t){var r=new Ei(t);r.pos=0;var s=r.readUTFString();if(!s||!s.startsWith("LAYAMODEL"))return console.warn(`Unknow version:${s} ! Model : ${e.url}`),null;return s.startsWith("LAYAMODEL2D")?kh.v2d.parse(r,s):kh.v3d?kh.v3d.parse(r,s):(console.warn(`Loading ${e.url} , you need load the laya.d3 lib!`),null)}}class Gh{static parse(e,t){var r=new eo;let s=r._subMeshes;if("LAYAMODEL2D:01"!==t)throw new Error("unknown mesh version: "+t);return Uh.parse(e,t,r,s),r._setSubMeshes(s),r}}kh.v2d=Gh,Te.registerLoader(["lm"],kh,Te.MESH),e.TextResourceFormat=void 0,(Ch=e.TextResourceFormat||(e.TextResourceFormat={}))[Ch.Buffer=0]="Buffer",Ch[Ch.Plain=1]="Plain",Ch[Ch.JSON=2]="JSON",Ch[Ch.XML=3]="XML";class Vh extends G{constructor(e,t){super(),this.data=e,this.format=t}}Te.registerLoader(["txt","csv"],class{load(t){return t.loader.fetch(t.url,"text",t.progress.createCallback(),t.options).then(t=>t?new Vh(t,e.TextResourceFormat.Plain):null)}},Te.TEXT),Te.registerLoader(["bin","bytes","fui"],class{load(t){return t.loader.fetch(t.url,"arraybuffer",t.progress.createCallback(),t.options).then(t=>t?new Vh(t,e.TextResourceFormat.Buffer):null)}},Te.BUFFER),Te.registerLoader(["json"],class{load(t){return t.loader.fetch(t.url,"json",t.progress.createCallback(),t.options).then(t=>t?new Vh(t,e.TextResourceFormat.JSON):null)}},Te.JSON),Te.registerLoader(["xml"],class{load(t){return t.loader.fetch(t.url,"xml",t.progress.createCallback(),t.options).then(t=>t?new Vh(t,e.TextResourceFormat.XML):null)}},Te.XML);Te.registerLoader(["atlas"],class{load(e){return e.loader.fetch(e.url,"json",e.progress.createCallback(.2),e.options).then(t=>{if(!t)return null;let r=[];if(t.meta&&t.meta.image){let s="",i=e.url.lastIndexOf("/");-1!=i&&(s=e.url.substring(0,i+1));let a="";i=e.url.lastIndexOf("?"),-1!=i&&(a=e.url.substring(i));let n=t.meta.image.split(",");for(let t of n)t.startsWith("res://")||(t=s+t+a),r.push(e.loader.load(t,null,e.progress.createCallback()))}else r.push(e.loader.load(Q.replaceFileExtension(e.url,"png"),null,e.progress.createCallback()));return Promise.all(r).then(r=>{var s,i;r=r.filter(e=>null!=e);let a=e.options.baseUrl||"",n=t.frames,o=t.meta&&null!=t.meta.prefix?t.meta.prefix:e.url.substring(0,e.url.lastIndexOf("."))+"/",l=[],h=1;t.meta&&t.meta.scale&&1!=t.meta.scale&&(h=parseFloat(t.meta.scale));for(let e of r)e.scaleRate=h;for(let t in n){let s=n[t],i=r[s.frame.idx?s.frame.idx:0];if(!i)continue;let h=a+o+(s.filename||t),u=ie.create(i,s.frame.x,s.frame.y,s.frame.w,s.frame.h,s.spriteSourceSize.x,s.spriteSourceSize.y,s.sourceSize.w,s.sourceSize.h);u._sizeGrid=s.sizeGrid,u._stateNum=s.stateNum,e.loader.cacheRes(h,u),u.url=h,l.push(u)}let u=e.obsoluteInst;return u?(u.update(r,l),u.dir=o,u.animation=t.animation,u.userData=null===(s=t.meta)||void 0===s?void 0:s.userData,u.event("reload"),u):(u=new oe(o,r,l),u.animation=t.animation,u.userData=null===(i=t.meta)||void 0===i?void 0:i.userData,u)})})}},Te.ATLAS,!0);class zh{load(e){let t=e.url,r="gltf"==e.ext||"fbx"==e.ext||"glb"==e.ext||"obj"==e.ext;return r&&(t=J.inst.getSubAssetURL(t,e.uuid,"0","lh")),e.loader.fetch(t,"json",e.progress.createCallback(.2),e.options).then(t=>t?null!=t._$ver?this._load(hl.v3,e,t,r):"ls"==e.ext||"lh"==e.ext?this._load(hl.v2,e,t,r):"scene"==e.ext||"prefab"==e.ext?this._load(hl.legacySceneOrPrefab,e,t,r):null:null)}_load(e,t,r,s){let i=ee.getPath(t.url),a=e.collectResourceLinks(r,i),n=Object.assign({},t.options);n.initiator=t,delete n.cache,delete n.ignoreCache;let o,l=a.filter(e=>e.preload);return l.length>0?(a=a.filter(e=>!e.preload),o=t.loader.load(l,n,t.progress.createCallback(.2)).then(e=>t.loader.load(a,n,t.progress.createCallback(.8)).then(t=>(e.push(...t),e)))):o=t.loader.load(a,n,t.progress.createCallback()),o.then(t=>{let i=new hl(e,r);return i.fromDCC=s,i.onLoad(),i.addDeps(t),i})}}Te.registerLoader(["lh","ls","scene","prefab"],zh,Te.HIERARCHY);class Hh{static _parseHDRTexture(e,t=null,r=null){let s=Hh.getHDRInfo(e),i=new Hi(s.width,s.height,s.format,!1,!1,!1);return i.setHDRData(s),t&&(null!=t.wrapModeU&&(i.wrapModeU=t.wrapModeU),null!=t.wrapModeV&&(i.wrapModeV=t.wrapModeV),null!=t.filterMode&&(i.filterMode=t.filterMode),null!=t.anisoLevel&&(i.anisoLevel=t.anisoLevel)),i}static getHDRInfo(t){let r=new Uint8Array(t),s=0;const i=()=>{let e=Hh.getLineString(r,s);return s+=e.length+1,e};if("#?RADIANCE"!=i())throw"HDR image: identifier wrong.";let a=new Map,n="";do{if(n=i(),"#"!=n[0]){let e=n.split("=");a.set(e[0],e[1])}}while(""!=n);if("32-bit_rle_rgbe"!=a.get("FORMAT"))throw"HDR image: unsupported format.";let o=i().split(" "),l="-Y"==o[0],h="-X"==o[2],u=parseInt(o[1]),d=parseInt(o[3]);return new Hh(t,s,h,l,d,u,e.TextureFormat.R32G32B32A32)}static getLineString(e,t){let r=e.length,s=t,i="",a="";for(;s<r&&"\n"!=a;)i=`${i}${a}`,a=String.fromCharCode(e[s]),s++;return i}constructor(e,t,r,s,i,a,n){this.source=e,this.byteOffset=t,this.decreaseX=r,this.decreaseY=s,this.width=i,this.height=a,this.format=n}get_32_bit_rle_rgbe(){let e=this.width,t=this.height;this.decreaseX,this.decreaseY;let r=new Uint8Array(this.source,this.byteOffset),s=0,i=new ArrayBuffer(4*e),a=new Uint8Array(i),n=new ArrayBuffer(e*t*4*3),o=new Float32Array(n);for(let i=t;i>0;i--){r[s++],r[s++];let n=r[s++]<<8|r[s++];if(n!=e)throw"HDR info: scanlineLength wrong.";let l=0;for(let e=0;e<4;e++){let t=(e+1)*n;for(;l<t;){let e=r[s++],i=r[s++];if(e>128){let r=e-128;if(r>t-l)throw"HDR info: ??";for(;r-- >0;)a[l++]=i}else{let n=e;if(0==n||n>t-l)throw"HDR info: ??";if(a[l++]=i,--n>0)for(let e=0;e<n;e++)a[l++]=r[s++]}}}for(let e=0;e<n;e++){let r=a[e],s=a[e+n],l=a[e+2*n],h=a[e+3*n],u=(t-i)*n*3+3*e;const d=(e,t)=>t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t);if(h>0){let e=d(1,h-136);o[u]=r*e,o[u+1]=s*e,o[u+2]=l*e}else o[u]=0,o[u+1]=0,o[u+2]=0}}return o}readScanLine(){let t=this.width,r=this.height,s=this.decreaseX,i=this.decreaseY,a=3;this.format==e.TextureFormat.R32G32B32A32&&(a=4);let n=new Float32Array(t*r*a),o=new Uint8Array(4*t),l=new Uint8Array(this.source,this.byteOffset),h=l.length,u=0;const d=()=>{if(u>=h)throw"HDR info: data wrong.";return l[u++]},c=()=>{throw"HDR info: data wrong."};for(let e=r-1;e>=0;e--){this.readcolors(o,d,c);for(let l=0;l<t;l++){let h=4*l,u=o[h],d=o[h+1],c=o[h+2],_=o[h+3],p=e,g=l;i&&(p=r-1-e),s&&(g=t-1-l);let m=p*t*a+g*a;if(0==_)n[m]=0,n[m+1]=0,n[m+2]=0,4==a&&(n[m+3]=1);else{let e=Wh(1,_-136);n[m]=(u+.5)*e,n[m+1]=(d+.5)*e,n[m+2]=(c+.5)*e,4==a&&(n[m+3]=1)}}}return n}readcolors(e,t,r){const s=(t,r,s)=>{e[4*t+r]=s};let i=this.width,a=t(),n=t(),o=t(),l=t();if(i<8||i>32767)this.olddreadcolors(e,t,a,n,o,l);else if(2!=a||2!=n||128&o)this.olddreadcolors(e,t,a,n,o,l);else{(o<<8|l)!=i&&r();for(let e=0;e<4;e++)for(let a=0;a<i;){let n=t();if(n>128){n&=127;let o=t();for(a+n>i&&r();n--;)s(a++,e,o)}else for(a+n>i&&r();n--;){s(a++,e,t())}}}}olddreadcolors(e,t,r,s,i,a){let n=0,o=this.width;e[0]=r,e[1]=s,e[2]=i,e[3]=a;for(let r=1;r<o;r++){let s=t(),i=t(),a=t(),o=t(),l=4*r;if(e[l]=s,e[l+1]=i,e[l+2]=a,e[l+3]=o,1==s&&1==i&&1==a){let t=l-4;for(let r=o<<n;r>0;r--)e[l]=e[t],e[l+1]=e[t+1],e[l+2]=e[t+2],e[l+3]=e[t+3];n+=8}else n=0}}color_color(e,t){let r=0;0==t.w?e.x=e.y=e.z=0:(r=Wh(1,t.w-136),e.x=t.x*r,e.y=t.y*r,e.z=t.z*r)}}function Wh(e,t){return e*Math.pow(2,t)}Hh.HDRTEXTURE="HDRTEXTURE";class Xh extends V{static createInstance(){return W.media.createVideoTexture()}constructor(){super(1,1,e.RenderTargetFormat.R8G8B8),this.allowBackground=!1,this._playing=!1,this._loaded=!1,this._frameRender=!0,this._interval=0,this._lastTimer=0,this._frameRate=0,this._useMediaFrameRate=!0,this._loop=!1,this._autoResume=!1,this._dimension=e.TextureDimension.Tex2D}get frameRate(){return this._frameRate}set frameRate(e){this._interval=e<.001?0:1e3/e,this._frameRate=e}get useMediaFrameRate(){return this._useMediaFrameRate}set useMediaFrameRate(e){this._useMediaFrameRate=e}get frameRender(){return this._frameRender}set frameRender(e){this._loaded&&(this._frameRender&&!e&&l.timer.clear(this,this.render),!this._frameRender&&e&&this._playing&&l.timer.frameLoop(1,this,this.render)),this._frameRender=e}get source(){return this._source}set source(e){this.load(e)}get currentTime(){return 0}set currentTime(e){}get volume(){return 0}set volume(e){}get muted(){return!1}set muted(e){}get readyState(){return 0}get videoWidth(){return this._width}get videoHeight(){return this._height}get duration(){return 0}get ended(){return!1}get loop(){return this._loop}set loop(e){this._loop=e}get playbackRate(){return 1}set playbackRate(e){}get paused(){return!1}canPlayType(e){return W.media.canPlayType(e)}setLoaded(t,r,s){this._width=t,this._height=r,this._loaded=!0,this._texture=f.textureContext.createTextureInternal(this._dimension,t,r,s?e.TextureFormat.R8G8B8A8:e.TextureFormat.R8G8B8,!1,!1,!1),this.wrapModeU=e.WrapMode.Clamp,this.wrapModeV=e.WrapMode.Clamp,this.filterMode=e.FilterMode.Bilinear,f.textureContext.initVideoTextureData(this._texture),this._texture.gammaCorrection=2.2,this._frameRender&&this._playing&&l.timer.frameLoop(1,this,this.render),this._playing&&this.onPlay(),this.event(c.READY,this)}render(e){if(this._loaded){if(!this._useMediaFrameRate&&!e){let e=performance.now();if(e-this._lastTimer<this._interval)return;this._lastTimer=e}this.onRender()&&this.event("videoUpdate")}}load(e){this._source=e,e?(this._texture&&(this._texture.dispose(),this._texture=null),J.inst.resolveURL(e,t=>{this._source===e&&this.onLoad(t)})):this.pause()}play(){!this._playing&&p.isPlaying&&(this._playing=!0,l.stage.on(c.BLUR,this,this.onBlur),this._loaded&&(this._frameRender&&l.timer.frameLoop(1,this,this.render),this.onPlay()))}pause(){this._autoResume=!1,this._playing&&(this._playing=!1,l.stage.off(c.BLUR,this,this.onBlur),l.timer.clear(this,this.render),this._loaded&&this.onPause())}resume(){this.play()}get gammaCorrection(){return 2.2}_getSource(){return this._texture?this._texture.resource:Hi.blackTexture._getSource()}get defaultTexture(){return Hi.blackTexture}destroy(){this._playing=!1,l.timer.clear(this,this.render),l.stage.off(c.BLUR,this,this.onBlur),this.onDestroy(),super.destroy()}onBlur(){this.allowBackground||W.media.resumeUntilGotFocus(this)}onLoad(e){}onRender(){return!1}onPlay(){}onPause(){}onDestroy(){}get currentSrc(){return this._source}get updateFrame(){return this.frameRate}set updateFrame(e){this.frameRate=e}get useFrame(){return this.useMediaFrameRate}set useFrame(e){this.useMediaFrameRate=e}}class Yh{constructor(){Mh||(Mh={"WhiteTexture.png":Hi.whiteTexture,"BlackTexture.png":Hi.blackTexture,"GrayTexture.png":Hi.grayTexture,"NormalTexture.png":Hi.normalTexture})}load(e){if(-1!=e.url.indexOf("internal/")){let t=Mh[Q.getBaseName(e.url)];if(t)return Promise.resolve(t)}let t;return e.url.startsWith("data:")||(t=J.inst.metaMap[e.url],t||!p.isPreview)?this.load2(e,t):J.inst.getMeta(e.url,e.uuid).then(t=>this.load2(e,t))}load2(t,r){var s;let i,a,n=t.ext,o=t.url;if(r){const l={format:e.TextureFormat.R8G8B8A8,file:null,ext:null};let h=l;if(r.platforms&&r.files){if(Y.platform in r.platforms){const e=r.platforms[Y.platform];h=r.files[e]}let e=R(h.format);if(e&&!f.renderEngine.getCapable(e)){const e=r.files.find(e=>{const t=R(e.format);return f.renderEngine.getCapable(t)});h=e||l}if(null==h.file){h=r.files.find(e=>e.ext===n)||l}}h.file&&(o=J.inst.getSubAssetURL(o,t.uuid,h.file,h.ext),n=h.ext),i=[0,0,h.format,r.mipmap,r.readWrite,r.sRGB],a={wrapModeU:r.wrapMode,wrapModeV:null!==(s=r.wrapModeV)&&void 0!==s?s:r.wrapMode,filterMode:r.filterMode,anisoLevel:r.anisoLevel,premultiplyAlpha:!!r.pma,hdrEncodeFormat:r.hdrEncodeFormat}}else i=t.options.constructParams,a=t.options.propertyParams;const l=e=>{var t;a&&(null!=a.wrapModeU&&(e.wrapModeU=a.wrapModeU),null!=a.wrapModeV&&(e.wrapModeV=a.wrapModeV),null==a.wrapModeV&&null==a.wrapModeU||(e.wrapModeW=null!==(t=a.wrapModeV)&&void 0!==t?t:a.wrapModeU),null!=a.filterMode&&(e.filterMode=a.filterMode),null!=a.anisoLevel&&(e.anisoLevel=a.anisoLevel))};let h=-1!=Zh.indexOf(n)?n:null;if(null!=h)return t.loader.fetch(o,"arraybuffer",t.progress.createCallback(),t.options).then(s=>{var n,o;if(!s)return null;let u;switch(h){case"dds":let t=Ui.getDDSTextureInfo(s);if(t.isCube){let e=Ee.getClass("TextureCube");if(!e)return null;{let r=!!i&&!!i[5],s=!!a&&a.premultiplyAlpha,n=new e(t.width,t.format,t.mipmapCount>1,r,s);n.setDDSData(t),l(n),u=n}}else u=Hi._parseDDS(s,a,i);break;case"ktx":let r=zi.getKTXTextureInfo(s);if(r.dimension==e.TextureDimension.Cube){let e=Ee.getClass("TextureCube");if(!e)return null;{let t=(null===(n=null==i?void 0:i[3])||void 0===n||n)&&r.mipmapCount>1,s=null!==(o=null==i?void 0:i[5])&&void 0!==o?o:r.sRGB,h=!!a&&a.premultiplyAlpha,d=new e(r.width,r.format,t,s,h);d.setKTXData(r),l(d),u=d}}else r.dimension==e.TextureDimension.Tex2D&&(u=Hi._parseKTX(s,a,i));break;case"pvr":u=Hi._parsePVR(s,a,i);break;case"hdr":u=Hh._parseHDRTexture(s,a,i);break;case"lanit.ls":u=Hi._SimpleAnimatorTextureParse(s,a,i)}let d=t.obsoluteInst;return d&&Object.getPrototypeOf(d)==Object.getPrototypeOf(u)&&(u=this.move(d,u)),a&&a.hdrEncodeFormat&&(u.hdrEncodeFormat=a.hdrEncodeFormat),r&&(u._sizeGrid=r.sizeGrid,u._stateNum=r.stateNum),u});{let e=t.options,s=a&&a.premultiplyAlpha?"premultiply":"none";return e.useWorkerLoader&&"none"===s&&(e=Object.assign({workerLoaderOptions:{premultiplyAlpha:s}},e)),t.loader.fetch(o,"image",t.progress.createCallback(),e).then(t=>f.textureContext.needBitmap?t instanceof ImageBitmap?t:createImageBitmap(t,e.workerLoaderOptions||{premultiplyAlpha:s}):t).then(e=>{if(!e)return null;let s=Hi._parseImage(e,a,i),n=t.obsoluteInst;return n&&Object.getPrototypeOf(n)==Object.getPrototypeOf(s)&&(s=this.move(n,s)),r&&(s._sizeGrid=r.sizeGrid,s._stateNum=r.stateNum),s})}}move(e,t){return e._texture=t._texture,e._format=t.format,e.width=t.width,e.height=t.height,e.obsolute=!1,delete G._idResourcesMap[t.id],e}}class qh{load(t){return t.loader.fetch(t.url,"json",t.progress.createCallback(),t.options).then(r=>{if(!r)return null;null==r.width&&(r.width=256),null==r.height&&(r.height=256),null==r.colorFormat&&(r.colorFormat=e.RenderTargetFormat.R8G8B8A8),null==r.depthFormat&&(r.depthFormat=e.RenderTargetFormat.DEPTHSTENCIL_24_8),null==r.multiSamples&&(r.multiSamples=1);let s=t.obsoluteInst;return s?s.recreate(r.width,r.height,r.colorFormat,r.depthFormat,!!r.generateMipmap,r.multiSamples,!!r.generateDepthTexture,!!r.sRGB,!!r.storage):s=new z(r.width,r.height,r.colorFormat,r.depthFormat,!!r.generateMipmap,r.multiSamples,!!r.generateDepthTexture,!!r.sRGB,!!r.storage),null!=r.anisoLevel&&(s.anisoLevel=r.anisoLevel),null!=r.filterMode&&(s.filterMode=r.filterMode),null!=r.wrapModeU&&(s.wrapModeU=r.wrapModeU),null!=r.wrapModeV&&(s.wrapModeV=r.wrapModeV),s})}}class $h{load(e){let t=e.obsoluteInst||Xh.createInstance();return t.source=e.url,Promise.resolve(t)}}const Kh={premultiplyAlpha:!0,wrapModeU:e.WrapMode.Clamp,wrapModeV:e.WrapMode.Clamp},jh=[null,null,e.TextureFormat.R8G8B8A8,!1,!1,!0];class Qh{wrapTex2D(e,t){if(!t)return null;let r=e.obsoluteInst;return r?(r.setTo(t),r.obsolute=!1,r._sizeGrid=t._sizeGrid,r._stateNum=t._stateNum,r.event("reload"),r._clipCache&&r._clipCache.forEach(e=>{e.event("reload"),e._sizeGrid=r._sizeGrid,e._stateNum=r._stateNum})):(r=new ie(t),r._sizeGrid=t._sizeGrid,r._stateNum=t._stateNum),r}load(e){var t,r,s,i,a,n;let o=e.loader.getRes(e.url,Te.TEXTURE2D);if(!o||o.obsolute){let o={url:e.url,type:Te.TEXTURE2D};return e.options.propertyParams?null!=e.options.propertyParams.premultiplyAlpha&&null!=e.options.propertyParams.wrapModeU&&null!=e.options.propertyParams.wrapModeV||(o.propertyParams=Object.assign({},Kh,e.options.propertyParams),null!==(t=(i=o.propertyParams).premultiplyAlpha)&&void 0!==t||(i.premultiplyAlpha=Kh.premultiplyAlpha),null!==(r=(a=o.propertyParams).wrapModeU)&&void 0!==r||(a.wrapModeU=Kh.wrapModeU),null!==(s=(n=o.propertyParams).wrapModeV)&&void 0!==s||(n.wrapModeV=Kh.wrapModeV)):o.propertyParams=Kh,e.options.constructParams?null==e.options.constructParams[5]&&(o.constructParams=Object.assign([],jh,e.options.constructParams)):o.constructParams=jh,e.loader.load(o,e.options,e.progress.createCallback()).then(t=>this.wrapTex2D(e,t))}return Promise.resolve(this.wrapTex2D(e,o))}}const Zh=["ktx","pvr","dds","hdr","exr","lanit.ls"],Jh=["mp4","webm"];Te.registerLoader(["tga","tif","tiff","png","jpg","jpeg","webp","rendertexture",...Jh,...Zh],Qh,Te.IMAGE,!0),Te.registerLoader([],Yh,Te.TEXTURE2D,!0),Te.registerLoader(["rendertexture"],qh,Te.TEXTURE2D,!0),Te.registerLoader(Jh,$h,Te.TEXTURE2D);Te.registerLoader(["mc"],class{load(e){return e.loader.fetch(e.url,"arraybuffer",e.progress.createCallback(),e.options).then(e=>e?vh._parse(e):null)}});Te.registerLoader(["mcc"],class{load(e){return e.loader.fetch(e.url,"json",e.progress.createCallback(.2),e.options).then(t=>{let r=new Fh(t);if(r.data&&r.data.controllerLayers){let t=r.data.controllerLayers,s=[];for(let r=t.length-1;r>=0;r--){let i=t[r].states;this.loadStates(i,s,e)}return Promise.all(s).then(e=>(r.addDeps(e),r))}return r})}loadStates(e,t,r){let s=ee.getPath(r.url);for(let i=e.length-1;i>=0;i--){if(e[i].clip&&e[i].clip._$uuid){let a=ee.getResURLByUUID(e[i].clip._$uuid);a.startsWith("res://")||(a=ee.join(s,a)),t.push(r.loader.load(a).then(t=>(e[i].clip=t,t)))}e[i].states&&this.loadStates(e[i].states,t,r)}}});class eu{load(e){return Promise.resolve(null)}}Te.registerLoader(["lighting"],eu);Te.registerLoader(["fnt"],class{load(e){let t=Q.replaceFileExtension(e.url,"png");return Promise.all([e.loader.fetch(e.url,"xml",e.progress.createCallback(.2),e.options),e.loader.load(t,e.options,e.progress.createCallback(.8))]).then(([e,t])=>{if(!e||!t)return null;let r=new El;return r.parseFont(e,t),r})}},Te.FONT);Te.registerLoader(["ttf","woff","woff2","otf"],class{load(e){return W.font.loadFont(e)}},Te.TTF);class tu{static parse(e){let t=e.props;switch(e.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":case"LAYAMATERIAL:03":let t=tu.parseLegacy(e);return t.oldparseEndEvent(),t;case"LAYAMATERIAL:04":break;default:throw new Error(`unkonwn material version: ${e.version}`)}let r,s=new Zn;s.setShaderName(t.type);for(let e in t)switch(e){case"type":case"name":break;case"defines":let o=t[e];for(let e=0,t=o.length;e<t;e++){let t=Ot.getDefineByName(o[e]);s._shaderValues.addDefine(t)}break;case"textures":let l=t[e];for(let e=0,t=l.length;e<t;e++){let t=l[e],r=t.path;r&&s._shaderValues.setTexture(Ot.propertyNameToID(t.name),Te.getBaseTexture(r))}break;case"renderQueue":r=t[e];break;case"alphaTest":s.alphaTest=t[e];break;case"materialRenderMode":s.materialRenderMode=t[e];break;default:let h=t[e],u=Ot.propertyNameToID(e);switch(u){case Ot.CULL:s.cull=h;break;case Ot.BLEND:s.blend=h;break;case Ot.BLEND_SRC:s.blendSrc=h;break;case Ot.BLEND_DST:s.blendDst=h;break;case Ot.BLEND_DST_ALPHA:s.blendDstAlpha=h;break;case Ot.BLEND_SRC_ALPHA:s.blendSrcAlpha=h;break;case Ot.BLEND_SRC_RGB:s.blendSrcRGB=h;break;case Ot.BLEND_DST_RGB:s.blendDstRGB=h;break;case Ot.DEPTH_TEST:s.depthTest=h;break;case Ot.DEPTH_WRITE:s.depthWrite=!!t[e];break;case Ot.STENCIL_TEST:s.stencilTest=h;break;case Ot.STENCIL_Op:s.stencilOp=h;break;case Ot.STENCIL_Ref:s.stencilRef=h;break;case Ot.STENCIL_WRITE:s.stencilWrite=h;break;case Ot.BLEND_EQUATION:s.blendEquation=h;break;case Ot.BLEND_EQUATION_RGB:s.blendEquationRGB=h;break;case Ot.BLEND_EQUATION_ALPHA:s.blendEquationAlpha=h;break;default:if(h.length){var n=h;switch(n.length){case 2:s._shaderValues.setVector2(u,new $e(n[0],n[1]));break;case 3:s._shaderValues.setVector3(u,new a(n[0],n[1],n[2]));break;case 4:s._shaderValues.getColor(u)?s._shaderValues.setColor(u,new y(n[0],n[1],n[2],n[3])):s._shaderValues.setVector(u,new i(n[0],n[1],n[2],n[3]));break;case 9:let e=new je;e.elements=new Float32Array(n),s._shaderValues.setMatrix3x3(u,e);break;case 16:let t=new nt;t.elements=new Float32Array(n),s._shaderValues.setMatrix4x4(u,t);break;default:s._shaderValues.setBuffer(u,n)}}else"boolean"==typeof h?s._shaderValues.setBool(u,t[e]):s._shaderValues.setNumber(u,t[e])}}return null!=r&&(s.renderQueue=r),s}static collectLinks(e,t){var r;let s=[],i=null===(r=e.props)||void 0===r?void 0:r.textures;if(i)for(let e=0,r=i.length;e<r;e++){let r=i[e],a=r.path;a&&(r.path=ee.join(t,a),s.push({url:r.path,type:Te.TEXTURE2D,constructParams:r.constructParams,propertyParams:r.propertyParams}))}return s}static parseLegacy(e){let t,r=e,s=r.props,n=s.type,o=Ee.getClass(n);switch(!o&&n&&n.startsWith("Laya.")&&(o=Ee.getClass(n.substring(5))),o?t=new o:(t=new Zn,t.setShaderName(n)),r.version){case"LAYAMATERIAL:01":case"LAYAMATERIAL:02":for(let e in s)switch(e){case"type":break;case"vectors":let r=s[e];for(let e=0,s=r.length;e<s;e++){let s=r[e],n=s.value;switch(n.length){case 2:t[s.name]=new $e(n[0],n[1]);break;case 3:t[s.name]instanceof y?t[s.name]=new y(n[0],n[1],n[2],1):t[s.name]=new a(n[0],n[1],n[2]);break;case 4:t[s.name]instanceof y?t[s.name]=new y(n[0],n[1],n[2],n[3]):t[s.name]=new i(n[0],n[1],n[2],n[3]);break;default:throw new Error("unknown material color length: "+n.length)}}break;case"colors":let n=s[e];for(let e=0,r=n.length;e<r;e++){let r=n[e],s=r.value;t[r.name]=new y(s[0],s[1],s[2],s[3])}break;case"textures":let o=s[e];for(let e=0,r=o.length;e<r;e++){let r=o[e],s=r.path;s&&(t[r.name]=Te.getBaseTexture(s))}break;case"defines":let l=s[e];for(let e=0,r=l.length;e<r;e++){let r=Ot.getDefineByName(l[e]);t._shaderValues.addDefine(r)}break;case"renderStates":let h=s[e][0];t.blend=h.blend,t.cull=this._getRenderStateParams(h.cull),t.depthTest=this._getRenderStateParams(h.depthTest),t.depthWrite=h.depthWrite,t.blendSrc=this._getRenderStateParams(h.srcBlend),t.blendDst=this._getRenderStateParams(h.dstBlend);break;case"cull":t.cull=this._getRenderStateParams(s[e]);break;case"blend":t.blend=this._getRenderStateParams(s[e]);break;case"depthWrite":t.depthWrite=!!s[e];break;case"srcBlend":case"blendSrc":t.blendSrc=this._getRenderStateParams(s[e]);break;case"dstBlend":case"blendDst":t.blendDst=this._getRenderStateParams(s[e]);break;case"depthTest":t.depthTest=this._getRenderStateParams(s[e]);break;default:t[e]=s[e]}break;case"LAYAMATERIAL:03":for(let e in s)switch(e){case"type":case"name":break;case"defines":let r=s[e];for(let e=0,s=r.length;e<s;e++){let s=Ot.getDefineByName(r[e]);t._shaderValues.addDefine(s)}break;case"textures":let n=s[e];for(let e=0,r=n.length;e<r;e++){let r=n[e],s=r.path;s&&t._shaderValues.setTexture(Ot.propertyNameToID(r.name),Te.getBaseTexture(s))}break;case"renderQueue":t.renderQueue=s[e];break;default:let o=s[e],h=Ot.propertyNameToID(e);switch(h){case Ot.CULL:t.cull=this._getRenderStateParams(o);break;case Ot.BLEND:t.blend=this._getRenderStateParams(o);break;case Ot.BLEND_SRC:t.blendSrc=this._getRenderStateParams(o);break;case Ot.BLEND_DST:t.blendDst=this._getRenderStateParams(o);break;case Ot.DEPTH_TEST:t.depthTest=this._getRenderStateParams(o);break;case Ot.DEPTH_WRITE:t.depthWrite=!!s[e];break;case Ot.BLEND_EQUATION:t.blendEquation=s[e];break;case Ot.BLEND_EQUATION_ALPHA:t.blendEquationAlpha=s[e];break;case Ot.BLEND_EQUATION_RGB:t.blendEquationRGB=s[e];break;default:if(o.length){var l=o;switch(l.length){case 2:t._shaderValues.setVector2(h,new $e(l[0],l[1]));break;case 3:t._shaderValues.setVector3(h,new a(l[0],l[1],l[2]));break;case 4:t._shaderValues.getColor(h)?t._shaderValues.setColor(h,new y(l[0],l[1],l[2],l[3])):t._shaderValues.setVector(h,new i(l[0],l[1],l[2],l[3]));break;default:throw new Error("unknown material color length: "+l.length)}}else"boolean"==typeof o?t._shaderValues.setBool(h,s[e]):t._shaderValues.setNumber(h,s[e])}}break;default:throw new Error("unknown material version: "+r.version)}return t}static _getRenderStateParams(t){switch(t){case 768:return e.BlendFactor.SourceColor;case 769:return e.BlendFactor.OneMinusSourceColor;case 774:return e.BlendFactor.DestinationColor;case 775:return e.BlendFactor.OneMinusDestinationColor;case 770:return e.BlendFactor.SourceAlpha;case 771:return e.BlendFactor.OneMinusSourceAlpha;case 772:return e.BlendFactor.DestinationAlpha;case 773:return e.BlendFactor.OneMinusDestinationAlpha;case 776:return e.BlendFactor.SourceAlphaSaturate;case 32774:return e.BlendEquationSeparate.ADD;case 32778:return e.BlendEquationSeparate.SUBTRACT;case 32779:return e.BlendEquationSeparate.REVERSE_SUBTRACT;case 512:return e.CompareFunction.Never;case 513:return e.CompareFunction.Less;case 514:return e.CompareFunction.Equal;case 515:return e.CompareFunction.LessEqual;case 516:return e.CompareFunction.Greater;case 517:return e.CompareFunction.NotEqual;case 518:return e.CompareFunction.GreaterEqual;case 519:return e.CompareFunction.Always;default:return t}}}class ru{load(e){return e.loader.fetch(e.url,"json",e.progress.createCallback(.3),e.options).then(t=>{if(!t)return null;let r=ee.getPath(e.url),s=tu.collectLinks(t,r);if("LAYAMATERIAL:04"===t.version){let i=t.props.type;if(!Ot.find(i)){let a=J.inst.shaderName_to_URL(i);if(!a)return J.inst.shaderName_to_URL_async(i).then(a=>(a?s.push(a):t.props.shaderPath?s.push(ee.join(r,t.props.shaderPath)):Te.warn(`unknown shaderName: ${i}`),this.load2(e,t,s)));s.push(a)}}return this.load2(e,t,s)})}load2(e,t,r){if(0==r.length){let r=tu.parse(t),s=e.obsoluteInst;return s&&(r=this.move(s,r)),Promise.resolve(r)}let s=Object.assign({},e.options);return s.initiator=e,delete s.cache,delete s.ignoreCache,e.loader.load(r,s,e.progress.createCallback()).then(()=>{let r=tu.parse(t),s=e.obsoluteInst;return e.obsoluteInst&&(r=this.move(s,r)),r})}move(e,t){return e._shaderValues.clearData(),e.setShaderName(t._shader.name),t._shaderValues.cloneTo(e._shaderValues),e.materialRenderMode=t.materialRenderMode,e.renderQueue=t.renderQueue,e.obsolute=!1,t.destroy(),e}}Te.registerLoader(["lmat"],ru,Te.MATERIAL,!0);class su{load(e){return e.loader.fetch(e.url,"json",e.progress.createCallback(.2),e.options).then(t=>{if(!t)return null;if(1!==t._$ver)return Te.warn(`Unsupported ScriptableObject version '${t._$ver}' in '${e.url}'.`),null;let r=t._$type;if(!r)return Te.warn(`Missing ScriptableObject type in '${e.url}'.`),null;let s=hl.v3.collectResourceLinks(t,ee.getPath(e.url)),i=Object.assign({},e.options);return i.initiator=e,delete i.cache,delete i.ignoreCache,e.loader.load(s,i,e.progress.createCallback(.8)).then(s=>{let i,a=Ee.getClass(r);if(!a)return Te.warn(`Unknown ScriptableObject type '${r}' in '${e.url}'.`),null;if(!(a.prototype instanceof Ah))return Te.warn(`Type '${r}' in '${e.url}' must extend ScriptableObject.`),null;try{i=pl.decodeObj(t)}catch(t){return Te.warn(`Failed to deserialize ScriptableObject '${e.url}': ${(null==t?void 0:t.message)||t}`),null}return i instanceof Ah?(i.addDeps(s),i):(Te.warn(`Failed to deserialize ScriptableObject '${e.url}'.`),null)})})}}Te.registerLoader(["sco"],su);class iu{static parse(e){return this.parseStart(e)}static findIndex(e,t,r,s){var i=e.indexOf(r,t+1);return 0>i&&(i=s),{str:e.substring(t+1,i),i:i}}static finCurrObj(){if(this.type=1,null==this.cobj)return null;if(0==this.currArr.length)return this.cobj.k&&(this.ret[this.cobj.k]=this.cobj.val),null;var e=this.currArr.pop();if(this.cobj.k)if(Array.isArray(e.val)){if(null!=this.cobj.k){var t={};t[this.cobj.k]=this.cobj.val,e.val.push(t)}}else e.val[this.cobj.k]=this.cobj.val;else Array.isArray(this.cobj.val)&&(Array.isArray(e.val)?e.val.push(this.cobj.val):e.val=this.cobj.val);return e}static formatVal(e){if(null==e)return null;var t=Number(e);return isNaN(t)?"false"!=e.toLowerCase()&&("true"==e.toLowerCase()||("null"==e?null:e)):t}static finCurrStr(){null!=this.currStr&&(this.currStr=this.currStr.trim(),""!=this.currStr&&(null!=this.cobj&&(Array.isArray(this.cobj.val)?this.cobj.val.push(this.formatVal(this.currStr)):(this.cobj.val=this.formatVal(this.currStr),this.cobj=this.finCurrObj())),this.currStr=""))}static parseStart(e){this.len=e.length;var t=0;for(this.ret={},this.currStr=null,this.currArr=[],this.cobj=null,this.type=0;t<this.len;){var r=e.charAt(t);if("/"==r){if(t+1<this.len){t+=1;var s=e.charAt(t),i=null;if("/"==s?i="\n":"*"==s&&(i="*/"),null!=i){this.finCurrStr();var a=e.indexOf(i,t);0>a?(console.log("没有找到注释结尾,应该是一直注释到最后了"),t=this.len):t=a+i.length-1}}}else if("}"==r)null!=this.cobj&&(this.finCurrStr(),null!=this.cobj&&(this.cobj=this.finCurrObj())),this.currStr="",this.type=1;else if("{"==r)this.currStr="",this.type=1;else if("'"==r||'"'==r||"‘"==r||"“"==r){"‘"==r?r="’":"“"==r&&(r="”");var n=this.findIndex(e,t,r,this.len);2==this.type&&null!=this.cobj&&Array.isArray(this.cobj.val)?(null!=this.currStr&&(this.currStr=this.currStr.trim(),""!=this.currStr&&this.cobj.val.push(this.formatVal(this.currStr))),this.cobj.val.push(n.str),this.currStr=""):null!=this.currStr&&(this.currStr+=n.str),t=n.i}else if(";"==r||","==r||"\n"==r)this.finCurrStr();else if("]"==r)null!=this.currStr&&null!=this.cobj&&Array.isArray(this.cobj.val)&&(this.currStr=this.currStr.trim(),""!=this.currStr&&this.cobj.val.push(this.formatVal(this.currStr))),null!=this.cobj&&(this.cobj=this.finCurrObj(),this.cobj=this.finCurrObj()),this.currStr="";else if("["==r)2!=this.type?console.warn("没有key值,忽略掉一个数组"):(null!=this.cobj&&this.currArr.push(this.cobj),this.cobj={val:[]});else if(":"==r){if(null!=this.currStr&&1==this.type){if(this.type=2,null!=this.cobj&&this.currArr.push(this.cobj),null!=this.cobj&&Array.isArray(this.cobj.val)){var o=this.cobj;this.cobj={val:{}},o.val.push(this.cobj.val),this.currArr.push(this.cobj)}this.cobj={k:this.currStr.trim(),val:{}},this.currStr=""}}else null!=this.currStr&&(this.currStr+=r);t++}return this.ret}}const au=["GLSL Start","GLSL End"],nu=["#defineGLSL","#endGLSL"],ou=["Shader3D Start","Shader3D End"],lu=["Sprite2DGlobal","Global"],hu={Color:e.ShaderDataType.Color,Int:e.ShaderDataType.Int,Bool:e.ShaderDataType.Bool,Float:e.ShaderDataType.Float,Vector2:e.ShaderDataType.Vector2,Vector3:e.ShaderDataType.Vector3,Vector4:e.ShaderDataType.Vector4,Vector4u:e.ShaderDataType.Vector4u,Matrix4x4:e.ShaderDataType.Matrix4x4,Matrix3x3:e.ShaderDataType.Matrix3x3,Texture2D:e.ShaderDataType.Texture2D,TextureCube:e.ShaderDataType.TextureCube,Texture2DArray:e.ShaderDataType.Texture2DArray,Texture3D:e.ShaderDataType.Texture3D,StorageTexture2D:e.ShaderDataType.StorageTexture2D,StorageBuffer:e.ShaderDataType.DeviceBuffer},uu={float:"Float",int:"Int",bool:"Bool",vec2:"Vector2",vec3:"Vector3",vec4:"Vector4",uvec4:"Vector4u",mat3:"Matrix3x3",mat4:"Matrix4x4",sampler2D:"Texture2D",sampler2DShadow:"Texture2D",sampler3D:"Texture3D",samplerCube:"TextureCube",samplerCubeShadow:"TextureCube",sampler2DArray:"Texture2DArray",sampler2DArrayShadow:"Texture2DArray"},du=/\buniform\s+(?:(?:lowp|mediump|highp)\s+)?(\w+)\s+(\w+)\s*(?:\[\s*(\d+)\s*\])?\s*;/gm;class cu{static parse(e,t){let r=cu.getShaderBlock(e),s=cu.getCGBlock(e);return cu.bindCG(r,s),Ot.parse(r,t)}static compileToTree(e,t,r){if(r==e.length)return[t];let s=e[r],i=t.split(s);if(1==i.length)return i;let a=[];for(let t=0,n=i.length;t<n;t++)a=a.concat(cu.compileToTree(e,i[t],r+1)),t!=n-1&&a.push(s);return a}static getMapKey(e){let t=e.indexOf("\n");return e=(e=(e=e.slice(0,t).replace("\r","")).slice(0,t).replace(" ","")).trim()}static getShaderBlock(t){var r,s;let i=null;try{let a=t.indexOf(ou[0]);if(-1==a)throw new Error(`no '${ou[0]}' tag`);let n=t.indexOf(ou[1]);if(-1==n)throw new Error(`no '${ou[1]}' tag`);let o=t.substring(a+ou[0].length,n);i=iu.parse(o),"string"==typeof i.shaderType?i.shaderType=null!==(r=e.ShaderFeatureType[i.shaderType])&&void 0!==r?r:e.ShaderFeatureType.None:i.shaderType=null!==(s=i.shaderType)&&void 0!==s?s:e.ShaderFeatureType.None,i.shaderType===e.ShaderFeatureType.D2_primitive&&(i.shaderType=e.ShaderFeatureType.D2_TextureSV),i.previewType=i.previewType||null}catch(e){console.error("Shader parse error: "+e+"\n"+t.substring(0,100)+"...")}return i}static getCGBlock(e){let t={};try{let r=e.indexOf(au[0]);if(-1==r)throw new Error(`no '${ou[0]}' tag`);let s=e.indexOf(au[1]);if(-1==s)throw new Error(`no '${ou[1]}' tag`);let i=e.substring(r,s),a=cu.compileToTree(nu,i,0);for(let e=0,r=a.length;e<r;e++){if(a[e]==nu[0]){e+=1;let r=a[e];t[cu.getMapKey(r)]=r.slice(r.indexOf("\n"),r.length-1)}}}catch(t){console.error("Shader parse error: "+t+"\n"+e.substring(0,100)+"...")}return t}static bindCG(t,r){var s,i,a;let n=t.shaderPass;n&&n.forEach(e=>{e.VS&&(e.VS=r[e.VS]),e.FS&&(e.FS=r[e.FS])}),cu.appendDirectGlslUniforms(t);let o=t.attributeMap;if(o){let e=0;for(let r in o)if(o[r]instanceof Array){let e=o[r],s=cu.getShaderDataType(e[0]);if(null==s){console.warn(`${t.name}: unkown attribute type '${e[0]}'`);continue}o[r]=[e[1],s]}else{let s=cu.getShaderDataType(o[r]);if(null==s){console.warn(`${t.name}: unkown attribute type '${o[r]}'`);continue}o[r]=[e,s],e++}}let l=t.uniformMap;if(l){let r={};t.defaultValue=r;let n={};t.uniformMap=n;for(let o in l){let h=l[o];if(!1===h.serializable)continue;let u,d,c=cu.getShaderDataType(h.type);if(null==c){console.warn(`${t.name}: unkown uniform type '${h.type}'`);continue}null!=h.default&&(r[o]=cu.getDefaultData(c,h.default)),c==e.ShaderDataType.StorageTexture2D?(u=null!==(s=h.format)&&void 0!==s?s:"rgba8",d=null!==(i=h.access)&&void 0!==i?i:"writeonly"):c==e.ShaderDataType.DeviceBuffer&&(d=null!==(a=h.access)&&void 0!==a?a:"readwrite","readonly"==d&&(c=e.ShaderDataType.ReadOnlyDeviceBuffer));let _=void 0!==u||void 0!==d?{type:c,format:u,access:d}:c;if(h.block){let e=n[h.block];e||(n[h.block]=e={}),e[o]=_}else n[o]=_}}}static appendDirectGlslUniforms(e){const t=e.uniformMap,r=e.shaderPass;if(!t||!r)return;const s=new Set;for(const e in t){s.add(e.replace(/\s*\[.*$/,""));const r=t[e];if(r&&"object"==typeof r&&null==r.type)for(const e in r)s.add(e.replace(/\s*\[.*$/,""))}for(const e of r)for(const r of[e.VS,e.FS]){if(!r)continue;let e;for(du.lastIndex=0;null!=(e=du.exec(r));){const[,r,i,a]=e;if(s.has(i))continue;const n=Ot.propertyNameToID(i);if(cu.isGlobalUniform(n)){s.add(i);continue}const o=uu[r];if(!o)continue;t[a?`${i}[${a}]`:i]={type:o},s.add(i)}}}static isGlobalUniform(e){const t=f.renderDeviceFactory;if(!t)return!1;for(const r of lu){if(t.createGlobalUniformMap(r).hasPtrID(e))return!0}return!1}static getShaderDataType(e){return hu[e]}static getDefaultData(t,r){switch(t){case e.ShaderDataType.Int:case e.ShaderDataType.Float:case e.ShaderDataType.Bool:return r;case e.ShaderDataType.Vector2:return new $e(r[0],r[1]);case e.ShaderDataType.Vector3:return new a(r[0],r[1],r[2]);case e.ShaderDataType.Vector4:return new i(r[0],r[1],r[2],r[3]);case e.ShaderDataType.Color:return new y(r[0],r[1],r[2],r[3]);case e.ShaderDataType.Matrix4x4:let t=new nt;return t.cloneByArray(r),t;case e.ShaderDataType.Matrix3x3:let s=new je;return s.cloneByArray(r),s;case e.ShaderDataType.Texture2D:let n=null;return"white"==r?n=Hi.whiteTexture:"black"==r?n=Hi.blackTexture:"gray"==r?n=Hi.grayTexture:"normal"==r&&(n=Hi.normalTexture),n;case e.ShaderDataType.TextureCube:let o=Go.grayTexture;return"white"==r?o=Go.whiteTexture:"black"==r?o=Go.blackTexture:"gray"==r&&(o=Go.grayTexture),o}}}Te.registerLoader(["shader","bps"],class{load(e){let t=e.url;return"bps"===e.ext&&(t=J.inst.getSubAssetURL(t,e.uuid,"0","shader")),e.loader.fetch(t,"text",e.progress.createCallback(),e.options).then(t=>{if(!t)return null;let r=cu.getShaderBlock(t),s=cu.getCGBlock(t);if(cu.bindCG(r,s),!r.name||!r.uniformMap)return null;let i=ee.getPath(e.url),a=r.shaderPass;return Promise.all(a.map(e=>qe.compileAsync(e.VS,e.FS,i))).then(t=>{var s;if(-1!=t.findIndex(e=>null==e))return Te.warn("some pass null "+e.url),null;let i=Ot.add(r.name,r.enableInstancing,r.supportReflectionProbe);i._supportVolumetricGI=r.supportVolumetricGI,i.shaderType=r.shaderType;let n=new Nt(r.attributeMap?r.attributeMap:Nt.DefaultAttributeMap,r.uniformMap,r.defaultValue);i.addSubShader(n);for(let e in a){let r=n._addShaderPass(t[e],a[e].pipeline);r.statefirst=null!==(s=a[e].statefirst)&&void 0!==s&&s,qe.getRenderState(a[e].renderState,r.renderState)}return i})})}});Te.registerLoader(["glsl","vs","fs"],class{load(e){let t=e.url;return e.loader.fetch(t,"text",e.progress.createCallback(),e.options).then(t=>t?qe.addInclude(e.url,t,!0):null)}});class _u{static createComputeShader(e,t,r){return _u._CompileShader[e]?_u._CompileShader[e]:new _u(e,qe.compileCompute(t),r)}constructor(e,t,r){this._cacheSharders={},this._cacheShaderHierarchy=1,this.name=e,this.node=t.node,this.uniformMaps=r.slice()}setCacheShader(e,t){for(var r=this._cacheSharders,s=e._mask,i=e._length-1,a=this._cacheShaderHierarchy-1,n=0;n<a;n++){var o=i<n?0:s[n],l=r[o];l||(r[o]=l={}),r=l}r[i<a?0:s[a]]=t}getCacheShader(e){var t=this._cacheSharders,r=e._length;r>this._cacheShaderHierarchy&&(this._resizeCacheShaderMap(t,0,r),this._cacheShaderHierarchy=r);for(var s=e._mask,i=e._length-1,a=this._cacheShaderHierarchy-1,n=0;n<a;n++){var o=i<n?0:s[n],l=t[o];l||(t[o]=l={}),t=l}var h=t[i<a?0:s[a]];return h||(h=f.renderDeviceFactory.createComputeShader({name:this.name,node:this.node,uniformMaps:this.uniformMaps,defineData:e}),this.setCacheShader(e,h)),h}_resizeCacheShaderMap(e,t,r){var s=this._cacheShaderHierarchy-1;if(t==s)for(var i in e)for(var a=e[i],n=0,o=r-s;n<o;n++)n===o-1?e[0]=a:e=e[0==n?i:0]={};else for(var i in++t,e)this._resizeCacheShaderMap(e[i],t,r)}}_u._CompileShader={};class pu{static parse(t,r){let s=cu.getShaderBlock(t),i=cu.getCGBlock(t);if(s.code&&(s.code=i[s.code]),s.uniformMaps){let t=s.uniformMaps,r={};s.defaultValue=r;let i=[];s.uniformMaps=i,t.forEach((t,a)=>{let n={};i[a]=n;for(let i in t){let a=t[i];if(!1===a.serializable)continue;let o=cu.getShaderDataType(a.type);if(null!=o){if(null!=a.default&&(r[i]=cu.getDefaultData(o,a.default)),n[i]={type:o},o==e.ShaderDataType.StorageTexture2D){let e=a.format?a.format:"rgba8",t=a.access?a.access:"writeonly";n[i].format=e,n[i].access=t}else if(o==e.ShaderDataType.DeviceBuffer){let t=a.access?a.access:"readwrite";"readonly"==t&&(n[i].type=e.ShaderDataType.ReadOnlyDeviceBuffer),n[i].access=t}}else console.warn(`${s.name}: unkown uniform type '${a.type}'`)}})}return s.name&&s.code?qe.compileComputeAsync(s.code,r).then(e=>{let t=s.name,r=s.uniformMaps,i=[];return r.forEach((e,r)=>{let s=f.renderDeviceFactory.createGlobalUniformMap(`${t}_u${r}`);i.push(s);for(let t in e){let r=t,i=gu(r);i>0&&(r=t.substring(0,t.lastIndexOf("[")));let a=Ot.propertyNameToID(r),n=e[t];i>0?s.addShaderUniformArray(a,r,n.type,i):s.addShaderUniform(a,t,n.type,{format:n.format,access:n.access})}}),e.node,e.defs,new _u(t,e,i)}):null}}function gu(e){let t=e.lastIndexOf("]"),r=e.lastIndexOf("[");if(-1!=r&&t==e.length-1){let s=e.slice(r+1,t),i=parseInt(s);if(!isNaN(i)&&i>0)return i}return 0}Te.registerLoader(["computeshader"],class{load(e){let t=e.url;return e.loader.fetch(t,"text",e.progress.createCallback(),e.options).then(t=>t?pu.parse(t,ee.getPath(e.url)):null)}},"COMPUTESHADER");Te.registerLoader(["mp3","wav","ogg"],class{load(e){return e.loader.fetch(e.url,"arraybuffer",e.progress.createCallback(),e.options).then(e=>{if(!e)return null;let t=e.byteLength;return W.media.decodeAudioData(e).then(e=>(e&&(e.__byteLength=t),e))})}},Te.SOUND);class mu extends po{get ignoreRotation(){return this._ignoreRotation}set ignoreRotation(e){this._ignoreRotation=e}get isMain(){return this._isMain}set isMain(e){this._ownerArea&&(e?(this._ownerArea._setMainCamera(this),this._isMain=!0):this._ownerArea.mainCamera==this&&(this._ownerArea._setMainCamera(null),this._isMain=!1)),this._isMain=e}_setUnBelongScene(){null!=this._ownerArea&&(this._ownerArea.mainCamera==this&&this._ownerArea._setMainCamera(null),this._ownerArea=null),super._setUnBelongScene()}_findOwnerArea(){let e=this;for(;e&&e!==this._scene&&e!==l.stage;){if(0!==(e._renderType&Mr.AREA2D)){this._ownerArea=e,this._isMain&&!this._ownerArea.mainCamera&&this._ownerArea._setMainCamera(this);break}e=e._parent}}get zoom(){return this._zoom}set zoom(e){e&&(e.cloneTo(this._zoom),this._struct.setRepaint(),this.parentRepaint())}get limit_Left(){return this._limit_Left}set limit_Left(e){this._limit_Left=e}get limit_Right(){return this._limit_Right}set limit_Right(e){this._limit_Right=e}get limit_Bottom(){return this._limit_Bottom}set limit_Bottom(e){this._limit_Bottom=e}get limit_Top(){return this._limit_Top}set limit_Top(e){this._limit_Top=e}get positionSmooth(){return this._positionSmooth}set positionSmooth(e){this._positionSmooth=e}get positionSpeed(){return this._positionSpeed}set positionSpeed(e){this._positionSpeed=e}get dragHorizontalEnable(){return this._dragHorizontalEnable}set dragHorizontalEnable(e){this._dragHorizontalEnable=e}get dragVerticalEnable(){return this._dragVerticalEnable}set dragVerticalEnable(e){this._dragVerticalEnable=e}get drag_Left(){return this._drag_Left}set drag_Left(e){this._drag_Left=e}get drag_Right(){return this._drag_Right}set drag_Right(e){this._drag_Right=e}get drag_Top(){return this._drag_Top}set drag_Top(e){this._drag_Top=e}get drag_Bottom(){return this._drag_Bottom}set drag_Bottom(e){this._drag_Bottom=e}get cameraMatrix(){return this._cameraMatrix}getCameraPos(){return this._cameraPos}constructor(){super(),this._cameraPos=new $e,this._cameraSmoothPos=new $e,this._firstUpdate=!0,this._cameraMatrix=new je,this._cameraInvertMatrix=new je,this._ignoreRotation=!0,this.visiableLayer=-1,this._viewRect=new $e,this._limit_Left=-1e7,this._limit_Right=1e7,this._limit_Top=-1e7,this._limit_Bottom=1e7,this._drag_Left=.2,this._drag_Right=.2,this._drag_Top=.2,this._drag_Bottom=.2,this._positionSmooth=!1,this._rect=new i,this._zoom=new $e(1,1)}_getScreenSize(){return this._viewRect.setValue(jn.width,jn.height),this._viewRect}onEnable(){this.on(c.TRANSFORM_CHANGED,this,this._onTransChanged)}onDisable(){this.off(c.TRANSFORM_CHANGED,this,this._onTransChanged)}_onTransChanged(e){this._struct.setRepaint(),this.parentRepaint()}_getCameraTransform(){let e=this._getScreenSize(),t=d.TEMP;this.globalTrans.getPos(t);let r=.5*e.x*this._zoom.x,s=.5*e.y*this._zoom.y;if(this._firstUpdate)this._cameraSmoothPos.x=this._cameraPos.x=t.x,this._cameraSmoothPos.y=this._cameraPos.y=t.y,this._firstUpdate=!1;else{this._dragHorizontalEnable?(this._cameraPos.x=Math.min(this._cameraPos.x,t.x+r*this._drag_Left),this._cameraPos.x=Math.max(this._cameraPos.x,t.x-r*this._drag_Right)):this._cameraPos.x=t.x,this._dragVerticalEnable?(this._cameraPos.y=Math.min(this._cameraPos.y,t.y+s*this._drag_Top),this._cameraPos.y=Math.max(this._cameraPos.y,t.y-s*this._drag_Bottom)):this._cameraPos.y=t.y;let e=this._cameraPos.x-r,i=e+2*r,a=this._cameraPos.y-s,n=a+2*s;if(e<this._limit_Left&&(this._cameraPos.x-=e-this._limit_Left),i>this._limit_Right&&(this._cameraPos.x-=i-this._limit_Right),n>this._limit_Bottom&&(this._cameraPos.y-=n-this._limit_Bottom),a<this._limit_Top&&(this._cameraPos.y-=a-this._limit_Top),this._positionSmooth){let e=.01,t=Math.max(e,Math.min(1,.16*this._positionSpeed)),r=1-Math.pow(1-t,Math.max(0,l.timer.delta)/(1e3/60)),s=this._cameraPos.x-this._cameraSmoothPos.x,i=this._cameraPos.y-this._cameraSmoothPos.y,a=s*r,n=i*r;Math.abs(s*t)<e&&Math.abs(i*t)<e?(this._cameraSmoothPos.x=this._cameraPos.x,this._cameraSmoothPos.y=this._cameraPos.y):(this._cameraSmoothPos.x+=a,this._cameraSmoothPos.y+=n)}else this._cameraSmoothPos.x=this._cameraPos.x,this._cameraSmoothPos.y=this._cameraPos.y}return this.ignoreRotation?this._cameraRotation=0:this.rotationSmooth||(this._cameraRotation=this.globalTrans.rotation),this._rect.setValue(this._cameraSmoothPos.x-r,this._cameraSmoothPos.x+r,this._cameraSmoothPos.y-s,this._cameraSmoothPos.y+s),je.createMatrixFromValue(this._cameraSmoothPos,this._cameraRotation*Math.PI/180,this._zoom,this._cameraMatrix),this._cameraMatrix.invert(this._cameraInvertMatrix),this._cameraInvertMatrix}}class fu{}fu.Blend=0,fu.Fixed=1;class Tu{get maxColorRGBKeysCount(){return this._maxColorRGBKeysCount}get colorRGBKeysCount(){return this._colorRGBKeysCount}get _rgbElements(){return this._rgbElementDatas}set _rgbElements(e){this._rgbElementDatas=e,this._maxColorRGBKeysCount=e?e.length/4:0}get maxColorAlphaKeysCount(){return this._maxColorAlphaKeysCount}get colorAlphaKeysCount(){return this._colorAlphaKeysCount}get _alphaElements(){return this._alphaElementDatas}set _alphaElements(e){this._alphaElementDatas=e,this._maxColorAlphaKeysCount=e?e.length/2:0}get maxColorKeysCount(){return Math.max(this._maxColorAlphaKeysCount,this._maxColorRGBKeysCount)}get mode(){return this._mode}set mode(e){this._mode=e}constructor(){this._mode=0,this._maxColorRGBKeysCount=0,this._colorRGBKeysCount=0,this._maxColorAlphaKeysCount=0,this._colorAlphaKeysCount=0,this._keyRanges=new i(1,0,1,0)}addColorRGB(e,t){if(this._colorRGBKeysCount>=this._maxColorRGBKeysCount){let e=new Float32Array(4*(this._maxColorRGBKeysCount+4));this._rgbElementDatas&&e.set(this._rgbElementDatas),this._rgbElements=e}let r=4*this._colorRGBKeysCount;this._rgbElementDatas[r]=e,this._rgbElementDatas[r+1]=t.r,this._rgbElementDatas[r+2]=t.g,this._rgbElementDatas[r+3]=t.b,this._colorRGBKeysCount++}addColorAlpha(e,t){if(this._colorAlphaKeysCount>=this._maxColorAlphaKeysCount){let e=new Float32Array(2*(this._maxColorAlphaKeysCount+4));this._alphaElementDatas&&e.set(this._alphaElementDatas),this._alphaElements=e}let r=2*this._colorAlphaKeysCount;this._alphaElementDatas[r]=e,this._alphaElementDatas[r+1]=t,this._colorAlphaKeysCount++}updateColorRGB(e,t,r){if(e<this._colorRGBKeysCount){var s=4*e;this._rgbElements[s]=t,this._rgbElements[s+1]=r.r,this._rgbElements[s+2]=r.g,this._rgbElements[s+3]=r.b,this._gpuRGBData4&&e<4&&(this._gpuRGBData4[s]=t,this._gpuRGBData4[s+1]=r.r,this._gpuRGBData4[s+2]=r.g,this._gpuRGBData4[s+3]=r.b),this._gpuRGBData8&&e<8&&(this._gpuRGBData8[s]=t,this._gpuRGBData8[s+1]=r.r,this._gpuRGBData8[s+2]=r.g,this._gpuRGBData8[s+3]=r.b)}else console.warn("Gradient:warning:index must lessEqual than colorRGBKeysCount:"+this._colorRGBKeysCount)}updateColorAlpha(e,t,r){if(e<this._colorAlphaKeysCount){var s=2*e;this._alphaElements[s]=t,this._alphaElements[s+1]=r,this._gpuAlphaData4&&e<4&&(this._gpuAlphaData4[s]=t,this._gpuAlphaData4[s+1]=r),this._gpuAlphaData8&&e<8&&(this._gpuAlphaData8[s]=t,this._gpuAlphaData8[s+1]=r)}else console.warn("Gradient:warning:index must lessEqual than colorAlphaKeysCount:"+this._colorAlphaKeysCount)}evaluateColorRGB(e,t,r=0,s=!1){e=Math.min(Math.max(e,0),1);var i=this._rgbElementDatas;!i&&(i=this._rgbElementDatas=new Float32Array(0));var a=r;if(s)for(var n=a;n>=0;n--){var o=4*n;if(e===(_=i[o]))return t.r=i[o+1],t.g=i[o+2],t.b=i[o+3],a;var l=i[o+4];switch(this._mode){case fu.Blend:if(e>_&&l){if(e>l)continue;var h=l-_,u=l-e,d=e-_;return t.r=(u*i[o+1]+d*i[o+5])/h,t.g=(u*i[o+2]+d*i[o+6])/h,t.b=(u*i[o+3]+d*i[o+7])/h,a}a--;continue;case fu.Fixed:if(e>_){if(e>i[o+4])throw"Gradient:wrong startSearchIndex.";return t.r=i[o+5],t.g=i[o+6],t.b=i[o+7],a}a--;continue;default:throw"Gradient:unknown mode."}}else{n=0;for(var c=this._rgbElements.length;n<c;n++){if(e===(l=i[o=4*n]))return t.r=i[o+1],t.g=i[o+2],t.b=i[o+3],a;switch(this._mode){case fu.Blend:if(e<l){var _;if(e<(_=i[o-4]))throw"Gradient:wrong startSearchIndex.";h=l-_,u=l-e,d=e-_;return t.r=(u*i[o-3]+d*i[o+1])/h,t.g=(u*i[o-2]+d*i[o+2])/h,t.b=(u*i[o-1]+d*i[o+3])/h,a}a++;continue;case fu.Fixed:if(e<l){if(e<i[o-4])throw"Gradient:wrong startSearchIndex.";return t.r=i[o+1],t.g=i[o+2],t.b=i[o+3],a}a++;continue;default:throw"Gradient:unknown mode."}}}return a}evaluateColorAlpha(e,t,r=0,s=!1){e=Math.min(Math.max(e,0),1);var i=this._alphaElementDatas;!i&&(i=this._alphaElementDatas=new Float32Array(0));var a=r;if(s)for(var n=a;n>=0;n--){if(e===(_=i[c=2*n]))return t.a=i[c+1],a;var o=i[c+2];switch(this._mode){case fu.Blend:if(e>_&&o){if(e>o)continue;var l=o-_,h=o-e,u=e-_;return t.a=(h*i[c+1]+u*i[c+3])/l,a}a--;continue;case fu.Fixed:if(e>_){if(e>i[c+2])throw"Gradient:wrong startSearchIndex.";return t.a=i[c+3],a}a--;continue;default:throw"Gradient:unknown mode."}}else{n=a;for(var d=this._alphaElements.length;n<d;n++){var c;if(e===(o=i[c=2*n]))return t.a=i[c+1],a;switch(this._mode){case fu.Blend:if(e<o){var _;if(e<(_=i[c-2]))throw"Gradient:wrong startSearchIndex.";l=o-_,h=o-e,u=e-_;return t.a=(h*i[c-1]+u*i[c+1])/l,a}a++;continue;case fu.Fixed:if(e<o){if(e<i[c-2])throw"Gradient:wrong startSearchIndex.";return t.a=i[c+1],a}a++;continue;default:throw"Gradient:unknown mode."}}}return a}_updateGpuData(e,t){let r=Math.min(e.length,t.length);for(let s=0;s<r;s++)e[s]=t[s]}_fixGPUAlphaData(e){if(1==this.colorAlphaKeysCount){let t=this._alphaElements[1];e[0]=0,e[1]=t,e[2]=1,e[3]=t}else 2==this.colorAlphaKeysCount?(e[0]=0,e[1]=this._alphaElements[1],e[2]=1,e[3]=this._alphaElements[3]):this._updateGpuData(e,this._alphaElements)}_fixGPURGBData(e){if(1==this.colorRGBKeysCount){let t=this._rgbElements[1],r=this._rgbElements[2],s=this._rgbElements[3];e[0]=0,e[1]=t,e[2]=r,e[3]=s,e[4]=1,e[5]=t,e[6]=r,e[7]=s}else 2==this.colorRGBKeysCount?(e[0]=0,e[1]=this._rgbElements[1],e[2]=this._rgbElements[2],e[3]=this._rgbElements[3],e[4]=1,e[5]=this._rgbElements[5],e[6]=this._rgbElements[6],e[7]=this._rgbElements[7]):this._updateGpuData(e,this._rgbElements)}_getGPURGBData4(){return this._gpuRGBData4||(this._gpuRGBData4=new Float32Array(16)),this._fixGPURGBData(this._gpuRGBData4),this._gpuRGBData4}_getGPURGBData8(){return this._gpuRGBData8||(this._gpuRGBData8=new Float32Array(32)),this._fixGPURGBData(this._gpuRGBData8),this._gpuRGBData8}_getGPUAlphaData4(){return this._gpuAlphaData4||(this._gpuAlphaData4=new Float32Array(8)),this._fixGPUAlphaData(this._gpuAlphaData4),this._gpuAlphaData4}_getGPUAlphaData8(){return this._gpuAlphaData8||(this._gpuAlphaData8=new Float32Array(16)),this._fixGPUAlphaData(this._gpuAlphaData8),this._gpuAlphaData8}cloneTo(e){e._colorAlphaKeysCount=this._colorAlphaKeysCount;var t=this._alphaElementDatas;if(t){let r=e._alphaElements=new Float32Array(t.length);for(let e=0,s=t.length;e<s;e++)r[e]=t[e]}e._colorRGBKeysCount=this._colorRGBKeysCount;var r=this._rgbElementDatas;if(r){var s=e._rgbElements=new Float32Array(r.length);for(let e=0,t=r.length;e<t;e++)s[e]=r[e]}}clone(){var e=new Tu;return this.cloneTo(e),e}}var yu,xu;e.WeightedMode=void 0,(yu=e.WeightedMode||(e.WeightedMode={}))[yu.None=0]="None",yu[yu.In=1]="In",yu[yu.Out=2]="Out",yu[yu.Both=3]="Both";class Su{constructor(){}cloneTo(e){e.time=this.time}clone(){var e=new Su;return this.cloneTo(e),e}}Su.defaultWeight=.33333;class Eu extends Su{constructor(){super(),this.inWeight=Su.defaultWeight,this.outWeight=Su.defaultWeight,this.weightedMode=e.WeightedMode.None}cloneTo(e){super.cloneTo(e),e.inTangent=this.inTangent,e.outTangent=this.outTangent,e.value=this.value,e.inTangent=this.inTangent,e.outTangent=this.outTangent,e.value=this.value,e.inWeight=this.inWeight,e.outWeight=this.outWeight,e.weightedMode=this.weightedMode}clone(){let e=new Eu;return this.cloneTo(e),e}}e.CurveWrapMode=void 0,(xu=e.CurveWrapMode||(e.CurveWrapMode={}))[xu.Clamp=0]="Clamp",xu[xu.Loop=1]="Loop",xu[xu.PingPong=2]="PingPong";class vu{constructor(){this.preWrapMode=e.CurveWrapMode.Clamp,this.postWrapMode=e.CurveWrapMode.Clamp,this._keys=[]}get frameData(){const e=this._keys,t=e.length,r=vu._FRAME_STRIDE,s=new Array(t*r);for(let i=0;i<t;i++){const t=e[i],a=i*r;s[a]=t.time,s[a+1]=t.value,s[a+2]=t.inTangent,s[a+3]=t.outTangent,s[a+4]=t.inWeight,s[a+5]=t.outWeight,s[a+6]=t.weightedMode}return s}set frameData(e){if(this._keys.length=0,!e)return;const t=vu._FRAME_STRIDE,r=Math.floor(e.length/t);for(let s=0;s<r;s++){const r=s*t,i=new Eu;i.time=e[r],i.value=e[r+1],i.inTangent=e[r+2],i.outTangent=e[r+3],i.inWeight=e[r+4],i.outWeight=e[r+5],i.weightedMode=e[r+6],this._keys.push(i)}}get length(){return this._keys.length}get duration(){return 0===this._keys.length?0:this._keys[this._keys.length-1].time-this._keys[0].time}get startTime(){return 0===this._keys.length?0:this._keys[0].time}get endTime(){return 0===this._keys.length?0:this._keys[this._keys.length-1].time}getKey(e){return this._keys[e]}get keys(){return this._keys}addKey(e,t){let r;"number"==typeof e?(r=new Eu,r.time=e,r.value=t,r.inTangent=0,r.outTangent=0):r=e;let s=this._findInsertIndex(r.time);return this._keys.splice(s,0,r),s}removeKey(e){this._keys.splice(e,1)}clear(){this._keys.length=0}evaluate(e){return this._evaluate(e)}smoothTangents(){const e=this._keys.length;for(let t=0;t<e;t++)this.smoothTangent(t)}smoothTangent(e){const t=this._keys,r=t.length;if(r<2)return;const s=t[e];if(0===e){const e=t[1],r=(e.value-s.value)/(e.time-s.time);s.inTangent=r,s.outTangent=r}else if(e===r-1){const r=t[e-1],i=(s.value-r.value)/(s.time-r.time);s.inTangent=i,s.outTangent=i}else{const r=t[e-1],i=t[e+1],a=.5*((s.value-r.value)/(s.time-r.time)+(i.value-s.value)/(i.time-s.time));s.inTangent=a,s.outTangent=a}}flatTangent(e){const t=this._keys[e];t&&(t.inTangent=0,t.outTangent=0)}cloneTo(e){e.preWrapMode=this.preWrapMode,e.postWrapMode=this.postWrapMode,e._keys.length=0;for(let t=0,r=this._keys.length;t<r;t++)e._keys.push(this._keys[t].clone())}clone(){const e=new vu;return this.cloneTo(e),e}_evaluate(t){const r=this._keys,s=r.length;if(0===s)return 0;if(1===s)return r[0].value;const i=r[0].time,a=r[s-1].time;if(t<=i){if(this.preWrapMode===e.CurveWrapMode.Clamp||i===a)return r[0].value;t=this._wrapTime(t,i,a,this.preWrapMode)}else if(t>=a){if(this.postWrapMode===e.CurveWrapMode.Clamp||i===a)return r[s-1].value;t=this._wrapTime(t,i,a,this.postWrapMode)}const n=this._findFrameIndex(t),o=r[n],l=r[n+1],h=l.time-o.time;if(h<=0)return o.value;const u=(t-o.time)/h;return this._curveInterpolate(o,l,u,h)}_wrapTime(t,r,s,i){const a=s-r;if(a<=0)return r;switch(i){case e.CurveWrapMode.Loop:{let e=(t-r)%a;return e<0&&(e+=a),r+e}case e.CurveWrapMode.PingPong:{let e=(t-r)%(2*a);return e<0&&(e+=2*a),e>a&&(e=2*a-e),r+e}default:return t}}_findInsertIndex(e){const t=this._keys;let r=0,s=t.length;for(;r<s;){const i=r+s>>>1;t[i].time<e?r=i+1:s=i}return r}_findFrameIndex(e){const t=this._keys;let r=0,s=t.length-2;for(;r<=s;){const i=r+s>>>1;if(t[i+1].time<=e)r=i+1;else{if(!(t[i].time>e))return i;s=i-1}}return Math.max(0,Math.min(r,t.length-2))}_isStandardHermite(t,r){return 0===(t&e.WeightedMode.Out)&&0===(r&e.WeightedMode.In)}_hermiteInterpolate(e,t,r,s){const i=e.outTangent,a=t.inTangent;if(Number.isFinite(i)&&Number.isFinite(a)){const n=r*r,o=n*r,l=o-2*n+r,h=o-n,u=-2*o+3*n;return(2*o-3*n+1)*e.value+l*i*s+h*a*s+u*t.value}return e.value}_hermiteWeightedInterpolate(e,t,r,s,i,a,n,o,l){const h=222e-18,u=l,d=e,c=r,_=n,p=a-t;let g=i-d;g=Math.max(Math.abs(g),h)*(g<0?-1:1);let m=s,f=o;if(!Number.isFinite(m)||!Number.isFinite(f))return e;m=m*p/g,f=f*p/g;const T=1-_;let y=.5,x=0;if(Math.abs(c-.33333334)<1e-4&&Math.abs(_-.33333334)<1e-4)y=u,x=1-y;else for(;;){x=1-y;const e=3*x*x*y*c+3*x*y*y*T+y*y*y-u;if(Math.abs(e)<=2.5*h)break;const t=3*x*x*c+6*x*y*(T-c)+3*y*y*(1-T),r=6*x*(T-2*c)+6*y*(1-2*T+c);y-=(6*e*t*t-3*e*e*r)/(6*t*t*t-6*e*t*r+e*e*(18*c-18*T+6))}return(3*x*x*y*c*m+3*x*y*y*(1-_*f)+y*y*y)*g+d}_curveInterpolate(e,t,r,s){return!e.weightedMode||this._isStandardHermite(e.weightedMode,t.weightedMode)?this._hermiteInterpolate(e,t,r,s):this._hermiteWeightedInterpolate(e.value,e.time,e.outWeight,e.outTangent,t.value,t.time,t.inWeight,t.inTangent,r)}}vu._FRAME_STRIDE=7;class Du extends po{constructor(){super(),this._renderType|=Mr.AREA2D,this._initShaderData(),this._globalRenderData=f.render2DRenderPassFactory.create2DGlobalRenderDataHandle(),this._globalRenderData.globalShaderData=this._globalShaderData=f.renderDeviceFactory.createShaderData(null),this._globalShaderData.addDefine(qo.SPRITE2DGLOBAL),this._globalRenderData.renderLayerMask=-1,this._struct.globalRenderData=this._globalRenderData}get mainCamera(){return this._mainCamera}_setMainCamera(e){e!=this._mainCamera&&p.isPlaying&&(this._mainCamera&&(this._mainCamera._isMain=!1),e?(e._isMain=!0,this._globalShaderData.addDefine(kt.SHADERDEFINE_CAMERA2D)):this._globalShaderData.removeDefine(kt.SHADERDEFINE_CAMERA2D),this._mainCamera=e)}getSelfBounds(e,t){if(this._mainCamera){e||(e=new te);let t=Ce.TEMP;this._globalTrans.getMatrixInv(t);let r=jn.width,s=jn.height,i=t.a,a=t.b,n=t.c,o=t.d,l=t.tx,h=t.ty,u=l,d=h,c=i*r+l,_=a*r+h,p=n*s+l,g=o*s+h,m=i*r+n*s+l,f=a*r+o*s+h,T=Math.min(u,c,p,m),y=Math.min(d,_,g,f),x=Math.max(u,c,p,m),S=Math.max(d,_,g,f);return e.setTo(T,y,x-T,S-y),e}return super.getSelfBounds(e,t)}render(){this._mainCamera&&this._globalShaderData&&(this._globalRenderData.renderLayerMask=this._mainCamera.visiableLayer,this._globalRenderData.cullRect=this._mainCamera._rect,this._globalShaderData.setMatrix3x3(kt.VIEW2D,this._mainCamera._getCameraTransform()))}_setBelongScene(e){super._setBelongScene(e),this._scene._area2Ds.add(this)}_setUnBelongScene(){this._scene._area2Ds.delete(this),super._setUnBelongScene()}localToView(e,t,r){return(r=r||new d).setTo(e,t),this.localToGlobal(r),this.transformPoint(r.x,r.y,r),r}transformPoint(e,t,r){if((r=r||new d).setTo(e,t),!this._mainCamera)return r;let s=.5*jn.width,i=.5*jn.height,a=e*l.stage.clientScaleX-s,n=t*l.stage.clientScaleY-i;this._mainCamera._getCameraTransform();let o=this._mainCamera.cameraMatrix.elements,h=o[0]*a+o[3]*n+o[6],u=o[1]*a+o[4]*n+o[7],c=Ce.TEMP;return this._globalTrans.getMatrixInv(c),r.x=c.a*h+c.c*u+c.tx,r.y=c.b*h+c.d*u+c.ty,r}inverseTransformPoint(e,t,r){if((r=r||new d).setTo(e,t),!this._mainCamera)return r;let s=this._globalTrans.getMatrix(),i=s.a*e+s.c*t+s.tx,a=s.b*e+s.d*t+s.ty,n=this._mainCamera._getCameraTransform().elements;return r.x=(n[0]*i+n[3]*a+n[6]+.5*jn.width)/l.stage.clientScaleX,r.y=(n[1]*i+n[4]*a+n[7]+.5*jn.height)/l.stage.clientScaleY,r}}class wu extends po{constructor(){super(),this._fps=30,this._width=this._height=200,this._widget=Yo.EMPTY;let t=new ie(new Hi(this._width,this._height,e.TextureFormat.R8G8B8A8,!1,!1,!0));t.bitmap.lock=!0,this.texture=t,this._canvas=W.browser.getOpenDataContextCanvas()}get fps(){return this._fps}set fps(e){this._fps!=e&&(this._fps=e,p.isPlaying&&this.activeInHierarchy&&this._canvas&&(l.timer.clear(this,this._onLoop),l.timer.loop(1e3/e,this,this._onLoop)))}_onActive(){p.isPlaying&&this._canvas&&l.timer.loop(1e3/this._fps,this,this._onLoop)}_onInActive(){p.isPlaying&&(this.postMsg({type:"close"}),l.timer.clear(this,this._onLoop))}get top(){return this._widget.top}set top(e){e!=this._widget.top&&(this._getWidget().top=e)}get bottom(){return this._widget.bottom}set bottom(e){e!=this._widget.bottom&&(this._getWidget().bottom=e)}get left(){return this._widget.left}set left(e){e!=this._widget.left&&(this._getWidget().left=e)}get right(){return this._widget.right}set right(e){e!=this._widget.right&&(this._getWidget().right=e)}get centerX(){return this._widget.centerX}set centerX(e){e!=this._widget.centerX&&(this._getWidget().centerX=e)}get centerY(){return this._widget.centerY}set centerY(e){e!=this._widget.centerY&&(this._getWidget().centerY=e)}_getWidget(){return this._widget===Yo.EMPTY&&(this._widget=this.addComponent(Yo)),this._widget}_onLoop(){let t=this.texture,r=this._canvas;t.width==r.width&&t.height==r.height||(t.bitmap.destroy(),t.bitmap=new Hi(r.width,r.height,e.TextureFormat.R8G8B8A8,!1,!1,!0,!0),t.bitmap.lock=!0,this._graphics.repaint()),this._canvas&&t.bitmap.setImageData(r,!0,!1)}_transChanged(t){super._transChanged(t),0!=(t&e.TransformKind.Size)&&(this._canvas&&(this._canvas.width=this._width,this._canvas.height=this._height),this._widget!==Yo.EMPTY&&this._widget.resetLayout(),this.callLater(this.updateViewPort)),0!=(t&e.TransformKind.Pos)&&this.callLater(this.updateViewPort)}updateViewPort(){let e=l.stage,t=e._canvasTransform.getScaleX()*this.scaleX*e.transform.getScaleX(),r=e._canvasTransform.getScaleY()*this.scaleY*e.transform.getScaleY();this.postMsg({type:"updateViewPort",box:{x:this.x*t,y:this.y*r,width:this.width*t,height:this.height*r}})}postMsg(e){W.browser.postMessageToOpenDataContext(e)}}class Ru{constructor(){this._active=!0,this.destroyed=!1,this._singleton=!1}get singleton(){return this._singleton}get active(){return this._active}set active(e){this._active!=e&&(this._active=e,this._owner&&this._owner._onChangeRender())}releaseInputTextureBindings(){}destroy(){this.destroyed=!0}}class Cu extends ah{constructor(){super(),this._clip=null,this._playStateInfo=new nh,this._clipState=new fh,this._defaultWeight=1,this._additive=!1,this._autoPlay=!0,this._clipState.name="ClipState",this._clipState.clipStart=0,this._clipState.clipEnd=1,this._playStateInfo._currentState=this._clipState}get clip(){return this._clip}set clip(e){if(this._clip!==e&&(this._clip&&(this._clip._removeReference(1),this._clipState.clip=null),this._clip=e,e)){e._addReference(1),this._clipState.clip=e;const t=e._duration*(this._clipState.clipEnd-this._clipState.clipStart);this._playStateInfo._resetPlayState(0,t)}}get defaultWeight(){return this._defaultWeight}set defaultWeight(e){this._defaultWeight=e}get additive(){return this._additive}set additive(e){this._additive=e}get autoPlay(){return this._autoPlay}set autoPlay(e){this._autoPlay=e}get loop(){return this._clipState.loop}set loop(e){this._clipState.loop=e}get yoyo(){return this._clipState.yoyo}set yoyo(e){this._clipState.yoyo=e}play(e){if(!this._clip)return;const t=this._clip._duration,r=t*(this._clipState.clipEnd-this._clipState.clipStart);this._updateDefVal();const s=null!=e?t*e:0;this._playStateInfo._resetPlayState(s,r),null!=e&&(this._playStateInfo._normalizedPlayTime=e),this._isPlaying=!0,this._clipState._eventStart(this,0)}stop(){this._isPlaying=!1}gotoAndStop(e){if(!this._clip)return;const t=this._clip._duration,r=t*(this._clipState.clipEnd-this._clipState.clipStart);this._updateDefVal(),this._playStateInfo._resetPlayState(t*e,r),this._playStateInfo._normalizedPlayTime=e,this._isPlaying=!1,this._updateClipDatas(this._clipState,this._additive,this._playStateInfo),this._setClipDatasToNode(this._clipState,this._additive,this._defaultWeight)}gotoAndStopByFrame(e){if(!this._clip)return;let t=e/(this._clip._duration*this._clip._frameRate);t>1&&(t=1),this.gotoAndStop(t)}onEnable(){this._autoPlay&&this._clip?this.play():this._isPlaying=!1}onUpdate(){if(!this._isPlaying||!this._clip)return;const e=this.owner.timer.delta/1e3,t=this._applyUpdateMode(e);if(0===this.speed||0===t)return;const r=this._clipState,s=this._playStateInfo,i=this.speed*r.speed,a=s._finish;let n=r.loop;n<=-1&&(n=this._clip.islooping?0:1);const o=t*i*(s._frontPlay?1:-1);a?this._updateStateFinish(r,s):this._updatePlayerTime(r,s,o,n),this._updateClipDatas(r,this._additive,s),a||(this._setClipDatasToNode(r,this._additive,this._defaultWeight),this._updateEventScript(r,s)),this._updateStateFinish(r,s)}onDestroy(){this.clip=null,this._playStateInfo._currentState=null,this._clipState.destroy(),super.onDestroy()}}let Mu=Ee.regClass;Mu("Record",Object),Mu("Node",Wa),Mu("Sprite",po),Mu("Widget",Yo),Mu("Text",Pl),Mu("Input",$l),Mu("Animation",Sl),Mu("SoundNode",jl),Mu("SoundPlayer",Kl),Mu("VideoNode",Zl),Mu("VideoPlayer",Ql),Mu("Area2D",Du),Mu("OpenDataContextView",wu),Mu("Scene",Ko),Mu("Stage",No),Mu("Component",Sn),Mu("Script",Oh),Mu("BitmapFont",El),Mu("Point",d),Mu("Rectangle",te),Mu("Texture",ie),Mu("Texture2D",Hi),Mu("Prefab",nl),Mu("ScriptableObject",Ah),Mu("Animator2D",mh),Mu("AnimatorClip2D",Cu),Mu("AnimatorControllerLayer2D",oh),Mu("AnimatorState2D",fh),Mu("AnimationClip2D",vh),Mu("AnimatorController2D",Fh),Mu("Animation2DParm",wh),Mu("Animation2DCondition",bh),Mu("FrameAnimation",xl),Mu("Vector2",$e),Mu("Vector3",a),Mu("Vector4",i),Mu("Quaternion",et),Mu("Color",y),Mu("Matrix",Ce),Mu("Matrix3x3",je),Mu("Matrix4x4",nt),Mu("Camera2D",mu),Mu("Mesh2DRender",to),Mu("SequenceFrame2DRender",Xo),Mu("BaseRenderNode2D",Dn),Mu("Mesh2D",eo),Mu("Gradient",Tu),Mu("FloatKeyframe",Eu),Mu("Curve",vu),Mu("PostProcess2D",uo),Mu("PostProcess2DEffect",Ru),Mu("SequenceFrame2DRender",Xo),Mu("COMPUTESHADER",_u);var bu,Au,Iu,Pu,Bu,Lu,Nu,Fu,Ou,Uu,ku,Gu;e.ComputeCommandType=void 0,(bu=e.ComputeCommandType||(e.ComputeCommandType={}))[bu.DispatchCompute=0]="DispatchCompute",bu[bu.SetRenderData=1]="SetRenderData",bu[bu.ClearBuffer=2]="ClearBuffer",bu[bu.CopyBufferToBuffer=3]="CopyBufferToBuffer",bu[bu.copyBufferToTexture=4]="copyBufferToTexture",bu[bu.copyTextureToBuffer=5]="copyTextureToBuffer",bu[bu.copyTextureToTexture=6]="copyTextureToTexture",e.EComputeCMDMemoryOperate=void 0,(Au=e.EComputeCMDMemoryOperate||(e.EComputeCMDMemoryOperate={}))[Au.ClearBuffer=0]="ClearBuffer",Au[Au.BufferToBuffer=1]="BufferToBuffer",Au[Au.BufferToTexture=2]="BufferToTexture",Au[Au.TextureToBuffer=3]="TextureToBuffer",Au[Au.TextureToTexture=4]="TextureToTexture";e.EDeviceBufferUsage=void 0,(Iu=e.EDeviceBufferUsage||(e.EDeviceBufferUsage={}))[Iu.MAP_READ=1]="MAP_READ",Iu[Iu.MAP_WRITE=2]="MAP_WRITE",Iu[Iu.COPY_SRC=4]="COPY_SRC",Iu[Iu.COPY_DST=8]="COPY_DST",Iu[Iu.STORAGE=16]="STORAGE",Iu[Iu.INDIRECT=32]="INDIRECT",Iu[Iu.VERTEX=64]="VERTEX",e.RenderCMDType=void 0,(Pu=e.RenderCMDType||(e.RenderCMDType={}))[Pu.DrawNode=0]="DrawNode",Pu[Pu.DrawElement=1]="DrawElement",Pu[Pu.Blit=2]="Blit",Pu[Pu.ChangeData=3]="ChangeData",Pu[Pu.ChangeShaderDefine=4]="ChangeShaderDefine",Pu[Pu.ChangeViewPort=5]="ChangeViewPort",Pu[Pu.ChangeRenderTarget=6]="ChangeRenderTarget",Pu[Pu.ComputeCommandAppatch=7]="ComputeCommandAppatch";class Vu{_dirty(){this.needUpload=!0}setInt(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeInt(r,t)}_writeInt(e,t){e.view[0]=t,this._dirty()}setBool(e,t){this.setInt(e,t?1:0)}setFloat(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeFloat(r,t)}_writeFloat(e,t){e.view[0]=t,this._dirty()}setVector2(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeVector2(r,t)}_writeVector2(e,t){e.view[0]=t.x,e.view[1]=t.y,this._dirty()}setVector3(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeVector3(r,t)}_writeVector3(e,t){e.view[0]=t.x,e.view[1]=t.y,e.view[2]=t.z,this._dirty()}setVector4(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeVector4(r,t)}_writeVector4(e,t){e.view[0]=t.x,e.view[1]=t.y,e.view[2]=t.z,e.view[3]=t.w,this._dirty()}setMatrix3x3(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeMatrix3x3(r,t)}_writeMatrix3x3(e,t){let r=t.elements;for(let t=0;t<3;t++)for(let s=0;s<3;s++)e.view[4*t+s]=r[3*t+s];this._dirty()}setMatrix4x4(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeMatrix4x4(r,t)}_writeMatrix4x4(e,t){e.view.set(t.elements),this._dirty()}setBuffer(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeBuffer(r,t)}_writeBuffer(e,t){e.view.set(t),this._dirty()}setArrayBuffer(e,t){let r=this.descriptor.uniforms.get(e);r&&this._writeArrayBuffer(r,t)}_writeArrayBuffer(e,t){let r=e.arrayLength,s=e.size,i=e.alignStride;for(let a=0;a<r;a++)e.view.set(t.subarray(a*s,(a+1)*s),a*i);this._dirty()}setMatrix3x3Array(e,t){let r=this.descriptor.uniforms.get(e);if(r){let e=r.arrayLength,s=r.alignStride;for(let i=0;i<e;i++)for(let e=0;e<3;e++)for(let a=0;a<3;a++)r.view[i*s+4*e+a]=t[9*i+3*e+a];this._dirty()}}setUniformData(t,r,s){let i=this.descriptor.uniforms.get(t);if(i)switch(r){case e.ShaderDataType.Bool:i.arrayLength>0?console.warn("ShaderDataType.Bool array not support"):this.setBool(t,s);break;case e.ShaderDataType.Int:i.arrayLength>0?this.setArrayBuffer(t,s):this.setInt(t,s);break;case e.ShaderDataType.Float:i.arrayLength>0?this.setArrayBuffer(t,s):this.setFloat(t,s);break;case e.ShaderDataType.Vector2:i.arrayLength>0?this.setArrayBuffer(t,s):this.setVector2(t,s);break;case e.ShaderDataType.Vector3:i.arrayLength>0?this.setArrayBuffer(t,s):this.setVector3(t,s);break;case e.ShaderDataType.Vector4u:case e.ShaderDataType.Vector4:case e.ShaderDataType.Color:i.arrayLength>0?this.setArrayBuffer(t,s):this.setVector4(t,s);break;case e.ShaderDataType.Matrix3x3:i.arrayLength>0?this.setMatrix3x3Array(t,s):this.setMatrix3x3(t,s);break;case e.ShaderDataType.Matrix4x4:i.arrayLength>0?this.setArrayBuffer(t,s):this.setMatrix4x4(t,s)}}}class zu extends Vu{constructor(e,t,r,s){super(),this._destroyed=!1,this._id=zu._idCounter++,this.cluster=e,this.index=t,this.size=r,this._alignedSize=s,this.offset=s*t}markDirty(){this.needUpload=!0,this.cluster._addUploadBlock(this.index)}_dirty(){this.needUpload||this.markDirty()}updateOver(){this.needUpload=!1}onRelocated(e){this.offset=this._alignedSize*this.index}destroy(){return!this._destroyed&&this.cluster.manager.freeBlock(this)}_onFreed(){this._destroyed=!0,this.cluster=null,this.descriptor=null}}function Hu(e,t){return((e+t-1)/t|0)*t}zu._idCounter=0;class Wu{constructor(e,t,r){this._inManagerUpdateArray=!1,this._sn=0,this._id=0,this._destroyed=!1,this._blocks=[],this._dirtyStartIndex=-1,this._dirtyEndIndex=-1,this._holeNum=0,this._expand=16,this._id=Wu._idCounter++,this.manager=r,this._blockSize=e,this._blockNum=t,this._totalSize=e*t,this._needUpload=new Array(t).fill(!1),this.data=new ArrayBuffer(this._totalSize),this._move=new Uint8Array(this._blockSize),this.buffer=this.manager.createGPUBuffer(this._totalSize)}get usedNum(){return this._blocks.length-this._holeNum}_expandBuffer(){let e=this._blockNum;if(this._blockNum+=this._expand,this._blockNum>this.manager.clusterMaxBlock&&(this._blockNum=this.manager.clusterMaxBlock),e=this._blockNum-e,e<1)return!1;this._totalSize=this._blockSize*this._blockNum,this._blockSize,this._expand,this._needUpload=this._needUpload.concat(new Array(e).fill(!1));const t=new ArrayBuffer(this._totalSize);new Uint8Array(t).set(new Uint8Array(this.data)),this.data=t;const r=this.buffer;return this.buffer=this.manager.createGPUBuffer(this._totalSize,null,this.data),this.manager.retireBuffer(r),this._blocks.forEach(e=>e&&e.onRelocated("expand")),this.manager._notifyBufferResourceChange(),!0}_createBufferBlock(e,t,r,s,i){const a=new zu(this,e,t,r);return a.descriptor=s,a}getBlock(e,t,r){const s=Hu(e,this.manager.byteAlign);if(s!==this._blockSize)return console.warn("WebGPUBufferCluster: 获取内存块时, 长度错误!"),null;const i=this._getBlockWithExpand(),a=this._createBufferBlock(i,e,s,t,r);return this._blocks[i]=a,a}freeBlock(e){const t=this._blocks.indexOf(e);if(-1!==t){const r=this._needUpload[t];return t===this._blocks.length-1?this._blocks.length--:(this._blocks[t]=null,this._holeNum++),this._needUpload[t]=!1,r&&this._rebuildDirtyRange(),e._onFreed(),!0}return!1}upload(){var e;if(this.manager.reduceWriteBufferCalls)return void this._uploadDirtyRange();let t=!1,r=-1,s=-1,i=0,a=0;for(let n=0,o=this._blocks.length;n<o;n++)this._needUpload[n]?(-1===r&&(r=n),s=n,t=!0,this._needUpload[n]=!1,null===(e=this._blocks[n])||void 0===e||e.updateOver()):t&&(i=r*this._blockSize,a=(s-r+1)*this._blockSize,this.manager.writeBuffer(this.buffer,this.data,i,a),r=-1,s=-1,t=!1);t&&(i=r*this._blockSize,a=(s-r+1)*this._blockSize,this.manager.writeBuffer(this.buffer,this.data,i,a)),this._dirtyStartIndex=-1,this._dirtyEndIndex=-1}_uploadDirtyRange(){var e;const t=this._dirtyStartIndex,r=this._dirtyEndIndex;if(-1===t)return;for(let s=t;s<=r;s++)this._needUpload[s]&&(this._needUpload[s]=!1,null===(e=this._blocks[s])||void 0===e||e.updateOver());this._dirtyStartIndex=-1,this._dirtyEndIndex=-1;const s=t*this._blockSize,i=(r-t+1)*this._blockSize;this.manager.writeBuffer(this.buffer,this.data,s,i)}_rebuildDirtyRange(){this._dirtyStartIndex=-1,this._dirtyEndIndex=-1;for(let e=0,t=this._blocks.length;e<t;e++)this._needUpload[e]&&(-1===this._dirtyStartIndex&&(this._dirtyStartIndex=e),this._dirtyEndIndex=e)}_addUploadBlock(e){this._needUpload[e]=!0,(-1===this._dirtyStartIndex||e<this._dirtyStartIndex)&&(this._dirtyStartIndex=e),e>this._dirtyEndIndex&&(this._dirtyEndIndex=e),this._inManagerUpdateArray||this.manager._addUpdateArray(this)}clear(e){this._blocks.forEach(e=>e&&e._onFreed()),this._blocks.length=0,this._holeNum=0,this.manager.retireBuffer(this.buffer),null!=e&&e>0&&e!==this._blockNum?(this._blockNum=e,this._totalSize=this._blockSize*this._blockNum,this.buffer=this.manager.createGPUBuffer(this._totalSize),this.data=new ArrayBuffer(this._totalSize)):(this._blockNum=0,this._totalSize=0,this.buffer=null,this.data=null),this._needUpload.length=this._blockNum,this._needUpload.fill(!1),this._dirtyStartIndex=-1,this._dirtyEndIndex=-1}_getBlockWithExpand(){for(let e=this._blocks.length-1;e>-1;e--)if(!this._blocks[e])return this._holeNum--,e;return this._blocks.length<this._blockNum||this._expandBuffer(),this._blocks.length}destroy(){return this._destroyed?(console.warn("UniformBufferCluster: object alreay destroyed!"),!1):(this._destroyed=!0,this.clear(),!0)}}Wu._idCounter=0,e.BaseRenderType=void 0,(Bu=e.BaseRenderType||(e.BaseRenderType={}))[Bu.BaseRender=0]="BaseRender",Bu[Bu.MeshRender=1]="MeshRender",Bu[Bu.ParticleRender=2]="ParticleRender",Bu[Bu.TrailRender=3]="TrailRender",Bu[Bu.LineRender=4]="LineRender",Bu[Bu.TerrainRender=5]="TerrainRender",Bu[Bu.SkyRender=7]="SkyRender",Bu[Bu.SimpleSkinRender=8]="SimpleSkinRender",Bu[Bu.SkinnedMeshRender=9]="SkinnedMeshRender",e.ENodeCustomData=void 0,(Lu=e.ENodeCustomData||(e.ENodeCustomData={}))[Lu.custom_0=0]="custom_0",Lu[Lu.custom_1=1]="custom_1",Lu[Lu.custom_2=2]="custom_2";class Xu{static create(e,t,r){}constructor(e){this.blendType=0}}Xu._blend_All_pool={},Xu._blend_seperate_pool={};class Yu{static getHash(e,t,r){return e+(t<<3)+(r<<7)}static getBlendComponent(e,t,r){let s=Yu.getHash(e,t,r);return Yu._pool[s]||(Yu._pool[s]=new Yu(e,t,r,s)),Yu._pool[s]}constructor(e,t,r,s){this._hashIndex=0,this._hashIndex=s,this._blendOperationGLData=e,this._sourceBlendFactor=t,this._destinationFactor=r}}Yu._pool={};class qu{get bufferUsage(){return this._bufferUsage}constructor(e,t){this._byteLength=0,this._bufferType=e,this._bufferUsage=t}destroy(){}}e.RenderClearFlag=void 0,(Nu=e.RenderClearFlag||(e.RenderClearFlag={}))[Nu.Nothing=0]="Nothing",Nu[Nu.Color=1]="Color",Nu[Nu.Depth=2]="Depth",Nu[Nu.Stencil=4]="Stencil",e.RenderDrawMode=void 0,(Fu=e.RenderDrawMode||(e.RenderDrawMode={}))[Fu.TRIANGLES=0]="TRIANGLES",Fu[Fu.POINTS=1]="POINTS",Fu[Fu.LINES=2]="LINES",e.RenderIndexMode=void 0,(Ou=e.RenderIndexMode||(e.RenderIndexMode={}))[Ou.UNSIGNED_BYTE=0]="UNSIGNED_BYTE",Ou[Ou.UNSIGNED_SHORT=1]="UNSIGNED_SHORT",Ou[Ou.UNSIGNED_INT=2]="UNSIGNED_INT",e.RenderStateType=void 0,(Uu=e.RenderStateType||(e.RenderStateType={}))[Uu.DepthTest=0]="DepthTest",Uu[Uu.DepthMask=1]="DepthMask",Uu[Uu.DepthFunc=2]="DepthFunc",Uu[Uu.StencilTest=3]="StencilTest",Uu[Uu.StencilMask=4]="StencilMask",Uu[Uu.StencilFunc=5]="StencilFunc",Uu[Uu.StencilOp=6]="StencilOp",Uu[Uu.BlendType=7]="BlendType",Uu[Uu.BlendEquation=8]="BlendEquation",Uu[Uu.BlendEquationSeparate=9]="BlendEquationSeparate",Uu[Uu.BlendFunc=10]="BlendFunc",Uu[Uu.BlendFuncSeperate=11]="BlendFuncSeperate",Uu[Uu.CullFace=12]="CullFace",Uu[Uu.FrontFace=13]="FrontFace",e.TextureCompareMode=void 0,(ku=e.TextureCompareMode||(e.TextureCompareMode={}))[ku.None=0]="None",ku[ku.LEQUAL=1]="LEQUAL",ku[ku.GEQUAL=2]="GEQUAL",ku[ku.LESS=3]="LESS",ku[ku.GREATER=4]="GREATER",ku[ku.EQUAL=5]="EQUAL",ku[ku.NOTEQUAL=6]="NOTEQUAL",ku[ku.ALWAYS=7]="ALWAYS",ku[ku.NEVER=8]="NEVER",e.TextureDecodeFormat=void 0,(Gu=e.TextureDecodeFormat||(e.TextureDecodeFormat={}))[Gu.Normal=0]="Normal",Gu[Gu.RGBM=1]="RGBM";class $u{static stripRegisteredUniformDeclarations(e,t){if(0==t.size)return e;const r=new Set;t.forEach(e=>r.add(e.propertyName));return e.replace(/(?:layout\s*\([^)]*\)\s*)?\buniform\s+(?:(?:lowp|mediump|highp)\s+)?(?:(?:readonly|writeonly|coherent|volatile|restrict)\s+)*(\w+)\s+(\w+)(?:\s*\[\s*\d+\s*\])?\s*;/gm,(e,t,s)=>r.has(s)?"":e)}static glslAttributeString(e){let t="";for(const r in e){let s=$u.getAttributeType(e[r][1]);""!=s&&(t=`${t}attribute ${s} ${r};\n`)}return t}static glslUniformString(t,r,s){if(0==t.size)return"";if(r){let r="",i=`uniform ${s}{\n`,a=0;return t.forEach((t,s)=>{let n=t.uniformtype,o=t.propertyName;t.arrayLength>0&&(o=`${o}[${t.arrayLength}]`);let l=$u.getAttributeType(n);""!=l&&(!function(t){switch(t){case e.ShaderDataType.Int:case e.ShaderDataType.Float:case e.ShaderDataType.Vector2:case e.ShaderDataType.Vector3:case e.ShaderDataType.Vector4:case e.ShaderDataType.Color:case e.ShaderDataType.Matrix4x4:case e.ShaderDataType.Matrix3x3:case e.ShaderDataType.Bool:return!0;default:return!1}}(n)?r+=`uniform ${l} ${o};\n`:(i+=`${l} ${o};\n`,a++))}),i+="};\n",a>0?i+r:r}{let e="";return t.forEach((t,r)=>{let s=t.uniformtype,i=t.propertyName;t.arrayLength>0&&(i=`${i}[${t.arrayLength}]`);let a=$u.getAttributeType(s);""!=a&&(e+=`uniform ${a} ${i};\n`)}),e}}static GLShaderLanguageProcess3D(r,s,i,a,n){var l=o.lightClusterCount,h={};const u=yt.getTargetCount(r),d=u>0||-1!==r.indexOf(yt.defineName);if(d&&f.renderEngine.getParams(e.RenderParams.SHADER_CAPAILITY_LEVEL)<=30)throw new Error("LAYA_MRT requires WebGL2 or a supported MRT shader backend.");var c,_,p="";let g=t.matUseUBO,m=$u.glslAttributeString(s),T=$u.glslUniformString(i,g,"Material");f.renderEngine.getParams(e.RenderParams.SHADER_CAPAILITY_LEVEL)>30?(-1===r.indexOf("GRAPHICS_API_GLES3")&&r.push("GRAPHICS_API_GLES3"),c=`#version 300 es\n#if defined(GL_FRAGMENT_PRECISION_HIGH)\n precision highp float;\n precision highp int;\n precision highp sampler2DArray;\n precision highp sampler3D;\n#else\n precision mediump float;\n precision mediump int;\n precision mediump sampler2DArray;\n precision mediump sampler3D;\n#endif\nlayout(std140, column_major) uniform;\n#define attribute in\n#define varying out\n#define textureCube texture\n#define texture2D texture\n${m}\n\n${T}\n`,_=`#version 300 es\n#if defined(GL_FRAGMENT_PRECISION_HIGH)\n precision highp float;\n precision highp int;\n precision highp sampler2DArray;\n\tprecision highp sampler3D;\n#else\n precision mediump float;\n precision mediump int;\n precision mediump sampler2DArray;\n\tprecision mediump sampler3D;\n#endif\nlayout(std140, column_major) uniform;\n#define varying in\n${d?"":"out highp vec4 pc_fragColor;\n#define gl_FragColor pc_fragColor"}\n#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad\n\n${T}`):(c=`#if defined(GL_FRAGMENT_PRECISION_HIGH)\n precision highp float;\n precision highp int;\n#else\n precision mediump float;\n precision mediump int;\n#endif\n${m}\n${T}`,_=`#ifdef GL_EXT_shader_texture_lod\n #extension GL_EXT_shader_texture_lod : enable\n#endif\n\n#ifdef GL_OES_standard_derivatives\n\t#extension GL_OES_standard_derivatives : enable \n#endif\n\n#if defined(GL_FRAGMENT_PRECISION_HIGH)\n precision highp float;\n precision highp int;\n#else\n precision mediump float;\n precision mediump int;\n#endif\n\n#if !defined(GL_EXT_shader_texture_lod)\n #define texture1DLodEXT texture1D\n #define texture2DLodEXT texture2D\n #define texture2DProjLodEXT texture2DProj\n #define texture3DLodEXT texture3D\n #define textureCubeLodEXT textureCube\n#endif\n${T}`),p+="#define MAX_LIGHT_COUNT "+o.maxLightCount+"\n",p+="#define MAX_LIGHT_COUNT_PER_CLUSTER "+o._maxAreaLightCountPerClusterAverage+"\n",p+="#define CLUSTER_X_COUNT "+l.x+"\n",p+="#define CLUSTER_Y_COUNT "+l.y+"\n",p+="#define CLUSTER_Z_COUNT "+l.z+"\n",p+="#define MORPH_MAX_COUNT "+o.maxMorphTargetCount+"\n",p+="#define SHADER_CAPAILITY_LEVEL "+f.renderEngine.getParams(e.RenderParams.SHADER_CAPAILITY_LEVEL)+"\n";for(var y=0,x=r.length;y<x;y++){var S=r[y];p+="#define "+S+"\n",h[S]=!0}var E=a.toscript(h,[]),v="";0==E[0].indexOf("#version")&&(v=E[0]+"\n",E.shift());var D=n.toscript(h,[]),w="";0==D[0].indexOf("#version")&&(w=D[0]+"\n",D.shift());const R=$u.stripRegisteredUniformDeclarations(E.join("\n"),i);let C=$u.stripRegisteredUniformDeclarations(D.join("\n"),i);return u&&(C=yt.prepare(C,u)),{vs:v+c+p+R,fs:w+_+p+C}}static getAttributeType(t){switch(t){case e.ShaderDataType.Int:return"int";case e.ShaderDataType.Bool:return"bool";case e.ShaderDataType.Float:return"float";case e.ShaderDataType.Vector2:return"vec2";case e.ShaderDataType.Vector3:return"vec3";case e.ShaderDataType.Vector4:case e.ShaderDataType.Color:return"vec4";case e.ShaderDataType.Matrix4x4:return"mat4";case e.ShaderDataType.Matrix3x3:return"mat3";case e.ShaderDataType.Texture2D:return"sampler2D";case e.ShaderDataType.TextureCube:return"samplerCube";case e.ShaderDataType.Texture2DArray:return f.renderEngine.getCapable(e.RenderCapable.Texture3D)?"sampler2DArray":"";case e.ShaderDataType.Texture3D:return f.renderEngine.getCapable(e.RenderCapable.Texture3D)?"sampler3D":"";case e.ShaderDataType.StorageTexture2D:return f.renderEngine.getCapable(e.RenderCapable.ComputeShader)?"image2D":"";case e.ShaderDataType.DeviceBuffer:case e.ShaderDataType.ReadOnlyDeviceBuffer:return f.renderEngine.getCapable(e.RenderCapable.StorageBuffer)?"buffer":"";default:return""}}}class Ku{constructor(){this.onID=Ku.pointID++,this.textureID=-1}}Ku.pointID=0;class ju{constructor(e){this.items=e||{}}add(e,t,r){let s=e._owner._owner,i=s._subShaders.indexOf(e._owner),a=e._owner._passes.indexOf(e),n=e.nodeCommonMap?e.nodeCommonMap.slice().sort():[],o=e.additionShaderData?e.additionShaderData.slice().sort():[],l=e.moduleData.attributeLocations,h=l?Array.from(l):[],u=[];t=t.slice().filter(e=>{let t=Ot._configDefineValues.has(Ot.getDefineByName(e));return"GRAPHICS_API_GLES3"==e&&(t=!0),t&&u.push(e),!t}).sort();let d=this.items[s._name];d||(d=[],this.items[s._name]=d),d.some(e=>e.is2D===r&&e.subShaderIndex===i&&e.passIndex===a&&e.defines.length===t.length&&e.defines.every((e,r)=>e===t[r])&&e.nodeCommonMap.length===n.length&&e.nodeCommonMap.every((e,t)=>e===n[t])&&e.additionMap.length===o.length&&e.additionMap.every((e,t)=>e===o[t])&&e.attributeLocations.length===h.length&&e.attributeLocations.every((e,t)=>e===h[t]))||(d.push({is2D:r,subShaderIndex:i,passIndex:a,defines:t,nodeCommonMap:n,additionMap:o,attributeLocations:h}),console.debug(`Shader variant: ${s._name}/${i}/${a}/${t.join(",")}/${n?n.join(","):""}/${o?o.join(","):""}_${u.join(",")}`))}compileAll(){let e=this.items;for(let t in e){let r=e[t];for(let e of r){let r=Ot.compileShaderByDefineNames(t,e.subShaderIndex,e.passIndex,e.defines,e.nodeCommonMap,e.additionMap,e.is2D,e.attributeLocations),s=`${t}/${e.subShaderIndex}/${e.passIndex}/${e.defines.join(",")}/${e.nodeCommonMap?e.nodeCommonMap.join(","):""}/${e.additionMap?e.additionMap.join(","):""}`;r?console.debug("Warm up",s):console.warn("Warm up failed!",s)}}}destroy(){this.items={}}}ju.active=new ju;class Qu{static getVertexLayoutByPool(e){let t=Qu._pool;for(var r in t){let s=t[r];if(s.deepthEqaul(e))return s}return new Qu(e)}constructor(e){this.VAElements=new Array,this.attributeByteSize=new Array,this.instanceMode=new Array;for(let t=0;t<e.length;t++){let r=[],s=e[t].vertexDeclaration.vertexStride,i=e[t].vertexDeclaration._VAElements;for(let e=0;e<i.length;e++)r.push({format:i[e].format,stride:i[e].stride,shaderLocation:i[e].shaderLocation});this.attributeByteSize.push(s),this.VAElements.push(r),this.instanceMode.push(e[t].instanceBuffer)}this.id=Qu.IPoint,Qu._pool[Qu.IPoint++]=this}deepthEqaul(e){if(e.length!=this.VAElements.length)return!1;for(var t=0;t<e.length;t++){let i=e[t]._vertexDeclaration._VAElements,a=this.VAElements[t];if(i.length!=a.length)return!1;for(var r=0,s=i.length;r<s;r++){let e=i[r],t=a[r];if(e.format!=t.format||e.stride!=t.stride||e.shaderLocation!=t.shaderLocation)return!1}}return!0}}Qu.IPoint=0,Qu._pool={};const Zu="ClipRectCmd";class Ju{static create(e,t,r,s){var i=h.getItemByClass(Zu,Ju);return i.x=e,i.y=t,i.width=r,i.height=s,i}recover(){h.recover(Zu,this)}run(e,t,r){console.warn("ClipRectCmd is deprecated and no longer supported. Use Sprite.scrollRect so clipping is handled by the render struct.")}get cmdID(){return Ju.ID}getGraphicsCommandInfo(e){return sr.writeState(e)}}Ju.ID=Zu;var ed={};class td extends Ru{get shaderV1(){return this._shaderV1}set shaderV1(e){e!=this._shaderV1&&e.cloneTo(this._shaderV1),this._mat&&this._mat.setVector4("u_strength_sig2_2sig2_gauss1",this._shaderV1),this._owner&&this._owner._onChangeRender()}constructor(e){super(),this._centerScale=new $e,this._shaderV1=new i,this._blurInfo=new $e,this._shaderV1=new i,this.strength=null!=e?e:4}effectInit(e){this._owner=e,!this._mat&&(this._mat=new Zn),this._mat.setShaderName("BlurEffect2D"),this._renderElement||(this._renderElement=f.render2DRenderPassFactory.createRenderElement2D(),this._renderElement.geometry=so.InvertQuadGeometry,this._renderElement.nodeCommonMap=null,this._renderElement.renderStateIsBySprite=!1,this._renderElement.materialShaderData=this._mat.shaderData,this._renderElement.subShader=this._mat.shader.getSubShaderAt(0)),this._mat.setVector4("u_strength_sig2_2sig2_gauss1",this._shaderV1),this._mat.setVector2("u_centerScale",this._centerScale),this._mat.lock=!0}render(e){let t=e.indirectTarget.width,r=e.indirectTarget.height,s=t+100,i=r+100;this._blurInfo.setValue(s,i),this._checkRenderTarget(s,i,e),this._centerScale.setValue(t/s,r/i),this._mat.setVector2("u_centerScale",this._centerScale),this._mat.setVector2("u_blurInfo",this._blurInfo),this._mat.setTexture("u_MainTex",e.indirectTarget),e.command.setRenderTarget(this._destRT,!0,y.CLEAR),e.command.drawRenderElement(this._renderElement,Ce.EMPTY),e.destination=this._destRT}_checkRenderTarget(t,r,s){this._destRT&&(this._destRT._inPool||this._destRT.destroyed||this._destRT.width!==t||this._destRT.height!==r)&&(Xa.recoverToPool(this._destRT),this._destRT=null),this._destRT||(this._destRT=s.getRenderTexture(t,r,e.RenderTargetFormat.R8G8B8A8,e.RenderTargetFormat.None))}releaseInputTextureBindings(){this._mat&&this._mat.setTexture("u_MainTex",null)}clearRT(e){this._destRT&&this._destRT!==e.destination&&(Xa.recoverToPool(this._destRT),this._destRT=null)}get strength(){return this._strength}set strength(e){if(e==this._strength)return;this._strength=Math.max(Math.abs(e),2);var t=this._strength/3,r=t*t;let s=this._shaderV1.setValue(this.strength,r,2*r,1/(2*Math.PI*r)),i=0,a=Math.floor(10*this.strength);if(null!=ed[a])i=ed[a];else{for(let e=-4;e<=4;++e)for(let t=-4;t<=4;++t)i+=s.w*Math.exp(-(t*t+e*e)/s.z);ed[a]=i}s.w/=i,this.shaderV1=s}destroy(){var e;super.destroy(),this._destRT&&Xa.recoverToPool(this._destRT),this._destRT=null,this._mat.destroy(),this._mat=null,null===(e=this._renderElement)||void 0===e||e.destroy(),this._renderElement=null}}Ee.regClass("BlurEffect2D",td);const rd=[0,.01,.02,.04,.05,.06,.07,.08,.1,.11,.12,.14,.15,.16,.17,.18,.2,.21,.22,.24,.25,.27,.28,.3,.32,.34,.36,.38,.4,.42,.44,.46,.48,.5,.53,.56,.59,.62,.65,.68,.71,.74,.77,.8,.83,.86,.89,.92,.95,.98,1,1.06,1.12,1.18,1.24,1.3,1.36,1.42,1.48,1.54,1.6,1.66,1.72,1.78,1.84,1.9,1.96,2,2.12,2.25,2.37,2.5,2.62,2.75,2.87,3,3.2,3.4,3.6,3.8,4,4.3,4.7,4.9,5,5.5,6,6.5,6.8,7,7.3,7.5,7.8,8,8.4,8.7,9,9.4,9.6,9.8,10],sd=[.3086,.6094,.082,0,0,.3086,.6094,.082,0,0,.3086,.6094,.082,0,0,0,0,0,1,0],id=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1];class ad extends Ru{constructor(e){super(),this._colorMat=new nt,this._centerScale=new $e,this._alpha=new i,this._colorArray=new Float32Array(16),this._alphaArray=new Float32Array(4),this.setByMatrix(e||id)}get colorMat(){return this._colorMat}set colorMat(e){e!=this._colorMat&&e.cloneTo(this._colorMat),this._mat&&this._mat.setMatrix4x4("u_colorMat",this.colorMat),this._owner&&this._owner._onChangeRender()}gray(){return this.setByMatrix(sd)}get alpha(){return this._alpha}set alpha(e){e!=this._alpha&&e.cloneTo(this._alpha),this._mat&&this._mat.setVector4("u_colorAlpha",this.alpha),this._owner&&this._owner._onChangeRender()}effectInit(e){this._owner=e,(!this._mat||this._mat.destroyed)&&(this._mat=new Zn),this._mat.setShaderName("ColorEffect2D"),this._mat.setMatrix4x4("u_colorMat",this._colorMat),this._mat.setVector4("u_colorAlpha",this._alpha),this._mat.addDefine(Ot.getDefineByName("COLORFILTER")),this._centerScale.setValue(1,1),this._mat.setVector2("u_centerScale",this._centerScale),this._mat.lock=!0,this._renderElement||(this._renderElement=f.render2DRenderPassFactory.createRenderElement2D(),this._renderElement.geometry=so.InvertQuadGeometry,this._renderElement.nodeCommonMap=null,this._renderElement.renderStateIsBySprite=!1,this._renderElement.materialShaderData=this._mat.shaderData,this._renderElement.subShader=this._mat.shader.getSubShaderAt(0))}setByMatrix(e){if(this._matrix!=e){this._matrix||(this._matrix=[]);for(var t=0;t<25;t++)this._matrix[t]=e[t]}var r=0,s=0;for(t=0;t<20;t++)t%5!=4?this._colorArray[r++]=e[t]:this._alphaArray[s++]=e[t];return this.alpha.setValue(this._alphaArray[0],this._alphaArray[1],this._alphaArray[2],this._alphaArray[3]),this.alpha=this.alpha,nt.TEMP.cloneByArray(this._colorArray),this.colorMat=nt.TEMP,this}color(e=0,t=0,r=0,s=1){return this.setByMatrix([e,0,0,0,1,0,t,0,0,1,0,0,r,0,1,0,0,0,s,0])}setColor(e){return nd.parse(e),this.color(nd.r,nd.g,nd.b,1)}adjustColor(e,t,r,s){return this.adjustHue(s),this.adjustContrast(t),this.adjustBrightness(e),this.adjustSaturation(r),this}adjustBrightness(e){return 0==(e=this._clampValue(e,100))||isNaN(e)?this:this._multiplyMatrix([1,0,0,0,e,0,1,0,0,e,0,0,1,0,e,0,0,0,1,0,0,0,0,0,1])}adjustContrast(e){if(0==(e=this._clampValue(e,100))||isNaN(e))return this;var t,r=(t=e<0?127+e/100*127:127*(t=0==(t=e%1)?rd[e]:rd[e|0]*(1-t)+rd[1+(e|0)]*t)+127)/127,s=.5*(127-t);return this._multiplyMatrix([r,0,0,0,s,0,r,0,0,s,0,0,r,0,s,0,0,0,1,0,0,0,0,0,1])}adjustSaturation(e){if(0==(e=this._clampValue(e,100))||isNaN(e))return this;var t=1+(e>0?3*e/100:e/100),r=1-t,s=.3086*r,i=.6094*r,a=.082*r;return this._multiplyMatrix([s+t,i,a,0,0,s,i+t,a,0,0,s,i,a+t,0,0,0,0,0,1,0,0,0,0,0,1])}adjustHue(e){if(0==(e=this._clampValue(e,180)/180*Math.PI)||isNaN(e))return this;var t=Math.cos(e),r=Math.sin(e),s=.213,i=.715,a=.072;return this._multiplyMatrix([s+t*(1-s)+r*-s,i+t*-i+r*-i,a+t*-a+r*(1-a),0,0,s+t*-s+.143*r,i+t*(1-i)+.14*r,a+t*-a+-.283*r,0,0,s+t*-s+-.787*r,i+t*-i+r*i,a+t*(1-a)+r*a,0,0,0,0,0,1,0,0,0,0,0,1])}reset(){return this.setByMatrix(id)}_multiplyMatrix(e){var t=[];this._matrix=this._fixMatrix(this._matrix);for(var r=0;r<5;r++){for(var s=0;s<5;s++)t[s]=this._matrix[s+5*r];for(s=0;s<5;s++){for(var i=0,a=0;a<5;a++)i+=e[s+5*a]*t[a];this._matrix[s+5*r]=i}}return this.setByMatrix(this._matrix)}_fixMatrix(e=null){return null==e?id:(e.length<25?e=e.slice(0,e.length).concat(id.slice(e.length,25)):e.length>25&&(e=e.slice(0,25)),e)}_clampValue(e,t){return Math.min(t,Math.max(-t,e))}render(e){this._checkRenderTarget(e.indirectTarget.width,e.indirectTarget.height,e),this._mat.setTexture("u_MainTex",e.indirectTarget),e.command.setRenderTarget(this._destRT,!0,y.CLEAR),e.command.drawRenderElement(this._renderElement,Ce.EMPTY),e.destination=this._destRT}_checkRenderTarget(t,r,s){this._destRT&&(this._destRT._inPool||this._destRT.destroyed||this._destRT.width!==t||this._destRT.height!==r)&&(Xa.recoverToPool(this._destRT),this._destRT=null),this._destRT||(this._destRT=s.getRenderTexture(t,r,e.RenderTargetFormat.R8G8B8A8,e.RenderTargetFormat.None))}releaseInputTextureBindings(){this._mat&&this._mat.setTexture("u_MainTex",null)}clearRT(e){this._destRT&&this._destRT!==e.destination&&(Xa.recoverToPool(this._destRT),this._destRT=null)}onAfterDeserialize(){pl.hasProp("_color")&&this.setColor(this._color||"#ffffff"),pl.hasProp("_brightness","_contrast","_saturation","_hue")&&this.adjustColor(this._brightness||0,this._contrast||0,this._saturation||0,this._hue||0)}destroy(){super.destroy(),this._destRT&&Xa.recoverToPool(this._destRT),this._destRT=null,this._mat&&this._mat.destroy(),this._renderElement&&this._renderElement.destroy()}}const nd=new y;Ee.regClass("ColorEffect2D",ad);class od extends ad{constructor(){super(sd)}}Ee.regClass("GrayscaleEffect2D",od);class ld extends Ru{get sv_blurInfo1(){return this._sv_blurInfo1}set sv_blurInfo1(e){e!==this._sv_blurInfo1&&e.cloneTo(this._sv_blurInfo1),this._glowMat&&this._glowMat.setVector4("u_blurInfo1",this._sv_blurInfo1),this._owner&&this._owner._onChangeRender()}get sv_blurInfo2(){return this._sv_blurInfo2}set sv_blurInfo2(e){e!==this._sv_blurInfo2&&e.cloneTo(this._sv_blurInfo2),this._glowMat&&this._glowMat.setVector4("u_blurInfo2",this._sv_blurInfo2),this._owner&&this._owner._onChangeRender()}get color(){return this._color}set color(e){this._color=e,this._colorVec.fromArray(zr.create(e).arrColor),this._glowMat&&this._glowMat.setVector4("u_color",this._colorVec),this._owner&&this._owner._onChangeRender()}get blur(){return this._sv_blurInfo1.y}set blur(e){this._sv_blurInfo1.x=this._sv_blurInfo1.y=e,this.sv_blurInfo1=this._sv_blurInfo1}get offsetY(){return this._sv_blurInfo1.w}set offsetY(e){e!==this._sv_blurInfo1.w&&(this._sv_blurInfo1.w=e,this.sv_blurInfo1=this._sv_blurInfo1)}get offsetX(){return this._sv_blurInfo1.z}set offsetX(e){e!==this._sv_blurInfo1.z&&(this._sv_blurInfo1.z=e,this.sv_blurInfo1=this._sv_blurInfo1)}constructor(e,t,r,s){super(),this._blitcenterScale=new $e,this._sv_blurInfo1=new i,this._sv_blurInfo2=new i(0,0,1,0),this._colorVec=new i,this.color=e||"#000",this.blur=null!=t?t:4,this.offsetX=null!=r?r:6,this.offsetY=null!=s?s:6}effectInit(e){this._owner=e,!this._blitmat&&(this._blitmat=new Zn),this._blitmat.setShaderName("ColorEffect2D"),this._blitmat.lock=!0,this._blitElement||(this._blitElement=f.render2DRenderPassFactory.createRenderElement2D(),this._blitElement.geometry=so.InvertQuadGeometry,this._blitElement.nodeCommonMap=null,this._blitElement.renderStateIsBySprite=!1,this._blitElement.materialShaderData=this._blitmat.shaderData,this._blitElement.subShader=this._blitmat.shader.getSubShaderAt(0)),!this._glowMat&&(this._glowMat=new Zn),this._glowMat.setShaderName("glow2D"),this._glowMat.setVector4("u_color",this._colorVec),this._glowMat.setVector4("u_blurInfo1",this.sv_blurInfo1),this._glowMat.lock=!0,this._glowElement||(this._glowElement=f.render2DRenderPassFactory.createRenderElement2D(),this._glowElement.geometry=so.InvertQuadGeometry,this._glowElement.nodeCommonMap=null,this._glowElement.renderStateIsBySprite=!1,this._glowElement.materialShaderData=this._glowMat.shaderData,this._glowElement.subShader=this._glowMat.shader.getSubShaderAt(0)),!this._compositeMat&&(this._compositeMat=new Zn),this._compositeMat.setShaderName("ColorEffect2D"),this._compositeMat.lock=!0,this._compositeElement||(this._compositeElement=f.render2DRenderPassFactory.createRenderElement2D(),this._compositeElement.geometry=so.InvertQuadGeometry,this._compositeElement.nodeCommonMap=null,this._compositeElement.renderStateIsBySprite=!1,this._compositeElement.materialShaderData=this._compositeMat.shaderData,this._compositeElement.subShader=this._compositeMat.shader.getSubShaderAt(0))}render(e){let t=e.indirectTarget.width,r=e.indirectTarget.height,s=t+100,i=r+100;this._checkRenderTarget(s,i,e),this._blitmat.setTexture("u_MainTex",e.indirectTarget),this._blitcenterScale.setValue(t/s,r/i),this._blitmat.setVector2("u_centerScale",this._blitcenterScale),e.command.setRenderTarget(this._blitExtendRT,!0,y.CLEAR),e.command.drawRenderElement(this._blitElement,Ce.EMPTY),this._glowMat.setVector2("u_centerScale",$e.ONE),this._glowMat.setTexture("u_MainTex",this._blitExtendRT),this._sv_blurInfo2.x=s,this._sv_blurInfo2.y=i,this._glowMat.setVector4("u_blurInfo2",this._sv_blurInfo2),e.command.setRenderTarget(this._destRT,!0,y.CLEAR),e.command.drawRenderElement(this._glowElement,Ce.EMPTY),this._compositeMat.setTexture("u_MainTex",this._blitExtendRT),this._compositeMat.setVector2("u_centerScale",$e.ONE),e.command.drawRenderElement(this._compositeElement,Ce.EMPTY),e.destination=this._destRT}_checkRenderTarget(t,r,s){this._destRT&&(this._destRT._inPool||this._destRT.destroyed||this._destRT.width!==t||this._destRT.height!==r)&&(Xa.recoverToPool(this._destRT),this._destRT=null),this._blitExtendRT&&(this._blitExtendRT._inPool||this._blitExtendRT.destroyed||this._blitExtendRT.width!==t||this._blitExtendRT.height!==r)&&(Xa.recoverToPool(this._blitExtendRT),this._blitExtendRT=null),this._destRT||(this._destRT=s.getRenderTexture(t,r,e.RenderTargetFormat.R8G8B8A8,e.RenderTargetFormat.None)),this._blitExtendRT||(this._blitExtendRT=s.getRenderTexture(t,r,e.RenderTargetFormat.R8G8B8A8,e.RenderTargetFormat.None))}releaseInputTextureBindings(){this._blitmat&&this._blitmat.setTexture("u_MainTex",null),this._glowMat&&this._glowMat.setTexture("u_MainTex",null),this._compositeMat&&this._compositeMat.setTexture("u_MainTex",null)}clearRT(e){this._blitExtendRT&&this._blitExtendRT!==e.destination&&(Xa.recoverToPool(this._blitExtendRT),this._blitExtendRT=null),this._destRT&&this._destRT!==e.destination&&(Xa.recoverToPool(this._destRT),this._destRT=null)}destroy(){super.destroy(),this._destRT&&Xa.recoverToPool(this._destRT),this._destRT=null,this._blitExtendRT&&Xa.recoverToPool(this._blitExtendRT),this._blitExtendRT=null,this._blitmat&&this._blitmat.destroy(),this._blitmat=null,this._blitElement&&this._blitElement.destroy(),this._blitElement=null,this._glowMat&&this._glowMat.destroy(),this._glowMat=null,this._glowElement&&this._glowElement.destroy(),this._glowElement=null,this._compositeMat&&this._compositeMat.destroy(),this._compositeMat=null,this._compositeElement&&this._compositeElement.destroy(),this._compositeElement=null}}Ee.regClass("GlowEffect2D",ld);class hd{onPopulateMesh(e){let t=e.contentRect;const r=t.width/2,s=t.height/2;let i=Math.ceil(Math.PI*(r+s)/4);i=Wr.clamp(i,40,800);const a=2*Math.PI/i;let n=0;const o=t.x+r,l=t.y+s;e.addVert(o,l);for(let t=0;t<i;t++){let t=Math.cos(n)*r+o,i=Math.sin(n)*s+l;e.addVert(t,i),n+=a}for(let t=0;t<i;t++)t!=i-1?e.addTriangle(0,t+1,t+2):e.addTriangle(0,t+1,1)}}Ee.regClass("CircleMesh",hd);class ud{constructor(){this.flipX=!0,this.flipY=!1}onPopulateMesh(e){var t;const r=te.create();let s=r.copyFrom(e.uvRect);if(this.flipX){let e=s.x;s.x=s.right,s.right=e}if(this.flipY){let e=s.y;s.y=s.bottom,s.bottom=e}let i=null===(t=e.mainTex)||void 0===t?void 0:t._sizeGrid;if(i){let t=te.create(),r=e.mainTex.sourceWidth,a=e.mainTex.sourceHeight;t.setTo(i[3],i[0],r-i[1]-i[3],a-i[0]-i[2]),this.flipX&&(t.x=r-t.right),this.flipY&&(t.y=a-t.bottom),Or(e,e.contentRect,s,t,1===i[4]?255:0)}else e.addQuad(e.contentRect,null,s),e.triangulateQuad(0);r.recover()}}var dd,cd;Ee.regClass("FlipMesh",ud),e.FillMethod=void 0,(dd=e.FillMethod||(e.FillMethod={}))[dd.None=0]="None",dd[dd.Horizontal=1]="Horizontal",dd[dd.Vertical=2]="Vertical",dd[dd.Radial90=3]="Radial90",dd[dd.Radial180=4]="Radial180",dd[dd.Radial360=5]="Radial360",e.FillOrigin=void 0,(cd=e.FillOrigin||(e.FillOrigin={}))[cd.Top=0]="Top",cd[cd.Bottom=1]="Bottom",cd[cd.Left=2]="Left",cd[cd.Right=3]="Right",cd[cd.TopLeft=0]="TopLeft",cd[cd.TopRight=1]="TopRight",cd[cd.BottomLeft=2]="BottomLeft",cd[cd.BottomRight=3]="BottomRight";class _d{constructor(){this.origin=0,this.amount=.6,this.clockwise=!0,this._method=5}get method(){return this._method}set method(t){this._method!=t&&(this._method=t,!p.isPlaying&&(t===e.FillMethod.Horizontal||t===e.FillMethod.Vertical)&&this.origin>1&&(this.origin=0))}onPopulateMesh(t){let r=Wr.clamp01(this.amount);switch(this.method){case e.FillMethod.Horizontal:!function(t,r,s,i){const a=te.create();let n=a.copyFrom(r),o=n.width*i;s!==e.FillOrigin.Right&&s!==e.FillOrigin.Bottom||(n.x+=n.width-o);n.width=o,t.addQuad(n),t.triangulateQuad(0),a.recover()}(t,t.contentRect,this.origin,r);break;case e.FillMethod.Vertical:!function(t,r,s,i){const a=te.create();let n=a.copyFrom(r),o=n.height*i;s!==e.FillOrigin.Right&&s!==e.FillOrigin.Bottom||(n.y+=n.height-o);n.height=o,t.addQuad(n),t.triangulateQuad(0),a.recover()}(t,t.contentRect,this.origin,r);break;case e.FillMethod.Radial90:pd(t,t.contentRect,this.origin,r,this.clockwise);break;case e.FillMethod.Radial180:gd(t,t.contentRect,this.origin,r,this.clockwise);break;case e.FillMethod.Radial360:!function(t,r,s,i,a){const n=te.create();let o=n.copyFrom(r);switch(s){case e.FillOrigin.Top:if(i<.5){o.width/=2,a&&(o.x+=o.width),gd(t,o,a?e.FillOrigin.Left:e.FillOrigin.Right,i/.5,a);let r=t.getPos(-8);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.width/=2,a||(o.x+=o.width),gd(t,o,a?e.FillOrigin.Right:e.FillOrigin.Left,(i-.5)/.5,a),a?o.x+=o.width:o.x-=o.width,t.addQuad(o),t.triangulateQuad(-4);break;case e.FillOrigin.Bottom:if(i<.5){o.width/=2,a||(o.x+=o.width),gd(t,o,a?e.FillOrigin.Right:e.FillOrigin.Left,i/.5,a);let r=t.getPos(-8);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.width/=2,a&&(o.x+=o.width),gd(t,o,a?e.FillOrigin.Left:e.FillOrigin.Right,(i-.5)/.5,a),a?o.x-=o.width:o.x+=o.width,t.addQuad(o),t.triangulateQuad(-4);break;case e.FillOrigin.Left:if(i<.5){o.height/=2,a||(o.y+=o.height),gd(t,o,a?e.FillOrigin.Bottom:e.FillOrigin.Top,i/.5,a);let r=t.getPos(-8);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.height/=2,a&&(o.y+=o.height),gd(t,o,a?e.FillOrigin.Top:e.FillOrigin.Bottom,(i-.5)/.5,a),a?o.y-=o.height:o.y+=o.height,t.addQuad(o),t.triangulateQuad(-4);break;case e.FillOrigin.Right:if(i<.5){o.height/=2,a&&(o.y+=o.height),gd(t,o,a?e.FillOrigin.Top:e.FillOrigin.Bottom,i/.5,a);let r=t.getPos(-8);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.height/=2,a||(o.y+=o.height),gd(t,o,a?e.FillOrigin.Bottom:e.FillOrigin.Top,(i-.5)/.5,a),a?o.y+=o.height:o.y-=o.height,t.addQuad(o),t.triangulateQuad(-4)}n.recover()}(t,t.contentRect,this.origin,r,this.clockwise);break;default:t.addQuad(t.contentRect),t.triangulateQuad(0)}}}function pd(t,r,s,i,a){let n=s===e.FillOrigin.TopRight||s===e.FillOrigin.BottomRight,o=s===e.FillOrigin.BottomLeft||s===e.FillOrigin.BottomRight;n!==o&&(a=!a);let l=a?i:1-i,h=Math.tan(.5*Math.PI*l),u=!1;1!==l&&(u=r.height/r.width-h>0),a||(u=!u);let d=r.x+(0===l?Number.MAX_VALUE:r.height/h),c=r.y+(1===l?Number.MAX_VALUE:r.width*h),_=d,p=c;n&&(_=r.width-d),o&&(p=r.height-c);let g=n?r.width-r.x:r.x,m=o?r.height-r.y:r.y,f=n?-r.x:r.right,T=o?-r.y:r.bottom;t.addVert(g,m),a&&t.addVert(f,m),c>r.bottom?u?t.addVert(_,T):t.addVert(f,T):t.addVert(f,p),d>r.right?u?t.addVert(f,p):t.addVert(f,T):t.addVert(_,T),a||t.addVert(g,T),n===o?(t.addTriangle(0,1,2),t.addTriangle(0,2,3)):(t.addTriangle(2,1,0),t.addTriangle(3,2,0))}function gd(t,r,s,i,a){const n=te.create();let o=n.copyFrom(r);switch(s){case e.FillOrigin.Top:if(i<=.5){o.width/=2,a&&(o.x+=o.width),pd(t,o,a?e.FillOrigin.TopLeft:e.FillOrigin.TopRight,i/.5,a);let r=t.getPos(-4);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.width/=2,a||(o.x+=o.width),pd(t,o,a?e.FillOrigin.TopRight:e.FillOrigin.TopLeft,(i-.5)/.5,a),a?o.x+=o.width:o.x-=o.width,t.addQuad(o),t.triangulateQuad(-4);break;case e.FillOrigin.Bottom:if(i<=.5){o.width/=2,a||(o.x+=o.width),pd(t,o,a?e.FillOrigin.BottomRight:e.FillOrigin.BottomLeft,i/.5,a);let r=t.getPos(-4);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.width/=2,a&&(o.x+=o.width),pd(t,o,a?e.FillOrigin.BottomLeft:e.FillOrigin.BottomRight,(i-.5)/.5,a),a?o.x-=o.width:o.x+=o.width,t.addQuad(o),t.triangulateQuad(-4);break;case e.FillOrigin.Left:if(i<=.5){o.height/=2,a||(o.y+=o.height),pd(t,o,a?e.FillOrigin.BottomLeft:e.FillOrigin.TopLeft,i/.5,a);let r=t.getPos(-4);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.height/=2,a&&(o.y+=o.height),pd(t,o,a?e.FillOrigin.TopLeft:e.FillOrigin.BottomLeft,(i-.5)/.5,a),a?o.y-=o.height:o.y+=o.height,t.addQuad(o),t.triangulateQuad(-4);break;case e.FillOrigin.Right:if(i<=.5){o.height/=2,a&&(o.y+=o.height),pd(t,o,a?e.FillOrigin.TopRight:e.FillOrigin.BottomRight,i/.5,a);let r=t.getPos(-4);t.addQuad(te.TEMP.setTo(r.x,r.y,0,0)),t.triangulateQuad(-4)}else o.height/=2,a||(o.y+=o.height),pd(t,o,a?e.FillOrigin.BottomRight:e.FillOrigin.TopRight,(i-.5)/.5,a),a?o.y+=o.height:o.y-=o.height,t.addQuad(o),t.triangulateQuad(-4)}n.recover()}Ee.regClass("ProgressMesh",_d);class md{constructor(){this.sides=6,this.distances=[],this.rotation=0,this.lineWidth=0,this.lineColor=null,this.centerColor=null,this.fillColor=null}onPopulateMesh(e){var t;let r=this.fillColor||e.color,i=this.lineColor||e.color;const a=2*Math.PI/this.sides;let n=this.rotation*s.Deg2Rad;const o=Math.min(e.contentRect.width/2,e.contentRect.height/2),l=this.lineWidth,h=o+e.contentRect.x,u=o+e.contentRect.y;e.addVert(h,u,this.centerColor||r);for(let s=0;s<this.sides;s++){let d=o;null!=this.distances&&(d*=null!==(t=this.distances[s])&&void 0!==t?t:1);let c=h+Math.cos(n)*(d-l),_=u+Math.sin(n)*(d-l);e.addVert(c,_,r),l>0&&(e.addVert(c,_,i),e.addVert(Math.cos(n)*d+h,Math.sin(n)*d+u,i)),n+=a}if(l>0){let t=3*this.sides;for(let r=0;r<t;r+=3)r!=t-3?(e.addTriangle(0,r+1,r+4),e.addTriangle(r+5,r+2,r+3),e.addTriangle(r+3,r+6,r+5)):(e.addTriangle(0,r+1,1),e.addTriangle(2,r+2,r+3),e.addTriangle(r+3,3,2))}else for(let t=0;t<this.sides;t++)e.addTriangle(0,t+1,t===this.sides-1?1:t+2)}}Ee.regClass("RegularPolygonMesh",md);class fd{constructor(){this.lt=6,this.rt=6,this.lb=6,this.rb=6}onPopulateMesh(e){let t=e.contentRect.x,r=e.contentRect.y,s=e.contentRect.width,i=e.contentRect.height,a=s/2,n=i/2,o=Math.min(a,n),l=t+a,h=r+n;e.addVert(l,h);let u=e.vertCount;for(let a=0;a<4;a++){let n=0;switch(a){case 0:n=this.rb;break;case 1:n=this.lb;break;case 2:n=this.lt;break;case 3:n=this.rt}n=Math.min(o,n);let l=0,h=0;if(0!==a&&3!==a||(l=s-2*n),0!==a&&1!==a||(h=i-2*n),l+=t,h+=r,0!==n){let t=Math.max(1,Math.ceil(Math.PI*n/8))+1,r=Math.PI/2/t,s=Math.PI/2*a,i=s;for(let a=1;a<=t;a++)a===t&&(s=i+Math.PI/2),e.addVert(l+Math.cos(s)*n+n,h+Math.sin(s)*n+n),s+=r}else e.addVert(l,h)}u=e.vertCount-u;for(let t=0;t<u;t++)e.addTriangle(0,t+1,t===u-1?1:t+2)}}Ee.regClass("RoundedRectMesh",fd);class Td{constructor(){this.repeatX=!0,this.repeatY=!0}onPopulateMesh(e){let t=e.mainTex;Ur(e,e.contentRect,e.uvRect,t?t.sourceWidth:e.contentRect.width,t?t.sourceHeight:e.contentRect.height,this.repeatX,this.repeatY)}}Ee.regClass("TileMesh",Td);class yd extends Sn{constructor(){super(...arguments),this.duration=1e3,this.delay=0,this.repeat=0,this.autoDestroyAtComplete=!0}_onAwake(){this.target=this.target||this.owner,this.autoDestroyAtComplete&&(this._comlete=he.create(this.target,this.target.destroy,null,!1)),this.eventName?this.owner.on(this.eventName,this,this._exeTween):this._exeTween()}_exeTween(){this._tween=this._doTween(),this._tween.repeat(this.repeat)}_doTween(){return null}onReset(){this.duration=1e3,this.delay=0,this.repeat=0,this.ease=null,this.target=null,this.eventName&&(this.owner.off(this.eventName,this,this._exeTween),this.eventName=null),this._comlete&&(this._comlete.recover(),this._comlete=null),this._tween&&(this._tween.clear(),this._tween=null)}}class xd{}xd.STANDARD=0,xd.LEFT=1,xd.RIGHT=2,xd.NUM_PAD=3;class Sd{}Sd.NUMBER_0=48,Sd.NUMBER_1=49,Sd.NUMBER_2=50,Sd.NUMBER_3=51,Sd.NUMBER_4=52,Sd.NUMBER_5=53,Sd.NUMBER_6=54,Sd.NUMBER_7=55,Sd.NUMBER_8=56,Sd.NUMBER_9=57,Sd.A=65,Sd.B=66,Sd.C=67,Sd.D=68,Sd.E=69,Sd.F=70,Sd.G=71,Sd.H=72,Sd.I=73,Sd.J=74,Sd.K=75,Sd.L=76,Sd.M=77,Sd.N=78,Sd.O=79,Sd.P=80,Sd.Q=81,Sd.R=82,Sd.S=83,Sd.T=84,Sd.U=85,Sd.V=86,Sd.W=87,Sd.X=88,Sd.Y=89,Sd.Z=90,Sd.F1=112,Sd.F2=113,Sd.F3=114,Sd.F4=115,Sd.F5=116,Sd.F6=117,Sd.F7=118,Sd.F8=119,Sd.F9=120,Sd.F10=121,Sd.F11=122,Sd.F12=123,Sd.F13=124,Sd.F14=125,Sd.F15=126,Sd.NUMPAD=21,Sd.NUMPAD_0=96,Sd.NUMPAD_1=97,Sd.NUMPAD_2=98,Sd.NUMPAD_3=99,Sd.NUMPAD_4=100,Sd.NUMPAD_5=101,Sd.NUMPAD_6=102,Sd.NUMPAD_7=103,Sd.NUMPAD_8=104,Sd.NUMPAD_9=105,Sd.NUMPAD_ADD=107,Sd.NUMPAD_DECIMAL=110,Sd.NUMPAD_DIVIDE=111,Sd.NUMPAD_ENTER=108,Sd.NUMPAD_MULTIPLY=106,Sd.NUMPAD_SUBTRACT=109,Sd.SEMICOLON=186,Sd.EQUAL=187,Sd.COMMA=188,Sd.MINUS=189,Sd.PERIOD=190,Sd.SLASH=191,Sd.BACKQUOTE=192,Sd.LEFTBRACKET=219,Sd.BACKSLASH=220,Sd.RIGHTBRACKET=221,Sd.QUOTE=222,Sd.ALTERNATE=18,Sd.BACKSPACE=8,Sd.CAPS_LOCK=20,Sd.COMMAND=15,Sd.CONTROL=17,Sd.DELETE=46,Sd.ENTER=13,Sd.ESCAPE=27,Sd.PAGE_UP=33,Sd.PAGE_DOWN=34,Sd.END=35,Sd.HOME=36,Sd.LEFT=37,Sd.UP=38,Sd.RIGHT=39,Sd.DOWN=40,Sd.SHIFT=16,Sd.SPACE=32,Sd.TAB=9,Sd.INSERT=45;class Ed extends N{onChange(){this.event(c.CHANGED)}}class vd extends Ed{getEffect(){return this._effect2D}constructor(e=4){super(),this._effect2D=new td(e)}get strength(){return this._effect2D.strength}set strength(e){this._effect2D.strength=e,this.onChange()}}Ee.regClass("BlurFilter",vd);class Dd extends Ed{getEffect(){return this._effect2D}constructor(e=null){super(),this._effect2D=new ad(e)}gray(){return this._effect2D.gray(),this}color(e=0,t=0,r=0,s=1){return this._effect2D.color(e,t,r,s),this}setColor(e){return this._effect2D.setColor(e),this}setByMatrix(e){return this._effect2D.setByMatrix(e),this.onChange(),this}adjustColor(e,t,r,s){return this._effect2D.adjustColor(e,t,r,s),this}adjustBrightness(e){return this._effect2D.adjustBrightness(e),this}adjustContrast(e){return this._effect2D.adjustContrast(e),this}adjustSaturation(e){return this._effect2D.adjustSaturation(e),this}adjustHue(e){return this._effect2D.adjustHue(e),this}reset(){return this._effect2D.reset(),this}onAfterDeserialize(){pl.hasProp("_color")&&this.setColor(this._color),pl.hasProp("_brightness","_contrast","_saturation","_hue")&&this.adjustColor(this._brightness||0,this._contrast||0,this._saturation||0,this._hue||0)}}Ee.regClass("ColorFilter",Dd);class wd extends Ed{constructor(e,t=4,r=6,s=6){super(),this._effect2D=new ld(e,t,r,s)}getEffect(){return this._effect2D}get offY(){return this._effect2D.offsetY}set offY(e){this._effect2D.offsetY=e,this.onChange()}get offX(){return this._effect2D.offsetX}set offX(e){this._effect2D.offsetX=e,this.onChange()}get color(){return this._effect2D.color}set color(e){this._effect2D.color=e,this.onChange()}get blur(){return this._effect2D.blur}set blur(e){this._effect2D.blur=e,this.onChange()}}Ee.regClass("GlowFilter",wd);class Rd{}Rd.enableAutoDynamicAtlas=!1,Rd.limitDynamicAtlasSize=1024;class Cd{static init(){const t={a_PositionTexcoord:[Lt.MESH_POSITION0,e.ShaderDataType.Vector4]},r={u_MainTex:e.ShaderDataType.Texture2D,u_OffsetScale:e.ShaderDataType.Vector4};this.LINEAR_TO_GAMMA=Ot.getDefineByName("LINEAR_TO_GAMMA"),this.GAMMA_TO_LINEAR=Ot.getDefineByName("GAMMA_TO_LINEAR"),this._sdNotChange=f.renderDeviceFactory.createShaderData(null),this._sdGammaToLinear=f.renderDeviceFactory.createShaderData(null),this._sdGammaToLinear.addDefine(this.GAMMA_TO_LINEAR),this._sdLinearToGamma=f.renderDeviceFactory.createShaderData(null),this._sdLinearToGamma.addDefine(this.LINEAR_TO_GAMMA);const s=Ot.add("TexMerge"),i=new Nt(t,r);s.addSubShader(i);const a=i.addShaderPass("#define SHADER_NAME TexMergeVS\nvarying vec2 v_Texcoord0;void main(){gl_Position=vec4(u_OffsetScale.x*2.0-1.0+(a_PositionTexcoord.x+1.0)*u_OffsetScale.z,(1.0-((u_OffsetScale.y*2.0-1.0+(-a_PositionTexcoord.y+1.0)*u_OffsetScale.w)+1.0)/2.0)*2.0-1.0,0.0,1.0);v_Texcoord0=a_PositionTexcoord.zw;\n#ifdef INVERTY\ngl_Position.y=-gl_Position.y;\n#endif\n}",'#define SHADER_NAME TexMergeFS\n#include "Color.glsl";\nvarying vec2 v_Texcoord0;void main(){vec4 color=texture2D(u_MainTex,v_Texcoord0);\n#ifdef LINEAR_TO_GAMMA\ncolor.rgb=linearToGamma(color.rgb);\n#endif\n#ifdef GAMMA_TO_LINEAR\ncolor.rgb=gammaToLinear(color.rgb);\n#endif\ngl_FragColor=color;}').renderState;a.depthTest=Gt.DEPTHTEST_ALWAYS,a.depthWrite=!1,a.cull=Gt.CULL_NONE,a.blend=Gt.BLEND_DISABLE}}class Md extends z{constructor(t,r,s=e.RenderTargetFormat.R8G8B8A8,i=null,a=!1,n=-1,o=!0,l=1){super(t,r,s,i,a,1,!1,o),this._limitMipmap=-1,this._willDestroyTex=[],this.immediately=!1,this.commands=new Set,this._waitMergeIds=new Set,this._limitMipmap=n,this.anisoLevel=1,this._limitMipmap>=0&&this.mipmapCount>this._limitMipmap&&this._setMaxMipmapLevel(this._limitMipmap),this._shader=Ot.find("TexMerge"),this._texture.gammaCorrection=l}_createRenderTarget(){if(t.useTextureArray){const e=Ws.allocateLayerAsTexture(this.width,this.height,this._format,64,this._gammaSpace,this._depthStencilFormat,this._generateMipmap);if(e)return this._arrayAlloc=e,this._dimension=e.sharedRT.dimension,this._renderTarget=e.sharedRT._renderTarget,this._generateMipmap=e.sharedRT.generateMipmap,this._texture=e.sharedRT._texture,Ws.register(this,e),void this._bindTextureArrayLayer()}super._createRenderTarget()}onUpdate(e=!1){if(!this.cmdBuffer||!this.commands.size)return null;let t=this.commands.values(),r=t.next().value,s=[],i=va.rendercontext2D.invertY;for(;r&&(e||jo.stage.getTimeFromFrameStart()<30);)this.cmdBuffer.addCacheCommand(r),this._bindTextureArrayLayer(),this.cmdBuffer.applyOne(!0),this.commands.delete(r),this._waitMergeIds.delete(r.source.id),s.push(r.source.id),r=t.next().value;return va.rendercontext2D.invertY=i,this.commands.size||this._doDestoryTex(),s}hasWaitMerge(e){return this._waitMergeIds.has(e)}_setMaxMipmapLevel(e){this.baseMipmapLevel=0,this.maxMipmapLevel=e}addTexture(e,t,r,s,i,a,n){let o=null;return i>0&&(o=this._drawTex(e,t,r,s,i,a)),o=this._drawTex(e,t,r,s,0,a),n&&this._willDestroyTex.push(a),o}addColor(t,r,s,i,a,n){let o,l;if(n==e.TextureFormat.R8G8B8){const e=255*a.x,t=255*a.y,r=255*a.z;o=new Uint8Array(s*i*3);for(let a=0;a<i;a++)for(let i=0;i<s;i++){let n=a*s*3+3*i;o[n]=e,o[n+1]=t,o[n+2]=r}}else if(n==e.TextureFormat.R8G8B8A8){const e=255*a.x,t=255*a.y,r=255*a.z,n=255*a.w;o=new Uint8Array(s*i*4);for(let a=0;a<i;a++)for(let i=0;i<s;i++){let l=a*s*4+4*i;o[l]=e,o[l+1]=t,o[l+2]=r,o[l+3]=n}}l=this._createSmallTex(s,i,o);let h=this._drawTex(t,r,s,i,0,l);return this._willDestroyTex.push(l),h}fillColor(t,r){let s,i;if(r==e.TextureFormat.R8G8B8){const e=255*t.x,r=255*t.y,i=255*t.z;s=new Uint8Array(48);for(let t=0;t<4;t++)for(let a=0;a<4;a++){let n=4*t*3+3*a;s[n]=e,s[n+1]=r,s[n+2]=i}}else if(r==e.TextureFormat.R8G8B8A8){const e=255*t.x,r=255*t.y,i=255*t.z,a=255*t.w;s=new Uint8Array(64);for(let t=0;t<4;t++)for(let n=0;n<4;n++){const o=4*t*4+4*n;s[o]=e,s[o+1]=r,s[o+2]=i,s[o+3]=a}}i=this._createSmallTex(4,4,s),this._drawTex(0,0,this.width,this.height,0,i),this._willDestroyTex.push(i)}destroy(){super.destroy(),this.cmdBuffer&&this.cmdBuffer.clear(),this.cmdBuffer=null,this._doDestoryTex(),this._willDestroyTex=null}_disposeResource(){if(this._arrayAlloc)return Ws.unregister(this),this._arrayAlloc=null,this._renderTarget=null,void(this._texture=null);super._disposeResource()}_createSmallTex(t,r,s){const i=new Hi(t,r,this.format,!1,!1,!1);return i.setPixelsData(s,!1,!1),i.filterMode=e.FilterMode.Point,i}_doDestoryTex(){if(this._willDestroyTex)for(;this._willDestroyTex.length;)this._willDestroyTex.pop().destroy()}_bindTextureArrayLayer(){this._arrayAlloc&&this._arrayAlloc.sharedRT.bindLayer(this._arrayAlloc.layer)}_drawTex(e,t,r,s,a,n){const o=this.width,l=this.height,h=new i;h.x=Math.max(0,e-a)/o,h.y=Math.max(0,l-t-s-a)/l,h.z=(r+2*a)/o,h.w=(s+2*a)/l;let u=Cd._sdNotChange;u=this.gammaSpace?n.gammaSpace?Cd._sdNotChange:Cd._sdLinearToGamma:n.gammaSpace?Cd._sdGammaToLinear:Cd._sdNotChange;let d=so.create(n,this,h,this._shader,u,!1);return this.commands.add(d),this.immediately?this.onUpdate(!0):this._waitMergeIds.add(n.id),d}}class bd{constructor(){this._dynamicAtlas=null,Rd.enableAutoDynamicAtlas&&(this._dynamicAtlas=new Nd({largeTextureSize:[Rd.limitDynamicAtlasSize,Rd.limitDynamicAtlasSize]},!0))}addTexture(e){var t;this.shouldAddToDynamicAtlas(e)&&(null===(t=this._dynamicAtlas)||void 0===t||t.addTexture(e))}shouldAddToDynamicAtlas(e){if(!Rd.enableAutoDynamicAtlas)return!1;const t=e.bitmap;return t instanceof Hi&&(t.width<Rd.limitDynamicAtlasSize&&t.height<Rd.limitDynamicAtlasSize)}onUpdate(){var e;null===(e=this._dynamicAtlas)||void 0===e||e.onUpdate()}cleanupUnused(){var e;null===(e=this._dynamicAtlas)||void 0===e||e.cleanupUnusedTextures()}}class Ad{constructor(){this.mgrs=[]}static addMgr(e){this._instance.addManager(e)}static removeMgr(e){this._instance.removeManager(e)}static cleanupUnused(){this._instance._textureProcessor.cleanupUnused()}get textureProcessor(){return this._textureProcessor}setTextureProcessor(e){this._textureProcessor=e}addManager(e){this.mgrs.push(e),1===this.mgrs.length&&jo.stage.timer.loop(200,this,this.update)}removeManager(e){this.mgrs.splice(this.mgrs.indexOf(e),1),0===this.mgrs.length&&jo.stage.timer.clear(this,this.update)}update(e=!1){if(!e&&jo.stage.getTimeFromFrameStart()>100)return;const t=this.mgrs;let r=t.length;for(let s=0;s<r;s++){const r=t[s];if(r&&(r.onUpdate(),!e&&jo.stage.getTimeFromFrameStart()>30))break}t.length!=r&&(t.length=r)}}jo.addAfterInitCallback(()=>{!!(f.renderEngine.objectName?f.renderEngine.objectName:"").includes("GPU")&&(Rd.enableAutoDynamicAtlas=!0),Cd.init();let e=Ad._instance=new Ad,t=new bd;e.setTextureProcessor(t),va.runner._textureProcessor=t});class Id{constructor(){this.id=0,this.x=0,this.y=0,this.w=0,this.h=0,this.pos=new i,this.largeTextureIndex=0,this.scale=1,this.token=!1,this.partId=[]}cloneTo(e){e.id=this.id,e.url=this.url,e.x=this.x,e.y=this.y,e.w=this.w,e.h=this.h,e.largeTextureIndex=this.largeTextureIndex,e.scale=this.scale,e.token=this.token,this.pos.cloneTo(e.pos),e.partId.length=this.partId.length;for(let t=0;t<this.partId.length;t++)e.partId[t]=this.partId[t]}isSelf(e){return this.id===e||this.url===e}}class Pd{constructor(t,r,s=16,a=0,n=e.RenderTargetFormat.R8G8B8A8){this.EXTEND_SIZE=0,this.TEX_SIZE_MIN=16,this.TEX_SIZE_MAX=1024,this.mipMap=!0,this.texWrap=e.WrapMode.Clamp,this.texMode=e.FilterMode.Trilinear,this.texAnisoLevel=1,this.texFormat=e.RenderTargetFormat.R8G8B8A8,this.backColor=new i(90,90,90,255),this.LARGE_TEX_W=2048,this.LARGE_TEX_H=2048,this.LARGE_TEX_N=32,this.delay=30,this.totalCapacity=0,this.usedCapacity=0,this.sRGB=!1,this.gammaCorrection=1,this.checkDup=!0,this.autoExtend=!1,this.immediately=!1,this._texItems=[],this._texMaps=[],this._tempMaps=[],this.largeTexs=[],this._cmdBuffer=new ho,this.destroyed=!1,this.gpuMemory=0,this.updateHook=null,t[0]&&(this.LARGE_TEX_W=t[0],t[1]?this.LARGE_TEX_H=t[1]:this.LARGE_TEX_H=t[0]),this.EXTEND_SIZE=a,this.LARGE_TEX_N=r,this.TEX_SIZE_MIN=s,this.texFormat=n;const o=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,l=this.LARGE_TEX_H/this.TEX_SIZE_MIN|0;this.totalCapacity=o*l*r;for(let e=0;e<r;e++)this._texItems[e]=[],this._texMaps[e]=new Array(o*l).fill(0);this._tempMaps=new Array(o*l).fill(0)}onUpdate(e=!1){var t;if(!this.largeTexs)return!1;for(let r=0,s=this.largeTexs.length;r<s;r++){const s=this.largeTexs[r];if(!s)continue;let i=s.onUpdate(e);if(null===(t=this.updateHook)||void 0===t||t.call(this,r,i),!e&&l.stage.getTimeFromFrameStart()>this.delay)break}return!0}adjustLtn(e=1){if(e>0){const t=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,r=this.LARGE_TEX_H/this.TEX_SIZE_MIN|0,s=this.LARGE_TEX_N+e;this.totalCapacity=t*r*s;for(let e=this.LARGE_TEX_N;e<s;e++)this._texItems[e]=[],this._texMaps[e]=new Array(t*r).fill(0);this.LARGE_TEX_N+=e}}calculateGpuMemory(){this.gpuMemory=0;for(let e=this.largeTexs.length-1;e>-1;e--)this.gpuMemory+=this.largeTexs[e]._renderTarget.gpuMemory;return this.gpuMemory}getLoadUsageRate(){return this.usedCapacity/this.totalCapacity}fillWithColor(t,r,s,i,a,n,o,l,h=255){if(t<this.LARGE_TEX_N&&this.largeTexs[t]){const u=new Hi(1,1,e.TextureFormat.R8G8B8A8,!1,!1),d=new Uint8Array([n,o,l,h]);u.setPixelsData(d,!1,!1),this.largeTexs[t].addTexture(r,s,i,a,0,u,!0)}}static calcFitTexSize(e,t,r,s,i){if(!e||0==e.length)return[0];const a=Pd._largeTexSize;for(let n=0,o=a.length;n<o;n++){i&&(i.length=0);let o=0,l=0;const h=a[n][0]/r|0,u=a[n][1]/r|0,d=new Array(h*u).fill(0);for(let a=0,n=e.length;a<n;a++){const n=Pd.calcTexSize(e[a].width,e[a].height,t,r,s),c=n[2],_=n[3];let p=!1;for(let e=0;e<u-_+1&&!p;e++)for(let t=0;t<h-c+1&&!p;t++){if(d[e*h+t]>0)continue;let r=!1;for(let s=e;s<e+_&&!r;s++)for(let e=t;e<t+c&&!r;e++)d[s*h+e]>0&&(r=!0);if(!r){for(let r=e;r<e+_;r++)for(let e=t;e<t+c;e++)d[r*h+e]=1,l++;o++,p=!0,i&&i.push([t,e,c,_])}}if(!p)break}if(o==e.length)return[a[n][0],a[n][1],100*l/h/u|0]}return[0]}areTextureMerged(e,t=-1){let r=!1;if(t>=0){let r=this._findTexture(e,t);if(r){return this.largeTexs[t].hasWaitMerge(r.id)}}else for(let t=0;t<this.LARGE_TEX_N;t++)if(this.areTextureMerged(e,t)){r=!0;break}return r}areAllTexturesIncluded(e){if(e){for(let t=e.length-1;t>-1;t--){let r=!1;for(let s=0;s<this.LARGE_TEX_N;s+=2)if(this._findTexture(e[t].id,s)){r=!0;break}if(!r)return!1}return!0}return!1}hasEnoughSpace(e,t,r){if(!e||0==e.length||0==this._texMaps.length||r<0||r>=this.LARGE_TEX_N)return!1;const s=this._tempMaps,i=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,a=this.LARGE_TEX_H/this.TEX_SIZE_MIN|0;for(let e=0;e<a;e++)for(let t=0;t<i;t++)s[e*i+t]=this._texMaps[r][e*i+t];for(let i=0,a=e.length;i<a;i++){if(!e[i])continue;if(this._findTexture(e[i].id,r))continue;const a=Pd.calcTexSize(e[i].width,e[i].height,t,this.TEX_SIZE_MIN,this.EXTEND_SIZE);if(!this._takeRoomInMap(a[2],a[3],s))return!1}return!0}findAvailableLargeTextureCode(e,t){for(let r=0;r<this.LARGE_TEX_N;r++)if(this.hasEnoughSpace(e,t,r))return r;return-1}addTexturesToLargeTexture(e,t,r,s=!1){if(!this.hasEnoughSpace(e,t,r))return!1;for(let i=0,a=e.length;i<a;i++)this.addTexture(e[i],t,r,null,s);return!0}addTexture(e,t=1,r=-1,s=null,i=!1){if(!e)return-1;const a=e.width*t|0,n=e.height*t|0;if(a>this.LARGE_TEX_W-2*this.EXTEND_SIZE||n>this.LARGE_TEX_H-2*this.EXTEND_SIZE)return console.warn("LargeTexManager: the texture is too large1!"),-1;if(a>this.TEX_SIZE_MAX||n>this.TEX_SIZE_MAX)return console.warn("LargeTexManager: the texture is too large2!"),-1;const o=this._addTexture(e,t,r,s,i);return o?o.largeTextureIndex:(console.warn("LargeTexManager: have not enough room!"),-1)}addPlaceholder(e,t,r,s=1,i=-1){let a=t*s|0,n=r*s|0;if(a>this.LARGE_TEX_W-2*this.EXTEND_SIZE||n>this.LARGE_TEX_H-2*this.EXTEND_SIZE)return console.warn("LargeTexManager: the texture is too large1!"),-1;if(a>this.TEX_SIZE_MAX||n>this.TEX_SIZE_MAX)return console.warn("LargeTexManager: the texture is too large2!"),-1;const o=this._addPlaceholder(e,t,r,s,i);return o?o.largeTextureIndex:(console.warn("LargeTexManager: have not enough room!"),-1)}updateTexture(e,t=1,r=-1,s,i=!1){if(e){const a=this._updateTexture(e,t,r,s,i);return a?a.largeTextureIndex:(console.warn("LargeTexManager: not found texture to update!"),-1)}return-1}getTexture(e,t=-1){const r=this._findTexture(e,t);if(r){const e={};return e.texItem=r,e.texture=this.largeTexs[r.largeTextureIndex],e.texCode=r.largeTextureIndex,e}return null}getTextureByRef(e,t=-1){return this.getTexture(e.id,t)}getLargeTex(e){return this.largeTexs[e]}removeTexture(e,t=-1){if(!this._texItems)return;const r=this.LARGE_TEX_W/this.TEX_SIZE_MIN;let s=0,i=0,a=0,n=0;if(t>=0){if(t<this.LARGE_TEX_N){const o=this._texItems[t];let l=this._texMaps[t];for(let t=o.length-1;t>-1;t--)if(o[t].isSelf(e)){const e=o[t],h=e.largeTextureIndex;s=e.pos.x,i=e.pos.y,a=e.pos.z+s,n=e.pos.w+i,l=this._texMaps[h];for(let e=i;e<n;e++)for(let t=s;t<a;t++)l[e*r+t]=0;this.fillWithColor(h,s*this.TEX_SIZE_MIN,i*this.TEX_SIZE_MIN,e.pos.z*this.TEX_SIZE_MIN,e.pos.w*this.TEX_SIZE_MIN,this.backColor.x,this.backColor.y,this.backColor.z,this.backColor.w),o.splice(t,1),this.usedCapacity-=e.pos.z*e.pos.w}}}else for(let t=0;t<this.LARGE_TEX_N;t++)this.removeTexture(e,t)}clear(){for(let e=this.largeTexs.length-1;e>-1;e--)this.largeTexs[e]&&this.largeTexs[e].destroy();this.largeTexs.length=0;const e=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,t=this.LARGE_TEX_H/this.TEX_SIZE_MIN|0;for(let r=0;r<this.LARGE_TEX_N;r++)this._texItems[r].length=0,this._texMaps[r]=new Array(e*t).fill(0);this.usedCapacity=0,this._cmdBuffer.clear()}destroy(e=!1){if(!this.destroyed){for(let t=0;t<this.largeTexs.length;t++)this.largeTexs[t]&&(e?this.largeTexs[t].lock=!1:this.largeTexs[t].destroy());this.largeTexs=null,this._texMaps=null,this._texItems=null,this.updateHook=null,this._cmdBuffer.clear(),this._cmdBuffer=null,this.destroyed=!0}}_findTexture(e,t=-1){if(t>=0){if(t<this.LARGE_TEX_N){const r=this._texItems[t],s=r.length;for(let t=0;t<s;t++)if(r[t].isSelf(e))return r[t]}}else for(let t=0;t<this.LARGE_TEX_N;t++){const r=this._texItems[t],s=r.length;for(let t=0;t<s;t++)if(r[t].isSelf(e))return r[t]}return null}removeAllTextures(){const e=this.LARGE_TEX_W/this.TEX_SIZE_MIN,t=this.LARGE_TEX_H/this.TEX_SIZE_MIN;for(let r=0;r<this.LARGE_TEX_N;r++){for(let s=0;s<t;s++)for(let t=0;t<e;t++)this._texMaps[r][s*e+t]=0;this.largeTexs[r]=null,this._texItems[r].length=0}this.usedCapacity=0}createLargeTex(e,t,r){const s=this.mipMap,i=this.texMode,a=this.texAnisoLevel;if(t=t||this.sRGB,r=r||this.gammaCorrection,e>=0&&e<this.LARGE_TEX_N&&!this.largeTexs[e]){const r=new Md(this.LARGE_TEX_W,this.LARGE_TEX_H,this.texFormat,null,s,4,t,this.gammaCorrection);r.lock=!0,r.filterMode=i,r.anisoLevel=a,r.wrapModeU=this.texWrap,r.wrapModeV=this.texWrap,r.cmdBuffer=this._cmdBuffer,r.immediately=this.immediately,r.name=this.name,this.largeTexs[e]=r,(this.backColor.x>0||this.backColor.y>0||this.backColor.z>0||this.backColor.w>0)&&this.fillWithColor(e,0,0,this.LARGE_TEX_W,this.LARGE_TEX_H,this.backColor.x,this.backColor.y,this.backColor.z,this.backColor.w)}}static calcTexSize(e,t,r,s,i){const a=e*r|0,n=t*r|0;let o=(a+2*i)/s,l=(n+2*i)/s;return o!=(0|o)&&(o=1+(0|o)),l!=(0|l)&&(l=1+(0|l)),[a,n,o,l]}_addTexture(e,t,r=-1,s=null,i=!1){if(!e||e instanceof Hi==0)return null;let a;if(this.checkDup&&(a=this._findTexture(e.id,r),a&&!a.token))return a;const n=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0;if(a&&a.token){a.token=!1,a.id=e.id;const t=a.pos.x+a.pos.z,r=a.pos.y+a.pos.w,s=a.w*this.LARGE_TEX_W,o=a.h*this.LARGE_TEX_H;for(let e=a.pos.y;e<r;e++)for(let r=a.pos.x;r<t;r++)this._texMaps[a.largeTextureIndex][e*n+r]=a.id;return this.largeTexs[a.largeTextureIndex]||this.createLargeTex(a.largeTextureIndex),this.largeTexs[a.largeTextureIndex].addTexture(this.TEX_SIZE_MIN*a.pos.x+this.EXTEND_SIZE,this.TEX_SIZE_MIN*a.pos.y+this.EXTEND_SIZE,s,o,this.EXTEND_SIZE,e,i),a}{const a=Pd.calcTexSize(e.width,e.height,t,this.TEX_SIZE_MIN,this.EXTEND_SIZE);let o=this._findRoom(a[2],a[3],r);if(o[0]<0&&this.autoExtend&&(this.adjustLtn(),o=this._findRoom(a[2],a[3],r)),o[0]>=0){const r=new Id;r.id=e.id,r.largeTextureIndex=o[0],r.x=(o[2]*this.TEX_SIZE_MIN+this.EXTEND_SIZE)/this.LARGE_TEX_W,r.y=(o[1]*this.TEX_SIZE_MIN+this.EXTEND_SIZE)/this.LARGE_TEX_H,r.w=a[0]/this.LARGE_TEX_W,r.h=a[1]/this.LARGE_TEX_H,r.pos.x=o[2],r.pos.y=o[1],r.pos.z=a[2],r.pos.w=a[3],r.scale=t,r.url=s||e.url,this._addToTextureItem(r),this.usedCapacity+=a[2]*a[3];const l=o[2]+a[2],h=o[1]+a[3];for(let e=o[1];e<h;e++)for(let t=o[2];t<l;t++)this._texMaps[r.largeTextureIndex][e*n+t]=r.id;return this.largeTexs[r.largeTextureIndex]||this.createLargeTex(r.largeTextureIndex),this.largeTexs[r.largeTextureIndex].addTexture(this.TEX_SIZE_MIN*o[2]+this.EXTEND_SIZE,this.TEX_SIZE_MIN*o[1]+this.EXTEND_SIZE,a[0],a[1],this.EXTEND_SIZE,e,i),r}}return null}_addPlaceholder(e,t,r,s=1,i=-1){const a=this._findTexture(e,i);if(a)return a;const n=Pd.calcTexSize(t,r,s,this.TEX_SIZE_MIN,this.EXTEND_SIZE);let o=this._findRoom(n[2],n[3],i);if(o[0]<0&&this.autoExtend&&(this.adjustLtn(),o=this._findRoom(n[2],n[3],i)),o[0]>=0){const t=new Id;t.largeTextureIndex=o[0],t.x=(o[2]*this.TEX_SIZE_MIN+this.EXTEND_SIZE)/this.LARGE_TEX_W,t.y=(o[1]*this.TEX_SIZE_MIN+this.EXTEND_SIZE)/this.LARGE_TEX_H,t.w=n[0]/this.LARGE_TEX_W,t.h=n[1]/this.LARGE_TEX_H,t.pos.x=o[2],t.pos.y=o[1],t.pos.z=n[2],t.pos.w=n[3],t.scale=s,t.token=!0,e&&(t.url=e),this._addToTextureItem(t),this.usedCapacity+=n[2]*n[3];const r=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,i=t.largeTextureIndex,a=o[2]+n[2],l=o[1]+n[3];for(let e=o[1];e<l;e++)for(let t=o[2];t<a;t++)this._texMaps[i][e*r+t]=2147483647;return t}return null}_updateTexture(e,t,r=-1,s=null,i=!1){if(!e)return null;const a=this._findTexture(e.id,r);if(!a||a.scale!=t)return null;const n=e.width,o=e.height,l=Pd.calcTexSize(n,o,t,this.TEX_SIZE_MIN,this.EXTEND_SIZE);if(a.pos.z!=l[2]||a.pos.w!=l[3])return null;const h=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0;if(a.token){a.token=!1,a.id=e.id;const t=a.pos.x+a.pos.z,r=a.pos.y+a.pos.w,s=a.w*this.LARGE_TEX_W,n=a.h*this.LARGE_TEX_H;for(let e=a.pos.y;e<r;e++)for(let r=a.pos.x;r<t;r++)this._texMaps[a.largeTextureIndex][e*h+r]=a.id;return this.largeTexs[a.largeTextureIndex]||this.createLargeTex(a.largeTextureIndex),this.largeTexs[a.largeTextureIndex].addTexture(this.TEX_SIZE_MIN*a.pos.x+this.EXTEND_SIZE,this.TEX_SIZE_MIN*a.pos.y+this.EXTEND_SIZE,s,n,this.EXTEND_SIZE,e,i),a}return a.id=e.id,s&&(a.url=s),this.largeTexs[a.largeTextureIndex]||this.createLargeTex(a.largeTextureIndex),this.largeTexs[a.largeTextureIndex].addTexture(this.TEX_SIZE_MIN*a.pos.x+this.EXTEND_SIZE,this.TEX_SIZE_MIN*a.pos.y+this.EXTEND_SIZE,l[0],l[1],this.EXTEND_SIZE,e,i),a}_takeRoomInMap(e,t,r){const s=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,i=this._peekRoomInMap(e,t,r);if(i[0]<0)return!1;const a=i[1],n=i[0],o=e+i[1],l=t+i[0];for(let e=n;e<l;e++)for(let t=a;t<o;t++)r[e*s+t]=2147483647;return!0}_peekRoomInMap(e,t,r){const s=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,i=this.LARGE_TEX_H/this.TEX_SIZE_MIN|0;for(let a=0;a<i-t+1;a++)for(let i=0;i<s-e+1;i++){let n=!1;if(r[a*s+i]>0&&(n=!0),!n){for(let o=a;o<a+t&&!n;o++)for(let t=i;t<i+e&&!n;t++)r[o*s+t]>0&&(n=!0);if(!n)return[a,i]}}return[-1,-1]}_findRoom(e,t,r=-1){if(r>=0){if(r<this.LARGE_TEX_N){const s=this._peekRoomInMap(e,t,this._texMaps[r]);return[r,s[0],s[1]]}return[-1,-1,-1]}for(let r=0;r<this.LARGE_TEX_N;r++){const s=this._peekRoomInMap(e,t,this._texMaps[r]);if(s[0]>=0)return[r,s[0],s[1]]}return[-1,-1,-1]}_addToTextureItem(e,t=!1){const r=this._texItems[e.largeTextureIndex];if(t){const t=r.length;for(let s=0;s<t;s++)if(e.w*e.h>r[s].w*r[s].h)return void r.splice(s,0,e)}r.push(e)}}Pd._largeTexSize=[[8,8],[16,8],[8,16],[16,16],[32,16],[16,32],[32,32],[64,32],[32,64],[64,64],[128,64],[64,128],[128,128],[256,128],[128,256],[256,256],[512,256],[256,512],[512,512],[1024,512],[512,1024],[1024,1024],[2048,1024],[1024,2048],[2048,2048]];class Bd extends Pd{constructor(t,r,s=16,i=0,n=e.RenderTargetFormat.R8G8B8A8){super(t,r,s,i,n),this.COLOR_ITEM_SIZE=4,this._curColor=[],this._curColorUV=new $e,this._curColorMap=[],this._largeTexCode=0,this._reserve=!1,this.active=!0,Ad.addMgr(this);for(let e=0;e<this.LARGE_TEX_N;e++)this._curColor[e]=new a(0,0,-1),this._curColorMap[e]=[]}addDummySideTexture(e=-1){this.addTexture(Hi.blackTexture,64,e,null,!0)}addColor(e,t=-1){return this._addColor(e.x,e.y,e.z,e.w,t)}getColor(e,t,r=-1){let s=this._largeTexCode;r&&r>=0&&r<this.LARGE_TEX_N&&(s=r);const i=this._findColor(e.x,e.y,e.z,e.w,s);return i?(t&&(t.x=i.u,t.y=i.v,t.z=1/this.LARGE_TEX_W,t.w=1/this.LARGE_TEX_H),this.largeTexs[s]):null}getReserve(){return this._reserve}setReserve(e){this._reserve=e}destroy(e=!1){Ad.removeMgr(this),super.destroy(e),this.active=!1}_findColor(t,r,s,i,a){if(a>=0&&a<this.LARGE_TEX_N){const n=this._curColorMap[a].length;if(this.texFormat==e.RenderTargetFormat.R8G8B8){for(let e=0;e<n;e++)if(this._curColorMap[a][e]&&this._curColorMap[a][e].r==t&&this._curColorMap[a][e].g==r&&this._curColorMap[a][e].b==s)return this._curColorMap[a][e]}else if(this.texFormat==e.RenderTargetFormat.R8G8B8A8)for(let e=0;e<n;e++)if(this._curColorMap[a][e]&&this._curColorMap[a][e].r==t&&this._curColorMap[a][e].g==r&&this._curColorMap[a][e].b==s&&this._curColorMap[a][e].a==i)return this._curColorMap[a][e]}return null}removeAllTextures(){super.removeAllTextures();for(let e=0;e<this.LARGE_TEX_N;e++)this._curColor[e].setValue(0,0,0),this._curColorMap[e].length=0;this._largeTexCode=0}_addColor(e,t,r,s,a){let n=this._largeTexCode;a&&a>=0&&a<this.LARGE_TEX_N&&(n=a);let o=this._findColor(e,t,r,s,n);if(o)return this._curColorUV.x=o.u,this._curColorUV.y=o.v,n;o={};let l=-1;const h=this.TEX_SIZE_MIN/this.COLOR_ITEM_SIZE|0;if(this._curColor[n].z>=0&&this._curColor[n].z<h*h)l=n;else{const e=this._findRoom(1,1,1);if(-1!=e[0]){const t=new Id;t.id=1,this._addToTextureItem(t);const r=this.LARGE_TEX_W/this.TEX_SIZE_MIN,s=e[0],i=e[1],a=e[2],n=i*r+a;this._texMaps[s][n]=1,this._curColor[s].x=a,this._curColor[s].y=i,this._curColor[s].z=0,this._largeTexCode=s,l=this._largeTexCode,this.largeTexs[s]||this.createLargeTex(s)}}if(l>=0){let a=this._curColor[l].z%h,n=this._curColor[l].z/h|0;return a=this._curColor[l].x*this.TEX_SIZE_MIN+(a+.5)*this.COLOR_ITEM_SIZE,n=this._curColor[l].y*this.TEX_SIZE_MIN+(n+.5)*this.COLOR_ITEM_SIZE,this._curColorUV.x=a/this.LARGE_TEX_W,this._curColorUV.y=n/this.LARGE_TEX_H,o.r=e,o.g=t,o.b=r,o.a=s,o.u=this._curColorUV.x,o.v=this._curColorUV.y,o.largeTextureIndex=l,this._curColorMap[l].push(o),this._curColor[l].z++,this.largeTexs[l].addColor(a-.5*this.COLOR_ITEM_SIZE,n-.5*this.COLOR_ITEM_SIZE,this.COLOR_ITEM_SIZE,this.COLOR_ITEM_SIZE,new i(e,t,r,s),this.texFormat),l}return-1}_peekRoomInMap(e,t,r){const s=this.LARGE_TEX_W/this.TEX_SIZE_MIN|0,i=this.LARGE_TEX_H/this.TEX_SIZE_MIN|0,a=s/2|0,n=i/2|0;for(let o=0;o<i-t+1;o++)for(let i=0;i<s-e+1;i++){let l=!1;if(r[o*s+i]>0&&(l=!0),!l){for(let h=o;h<o+t&&!l;h++)for(let t=i;t<i+e&&!l;t++)(this._reserve&&h>n&&t>a||r[h*s+t]>0)&&(l=!0);if(!l)return[o,i]}}return[-1,-1]}getBase64(){let e=[];return this.largeTexs.forEach(t=>{e.push(Q.uint8ArrayToArrayBufferAsync(t))}),Promise.all(e)}}class Ld{recover(){this.owner.removeByTexture2DId(this.textureId,-1,!1)}}class Nd{constructor(t,r=!0){this._textureMap=new Map,this._textureIdMap=new Map,this._isDestroyed=!1,this._autoReplace=!1,this._totalDrawCount=1,this._waitReplace=new Set,this._config=Object.assign({largeTextureSize:[1024,1024],maxLargeTextures:4,textureUnitSize:16,extendSize:1,textureFormat:e.RenderTargetFormat.R8G8B8A8,immediately:!1,autoExtend:!0,checkDuplicate:!0},t),this._largeTexManager=new Bd(this._config.largeTextureSize,this._config.maxLargeTextures,this._config.textureUnitSize,this._config.extendSize,this._config.textureFormat),this._largeTexManager.gammaCorrection=2.2,this._largeTexManager.sRGB=!1,this._largeTexManager.immediately=this._config.immediately,this._largeTexManager.autoExtend=this._config.autoExtend,this._largeTexManager.checkDup=this._config.checkDuplicate,this._largeTexManager.name="DynamicAtlas",this._autoReplace=r,r&&(this._largeTexManager.updateHook=this.afterUpdate.bind(this)),this._totalDrawCount=this._config.extendSize>0?2:1}_getTexture2DByUrl(e){if(!e)return null;let t=jo.loader.getRes(e,Te.TEXTURE2D);if(t)return t;let r=jo.loader.getRes(e,Te.IMAGE);return r&&r.bitmap?r.bitmap:null}_getTexture2DId(e){return this._textureIdMap.get(e)||null}_findSmallTexture(e,t){let r=t.textureMap,s=e.bitmap,i=t.textureId;(e=>{let a=e._atlas;a&&(a.frames.forEach(e=>{e.bitmap==s&&(e._dynamic=t,r.set(e.id,{texture:e,uv:e.uv}),this._textureIdMap.set(e.id,i))}),a.textures.forEach(e=>{e.bitmap==s&&(e._dynamic=t,r.set(e.id,{texture:e,uv:e.uv}),this._textureIdMap.set(e.id,i))}))})(e),e._dynamic!=t&&(r.set(e.id,{texture:e,uv:e.uv}),e._dynamic=t,this._textureIdMap.set(e.id,i))}addTexture(e,t=1,r=-1){if(this._isDestroyed||!e||!e.bitmap)return!1;let s=e.bitmap,a=s.id,n=this._textureMap.get(a);if(n){let t=n.textureMap;return t.has(e.id)||(t.set(e.id,{texture:e,uv:e.uv}),this._textureIdMap.set(e.id,a),this._autoReplace&&n.merged&&(this._waitReplace.add(a),jo.timer.callLater(this,this.onUpdate))),!0}let o=this._largeTexManager.addTexture(s,t,r,e.url,!1);if(o<0)return console.warn(`DynamicAtlasManager: 纹理 ${a} 添加失败,空间不足`),!1;let l=this._largeTexManager.getTexture(a,o);return n=new Ld,n.textureMap=new Map,n.source=s,n.textureId=a,n.url=s.url||"",n.uv=new i(l.texItem.x,l.texItem.y,l.texItem.w,l.texItem.h),n.largeTextureIndex=o,n.isInAtlas=!0,n.merged=!1,n.drawCompletedCount=0,n.referenceCount=0,n.owner=this,this._findSmallTexture(e,n),this._textureMap.set(a,n),!0}onUpdate(){if(this._waitReplace.size>0)for(const e of this._waitReplace){let t=this._textureMap.get(e);t&&this._replaceTexture(t,this._largeTexManager.getTexture(e,t.largeTextureIndex))}this._waitReplace.clear()}afterUpdate(e,t){if(!this._isDestroyed&&t&&0!==t.length)for(const r of t){let t=this._textureMap.get(r);if(!t||!t.isInAtlas)continue;if(t.merged)continue;if(t.drawCompletedCount++,t.drawCompletedCount<this._totalDrawCount)continue;const s=this._largeTexManager.getTexture(r,e);s&&s.texture&&s.texItem&&this._replaceTexture(t,s)}}addTextureByUrl(e,t=1,r=-1){if(this._isDestroyed||!e)return!1;let s=l.loader.getRes(e,Te.IMAGE);return s?s.bitmap?this.addTexture(s,t,r):(console.warn(`DynamicAtlasManager: 纹理 ${e} 的 bitmap 为空,无法添加到图集`),!1):(console.warn(`DynamicAtlasManager: 纹理 ${e} 未加载,请先加载纹理`),!1)}addTextures(e,t=1,r=-1){let s=0;for(const i of e)this.addTexture(i,t,r)&&s++;return s}addTexturesByUrl(e,t=1,r=-1){let s=0;for(const i of e)this.addTextureByUrl(i,t,r)&&s++;return s}removeTexture(e,t=-1,r=!0){return!this._isDestroyed&&this.removeByTexture2DId(this._getTexture2DId("number"==typeof e?e:e.id),t)}removeByTexture2DId(e,t=-1,r=!0){if(this._isDestroyed)return!1;let s=this._textureMap.get(e);if(!s)return!1;this._largeTexManager.removeTexture(e,t),this._textureMap.delete(e);let i=s.source;return i&&!i.destroyed||s.url&&(i=jo.loader.getRes(s.url,Te.TEXTURE2D)),!i||i.destroyed||s.textureMap.forEach(({texture:e,uv:t},s)=>{e.bitmap=i,e.uv=t,e._dynamic=null,this._textureIdMap.delete(s),r&&e.event(c.CHANGE)}),!0}removeTextureByUrl(e,t=-1){if(!e)return!1;let r=jo.loader.getRes(e,Te.IMAGE);if(r&&r._dynamic){let e=r._dynamic;return this.removeByTexture2DId(e.textureId,t)}for(let[r,s]of this._textureMap)if(s.url===e)return this.removeByTexture2DId(r,t);return console.warn(`DynamicAtlasManager: 纹理 ${e} 未在图集中找到`),!1}_replaceTexture(e,t){e.merged=!0;let r=e.textureMap,s=t.texture,i=t.texItem.x,a=t.texItem.y,n=t.texItem.w,o=t.texItem.h;return r.forEach(({texture:t,uv:r},l)=>{if(t.bitmap!==s){let l,h=t.sourceWidth,u=t.sourceHeight,d=t.width,_=t.height;if(r===ie.DEF_UV)l=Float32Array.from([i,a,i+n,a,i+n,a+o,i,a+o]);else{let e=r[0],t=r[1],s=r[2]-e,h=r[5]-t,u=i+e*n,d=a+t*o,c=s*n,_=h*o;l=Float32Array.from([u,d,u+c,d,u+c,d+_,u,d+_])}t.setTo(s,l,h,u),t.event(c.CHANGE),t.width=d,t.height=_,t._dynamic=e}}),!0}replaceOriginalTexture(e){if(this._isDestroyed)return!1;let t=this._textureMap.get(e);if(!t||!t.isInAtlas)return!1;const r=this._largeTexManager.getTexture(e,t.largeTextureIndex);return r&&r.texture&&r.texItem?(this._replaceTexture(t,r),!0):(console.warn(`DynamicAtlasManager: 无法获取纹理 ${e} 的图集信息`),!1)}replaceOriginalTextures(e){let t=0;if(e&&e.length>0)for(const r of e)this.replaceOriginalTexture(r)&&t++;else for(const[e,r]of this._textureMap)r.isInAtlas&&this.replaceOriginalTexture(e)&&t++;return t}getTextureInfo(e){return this._textureMap.get(e)||null}getTextureInfoByUrl(e){if(!e)return null;let t=this._getTexture2DByUrl(e);return t&&this.getTextureInfo(t.id)||null}getLargeTexture(e){return this._largeTexManager.getLargeTex(e)}getAllLargeTextures(){return this._largeTexManager.largeTexs}getTextureCount(){return this._textureMap.size}clear(){this._largeTexManager.clear(),this._textureMap.clear(),this._textureIdMap.clear()}destroy(){this._isDestroyed||(this.clear(),this._isDestroyed=!0)}getStatistics(){return{textureCount:this.getTextureCount(),usageRate:this._largeTexManager.getLoadUsageRate(),gpuMemoryUsage:this._largeTexManager.calculateGpuMemory(),largeTextureCount:this._largeTexManager.largeTexs.length,config:this._config}}cleanupUnusedTextures(e=!1){if(this._isDestroyed)return 0;let t=0;const r=[];for(const[t,s]of this._textureMap)(e||s.referenceCount<=0)&&r.push(t);for(const e of r)this.removeByTexture2DId(e)&&t++;return t}}class Fd extends Su{cloneTo(e){super.cloneTo(e),e.value=this.value}clone(){let e=new Fd;return this.cloneTo(e),e}}class Od extends Su{cloneTo(e){super.cloneTo(e),e.value||(e.value=new dh),console.warn("PathPointKeyframe.cloneTo() not implemented yet.")}clone(){let e=new Od;return this.cloneTo(e),e}}class Ud extends Su{constructor(){super(...arguments),this.value=""}cloneTo(e){super.cloneTo(e),e.value=this.value}clone(){let e=new Ud;return this.cloneTo(e),e}}class kd{constructor(e,t,r,s){this.minDepth=0,this.maxDepth=1,this.x=null!=e?e:0,this.y=null!=t?t:0,this.width=null!=r?r:0,this.height=null!=s?s:0}project(e,t,r){a.transformV3ToV4(e,t,r);var s=r.x,i=r.y,n=r.z,o=r.w;1!==o&&(s/=o,i/=o,n/=o),r.x=.5*(s+1)*this.width+this.x,r.y=.5*(1-i)*this.height+this.y,r.z=n*(this.maxDepth-this.minDepth)+this.minDepth}unprojectFromMat(e,t,r){var s=t.elements;r.x=(e.x-this.x)/this.width*2-1,r.y=-((e.y-this.y)/this.height*2-1),r.z=(e.z-this.minDepth)/(this.maxDepth-this.minDepth);var i=r.x*s[3]+r.y*s[7]+r.z*s[11]+s[15];a.transformV3ToV3(r,t,r),1!==i&&(r.x=r.x/i,r.y=r.y/i,r.z=r.z/i)}unprojectFromWVP(e,t,r,s,i){nt.multiply(t,r,Gd),s&&nt.multiply(Gd,s,Gd),Gd.invert(Gd),this.unprojectFromMat(e,Gd,i)}set(e,t,r,s){this.x=e,this.y=t,this.width=r,this.height=s}cloneTo(e){e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e.minDepth=this.minDepth,e.maxDepth=this.maxDepth}}kd.TEMP=new kd(0,0,0,0);const Gd=new nt;class Vd{constructor(){this._size=0,this._lastCheck=0,this._items={}}add(e,r,s){this._items[e]&&(this._size-=this._items[e].size);let i=performance.now();if(this._items[e]={obj:r,size:s,time:i},this._size+=s,this._size>t.audioBufferCacheMaxSize&&i-this._lastCheck>1e4){this._lastCheck=i;for(let e in this._items){let t=this._items[e];i-t.time>3e4&&(this._size-=t.size,delete this._items[e],console.debug("AudioDataCache: remove "+e))}}}get(e,t,r){let s=this._items[e];if(null!=s)return s.time=performance.now(),void t.call(r,s.obj);l.loader.load(e,{type:Te.SOUND,cache:!1,ignoreCache:!1}).then(s=>{s&&this.add(e,s,s.__byteLength),t.call(r,s)})}}class zd extends N{get playbackRate(){return this._playbackRate}set playbackRate(e){e!==this._playbackRate&&(this._playbackRate=e,this._loaded&&this.onPlaybackRateChanged())}constructor(e){super(),this._started=!1,this._paused=!1,this._loaded=!1,this._completed=!1,this._repeated=0,this._volumeSet=1,this._volume=1,this._playbackRate=1,this._muted=!1,this._startTime=0,this._pauseTime=0,this._isMusic=!1,this._autoResume=!1,this.url=e}get volume(){return this._volumeSet}set volume(e){this._volumeSet=e;let t=e*(this._isMusic?Vo.musicVolume:Vo.soundVolume);t!==this._volume&&(this._volume=t,this._loaded&&this.onVolumeChanged())}get muted(){return this._muted}set muted(e){e=!!e,this._muted!=e&&(this._muted=e,this._loaded&&this.onMuted())}get position(){return this._paused?this._pauseTime:0!=this._startTime?(performance.now()-this._startTime)/1e3+this.startTime:this.startTime}get duration(){return 0}get paused(){return this._paused}get isStopped(){return!this._started}play(){this._started?this._paused&&this.resume():(this._started=!0,this._loaded=!1,this._completed=!1,this._repeated=0,this._startTime=performance.now(),Vo.addChannel(this),J.inst.resolveURL(this.url,e=>{this._started&&(e?this.onPlay(e):this.stop())}))}stop(){this._started&&(this._started=!1,this._loaded=!1,Vo.removeChannel(this),this.onStop(),this.callComplete(this._completed))}pause(){this._started&&!this._paused&&(this._pauseTime=this.position,this._paused=!0,this._autoResume=!1,this._loaded&&this.onPause())}resume(){this._started&&this._paused&&(this._paused=!1,this._loaded&&this.onResume())}onPlay(e){}onPlayAgain(){}onStop(){}onPause(){}onResume(){}onVolumeChanged(){}onMuted(){}onPlaybackRateChanged(){}onPlayEnd(){this._repeated++,this.loops>0&&this._repeated>=this.loops?(this._completed=!0,this.stop()):this.onPlayAgain()}callComplete(e){if(e&&this.event(c.COMPLETE),!this.completeHandler)return;let t=this.completeHandler;this.completeHandler=null,t instanceof he?t.runWith(null==e||e):t(null==e||e)}}class Hd extends zd{get position(){return this._ele?this._ele.currentTime:0}get duration(){return this._ele?this._ele.duration:0}onPlay(e){this._ele=Hd.elementPool.take(),Y.container.appendChild(this._ele),this._loaded=!0;let t=this._ele;if(t.onerror=e=>{console.error("HTMLAudioChannel: ",e),this.stop()},t.onended=()=>this.onPlayEnd(),t.src=ee.postFormatURL(ee.formatURL(e)),t.playbackRate=this.playbackRate,t.currentTime=this.startTime,t.loop=0===this.loops,t.volume=this._volume,t.muted=this._muted,!this._paused){if(t.readyState>0&&!t.paused)return;Promise.resolve().then(()=>{this._ele&&this._ele.play().catch(e=>{"NotAllowedError"===e.name&&this._isMusic?W.media.resumeUntilGotFocus(this):console.warn(e)})})}}onPlayAgain(){this._ele&&(this._ele.currentTime=this.startTime,this._ele.play().catch(e=>{}))}onStop(){this._ele.pause(),Hd.elementPool.recover(this._ele),this._ele=null}onPause(){this._ele.pause()}onResume(){0===this._ele.readyState&&this._ele.load(),this._ele.play().catch(e=>{})}onVolumeChanged(){this._ele.volume=this._volume}onMuted(){this._ele.muted=this._muted}onPlaybackRateChanged(){this._ele&&(this._ele.playbackRate=this.playbackRate)}}Hd.elementPool=h.createPool2(()=>Y.createElement("audio"),null,e=>function(e){e.remove(),e.src="",e.onended=null,e.onerror=null,e.oncanplay=null,e.oncanplaythrough=null}(e));class Wd{constructor(){this.options={},this.allowBackground=!1,this._playing=!1,this._loaded=!1,this._autoResume=!1}get currentTime(){return 0}set currentTime(e){}get volume(){return 0}set volume(e){}get muted(){return!1}set muted(e){}get duration(){return 0}get ended(){return!1}get loop(){return!1}set loop(e){}get playbackRate(){return 1}set playbackRate(e){}get paused(){return!1}attachTo(e){this._owner&&(this._owner.off(c.TRANSFORM_CHANGED,this,this.onTransformChanged),l.stage.off(c.RESIZE,this,this.onTransformChanged)),this._owner=e,this._owner&&(this._owner.on(c.TRANSFORM_CHANGED,this,this.onTransformChanged),l.stage.on(c.RESIZE,this,this.onTransformChanged))}load(e){e&&J.inst.resolveURL(e,e=>this.onLoad(e))}play(){!this._playing&&p.isPlaying&&(this._playing=!0,l.stage.on(c.BLUR,this,this.onBlur),this._loaded&&this.onPlay())}pause(){this._autoResume=!1,this._playing&&(this._playing=!1,l.stage.off(c.BLUR,this,this.onBlur),this._loaded&&this.onPause())}resume(){this.play()}setLoaded(){this._loaded=!0,this.onTransformChanged(),this._playing&&this.onPlay()}getNodeTransform(){let e;return Y.onTTMiniGame?(e=Tn.getGlobalPosAndScale(this._owner),e.x*=l.stage.clientScaleX,e.y*=l.stage.clientScaleY,e.scaleX*=l.stage.clientScaleX,e.scaleY*=l.stage.clientScaleY):e=Tn.getTransformRelativeToWindow(this._owner,0,0),{x:e.x,y:e.y,width:Math.round(this._owner.width*e.scaleX),height:Math.round(this._owner.height*e.scaleY)}}onTransformChanged(){}destroy(){this.onDestroy(),this.attachTo(null),l.stage.off(c.BLUR,this,this.onBlur)}onBlur(){this.allowBackground||W.media.resumeUntilGotFocus(this)}onLoad(e){}onPlay(){}onPause(){}onDestroy(){}}class Xd extends Wd{constructor(){super(),this.element=Xd.createElement()}get currentTime(){return this.element.currentTime}set currentTime(e){this.element.currentTime=e}get volume(){return this.element.volume}set volume(e){this.element.volume=e}get readyState(){return this.element.readyState}get duration(){return this.element.duration}get ended(){return this.element.ended}get loop(){return this.element.loop}set loop(e){this.element.loop=e}get playbackRate(){return this.element.playbackRate}set playbackRate(e){this.element.playbackRate=e}get muted(){return this.element.muted}set muted(e){this.element.muted=e}onLoad(e){var t;if(this.element.controls=null!==(t=this.options.controls)&&void 0!==t&&t,Xd.setSrc(this.element,e),this.options.underGameView){let e=Y.container;e!==Y.document.body?Y.document.body.insertBefore(this.element,e):Y.document.body.appendChild(this.element)}else Y.document.body.appendChild(this.element);this.onTransformChanged(),this.setLoaded()}onPlay(){this.element.play().catch(e=>{"NotAllowedError"===e.name?W.media.resumeUntilGotFocus(this):console.warn(e)})}onPause(){this.element.pause()}onTransformChanged(){let{x:e,y:t,width:r,height:s}=this.getNodeTransform(),i=this.element.style;i.left=e+"px",i.top=t+"px",i.width=r+"px",i.height=s+"px",W.browser.setStyleTransform(i,"rotate("+l.stage.canvasDegree+"deg)")}onDestroy(){Xd.setSrc(this.element,null),this.element.remove()}static createElement(){let e=Y.createElement("video"),t=e.style;return t.position="absolute",t.top="0px",t.left="0px",W.browser.setStyleTransformOrigin(t,"0 0"),e.setAttribute("crossorigin","anonymous"),Y.onMobile&&(e["x5-playsInline"]=!0,e["x5-playsinline"]=!0,e.x5PlaysInline=!0,e.playsInline=!0,e["webkit-playsInline"]=!0,e["webkit-playsinline"]=!0,e.webkitPlaysInline=!0,e.playsinline=!0,e.style.playsInline=!0,e.crossOrigin="anonymous",e.setAttribute("playsinline","true"),e.setAttribute("x5-playsinline","true"),e.setAttribute("webkit-playsinline","true"),e.autoplay=!0),e}static setSrc(e,t){for(;e.childElementCount;)e.firstChild.remove();if(t)if(t.startsWith("blob:"))e.src=t;else{let r=Y.createElement("source");r.src=ee.postFormatURL(ee.formatURL(t));let s=Q.getFileExtension(t);r.type="m3u8"==s?"application/vnd.apple.mpegurl":"video/"+s,e.appendChild(r)}else e.pause(),e.src=""}}class Yd extends Xh{constructor(){super(),this._needUpdate=!0,this._hasRequestVideoFrame=!1;let e=this.element=Xd.createElement();if(e.addEventListener("loadedmetadata",()=>this.setLoaded(this.element.videoWidth,this.element.videoHeight,Y.onLayaRuntime)),e.addEventListener("canplay",()=>{!this._loaded&&this.element.videoWidth>0&&this.element.videoHeight>0&&this.setLoaded(this.element.videoWidth,this.element.videoHeight,Y.onLayaRuntime),this.event("canplay"),this._playing||this.render(!0)}),e.addEventListener("ended",()=>{this.event("ended")}),"requestVideoFrameCallback"in HTMLVideoElement.prototype){const t=this;function r(){t._needUpdate=!0,e.requestVideoFrameCallback(r)}e.requestVideoFrameCallback(r),this._hasRequestVideoFrame=!0}}get currentTime(){return this.element.currentTime}set currentTime(e){this.element.currentTime=e,!this._playing&&this._loaded&&this.render()}get volume(){return this.element.volume}set volume(e){this.element.volume=e}get readyState(){return this.element.readyState}get duration(){return this.element.duration}get ended(){return this.element.ended}get loop(){return this.element.loop}set loop(e){this.element.loop=e}get playbackRate(){return this.element.playbackRate}set playbackRate(e){this.element.playbackRate=e}get muted(){return this.element.muted}set muted(e){this.element.muted=e}onLoad(e){Xd.setSrc(this.element,e),this.element.load()}onPlay(){this.element.play().catch(e=>{"NotAllowedError"===e.name?W.media.resumeUntilGotFocus(this):console.warn(e)})}onPause(){this.element.pause()}onRender(){return!(this._hasRequestVideoFrame&&!this._needUpdate)&&(f.textureContext.updateVideoTexture(this._texture,this.element,!1,!1),this._needUpdate=!1,!0)}onDestroy(){Xd.setSrc(this.element,null),this.element.remove()}}class qd extends zd{get duration(){return this._buffer?this._buffer.duration:0}onPlay(e){W.media.audioDataCache.get(e,this.onLoaded,this)}onPlayAgain(){this.reset(),this.startPlay(!1)}onStop(){this.reset(),this._buffer=null}onPause(){this.reset()}onResume(){this.startPlay(!0)}onVolumeChanged(){if(!this._sourceNode)return;let e=this._muted?0:this._volume;this._gainNode.gain.setTargetAtTime?this._gainNode.gain.setTargetAtTime(e,W.media.audioCtx.currentTime,.001):this._gainNode.gain.value=e}onMuted(){this.onVolumeChanged()}onPlaybackRateChanged(){this.applyPlaybackRate()}onLoaded(e){this._started&&(this._buffer=e,!e||this.startTime>=this.duration?this.stop():(this._loaded=!0,this._paused||this.startPlay(!1)))}startPlay(e){let t=W.media.audioCtx,r=t.state;if("closed"===r)return void this.stop();if("interrupted"===r){let t=e?this._pauseTime:this.startTime;return this._startTime=0,W.media.resumeUntilGotFocus(this),void(this._pauseTime=t)}this._gainNode=qd.gainNodePool.take();let s=this._sourceNode=t.createBufferSource();if(s.buffer=this._buffer,s.connect(this._gainNode),s.onended=()=>this.onPlayEnd(),this.applyPlaybackRate(),s.loop=0===this.loops,s.loopStart=this.startTime,s.loopEnd=this._buffer.duration,this._gainNode.gain.value=this._muted?0:this._volume,s.start(0,e?this._pauseTime:this.startTime),null!=t.state&&"running"!==t.state){let t=e?this._pauseTime:this.startTime;this._startTime=0,W.media.resumeUntilGotFocus(this),this._pauseTime=t}else this._startTime=performance.now()}applyPlaybackRate(){var e;let t=null===(e=this._sourceNode)||void 0===e?void 0:e.playbackRate;t&&(t.setTargetAtTime?t.setTargetAtTime(this.playbackRate,W.media.audioCtx.currentTime,.001):t.value=this.playbackRate)}reset(){if(!this._sourceNode)return;let e=this._sourceNode;e.stop?e.stop(0):e.noteOff(0),e.disconnect(),e.onended=null,this._sourceNode=null,qd.gainNodePool.recover(this._gainNode),this._gainNode=null}}qd.gainNodePool=h.createPool2(()=>function(){let e;e=W.media.audioCtx.createGain?W.media.audioCtx.createGain():W.media.audioCtx.createGainNode();return e}(),e=>function(e){e.connect(W.media.audioCtx.destination)}(e),e=>function(e){e.disconnect()}(e));class $d{open(e,t){let r=null==t?void 0:t.protocols;r&&0!=r.length?this.ws=new Y.window.WebSocket(e,r):this.ws=new Y.window.WebSocket(e),this.ws.binaryType="arraybuffer",this.ws.onopen=e=>this.onOpen({}),this.ws.onclose=e=>this.onClose(e.code,e.reason),this.ws.onerror=e=>this.onError(e),this.ws.onmessage=e=>{e.data&&this.onMessage(e.data)}}close(){this.ws.close()}send(e){return this.ws.send(e),Promise.resolve()}}class Kd extends N{constructor(){super(),this.webSocketClass=$d,this._pixelRatio=1,this.init(),this.initRequestFrameFunction()}init(){var e;let t=Y.document,r=Y.window;this._pixelRatio=Math.max(1,r.devicePixelRatio||1),this.setPlatform(r.navigator.userAgent||"",r.navigator.platform||"");let s="visibilityState",i="visibilitychange",a="fullscreenchange";if(void 0!==t.hidden?(i="visibilitychange",s="visibilityState",a="fullscreenchange"):void 0!==t.mozHidden?(i="mozvisibilitychange",s="mozVisibilityState",a="mozfullscreenchange"):void 0!==t.msHidden?(i="msvisibilitychange",s="msVisibilityState",a="msfullscreenchange"):void 0!==t.webkitHidden&&(i="webkitvisibilitychange",s="webkitVisibilityState",a="webkitfullscreenchange"),this._visibilityStateKey=s,t.addEventListener(i,()=>{this.event(c.VISIBILITY_CHANGE,this.getVisibility()),Y.onAndroid&&!Y.onLayaRuntime&&(this.getVisibility()?this.event(c.FOCUS):this.event(c.BLUR))}),t.addEventListener(a,()=>this.event(c.FULL_SCREEN_CHANGE)),r.addEventListener("resize",()=>this.event(c.RESIZE)),r.addEventListener("orientationchange",e=>this.event(c.ORIENTATION_CHANGE,e)),r.addEventListener("focus",()=>this.event(c.FOCUS)),r.addEventListener("blur",()=>this.event(c.BLUR)),Y.onIOS&&!Y.onLayaRuntime){let e=()=>this.event(c.FOCUS);r.addEventListener("touchstart",e,!0),r.addEventListener("mousedown",e,!0)}r.addEventListener("unhandledrejection",e=>this.event("unhandledrejection",e));let n=t.body.style;n.margin=0,n.overflow="hidden",n["-webkit-user-select"]="none",n["-webkit-tap-highlight-color"]="rgba(200,200,200,0)";let o,l=t.getElementsByTagName("meta"),h={width:"device-width","initial-scale":"1.0","minimum-scale":"1.0","maximum-scale":"1.0","user-scalable":"no"};for(let e=0;e<l.length;e++){let t=l[e];if("viewport"===t.name){o=t;break}}if(o){let e=(o.content||"").split(",");for(let t of e){let e=t.split("=");h[e[0].trim()]||(h[e[0]]=e[1])}}else o=t.createElement("meta"),o.name="viewport",null===(e=t.getElementsByTagName("head")[0])||void 0===e||e.appendChild(o);o.content=Object.keys(h).map(e=>e+"="+h[e])}setPlatform(e,t){-1===(t=(t||"").toLowerCase()).indexOf("openharmony")&&-1===t.indexOf("harmonyos")||(t="ohos"),Y.userAgent=e,Y.onMobile=e.indexOf("Mobile")>-1,Y.onIOS=!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),Y.onIPhone=e.indexOf("iPhone")>-1,Y.onMac=e.indexOf("Mac OS X")>-1,Y.onIPad=e.indexOf("iPad")>-1,Y.onAndroid=e.indexOf("Android")>-1||e.indexOf("Adr")>-1,Y.onOpenHarmonyOS=e.indexOf("OpenHarmony")>-1,Y.onWP=e.indexOf("Windows Phone")>-1,Y.onQQBrowser=e.indexOf("QQBrowser")>-1,Y.onMQQBrowser=e.indexOf("MQQBrowser")>-1||e.indexOf("Mobile")>-1&&e.indexOf("QQ")>-1,Y.onIE=!!window.ActiveXObject||"ActiveXObject"in window,Y.onWeiXin=e.indexOf("MicroMessenger")>-1,Y.onSafari=e.indexOf("Safari")>-1&&-1===e.indexOf("Chrome"),Y.onChrome=e.indexOf("Chrome")>-1,Y.onFirefox=e.indexOf("Firefox")>-1,Y.onEdge=e.indexOf("Edge")>-1||e.indexOf("Edg")>-1,-1!==t.indexOf("ios")?(Y.onIOS=!0,Y.onMobile=!0,e||(Y.onIPhone=!0,Y.onIPad=!0),Y.platform=Y.PLATFORM_IOS,Y.platformName="ios"):-1!==t.indexOf("android")?(Y.onAndroid=!0,Y.onMobile=!0,Y.platform=Y.PLATFORM_ANDROID,Y.platformName="android"):-1!==t.indexOf("ohos")?(Y.onOpenHarmonyOS=!0,Y.onMobile=!0,Y.platform=Y.PLATFORM_ANDROID,Y.platformName="ohos"):-1!==t.indexOf("mac")?(Y.onMac=!0,Y.platform=Y.PLATFORM_PC,Y.platformName="mac"):-1!==t.indexOf("win")?(Y.platform=Y.PLATFORM_PC,Y.platformName="windows"):Y.onAndroid?(Y.platform=Y.PLATFORM_ANDROID,Y.platformName="android"):Y.onIOS?(Y.platform=Y.PLATFORM_IOS,Y.platformName="ios"):(Y.platform=Y.PLATFORM_PC,Y.platformName=t),Y.onPC=!Y.onMobile,Y.onDevTools="devtools"===Y.platformName,Y.isTouchDevice=!0,-1!=e.indexOf("Mozilla/6.0(Linux; Android 6.0; HUAWEI NXT-AL10 Build/HUAWEINXT-AL10)")&&(this._pixelRatio=2)}initRequestFrameFunction(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return setTimeout(e,1e3/60)})}start(){return Promise.resolve()}onInitRender(){}getScreenOrientation(){let e=window.screen.orientation.type;if(null==e){switch(window.orientation){case 0:e="portrait-primary";break;case 180:e="portrait-secondary";break;case 90:e="landscape-primary";break;case-90:e="landscape-secondary"}}return e}getPixelRatio(){return this._pixelRatio}getClientWidth(){return Y.window.innerWidth||Y.document.body.clientWidth||Y.document.documentElement.clientWidth}getClientHeight(){return Y.window.innerHeight||Y.document.body.clientHeight||Y.document.documentElement.clientHeight}setWindowSize(e,t){return!1}setResolution(e,t,r){return!1}setWindowedFullscreen(e){return!1}getVisibility(){return"hidden"!==Y.document[this._visibilityStateKey]}requestFullscreen(){let e=Y.document.documentElement;e&&(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen())}exitFullscreen(){let e=document;e.exitFullscreen?e.exitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.webkitExitFullscreen&&e.webkitExitFullscreen()}createElement(e){return Y.document.createElement(e)}getElementById(e){return Y.document.getElementById(e)}removeElement(e){e&&e.remove()}createMainCanvas(){let e=this.createElement("canvas");e.id="layaCanvas",e.width=2,e.height=2;let t=e.style;t.position="absolute",t.top=t.left="0px",t.background="#000000";let r=Y.document.createElement("div");return r.id="layaContainer",Y.document.body.appendChild(r),r.appendChild(e),e}setCursor(e){Y.isDomSupported&&(Y.document.body.style.cursor=e)}get supportArrayBufferURL(){return!!window.Blob}createBufferURL(e){if(window.Blob){let t=new Blob([e],{type:"application/octet-binary"});return window.URL.createObjectURL(t)}return null}revokeBufferURL(e){window.URL.revokeObjectURL(e)}getOpenDataContextCanvas(){return null}postMessageToOpenDataContext(e){}captureGlobalError(e){this._globalErrorCallback=e,this.onCaptureGlobalError(null!=e,jd)}onCaptureGlobalError(e,t){e?(Y.window.addEventListener("error",t),Y.window.addEventListener("unhandledrejection",t)):(Y.window.removeEventListener("error",t),Y.window.removeEventListener("unhandledrejection",t))}alert(e){Y.window.alert(e)}setStyleTransformOrigin(e,t){e.transformOrigin=e.webkitTransformOrigin=e.msTransformOrigin=e.mozTransformOrigin=e.oTransformOrigin=t}setStyleTransform(e,t){e.transform=e.webkitTransform=e.msTransform=e.mozTransform=e.oTransform=t}createWebSocket(){return this.webSocketClass?new this.webSocketClass:null}}function jd(e){W.browser._globalErrorCallback(e)}W.register("browser",Kd);class Qd extends N{get supportedLocation(){return!1}get supportedGetUserMedia(){return!1}getCurrentPosition(e,t,r){}watchPosition(e,t,r){return-1}clearWatchPosition(e){}getUserMedia(e,t,r){}onStartListeningToType(e){return"devicemotion"===e?this.startListeningDeviceMotion():"deviceorientation"===e&&this.startListeningDeviceOrientation(),this}startListeningDeviceMotion(){}startListeningDeviceOrientation(){}}W.register("device",Qd);class Zd{readFile(e,t){throw new C}writeFile(e,t,r){throw new C}unlink(e){throw new C}copyFile(e,t){throw new C}exists(e){throw new C}getFileSize(e){throw new C}mkdir(e,t){throw new C}rmdir(e,t){throw new C}readdir(e){throw new C}unzip(e,t){throw new C}}W.register("fs",Zd);class Jd{loadFont(e){let t=Q.replaceFileExtension(Q.getBaseName(e.url),""),r=ee.postFormatURL(ee.formatURL(e.url));return Y.window.FontFace?this.loadByFontFace(e,r,t):this.loadByCSS(e,r,t)}loadByFontFace(e,t,r){let s=new Y.window.FontFace(r,"url('"+t+"')");return Y.document.fonts.add(s),s.load().then(()=>s)}loadByCSS(e,t,r){let s="40px "+r;Y.context.font=s;let i=Y.context.measureText(ec).width,a=Y.createElement("style");return a.type="text/css",Y.document.body.appendChild(a),a.textContent="@font-face { font-family:'"+r+"'; src:url('"+t+"');}",new Promise(e=>{let t=()=>{Y.context.font=s,Y.context.measureText(ec).width!=i&&a()},a=()=>{l.systemTimer.clear(this,t),l.systemTimer.clear(this,a),e({family:r})};l.systemTimer.once(1e4,this,a),l.systemTimer.loop(20,this,t)})}}const ec="LayaTTFFont";W.register("font",Jd);class tc{constructor(){this.touchToStart=!0,this._firstTouch=!0,this.audioDataCache=new Vd,this.suspendedMedias=new Set,this.touchToStart=null==W.g,this.init()}init(){let e=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;null!=e&&(this.audioCtx=new e),this.shortAudioClass=this.audioCtx?qd:Hd,this.longAudioClass=Hd,this.videoTextureClass=Yd,this.videoPlayerClass=Xd}createSoundChannel(e,t){return t?new this.longAudioClass(e):new this.shortAudioClass(e)}createVideoTexture(){return null==this.videoTextureClass?(W.warnIncompatibility("VideoTexture"),new Xh):new this.videoTextureClass}createVideoPlayer(){return null==this.videoPlayerClass?(W.warnIncompatibility("VideoPlayer"),new Wd):new this.videoPlayerClass}decodeAudioData(e){return this.audioCtx?this.audioCtx.decodeAudioData(e):Promise.resolve(null)}resumeUntilGotFocus(e){0===this.suspendedMedias.size&&(l.stage.on(c.MOUSE_UP,this,this.onGotFocus),this._firstTouch&&this.touchToStart||l.stage.on(c.FOCUS,this,this.onGotFocus)),this.suspendedMedias.add(e),e.pause(),e._autoResume=!0}canPlayType(e){return"undefined"!=typeof HTMLAudioElement&&"function"==typeof HTMLAudioElement.prototype.canPlayType?(this._testElement||(this._testElement=Y.createElement("audio")),this._testElement.canPlayType(e)):""}onGotFocus(){if(this._firstTouch=!1,l.stage.off(c.MOUSE_UP,this,this.onGotFocus),l.stage.off(c.FOCUS,this,this.onGotFocus),0===this.suspendedMedias.size)return;let e=Array.from(this.suspendedMedias).filter(e=>e._autoResume);this.suspendedMedias.clear(),this.beforeResumeMedias(e).then(()=>{for(let t of e)t._autoResume=!1,t.resume()})}beforeResumeMedias(e){let t=!1;for(let r of e)if(r instanceof qd&&!t){t=!0;let e=this.audioCtx.state;if("suspended"===e||"interrupted"===e)return this.audioCtx.resume().catch(e=>{})}return Promise.resolve()}}W.register("media",tc);class rc{constructor(){this._storage=Y.window.localStorage,this._supported=this.checkSupport()}checkSupport(){return null!=this._storage&&"function"==typeof this._storage.getItem&&"function"==typeof this._storage.setItem}getItem(e){return this._supported?this._storage.getItem(e):null}setItem(e,t){this._supported&&this._storage.setItem(e,t)}removeItem(e){this._supported&&this._storage.removeItem(e)}clear(){this._supported&&this._storage.clear()}getCount(){return this._supported&&this._storage.length||0}}W.register("storage",rc);class sc{constructor(){this._beginFlag=0,this._selectionReady=!1,this._selectionSession=0,this._editInline=!0,this._enterEvent=new c,this._lastTransform={},jo.addAfterInitCallback(()=>{l.stage.on(c.MOUSE_UP,this,this.onTouchEnd),wo.onMouseDownCapture.add(this.onTouchBegin,this)})}begin(e,t){if(this.target===e||0!==this._beginFlag)return Promise.resolve();this._beginFlag=1,this._selectionReady=!1,this._selectionSession++;const r=this.target?this.end(!1,this.target.editable):Promise.resolve();return this._beginTarget=e,r.then(()=>(this.target=e,l.stage.focus=e,this.updateRestrictPattern(),this._lastTransform.x=null,e.on(c.UNDISPLAY,this,this.end),this.onBegin().catch(e=>{console.error("TextInputAdapter begin error:",e)}))).then(()=>{this._editInline&&(this.target.hideText(!0),l.stage.on(c.KEY_DOWN,this,this.onKeyDown)),e.event(c.FOCUS)}).then(()=>t?(this._beginFlag=2,Promise.resolve()):(this._beginFlag=0,this.showKeyboard().catch(e=>{console.error("TextInputAdapter begin error:",e)})))}end(e,t){this._selectionReady=!1,this._selectionSession++,this._beginTarget=null,this._pendingSelection=null;let r=this.target;return r?(this.target=null,l.stage.focus=null,r.off(c.UNDISPLAY,this,this.end),this._editInline&&l.stage.off(c.KEY_DOWN,this,this.onKeyDown),this.onEnd(r,!!e,!!t).then(()=>{this._editInline&&r.hideText(!1),r.editable&&r.event(c.CHANGE),r.event(c.BLUR)}).catch(e=>{console.error("TextInputAdapter end error:",e)})):Promise.resolve()}onBegin(){this.showInputElement();let e=this._visEle,t=this.target;e instanceof HTMLInputElement&&(e.type=this.target.type),e.readOnly=!t.editable,e.maxLength=t.maxChars<=0?1e5:t.maxChars,e.value=this.target.text,e.placeholder=t.localizedPrompt;let r=e.style;return r.fontFamily=t.realFont,r.color=t.color,r.fontSize=t.fontSize+"px",r.whiteSpace=t.wordWrap?"pre-wrap":"nowrap",r.lineHeight=t.leading+t.fontSize+"px",r.fontStyle=t.italic?"italic":"normal",r.fontWeight=t.bold?"bold":"normal",r.textAlign=t.align,r.padding="0 0",r.direction=Pl.RightToLeft?"rtl":"",this.setPromptColor(),this.syncTransform(),this._editInline&&l.systemTimer.frameLoop(1,this,this.syncTransform),Promise.resolve()}onCanShowKeyboard(){return this._visEle&&this._visEle.focus(),Promise.resolve()}onEnd(e,t,r){return Y.document.body.scrollTop=0,e.text=this._visEle.value,this._visEle.blur(),this.hideInputElement(),this._visEle=null,this._editInline&&l.systemTimer.clear(this,this.syncTransform),Promise.resolve()}syncText(){this._visEle&&0===this._beginFlag&&this.updateTargetText(this._visEle.value)}setText(e){this._visEle&&(this._visEle.value=e)}setSelection(e,t){this._visEle&&(this._visEle.selectionStart=e,this._visEle.selectionEnd=t)}setSelectionFor(e,t,r){if(this.target===e&&this._selectionReady)return this._pendingSelection=null,void this.setSelection(t,r);this.begin(e),this.target!==e&&this._beginTarget!==e||(this._pendingSelection={target:e,start:t,end:r})}showKeyboard(){const e=this.target,t=this._selectionSession;return this.onCanShowKeyboard().then(()=>{if(!e||this.target!==e||this._selectionSession!==t)return;this._selectionReady=!0,this._beginTarget=null;const r=this._pendingSelection;this._pendingSelection=null,r&&r.target===e&&this.setSelection(r.start,r.end)})}onTouchBegin(){let e=l.stage.focus,t=wo.touchTarget;e!=t&&(t instanceof $l?this.begin(t,!0):e instanceof $l&&this.end())}onTouchEnd(){0!==this._beginFlag&&(1===this._beginFlag?l.systemTimer.frameOnce(1,this,this.onTouchEnd):(this._beginFlag=0,this.showKeyboard().catch(e=>{console.error("TextInputAdapter begin error:",e)})))}setPromptColor(){this._promptStyleDOM=Y.document.getElementById("promptStyle"),this._promptStyleDOM||(this._promptStyleDOM=Y.document.createElement("style"),this._promptStyleDOM.setAttribute("id","promptStyle"),Y.document.head.appendChild(this._promptStyleDOM));let e=this.target.promptColor;this._promptStyleDOM.innerText=`input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {\n color: ${e}\n }\n input:-moz-placeholder, textarea:-moz-placeholder {\n color: ${e}\n }\n input::-moz-placeholder, textarea::-moz-placeholder {\n color: ${e}\n }\n input:-ms-input-placeholder, textarea:-ms-input-placeholder {\n color: ${e}\n }\n `}updateRestrictPattern(){let e=this.target.restrict;e?(e="[^"+e+"]",e.indexOf("^^")>-1&&(e=e.replace("^^","")),this._restrictPattern=new RegExp(e,"g")):this._restrictPattern=null}validateText(e){return null==e&&(e=""),this.target.multiline||(e=e.replace(/\r?\n/g,"")),this._restrictPattern&&(e=e.replace(/\u2006|\x27/g,""),this._restrictPattern.test(e)&&(e=e.replace(this._restrictPattern,""))),e}showInputElement(){this._eInput||this.createElements();let e="password"===this.target.type,t=this.target.multiline&&!e?this._eTextArea:e?this._ePassword:this._eInput;this._visEle=t,this._container.appendChild(t)}hideInputElement(){this._visEle&&this._visEle.parentElement&&this._visEle.remove()}updateTargetText(e){let t=this.target;this.target=null;let r=t.text!=e;return t.text=e,this.target=t,r}getTargetTransform(){let e=this.target.padding,{x:t,y:r,scaleX:s,scaleY:i}=Tn.getTransformRelativeToWindow(this.target,e[3],e[0]),a=this.target.width-e[1]-e[3],n=this.target.height-e[0]-e[2],o=this._lastTransform;return t!==o.x||r!==o.y||a!==o.width||n!==o.height||s!==o.scaleX||i!==o.scaleY?(o.x=t,o.y=r,o.width=a,o.height=n,o.scaleX=s,o.scaleY=i,o):null}syncTransform(){let e=this.getTargetTransform();if(null!=e){let t=this._visEle.style;t.width=e.width+"px",t.height=e.height+"px",W.browser.setStyleTransform(t,"scale("+e.scaleX+","+e.scaleY+") rotate("+l.stage.canvasDegree+"deg)"),this._container.style.left=e.x+"px",this._container.style.top=e.y+"px"}}createElements(){this._container=Y.document.createElement("div"),Y.container.appendChild(this._container);let e=this._container.style;e.position="absolute",e.zIndex="1E5",this.initElement(this._eTextArea=Y.document.createElement("textarea")),this.initElement(this._eInput=Y.document.createElement("input")),this.initElement(this._ePassword=Y.document.createElement("input"))}initElement(e){let t=e.style;t.cssText="position:absolute;overflow:hidden;resize:none;",t.resize="none",t.backgroundColor="transparent",t.border="none",t.outline="none",t.zIndex="1",W.browser.setStyleTransformOrigin(t,"0 0"),e.addEventListener("input",e=>!e.isComposing&&this.processInputting(e)),e.addEventListener("compositionend",e=>this.processInputting(e)),e.addEventListener("mousemove",e=>this.stopEvent(e),{passive:!1}),e.addEventListener("mousedown",e=>this.stopEvent(e),{passive:!1}),e.addEventListener("touchmove",e=>this.stopEvent(e),{passive:!1})}processInputting(e){if(!this.target)return;let t=e.target,r=this.validateText(t.value);t.value=r,this.updateTargetText(r)&&this.target.event(c.INPUT)}stopEvent(e){"touchmove"==e.type&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()}onKeyDown(e){if("Enter"===e.key||"NumpadEnter"===e.key){let t=this.target;t.multiline||(e.preventDefault(),this._enterEvent.setTo(c.ENTER,this.target,this.target),t.event(c.ENTER,this._enterEvent),this._enterEvent._defaultPrevented||this.target!==t||this.end())}}}W.register("textInput",sc);class ic extends z{static createFromPool(t,r,s,i,a=!1,n=1,o=!1,l=!1,h=!1){var u;if("number"==typeof t&&(a||1!==n||h))throw new Error("RenderTextureMRT requires single sampling, no mipmaps and no storage usage.");const d="number"==typeof t?{width:t,height:r,colorFormats:[s],depthStencilFormat:i,depthTexture:o,sRGB:l}:t,c=ic._getFormats(d),_=c.join(","),p=null!==(u=d.depthStencilFormat)&&void 0!==u?u:e.RenderTargetFormat.None,g=!!d.depthTexture&&p!==e.RenderTargetFormat.None,m=!!d.sRGB;for(let e=0;e<z._pool.length;e++){const t=z._pool[e];if(t instanceof ic&&!t.destroyed&&t._poolLayout===_&&t.width===d.width&&t.height===d.height&&t.depthStencilFormat===p&&t.generateDepthTexture===g&&t._gammaSpace===m){const r=z._pool.pop();return e<z._pool.length&&(z._pool[e]=r),z._poolMemory-=t._renderTarget.gpuMemory/1024/1024,t._inPool=!1,t}}const f=new ic(Object.assign(Object.assign({},d),{colorFormats:c}));return f.lock=!0,f}static _getFormats(t){if(!t||!Array.isArray(t.colorFormats)||0===t.colorFormats.length)throw new RangeError("RenderTextureMRT requires a non-empty colorFormats array.");if(!Number.isInteger(t.width)||!Number.isInteger(t.height)||t.width<=0||t.height<=0)throw new RangeError("RenderTextureMRT dimensions must be positive integers.");if(t.depthTexture&&t.depthStencilFormat===e.RenderTargetFormat.STENCIL_8)throw new Error("A stencil-only MRT attachment cannot be sampled as depth.");if(null==t.colorFormats[0])throw new Error("RenderTextureMRT requires a color attachment at location 0.");const r=Array.from(t.colorFormats,e=>null==e?null:z._getCompatibleColorFormat(e));for(;null===r[r.length-1];)r.pop();return r}get isMRT(){return!0}get colorFormats(){return this._colorFormats}get colorAttachmentCount(){return this._colorFormats.length}get width(){return this._width}set width(e){if(e!==this._width)throw new Error("RenderTextureMRT dimensions are immutable; construct a new instance.")}get height(){return this._height}set height(e){if(e!==this._height)throw new Error("RenderTextureMRT dimensions are immutable; construct a new instance.")}get generateDepthTexture(){return this._generateDepthTexture}set generateDepthTexture(t){if(t&&this.depthStencilFormat===e.RenderTargetFormat.STENCIL_8)throw new Error("A stencil-only MRT attachment cannot be sampled as depth.");if(this.depthStencilFormat===e.RenderTargetFormat.None&&(t=!1),t&&!this._depthStencilTexture){const t=f.textureContext.createRenderTargetDepthTexture(this._renderTarget,e.TextureDimension.Tex2D,this.width,this.height);this._depthStencilTexture=new ac(this,t,this.depthStencilFormat)}this._generateDepthTexture=t}constructor(t){var r,s;const i=Object.freeze(ic._getFormats(t)),{width:a,height:n}=t,o=f.textureContext;if(!o.createMultiRenderTargetInternal)throw new Error("The active render backend does not support MRT.");const l=o.createMultiRenderTargetInternal(a,n,i,null!==(r=t.depthStencilFormat)&&void 0!==r?r:e.RenderTargetFormat.None,!!t.sRGB);super(a,n,i[0],null!==(s=t.depthStencilFormat)&&void 0!==s?s:e.RenderTargetFormat.None,!1,1,!!t.depthTexture,!!t.sRGB,!1),this._colorTextures=[],this._colorFormats=i,this._poolLayout=i.join(","),this._dimension=e.TextureDimension.Tex2D,this._renderTarget=l,this._texture=this._renderTarget._textures[0];for(let e=0;e<this._colorFormats.length;e++){const t=this._colorFormats[e];this._colorTextures.push(null===t?null:new ac(this,this._renderTarget._textures[e],t))}this.generateDepthTexture=this._generateDepthTexture}_createRenderTarget(){if(this.destroyed||this._renderTarget)throw new Error("RenderTextureMRT cannot be recreated.")}_getRenderTarget(e=!1){this._checkAttachment(0);const t=e?this._renderTarget._color0Target:this._renderTarget;if(!t)throw new Error("The MRT backend does not provide a color-0 binding.");return t}getColorTexture(e){return this._checkAttachment(e),this._colorTextures[e]}async getDataAsync(e,t,r,s,i,a=0){if(this._checkAttachment(a),null===this._colorFormats[a])throw new Error(`MRT color attachment ${a} is not allocated.`);return f.textureContext.readRenderTargetPixelDataAsync(this._renderTarget,e,t,r,s,i,a)}getData(...e){throw new Error("RenderTextureMRT synchronous readback is not supported; use getDataAsync.")}recreate(...e){throw new Error("RenderTextureMRT cannot be recreated; construct a new instance.")}_checkAttachment(e){if(this.destroyed||!this._renderTarget)throw new Error("Cannot access a destroyed RenderTextureMRT.");if(!Number.isInteger(e)||e<0||e>=this._colorFormats.length)throw new RangeError(`MRT color attachment index out of range: ${e}.`)}_getSource(){return this._checkAttachment(0),super._getSource()}_disposeResource(){var e;for(const e of this._colorTextures)null==e||e.invalidate();this._colorTextures.length=0,null===(e=this._depthStencilTexture)||void 0===e||e.invalidate(),this._depthStencilTexture=null,this._texture=null,this._renderTarget&&super._disposeResource()}}class ac extends V{constructor(t,r,s){super(t.width,t.height,s),this._owner=t,this._dimension=e.TextureDimension.Tex2D,this._texture=r,this.unmanaged()}get width(){return this._width}set width(e){if(e!==this._width)throw new Error("MRT attachment dimensions are immutable.")}get height(){return this._height}set height(e){if(e!==this._height)throw new Error("MRT attachment dimensions are immutable.")}_addReference(e=1){if(this.destroyed||this._owner.destroyed)throw new Error("Cannot reference a destroyed MRT attachment.");this._referenceCount+=e,this._owner._addReference(e)}_removeReference(e=1){var t;this._referenceCount-=e,null===(t=this._owner)||void 0===t||t._removeReference(e)}_clearReference(){var e;const t=this._referenceCount;this._referenceCount=0,t&&(null===(e=this._owner)||void 0===e||e._removeReference(t))}_getSource(){if(this.destroyed)throw new Error("Cannot sample a destroyed MRT attachment.");return super._getSource()}destroy(){if(!this.destroyed)throw new Error("MRT attachment views cannot be destroyed independently; destroy their owner.")}invalidate(){super.destroy()}_disposeResource(){const e=this._owner;this._owner=null,this._texture=null,this._referenceCount&&e._removeReference(this._referenceCount)}}class nc{static getRT(t,r){return r|=0,(t|=0)>=1e4&&console.error("getRT error! w too big"),new Xa(t,r,e.RenderTargetFormat.R8G8B8A8,e.RenderTargetFormat.None)}static releaseRT(e){e.destroy()}}nc.dict={};class oc extends N{constructor(){super(...arguments),this._tweenDic=[],this._tweenDataList=[],this._currTime=0,this._lastTime=0,this._startTime=0,this._index=0,this._firstTweenDic={},this._startTimeSort=!1,this._endTimeSort=!1,this._loopKey=!1,this.scale=1,this._frameRate=60,this._frameIndex=0,this._total=0}static to(e,t,r,s=null,i=0){return(new oc).to(e,t,r,s,i)}static from(e,t,r,s=null,i=0){return(new oc).from(e,t,r,s,i)}to(e,t,r,s=null,i=0){return this._create(e,t,r,s,i,!0)}from(e,t,r,s=null,i=0){return this._create(e,t,r,s,i,!1)}_create(e,t,r,s,i,a){var n=h.getItemByClass("tweenData",lc);return n.isTo=a,n.type=0,n.target=e,n.duration=r,n.data=t,n.startTime=this._startTime+i,n.endTime=n.startTime+n.duration,n.ease=s,this._startTime=Math.max(n.endTime,this._startTime),this._tweenDataList.push(n),this._startTimeSort=!0,this._endTimeSort=!0,this}addLabel(e,t){var r=h.getItemByClass("tweenData",lc);return r.type=1,r.data=e,r.endTime=r.startTime=this._startTime+t,this._labelDic||(this._labelDic={}),this._labelDic[e]=r,this._tweenDataList.push(r),this}removeLabel(e){if(this._labelDic&&this._labelDic[e]){var t=this._labelDic[e];if(t){var r=this._tweenDataList.indexOf(t);r>-1&&this._tweenDataList.splice(r,1)}delete this._labelDic[e]}}gotoTime(e){if(null!=this._tweenDataList&&0!=this._tweenDataList.length){for(let o in this._firstTweenDic){let l=this._firstTweenDic[o];if(l)for(let h in l)h in l.diyTarget&&(l.diyTarget[h]=l[h])}for(let u of this._tweenDic)cn.kill(u);var t,r;if(this._tweenDic.length=0,this._index=0,this._currTime=e,this._lastTime=performance.now(),null==this._endTweenDataList||this._endTimeSort){function d(e,t){return e.endTime>t.endTime?1:e.endTime<t.endTime?-1:0}this._endTimeSort=!1,this._endTweenDataList=t=this._tweenDataList.concat(),t.sort(d)}else t=this._endTweenDataList;for(var s=0,i=t.length;s<i;s++)if(0==(r=t[s]).type){if(!(e>=r.endTime))break;this._index=Math.max(this._index,s+1);var a=r.data;if(r.isTo)for(var n in a)r.target[n]=a[n]}for(s=0,i=this._tweenDataList.length;s<i;s++)if(0==(r=this._tweenDataList[s]).type){if(e>=r.startTime&&e<r.endTime){let _;this._index=Math.max(this._index,s+1),_=r.isTo?cn.to(r.target,r.data,r.duration,r.ease,he.create(this,this._animComplete)):cn.from(r.target,r.data,r.duration,r.ease,he.create(this,this._animComplete)),this._tweenDic.push(_)}}else 1==r.type&&e>=r.startTime&&(this._index=Math.max(this._index,s+1),this.event(c.LABEL,r.data))}}gotoLabel(e){if(null!=this._labelDic){var t=this._labelDic[e];t&&this.gotoTime(t.startTime)}}pause(){l.timer.clear(this,this._update)}resume(){this.play(this._currTime,this._loopKey)}play(e=0,t=!1){if(this._tweenDataList){if(this._startTimeSort){function u(e,t){return e.startTime>t.startTime?1:e.startTime<t.startTime?-1:0}this._startTimeSort=!1,this._tweenDataList.sort(u);for(var r=0,s=this._tweenDataList.length;r<s;r++){var i=this._tweenDataList[r];if(null!=i&&0==i.type){var a=i.target,n=Q.getGID(a),o=null;for(var h in null==this._firstTweenDic[n]?((o={}).diyTarget=a,this._firstTweenDic[n]=o):o=this._firstTweenDic[n],i.data)null==o[h]&&(o[h]=a[h])}}}"string"==typeof e?this.gotoLabel(e):this.gotoTime(e),this._loopKey=t,this._lastTime=performance.now(),l.timer.frameLoop(1,this,this._update)}}_update(){if(this._currTime>=this._startTime){if(!this._loopKey){for(let e of this._tweenDic)e.complete();return this.pause(),void this._complete()}if(this._complete(),!this._tweenDataList)return;this.gotoTime(0)}var e=performance.now(),t=e-this._lastTime,r=this._currTime+=t*this.scale;for(this._lastTime=e;0!=this._tweenDataList.length&&this._index<this._tweenDataList.length;){var s=this._tweenDataList[this._index];if(!(r>=s.startTime))break;if(this._index++,0==s.type){let e;e=s.isTo?cn.to(s.target,s.data,s.duration,s.ease,he.create(this,this._animComplete)):cn.from(s.target,s.data,s.duration,s.ease,he.create(this,this._animComplete)),this._tweenDic.push(e)}else this.event(c.LABEL,s.data)}}_animComplete(e){let t=this._tweenDic.indexOf(e.owner);t>-1&&this._tweenDic.splice(t,1)}_complete(){this.event(c.COMPLETE)}get index(){return this._frameIndex}set index(e){this._frameIndex=e,this.gotoTime(this._frameIndex/this._frameRate*1e3)}get total(){return this._total=Math.floor(this._startTime/1e3*this._frameRate),this._total}reset(){var e,t,r;if(this._labelDic)for(e in this._labelDic)delete this._labelDic[e];for(let e of this._tweenDic)cn.kill(e);for(e in this._tweenDic.length=0,this._firstTweenDic)delete this._firstTweenDic[e];if(this._endTweenDataList=null,this._tweenDataList&&this._tweenDataList.length)for(r=this._tweenDataList.length,t=0;t<r;t++)this._tweenDataList[t]&&this._tweenDataList[t].destroy();this._tweenDataList.length=0,this._currTime=0,this._lastTime=0,this._startTime=0,this._index=0,this.scale=1,l.timer.clear(this,this._update)}destroy(){this.reset(),this._labelDic=null,this._tweenDic=null,this._tweenDataList=null,this._firstTweenDic=null}}class lc{constructor(){this.type=0,this.isTo=!0}destroy(){this.target=null,this.ease=null,this.data=null,this.isTo=!0,this.type=0,h.recover("tweenData",this)}}class hc{static init(){if(!hc.lookup){hc.lookup=new Uint8Array(256);for(var e=0;e<hc.chars.length;e++)hc.lookup[hc.chars.charCodeAt(e)]=e}}static isBase64String(e){return hc.reg.test(e)}static encode(e){var t,r=new Uint8Array(e),s=r.length,i="";for(t=0;t<s;t+=3)i+=hc.chars[r[t]>>2],i+=hc.chars[(3&r[t])<<4|r[t+1]>>4],i+=hc.chars[(15&r[t+1])<<2|r[t+2]>>6],i+=hc.chars[63&r[t+2]];return s%3==2?i=i.substring(0,i.length-1)+"=":s%3==1&&(i=i.substring(0,i.length-2)+"=="),i}static decode(e){hc.init();var t,r,s,i,a,n=.75*e.length,o=e.length,l=0;"="===e[e.length-1]&&(n--,"="===e[e.length-2]&&n--);var h=new ArrayBuffer(n),u=new Uint8Array(h);for(t=0;t<o;t+=4)r=hc.lookup[e.charCodeAt(t)],s=hc.lookup[e.charCodeAt(t+1)],i=hc.lookup[e.charCodeAt(t+2)],a=hc.lookup[e.charCodeAt(t+3)],l+1>n||(u[l++]=r<<2|s>>4,l+1>n||(u[l++]=(15&s)<<4|i>>2,l+1>n||(u[l++]=(3&i)<<6|63&a)));return h}}hc.chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",hc.reg=/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i,hc.reghead=/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,/i,hc.lookup=null;const uc=new te;class dc{contains(e,t,r){return!dc._isHitGraphic(e,t,r,this._unHit)&&dc._isHitGraphic(e,t,r,this._hit)}moveTo(e,t,r,s){if(r&&this._hit)for(let r of this._hit.cmds)r.x=e,r.y=t;if(s&&this._unHit)for(let r of this._unHit.cmds)r.x=e,r.y=t}static _isHitGraphic(e,t,r,s){return!!s&&-1!==s.cmds.findIndex(s=>s&&dc._isHitCmd(e,t,r,s))}static _isHitCmd(e,t,r,s){if(!s)return!1;var i=!1;switch(s.cmdID){case bs.ID:{let a=s;a.percent?uc.setTo(a.x*r.width,a.y*r.height,a.width*r.width,a.height*r.height):uc.setTo(a.x,a.y,a.width,a.height),i=uc.contains(e,t);break}case is.ID:{let a,n=s,o=n.radius;n.percent?(e-=n.x*r.width,t-=n.y*r.height,o*=r.width):(e-=n.x,t-=n.y),a=e*e+t*t,i=a<o*o;break}case Ys.ID:{let a,n=s,o=n.width/2,l=n.height/2;n.percent?(e-=n.x*r.width,t-=n.y*r.height,o*=r.width,l*=r.height):(e-=n.x,t-=n.y),a=Math.pow(e/o,2)+Math.pow(e/l,2),i=a<1;break}case Cs.ID:{let r=s;e-=r.x,t-=r.y,i=Q.testPointInPolygon(e,t,r.points);break}}return i}get hit(){return this._hit||(this._hit=new Ga),this._hit}set hit(e){this._hit=e}get unHit(){return this._unHit||(this._unHit=new Ga),this._unHit}set unHit(e){this._unHit=e}onAfterDeserialize(){this._hitCmds&&(this.hit.cmds=this._hitCmds,delete this._hitCmds),this._unHitCmds&&(this.unHit.cmds=this._unHitCmds,delete this._unHitCmds)}}Ee.regClass("HitArea",dc);class cc{static isJsonBin(e){if(e.byteLength<5)return!1;const t=new Uint32Array(e,0,4)[0];return t===gc||t===mc||t===fc}static parse(e,t){if(!cc.isJsonBin(e)){let t=new Ei;t.writeArrayBuffer(e),t.pos=0;let r=t.readUTFBytes();return JSON.parse(r)}Jc=t;let r,s,i=new Ei;switch(i.writeArrayBuffer(e),i.pos=0,l_={},s=i.readInt32(),s){case gc:r=i.readUTFString();break;case mc:case fc:r=i.readUTFString32();break;default:return i.pos=0,null}var a={keys:{},strs:["BEGIN",0],keyArray:[],keyIndex:1};a.strs=r.split(Tc),a.keyArray.length=a.strs.length/2;for(var n=0,o=a.strs.length;n<o;n+=2)a.keyArray[n/2]=[a.strs[n],parseInt(a.strs[n+1])];Zc=i.pos;var l={};return r_(l,i,null,Lc,a),s==fc?l.top:l}static write(e,t){o_=t;var r={keys:{},strs:["BEGIN",0],keyArray:[],keyIndex:1};l_={};var s=new Ei;p_(s,r,{top:e}),s.writeUint16(Qc);var i=new Ei;return i.writeInt32(fc),i.writeUTFString32(r.strs.join(Tc)),i.writeArrayBuffer(s.buffer),i.buffer}}class _c{static get instance(){return _c._instance||(_c._instance=new _c)}static IsJsonbin(e){return cc.isJsonBin(e)}static parse(e){return cc.parse(e)}read(e,t){return cc.parse(e,t)}}class pc{static get instance(){return pc._instance||(pc._instance=new pc)}write(e,t){return cc.write(e,t)}}const gc=16777215,mc=16777214,fc=16777213,Tc=String.fromCharCode(3),yc=1,xc=0,Sc=1,Ec=2,vc=3,Dc=4,wc=5,Rc=6,Cc=7,Mc=8,bc=9,Ac=10,Ic=11,Pc=12,Bc=14,Lc=15,Nc=16,Fc=17,Oc=18,Uc=19,kc=20,Gc=21,Vc=22,zc=23,Hc=24,Wc=25,Xc=26,Yc=27,qc=28,$c=29,Kc=30,jc=31,Qc=32767;var Zc,Jc;function e_(e,t,r,s,i){var a,n=[];n.length=r,t>=0&&(a=e.pos,e.pos=t);for(var o=0;o<r;o++)n[o]=r_({},e,null,e.readUint8(),i);return t>=0&&(e.pos=a),n}function t_(e){let t=e.readUint8();return 128&t?e.readUint8()|(-129&t)<<8:t}function r_(e,t,r,s,i){let a,n;switch(s){case Bc:n=null;break;case xc:n=t.readByte();break;case Sc:n=t.readInt16();break;case Ec:n=t.readInt32();break;case Yc:n=s_(t.readInt32(),t.readInt32());break;case vc:n=!!t.readByte();break;case Dc:n=t.readFloat32();break;case Nc:n=t.readInt16()/1e3;break;case Fc:n=t.readInt32()/1e3;break;case wc:n=i.keyArray[t.readUint16()][0];break;case Oc:break;case Mc:t.readUint8(),n=[];break;case bc:n=[],n.length=a=t.readUint8();for(let e=0;e<a;e++)n[e]=t.readByte();break;case Ac:n=[],n.length=a=t.readUint8();for(let e=0;e<a;e++)n[e]=t.readInt16();break;case Ic:n=[],n.length=a=t.readUint8();for(let e=0;e<a;e++)n[e]=t.readInt32();break;case Pc:n=[],n.length=a=t.readUint8();for(let e=0;e<a;e++)n[e]=t.readFloat32();break;case Uc:n=t.readArrayBuffer(t.readUint16());break;case zc:n=t.readArrayBuffer(t.readUint32());break;case qc:a=t_(t),n=t.readInt8Array(t.pos,a);break;case $c:a=t_(t),n=t.readUint8Array(t.pos,a);break;case Kc:a=t_(t),n=t.readInt16Array(t.pos,a);break;case jc:a=t_(t),n=t.readFloat32Array(t.pos,a);break;default:return function(e,t,r,s,i){let a,n,o,l,h=e;switch(s){case Rc:case Cc:case Wc:switch(s){case Rc:n=t.readUint8();break;case Cc:n=t.readInt16();break;case Wc:n=t.readUint32()}var u=a=[];for(u.length=n,o=0;o<n;o++)s=t.readUint8(),u[o]=r_(null,t,null,s,i);break;case Gc:case Vc:n=s===Gc?t.readUint8():t.readInt16(),l=t.pos-Zc,a=e_(t,-1,n,0,i),l_[l]={array:a,pos:l};break;case kc:case Hc:o=t.readByte(),l=s===kc?t.readUint16():t.readUint32();let d=l_[l];if(!d)throw new Error("load ref err");a=o===yc?e_(t,l+Zc,d.array.length,0,i):d.array;break;case Lc:case Xc:if(null!=r||!e){if(s===Lc)h={};else if(n=t.readUint16(),h=Jc(i.keyArray[n][0]),!h)throw new Error("jsonbin read err,no this class:"+i.keyArray[n][0]);r&&e&&(e[r]=h)}let c;for(;n=t.readUint16(),n!==Qc;)c=i.keyArray[n],r_(h,t,c[0],c[1],i);a=h,h=e}return null!=r&&(h[r]=a),a}(e,t,r,s,i)}return e&&r&&(e[r]=n),n}function s_(e,t){let r=t.toString(16);if(r.length<7)for(let e=r.length;e<7;e++)r="0"+r;return parseInt(e.toString(16)+""+r,16)}const i_="_$TeMpkEy$_CoMpReSs",a_="_$TeMpkEyNoSv$_",n_=15;var o_,l_={};function h_(e,t,r,s){var i=e+"/&&__*?/"+t,a=f_(r.keys,i)?r.keys[i]:void 0;a||(a=r.keys[i]=r.keyIndex,r.strs.push(e,t),r.keyIndex++),s.writeUint16(a)}function u_(e){switch(typeof e){case"number":if(Math.floor(e)!==e)return Pc;var t=Math.abs(e);return t<128?bc:t<32767?Ac:Ic;case"string":return Lc;case"boolean":return vc}return Lc}function d_(e,t,r,s,i){var a=i?Oc:wc;null!=t?h_(t,a,e,s):s.writeUint8(a);var n=f_(e.keys,r)?e.keys[r]:void 0;void 0===n&&(n=e.keyIndex,e.keys[r]=n,e.strs.push(r,0),e.keyIndex++),s.writeUint16(n)}function c_(e,t){if(t<128)e.writeUint8(t);else{if(!(t<32768))throw new Error("jsonbin save len must<0x8000 "+t);e.writeUint8(t>>8|128),e.writeUint8(255&t)}}function __(e,t,r,s,i){if(null==s)return!1;let a=typeof s;if("object"===a&&s){if(s.$__$disbaleJsonBinSv)return s.$__$disbaleJsonBinSv,!1;a=function(e){return e instanceof ArrayBuffer?"ArrayBuffer":e instanceof Uint8Array?"Uint8Array":e instanceof Int8Array?"Int8Array":e instanceof Int16Array?"Int16Array":e instanceof Float32Array?"Float32Array":"object"}(s)}switch(a){case"number":if(Math.floor(s)!==s){var n=1e3*s;if((0|n)===n){if(Math.abs(s)<32)return null!=r?h_(r,Nc,t,e):e.writeUint8(Nc),e.writeInt16(n),!0;if(Math.abs(s)<2147483)return null!=r?h_(r,Fc,t,e):e.writeUint8(Fc),e.writeInt32(n),!0}return null!=r?h_(r,Dc,t,e):e.writeUint8(Dc),e.writeFloat32(s),!0}var o=Math.abs(s);return o<128?(null!=r?h_(r,xc,t,e):e.writeUint8(xc),e.writeByte(s),!0):o<32767?(null!=r?h_(r,Sc,t,e):e.writeUint8(Sc),e.writeInt16(s),!0):o<2147483647?(null!=r?h_(r,Ec,t,e):e.writeUint8(Ec),e.writeInt32(s),!0):(null!=r?h_(r,Yc,t,e):e.writeUint8(Yc),function(e,t){let r=t.toString(16),s=parseInt(r.substring(0,r.length-7),16),i=parseInt(r.substring(r.length-7),16);if(e.writeInt32(s),e.writeInt32(i),s_(s,i)!=t)throw new Error("save big number err:"+t)}(e,s),!0);case"string":return d_(t,r,s,e,!1),!0;case"boolean":return null!=r?h_(r,vc,t,e):e.writeUint8(vc),e.writeByte(s?1:0),!0;case"ArrayBuffer":return null!=r?h_(r,zc,t,e):e.writeUint8(zc),e.writeUint32(s.byteLength),e.writeArrayBuffer(s),!0;case"Uint8Array":return null!=r?h_(r,$c,t,e):e.writeUint8($c),c_(e,s.length),e.writeArrayBuffer(s.buffer),!0;case"Int8Array":return null!=r?h_(r,qc,t,e):e.writeUint8(qc),c_(e,s.length),e.writeArrayBuffer(s.buffer),!0;case"Int16Array":return null!=r?h_(r,Kc,t,e):e.writeUint8(Kc),c_(e,s.length),e.writeArrayBuffer(s.buffer),!0;case"Float32Array":return null!=r?h_(r,jc,t,e):e.writeUint8(jc),c_(e,s.length),e.writeArrayBuffer(s.buffer),!0;case"WordText":return d_(t,r,s._text,e,!0),!0;case"object":break;default:throw new Error("jsonbin no this type:"+a)}return s?s instanceof Array?function(e,t,r,s,i){var a,n,o,l=i.length;if(0===l)return null!=s?h_(s,Mc,r,t):t.writeUint8(Mc),t.writeByte(0),!0;if(l>1&&l<250&&(n=u_(i[0]))!=Lc){for(a=1;a<l;a++)if(n!==u_(i[a])){n=Lc;break}if(n!=Lc&&n!=vc){switch(null!=s?h_(s,n,r,t):t.writeUint8(n),t.writeUint8(i.length),n){case bc:for(a=0;a<l;a++)t.writeByte(i[a]);break;case Ac:for(a=0;a<l;a++)t.writeInt16(i[a]);break;case Ic:for(a=0;a<l;a++)t.writeInt32(i[a]);break;case Pc:for(a=0;a<l;a++)t.writeFloat32(i[a])}return!0}}o=l<250?Rc:l<32700?Cc:Wc;var h=t.pos;null!=s?h_(s,o,r,t):t.writeUint8(o);var u=t.pos,d=0;switch(o){case Rc:t.writeUint8(l);break;case Cc:t.writeInt16(l);break;case Wc:t.writeUint32(l)}var c,_=t.pos;for(a=0;a<l;a++)__(t,r,null,i[a],e)&&d++;if(d!=l){var p=t.pos;t.pos=u,o===Rc?t.writeUint8(d):t.writeInt16(d),t.pos=p}s&&e&&(c=e[i_+s])&&function(e,t,r,s,i,a,n,o){var l,h,u,d,c=e.pos-a,_=function(e,t,r,s=9191891){var i,a=0;for(i=0;i<r;i++)a=(2*a+e[t+i])%s;return a}(e._u8d_,a,c);if(l_[_]){var p=l_[_];for(d=p.length,u=0;u<d;u++)if((h=p[u]).value==s){l=h;break}if(!l)for(u=0;u<d;u++)if(h=p[u],g_(e._u8d_,h.pos,h.len,e._u8d_,a,c)){l=h;break}}else l_[_]=[];l?(e.pos=i,h_(r,Hc,t,e),e.writeByte(n),e.writeUint32(l.pos)):(l_[_].push({hashCode:_,pos:a,len:c,value:s}),e.pos=i,h_(r,o===Rc?Gc:Vc,t,e),e.pos=a+c)}(t,r,s,i,h,_,c,o);return!0}(i,e,t,r,s):(o_&&s.__CLASS__?null!=r?h_(r,Xc,t,e):e.writeUint8(Xc):null!=r?h_(r,Lc,t,e):e.writeUint8(Lc),p_(e,t,s),e.writeUint16(Qc),!0):(null!=r?h_(r,Bc,t,e):e.writeUint8(Bc),!0)}function p_(e,t,r){for(var s in o_&&r.__CLASS__&&function(e,t,r){var s=f_(e.keys,t)?e.keys[t]:void 0;void 0===s&&(s=e.keyIndex,e.keys[t]=s,e.strs.push(t,0),e.keyIndex++),r.writeUint16(s)}(t,r.__CLASS__,e),r)s&&s.length>n_&&s.substr(0,n_)==a_||o_&&"__CLASS__"==s||__(e,t,s,r[s],r)}function g_(e,t,r,s,i,a){if(r!=a)return!1;var n,o;for(o=r,n=0;n<o;n++)if(e[t+n]!=s[i+n])return!1;return!0}const m_=Object.prototype.hasOwnProperty;function f_(e,t){return m_.call(e,t)}class T_{static set cursor(e){this._cursor=e,this._hidden||W.browser.setCursor(e)}static get cursor(){return this._cursor}static hide(){this._hidden=!0,W.browser.setCursor("none")}static show(){this._hidden=!1,W.browser.setCursor(this._cursor)}}T_._cursor="auto",T_._hidden=!1;class y_{constructor(){this.elements=[],this.length=0}add(e){let t=this.elements.indexOf(e);-1!=t&&t<this.length||(this.elements[this.length++]=e)}addList(e){let t=this.length,r=e.length;this.length=t+r;let s=this.elements,i=e.elements;s.length<this.length&&(s.length=this.length);for(let e=0;e<r;e++)s[t+e]=i[e]}indexof(e){let t=this.elements.indexOf(e);return-1!=t&&t<this.length?t:-1}remove(e){let t=this.elements.indexOf(e);-1!=t&&t<this.length&&(this.elements[t]=this.elements[this.length-1],this.elements[this.length-1]=null,this.length--)}clear(){this.elements.length=0,this.length=0}clean(){this.elements.length=this.length}cloneTo(e){e.length=this.length,e.elements=this.elements.slice()}destroy(){this.elements=null}}class x_{createUI(){this._pass=f.render2DRenderPassFactory.createRender2DPass();let e=this._sp=new po;this._pass.root=this._sp._struct,this._sp._struct.pass=this._pass,this._pass.doClearColor=!1;let t=this._title=new Pl;t.pos(5,5),t.color="#ffffff",t.name="title",e.addChild(t);let r=this._txt=new Pl;r.singleCharRender=!0,r.pos(100,5),r.color="#ffffff",r.name="txt",e.addChild(r),e.graphics.clear(),e.graphics.alpha(.5),e.graphics.drawRect(0,0,1,1,"#999999",null,null,!0),jo.stage.on(c.RESIZE,this,this.updateSize)}updateSize(){let t=Y.onMobile?10:12;t=Math.max(t,t/(jo.stage._canvasTransform.getScaleX()*jo.stage.clientScaleX)),this._txt.fontSize=t,this._title.fontSize=t,this._txt.x=this._title.textWidth+10,this._sp.size(this._title.textWidth+8*t,this._title.textHeight+10),this._sp._globalTrans._spTransChanged(e.TransformKind.TRS)}_displayChild(e,t){for(let r of e._children)r._children.length>0?this._displayChild(r,t):r._setDisplay(t);e._setDisplay(t)}show(t,r){this._items=new Array,S_.length=0;for(let t of Ua.elements){let r=e.StatElement[t],s=r.replace(/^(T_|C_|M_|CT_)/,"").replace(/_/g," "),i="",a=3;r.startsWith("CT_")||r.startsWith("C_")?a=0:r.startsWith("M_")?i="M":r.startsWith("T_")&&(i="ms"),this._items.push({value:t,fractionDigits:a,unit:i}),S_.push(s)}this._sp||this.createUI(),this._title.text=S_.join("\n"),this._sp.pos(t||0,r||0),this._sp._parent=jo.stage,this._sp._syncTransParent(),this.updateSize(),this._displayChild(this._sp,!0)}hide(){this._sp&&(this._title.text=null,this._txt.text=null,this._sp._parent=null,this._sp._syncTransParent(),this._displayChild(this._sp,!1))}update(){S_.length=0;for(let e=0;e<this._items.length;e++){let t=this._items[e],r=f.statAgent.getElementData(t.value).toFixed(t.fractionDigits).replace(E_,"$1");"-0"==r&&(r="0"),S_.push(r+" "+t.unit)}this._txt.text=S_.join("\n")}render(){this._pass&&this._pass.fowardRender(va.rendercontext2D,va.renderTime)}}const S_=[],E_=/\.0*$|(\.\d*[1-9])0+$/;Ua._statUIClass=x_;class v_{static create(e,t){var r;let s;return"undefined"!=typeof document&&(s=null===(r=Y.document.currentScript)||void 0===r?void 0:r.src,s&&(s=s.substring(0,s.replace(/[?#].*/,"").lastIndexOf("/")+1))),()=>{let r={};return null!=v_.instantiateWasm&&(r.instantiateWasm=function(e,r){return v_.instantiateWasm(t,e).then(e=>(r(e.instance),e))}),r.locateFile=function(e,r){return t=null!=v_.locateFile?v_.locateFile(e,r,s):v_.locateFileDefault(e,r)},e(r)}}static locateFileDefault(e,t){return ee.urlMapping[e]?ee.formatURL(e,""):null!=t?t+e:e}}v_.Memory=void 0!==window.WebAssembly?window.WebAssembly.Memory:null;class D_{static get I(){return this._i||(this._i=new D_)}static clearCache(){for(let e=0,t=D_._maps.length;e<t;e++){D_._maps[e]._obj={}}}constructor(){this._obj={},D_._maps?D_._maps.push(this):(D_._maps=[this],l.systemTimer.loop(D_.delInterval,null,D_.clearCache))}set(e,t){null!=e&&("string"==typeof e||"number"==typeof e?this._obj[e]=t:this._obj[Q.getGID(e)]=t)}get(e){return null==e?null:"string"==typeof e||"number"==typeof e?this._obj[e]:this._obj[Q.getGID(e)]}del(e){null!=e&&("string"==typeof e||"number"==typeof e?delete this._obj[e]:delete this._obj[Q.getGID(e)])}has(e){return null!=e&&("string"==typeof e||"number"==typeof e?null!=this._obj[e]:null!=this._obj[Q.getGID(e)])}}D_.delInterval=6e5;class w_{constructor(){this._deviceBufferState=f.renderDeviceFactory.createBufferState()}applyState(e,t){this._vertexBuffers=e,this._bindedIndexBuffer=t,this._deviceBufferState&&(1==e.length?(w_.vertexBufferArray.length=1,w_.vertexBufferArray[0]=e[0]._deviceBuffer):(w_.vertexBufferArray.length=0,e.forEach(e=>{w_.vertexBufferArray.push(e._deviceBuffer)})),this._deviceBufferState.applyState(w_.vertexBufferArray,t?t._deviceBuffer:null))}destroy(){this._deviceBufferState&&(this._deviceBufferState.destroy(),this._deviceBufferState=null)}}return w_.vertexBufferArray=[],e.AlphaCmd=Ar,e.Animation=Sl,e.Animation2DCondition=bh,e.Animation2DEvent=xh,e.Animation2DParm=wh,e.AnimationClip2D=vh,e.AnimationClip2DParse01=Sh,e.Animator2D=mh,e.Animator2DBase=ah,e.AnimatorClip2D=Cu,e.AnimatorController2D=Fh,e.AnimatorControllerLayer2D=oh,e.AnimatorControllerParse=lh,e.AnimatorPlayState2D=nh,e.AnimatorState2D=fh,e.AnimatorState2DScript=class{setPlayScriptInfo(e,t,r){this.playStateInfo.animator=e,this.playStateInfo.layerindex=t,this.playStateInfo.playState=r}constructor(){this.playStateInfo={animator:null,layerindex:-1,playState:null}}onStateEnter(){}onStateUpdate(e){}onStateExit(){}onStateSwitch(e){}onStateLoop(){}},e.AnimatorStateBoolCondition=Bh,e.AnimatorStateCondition=Ih,e.AnimatorStateNumberCondition=Ph,e.AnimatorStateTriggerCondition=Lh,e.AnimatorTransition2D=Nh,e.Area2D=Du,e.AssetDb=J,e.AtlasGrid=ia,e.AtlasInfoManager=ae,e.AtlasResource=oe,e.AudioDataCache=Vd,e.AutoTextureConfig=Rd,e.Base64Tool=hc,e.BasePoly=zs,e.BaseRenderNode2D=Dn,e.BaseTexture=V,e.BatchProgress=le,e.Bezier=as,e.BitmapFont=El,e.BlendComponent=Yu,e.BlendModeHandler=zt,e.BlendState=Xu,e.Blit2DCMD=so,e.Blit2DQuadCMD=class{get element(){return this._element}set element(e){this._element=e}get dest(){return this._dest}set dest(e){this._dest=e}get source(){return this._source}set source(e){this._source=e}get offsetScale(){return this._offsetScale}set offsetScale(e){this._offsetScale=e}apply(e){}},e.BlurEffect2D=td,e.BlurFilter=vd,e.BooleanKeyframe=Fd,e.Browser=Y,e.BrowserAdapter=Kd,e.Buffer=qu,e.BufferState=w_,e.ButtonEffect=class{constructor(){this._curState=0,this.effectScale=1.5,this.tweenTime=300}set target(e){this._tar=e,e.on(c.MOUSE_DOWN,this,this.toChangedState),e.on(c.MOUSE_UP,this,this.toInitState),e.on(c.MOUSE_OUT,this,this.toInitState)}toChangedState(){this._curState=1,this._curTween&&cn.clear(this._curTween),this._curTween=cn.to(this._tar,{scaleX:this.effectScale,scaleY:this.effectScale},this.tweenTime,Ya[this.effectEase],he.create(this,this.tweenComplete))}toInitState(){2!=this._curState&&(this._curTween&&cn.clear(this._curTween),this._curState=2,this._curTween=cn.to(this._tar,{scaleX:1,scaleY:1},this.tweenTime,Ya[this.backEase],he.create(this,this.tweenComplete)))}tweenComplete(){this._curState=0,this._curTween=null}},e.Byte=Ei,e.Camera2D=mu,e.CircleMesh=hd,e.ClassUtils=Ee,e.ClipRectCmd=Ju,e.Color=y,e.ColorEffect2D=ad,e.ColorFilter=Dd,e.ColorUtils=zr,e.Command2D=ro,e.CommandBuffer2D=ho,e.CommandEncoder=class{constructor(){this._idata=[]}getArrayData(){return this._idata}getCount(){return this._idata.length}addShaderUniform(e){this._idata.push(e)}},e.CommandUniformMap=class{constructor(e){}hasPtrID(e){return!1}addShaderUniform(e,t,r,s){throw"need override it"}addShaderUniformArray(e,t,r,s){throw"need override it"}setDefaultTextureData(e,t){throw"need override it"}},e.Component=Sn,e.ComponentDriver=Mo,e.ComputeCommandAppatchCMD=class{apply(e){throw new C}},e.ComputeCommandBuffer=class{constructor(){f.renderDeviceFactory.createComputeContext&&(this._context=f.renderDeviceFactory.createComputeContext())}getResource(){return this._context}clearCMDs(){this._context.clearCMDs()}addDispatchCommand(e,t,r,s){let i={shader:e.getCacheShader(t),shaderData:r,dispatchParams:s.clone()};this._context.addDispatchCommand(i)}addDispatchIndirectCommand(e,t,r,s,i){let a={shader:e.getCacheShader(t),shaderData:r,indirectBuffer:s,indirectOffset:i};this._context.addDispatchIndirectCommand(a)}addSetShaderDataCommand(e,t,r,s){this._context.addSetShaderDataCommand(e,t,r,s)}addBufferToBufferCommand(e,t,r,s,i){this._context.addBufferToBufferCommand(e,t,r,s,i)}addClearBufferCommand(e,t,r){this._context.addClearBufferCommand(e,t,r)}addBufferToTextureCommand(e,t,r,s){}addTextureToBufferCommand(e,t,r,s){}addTextureToTextureCommand(e,t,r){this._context.addTextureToTextureCommand(e,t,r)}executeCMDs(){this._context.executeCMDs()}destroy(){this._context.destroy()}},e.ComputeShader=_u,e.ComputeShaderParser=pu,e.Config=t,e.Config3D=o,e.Const=De,e.CopyTextureInfo=class{constructor(){this.mipLevel=0,this.origin=new a(0,0,0)}},e.Curve=vu,e.CurvePath=dh,e.DDSTextureInfo=Ui,e.DefaultStaticsContext=m,e.Delegate=B,e.DeviceAdapter=Qd,e.Downloader=ge,e.DragSupport=mn,e.Draw2DElementCMD=class{setRenderelements(e){throw new C}apply(e){throw new C}},e.Draw9GridTextureCmd=ts,e.DrawCircleCmd=is,e.DrawCurvesCmd=gs,e.DrawEllipseCmd=Ys,e.DrawImageCmd=fs,e.DrawLineCmd=ys,e.DrawLinesCmd=Ss,e.DrawMesh2DCMD=io,e.DrawPathCmd=vs,e.DrawPieCmd=ws,e.DrawPolyCmd=Cs,e.DrawRectCmd=bs,e.DrawRenderElement2DCMD=ao,e.DrawRoundRectCmd=$s,e.DrawStyle=Wi,e.DrawTextureCmd=Is,e.DrawTexturesCmd=Bs,e.DrawTrianglesCmd=Ns,e.DynamicAtlasManager=Nd,e.Earcut=Kr,e.EarcutNode=$r,e.Ease=Ya,e.Effect2DShaderInit=$n,e.EffectBase=yd,e.EmptyTextureProcessor=Ta,e.Event=c,e.EventDispatcher=N,e.FadeIn=class extends yd{_doTween(){return this.target.alpha=0,cn.to(this.target,{alpha:1},this.duration,Ya[this.ease],this._comlete,this.delay)}},e.FadeOut=class extends yd{_doTween(){return this.target.alpha=1,cn.to(this.target,{alpha:0},this.duration,Ya[this.ease],this._comlete,this.delay)}},e.FastSinglelist=class extends y_{add(e){this.elements[this.length++]=e}},e.FileSystemAdapter=Zd,e.FillTextCmd=wa,e.FillTextureCmd=js,e.Filter=Ed,e.FlipMesh=ud,e.FloatKeyframe=Eu,e.FontAdapter=Jd,e.FrameAnimation=xl,e.GLSLCodeGenerator=$u,e.GRAPHICS_INFO_DEFAULT_QUAD_INDICES=[0,2,1,0,3,2],e.GRAPHICS_INFO_INDEX_BLOCK_SIZE=1024,e.GRAPHICS_INFO_MAX_VERTEX=ei,e.GRAPHICS_INFO_VERTEX_BLOCK_SIZE=4,e.GRAPHICS_INFO_VERTEX_BYTE_STRIDE=Js,e.GRAPHICS_INFO_VERTEX_FLAG_DISABLED=0,e.GRAPHICS_INFO_VERTEX_FLAG_ENABLED=255,e.GRAPHICS_INFO_VERTEX_STRIDE=Zs,e.GlowEffect2D=ld,e.GlowFilter=wd,e.Gradient=Tu,e.GradientMode=fu,e.GrahamScan=hr,e.Graphics=Ga,e.GraphicsBounds=Tr,e.GraphicsCommandInfoHelper=sr,e.GraphicsCommandStreamMode=Xn,e.GraphicsCompileContext=Si,e.GraphicsDefines=Yr,e.GraphicsGeometryHelper=ir,e.GraphicsOpRenderStateHelper=nr,e.GraphicsRenderer=qn,e.GraphicsRunner=Sa,e.GraphicsSingleQuadMode=Yn,e.GraphicsTextureDataHelper=ar,e.GrayscaleEffect2D=od,e.HDRTextureInfo=Hh,e.HTMLAudioChannel=Hd,e.HTMLCanvas=Me,e.HTMLVideoPlayer=Xd,e.HTMLVideoTexture=Yd,e.HalfFloatUtils=vi,e.Handler=he,e.HideFlags=Re,e.HierarchyLoader=zh,e.HierarchyParser=al,e.HierarchyResource=ll,e.HitArea=dc,e.HtmlElement=Dl,e.HtmlImage=wl,e.HtmlLink=Rl,e.HtmlParseOptions=Cl,e.HtmlParser=Al,e.HttpRequest=pe,e.ILaya=l,e.IncludeFile=Oe,e.IndexBuffer=class extends qu{constructor(t,r){super(t,r),this._indexType=e.IndexFormat.UInt16}},e.Input=$l,e.InputManager=wo,e.JsonBin=cc,e.JsonBinRead=_c,e.JsonBinWrite=pc,e.KTXTextureInfo=zi,e.KeyLocation=xd,e.Keyboard=Sd,e.Keyframe=Su,e.Keyframe2D=yh,e.KeyframeNode2D=Th,e.KeyframeNodeList2D=Eh,e.LargeTex=Md,e.LargeTexBase=Pd,e.LargeTexManager=Bd,e.LargeTexProcessor=Ad,e.Laya=jo,e.LayaEnv=p,e.LayaGL=f,e.LoadModel2DV01=Uh,e.Loader=Te,e.LocalStorage=class{static setItem(e,t){W.storage.setItem(e,t)}static getItem(e){return W.storage.getItem(e)}static setJSON(e,t){W.storage.setItem(e,JSON.stringify(t))}static getJSON(e){return JSON.parse(W.storage.getItem(e)||null)}static removeItem(e){W.storage.removeItem(e)}static clear(){W.storage.clear()}static get count(){return W.storage.getCount()}},e.Material=Zn,e.MaterialLoader=ru,e.MaterialParser=tu,e.MathUtil=Wr,e.MathUtils3D=s,e.Matrix=Ce,e.Matrix3x3=je,e.Matrix4x4=nt,e.MediaAdapter=tc,e.Mesh2D=eo,e.Mesh2DReader=Gh,e.Mesh2DRender=to,e.MeshLoader=kh,e.Mouse=T_,e.Node=Wa,e.NodeFlags=we,e.NotImplementedError=C,e.NotReadableError=b,e.NullLoader=eu,e.ObjDecoder=ul,e.OpenDataContextView=wu,e.OutOfRangeError=M,e.PAL=W,e.ParseJSON=iu,e.Path=Xi,e.PathPoint=hh,e.PathPointKeyframe=Od,e.PlayerConfig=r,e.Point=d,e.Pool=h,e.PostProcess2D=uo,e.PostProcess2DEffect=Ru,e.PostProcessRenderContext2D=co,e.Prefab=nl,e.PrefabImpl=hl,e.Profiler=Lo,e.ProgressMesh=_d,e.Quaternion=et,e.QuaternionKeyframe=class extends Su{constructor(e=!1){super(),this.inTangent=new i,this.outTangent=new i,this.value=new et,e&&(this.inWeight=new i,this.outWeight=new i,this.weightedMode=new i)}cloneTo(e){super.cloneTo(e);var t=e;this.inTangent.cloneTo(t.inTangent),this.outTangent.cloneTo(t.outTangent),this.value.cloneTo(t.value),this.weightedMode&&(this.inWeight.cloneTo(t.inWeight),this.outWeight.cloneTo(t.outWeight),this.weightedMode.cloneTo(t.weightedMode))}},e.Rand=class{static getFloatFromInt(e){return 1/8388607*(8388607&e)}static getByteFromInt(e){return(8388607&e)>>>15}get seed(){return this.seeds[0]}set seed(e){this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}constructor(e){this._temp=new Uint32Array(1),this.seeds=new Uint32Array(4),this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}getUint(){return this._temp[0]=this.seeds[0]^this.seeds[0]<<11,this.seeds[0]=this.seeds[1],this.seeds[1]=this.seeds[2],this.seeds[2]=this.seeds[3],this.seeds[3]=this.seeds[3]^this.seeds[3]>>>19^this._temp[0]^this._temp[0]>>>8,this.seeds[3]}getFloat(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)}getSignedFloat(){return 2*this.getFloat()-1}},e.Rectangle=te,e.RegularPolygonMesh=md,e.Render=Io,e.Render2DProcessor=va,e.RenderState=Gt,e.RenderState2D=jn,e.RenderTexture=z,e.RenderTexture2D=Xa,e.RenderTexture2DArray=Hs,e.RenderTextureCube=class extends z{constructor(e,t,r,s,i){super(e,e,t,r,s,i),this.faceIndex=0}_createRenderTarget(){this._dimension=e.TextureDimension.Cube,this._renderTarget=f.textureContext.createRenderTargetCubeInternal(this.width,this._format,this._depthStencilFormat,this._generateMipmap,this._gammaSpace,this._multiSamples),this._texture=this._renderTarget._textures[0]}},e.RenderTextureLoader=qh,e.RenderTextureMRT=ic,e.Resource=G,e.RestoreCmd=lr,e.RotateCmd=Ca,e.RoundedRectMesh=fd,e.SaveBase=qi,e.SaveCmd=fr,e.SaveMark=Ki,e.SaveStyle=$i,e.SaveTransform=ji,e.SaveTranslate=Qi,e.ScaleCmd=Aa,e.Scene=Ko,e.Scene2DSpecialManager=qo,e.Script=Oh,e.ScriptableObject=Ah,e.ScriptableObjectLoader=su,e.SequenceFrame2DRender=Xo,e.SequenceFrame2DShader=Wo,e.SerializeUtil=pl,e.Set2DDefineCMD=lo,e.Set2DRTCMD=no,e.Set2DShaderDataCMD=oo,e.SetRenderDataCMD=class{get value(){return this._value}set value(e){this._value=e}get dataType(){return this._dataType}set dataType(e){this._dataType=e}get propertyID(){return this._propertyID}set propertyID(e){this._propertyID=e}get dest(){return this._dest}set dest(e){this._dest=e}apply(e){throw new C}},e.SetRendertarget2DCMD=class{constructor(){this.size=new $e,this._viewportX=0,this._viewportY=0}get viewportX(){return this._viewportX}set viewportX(e){this._viewportX=e}get viewportY(){return this._viewportY}set viewportY(e){this._viewportY=e}get invertY(){return this._invertY}set invertY(e){this._invertY=e}get clearColorValue(){return this._clearColorValue}set clearColorValue(e){this._clearColorValue=e}get rt(){return this._rt}set rt(e){this._rt=e}get clearColor(){return this._clearColor}set clearColor(e){this._clearColor=e}apply(e){throw new C}},e.SetShaderDefineCMD=class{get define(){return this._define}set define(e){this._define=e}get dest(){return this._dest}set dest(e){this._dest=e}get add(){return this._add}set add(e){this._add=e}apply(e){throw new C}},e.Shader2D=Ut,e.Shader3D=Ot,e.ShaderCompile=qe,e.ShaderCompileDefineBase=xt,e.ShaderData=class{constructor(e=null){this._uboLayoutVersion=0,this._ownerResource=e}getDefineData(){throw new C}getData(){throw new C}addDefine(e){throw new C}addDefines(e){throw new C}removeDefine(e){throw new C}hasDefine(e){throw new C}clearDefine(){throw new C}clearData(){throw new C}_getUniformBlockByProperty(e){return null}getUniformField(e){const t=new ct;return t._owner=this,t._index=e,t}getBool(e){throw new C}setBool(e,t){throw new C}getInt(e){throw new C}setInt(e,t){throw new C}getNumber(e){throw new C}setNumber(e,t){throw new C}getVector2(e){throw new C}setVector2(e,t){throw new C}getVector3(e){throw new C}setVector3(e,t){throw new C}getVector(e){throw new C}setVector(e,t){throw new C}getColor(e){throw new C}setColor(e,t){throw new C}getMatrix4x4(e){throw new C}setMatrix4x4(e,t){throw new C}getMatrix3x3(e){throw new C}setMatrix3x3(e,t){throw new C}getBuffer(e){throw new C}setBuffer(e,t){throw new C}setDeviceBuffer(e,t){throw new C}getStorageBuffer(e){throw new C}setTexture(e,t){throw new C}getTexture(e){throw new C}setShaderData(t,r,s){switch(r){case e.ShaderDataType.Int:this.setInt(t,s);break;case e.ShaderDataType.Bool:this.setBool(t,s);break;case e.ShaderDataType.Float:this.setNumber(t,s);break;case e.ShaderDataType.Vector2:this.setVector2(t,s);break;case e.ShaderDataType.Vector3:this.setVector3(t,s);break;case e.ShaderDataType.Vector4:this.setVector(t,s);break;case e.ShaderDataType.Color:this.setColor(t,s);break;case e.ShaderDataType.Matrix4x4:this.setMatrix4x4(t,s);break;case e.ShaderDataType.Matrix3x3:this.setMatrix3x3(t,s);break;case e.ShaderDataType.Texture2D:case e.ShaderDataType.TextureCube:this.setTexture(t,s);break;case e.ShaderDataType.Buffer:this.setBuffer(t,s);break;default:throw new Error(`unknown shader data type: ${r}`)}}getShaderData(t,r){switch(r){case e.ShaderDataType.Int:return this.getInt(t);case e.ShaderDataType.Bool:return this.getBool(t);case e.ShaderDataType.Float:return this.getNumber(t);case e.ShaderDataType.Vector2:return this.getVector2(t);case e.ShaderDataType.Vector3:return this.getVector3(t);case e.ShaderDataType.Vector4:return this.getVector(t);case e.ShaderDataType.Color:return this.getColor(t);case e.ShaderDataType.Texture2D:case e.ShaderDataType.TextureCube:return this.getTexture(t);case e.ShaderDataType.Buffer:return this.getBuffer(t);case e.ShaderDataType.Matrix3x3:return this.getMatrix3x3(t);case e.ShaderDataType.Matrix4x4:return this.getMatrix4x4(t);default:throw"unknown shader data type."}}_setInternalTexture(e,t){throw new C}update(e){throw new C}cloneTo(e){throw new C}clone(){throw new C}destroy(){throw new C}},e.ShaderDataDefaultValue=Tt,e.ShaderDefine=class{constructor(e,t){this._index=e,this._value=t}},e.ShaderDefines2D=kt,e.ShaderMRT=yt,e.ShaderNode=Ue,e.ShaderParser=cu,e.ShaderPass=St,e.ShaderVariable=Ku,e.ShaderVariantCollection=ju,e.SingletonList=y_,e.Socket=class extends N{constructor(e,t,r,s,i){super(),this.disableInput=!1,Array.isArray(r)&&(s=r),"boolean"==typeof s&&(i=s,s=null),this.output=new Ei,this.input=new Ei,this.endian=Ei.BIG_ENDIAN,e&&t>0&&t<65535&&this.connect(e,t,i,s)}get connected(){return this._connected}get endian(){return this.output.endian}set endian(e){this.input.endian=e,this.output.endian=e}connect(e,t,r,s){this.connectByUrl(`${r?"wss":"ws"}://${e}:${t}`,s)}connectByUrl(e,t){null!=this._socket&&this.close(),this.output.length=0,this.input.length=0,this._inputPos=0,Array.isArray(t)&&(t={protocols:t}),this._socket=W.browser.createWebSocket(),null!=this._socket?(this._socket.onOpen=()=>{this._connected=!0,this.event(c.OPEN)},this._socket.onClose=(e,t)=>{this._connected=!1,this.event(c.CLOSE,[e,t])},this._socket.onError=e=>{this.hasListener(c.ERROR)?this.event(c.ERROR,e):console.error("Socket Error: "+A(e))},this._socket.onMessage=e=>this._onMessage(e),this._socket.open(e,t)):console.warn("WebSocket is not supported in this platform.")}close(){if(null!=this._socket){try{this._socket.close()}catch(e){}this._socket=null}this._connected=!1}cleanSocket(){this.close()}send(e){return this._socket.send(e)}flush(){if(0===this.output.length||!this._socket||!this._connected)return;let e;try{this._socket.send(this.output.rawBuffer.slice(0,this.output.length))}catch(t){e=t}this.output.clear(),e&&this.event(c.ERROR,e)}_onMessage(e){if(this.disableInput)return void this.event(c.MESSAGE,e);this.input.length>0&&this.input.bytesAvailable<1&&(this.input.clear(),this._inputPos=0);let t=this.input.pos;!this._inputPos&&(this._inputPos=0),this.input.pos=this._inputPos,"string"==typeof e?this.input.writeUTFBytes(e):this.input.writeArrayBuffer(e),this._inputPos=this.input.pos,this.input.pos=t,this.event(c.MESSAGE,e)}},e.SoundChannel=zd,e.SoundManager=Vo,e.SoundNode=jl,e.SoundPlayer=Kl,e.Sprite=po,e.SpriteConst=Mr,e.SpriteGlobalTransform=Ln,e.SpriteUtils=Tn,e.Stage=No,e.Stat=Ua,e.StatUI=x_,e.StencilState=class{},e.StorageAdapter=rc,e.StringKeyframe=Ud,e.SubShader=Nt,e.SubStructRender=Un,e.SubmitBase=Ji,e.SubmitKey=Zi,e.Text=Pl,e.TextInputAdapter=sc,e.TextRender=aa,e.TextRenderConfig=ea,e.TextResource=Vh,e.TextStyle=vl,e.Texture=ie,e.Texture2D=Hi,e.Texture2DArray=fa,e.Texture2DLoader=Yh,e.Texture3D=Uo,e.TextureArrayRegistry2D=Ws,e.TextureCube=Go,e.TextureInfo=Ld,e.TextureItem=Id,e.TextureLoader=Qh,e.TextureMergeShaderInit=Cd,e.TextureProcessorAdapter=bd,e.TileMesh=Td,e.TimeLine=oc,e.Timer=Po,e.Transform2DStore=Bn,e.TransformCmd=Ba,e.TranslateCmd=Fa,e.TreeChunk=wn,e.Tween=cn,e.TweenValue=ja,e.TweenValueAdapterKey=Ja,e.Tweener=nn,e.TypedArrayClasses=_l,e.UBBParser=Il,e.URL=ee,e.UVClippingUtils=Zr,e.UniformBufferBlock=zu,e.UniformBufferCluster=Wu,e.UniformBufferField=ct,e.UniformBufferManager=class{constructor(e){this._destroyed=!1,this._needUpdateClusters=[],this._removeHoleArray=[],this._optimizeBufferPosArray=[],this._retiredCur=[],this._retiredPrev=[],this.bufferResourceChangeEpoch=0,this._useBigBuffer=!0,this.byteAlign=256,this.clusterMaxBlock=256,this.uploadThreshold=200,this.removeHoleThreshold=10,this.reduceWriteBufferCalls=!1,this._useBigBuffer=e,this._clustersAll=new Map,this._clustersCur=new Map}_createBufferCluster(e,t){return new Wu(e,t,this)}_addCluster(e,t=16){const r=Hu(e,this.byteAlign),s=this._createBufferCluster(r,t),i=this._clustersAll.get(r);return i?(i.push(s),s._sn=i.length-1):this._clustersAll.set(r,[s]),this._clustersCur.set(r,s),s}startFrame(){}endFrame(){for(let e=0;e<this._retiredPrev.length;e++)this._destroyBuffer(this._retiredPrev[e]);this._retiredPrev.length=0;const e=this._retiredPrev;this._retiredPrev=this._retiredCur,this._retiredCur=e}getBufferAlone(e,t){const r=Hu(e,this.byteAlign);return this.createGPUBuffer(r,t)}removeCluster(e,t){var r;const s=Hu(e,this.byteAlign);if(t<0){const e=this._clustersAll.get(s);if(e)for(let t=0;t<e.length;t++)this._retireCluster(e[t]);return this._clustersAll.delete(s),void this._clustersCur.delete(s)}const i=null===(r=this._clustersCur.get(s))||void 0===r?void 0:r._sn,a=this._clustersAll.get(s);if(a.length>t){if(this._retireCluster(a[t]),a.splice(t,1),0===a.length)return this._clustersAll.delete(s),void this._clustersCur.delete(s);for(let e=t;e<a.length;e++)a[e]._sn--;if(void 0!==i&&i===t){let e=-1,t=-1,r=-1;for(let s=a.length-1;s>-1;s--)t=a[s].usedNum,t>e&&t<this.clusterMaxBlock&&(r=s,e=t);r>=0?this._clustersCur.set(s,a[r]):this._clustersCur.delete(s)}}}getBlock(e,t,r){const s=Hu(e,this.byteAlign);let i=this._clustersCur.get(s);if(!i)return this._addCluster(s).getBlock(e,t,r);if(i.usedNum<this.clusterMaxBlock)return i.getBlock(e,t,r);i=null;const a=this._clustersAll.get(s);let n=-1,o=-1,l=-1;for(let e=a.length-1;e>0;e--)o=a[e].usedNum,o>n&&o<this.clusterMaxBlock&&(l=e,n=o);return l>=0?(i=a[l],this._clustersCur.set(s,i)):this._clustersCur.delete(s),i?i.getBlock(e,t,r):this._addCluster(s).getBlock(e,t,r)}freeBlock(e){const t=e.cluster;return!!t&&(!!t.freeBlock(e)&&(0===t.usedNum&&this.removeCluster(t._blockSize,t._sn),!0))}upload(){if(this._useBigBuffer){let e;for(let t=this._needUpdateClusters.length-1;t>-1;t--)e=this._needUpdateClusters[t],e.upload(),e._inManagerUpdateArray=!1;this._needUpdateClusters.length=0}}_addUpdateArray(e){e._inManagerUpdateArray||(this._needUpdateClusters.push(e),e._inManagerUpdateArray=!0)}_notifyBufferResourceChange(){this.bufferResourceChangeEpoch++}retireBuffer(e){e&&this._retiredCur.push(e)}_destroyBuffer(e){e&&e.destroy&&e.destroy()}_retireCluster(e){let t=this._needUpdateClusters.indexOf(e);-1!==t&&this._needUpdateClusters.splice(t,1),t=this._removeHoleArray.indexOf(e),-1!==t&&this._removeHoleArray.splice(t,1),e.destroy()}clear(){this._clustersAll.forEach(e=>{for(let t=e.length-1;t>-1;t--)e[t].clear()})}destroy(){if(!this._destroyed){this.clear();for(let e=0;e<this._retiredPrev.length;e++)this._destroyBuffer(this._retiredPrev[e]);for(let e=0;e<this._retiredCur.length;e++)this._destroyBuffer(this._retiredCur[e]);return this._retiredPrev.length=0,this._retiredCur.length=0,this._clustersAll.clear(),this._clustersCur.clear(),this._destroyed=!0,!0}return console.warn("UniformBufferManager: object alreay destroyed!"),!1}createGPUBuffer(e,t,r){}writeBuffer(e,t,r,s){}},e.UniformBufferWriter=Vu,e.Utils=Q,e.Vector2=$e,e.Vector2Keyframe=class extends Su{constructor(t=!1){super(),this.inTangent=new $e,this.outTangent=new $e,this.value=new $e,t&&(this.inWeight=new $e(Su.defaultWeight,Su.defaultWeight),this.outWeight=new $e(Su.defaultWeight,Su.defaultWeight),this.weightedMode=new $e(e.WeightedMode.None,e.WeightedMode.None))}cloneTo(e){super.cloneTo(e),this.inTangent.cloneTo(e.inTangent),this.outTangent.cloneTo(e.outTangent),this.value.cloneTo(e.value),this.weightedMode&&(this.inWeight.cloneTo(e.inWeight),this.outWeight.cloneTo(e.outWeight),this.weightedMode.cloneTo(e.weightedMode))}},e.Vector3=a,e.Vector3Keyframe=class extends Su{constructor(t=!1){super(),this.inTangent=new a,this.outTangent=new a,this.value=new a,t&&(this.inWeight=new a(Su.defaultWeight,Su.defaultWeight,Su.defaultWeight),this.outWeight=new a(Su.defaultWeight,Su.defaultWeight,Su.defaultWeight),this.weightedMode=new a(e.WeightedMode.None,e.WeightedMode.None,e.WeightedMode.None))}cloneTo(e){super.cloneTo(e),this.inTangent.cloneTo(e.inTangent),this.outTangent.cloneTo(e.outTangent),this.value.cloneTo(e.value),this.weightedMode&&(this.inWeight.cloneTo(e.inWeight),this.outWeight.cloneTo(e.outWeight),this.weightedMode.cloneTo(e.weightedMode))}},e.Vector4=i,e.Vector4Keyframe=class extends Su{constructor(t=!1){super(),this.inTangent=new i,this.outTangent=new i,this.value=new i,t&&(this.inWeight=new i(Su.defaultWeight,Su.defaultWeight,Su.defaultWeight,Su.defaultWeight),this.outWeight=new i(Su.defaultWeight,Su.defaultWeight,Su.defaultWeight,Su.defaultWeight),this.weightedMode=new i(e.WeightedMode.None,e.WeightedMode.None,e.WeightedMode.None,e.WeightedMode.None))}cloneTo(e){super.cloneTo(e),this.inTangent.cloneTo(e.inTangent),this.outTangent.cloneTo(e.outTangent),this.value.cloneTo(e.value),this.weightedMode&&(this.inWeight.cloneTo(e.inWeight),this.outWeight.cloneTo(e.outWeight),this.weightedMode.cloneTo(e.weightedMode))}},e.VertexAttributeLayout=Qu,e.VertexBuffer=class extends qu{get vertexDeclaration(){return this._vertexDeclaration}set vertexDeclaration(e){this._vertexDeclaration=e}get instanceBuffer(){return this._instanceBuffer}set instanceBuffer(e){this._instanceBuffer=e}constructor(e,t){super(e,t),this._instanceBuffer=!1,this._vertexDeclaration=null}},e.VertexDeclaration=Bt,e.VertexElement=vt,e.VertexElementFormat=It,e.VertexMesh=Lt,e.VertexMesh2D=Jn,e.VertexStateContext=Pt,e.VertexStream=qr,e.VideoNode=Zl,e.VideoPlayer=Ql,e.VideoPlayerBackend=Wd,e.VideoTexture=Xh,e.VideoTextureLoader=$h,e.Viewport=kd,e.WasmAdapter=v_,e.WeakObject=D_,e.WebAudioChannel=qd,e.WebGLRTMgr=nc,e.Widget=Yo,e.WorkerLoader=ne,e.XML=_e,e.XMLIterator=ce,e.XMLUtils=ue,e._WebSocket=$d,e.addAfterInitCallback=rl,e.addBeforeInitCallback=tl,e.addInitCallback=el,e.alertGlobalError=Jo,e.allowMultiple=function(e){e.prototype._$singleton=!1},e.checkShaderDataValueLegal=ft,e.classInfo=function(e){return ve},e.drawTrianglesBatched=Jr,e.genSliceMesh=Or,e.genTileMesh=Ur,e.getCompressTextureRenderCapable=R,e.getErrorMsg=A,e.importNative=sl,e.init=Zo,e.isBlendProperty=pt,e.isCullProperty=mt,e.isDepthStencilProperty=gt,e.isRenderStateProperty=function(e){return pt(e)||gt(e)||mt(e)},e.isUboBufferShaderType=function(t){return!(t===e.ShaderDataType.ReadOnlyDeviceBuffer||t===e.ShaderDataType.DeviceBuffer||t===e.ShaderDataType.StorageTexture2D||t===e.ShaderDataType.Texture2D||t===e.ShaderDataType.Texture3D||t===e.ShaderDataType.TextureCube||t===e.ShaderDataType.Texture2DArray)},e.measureFont=ta,e.property=function(e){return ve},e.regClass=function(e){return function(t){Ee.regClass(e,t)}},e.regLoader=function(e,t,r){return function(s){Te.registerLoader(e,s,t,r)}},e.roundDown=function(e,t){const r=((e+t-1)/t|0)*t;return r>e?r-t:r},e.roundUp=Hu,e.runInEditor=function(e){},e}({});