@volter/game-editor 0.5.155 → 0.5.156

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 (294) hide show
  1. package/BUNDLED_NOTICES +22 -22
  2. package/catalog/entries/blender.json +2 -2
  3. package/catalog/entries/music.json +2 -2
  4. package/dist/.vite/manifest.json +2138 -2138
  5. package/dist/assets/{AssetBudgetPanel-B2Wb7-b1.js → AssetBudgetPanel-BQdPOlqp.js} +3 -3
  6. package/dist/assets/{AudioViewer-gge--M-h.js → AudioViewer-C5y-GQP-.js} +1 -1
  7. package/dist/assets/{CanvasBoardDocument-CyGiXrEJ.js → CanvasBoardDocument-DbChIzOl.js} +1 -1
  8. package/dist/assets/{CanvasSceneViewport-ChG9oRS8.js → CanvasSceneViewport-BAUsxjQl.js} +1 -1
  9. package/dist/assets/{ColorInput-Dzpqy-J3.js → ColorInput-DGN6sIXS.js} +1 -1
  10. package/dist/assets/{ColorPicker-CqJPBHlh.js → ColorPicker-C83d-sVK.js} +1 -1
  11. package/dist/assets/{EntityModelDocument-D7XDf6uB.js → EntityModelDocument-D4IbBjti.js} +1 -1
  12. package/dist/assets/{EnvironmentAssetDocument-BgO7Hl3g.js → EnvironmentAssetDocument-BqTeI8cz.js} +1 -1
  13. package/dist/assets/{GameplaySessionTimeline-BBmwHCKA.js → GameplaySessionTimeline-FqH6Sz1y.js} +1 -1
  14. package/dist/assets/{ImageViewer-BjxoscVa.js → ImageViewer-C_4yhkuB.js} +1 -1
  15. package/dist/assets/InspectorObjectPreview-DCEUdndv.js +1 -0
  16. package/dist/assets/{JsonAssetDocument-D81JuRAm.js → JsonAssetDocument-C-drMm6I.js} +1 -1
  17. package/dist/assets/{LiveModuleDocument-bgStMiU1.js → LiveModuleDocument-C73e8H-p.js} +1 -1
  18. package/dist/assets/{LutAssetDocument-cl9Jq0Zw.js → LutAssetDocument-DfBf46zV.js} +1 -1
  19. package/dist/assets/{ModelAssetDocument-CYCLKpxJ.js → ModelAssetDocument-BgP4YOdh.js} +1 -1
  20. package/dist/assets/{NonThreeAuthoringBootstrap-DhHjvD5d.js → NonThreeAuthoringBootstrap-qnG1AmuP.js} +1 -1
  21. package/dist/assets/{Object3DDocumentToolbar-CQbARBIW.js → Object3DDocumentToolbar-34bmavxS.js} +1 -1
  22. package/dist/assets/Object3DDocumentViewport-Blr8aQeS.js +2 -0
  23. package/dist/assets/{Object3DPreview-BOZYzjz_.js → Object3DPreview-wWjXCo6v.js} +1 -1
  24. package/dist/assets/{OnlineAssetDetail-DdKHHjxg.js → OnlineAssetDetail-C4iaJDOr.js} +1 -1
  25. package/dist/assets/{PlayBar-CAarfEOh.js → PlayBar-CBvuzv1Q.js} +1 -1
  26. package/dist/assets/{QuarksAssetDocument-GTbawoy7.js → QuarksAssetDocument-BlYjfRGp.js} +1 -1
  27. package/dist/assets/{ReactCanvasControls-DIFkxeKv.js → ReactCanvasControls-C06AmSIB.js} +1 -1
  28. package/dist/assets/{RootSelectionOverlay-Dv_w1D9s.js → RootSelectionOverlay-CPw5aFQf.js} +1 -1
  29. package/dist/assets/{ShaderAssetDocument-OA-nshNN.js → ShaderAssetDocument-BVeK6Owt.js} +1 -1
  30. package/dist/assets/{ShadowEditor-Cp1QVCo9.js → ShadowEditor-BKEyyzOq.js} +1 -1
  31. package/dist/assets/{SourceAssetViewer-CGGHBzgL.js → SourceAssetViewer-DB6Fg4Re.js} +1 -1
  32. package/dist/assets/{StageHost-BMgCrIPG.js → StageHost-dHitOcUe.js} +2 -2
  33. package/dist/assets/{StoryPreviewMount-CyF7FwI7.js → StoryPreviewMount-BONsNxze.js} +1 -1
  34. package/dist/assets/{ThreeBoardDocument-DCJkLWU8.js → ThreeBoardDocument-D4CSNWux.js} +2 -2
  35. package/dist/assets/{ThreeIsolationSceneContent-CxsM-QHW.js → ThreeIsolationSceneContent-DkXfPv14.js} +1 -1
  36. package/dist/assets/{ToolObject3DPreview-lsAoRxtr.js → ToolObject3DPreview-DvGqYC9c.js} +1 -1
  37. package/dist/assets/{Toolbar-yvFlRv8R.js → Toolbar-BqUPRrhs.js} +1 -1
  38. package/dist/assets/{TransientHint-Bslncm_l.js → TransientHint-w6qEumzV.js} +1 -1
  39. package/dist/assets/{VideoViewer-Ba-e91kP.js → VideoViewer-B99XdTSg.js} +1 -1
  40. package/dist/assets/{ViewportShadingMenu-CgbuQ0e-.js → ViewportShadingMenu-9AaJLhq_.js} +1 -1
  41. package/dist/assets/{active-ingest-CJ2U5L1O.js → active-ingest-DwF45MBm.js} +2 -2
  42. package/dist/assets/{animation-clock-CVpGQSVj.js → animation-clock-DW8tJ4l7.js} +1 -1
  43. package/dist/assets/{animation-mixers.service-CI0K1tfi.js → animation-mixers.service-kllpdYjk.js} +1 -1
  44. package/dist/assets/{animation-timeline.utility-Wg6WxkxK.js → animation-timeline.utility-C9UVqsSv.js} +1 -1
  45. package/dist/assets/{asset-budget-asset.menu-BbCBxjLY.js → asset-budget-asset.menu-Cl8tmAtz.js} +1 -1
  46. package/dist/assets/{asset-budget.action-CK8h0v1A.js → asset-budget.action-dw6ctYdi.js} +1 -1
  47. package/dist/assets/{asset-budget.document-CYVcDLvH.js → asset-budget.document-BfDL1bS4.js} +1 -1
  48. package/dist/assets/{asset-budget.menu-BcTijQ2R.js → asset-budget.menu-DiOMl0Yh.js} +1 -1
  49. package/dist/assets/{asset-editor-persistence-DWp0E8cc.js → asset-editor-persistence-D2o6zb5I.js} +1 -1
  50. package/dist/assets/{asset-loaders-Bo91oPiL.js → asset-loaders-bMb8Nvq8.js} +1 -1
  51. package/dist/assets/{asset-preview-BUpxsHNd.js → asset-preview-uRqIcg3G.js} +1 -1
  52. package/dist/assets/{audio-unlock.service-CyiXe5qk.js → audio-unlock.service-CBeaLfYT.js} +1 -1
  53. package/dist/assets/{audio.utility-BN4mANCx.js → audio.utility-iWLchCUR.js} +1 -1
  54. package/dist/assets/autoplay.service---Nu6koq.js +1 -0
  55. package/dist/assets/{babylon-authoring-adapter-C-EAsfMr.js → babylon-authoring-adapter-Bt8B089v.js} +1 -1
  56. package/dist/assets/{binding-resolver-DoOAFM2m.js → binding-resolver-qdReeiXP.js} +2 -2
  57. package/dist/assets/{blender-node-editor.document-BzkGPs0i.js → blender-node-editor.document-DHj3Luuz.js} +1 -1
  58. package/dist/assets/{blender-properties-tab-B1ggqOYB.js → blender-properties-tab-mrwIpZz_.js} +1 -1
  59. package/dist/assets/{blender-runtime-host-MJZEPwHA.js → blender-runtime-host-rAbOjzv5.js} +1 -1
  60. package/dist/assets/{blender-runtime-skin-hw-op7Nt.js → blender-runtime-skin-CVACAkwd.js} +2 -2
  61. package/dist/assets/{blender-runtime.document-CvTyAou8.js → blender-runtime.document-VP-2qjfk.js} +10 -10
  62. package/dist/assets/{blender-screenshot.menu-C4VXpXVa.js → blender-screenshot.menu-B_zThqdR.js} +1 -1
  63. package/dist/assets/{blender-timeline.document-BRFDd7JZ.js → blender-timeline.document-BMNJBWXP.js} +1 -1
  64. package/dist/assets/{blender-uv-editor.document-CM09ITWu.js → blender-uv-editor.document-B2xmye2O.js} +1 -1
  65. package/dist/assets/{blender-version.status-CPyc_-kA.js → blender-version.status-BzVGyJhB.js} +1 -1
  66. package/dist/assets/{blender.command-ktKz-2Zi.js → blender.command-CNlvvxaj.js} +1 -1
  67. package/dist/assets/{board-guides-CCiyx8cT.js → board-guides-BPvQZ1ob.js} +1 -1
  68. package/dist/assets/{bridge.command-tP5j6w72.js → bridge.command-dqFe1Lyp.js} +3 -3
  69. package/dist/assets/{browserAll-BSQVVrNG.js → browserAll-DLXEw1rV.js} +1 -1
  70. package/dist/assets/{build-player.document-BwbBXtF5.js → build-player.document-Bra3vDcF.js} +1 -1
  71. package/dist/assets/{build-profiles.document-UiF_BsjE.js → build-profiles.document-DuSvWEO8.js} +1 -1
  72. package/dist/assets/{build-progress.status-Bf5KpnxC.js → build-progress.status-hkKRXBcc.js} +1 -1
  73. package/dist/assets/{build-session-C4jVDt-u.js → build-session-B5GOV8fm.js} +1 -1
  74. package/dist/assets/{build.action-DP2d1Uhj.js → build.action-DUrS97Yw.js} +1 -1
  75. package/dist/assets/{build.command-D5pyNcoj.js → build.command-fNnr9pdz.js} +1 -1
  76. package/dist/assets/{build.header-DupBIAOw.js → build.header-C-WQMQD8.js} +1 -1
  77. package/dist/assets/{build.menu-DWrKtdoV.js → build.menu-CsVJRmY6.js} +1 -1
  78. package/dist/assets/{build.service-qnz73gSX.js → build.service-CJfK8K6X.js} +1 -1
  79. package/dist/assets/{camera-C74U5X7o.js → camera-CpvCFt-Y.js} +1 -1
  80. package/dist/assets/{camera-runtime.inspector-B2l34Xhl.js → camera-runtime.inspector-BwSdtfTT.js} +1 -1
  81. package/dist/assets/{canvas-design-mount-D4M3E1AX.js → canvas-design-mount-CE-67ZS9.js} +3 -3
  82. package/dist/assets/{canvas-entry-runtime-CLOuJcgT.js → canvas-entry-runtime-CBpGQGRw.js} +2 -2
  83. package/dist/assets/{canvas-preview-frames-CSCcu2sG.js → canvas-preview-frames-DoDVjE4O.js} +1 -1
  84. package/dist/assets/{canvas-story-capture.service-onD_xSpQ.js → canvas-story-capture.service-hibqSqwB.js} +2 -2
  85. package/dist/assets/{capability-coverage-EnZ99FoT.js → capability-coverage-DWVel6Wq.js} +1 -1
  86. package/dist/assets/{collaboration-presence-1_UMOAkw.js → collaboration-presence-B9eqNDDB.js} +1 -1
  87. package/dist/assets/{collider-C6R1tHfa.js → collider-DD5wreOq.js} +1 -1
  88. package/dist/assets/{component-board.service-BX_2bwX3.js → component-board.service-B1RineLo.js} +2 -2
  89. package/dist/assets/{component-board.service-Cuf_SXeA.js → component-board.service-eXvcrWzD.js} +2 -2
  90. package/dist/assets/{component-board.service-Ckl-5tA4.js → component-board.service-r8KlRes9.js} +2 -2
  91. package/dist/assets/{component-contracts.service-rI-rbvDG.js → component-contracts.service-YWaJqTzM.js} +1 -1
  92. package/dist/assets/{component-instance-root-wO1p-rLr.js → component-instance-root-BrRLxTKu.js} +1 -1
  93. package/dist/assets/{component-verbs.command-O2bwqmK3.js → component-verbs.command-D5LCfxHY.js} +1 -1
  94. package/dist/assets/{component-verbs.service-BiiQMtJt.js → component-verbs.service-BUTHHNRT.js} +1 -1
  95. package/dist/assets/{config-dVnV1cxW.js → config-DQqPM4dV.js} +2 -2
  96. package/dist/assets/{configurations-8qaUqMH7.js → configurations-Dn9LLbWO.js} +1 -1
  97. package/dist/assets/{connection.status-vH9WCDDg.js → connection.status-CMZKs7ch.js} +1 -1
  98. package/dist/assets/{constraints.inspector-C7UjUxPR.js → constraints.inspector-CRay8pK8.js} +1 -1
  99. package/dist/assets/{content-bounds-Dl5Y3LLv.js → content-bounds-UvcUv1DD.js} +1 -1
  100. package/dist/assets/{contract-system-adapters-BDUpDoKd.js → contract-system-adapters-Bbw5uUUi.js} +1 -1
  101. package/dist/assets/{coverage.service-IS7Oklo8.js → coverage.service-DeTXoRCC.js} +1 -1
  102. package/dist/assets/{create-runtime-Bucz0XVU.js → create-runtime-Z7LcpKwn.js} +1 -1
  103. package/dist/assets/{curve-D0Q6TczG.js → curve-DGhnvtG4.js} +1 -1
  104. package/dist/assets/{data-asset-B0a1y8M-.js → data-asset-CrnqULWS.js} +1 -1
  105. package/dist/assets/{data-ref-dRt2Wi5L.js → data-ref-ym18xkxV.js} +1 -1
  106. package/dist/assets/{debug-bridge-EhDkhrLX.js → debug-bridge-BknWW_8M.js} +1 -1
  107. package/dist/assets/{debug-registry-B2THKz1v.js → debug-registry-C7poEnyY.js} +1 -1
  108. package/dist/assets/{deferred-ingest-play-To3ZratW.js → deferred-ingest-play-3qS-wvgF.js} +2 -2
  109. package/dist/assets/{design-time-canvas-mount-BnSaRAbS.js → design-time-canvas-mount-JkGmMINz.js} +2 -2
  110. package/dist/assets/{design-time-layers-OMAIxOrv.js → design-time-layers-nxUfMfKI.js} +1 -1
  111. package/dist/assets/{design-time-mount.service-Bgr_nCDs.js → design-time-mount.service-DQganiM8.js} +2 -2
  112. package/dist/assets/{design-time-mount.service-RFkiqPIn.js → design-time-mount.service-EBZKN6cL.js} +2 -2
  113. package/dist/assets/{design-time-react-mount-BsSBoX7J.js → design-time-react-mount-COvuTCBY.js} +1 -1
  114. package/dist/assets/{document-preview-three-Qni0oVBw.js → document-preview-three-BaWpv458.js} +1 -1
  115. package/dist/assets/{dom-authoring-adapter-DsUgOtQy.js → dom-authoring-adapter-wlPbZwHo.js} +1 -1
  116. package/dist/assets/{draco3d-DyZllcka.js → draco3d-DdFfLaRu.js} +1 -1
  117. package/dist/assets/{edit-mode-audio.service-CjXNAZEs.js → edit-mode-audio.service-B74d6zkz.js} +1 -1
  118. package/dist/assets/{edit-mode-authoring-BDgZD47j.js → edit-mode-authoring-Cf83TffW.js} +1 -1
  119. package/dist/assets/{edit-mode-networking.service-3dUr2g_0.js → edit-mode-networking.service-C7FSPHzl.js} +1 -1
  120. package/dist/assets/{editor-api-DTrNJMXL.js → editor-api-DLfSJ2g2.js} +1 -1
  121. package/dist/assets/{editor-layers-DwaX5UFy.js → editor-layers-BVicagU1.js} +1 -1
  122. package/dist/assets/{editor-shell-store-aKHbAoCV.js → editor-shell-store-CV73gQk5.js} +1 -1
  123. package/dist/assets/{entity-object-BLJ-I8XT.js → entity-object-DTQ4I2K5.js} +1 -1
  124. package/dist/assets/{extend-6LrR7eSL.js → extend-B7YOIXSU.js} +1 -1
  125. package/dist/assets/{fork-menu-V-FM6YuY.js → fork-menu-BToX8Jv4.js} +1 -1
  126. package/dist/assets/{frame-debugger-store-DwDC0wAm.js → frame-debugger-store-CuCtiEQ1.js} +1 -1
  127. package/dist/assets/{game-contract-seams-C22a4B79.js → game-contract-seams-DRUf45xM.js} +1 -1
  128. package/dist/assets/{game-css-scope-transform-Wv0ZdTsR.js → game-css-scope-transform-rbFoxfMV.js} +1 -1
  129. package/dist/assets/{game-document.service-BzvFIWCc.js → game-document.service-D409VVnQ.js} +1 -1
  130. package/dist/assets/{game-eval.command-DpQn_nY8.js → game-eval.command-BJ51kPy3.js} +1 -1
  131. package/dist/assets/{game-module-access-BI6oBa8Y.js → game-module-access-ib9tWhJc.js} +1 -1
  132. package/dist/assets/{game-network-Deo8lcPw.js → game-network-BZM-o9Ey.js} +3 -3
  133. package/dist/assets/{gameplay-export-BOLhxmII.js → gameplay-export-Bsvbs7wO.js} +1 -1
  134. package/dist/assets/{gameplay-replay-Dkvmv6hf.js → gameplay-replay-k_14DJ5F.js} +1 -1
  135. package/dist/assets/{gameplay.command-DCKqLv7C.js → gameplay.command-DGVwoOz_.js} +1 -1
  136. package/dist/assets/{generation-jobs-6D562vMB.js → generation-jobs-BxpAnwDo.js} +1 -1
  137. package/dist/assets/{generation.service-BFRoLb7y.js → generation.service-D1win2Pl.js} +1 -1
  138. package/dist/assets/{generations-HwV1btKK.js → generations-Dlu2fhGN.js} +1 -1
  139. package/dist/assets/{generations.status-BLiDcKsg.js → generations.status-BPYUSGr_.js} +1 -1
  140. package/dist/assets/{hierarchy-marks-DeG4E4Ke.js → hierarchy-marks-Dn7SO2iG.js} +1 -1
  141. package/dist/assets/{hosted-asset-materialization-Bod7CEMF.js → hosted-asset-materialization-DPmn23AM.js} +1 -1
  142. package/dist/assets/{index-CLUA6PYq.js → index-B41IX0yA.js} +1 -1
  143. package/dist/assets/{index-CyLPQ8pY.js → index-B4NI0L5I.js} +1 -1
  144. package/dist/assets/{index-DkYeh000.js → index-BjUxirz3.js} +1 -1
  145. package/dist/assets/{index-KIR4Has5.js → index-C_XSSPHO.js} +1 -1
  146. package/dist/assets/{index-4hL3-0yz.js → index-Cp9b5Qfa.js} +1 -1
  147. package/dist/assets/{index-jS3rfNkZ.js → index-D1nMmQxJ.js} +1 -1
  148. package/dist/assets/{index-ClgrFOcX.js → index-D9shXtZ9.js} +7 -7
  149. package/dist/assets/{index-CHOT9sYh.js → index-FWtJb07f.js} +2 -2
  150. package/dist/assets/{index-CdLhNxor.js → index-_-7lUYI-.js} +1 -1
  151. package/dist/assets/{inference-diagnostics-BmZ5ggEK.js → inference-diagnostics-V4igFQX2.js} +1 -1
  152. package/dist/assets/{ingest-boot-viewport-CipkFljr.js → ingest-boot-viewport-DBpKatwo.js} +1 -1
  153. package/dist/assets/{ingest-siblings-CEwYp-xg.js → ingest-siblings-C8OmNNTc.js} +1 -1
  154. package/dist/assets/{ingest-source-persistence-CVU1rTj0.js → ingest-source-persistence-DH7q9G1S.js} +1 -1
  155. package/dist/assets/{ingest.service-bNqvcqoK.js → ingest.service-D3Ru3YUS.js} +1 -1
  156. package/dist/assets/{inspect-BunjdqX7.js → inspect-Bhr2b3pa.js} +1 -1
  157. package/dist/assets/instances.command-CDIwEW8H.js +1 -0
  158. package/dist/assets/{json-history-resource-CDEoQe1R.js → json-history-resource-B8_YpeAT.js} +1 -1
  159. package/dist/assets/{layered-pick-guh6WlA7.js → layered-pick-MdBIQeUt.js} +1 -1
  160. package/dist/assets/{light-BPZivpCK.js → light-BvCKNW4e.js} +1 -1
  161. package/dist/assets/{live-project-verbs-Bqmxbr2o.js → live-project-verbs-DggWGgn-.js} +1 -1
  162. package/dist/assets/{machine.document-CAFPFq5K.js → machine.document-CTyXmK5a.js} +1 -1
  163. package/dist/assets/{machines.finder-CbUWReMp.js → machines.finder-C6WR7N-k.js} +1 -1
  164. package/dist/assets/{material-huG6lNEK.js → material-BoHGaIcq.js} +1 -1
  165. package/dist/assets/{material-factory-BkyOzJ7B.js → material-factory-D-cyMEti.js} +1 -1
  166. package/dist/assets/{mesh-CjCfRcFK.js → mesh-B-ksBKUU.js} +1 -1
  167. package/dist/assets/{model-asset-sections.service-Dt4V2K2v.js → model-asset-sections.service-DHsGD1SZ.js} +1 -1
  168. package/dist/assets/{model-inspection-BDA5jikL.js → model-inspection-Bsfj6b48.js} +1 -1
  169. package/dist/assets/{model-thumbnail-CF3qGQWb.js → model-thumbnail-Bp-1yQ-X.js} +1 -1
  170. package/dist/assets/{models.finder-yh4YeGrA.js → models.finder-DksRlbR8.js} +1 -1
  171. package/dist/assets/{module-mode-D8en13PD.js → module-mode-qROy_5Tk.js} +2 -2
  172. package/dist/assets/{mount-canvas-ingest-root-JOkm2Ypj.js → mount-canvas-ingest-root-CLbJS_Ob.js} +2 -2
  173. package/dist/assets/{mount-dom-ingest-root-CVXFnJZb.js → mount-dom-ingest-root-CI7VtdaS.js} +2 -2
  174. package/dist/assets/{mount-ingest-root-C3o0o28C.js → mount-ingest-root-BX_usF8y.js} +2 -2
  175. package/dist/assets/{mount-manifest-d7WQ9MYp.js → mount-manifest-lQBlK2Y1.js} +1 -1
  176. package/dist/assets/{mount-three-ingest-root-Dqd4XWP1.js → mount-three-ingest-root-g6yhs1S-.js} +1 -1
  177. package/dist/assets/{mounted-authoring-B697dYuN.js → mounted-authoring-D5cvzNXX.js} +1 -1
  178. package/dist/assets/{mounted-story-viewport-source-BvNZ3QQn.js → mounted-story-viewport-source-C-RZo_xH.js} +1 -1
  179. package/dist/assets/{native-debug-module-iX2-V5kg.js → native-debug-module-Bh_HQdg_.js} +1 -1
  180. package/dist/assets/{navigation-CIl9OY1F.js → navigation-DVO5eQO6.js} +1 -1
  181. package/dist/assets/{navmesh.menu-DrMoj7Ag.js → navmesh.menu-Cu9R-p4V.js} +1 -1
  182. package/dist/assets/{navmesh.service-CTr1NVfz.js → navmesh.service-D6EeQxE0.js} +1 -1
  183. package/dist/assets/network-observer.service-CLE3M7gH.js +1 -0
  184. package/dist/assets/{network.utility-Btexm5ao.js → network.utility-D4Uo1xUC.js} +1 -1
  185. package/dist/assets/{object3d-document-session-registry-CADiW-LP.js → object3d-document-session-registry-bor-eSgr.js} +2 -2
  186. package/dist/assets/{oid-transform-Ca1oU_Ei.js → oid-transform-rEmA5PfE.js} +1 -1
  187. package/dist/assets/{particles-D1oPwNJh.js → particles-BxlIkQUX.js} +1 -1
  188. package/dist/assets/{pixi-authoring-adapter-B1BBfTju.js → pixi-authoring-adapter-CTSRtvNw.js} +1 -1
  189. package/dist/assets/{pixi-live-write-target-BcUhtqmJ.js → pixi-live-write-target-DaUAvNu7.js} +1 -1
  190. package/dist/assets/{play.command-ScnwcvJr.js → play.command-BtV56gUr.js} +2 -2
  191. package/dist/assets/{presentation-DPfnCjNA.js → presentation-DxTT40_3.js} +1 -1
  192. package/dist/assets/{product-D_9saRiZ.js → product-BAGhTFHw.js} +1 -1
  193. package/dist/assets/{profiler.action-PXTw93E5.js → profiler.action-DaSS1RoY.js} +1 -1
  194. package/dist/assets/{profiler.menu-DPFV6QQD.js → profiler.menu-5OyI3lyY.js} +1 -1
  195. package/dist/assets/{profiler.utility-eDooJGnI.js → profiler.utility-DLzaMOPh.js} +1 -1
  196. package/dist/assets/{project-authoring-session-BmeutotA.js → project-authoring-session-DZOgiTch.js} +2 -2
  197. package/dist/assets/{properties-bone-constraints.inspector-BW0V1WXQ.js → properties-bone-constraints.inspector-JMlHKfN2.js} +1 -1
  198. package/dist/assets/{properties-bone.inspector-DIvTZhY8.js → properties-bone.inspector-C-c7iGEx.js} +1 -1
  199. package/dist/assets/{properties-collection.inspector-Dbt5XMhs.js → properties-collection.inspector-PXHDUs1b.js} +1 -1
  200. package/dist/assets/{properties-constraints.inspector-5SvB0GDC.js → properties-constraints.inspector-CQnnGi1O.js} +1 -1
  201. package/dist/assets/{properties-data.inspector-C-SngIsI.js → properties-data.inspector-DuEPeVBm.js} +1 -1
  202. package/dist/assets/{properties-material.inspector-CYAWsvsX.js → properties-material.inspector-BhKP0Zc_.js} +1 -1
  203. package/dist/assets/{properties-modifiers.inspector-XN6BL-Ll.js → properties-modifiers.inspector-lOMb72vk.js} +1 -1
  204. package/dist/assets/{properties-object.inspector-CfryU0kN.js → properties-object.inspector-BU2hn26Q.js} +1 -1
  205. package/dist/assets/{properties-output.inspector-COfgmFUW.js → properties-output.inspector-yNaC3IgX.js} +1 -1
  206. package/dist/assets/{properties-particles.inspector-BCh0vFr6.js → properties-particles.inspector-CaHfdQZB.js} +1 -1
  207. package/dist/assets/{properties-physics.inspector-B6to1u6U.js → properties-physics.inspector-Bt9Xjyu-.js} +1 -1
  208. package/dist/assets/{properties-render.inspector-C4hVfo7j.js → properties-render.inspector-Cl8UBLPY.js} +1 -1
  209. package/dist/assets/{properties-scene.inspector-dKta4xn5.js → properties-scene.inspector-D9cgONMx.js} +1 -1
  210. package/dist/assets/{properties-texture.inspector-ZlNhW25m.js → properties-texture.inspector-804GEF8F.js} +1 -1
  211. package/dist/assets/{properties-view-layer.inspector-CIxHmkDR.js → properties-view-layer.inspector-CLo0Z-B1.js} +1 -1
  212. package/dist/assets/{properties-world.inspector-Ce0q2dmK.js → properties-world.inspector-CjywenDE.js} +1 -1
  213. package/dist/assets/{r3f-design-session-1riISktt.js → r3f-design-session-B2k02ypD.js} +2 -2
  214. package/dist/assets/{r3f-physics-binding-DuG97FR9.js → r3f-physics-binding-D1rgVgsz.js} +1 -1
  215. package/dist/assets/{r3f-source-authoring-adapter-B8qqrdwk.js → r3f-source-authoring-adapter-Dj0r13-b.js} +1 -1
  216. package/dist/assets/{react-canvas-navigation-CxBm8iw8.js → react-canvas-navigation-t00NiEKB.js} +1 -1
  217. package/dist/assets/{react-inspector.service-BcdePwno.js → react-inspector.service-Xp4f-M0O.js} +1 -1
  218. package/dist/assets/{react-story-board-CMvkLAkF.js → react-story-board-DAQaZNga.js} +1 -1
  219. package/dist/assets/{react-three-rapier.esm-D5svf-ME.js → react-three-rapier.esm-D13B7Exz.js} +1 -1
  220. package/dist/assets/{react-world-authoring-adapter-Dq8NqvWu.js → react-world-authoring-adapter-zzyaxcpN.js} +1 -1
  221. package/dist/assets/{realm-services-CqjVBanw.js → realm-services-CyeBcuLZ.js} +1 -1
  222. package/dist/assets/{reflection-probe-capture.inspector-uEvyppEj.js → reflection-probe-capture.inspector-BpdGQ2gf.js} +1 -1
  223. package/dist/assets/{registry-D7lFIA8c.js → registry-DM1tIelZ.js} +1 -1
  224. package/dist/assets/{relative-import-specifier-CA9mSNXO.js → relative-import-specifier-txHdCBKR.js} +1 -1
  225. package/dist/assets/{render-env-BHasp-z3.js → render-env-DiO35wd3.js} +1 -1
  226. package/dist/assets/{render-features-sSb1-c5x.js → render-features-Bv3_74_x.js} +1 -1
  227. package/dist/assets/{render-settings-CUbo4Sw5.js → render-settings-8kb_yvkr.js} +1 -1
  228. package/dist/assets/{resolve-three-TQ367RQD.js → resolve-three-D9rgCC5Z.js} +3 -3
  229. package/dist/assets/{root-seam-contract-CneTgNww.js → root-seam-contract-BgkkJVuJ.js} +1 -1
  230. package/dist/assets/{run-selection-CNsOQTEG.js → run-selection-WrcYgYP3.js} +1 -1
  231. package/dist/assets/{scene-capture-KbdRgsD3.js → scene-capture-C08wT5TW.js} +1 -1
  232. package/dist/assets/{scene-document.service-CmPSUocW.js → scene-document.service-D7sb6hvQ.js} +2 -2
  233. package/dist/assets/{scene-framing-B5JC4NeG.js → scene-framing-BSvegpi4.js} +1 -1
  234. package/dist/assets/{seeded-random-B6zqGkWP.js → seeded-random-Bc5190so.js} +1 -1
  235. package/dist/assets/{setup-renderer-efjIBSGF.js → setup-renderer-JwrNwzqH.js} +1 -1
  236. package/dist/assets/{source-object3d-authoring-adapter-DeeboYub.js → source-object3d-authoring-adapter-BJwLQVsv.js} +1 -1
  237. package/dist/assets/{source-persistence-backend-Cwy93SmQ.js → source-persistence-backend-DsG30XMj.js} +1 -1
  238. package/dist/assets/{stage-keyboard-GNCaTXLA.js → stage-keyboard-BnzybgXw.js} +1 -1
  239. package/dist/assets/{stage-overlay-set-DV3SCzJb.js → stage-overlay-set-BWxO_Pk6.js} +1 -1
  240. package/dist/assets/{stage-presence-markers-CBEU1Kzo.js → stage-presence-markers-BD5JPVX6.js} +1 -1
  241. package/dist/assets/{stage-transform-tools-C9nNDW6n.js → stage-transform-tools-CHvXlnKB.js} +1 -1
  242. package/dist/assets/{standard-viewport-dressing-BJkGwiNT.js → standard-viewport-dressing-4xAZCGJ3.js} +1 -1
  243. package/dist/assets/{state-watch.action-Doz_jrzS.js → state-watch.action-0KAywung.js} +1 -1
  244. package/dist/assets/{state-watch.menu-Dj4DUUxN.js → state-watch.menu-4xjTZIEx.js} +1 -1
  245. package/dist/assets/{state-watch.utility-COPa8xpV.js → state-watch.utility-DZgzPGEZ.js} +1 -1
  246. package/dist/assets/{story-capture-stRSY4PQ.js → story-capture-d695eMLJ.js} +1 -1
  247. package/dist/assets/{story-documents-CYzWYY1o.js → story-documents-C1hZeYU3.js} +1 -1
  248. package/dist/assets/{story-documents.service-DJBu4rve.js → story-documents.service-CSXB6uqT.js} +1 -1
  249. package/dist/assets/{story-documents.service-C5r8KFEG.js → story-documents.service-bB0UDbvA.js} +1 -1
  250. package/dist/assets/{story-media-presence-D4AIsAtK.js → story-media-presence-CxD6G_Mu.js} +1 -1
  251. package/dist/assets/{story-pixi-preview-mPo3OFOd.js → story-pixi-preview-CJKGDBKs.js} +1 -1
  252. package/dist/assets/{story-presentation-Dw4Vw65P.js → story-presentation-BBS9x4BP.js} +1 -1
  253. package/dist/assets/{story-three-preview-CWM0Rj7x.js → story-three-preview-v22RRpqB.js} +2 -2
  254. package/dist/assets/{studio-environment-Bw9zMFE8.js → studio-environment-CvCEc6PK.js} +1 -1
  255. package/dist/assets/{surface-state-b_H4iOCJ.js → surface-state-EsG-yMSi.js} +1 -1
  256. package/dist/assets/{syntactic-prop-specs-BCdwWi-T.js → syntactic-prop-specs-DvSr6VoQ.js} +1 -1
  257. package/dist/assets/{team-playtest.service-CnxdTghn.js → team-playtest.service-Bp6j6MAv.js} +1 -1
  258. package/dist/assets/{three-DWy0sZom.js → three-Do16bEo9.js} +1 -1
  259. package/dist/assets/{three-authoring-adapter-9LcUBPaU.js → three-authoring-adapter-C2QFVlpK.js} +1 -1
  260. package/dist/assets/three-authoring.service-DxL4grJx.js +2 -0
  261. package/dist/assets/{three-ingest-runtime-x9nLmUl-.js → three-ingest-runtime-DW-lHDmp.js} +1 -1
  262. package/dist/assets/{three-integration-DB-xQHD5.js → three-integration-C1onOQwq.js} +2 -2
  263. package/dist/assets/three-integration.service-26hsEOk3.js +1 -0
  264. package/dist/assets/{three-projection-core-IUovHgg_.js → three-projection-core-1FETWj5n.js} +1 -1
  265. package/dist/assets/{three-state-_ImCbP87.js → three-state-d-szeOea.js} +1 -1
  266. package/dist/assets/{three-story-capture.service-wKwfSnqA.js → three-story-capture.service-gnrRzcjj.js} +2 -2
  267. package/dist/assets/{three-story-model-BxWKcl9d.js → three-story-model-CbEMWEte.js} +1 -1
  268. package/dist/assets/{three-viewport-presentation-Bg86EsDJ.js → three-viewport-presentation-D1ysWIW4.js} +1 -1
  269. package/dist/assets/{transform-mode-request-BnV8FSnx.js → transform-mode-request-B3AxgwGW.js} +1 -1
  270. package/dist/assets/{transport-strip-BZQnaxFN.js → transport-strip-D4N14xHx.js} +1 -1
  271. package/dist/assets/transport.header-D3j_V-tN.js +1 -0
  272. package/dist/assets/{tuples-DR33sMq6.js → tuples-B3URXxaa.js} +1 -1
  273. package/dist/assets/{ui-board-document-VJMvm6Ks.js → ui-board-document-BSrfzH8L.js} +2 -2
  274. package/dist/assets/{user-data-DL6HsBPf.js → user-data-DHB4MWum.js} +1 -1
  275. package/dist/assets/{utility-view-state-ghWXsYXq.js → utility-view-state-CfZ51NRS.js} +1 -1
  276. package/dist/assets/{viewport-door-BV_lf5uK.js → viewport-door-DkDcO9tp.js} +1 -1
  277. package/dist/assets/{viewport-root-presentation-CKqhX3mt.js → viewport-root-presentation-DtuBFJ-J.js} +1 -1
  278. package/dist/assets/{viewport-surface-status-D7M2L2lI.js → viewport-surface-status-HKbJtC2G.js} +1 -1
  279. package/dist/assets/{webworkerAll-DDbFvxgB.js → webworkerAll-JD3yAUg1.js} +1 -1
  280. package/dist/assets/{workspace-arrangement-86_8Kk5K.js → workspace-arrangement-BOk46mGq.js} +1 -1
  281. package/dist/assets/{world-documents-DeNJUefV.js → world-documents-AnhAH_9y.js} +1 -1
  282. package/dist/assets/{world-root-stage-binding-VOrldLB4.js → world-root-stage-binding-H0SUNbfK.js} +1 -1
  283. package/dist/assets/{xstate-animation-binding-747CfEeB.js → xstate-animation-binding-BjWKb5ne.js} +1 -1
  284. package/dist/assets/{xstate-animation-meta-DNMlMnr-.js → xstate-animation-meta-CTBp-Vc5.js} +1 -1
  285. package/dist-node/cli.js +16 -16
  286. package/package.json +16 -16
  287. package/dist/assets/InspectorObjectPreview-C87CasN_.js +0 -1
  288. package/dist/assets/Object3DDocumentViewport-BpiyRQ5p.js +0 -2
  289. package/dist/assets/autoplay.service-CKBqjozr.js +0 -1
  290. package/dist/assets/instances.command-DzcXdKuG.js +0 -1
  291. package/dist/assets/network-observer.service-DyzpGKA7.js +0 -1
  292. package/dist/assets/three-authoring.service-DdTMF4A2.js +0 -2
  293. package/dist/assets/three-integration.service-DwToRGIc.js +0 -1
  294. package/dist/assets/transport.header-1SF4ZbEd.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/draco3d-DyZllcka.js","assets/_commonjsHelpers-D6-XlEtG.js","assets/index-ClgrFOcX.js","assets/index-nmcBqr7Y.js","assets/index-D_NuPfjr.js","assets/jsx-runtime-DPjLkJKQ.js","assets/index-CtzuWnCS.js","assets/index-CinJrH5C.js","assets/index-FUuS4qwW.js","assets/client-DNXj_opT.js","assets/index-CPiRKiDC.css"])))=>i.map(i=>d[i]);
2
- import{a as A}from"./jsx-runtime-DPjLkJKQ.js";import{_ as ft,b3 as on,gu as oi,gv as ai,gw as ci,aZ as G,eo as Ls,ep as ht,er as O,et as F,a6 as st,iR as me,ev as Xt,r as ui,k$ as Bt,ex as Lt,ew as gt,eW as an,es as Es,bH as li}from"./index-ClgrFOcX.js";import{r as Y}from"./index-nmcBqr7Y.js";import"./index-CtzuWnCS.js";import{g as fi}from"./_commonjsHelpers-D6-XlEtG.js";import{invalidateCachedAsset as ss}from"./asset-loaders-Bo91oPiL.js";function Vs(e){return e.id==="http"||e.id.startsWith("frame:")}var cn=class{_listeners={};addEventListener(e,t){const s=this._listeners;return s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t),this}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}return this}dispatchEvent(e){const t=this._listeners[e.type];if(t!==void 0){const s=t.slice(0);for(let r=0,n=s.length;r<n;r++)s[r].call(this,e)}return this}dispose(){for(const e in this._listeners)delete this._listeners[e]}},Je=class{_disposed=!1;_name;_parent;_child;_attributes;constructor(e,t,s,r={}){if(this._name=e,this._parent=t,this._child=s,this._attributes=r,!t.isOnGraph(s))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){this._disposed||(this._parent._destroyRef(this),this._disposed=!0)}isDisposed(){return this._disposed}},hi=class extends cn{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){const t=new Set;for(const s of this.listParentEdges(e))t.add(s.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){const t=new Set;for(const s of this.listChildEdges(e))t.add(s.getChild());return Array.from(t)}disconnectParents(e,t){for(const s of this.listParentEdges(e))(!t||t(s.getParent()))&&s.dispose();return this}_createEdge(e,t,s,r){const n=new Je(e,t,s,r);this._edges.add(n);const o=n.getParent();this._parentEdges.has(o)||this._parentEdges.set(o,new Set),this._parentEdges.get(o).add(n);const i=n.getChild();return this._childEdges.has(i)||this._childEdges.set(i,new Set),this._childEdges.get(i).add(n),n}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}},re=class{list=[];constructor(e){if(e)for(const t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){const t=this.list.indexOf(e);t>=0&&this.list.splice(t,1)}removeChild(e){const t=[];for(const s of this.list)s.getChild()===e&&t.push(s);for(const s of t)this.remove(s);return t}listRefsByChild(e){const t=[];for(const s of this.list)s.getChild()===e&&t.push(s);return t}values(){return this.list}},$=class{set=new Set;map=new Map;constructor(e){if(e)for(const t of e)this.add(t)}add(e){const t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){const t=this.map.get(e)||null;return t&&this.remove(t),t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}},J=class{map={};constructor(e){e&&Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}};const V=Symbol("attributes"),Le=Symbol("immutableKeys");var di=class un extends cn{_disposed=!1;graph;[V];[Le];constructor(t){super(),this.graph=t,this[Le]=new Set,this[V]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){const t=this.getDefaults(),s={};for(const r in t){const n=t[r];if(n instanceof un){const o=this.graph._createEdge(r,this,n);this[Le].add(r),s[r]=o}else s[r]=n}return s}isOnGraph(t){return this.graph===t.graph}isDisposed(){return this._disposed}dispose(){this._disposed||(this.graph.listChildEdges(this).forEach(t=>t.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"}))}detach(){return this.graph.disconnectParents(this),this}swap(t,s){for(const r in this[V]){const n=this[V][r];if(n instanceof Je){const o=n;o.getChild()===t&&this.setRef(r,s,o.getAttributes())}else if(n instanceof re)for(const o of n.listRefsByChild(t)){const i=o.getAttributes();this.removeRef(r,t),this.addRef(r,s,i)}else if(n instanceof $){const o=n.getRefByChild(t);if(o){const i=o.getAttributes();this.removeRef(r,t),this.addRef(r,s,i)}}else if(n instanceof J)for(const o of n.keys()){const i=n.get(o);i.getChild()===t&&this.setRefMap(r,o,s,i.getAttributes())}}return this}get(t){return this[V][t]}set(t,s){return this[V][t]=s,this.dispatchEvent({type:"change",attribute:t})}getRef(t){const s=this[V][t];return s?s.getChild():null}setRef(t,s,r){if(this[Le].has(t))throw new Error(`Cannot overwrite immutable attribute, "${t}".`);const n=this[V][t];if(n&&n.dispose(),!s)return this;const o=this.graph._createEdge(t,this,s,r);return this[V][t]=o,this.dispatchEvent({type:"change",attribute:t})}listRefs(t){return this.assertRefList(t).values().map(s=>s.getChild())}addRef(t,s,r){const n=this.graph._createEdge(t,this,s,r);return this.assertRefList(t).add(n),this.dispatchEvent({type:"change",attribute:t})}removeRef(t,s){const r=this.assertRefList(t);if(r instanceof re)for(const n of r.listRefsByChild(s))n.dispose();else{const n=r.getRefByChild(s);n&&n.dispose()}return this}assertRefList(t){const s=this[V][t];if(s instanceof re||s instanceof $)return s;throw new Error(`Expected RefList or RefSet for attribute "${t}"`)}listRefMapKeys(t){return this.assertRefMap(t).keys()}listRefMapValues(t){return this.assertRefMap(t).values().map(s=>s.getChild())}getRefMap(t,s){const r=this.assertRefMap(t).get(s);return r?r.getChild():null}setRefMap(t,s,r,n){const o=this.assertRefMap(t),i=o.get(s);if(i&&i.dispose(),!r)return this;n=Object.assign(n||{},{key:s});const a=this.graph._createEdge(t,this,r,{...n,key:s});return o.set(s,a),this.dispatchEvent({type:"change",attribute:t,key:s})}assertRefMap(t){const s=this[V][t];if(s instanceof J)return s;throw new Error(`Expected RefMap for attribute "${t}"`)}dispatchEvent(t){return super.dispatchEvent({...t,target:this}),this.graph.dispatchEvent({...t,target:this,type:`node:${t.type}`}),this}_destroyRef(t){const s=t.getName();if(this[V][s]===t)this[V][s]=null,this[Le].has(s)&&t.getChild().dispose();else if(this[V][s]instanceof re)this[V][s].remove(t);else if(this[V][s]instanceof $)this[V][s].remove(t);else if(this[V][s]instanceof J){const r=this[V][s];for(const n of r.keys())r.get(n)===t&&r.delete(n)}else return;this.graph._destroyEdge(t),this.dispatchEvent({type:"change",attribute:s})}};const ln="v4.5.0",ze="@glb.bin";let _=(function(e){return e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo",e})({}),gi=(function(e){return e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE",e})({}),de=(function(e){return e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A",e})({});var pi=class extends Float32Array{constructor(){throw super(),new Error("Unsupported typed array instantiation.")}};const pt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5131:typeof Float16Array<"u"?Float16Array:pi,5126:Float32Array,5130:Float64Array};var C=class{static createBufferFromDataURI(e){if(typeof Buffer>"u"){const t=atob(e.split(",")[1]),s=new Uint8Array(t.length);for(let r=0;r<t.length;r++)s[r]=t.charCodeAt(r);return s}else{const t=e.split(",")[1],s=e.indexOf("base64")>=0;return Buffer.from(t,s?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(const n of e)t+=n.byteLength;const s=new Uint8Array(t);let r=0;for(const n of e)s.set(n,r),r+=n.byteLength;return s}static pad(e,t=0){const s=this.padNumber(e.byteLength);if(s===e.byteLength)return e;const r=new Uint8Array(s);if(r.set(e),t!==0)for(let n=e.byteLength;n<s;n++)r[n]=t;return r}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let s=e.byteLength;for(;s--;)if(e[s]!==t[s])return!1;return!0}static toView(e,t=0,s=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,s))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw new Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}},mi=class{static hexToFactor(e,t){e=Math.floor(e);const s=t;return s[0]=(e>>16&255)/255,s[1]=(e>>8&255)/255,s[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){const t=[...e],[s,r,n]=this.convertLinearToSRGB(e,t);return s*255<<16^r*255<<8^n*255<<0}static convertSRGBToLinear(e,t){const s=e,r=t;for(let n=0;n<3;n++)r[n]=s[n]<.04045?s[n]*.0773993808:Math.pow(s[n]*.9478672986+.0521327014,2.4);return t}static convertLinearToSRGB(e,t){const s=e,r=t;for(let n=0;n<3;n++)r[n]=s[n]<.0031308?s[n]*12.92:1.055*Math.pow(s[n],.41666)-.055;return t}},yi=class{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),s,r;for(;t.byteLength;){if(s=t.getUint16(0,!1),xi(t,s),r=t.getUint8(s+1),r===192||r===193||r===194)return[t.getUint16(s+7,!1),t.getUint16(s+5,!1)];t=new DataView(e.buffer,t.byteOffset+s+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(e){return 3}},Ti=class fn{static PNG_FRIED_CHUNK_NAME="CgBI";match(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10}getSize(t){const s=new DataView(t.buffer,t.byteOffset);return C.decodeText(t.slice(12,16))===fn.PNG_FRIED_CHUNK_NAME?[s.getUint32(32,!1),s.getUint32(36,!1)]:[s.getUint32(16,!1),s.getUint32(20,!1)]}getChannels(t){return 4}},fe=class{static impls={"image/jpeg":new yi,"image/png":new Ti};static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(const t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){return this.impls[t]?this.impls[t].getSize(e):null}static getChannels(e,t){return this.impls[t]?this.impls[t].getChannels(e):null}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let s=0;const r=4,n=this.getSize(e,t);if(!n)return null;for(;n[0]>1||n[1]>1;)s+=n[0]*n[1]*r,n[0]=Math.max(Math.floor(n[0]/2),1),n[1]=Math.max(Math.floor(n[1]/2),1);return s+=4,s}static mimeTypeToExtension(e){return e==="image/jpeg"?"jpg":e.split("/").pop()}static extensionToMimeType(e){return e==="jpg"?"image/jpeg":e?`image/${e}`:""}};function xi(e,t){if(t>e.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(e.getUint8(t)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return e}var rt=class{static basename(e){const t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){const t=e.match(/data:(image\/\w+)/)[1];return fe.mimeTypeToExtension(t)}else{if(e.startsWith("data:model/gltf+json"))return"gltf";if(e.startsWith("data:model/gltf-binary"))return"glb";if(e.startsWith("data:application/"))return"bin"}return e.split(/[\\/]/).pop().split(/[.]/).pop()}},bs=typeof Float32Array<"u"?Float32Array:Array;function Ei(){var e=new bs(3);return bs!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function rs(e){var t=e[0],s=e[1],r=e[2];return Math.sqrt(t*t+s*s+r*r)}function bi(e,t,s){var r=t[0],n=t[1],o=t[2],i=s[3]*r+s[7]*n+s[11]*o+s[15];return i=i||1,e[0]=(s[0]*r+s[4]*n+s[8]*o+s[12])/i,e[1]=(s[1]*r+s[5]*n+s[9]*o+s[13])/i,e[2]=(s[2]*r+s[6]*n+s[10]*o+s[14])/i,e}(function(){var e=Ei();return function(t,s,r,n,o,i){var a,c;for(s||(s=3),r||(r=0),n?c=Math.min(n*s+r,t.length):c=t.length,a=r;a<c;a+=s)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],o(e,e,i),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();function hn(e){const t=dn(),s=e.propertyType==="Node"?[e]:e.listChildren();for(const r of s)r.traverse(n=>{const o=n.getMesh();if(!o)return;const i=_i(o,n.getWorldMatrix());i.min.every(isFinite)&&i.max.every(isFinite)&&(_s(i.min,t),_s(i.max,t))});return t}function _i(e,t){const s=dn();for(const r of e.listPrimitives()){const n=r.getAttribute("POSITION"),o=r.getIndices();if(!n)continue;let i=[0,0,0],a=[0,0,0];for(let c=0,l=o?o.getCount():n.getCount();c<l;c++){const u=o?o.getScalar(c):c;i=n.getElement(u,i),a=bi(a,i,t),_s(a,s)}}return s}function _s(e,t){for(let s=0;s<3;s++)t.min[s]=Math.min(e[s],t.min[s]),t.max[s]=Math.max(e[s],t.max[s])}function dn(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}const er="https://null.example";var ns=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substring(0,t+1)}static basename(e){return rt.basename(new URL(e,er).pathname)}static extension(e){return rt.extension(new URL(e,er).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;const s=e.split("/"),r=t.split("/");s.pop();for(let n=0;n<r.length;n++)r[n]!=="."&&(r[n]===".."?s.pop():s.push(r[n]));return s.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}};function tr(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ve(e){if(tr(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(tr(s)===!1||Object.hasOwn(s,"isPrototypeOf")===!1)}let Ii=(function(e){return e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG",e})({});var Wt=class gn{verbosity;static Verbosity=Ii;static DEFAULT_INSTANCE=new gn(1);constructor(t){this.verbosity=t}debug(t){this.verbosity<=0&&console.debug(t)}info(t){this.verbosity<=1&&console.info(t)}warn(t){this.verbosity<=2&&console.warn(t)}error(t){this.verbosity<=3&&console.error(t)}};function Ai(e){var t=e[0],s=e[1],r=e[2],n=e[3],o=e[4],i=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],f=e[11],g=e[12],T=e[13],p=e[14],x=e[15],d=t*i-s*o,y=t*a-r*o,m=s*a-r*i,E=l*T-u*g,b=l*p-h*g,I=u*p-h*T,w=t*I-s*b+r*E,R=o*I-i*b+a*E,v=l*m-u*y+h*d,M=g*m-T*y+p*d;return c*w-n*R+x*v-f*M}function vi(e,t,s){var r=t[0],n=t[1],o=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],h=t[8],f=t[9],g=t[10],T=t[11],p=t[12],x=t[13],d=t[14],y=t[15],m=s[0],E=s[1],b=s[2],I=s[3];return e[0]=m*r+E*a+b*h+I*p,e[1]=m*n+E*c+b*f+I*x,e[2]=m*o+E*l+b*g+I*d,e[3]=m*i+E*u+b*T+I*y,m=s[4],E=s[5],b=s[6],I=s[7],e[4]=m*r+E*a+b*h+I*p,e[5]=m*n+E*c+b*f+I*x,e[6]=m*o+E*l+b*g+I*d,e[7]=m*i+E*u+b*T+I*y,m=s[8],E=s[9],b=s[10],I=s[11],e[8]=m*r+E*a+b*h+I*p,e[9]=m*n+E*c+b*f+I*x,e[10]=m*o+E*l+b*g+I*d,e[11]=m*i+E*u+b*T+I*y,m=s[12],E=s[13],b=s[14],I=s[15],e[12]=m*r+E*a+b*h+I*p,e[13]=m*n+E*c+b*f+I*x,e[14]=m*o+E*l+b*g+I*d,e[15]=m*i+E*u+b*T+I*y,e}function Ri(e,t){var s=t[0],r=t[1],n=t[2],o=t[4],i=t[5],a=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(s*s+r*r+n*n),e[1]=Math.sqrt(o*o+i*i+a*a),e[2]=Math.sqrt(c*c+l*l+u*u),e}function wi(e,t){var s=new bs(3);Ri(s,t);var r=1/s[0],n=1/s[1],o=1/s[2],i=t[0]*r,a=t[1]*n,c=t[2]*o,l=t[4]*r,u=t[5]*n,h=t[6]*o,f=t[8]*r,g=t[9]*n,T=t[10]*o,p=i+u+T,x=0;return p>0?(x=Math.sqrt(p+1)*2,e[3]=.25*x,e[0]=(h-g)/x,e[1]=(f-c)/x,e[2]=(a-l)/x):i>u&&i>T?(x=Math.sqrt(1+i-u-T)*2,e[3]=(h-g)/x,e[0]=.25*x,e[1]=(a+l)/x,e[2]=(f+c)/x):u>T?(x=Math.sqrt(1+u-i-T)*2,e[3]=(f-c)/x,e[0]=(a+l)/x,e[1]=.25*x,e[2]=(h+g)/x):(x=Math.sqrt(1+T-i-u)*2,e[3]=(a-l)/x,e[0]=(f+c)/x,e[1]=(h+g)/x,e[2]=.25*x),e}var B=class lt{static identity(t){return t}static eq(t,s,r=1e-5){if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(Math.abs(t[n]-s[n])>r)return!1;return!0}static clamp(t,s,r){return t<s?s:t>r?r:t}static decodeNormalizedInt(t,s){switch(s){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(t,s){switch(s){case 5126:return t;case 5123:return Math.round(lt.clamp(t,0,1)*65535);case 5121:return Math.round(lt.clamp(t,0,1)*255);case 5122:return Math.round(lt.clamp(t,-1,1)*32767);case 5120:return Math.round(lt.clamp(t,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(t,s,r,n){let o=rs([t[0],t[1],t[2]]);const i=rs([t[4],t[5],t[6]]),a=rs([t[8],t[9],t[10]]);Ai(t)<0&&(o=-o),s[0]=t[12],s[1]=t[13],s[2]=t[14];const c=t.slice(),l=1/o,u=1/i,h=1/a;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=h,c[9]*=h,c[10]*=h,wi(r,c),n[0]=o,n[1]=i,n[2]=a}static compose(t,s,r,n){const o=n,i=s[0],a=s[1],c=s[2],l=s[3],u=i+i,h=a+a,f=c+c,g=i*u,T=i*h,p=i*f,x=a*h,d=a*f,y=c*f,m=l*u,E=l*h,b=l*f,I=r[0],w=r[1],R=r[2];return o[0]=(1-(x+y))*I,o[1]=(T+b)*I,o[2]=(p-E)*I,o[3]=0,o[4]=(T-b)*w,o[5]=(1-(g+y))*w,o[6]=(d+m)*w,o[7]=0,o[8]=(p+E)*R,o[9]=(d-m)*R,o[10]=(1-(g+x))*R,o[11]=0,o[12]=t[0],o[13]=t[1],o[14]=t[2],o[15]=1,o}};function Si(e,t){if(!!e!=!!t)return!1;const s=e.getChild(),r=t.getChild();return s===r||s.equals(r)}function Ni(e,t){if(!!e!=!!t)return!1;const s=e.values(),r=t.values();if(s.length!==r.length)return!1;for(let n=0;n<s.length;n++){const o=s[n],i=r[n];if(o.getChild()!==i.getChild()&&!o.getChild().equals(i.getChild()))return!1}return!0}function Mi(e,t){if(!!e!=!!t)return!1;const s=e.keys(),r=t.keys();if(s.length!==r.length)return!1;for(const n of s){const o=e.get(n),i=t.get(n);if(!!o!=!!i)return!1;const a=o.getChild(),c=i.getChild();if(a!==c&&!a.equals(c))return!1}return!0}function pn(e,t){if(e===t)return!0;if(!!e!=!!t||!e||!t||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function mn(e,t){if(e===t)return!0;if(!!e!=!!t)return!1;if(!Ve(e)||!Ve(t))return e===t;const s=e,r=t;let n=0,o=0,i;for(i in s)n++;for(i in r)o++;if(n!==o)return!1;for(i in s){const a=s[i],c=r[i];if(Vt(a)&&Vt(c)){if(!pn(a,c))return!1}else if(Ve(a)&&Ve(c)){if(!mn(a,c))return!1}else if(a!==c)return!1}return!0}function Vt(e){return Array.isArray(e)||ArrayBuffer.isView(e)}const Ci="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Oi=999,Di=6,sr=new Set,Pi=function(){let e="";for(let t=0;t<Di;t++)e+=Ci.charAt(Math.floor(Math.random()*42));return e},ji=function(){for(let e=0;e<Oi;e++){const t=Pi();if(!sr.has(t))return sr.add(t),t}return""},Ue=e=>e,Fi=new Set;var ks=class extends di{constructor(e,t=""){super(e),this[V].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){return Array.isArray(t)&&(t=t.slice()),super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){const e=this.constructor;return new e(this.graph).copy(this,Ue)}copy(e,t=Ue){for(const s in this[V]){const r=this[V][s];if(r instanceof Je)this[Le].has(s)||r.dispose();else if(r instanceof re||r instanceof $)for(const n of r.values())n.dispose();else if(r instanceof J)for(const n of r.values())n.dispose()}for(const s in e[V]){const r=this[V][s],n=e[V][s];if(n instanceof Je)this[Le].has(s)?r.getChild().copy(t(n.getChild()),t):this.setRef(s,t(n.getChild()),n.getAttributes());else if(n instanceof $||n instanceof re)for(const o of n.values())this.addRef(s,t(o.getChild()),o.getAttributes());else if(n instanceof J)for(const o of n.keys()){const i=n.get(o);this.setRefMap(s,o,t(i.getChild()),i.getAttributes())}else Ve(n)?this[V][s]=JSON.parse(JSON.stringify(n)):Array.isArray(n)||n instanceof ArrayBuffer||ArrayBuffer.isView(n)?this[V][s]=n.slice():this[V][s]=n}return this}equals(e,t=Fi){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(const s in this[V]){if(t.has(s))continue;const r=this[V][s],n=e[V][s];if(r instanceof Je||n instanceof Je){if(!Si(r,n))return!1}else if(r instanceof $||n instanceof $||r instanceof re||n instanceof re){if(!Ni(r,n))return!1}else if(r instanceof J||n instanceof J){if(!Mi(r,n))return!1}else if(Ve(r)||Ve(n)){if(!mn(r,n))return!1}else if(Vt(r)||Vt(n)){if(!pn(r,n))return!1}else if(r!==n)return!1}return!0}detach(){return this.graph.disconnectParents(this,e=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},ee=class extends ks{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new J})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){return t&&t._validateParent(this),this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}},N=class K extends ee{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor"}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K.Type.SCALAR,componentType:K.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(t){switch(t){case K.Type.SCALAR:return 1;case K.Type.VEC2:return 2;case K.Type.VEC3:return 3;case K.Type.VEC4:return 4;case K.Type.MAT2:return 4;case K.Type.MAT3:return 9;case K.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case K.ComponentType.BYTE:case K.ComponentType.UNSIGNED_BYTE:return 1;case K.ComponentType.SHORT:case K.ComponentType.UNSIGNED_SHORT:return 2;case K.ComponentType.UNSIGNED_INT:case K.ComponentType.FLOAT:return 4;case K.ComponentType.FLOAT16:return 2;case K.ComponentType.FLOAT64:return 8;default:throw new Error("Unexpected component type: "+t)}}getMinNormalized(t){const s=this.getNormalized(),r=this.getElementSize(),n=this.getComponentType();if(this.getMin(t),s)for(let o=0;o<r;o++)t[o]=B.decodeNormalizedInt(t[o],n);return t}getMin(t){const s=this.getArray(),r=this.getCount(),n=this.getElementSize();for(let o=0;o<n;o++)t[o]=1/0;for(let o=0;o<r*n;o+=n)for(let i=0;i<n;i++){const a=s[o+i];Number.isFinite(a)&&(t[i]=Math.min(t[i],a))}return t}getMaxNormalized(t){const s=this.getNormalized(),r=this.getElementSize(),n=this.getComponentType();if(this.getMax(t),s)for(let o=0;o<r;o++)t[o]=B.decodeNormalizedInt(t[o],n);return t}getMax(t){const s=this.get("array"),r=this.getCount(),n=this.getElementSize();for(let o=0;o<n;o++)t[o]=-1/0;for(let o=0;o<r*n;o+=n)for(let i=0;i<n;i++){const a=s[o+i];Number.isFinite(a)&&(t[i]=Math.max(t[i],a))}return t}getCount(){const t=this.get("array");return t?t.length/this.getElementSize():0}getType(){return this.get("type")}setType(t){return this.set("type",t)}getElementSize(){return K.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(t){return this.set("normalized",t)}getScalar(t){const s=this.getElementSize(),r=this.getComponentType(),n=this.getArray();return this.getNormalized()?B.decodeNormalizedInt(n[t*s],r):n[t*s]}setScalar(t,s){const r=this.getElementSize(),n=this.getComponentType(),o=this.getArray();return this.getNormalized()?o[t*r]=B.encodeNormalizedInt(s,n):o[t*r]=s,this}getElement(t,s){const r=this.getNormalized(),n=this.getElementSize(),o=this.getComponentType(),i=this.getArray();for(let a=0;a<n;a++)r?s[a]=B.decodeNormalizedInt(i[t*n+a],o):s[a]=i[t*n+a];return s}setElement(t,s){const r=this.getNormalized(),n=this.getElementSize(),o=this.getComponentType(),i=this.getArray();for(let a=0;a<n;a++)r?i[t*n+a]=B.encodeNormalizedInt(s[a],o):i[t*n+a]=s[a];return this}getSparse(){return this.get("sparse")}setSparse(t){return this.set("sparse",t)}getBuffer(){return this.getRef("buffer")}setBuffer(t){return this.setRef("buffer",t)}getArray(){return this.get("array")}setArray(t){return this.set("componentType",t?Ui(t):K.ComponentType.FLOAT),this.set("array",t),this}getByteLength(){const t=this.get("array");return t?t.byteLength:0}};function Ui(e){switch(e.constructor){case Float32Array:return N.ComponentType.FLOAT;case Uint32Array:return N.ComponentType.UNSIGNED_INT;case Uint16Array:return N.ComponentType.UNSIGNED_SHORT;case Uint8Array:return N.ComponentType.UNSIGNED_BYTE;case Int16Array:return N.ComponentType.SHORT;case Int8Array:return N.ComponentType.BYTE;case Float64Array:return N.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&e.constructor===Float16Array)return N.ComponentType.FLOAT16;throw new Error("Unknown accessor componentType.")}var yn=class extends ee{init(){this.propertyType="Animation"}getDefaults(){return Object.assign(super.getDefaults(),{channels:new $,samplers:new $})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}},mt=class extends ee{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel"}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}},zs=class Tn extends ee{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler"}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:Tn.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(t){return this.set("interpolation",t)}getInput(){return this.getRef("input")}setInput(t){return this.setRef("input",t,{usage:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(t){return this.setRef("output",t,{usage:"OTHER"})}},xn=class extends ee{init(){this.propertyType="Buffer"}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}},Yt=class En extends ee{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera"}getDefaults(){return Object.assign(super.getDefaults(),{type:En.Type.PERSPECTIVE,znear:.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(t){return this.set("type",t)}getZNear(){return this.get("znear")}setZNear(t){return this.set("znear",t)}getZFar(){return this.get("zfar")}setZFar(t){return this.set("zfar",t)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(t){return this.set("aspectRatio",t)}getYFov(){return this.get("yfov")}setYFov(t){return this.set("yfov",t)}getXMag(){return this.get("xmag")}setXMag(t){return this.set("xmag",t)}getYMag(){return this.get("ymag")}setYMag(t){return this.set("ymag",t)}},j=class extends ks{static EXTENSION_NAME;_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw new Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}},z=class Is extends ee{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo"}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:Is.WrapMode.REPEAT,wrapT:Is.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(t){return this.set("texCoord",t)}getMagFilter(){return this.get("magFilter")}setMagFilter(t){return this.set("magFilter",t)}getMinFilter(){return this.get("minFilter")}setMinFilter(t){return this.set("minFilter",t)}getWrapS(){return this.get("wrapS")}setWrapS(t){return this.set("wrapS",t)}getWrapT(){return this.get("wrapT")}setWrapT(t){return this.set("wrapT",t)}};const{R:_t,G:It,B:At,A:Bi}=de;var nt=class bn extends ee{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material"}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:bn.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new z(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new z(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new z(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new z(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new z(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(t){return this.set("doubleSided",t)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(t){const s=this.get("baseColorFactor").slice();return s[3]=t,this.set("baseColorFactor",s)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(t){return this.set("alphaMode",t)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(t){return this.set("alphaCutoff",t)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(t){return this.set("baseColorFactor",t)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(t){return this.setRef("baseColorTexture",t,{channels:_t|It|At|Bi,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(t){return this.set("emissiveFactor",t)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(t){return this.setRef("emissiveTexture",t,{channels:_t|It|At,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(t){return this.set("normalScale",t)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(t){return this.setRef("normalTexture",t,{channels:_t|It|At})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(t){return this.set("occlusionStrength",t)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(t){return this.setRef("occlusionTexture",t,{channels:_t})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(t){return this.set("roughnessFactor",t)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(t){return this.set("metallicFactor",t)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(t){return this.setRef("metallicRoughnessTexture",t,{channels:It|At})}},_n=class extends ee{init(){this.propertyType="Mesh"}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new $})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}},Gs=class extends ee{init(){this.propertyType="Node"}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new $})}copy(e,t=Ue){if(t===Ue)throw new Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return B.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){const t=this.get("translation").slice(),s=this.get("rotation").slice(),r=this.get("scale").slice();return B.decompose(e,t,s,r),this.set("translation",t).set("rotation",s).set("scale",r)}getWorldTranslation(){const e=[0,0,0];return B.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){const e=[0,0,0,1];return B.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){const e=[1,1,1];return B.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){const e=[];for(let r=this;r!=null;r=r.getParentNode())e.push(r);let t;const s=e.pop().getMatrix();for(;t=e.pop();)vi(s,s,t.getMatrix());return s}addChild(e){const t=e.getParentNode();t&&t.removeChild(e);for(const s of e.listParents())s.propertyType==="Scene"&&s.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(const e of this.listParents())if(e.propertyType==="Node")return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(const t of this.listChildren())t.traverse(e);return this}},q=class In extends ee{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive"}getDefaults(){return Object.assign(super.getDefaults(),{mode:In.Mode.TRIANGLES,material:null,indices:null,attributes:new J,targets:new $})}getIndices(){return this.getRef("indices")}setIndices(t){return this.setRef("indices",t,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(t){return this.getRefMap("attributes",t)}setAttribute(t,s){return this.setRefMap("attributes",t,s,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(t){return this.setRef("material",t)}getMode(){return this.get("mode")}setMode(t){return this.set("mode",t)}listTargets(){return this.listRefs("targets")}addTarget(t){return this.addRef("targets",t)}removeTarget(t){return this.removeRef("targets",t)}},An=class extends ks{init(){this.propertyType="PrimitiveTarget"}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new J})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},$s=class extends ee{init(){this.propertyType="Scene"}getDefaults(){return Object.assign(super.getDefaults(),{children:new $})}copy(e,t=Ue){if(t===Ue)throw new Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){const t=e.getParentNode();return t&&t.removeChild(e),this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(const t of this.listChildren())t.traverse(e);return this}},vn=class extends ee{init(){this.propertyType="Skin"}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new $})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:"INVERSE_BIND_MATRICES"})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}},Ge=class extends ee{init(){this.propertyType="Texture"}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||fe.extensionToMimeType(rt.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);const t=fe.extensionToMimeType(rt.extension(e));return t&&this.set("mimeType",t),this}getImage(){return this.get("image")}setImage(e){return this.set("image",C.assertView(e))}getSize(){const e=this.get("image");return e?fe.getSize(e,this.getMimeType()):null}},it=class extends ee{_extensions=new Set;init(){this.propertyType="Root"}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${ln}`,version:"2.0"},defaultScene:null,accessors:new $,animations:new $,buffers:new $,cameras:new $,materials:new $,meshes:new $,nodes:new $,scenes:new $,skins:new $,textures:new $})}constructor(e){super(e),e.addEventListener("node:create",t=>{this._addChildOfRoot(t.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(e,t=Ue){if(t===Ue)throw new Error("Root cannot be copied.");this.set("asset",{...e.get("asset")}),this.setName(e.getName()),this.setExtras({...e.getExtras()}),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(const s of e.listRefMapKeys("extensions")){const r=e.getExtension(s);this.setExtension(s,t(r))}return this}_addChildOfRoot(e){return e instanceof $s?this.addRef("scenes",e):e instanceof Gs?this.addRef("nodes",e):e instanceof Yt?this.addRef("cameras",e):e instanceof vn?this.addRef("skins",e):e instanceof _n?this.addRef("meshes",e):e instanceof nt?this.addRef("materials",e):e instanceof Ge?this.addRef("textures",e):e instanceof yn?this.addRef("animations",e):e instanceof N?this.addRef("accessors",e):e instanceof xn&&this.addRef("buffers",e),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter(e=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}},$e=class As{_graph=new hi;_root=new it(this._graph);_logger=Wt.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(t){return As._GRAPH_DOCUMENTS.get(t)||null}constructor(){As._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(t){return this._logger=t,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(t){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...t){const s=t.map(r=>r.name);for(const r of t)await r(this,{stack:s});return this}hasExtension(t){return this.getRoot().listExtensionsUsed().some(s=>s.extensionName===t)}createExtension(t){const s=t.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(r=>r.extensionName===s)||new t(this)}disposeExtension(t){const s=this.getRoot().listExtensionsUsed().find(r=>r.extensionName===t);s&&s.dispose()}createScene(t=""){return new $s(this._graph,t)}createNode(t=""){return new Gs(this._graph,t)}createCamera(t=""){return new Yt(this._graph,t)}createSkin(t=""){return new vn(this._graph,t)}createMesh(t=""){return new _n(this._graph,t)}createPrimitive(){return new q(this._graph)}createPrimitiveTarget(t=""){return new An(this._graph,t)}createMaterial(t=""){return new nt(this._graph,t)}createTexture(t=""){return new Ge(this._graph,t)}createAnimation(t=""){return new yn(this._graph,t)}createAnimationChannel(t=""){return new mt(this._graph,t)}createAnimationSampler(t=""){return new zs(this._graph,t)}createAccessor(t="",s=null){return s||(s=this.getRoot().listBuffers()[0]),new N(this._graph,t).setBuffer(s)}createBuffer(t=""){return new xn(this._graph,t)}},k=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=!1;properties=new Set;_listener;constructor(e){this.document=e,e.getRoot()._enableExtension(this),this._listener=s=>{const r=s,n=r.target;n instanceof j&&n.extensionName===this.extensionName&&(r.type==="node:create"&&this._addExtensionProperty(n),r.type==="node:dispose"&&this._removeExtensionProperty(n))};const t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);const e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(const t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}},Li=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(e){this.jsonDoc=e}setTextureInfo(e,t){this.textureInfos.set(e,t),t.texCoord!==void 0&&e.setTexCoord(t.texCoord),t.extras!==void 0&&e.setExtras(t.extras);const s=this.jsonDoc.json.textures[t.index];if(s.sampler===void 0)return;const r=this.jsonDoc.json.samplers[s.sampler];r.magFilter!==void 0&&e.setMagFilter(r.magFilter),r.minFilter!==void 0&&e.setMinFilter(r.minFilter),r.wrapS!==void 0&&e.setWrapS(r.wrapS),r.wrapT!==void 0&&e.setWrapT(r.wrapT)}};const rr={logger:Wt.DEFAULT_INSTANCE,extensions:[],dependencies:{}},Vi=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]);var ki=class{static read(e,t=rr){const s={...rr,...t},{json:r}=e,n=new $e().setLogger(s.logger);this.validate(e,s);const o=new Li(e),i=r.asset,a=n.getRoot().getAsset();i.copyright&&(a.copyright=i.copyright),i.extras&&(a.extras=i.extras),r.extras!==void 0&&n.getRoot().setExtras({...r.extras});const c=r.extensionsUsed||[],l=r.extensionsRequired||[];s.extensions.sort((d,y)=>d.EXTENSION_NAME>y.EXTENSION_NAME?1:-1);for(const d of s.extensions)if(c.includes(d.EXTENSION_NAME)){const y=n.createExtension(d).setRequired(l.includes(d.EXTENSION_NAME)),m=y.prereadTypes.filter(E=>!Vi.has(E));m.length&&s.logger.warn(`Preread hooks for some types (${m.join()}), requested by extension ${y.extensionName}, are unsupported. Please file an issue or a PR.`);for(const E of y.readDependencies)y.install(E,s.dependencies[E])}const u=r.buffers||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Buffer")).forEach(d=>d.preread(o,"Buffer")),o.buffers=u.map(d=>{const y=n.createBuffer(d.name);return d.extras&&y.setExtras(d.extras),d.uri&&d.uri.indexOf("__")!==0&&y.setURI(d.uri),y}),o.bufferViewBuffers=(r.bufferViews||[]).map((d,y)=>{if(!o.bufferViews[y]){const m=e.json.buffers[d.buffer],E=m.uri?e.resources[m.uri]:e.resources[ze],b=d.byteOffset||0;o.bufferViews[y]=C.toView(E,b,d.byteLength)}return o.buffers[d.buffer]});const h=r.accessors||[];o.accessors=h.map(d=>{const y=o.bufferViewBuffers[d.bufferView],m=n.createAccessor(d.name,y).setType(d.type);return d.extras&&m.setExtras(d.extras),d.normalized!==void 0&&m.setNormalized(d.normalized),d.bufferView===void 0||m.setArray(Ot(d,o)),m});const f=r.images||[],g=r.textures||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Texture")).forEach(d=>d.preread(o,"Texture")),o.textures=f.map(d=>{const y=n.createTexture(d.name);if(d.extras&&y.setExtras(d.extras),d.bufferView!==void 0){const m=r.bufferViews[d.bufferView],E=e.json.buffers[m.buffer],b=E.uri?e.resources[E.uri]:e.resources[ze],I=m.byteOffset||0,w=m.byteLength,R=b.slice(I,I+w);y.setImage(R)}else d.uri!==void 0&&(y.setImage(e.resources[d.uri]),d.uri.indexOf("__")!==0&&y.setURI(d.uri));if(d.mimeType!==void 0)y.setMimeType(d.mimeType);else if(d.uri){const m=rt.extension(d.uri);y.setMimeType(fe.extensionToMimeType(m))}return y}),n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Material")).forEach(d=>d.preread(o,"Material")),o.materials=(r.materials||[]).map(d=>{const y=n.createMaterial(d.name);d.extras&&y.setExtras(d.extras),d.alphaMode!==void 0&&y.setAlphaMode(d.alphaMode),d.alphaCutoff!==void 0&&y.setAlphaCutoff(d.alphaCutoff),d.doubleSided!==void 0&&y.setDoubleSided(d.doubleSided);const m=d.pbrMetallicRoughness||{};if(m.baseColorFactor!==void 0&&y.setBaseColorFactor(m.baseColorFactor),d.emissiveFactor!==void 0&&y.setEmissiveFactor(d.emissiveFactor),m.metallicFactor!==void 0&&y.setMetallicFactor(m.metallicFactor),m.roughnessFactor!==void 0&&y.setRoughnessFactor(m.roughnessFactor),m.baseColorTexture!==void 0){const E=m.baseColorTexture,b=o.textures[g[E.index].source];y.setBaseColorTexture(b),o.setTextureInfo(y.getBaseColorTextureInfo(),E)}if(d.emissiveTexture!==void 0){const E=d.emissiveTexture,b=o.textures[g[E.index].source];y.setEmissiveTexture(b),o.setTextureInfo(y.getEmissiveTextureInfo(),E)}if(d.normalTexture!==void 0){const E=d.normalTexture,b=o.textures[g[E.index].source];y.setNormalTexture(b),o.setTextureInfo(y.getNormalTextureInfo(),E),d.normalTexture.scale!==void 0&&y.setNormalScale(d.normalTexture.scale)}if(d.occlusionTexture!==void 0){const E=d.occlusionTexture,b=o.textures[g[E.index].source];y.setOcclusionTexture(b),o.setTextureInfo(y.getOcclusionTextureInfo(),E),d.occlusionTexture.strength!==void 0&&y.setOcclusionStrength(d.occlusionTexture.strength)}if(m.metallicRoughnessTexture!==void 0){const E=m.metallicRoughnessTexture,b=o.textures[g[E.index].source];y.setMetallicRoughnessTexture(b),o.setTextureInfo(y.getMetallicRoughnessTextureInfo(),E)}return y}),n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Mesh")).forEach(d=>d.preread(o,"Mesh"));const T=r.meshes||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Primitive")).forEach(d=>d.preread(o,"Primitive")),o.meshes=T.map(d=>{const y=n.createMesh(d.name);return d.extras&&y.setExtras(d.extras),d.weights!==void 0&&y.setWeights(d.weights),(d.primitives||[]).forEach(m=>{const E=n.createPrimitive();m.extras&&E.setExtras(m.extras),m.material!==void 0&&E.setMaterial(o.materials[m.material]),m.mode!==void 0&&E.setMode(m.mode);for(const[I,w]of Object.entries(m.attributes||{}))E.setAttribute(I,o.accessors[w]);m.indices!==void 0&&E.setIndices(o.accessors[m.indices]);const b=d.extras&&d.extras.targetNames||[];(m.targets||[]).forEach((I,w)=>{const R=b[w]||w.toString(),v=n.createPrimitiveTarget(R);for(const[M,U]of Object.entries(I))v.setAttribute(M,o.accessors[U]);E.addTarget(v)}),y.addPrimitive(E)}),y}),o.cameras=(r.cameras||[]).map(d=>{const y=n.createCamera(d.name).setType(d.type);if(d.extras&&y.setExtras(d.extras),d.type===Yt.Type.PERSPECTIVE){const m=d.perspective;y.setYFov(m.yfov),y.setZNear(m.znear),m.zfar!==void 0&&y.setZFar(m.zfar),m.aspectRatio!==void 0&&y.setAspectRatio(m.aspectRatio)}else{const m=d.orthographic;y.setZNear(m.znear).setZFar(m.zfar).setXMag(m.xmag).setYMag(m.ymag)}return y});const p=r.nodes||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Node")).forEach(d=>d.preread(o,"Node")),o.nodes=p.map(d=>{const y=n.createNode(d.name);if(d.extras&&y.setExtras(d.extras),d.translation!==void 0&&y.setTranslation(d.translation),d.rotation!==void 0&&y.setRotation(d.rotation),d.scale!==void 0&&y.setScale(d.scale),d.matrix!==void 0){const m=[0,0,0],E=[0,0,0,1],b=[1,1,1];B.decompose(d.matrix,m,E,b),y.setTranslation(m),y.setRotation(E),y.setScale(b)}return d.weights!==void 0&&y.setWeights(d.weights),y}),o.skins=(r.skins||[]).map(d=>{const y=n.createSkin(d.name);d.extras&&y.setExtras(d.extras),d.inverseBindMatrices!==void 0&&y.setInverseBindMatrices(o.accessors[d.inverseBindMatrices]),d.skeleton!==void 0&&y.setSkeleton(o.nodes[d.skeleton]);for(const m of d.joints)y.addJoint(o.nodes[m]);return y}),p.map((d,y)=>{const m=o.nodes[y];(d.children||[]).forEach(E=>m.addChild(o.nodes[E])),d.mesh!==void 0&&m.setMesh(o.meshes[d.mesh]),d.camera!==void 0&&m.setCamera(o.cameras[d.camera]),d.skin!==void 0&&m.setSkin(o.skins[d.skin])}),o.animations=(r.animations||[]).map(d=>{const y=n.createAnimation(d.name);d.extras&&y.setExtras(d.extras);const m=(d.samplers||[]).map(E=>{const b=n.createAnimationSampler().setInput(o.accessors[E.input]).setOutput(o.accessors[E.output]).setInterpolation(E.interpolation||zs.Interpolation.LINEAR);return E.extras&&b.setExtras(E.extras),y.addSampler(b),b});return(d.channels||[]).forEach(E=>{const b=n.createAnimationChannel().setSampler(m[E.sampler]).setTargetPath(E.target.path);E.target.node!==void 0&&b.setTargetNode(o.nodes[E.target.node]),E.extras&&b.setExtras(E.extras),y.addChannel(b)}),y});const x=r.scenes||[];return n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Scene")).forEach(d=>d.preread(o,"Scene")),o.scenes=x.map(d=>{const y=n.createScene(d.name);return d.extras&&y.setExtras(d.extras),(d.nodes||[]).map(m=>o.nodes[m]).forEach(m=>y.addChild(m)),y}),r.scene!==void 0&&n.getRoot().setDefaultScene(o.scenes[r.scene]),n.getRoot().listExtensionsUsed().forEach(d=>d.read(o)),h.forEach((d,y)=>{const m=o.accessors[y],E=!!d.sparse,b=!d.bufferView&&!m.getArray();(E||b)&&m.setSparse(!0).setArray(Gi(d,o))}),n}static validate(e,t){const s=e.json;if(s.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${s.asset.version}".`);if(s.extensionsRequired){for(const r of s.extensionsRequired)if(!t.extensions.find(n=>n.EXTENSION_NAME===r))throw new Error(`Missing required extension, "${r}".`)}if(s.extensionsUsed)for(const r of s.extensionsUsed)t.extensions.find(n=>n.EXTENSION_NAME===r)||t.logger.warn(`Missing optional extension, "${r}".`)}};function zi(e,t){const s=t.jsonDoc,r=t.bufferViews[e.bufferView],n=s.json.bufferViews[e.bufferView],o=pt[e.componentType],i=N.getElementSize(e.type),a=o.BYTES_PER_ELEMENT,c=e.byteOffset||0,l=new o(e.count*i),u=new DataView(r.buffer,r.byteOffset,r.byteLength),h=n.byteStride;for(let f=0;f<e.count;f++)for(let g=0;g<i;g++){const T=c+f*h+g*a;let p;switch(e.componentType){case N.ComponentType.FLOAT:p=u.getFloat32(T,!0);break;case N.ComponentType.UNSIGNED_INT:p=u.getUint32(T,!0);break;case N.ComponentType.UNSIGNED_SHORT:p=u.getUint16(T,!0);break;case N.ComponentType.UNSIGNED_BYTE:p=u.getUint8(T);break;case N.ComponentType.SHORT:p=u.getInt16(T,!0);break;case N.ComponentType.BYTE:p=u.getInt8(T);break;case N.ComponentType.FLOAT16:p=u.getFloat16(T,!0);break;case N.ComponentType.FLOAT64:p=u.getFloat64(T,!0);break;default:throw new Error(`Unexpected componentType "${e.componentType}".`)}l[f*i+g]=p}return l}function Ot(e,t){const s=t.jsonDoc,r=t.bufferViews[e.bufferView],n=s.json.bufferViews[e.bufferView],o=pt[e.componentType],i=N.getElementSize(e.type),a=o.BYTES_PER_ELEMENT,c=i*a;if(n.byteStride!==void 0&&n.byteStride!==c)return zi(e,t);const l=r.byteOffset+(e.byteOffset||0),u=e.count*i*a;return new o(r.buffer.slice(l,l+u))}function Gi(e,t){const s=pt[e.componentType],r=N.getElementSize(e.type);let n;e.bufferView!==void 0?n=Ot(e,t):n=new s(e.count*r);const o=e.sparse;if(!o)return n;const i=o.count,a={...e,...o.indices,count:i,type:"SCALAR"},c={...e,...o.values,count:i},l=Ot(a,t),u=Ot(c,t);for(let h=0;h<a.count;h++)for(let f=0;f<r;f++)n[l[h]*r+f]=u[h*r+f];return n}var Rn=(function(e){return e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e})(Rn||{}),ke=class{_doc;jsonDoc;options;static BufferViewTarget=Rn;static BufferViewUsage=gi;static USAGE_TO_TARGET={ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(e,t,s){this._doc=e,this.jsonDoc=t,this.options=s;const r=e.getRoot(),n=r.listBuffers().length,o=r.listTextures().length;this.bufferURIGenerator=new nr(n>1,()=>s.basename||"buffer"),this.imageURIGenerator=new nr(o>1,i=>$i(e,i)||s.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){const s={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},r=JSON.stringify(s);this.samplerDefIndexMap.has(r)||(this.samplerDefIndexMap.set(r,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(s));const n={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(r)},o=JSON.stringify(n);this.textureDefIndexMap.has(o)||(this.textureDefIndexMap.set(o,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(n));const i={index:this.textureDefIndexMap.get(o)};return t.getTexCoord()!==0&&(i.texCoord=t.getTexCoord()),Object.keys(t.getExtras()).length>0&&(i.extras=t.getExtras()),this.textureInfoDefMap.set(t,i),i}createPropertyDef(e){const t={};return e.getName()&&(t.name=e.getName()),Object.keys(e.getExtras()).length>0&&(t.extras=e.getExtras()),t}createAccessorDef(e){const t=this.createPropertyDef(e);return t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some(s=>s.getName()==="attributes"&&s.getAttributes().key==="POSITION"||s.getName()==="input")&&(t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround)),e.getNormalized()&&(t.normalized=e.getNormalized()),t}createImageData(e,t,s){if(this.options.format==="GLB")this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{const r=fe.mimeTypeToExtension(s.getMimeType());e.uri=this.imageURIGenerator.createURI(s,r),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,s){const r=this.jsonDoc.resources;if(!(e in r)){r[e]=t;return}if(t===r[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}const n=`Resource URI "${e}" already assigned to different data.`;if(!s){this.logger.warn(n);return}throw new Error(n)}getAccessorUsage(e){const t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return"SPARSE";for(const s of this._doc.getGraph().listParentEdges(e)){const{usage:r}=s.getAttributes();if(r)return r;s.getParent().propertyType!=="Root"&&this.logger.warn(`Missing attribute ".usage" on edge, "${s.getName()}".`)}return"OTHER"}addAccessorToUsageGroup(e,t){const s=this._accessorUsageMap.get(e);if(s&&s!==t)throw new Error(`Accessor with usage "${s}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}},nr=class{multiple;basename;counter={};constructor(e,t){this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();if(this.multiple){const s=this.basename(e);return this.counter[s]=this.counter[s]||1,`${s}_${this.counter[s]++}.${t}`}else return`${this.basename(e)}.${t}`}};function $i(e,t){const s=e.getGraph().listParentEdges(t).find(r=>r.getParent()!==e.getRoot());return s?s.getName().replace(/texture$/i,""):""}const{BufferViewUsage:vt}=ke,{UNSIGNED_INT:Hi,UNSIGNED_SHORT:Ki,UNSIGNED_BYTE:qi}=N.ComponentType,Xi=new Set(["Accessor","Buffer","Material","Mesh"]);var Wi=class{static write(e,t){const s=e.getGraph(),r=e.getRoot(),n={asset:{generator:`glTF-Transform ${ln}`,...r.getAsset()},extras:{...r.getExtras()}},o={json:n,resources:{}},i=new ke(e,o,t),a=t.logger||Wt.DEFAULT_INSTANCE,c=new Set(t.extensions.map(p=>p.EXTENSION_NAME)),l=e.getRoot().listExtensionsUsed().filter(p=>c.has(p.extensionName)).sort((p,x)=>p.extensionName>x.extensionName?1:-1),u=e.getRoot().listExtensionsRequired().filter(p=>c.has(p.extensionName)).sort((p,x)=>p.extensionName>x.extensionName?1:-1);l.length<e.getRoot().listExtensionsUsed().length&&a.warn("Some extensions were not registered for I/O, and will not be written.");for(const p of l){const x=p.prewriteTypes.filter(d=>!Xi.has(d));x.length&&a.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${p.extensionName}, are unsupported. Please file an issue or a PR.`);for(const d of p.writeDependencies)p.install(d,t.dependencies[d])}function h(p,x,d,y){const m=[];let E=0;for(const I of p){const w=i.createAccessorDef(I);w.bufferView=n.bufferViews.length;const R=I.getArray(),v=C.pad(C.toView(R));w.byteOffset=E,E+=v.byteLength,m.push(v),i.accessorIndexMap.set(I,n.accessors.length),n.accessors.push(w)}const b={buffer:x,byteOffset:d,byteLength:C.concat(m).byteLength};return y&&(b.target=y),n.bufferViews.push(b),{buffers:m,byteLength:E}}function f(p,x,d){const y=p[0].getCount();let m=0;for(const R of p){const v=i.createAccessorDef(R);v.bufferView=n.bufferViews.length,v.byteOffset=m;const M=R.getElementSize(),U=R.getComponentSize();m+=C.padNumber(M*U),i.accessorIndexMap.set(R,n.accessors.length),n.accessors.push(v)}const E=y*m,b=new ArrayBuffer(E),I=new DataView(b);for(let R=0;R<y;R++){let v=0;for(const M of p){const U=M.getElementSize(),L=M.getComponentSize(),D=M.getComponentType(),S=M.getArray();for(let W=0;W<U;W++){const ne=R*m+v+W*L,Q=S[R*U+W];switch(D){case N.ComponentType.FLOAT:I.setFloat32(ne,Q,!0);break;case N.ComponentType.BYTE:I.setInt8(ne,Q);break;case N.ComponentType.SHORT:I.setInt16(ne,Q,!0);break;case N.ComponentType.UNSIGNED_BYTE:I.setUint8(ne,Q);break;case N.ComponentType.UNSIGNED_SHORT:I.setUint16(ne,Q,!0);break;case N.ComponentType.UNSIGNED_INT:I.setUint32(ne,Q,!0);break;case N.ComponentType.FLOAT16:I.setFloat16(ne,Q,!0);break;case N.ComponentType.FLOAT64:I.setFloat64(ne,Q,!0);break;default:throw new Error("Unexpected component type: "+D)}}v+=C.padNumber(U*L)}}const w={buffer:x,byteOffset:d,byteLength:E,byteStride:m,target:ke.BufferViewTarget.ARRAY_BUFFER};return n.bufferViews.push(w),{byteLength:E,buffers:[new Uint8Array(b)]}}function g(p,x,d){const y=[];let m=0;const E=new Map;let b=-1/0,I=!1;for(const D of p){const S=i.createAccessorDef(D);n.accessors.push(S),i.accessorIndexMap.set(D,n.accessors.length-1);const W=[],ne=[],Q=[],Tt=new Array(D.getElementSize()).fill(0);for(let Te=0,Et=D.getCount();Te<Et;Te++)if(D.getElement(Te,Q),!B.eq(Q,Tt,0)){b=Math.max(Te,b),W.push(Te);for(let Xe=0;Xe<Q.length;Xe++)ne.push(Q[Xe])}const qe=W.length,at={accessorDef:S,count:qe};if(E.set(D,at),qe===0)continue;qe>D.getCount()/2&&(I=!0);const xt=pt[D.getComponentType()];at.indices=W,at.values=new xt(ne)}if(!Number.isFinite(b))return{buffers:y,byteLength:m};I&&a.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");const w=b<255?Uint8Array:b<65535?Uint16Array:Uint32Array,R=b<255?qi:b<65535?Ki:Hi,v={buffer:x,byteOffset:d+m,byteLength:0};for(const D of p){const S=E.get(D);if(S.count===0)continue;S.indicesByteOffset=v.byteLength;const W=C.pad(C.toView(new w(S.indices)));y.push(W),m+=W.byteLength,v.byteLength+=W.byteLength}n.bufferViews.push(v);const M=n.bufferViews.length-1,U={buffer:x,byteOffset:d+m,byteLength:0};for(const D of p){const S=E.get(D);if(S.count===0)continue;S.valuesByteOffset=U.byteLength;const W=C.pad(C.toView(S.values));y.push(W),m+=W.byteLength,U.byteLength+=W.byteLength}n.bufferViews.push(U);const L=n.bufferViews.length-1;for(const D of p){const S=E.get(D);S.count!==0&&(S.accessorDef.sparse={count:S.count,indices:{bufferView:M,byteOffset:S.indicesByteOffset,componentType:R},values:{bufferView:L,byteOffset:S.valuesByteOffset}})}return{buffers:y,byteLength:m}}if(n.accessors=[],n.bufferViews=[],n.samplers=[],n.textures=[],n.images=r.listTextures().map((p,x)=>{const d=i.createPropertyDef(p);p.getMimeType()&&(d.mimeType=p.getMimeType());const y=p.getImage();return y&&i.createImageData(d,y,p),i.imageIndexMap.set(p,x),d}),l.filter(p=>p.prewriteTypes.includes("Accessor")).forEach(p=>p.prewrite(i,"Accessor")),r.listAccessors().forEach(p=>{const x=i.accessorUsageGroupedByParent,d=i.accessorParents;if(i.accessorIndexMap.has(p))return;const y=i.getAccessorUsage(p);if(i.addAccessorToUsageGroup(p,y),x.has(y)){const m=s.listParents(p).find(E=>E.propertyType!=="Root");d.set(p,m)}}),l.filter(p=>p.prewriteTypes.includes("Buffer")).forEach(p=>p.prewrite(i,"Buffer")),(r.listAccessors().length>0||i.otherBufferViews.size>0||r.listTextures().length>0&&t.format==="GLB")&&r.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");n.buffers=[],r.listBuffers().forEach((p,x)=>{const d=i.createPropertyDef(p),y=i.accessorUsageGroupedByParent,m=p.listParents().filter(M=>M instanceof N),E=new Set(m.map(M=>i.accessorParents.get(M))),b=new Map(Array.from(E).map((M,U)=>[M,U])),I={};for(const M of m){if(i.accessorIndexMap.has(M))continue;const U=i.getAccessorUsage(M);let L=U;if(y.has(U)){const D=i.accessorParents.get(M);L+=`:${b.get(D)}`}I[L]||={usage:U,accessors:[]},I[L].accessors.push(M)}const w=[],R=n.buffers.length;let v=0;for(const{usage:M,accessors:U}of Object.values(I))if(M===vt.ARRAY_BUFFER&&t.vertexLayout==="interleaved"){const L=f(U,R,v);v+=L.byteLength;for(const D of L.buffers)w.push(D)}else if(M===vt.ARRAY_BUFFER)for(const L of U){const D=f([L],R,v);v+=D.byteLength;for(const S of D.buffers)w.push(S)}else if(M===vt.SPARSE){const L=g(U,R,v);v+=L.byteLength;for(const D of L.buffers)w.push(D)}else if(M===vt.ELEMENT_ARRAY_BUFFER){const L=ke.BufferViewTarget.ELEMENT_ARRAY_BUFFER,D=h(U,R,v,L);v+=D.byteLength;for(const S of D.buffers)w.push(S)}else{const L=h(U,R,v);v+=L.byteLength;for(const D of L.buffers)w.push(D)}if(i.imageBufferViews.length&&x===0){for(let M=0;M<i.imageBufferViews.length;M++)if(n.bufferViews[n.images[M].bufferView].byteOffset=v,v+=i.imageBufferViews[M].byteLength,w.push(i.imageBufferViews[M]),v%8){const U=8-v%8;v+=U,w.push(new Uint8Array(U))}}if(i.otherBufferViews.has(p))for(const M of i.otherBufferViews.get(p))n.bufferViews.push({buffer:R,byteOffset:v,byteLength:M.byteLength}),i.otherBufferViewsIndexMap.set(M,n.bufferViews.length-1),v+=M.byteLength,w.push(M);if(v){let M;t.format==="GLB"?M=ze:(M=i.bufferURIGenerator.createURI(p,"bin"),d.uri=M),d.byteLength=v,i.assignResourceURI(M,C.concat(w),!0)}n.buffers.push(d),i.bufferIndexMap.set(p,x)}),r.listAccessors().find(p=>!p.getBuffer())&&a.warn("Skipped writing one or more Accessors: no Buffer assigned."),l.filter(p=>p.prewriteTypes.includes("Material")).forEach(p=>p.prewrite(i,"Material")),n.materials=r.listMaterials().map((p,x)=>{const d=i.createPropertyDef(p);if(p.getAlphaMode()!==nt.AlphaMode.OPAQUE&&(d.alphaMode=p.getAlphaMode()),p.getAlphaMode()===nt.AlphaMode.MASK&&(d.alphaCutoff=p.getAlphaCutoff()),p.getDoubleSided()&&(d.doubleSided=!0),d.pbrMetallicRoughness={},B.eq(p.getBaseColorFactor(),[1,1,1,1])||(d.pbrMetallicRoughness.baseColorFactor=p.getBaseColorFactor()),B.eq(p.getEmissiveFactor(),[0,0,0])||(d.emissiveFactor=p.getEmissiveFactor()),p.getRoughnessFactor()!==1&&(d.pbrMetallicRoughness.roughnessFactor=p.getRoughnessFactor()),p.getMetallicFactor()!==1&&(d.pbrMetallicRoughness.metallicFactor=p.getMetallicFactor()),p.getBaseColorTexture()){const y=p.getBaseColorTexture(),m=p.getBaseColorTextureInfo();d.pbrMetallicRoughness.baseColorTexture=i.createTextureInfoDef(y,m)}if(p.getEmissiveTexture()){const y=p.getEmissiveTexture(),m=p.getEmissiveTextureInfo();d.emissiveTexture=i.createTextureInfoDef(y,m)}if(p.getNormalTexture()){const y=p.getNormalTexture(),m=p.getNormalTextureInfo(),E=i.createTextureInfoDef(y,m);p.getNormalScale()!==1&&(E.scale=p.getNormalScale()),d.normalTexture=E}if(p.getOcclusionTexture()){const y=p.getOcclusionTexture(),m=p.getOcclusionTextureInfo(),E=i.createTextureInfoDef(y,m);p.getOcclusionStrength()!==1&&(E.strength=p.getOcclusionStrength()),d.occlusionTexture=E}if(p.getMetallicRoughnessTexture()){const y=p.getMetallicRoughnessTexture(),m=p.getMetallicRoughnessTextureInfo();d.pbrMetallicRoughness.metallicRoughnessTexture=i.createTextureInfoDef(y,m)}return i.materialIndexMap.set(p,x),d}),l.filter(p=>p.prewriteTypes.includes("Mesh")).forEach(p=>p.prewrite(i,"Mesh")),n.meshes=r.listMeshes().map((p,x)=>{const d=i.createPropertyDef(p);let y=null;return d.primitives=p.listPrimitives().map(m=>{const E={attributes:{}};E.mode=m.getMode();const b=m.getMaterial();b&&(E.material=i.materialIndexMap.get(b)),Object.keys(m.getExtras()).length&&(E.extras=m.getExtras());const I=m.getIndices();I&&(E.indices=i.accessorIndexMap.get(I));for(const w of m.listSemantics())E.attributes[w]=i.accessorIndexMap.get(m.getAttribute(w));for(const w of m.listTargets()){const R={};for(const v of w.listSemantics())R[v]=i.accessorIndexMap.get(w.getAttribute(v));E.targets=E.targets||[],E.targets.push(R)}return m.listTargets().length&&!y&&(y=m.listTargets().map(w=>w.getName())),E}),p.getWeights().length&&(d.weights=p.getWeights()),y&&(d.extras=d.extras||{},d.extras.targetNames=y),i.meshIndexMap.set(p,x),d}),n.cameras=r.listCameras().map((p,x)=>{const d=i.createPropertyDef(p);if(d.type=p.getType(),d.type===Yt.Type.PERSPECTIVE){d.perspective={znear:p.getZNear(),zfar:p.getZFar(),yfov:p.getYFov()};const y=p.getAspectRatio();y!==null&&(d.perspective.aspectRatio=y)}else d.orthographic={znear:p.getZNear(),zfar:p.getZFar(),xmag:p.getXMag(),ymag:p.getYMag()};return i.cameraIndexMap.set(p,x),d}),n.nodes=r.listNodes().map((p,x)=>{const d=i.createPropertyDef(p);return B.eq(p.getTranslation(),[0,0,0])||(d.translation=p.getTranslation()),B.eq(p.getRotation(),[0,0,0,1])||(d.rotation=p.getRotation()),B.eq(p.getScale(),[1,1,1])||(d.scale=p.getScale()),p.getWeights().length&&(d.weights=p.getWeights()),i.nodeIndexMap.set(p,x),d}),n.skins=r.listSkins().map((p,x)=>{const d=i.createPropertyDef(p),y=p.getInverseBindMatrices();y&&(d.inverseBindMatrices=i.accessorIndexMap.get(y));const m=p.getSkeleton();return m&&(d.skeleton=i.nodeIndexMap.get(m)),d.joints=p.listJoints().map(E=>i.nodeIndexMap.get(E)),i.skinIndexMap.set(p,x),d}),r.listNodes().forEach((p,x)=>{const d=n.nodes[x],y=p.getMesh();y&&(d.mesh=i.meshIndexMap.get(y));const m=p.getCamera();m&&(d.camera=i.cameraIndexMap.get(m));const E=p.getSkin();E&&(d.skin=i.skinIndexMap.get(E)),p.listChildren().length>0&&(d.children=p.listChildren().map(b=>i.nodeIndexMap.get(b)))}),n.animations=r.listAnimations().map((p,x)=>{const d=i.createPropertyDef(p),y=new Map;return d.samplers=p.listSamplers().map((m,E)=>{const b=i.createPropertyDef(m);return b.input=i.accessorIndexMap.get(m.getInput()),b.output=i.accessorIndexMap.get(m.getOutput()),b.interpolation=m.getInterpolation(),y.set(m,E),b}),d.channels=p.listChannels().map(m=>{const E=i.createPropertyDef(m);return E.sampler=y.get(m.getSampler()),E.target={node:i.nodeIndexMap.get(m.getTargetNode()),path:m.getTargetPath()},E}),i.animationIndexMap.set(p,x),d}),n.scenes=r.listScenes().map((p,x)=>{const d=i.createPropertyDef(p);return d.nodes=p.listChildren().map(y=>i.nodeIndexMap.get(y)),i.sceneIndexMap.set(p,x),d});const T=r.getDefaultScene();return T&&(n.scene=r.listScenes().indexOf(T)),n.extensionsUsed=l.map(p=>p.extensionName),n.extensionsRequired=u.map(p=>p.extensionName),l.forEach(p=>p.write(i)),Yi(n),o}};function Yi(e){const t=[];for(const s in e){const r=e[s];(Array.isArray(r)&&r.length===0||r===null||r===""||r&&typeof r=="object"&&Object.keys(r).length===0)&&t.push(s)}for(const s of t)delete e[s]}var Ji=class{_logger=Wt.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=!0;lastReadBytes=0;lastWriteBytes=0;setLogger(e){return this._logger=e,this}registerExtensions(e){for(const t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){const t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;const s=ir(t)?this._binaryToJSON(t):{json:JSON.parse(C.decodeText(t)),resources:{}};return await this._readResourcesExternal(s,this.dirname(e)),this._readResourcesInternal(s),s}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),ki.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){const t=this._binaryToJSON(C.assertView(e));this._readResourcesInternal(t);const s=t.json;if(s.buffers&&s.buffers.some(r=>Qi(t,r)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(s.images&&s.images.some(r=>Zi(t,r)))throw new Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(C.assertView(e)))}async writeJSON(e,t={}){if(t.format==="GLB"&&e.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Wi.write(e,{format:t.format||"GLTF",basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(e){const{json:t,resources:s}=await this.writeJSON(e,{format:"GLB"}),r=new Uint32Array([1179937895,2,12]),n=JSON.stringify(t),o=C.pad(C.encodeText(n),32),i=C.toView(new Uint32Array([o.byteLength,1313821514])),a=C.concat([i,o]);r[r.length-1]+=a.byteLength;const c=Object.values(s)[0];if(!c||!c.byteLength)return C.concat([C.toView(r),a]);const l=C.pad(c,0),u=C.toView(new Uint32Array([l.byteLength,5130562])),h=C.concat([u,l]);return r[r.length-1]+=h.byteLength,C.concat([C.toView(r),a,h])}async _readResourcesExternal(e,t){const s=e.json.images||[],r=e.json.buffers||[],n=[...s,...r].map(async o=>{const i=o.uri;if(!i||i.match(/data:/))return Promise.resolve();try{e.resources[i]=await this.readURI(this.resolve(t,i),"view"),this.lastReadBytes+=e.resources[i].byteLength}catch(a){if(!this._strictResources&&s.includes(o))this._logger.warn(`Failed to load image URI, "${i}". ${a}`),e.resources[i]=null;else throw a}});await Promise.all(n)}_readResourcesInternal(e){function t(s){if(s.uri){if(s.uri in e.resources){C.assertView(e.resources[s.uri]);return}if(s.uri.match(/data:/)){const r=`__${ji()}.${rt.extension(s.uri)}`;e.resources[r]=C.createBufferFromDataURI(s.uri),s.uri=r}}}(e.json.images||[]).forEach(s=>{if(s.bufferView===void 0&&s.uri===void 0)throw new Error("Missing resource URI or buffer view.");t(s)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){const{images:t,buffers:s}=e.json;return e={json:{...e.json},resources:{...e.resources}},t&&(e.json.images=t.map(r=>({...r}))),s&&(e.json.buffers=s.map(r=>({...r}))),e}_binaryToJSON(e){if(!ir(e))throw new Error("Invalid glTF 2.0 binary.");const t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==1313821514)throw new Error("Missing required GLB JSON chunk.");const s=20,r=t[0],n=C.decodeText(C.toView(e,s,r)),o=JSON.parse(n),i=s+r;if(e.byteLength<=i)return{json:o,resources:{}};const a=new Uint32Array(e.buffer,e.byteOffset+i,2);if(a[1]!==5130562)return{json:o,resources:{}};const c=a[0],l=C.toView(e,i+8,c);return{json:o,resources:{[ze]:l}}}};function Qi(e,t){return t.uri!==void 0&&!(t.uri in e.resources)}function Zi(e,t){return t.uri!==void 0&&!(t.uri in e.resources)&&t.bufferView===void 0}function ir(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;const t=new Uint32Array(e.buffer,e.byteOffset,3);return t[0]===1179937895&&t[1]===2}var eo=class extends Ji{_fetchConfig;constructor(e=ns.DEFAULT_INIT){super(),this._fetchConfig=e}async readURI(e,t){const s=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await s.arrayBuffer());case"text":return s.text()}}resolve(e,t){return ns.resolve(e,t)}dirname(e){return ns.dirname(e)}},is,or;function to(){if(or)return is;or=1;function e(t){for(var s=new Array(t),r=0;r<t;++r)s[r]=r;return s}return is=e,is}/*!
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/draco3d-DdFfLaRu.js","assets/_commonjsHelpers-D6-XlEtG.js","assets/index-D9shXtZ9.js","assets/index-nmcBqr7Y.js","assets/index-D_NuPfjr.js","assets/jsx-runtime-DPjLkJKQ.js","assets/index-CtzuWnCS.js","assets/index-CinJrH5C.js","assets/index-FUuS4qwW.js","assets/client-DNXj_opT.js","assets/index-CPiRKiDC.css"])))=>i.map(i=>d[i]);
2
+ import{a as A}from"./jsx-runtime-DPjLkJKQ.js";import{_ as ft,b3 as on,gu as oi,gv as ai,gw as ci,aZ as G,eo as Ls,ep as ht,er as O,et as F,a6 as st,iR as me,ev as Xt,r as ui,k$ as Bt,ex as Lt,ew as gt,eW as an,es as Es,bH as li}from"./index-D9shXtZ9.js";import{r as Y}from"./index-nmcBqr7Y.js";import"./index-CtzuWnCS.js";import{g as fi}from"./_commonjsHelpers-D6-XlEtG.js";import{invalidateCachedAsset as ss}from"./asset-loaders-bMb8Nvq8.js";function Vs(e){return e.id==="http"||e.id.startsWith("frame:")}var cn=class{_listeners={};addEventListener(e,t){const s=this._listeners;return s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t),this}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}return this}dispatchEvent(e){const t=this._listeners[e.type];if(t!==void 0){const s=t.slice(0);for(let r=0,n=s.length;r<n;r++)s[r].call(this,e)}return this}dispose(){for(const e in this._listeners)delete this._listeners[e]}},Je=class{_disposed=!1;_name;_parent;_child;_attributes;constructor(e,t,s,r={}){if(this._name=e,this._parent=t,this._child=s,this._attributes=r,!t.isOnGraph(s))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){this._disposed||(this._parent._destroyRef(this),this._disposed=!0)}isDisposed(){return this._disposed}},hi=class extends cn{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){const t=new Set;for(const s of this.listParentEdges(e))t.add(s.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){const t=new Set;for(const s of this.listChildEdges(e))t.add(s.getChild());return Array.from(t)}disconnectParents(e,t){for(const s of this.listParentEdges(e))(!t||t(s.getParent()))&&s.dispose();return this}_createEdge(e,t,s,r){const n=new Je(e,t,s,r);this._edges.add(n);const o=n.getParent();this._parentEdges.has(o)||this._parentEdges.set(o,new Set),this._parentEdges.get(o).add(n);const i=n.getChild();return this._childEdges.has(i)||this._childEdges.set(i,new Set),this._childEdges.get(i).add(n),n}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}},re=class{list=[];constructor(e){if(e)for(const t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){const t=this.list.indexOf(e);t>=0&&this.list.splice(t,1)}removeChild(e){const t=[];for(const s of this.list)s.getChild()===e&&t.push(s);for(const s of t)this.remove(s);return t}listRefsByChild(e){const t=[];for(const s of this.list)s.getChild()===e&&t.push(s);return t}values(){return this.list}},$=class{set=new Set;map=new Map;constructor(e){if(e)for(const t of e)this.add(t)}add(e){const t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){const t=this.map.get(e)||null;return t&&this.remove(t),t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}},J=class{map={};constructor(e){e&&Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}};const V=Symbol("attributes"),Le=Symbol("immutableKeys");var di=class un extends cn{_disposed=!1;graph;[V];[Le];constructor(t){super(),this.graph=t,this[Le]=new Set,this[V]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){const t=this.getDefaults(),s={};for(const r in t){const n=t[r];if(n instanceof un){const o=this.graph._createEdge(r,this,n);this[Le].add(r),s[r]=o}else s[r]=n}return s}isOnGraph(t){return this.graph===t.graph}isDisposed(){return this._disposed}dispose(){this._disposed||(this.graph.listChildEdges(this).forEach(t=>t.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"}))}detach(){return this.graph.disconnectParents(this),this}swap(t,s){for(const r in this[V]){const n=this[V][r];if(n instanceof Je){const o=n;o.getChild()===t&&this.setRef(r,s,o.getAttributes())}else if(n instanceof re)for(const o of n.listRefsByChild(t)){const i=o.getAttributes();this.removeRef(r,t),this.addRef(r,s,i)}else if(n instanceof $){const o=n.getRefByChild(t);if(o){const i=o.getAttributes();this.removeRef(r,t),this.addRef(r,s,i)}}else if(n instanceof J)for(const o of n.keys()){const i=n.get(o);i.getChild()===t&&this.setRefMap(r,o,s,i.getAttributes())}}return this}get(t){return this[V][t]}set(t,s){return this[V][t]=s,this.dispatchEvent({type:"change",attribute:t})}getRef(t){const s=this[V][t];return s?s.getChild():null}setRef(t,s,r){if(this[Le].has(t))throw new Error(`Cannot overwrite immutable attribute, "${t}".`);const n=this[V][t];if(n&&n.dispose(),!s)return this;const o=this.graph._createEdge(t,this,s,r);return this[V][t]=o,this.dispatchEvent({type:"change",attribute:t})}listRefs(t){return this.assertRefList(t).values().map(s=>s.getChild())}addRef(t,s,r){const n=this.graph._createEdge(t,this,s,r);return this.assertRefList(t).add(n),this.dispatchEvent({type:"change",attribute:t})}removeRef(t,s){const r=this.assertRefList(t);if(r instanceof re)for(const n of r.listRefsByChild(s))n.dispose();else{const n=r.getRefByChild(s);n&&n.dispose()}return this}assertRefList(t){const s=this[V][t];if(s instanceof re||s instanceof $)return s;throw new Error(`Expected RefList or RefSet for attribute "${t}"`)}listRefMapKeys(t){return this.assertRefMap(t).keys()}listRefMapValues(t){return this.assertRefMap(t).values().map(s=>s.getChild())}getRefMap(t,s){const r=this.assertRefMap(t).get(s);return r?r.getChild():null}setRefMap(t,s,r,n){const o=this.assertRefMap(t),i=o.get(s);if(i&&i.dispose(),!r)return this;n=Object.assign(n||{},{key:s});const a=this.graph._createEdge(t,this,r,{...n,key:s});return o.set(s,a),this.dispatchEvent({type:"change",attribute:t,key:s})}assertRefMap(t){const s=this[V][t];if(s instanceof J)return s;throw new Error(`Expected RefMap for attribute "${t}"`)}dispatchEvent(t){return super.dispatchEvent({...t,target:this}),this.graph.dispatchEvent({...t,target:this,type:`node:${t.type}`}),this}_destroyRef(t){const s=t.getName();if(this[V][s]===t)this[V][s]=null,this[Le].has(s)&&t.getChild().dispose();else if(this[V][s]instanceof re)this[V][s].remove(t);else if(this[V][s]instanceof $)this[V][s].remove(t);else if(this[V][s]instanceof J){const r=this[V][s];for(const n of r.keys())r.get(n)===t&&r.delete(n)}else return;this.graph._destroyEdge(t),this.dispatchEvent({type:"change",attribute:s})}};const ln="v4.5.0",ze="@glb.bin";let _=(function(e){return e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo",e})({}),gi=(function(e){return e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE",e})({}),de=(function(e){return e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A",e})({});var pi=class extends Float32Array{constructor(){throw super(),new Error("Unsupported typed array instantiation.")}};const pt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5131:typeof Float16Array<"u"?Float16Array:pi,5126:Float32Array,5130:Float64Array};var C=class{static createBufferFromDataURI(e){if(typeof Buffer>"u"){const t=atob(e.split(",")[1]),s=new Uint8Array(t.length);for(let r=0;r<t.length;r++)s[r]=t.charCodeAt(r);return s}else{const t=e.split(",")[1],s=e.indexOf("base64")>=0;return Buffer.from(t,s?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(const n of e)t+=n.byteLength;const s=new Uint8Array(t);let r=0;for(const n of e)s.set(n,r),r+=n.byteLength;return s}static pad(e,t=0){const s=this.padNumber(e.byteLength);if(s===e.byteLength)return e;const r=new Uint8Array(s);if(r.set(e),t!==0)for(let n=e.byteLength;n<s;n++)r[n]=t;return r}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let s=e.byteLength;for(;s--;)if(e[s]!==t[s])return!1;return!0}static toView(e,t=0,s=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,s))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw new Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}},mi=class{static hexToFactor(e,t){e=Math.floor(e);const s=t;return s[0]=(e>>16&255)/255,s[1]=(e>>8&255)/255,s[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){const t=[...e],[s,r,n]=this.convertLinearToSRGB(e,t);return s*255<<16^r*255<<8^n*255<<0}static convertSRGBToLinear(e,t){const s=e,r=t;for(let n=0;n<3;n++)r[n]=s[n]<.04045?s[n]*.0773993808:Math.pow(s[n]*.9478672986+.0521327014,2.4);return t}static convertLinearToSRGB(e,t){const s=e,r=t;for(let n=0;n<3;n++)r[n]=s[n]<.0031308?s[n]*12.92:1.055*Math.pow(s[n],.41666)-.055;return t}},yi=class{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),s,r;for(;t.byteLength;){if(s=t.getUint16(0,!1),xi(t,s),r=t.getUint8(s+1),r===192||r===193||r===194)return[t.getUint16(s+7,!1),t.getUint16(s+5,!1)];t=new DataView(e.buffer,t.byteOffset+s+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(e){return 3}},Ti=class fn{static PNG_FRIED_CHUNK_NAME="CgBI";match(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10}getSize(t){const s=new DataView(t.buffer,t.byteOffset);return C.decodeText(t.slice(12,16))===fn.PNG_FRIED_CHUNK_NAME?[s.getUint32(32,!1),s.getUint32(36,!1)]:[s.getUint32(16,!1),s.getUint32(20,!1)]}getChannels(t){return 4}},fe=class{static impls={"image/jpeg":new yi,"image/png":new Ti};static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(const t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){return this.impls[t]?this.impls[t].getSize(e):null}static getChannels(e,t){return this.impls[t]?this.impls[t].getChannels(e):null}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let s=0;const r=4,n=this.getSize(e,t);if(!n)return null;for(;n[0]>1||n[1]>1;)s+=n[0]*n[1]*r,n[0]=Math.max(Math.floor(n[0]/2),1),n[1]=Math.max(Math.floor(n[1]/2),1);return s+=4,s}static mimeTypeToExtension(e){return e==="image/jpeg"?"jpg":e.split("/").pop()}static extensionToMimeType(e){return e==="jpg"?"image/jpeg":e?`image/${e}`:""}};function xi(e,t){if(t>e.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(e.getUint8(t)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return e}var rt=class{static basename(e){const t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){const t=e.match(/data:(image\/\w+)/)[1];return fe.mimeTypeToExtension(t)}else{if(e.startsWith("data:model/gltf+json"))return"gltf";if(e.startsWith("data:model/gltf-binary"))return"glb";if(e.startsWith("data:application/"))return"bin"}return e.split(/[\\/]/).pop().split(/[.]/).pop()}},bs=typeof Float32Array<"u"?Float32Array:Array;function Ei(){var e=new bs(3);return bs!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function rs(e){var t=e[0],s=e[1],r=e[2];return Math.sqrt(t*t+s*s+r*r)}function bi(e,t,s){var r=t[0],n=t[1],o=t[2],i=s[3]*r+s[7]*n+s[11]*o+s[15];return i=i||1,e[0]=(s[0]*r+s[4]*n+s[8]*o+s[12])/i,e[1]=(s[1]*r+s[5]*n+s[9]*o+s[13])/i,e[2]=(s[2]*r+s[6]*n+s[10]*o+s[14])/i,e}(function(){var e=Ei();return function(t,s,r,n,o,i){var a,c;for(s||(s=3),r||(r=0),n?c=Math.min(n*s+r,t.length):c=t.length,a=r;a<c;a+=s)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],o(e,e,i),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();function hn(e){const t=dn(),s=e.propertyType==="Node"?[e]:e.listChildren();for(const r of s)r.traverse(n=>{const o=n.getMesh();if(!o)return;const i=_i(o,n.getWorldMatrix());i.min.every(isFinite)&&i.max.every(isFinite)&&(_s(i.min,t),_s(i.max,t))});return t}function _i(e,t){const s=dn();for(const r of e.listPrimitives()){const n=r.getAttribute("POSITION"),o=r.getIndices();if(!n)continue;let i=[0,0,0],a=[0,0,0];for(let c=0,l=o?o.getCount():n.getCount();c<l;c++){const u=o?o.getScalar(c):c;i=n.getElement(u,i),a=bi(a,i,t),_s(a,s)}}return s}function _s(e,t){for(let s=0;s<3;s++)t.min[s]=Math.min(e[s],t.min[s]),t.max[s]=Math.max(e[s],t.max[s])}function dn(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}const er="https://null.example";var ns=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substring(0,t+1)}static basename(e){return rt.basename(new URL(e,er).pathname)}static extension(e){return rt.extension(new URL(e,er).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;const s=e.split("/"),r=t.split("/");s.pop();for(let n=0;n<r.length;n++)r[n]!=="."&&(r[n]===".."?s.pop():s.push(r[n]));return s.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}};function tr(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ve(e){if(tr(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(tr(s)===!1||Object.hasOwn(s,"isPrototypeOf")===!1)}let Ii=(function(e){return e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG",e})({});var Wt=class gn{verbosity;static Verbosity=Ii;static DEFAULT_INSTANCE=new gn(1);constructor(t){this.verbosity=t}debug(t){this.verbosity<=0&&console.debug(t)}info(t){this.verbosity<=1&&console.info(t)}warn(t){this.verbosity<=2&&console.warn(t)}error(t){this.verbosity<=3&&console.error(t)}};function Ai(e){var t=e[0],s=e[1],r=e[2],n=e[3],o=e[4],i=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],f=e[11],g=e[12],T=e[13],p=e[14],x=e[15],d=t*i-s*o,y=t*a-r*o,m=s*a-r*i,E=l*T-u*g,b=l*p-h*g,I=u*p-h*T,w=t*I-s*b+r*E,R=o*I-i*b+a*E,v=l*m-u*y+h*d,M=g*m-T*y+p*d;return c*w-n*R+x*v-f*M}function vi(e,t,s){var r=t[0],n=t[1],o=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],h=t[8],f=t[9],g=t[10],T=t[11],p=t[12],x=t[13],d=t[14],y=t[15],m=s[0],E=s[1],b=s[2],I=s[3];return e[0]=m*r+E*a+b*h+I*p,e[1]=m*n+E*c+b*f+I*x,e[2]=m*o+E*l+b*g+I*d,e[3]=m*i+E*u+b*T+I*y,m=s[4],E=s[5],b=s[6],I=s[7],e[4]=m*r+E*a+b*h+I*p,e[5]=m*n+E*c+b*f+I*x,e[6]=m*o+E*l+b*g+I*d,e[7]=m*i+E*u+b*T+I*y,m=s[8],E=s[9],b=s[10],I=s[11],e[8]=m*r+E*a+b*h+I*p,e[9]=m*n+E*c+b*f+I*x,e[10]=m*o+E*l+b*g+I*d,e[11]=m*i+E*u+b*T+I*y,m=s[12],E=s[13],b=s[14],I=s[15],e[12]=m*r+E*a+b*h+I*p,e[13]=m*n+E*c+b*f+I*x,e[14]=m*o+E*l+b*g+I*d,e[15]=m*i+E*u+b*T+I*y,e}function Ri(e,t){var s=t[0],r=t[1],n=t[2],o=t[4],i=t[5],a=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(s*s+r*r+n*n),e[1]=Math.sqrt(o*o+i*i+a*a),e[2]=Math.sqrt(c*c+l*l+u*u),e}function wi(e,t){var s=new bs(3);Ri(s,t);var r=1/s[0],n=1/s[1],o=1/s[2],i=t[0]*r,a=t[1]*n,c=t[2]*o,l=t[4]*r,u=t[5]*n,h=t[6]*o,f=t[8]*r,g=t[9]*n,T=t[10]*o,p=i+u+T,x=0;return p>0?(x=Math.sqrt(p+1)*2,e[3]=.25*x,e[0]=(h-g)/x,e[1]=(f-c)/x,e[2]=(a-l)/x):i>u&&i>T?(x=Math.sqrt(1+i-u-T)*2,e[3]=(h-g)/x,e[0]=.25*x,e[1]=(a+l)/x,e[2]=(f+c)/x):u>T?(x=Math.sqrt(1+u-i-T)*2,e[3]=(f-c)/x,e[0]=(a+l)/x,e[1]=.25*x,e[2]=(h+g)/x):(x=Math.sqrt(1+T-i-u)*2,e[3]=(a-l)/x,e[0]=(f+c)/x,e[1]=(h+g)/x,e[2]=.25*x),e}var B=class lt{static identity(t){return t}static eq(t,s,r=1e-5){if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(Math.abs(t[n]-s[n])>r)return!1;return!0}static clamp(t,s,r){return t<s?s:t>r?r:t}static decodeNormalizedInt(t,s){switch(s){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(t,s){switch(s){case 5126:return t;case 5123:return Math.round(lt.clamp(t,0,1)*65535);case 5121:return Math.round(lt.clamp(t,0,1)*255);case 5122:return Math.round(lt.clamp(t,-1,1)*32767);case 5120:return Math.round(lt.clamp(t,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(t,s,r,n){let o=rs([t[0],t[1],t[2]]);const i=rs([t[4],t[5],t[6]]),a=rs([t[8],t[9],t[10]]);Ai(t)<0&&(o=-o),s[0]=t[12],s[1]=t[13],s[2]=t[14];const c=t.slice(),l=1/o,u=1/i,h=1/a;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=h,c[9]*=h,c[10]*=h,wi(r,c),n[0]=o,n[1]=i,n[2]=a}static compose(t,s,r,n){const o=n,i=s[0],a=s[1],c=s[2],l=s[3],u=i+i,h=a+a,f=c+c,g=i*u,T=i*h,p=i*f,x=a*h,d=a*f,y=c*f,m=l*u,E=l*h,b=l*f,I=r[0],w=r[1],R=r[2];return o[0]=(1-(x+y))*I,o[1]=(T+b)*I,o[2]=(p-E)*I,o[3]=0,o[4]=(T-b)*w,o[5]=(1-(g+y))*w,o[6]=(d+m)*w,o[7]=0,o[8]=(p+E)*R,o[9]=(d-m)*R,o[10]=(1-(g+x))*R,o[11]=0,o[12]=t[0],o[13]=t[1],o[14]=t[2],o[15]=1,o}};function Si(e,t){if(!!e!=!!t)return!1;const s=e.getChild(),r=t.getChild();return s===r||s.equals(r)}function Ni(e,t){if(!!e!=!!t)return!1;const s=e.values(),r=t.values();if(s.length!==r.length)return!1;for(let n=0;n<s.length;n++){const o=s[n],i=r[n];if(o.getChild()!==i.getChild()&&!o.getChild().equals(i.getChild()))return!1}return!0}function Mi(e,t){if(!!e!=!!t)return!1;const s=e.keys(),r=t.keys();if(s.length!==r.length)return!1;for(const n of s){const o=e.get(n),i=t.get(n);if(!!o!=!!i)return!1;const a=o.getChild(),c=i.getChild();if(a!==c&&!a.equals(c))return!1}return!0}function pn(e,t){if(e===t)return!0;if(!!e!=!!t||!e||!t||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function mn(e,t){if(e===t)return!0;if(!!e!=!!t)return!1;if(!Ve(e)||!Ve(t))return e===t;const s=e,r=t;let n=0,o=0,i;for(i in s)n++;for(i in r)o++;if(n!==o)return!1;for(i in s){const a=s[i],c=r[i];if(Vt(a)&&Vt(c)){if(!pn(a,c))return!1}else if(Ve(a)&&Ve(c)){if(!mn(a,c))return!1}else if(a!==c)return!1}return!0}function Vt(e){return Array.isArray(e)||ArrayBuffer.isView(e)}const Ci="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Oi=999,Di=6,sr=new Set,Pi=function(){let e="";for(let t=0;t<Di;t++)e+=Ci.charAt(Math.floor(Math.random()*42));return e},ji=function(){for(let e=0;e<Oi;e++){const t=Pi();if(!sr.has(t))return sr.add(t),t}return""},Ue=e=>e,Fi=new Set;var ks=class extends di{constructor(e,t=""){super(e),this[V].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){return Array.isArray(t)&&(t=t.slice()),super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){const e=this.constructor;return new e(this.graph).copy(this,Ue)}copy(e,t=Ue){for(const s in this[V]){const r=this[V][s];if(r instanceof Je)this[Le].has(s)||r.dispose();else if(r instanceof re||r instanceof $)for(const n of r.values())n.dispose();else if(r instanceof J)for(const n of r.values())n.dispose()}for(const s in e[V]){const r=this[V][s],n=e[V][s];if(n instanceof Je)this[Le].has(s)?r.getChild().copy(t(n.getChild()),t):this.setRef(s,t(n.getChild()),n.getAttributes());else if(n instanceof $||n instanceof re)for(const o of n.values())this.addRef(s,t(o.getChild()),o.getAttributes());else if(n instanceof J)for(const o of n.keys()){const i=n.get(o);this.setRefMap(s,o,t(i.getChild()),i.getAttributes())}else Ve(n)?this[V][s]=JSON.parse(JSON.stringify(n)):Array.isArray(n)||n instanceof ArrayBuffer||ArrayBuffer.isView(n)?this[V][s]=n.slice():this[V][s]=n}return this}equals(e,t=Fi){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(const s in this[V]){if(t.has(s))continue;const r=this[V][s],n=e[V][s];if(r instanceof Je||n instanceof Je){if(!Si(r,n))return!1}else if(r instanceof $||n instanceof $||r instanceof re||n instanceof re){if(!Ni(r,n))return!1}else if(r instanceof J||n instanceof J){if(!Mi(r,n))return!1}else if(Ve(r)||Ve(n)){if(!mn(r,n))return!1}else if(Vt(r)||Vt(n)){if(!pn(r,n))return!1}else if(r!==n)return!1}return!0}detach(){return this.graph.disconnectParents(this,e=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},ee=class extends ks{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new J})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){return t&&t._validateParent(this),this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}},N=class K extends ee{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor"}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K.Type.SCALAR,componentType:K.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(t){switch(t){case K.Type.SCALAR:return 1;case K.Type.VEC2:return 2;case K.Type.VEC3:return 3;case K.Type.VEC4:return 4;case K.Type.MAT2:return 4;case K.Type.MAT3:return 9;case K.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case K.ComponentType.BYTE:case K.ComponentType.UNSIGNED_BYTE:return 1;case K.ComponentType.SHORT:case K.ComponentType.UNSIGNED_SHORT:return 2;case K.ComponentType.UNSIGNED_INT:case K.ComponentType.FLOAT:return 4;case K.ComponentType.FLOAT16:return 2;case K.ComponentType.FLOAT64:return 8;default:throw new Error("Unexpected component type: "+t)}}getMinNormalized(t){const s=this.getNormalized(),r=this.getElementSize(),n=this.getComponentType();if(this.getMin(t),s)for(let o=0;o<r;o++)t[o]=B.decodeNormalizedInt(t[o],n);return t}getMin(t){const s=this.getArray(),r=this.getCount(),n=this.getElementSize();for(let o=0;o<n;o++)t[o]=1/0;for(let o=0;o<r*n;o+=n)for(let i=0;i<n;i++){const a=s[o+i];Number.isFinite(a)&&(t[i]=Math.min(t[i],a))}return t}getMaxNormalized(t){const s=this.getNormalized(),r=this.getElementSize(),n=this.getComponentType();if(this.getMax(t),s)for(let o=0;o<r;o++)t[o]=B.decodeNormalizedInt(t[o],n);return t}getMax(t){const s=this.get("array"),r=this.getCount(),n=this.getElementSize();for(let o=0;o<n;o++)t[o]=-1/0;for(let o=0;o<r*n;o+=n)for(let i=0;i<n;i++){const a=s[o+i];Number.isFinite(a)&&(t[i]=Math.max(t[i],a))}return t}getCount(){const t=this.get("array");return t?t.length/this.getElementSize():0}getType(){return this.get("type")}setType(t){return this.set("type",t)}getElementSize(){return K.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(t){return this.set("normalized",t)}getScalar(t){const s=this.getElementSize(),r=this.getComponentType(),n=this.getArray();return this.getNormalized()?B.decodeNormalizedInt(n[t*s],r):n[t*s]}setScalar(t,s){const r=this.getElementSize(),n=this.getComponentType(),o=this.getArray();return this.getNormalized()?o[t*r]=B.encodeNormalizedInt(s,n):o[t*r]=s,this}getElement(t,s){const r=this.getNormalized(),n=this.getElementSize(),o=this.getComponentType(),i=this.getArray();for(let a=0;a<n;a++)r?s[a]=B.decodeNormalizedInt(i[t*n+a],o):s[a]=i[t*n+a];return s}setElement(t,s){const r=this.getNormalized(),n=this.getElementSize(),o=this.getComponentType(),i=this.getArray();for(let a=0;a<n;a++)r?i[t*n+a]=B.encodeNormalizedInt(s[a],o):i[t*n+a]=s[a];return this}getSparse(){return this.get("sparse")}setSparse(t){return this.set("sparse",t)}getBuffer(){return this.getRef("buffer")}setBuffer(t){return this.setRef("buffer",t)}getArray(){return this.get("array")}setArray(t){return this.set("componentType",t?Ui(t):K.ComponentType.FLOAT),this.set("array",t),this}getByteLength(){const t=this.get("array");return t?t.byteLength:0}};function Ui(e){switch(e.constructor){case Float32Array:return N.ComponentType.FLOAT;case Uint32Array:return N.ComponentType.UNSIGNED_INT;case Uint16Array:return N.ComponentType.UNSIGNED_SHORT;case Uint8Array:return N.ComponentType.UNSIGNED_BYTE;case Int16Array:return N.ComponentType.SHORT;case Int8Array:return N.ComponentType.BYTE;case Float64Array:return N.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&e.constructor===Float16Array)return N.ComponentType.FLOAT16;throw new Error("Unknown accessor componentType.")}var yn=class extends ee{init(){this.propertyType="Animation"}getDefaults(){return Object.assign(super.getDefaults(),{channels:new $,samplers:new $})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}},mt=class extends ee{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel"}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}},zs=class Tn extends ee{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler"}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:Tn.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(t){return this.set("interpolation",t)}getInput(){return this.getRef("input")}setInput(t){return this.setRef("input",t,{usage:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(t){return this.setRef("output",t,{usage:"OTHER"})}},xn=class extends ee{init(){this.propertyType="Buffer"}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}},Yt=class En extends ee{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera"}getDefaults(){return Object.assign(super.getDefaults(),{type:En.Type.PERSPECTIVE,znear:.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(t){return this.set("type",t)}getZNear(){return this.get("znear")}setZNear(t){return this.set("znear",t)}getZFar(){return this.get("zfar")}setZFar(t){return this.set("zfar",t)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(t){return this.set("aspectRatio",t)}getYFov(){return this.get("yfov")}setYFov(t){return this.set("yfov",t)}getXMag(){return this.get("xmag")}setXMag(t){return this.set("xmag",t)}getYMag(){return this.get("ymag")}setYMag(t){return this.set("ymag",t)}},j=class extends ks{static EXTENSION_NAME;_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw new Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}},z=class Is extends ee{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo"}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:Is.WrapMode.REPEAT,wrapT:Is.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(t){return this.set("texCoord",t)}getMagFilter(){return this.get("magFilter")}setMagFilter(t){return this.set("magFilter",t)}getMinFilter(){return this.get("minFilter")}setMinFilter(t){return this.set("minFilter",t)}getWrapS(){return this.get("wrapS")}setWrapS(t){return this.set("wrapS",t)}getWrapT(){return this.get("wrapT")}setWrapT(t){return this.set("wrapT",t)}};const{R:_t,G:It,B:At,A:Bi}=de;var nt=class bn extends ee{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material"}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:bn.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new z(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new z(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new z(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new z(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new z(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(t){return this.set("doubleSided",t)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(t){const s=this.get("baseColorFactor").slice();return s[3]=t,this.set("baseColorFactor",s)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(t){return this.set("alphaMode",t)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(t){return this.set("alphaCutoff",t)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(t){return this.set("baseColorFactor",t)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(t){return this.setRef("baseColorTexture",t,{channels:_t|It|At|Bi,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(t){return this.set("emissiveFactor",t)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(t){return this.setRef("emissiveTexture",t,{channels:_t|It|At,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(t){return this.set("normalScale",t)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(t){return this.setRef("normalTexture",t,{channels:_t|It|At})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(t){return this.set("occlusionStrength",t)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(t){return this.setRef("occlusionTexture",t,{channels:_t})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(t){return this.set("roughnessFactor",t)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(t){return this.set("metallicFactor",t)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(t){return this.setRef("metallicRoughnessTexture",t,{channels:It|At})}},_n=class extends ee{init(){this.propertyType="Mesh"}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new $})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}},Gs=class extends ee{init(){this.propertyType="Node"}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new $})}copy(e,t=Ue){if(t===Ue)throw new Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return B.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){const t=this.get("translation").slice(),s=this.get("rotation").slice(),r=this.get("scale").slice();return B.decompose(e,t,s,r),this.set("translation",t).set("rotation",s).set("scale",r)}getWorldTranslation(){const e=[0,0,0];return B.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){const e=[0,0,0,1];return B.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){const e=[1,1,1];return B.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){const e=[];for(let r=this;r!=null;r=r.getParentNode())e.push(r);let t;const s=e.pop().getMatrix();for(;t=e.pop();)vi(s,s,t.getMatrix());return s}addChild(e){const t=e.getParentNode();t&&t.removeChild(e);for(const s of e.listParents())s.propertyType==="Scene"&&s.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(const e of this.listParents())if(e.propertyType==="Node")return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(const t of this.listChildren())t.traverse(e);return this}},q=class In extends ee{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive"}getDefaults(){return Object.assign(super.getDefaults(),{mode:In.Mode.TRIANGLES,material:null,indices:null,attributes:new J,targets:new $})}getIndices(){return this.getRef("indices")}setIndices(t){return this.setRef("indices",t,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(t){return this.getRefMap("attributes",t)}setAttribute(t,s){return this.setRefMap("attributes",t,s,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(t){return this.setRef("material",t)}getMode(){return this.get("mode")}setMode(t){return this.set("mode",t)}listTargets(){return this.listRefs("targets")}addTarget(t){return this.addRef("targets",t)}removeTarget(t){return this.removeRef("targets",t)}},An=class extends ks{init(){this.propertyType="PrimitiveTarget"}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new J})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},$s=class extends ee{init(){this.propertyType="Scene"}getDefaults(){return Object.assign(super.getDefaults(),{children:new $})}copy(e,t=Ue){if(t===Ue)throw new Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){const t=e.getParentNode();return t&&t.removeChild(e),this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(const t of this.listChildren())t.traverse(e);return this}},vn=class extends ee{init(){this.propertyType="Skin"}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new $})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:"INVERSE_BIND_MATRICES"})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}},Ge=class extends ee{init(){this.propertyType="Texture"}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||fe.extensionToMimeType(rt.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);const t=fe.extensionToMimeType(rt.extension(e));return t&&this.set("mimeType",t),this}getImage(){return this.get("image")}setImage(e){return this.set("image",C.assertView(e))}getSize(){const e=this.get("image");return e?fe.getSize(e,this.getMimeType()):null}},it=class extends ee{_extensions=new Set;init(){this.propertyType="Root"}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${ln}`,version:"2.0"},defaultScene:null,accessors:new $,animations:new $,buffers:new $,cameras:new $,materials:new $,meshes:new $,nodes:new $,scenes:new $,skins:new $,textures:new $})}constructor(e){super(e),e.addEventListener("node:create",t=>{this._addChildOfRoot(t.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(e,t=Ue){if(t===Ue)throw new Error("Root cannot be copied.");this.set("asset",{...e.get("asset")}),this.setName(e.getName()),this.setExtras({...e.getExtras()}),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(const s of e.listRefMapKeys("extensions")){const r=e.getExtension(s);this.setExtension(s,t(r))}return this}_addChildOfRoot(e){return e instanceof $s?this.addRef("scenes",e):e instanceof Gs?this.addRef("nodes",e):e instanceof Yt?this.addRef("cameras",e):e instanceof vn?this.addRef("skins",e):e instanceof _n?this.addRef("meshes",e):e instanceof nt?this.addRef("materials",e):e instanceof Ge?this.addRef("textures",e):e instanceof yn?this.addRef("animations",e):e instanceof N?this.addRef("accessors",e):e instanceof xn&&this.addRef("buffers",e),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter(e=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}},$e=class As{_graph=new hi;_root=new it(this._graph);_logger=Wt.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(t){return As._GRAPH_DOCUMENTS.get(t)||null}constructor(){As._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(t){return this._logger=t,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(t){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...t){const s=t.map(r=>r.name);for(const r of t)await r(this,{stack:s});return this}hasExtension(t){return this.getRoot().listExtensionsUsed().some(s=>s.extensionName===t)}createExtension(t){const s=t.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(r=>r.extensionName===s)||new t(this)}disposeExtension(t){const s=this.getRoot().listExtensionsUsed().find(r=>r.extensionName===t);s&&s.dispose()}createScene(t=""){return new $s(this._graph,t)}createNode(t=""){return new Gs(this._graph,t)}createCamera(t=""){return new Yt(this._graph,t)}createSkin(t=""){return new vn(this._graph,t)}createMesh(t=""){return new _n(this._graph,t)}createPrimitive(){return new q(this._graph)}createPrimitiveTarget(t=""){return new An(this._graph,t)}createMaterial(t=""){return new nt(this._graph,t)}createTexture(t=""){return new Ge(this._graph,t)}createAnimation(t=""){return new yn(this._graph,t)}createAnimationChannel(t=""){return new mt(this._graph,t)}createAnimationSampler(t=""){return new zs(this._graph,t)}createAccessor(t="",s=null){return s||(s=this.getRoot().listBuffers()[0]),new N(this._graph,t).setBuffer(s)}createBuffer(t=""){return new xn(this._graph,t)}},k=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=!1;properties=new Set;_listener;constructor(e){this.document=e,e.getRoot()._enableExtension(this),this._listener=s=>{const r=s,n=r.target;n instanceof j&&n.extensionName===this.extensionName&&(r.type==="node:create"&&this._addExtensionProperty(n),r.type==="node:dispose"&&this._removeExtensionProperty(n))};const t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);const e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(const t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}},Li=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(e){this.jsonDoc=e}setTextureInfo(e,t){this.textureInfos.set(e,t),t.texCoord!==void 0&&e.setTexCoord(t.texCoord),t.extras!==void 0&&e.setExtras(t.extras);const s=this.jsonDoc.json.textures[t.index];if(s.sampler===void 0)return;const r=this.jsonDoc.json.samplers[s.sampler];r.magFilter!==void 0&&e.setMagFilter(r.magFilter),r.minFilter!==void 0&&e.setMinFilter(r.minFilter),r.wrapS!==void 0&&e.setWrapS(r.wrapS),r.wrapT!==void 0&&e.setWrapT(r.wrapT)}};const rr={logger:Wt.DEFAULT_INSTANCE,extensions:[],dependencies:{}},Vi=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]);var ki=class{static read(e,t=rr){const s={...rr,...t},{json:r}=e,n=new $e().setLogger(s.logger);this.validate(e,s);const o=new Li(e),i=r.asset,a=n.getRoot().getAsset();i.copyright&&(a.copyright=i.copyright),i.extras&&(a.extras=i.extras),r.extras!==void 0&&n.getRoot().setExtras({...r.extras});const c=r.extensionsUsed||[],l=r.extensionsRequired||[];s.extensions.sort((d,y)=>d.EXTENSION_NAME>y.EXTENSION_NAME?1:-1);for(const d of s.extensions)if(c.includes(d.EXTENSION_NAME)){const y=n.createExtension(d).setRequired(l.includes(d.EXTENSION_NAME)),m=y.prereadTypes.filter(E=>!Vi.has(E));m.length&&s.logger.warn(`Preread hooks for some types (${m.join()}), requested by extension ${y.extensionName}, are unsupported. Please file an issue or a PR.`);for(const E of y.readDependencies)y.install(E,s.dependencies[E])}const u=r.buffers||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Buffer")).forEach(d=>d.preread(o,"Buffer")),o.buffers=u.map(d=>{const y=n.createBuffer(d.name);return d.extras&&y.setExtras(d.extras),d.uri&&d.uri.indexOf("__")!==0&&y.setURI(d.uri),y}),o.bufferViewBuffers=(r.bufferViews||[]).map((d,y)=>{if(!o.bufferViews[y]){const m=e.json.buffers[d.buffer],E=m.uri?e.resources[m.uri]:e.resources[ze],b=d.byteOffset||0;o.bufferViews[y]=C.toView(E,b,d.byteLength)}return o.buffers[d.buffer]});const h=r.accessors||[];o.accessors=h.map(d=>{const y=o.bufferViewBuffers[d.bufferView],m=n.createAccessor(d.name,y).setType(d.type);return d.extras&&m.setExtras(d.extras),d.normalized!==void 0&&m.setNormalized(d.normalized),d.bufferView===void 0||m.setArray(Ot(d,o)),m});const f=r.images||[],g=r.textures||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Texture")).forEach(d=>d.preread(o,"Texture")),o.textures=f.map(d=>{const y=n.createTexture(d.name);if(d.extras&&y.setExtras(d.extras),d.bufferView!==void 0){const m=r.bufferViews[d.bufferView],E=e.json.buffers[m.buffer],b=E.uri?e.resources[E.uri]:e.resources[ze],I=m.byteOffset||0,w=m.byteLength,R=b.slice(I,I+w);y.setImage(R)}else d.uri!==void 0&&(y.setImage(e.resources[d.uri]),d.uri.indexOf("__")!==0&&y.setURI(d.uri));if(d.mimeType!==void 0)y.setMimeType(d.mimeType);else if(d.uri){const m=rt.extension(d.uri);y.setMimeType(fe.extensionToMimeType(m))}return y}),n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Material")).forEach(d=>d.preread(o,"Material")),o.materials=(r.materials||[]).map(d=>{const y=n.createMaterial(d.name);d.extras&&y.setExtras(d.extras),d.alphaMode!==void 0&&y.setAlphaMode(d.alphaMode),d.alphaCutoff!==void 0&&y.setAlphaCutoff(d.alphaCutoff),d.doubleSided!==void 0&&y.setDoubleSided(d.doubleSided);const m=d.pbrMetallicRoughness||{};if(m.baseColorFactor!==void 0&&y.setBaseColorFactor(m.baseColorFactor),d.emissiveFactor!==void 0&&y.setEmissiveFactor(d.emissiveFactor),m.metallicFactor!==void 0&&y.setMetallicFactor(m.metallicFactor),m.roughnessFactor!==void 0&&y.setRoughnessFactor(m.roughnessFactor),m.baseColorTexture!==void 0){const E=m.baseColorTexture,b=o.textures[g[E.index].source];y.setBaseColorTexture(b),o.setTextureInfo(y.getBaseColorTextureInfo(),E)}if(d.emissiveTexture!==void 0){const E=d.emissiveTexture,b=o.textures[g[E.index].source];y.setEmissiveTexture(b),o.setTextureInfo(y.getEmissiveTextureInfo(),E)}if(d.normalTexture!==void 0){const E=d.normalTexture,b=o.textures[g[E.index].source];y.setNormalTexture(b),o.setTextureInfo(y.getNormalTextureInfo(),E),d.normalTexture.scale!==void 0&&y.setNormalScale(d.normalTexture.scale)}if(d.occlusionTexture!==void 0){const E=d.occlusionTexture,b=o.textures[g[E.index].source];y.setOcclusionTexture(b),o.setTextureInfo(y.getOcclusionTextureInfo(),E),d.occlusionTexture.strength!==void 0&&y.setOcclusionStrength(d.occlusionTexture.strength)}if(m.metallicRoughnessTexture!==void 0){const E=m.metallicRoughnessTexture,b=o.textures[g[E.index].source];y.setMetallicRoughnessTexture(b),o.setTextureInfo(y.getMetallicRoughnessTextureInfo(),E)}return y}),n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Mesh")).forEach(d=>d.preread(o,"Mesh"));const T=r.meshes||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Primitive")).forEach(d=>d.preread(o,"Primitive")),o.meshes=T.map(d=>{const y=n.createMesh(d.name);return d.extras&&y.setExtras(d.extras),d.weights!==void 0&&y.setWeights(d.weights),(d.primitives||[]).forEach(m=>{const E=n.createPrimitive();m.extras&&E.setExtras(m.extras),m.material!==void 0&&E.setMaterial(o.materials[m.material]),m.mode!==void 0&&E.setMode(m.mode);for(const[I,w]of Object.entries(m.attributes||{}))E.setAttribute(I,o.accessors[w]);m.indices!==void 0&&E.setIndices(o.accessors[m.indices]);const b=d.extras&&d.extras.targetNames||[];(m.targets||[]).forEach((I,w)=>{const R=b[w]||w.toString(),v=n.createPrimitiveTarget(R);for(const[M,U]of Object.entries(I))v.setAttribute(M,o.accessors[U]);E.addTarget(v)}),y.addPrimitive(E)}),y}),o.cameras=(r.cameras||[]).map(d=>{const y=n.createCamera(d.name).setType(d.type);if(d.extras&&y.setExtras(d.extras),d.type===Yt.Type.PERSPECTIVE){const m=d.perspective;y.setYFov(m.yfov),y.setZNear(m.znear),m.zfar!==void 0&&y.setZFar(m.zfar),m.aspectRatio!==void 0&&y.setAspectRatio(m.aspectRatio)}else{const m=d.orthographic;y.setZNear(m.znear).setZFar(m.zfar).setXMag(m.xmag).setYMag(m.ymag)}return y});const p=r.nodes||[];n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Node")).forEach(d=>d.preread(o,"Node")),o.nodes=p.map(d=>{const y=n.createNode(d.name);if(d.extras&&y.setExtras(d.extras),d.translation!==void 0&&y.setTranslation(d.translation),d.rotation!==void 0&&y.setRotation(d.rotation),d.scale!==void 0&&y.setScale(d.scale),d.matrix!==void 0){const m=[0,0,0],E=[0,0,0,1],b=[1,1,1];B.decompose(d.matrix,m,E,b),y.setTranslation(m),y.setRotation(E),y.setScale(b)}return d.weights!==void 0&&y.setWeights(d.weights),y}),o.skins=(r.skins||[]).map(d=>{const y=n.createSkin(d.name);d.extras&&y.setExtras(d.extras),d.inverseBindMatrices!==void 0&&y.setInverseBindMatrices(o.accessors[d.inverseBindMatrices]),d.skeleton!==void 0&&y.setSkeleton(o.nodes[d.skeleton]);for(const m of d.joints)y.addJoint(o.nodes[m]);return y}),p.map((d,y)=>{const m=o.nodes[y];(d.children||[]).forEach(E=>m.addChild(o.nodes[E])),d.mesh!==void 0&&m.setMesh(o.meshes[d.mesh]),d.camera!==void 0&&m.setCamera(o.cameras[d.camera]),d.skin!==void 0&&m.setSkin(o.skins[d.skin])}),o.animations=(r.animations||[]).map(d=>{const y=n.createAnimation(d.name);d.extras&&y.setExtras(d.extras);const m=(d.samplers||[]).map(E=>{const b=n.createAnimationSampler().setInput(o.accessors[E.input]).setOutput(o.accessors[E.output]).setInterpolation(E.interpolation||zs.Interpolation.LINEAR);return E.extras&&b.setExtras(E.extras),y.addSampler(b),b});return(d.channels||[]).forEach(E=>{const b=n.createAnimationChannel().setSampler(m[E.sampler]).setTargetPath(E.target.path);E.target.node!==void 0&&b.setTargetNode(o.nodes[E.target.node]),E.extras&&b.setExtras(E.extras),y.addChannel(b)}),y});const x=r.scenes||[];return n.getRoot().listExtensionsUsed().filter(d=>d.prereadTypes.includes("Scene")).forEach(d=>d.preread(o,"Scene")),o.scenes=x.map(d=>{const y=n.createScene(d.name);return d.extras&&y.setExtras(d.extras),(d.nodes||[]).map(m=>o.nodes[m]).forEach(m=>y.addChild(m)),y}),r.scene!==void 0&&n.getRoot().setDefaultScene(o.scenes[r.scene]),n.getRoot().listExtensionsUsed().forEach(d=>d.read(o)),h.forEach((d,y)=>{const m=o.accessors[y],E=!!d.sparse,b=!d.bufferView&&!m.getArray();(E||b)&&m.setSparse(!0).setArray(Gi(d,o))}),n}static validate(e,t){const s=e.json;if(s.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${s.asset.version}".`);if(s.extensionsRequired){for(const r of s.extensionsRequired)if(!t.extensions.find(n=>n.EXTENSION_NAME===r))throw new Error(`Missing required extension, "${r}".`)}if(s.extensionsUsed)for(const r of s.extensionsUsed)t.extensions.find(n=>n.EXTENSION_NAME===r)||t.logger.warn(`Missing optional extension, "${r}".`)}};function zi(e,t){const s=t.jsonDoc,r=t.bufferViews[e.bufferView],n=s.json.bufferViews[e.bufferView],o=pt[e.componentType],i=N.getElementSize(e.type),a=o.BYTES_PER_ELEMENT,c=e.byteOffset||0,l=new o(e.count*i),u=new DataView(r.buffer,r.byteOffset,r.byteLength),h=n.byteStride;for(let f=0;f<e.count;f++)for(let g=0;g<i;g++){const T=c+f*h+g*a;let p;switch(e.componentType){case N.ComponentType.FLOAT:p=u.getFloat32(T,!0);break;case N.ComponentType.UNSIGNED_INT:p=u.getUint32(T,!0);break;case N.ComponentType.UNSIGNED_SHORT:p=u.getUint16(T,!0);break;case N.ComponentType.UNSIGNED_BYTE:p=u.getUint8(T);break;case N.ComponentType.SHORT:p=u.getInt16(T,!0);break;case N.ComponentType.BYTE:p=u.getInt8(T);break;case N.ComponentType.FLOAT16:p=u.getFloat16(T,!0);break;case N.ComponentType.FLOAT64:p=u.getFloat64(T,!0);break;default:throw new Error(`Unexpected componentType "${e.componentType}".`)}l[f*i+g]=p}return l}function Ot(e,t){const s=t.jsonDoc,r=t.bufferViews[e.bufferView],n=s.json.bufferViews[e.bufferView],o=pt[e.componentType],i=N.getElementSize(e.type),a=o.BYTES_PER_ELEMENT,c=i*a;if(n.byteStride!==void 0&&n.byteStride!==c)return zi(e,t);const l=r.byteOffset+(e.byteOffset||0),u=e.count*i*a;return new o(r.buffer.slice(l,l+u))}function Gi(e,t){const s=pt[e.componentType],r=N.getElementSize(e.type);let n;e.bufferView!==void 0?n=Ot(e,t):n=new s(e.count*r);const o=e.sparse;if(!o)return n;const i=o.count,a={...e,...o.indices,count:i,type:"SCALAR"},c={...e,...o.values,count:i},l=Ot(a,t),u=Ot(c,t);for(let h=0;h<a.count;h++)for(let f=0;f<r;f++)n[l[h]*r+f]=u[h*r+f];return n}var Rn=(function(e){return e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e})(Rn||{}),ke=class{_doc;jsonDoc;options;static BufferViewTarget=Rn;static BufferViewUsage=gi;static USAGE_TO_TARGET={ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(e,t,s){this._doc=e,this.jsonDoc=t,this.options=s;const r=e.getRoot(),n=r.listBuffers().length,o=r.listTextures().length;this.bufferURIGenerator=new nr(n>1,()=>s.basename||"buffer"),this.imageURIGenerator=new nr(o>1,i=>$i(e,i)||s.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){const s={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},r=JSON.stringify(s);this.samplerDefIndexMap.has(r)||(this.samplerDefIndexMap.set(r,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(s));const n={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(r)},o=JSON.stringify(n);this.textureDefIndexMap.has(o)||(this.textureDefIndexMap.set(o,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(n));const i={index:this.textureDefIndexMap.get(o)};return t.getTexCoord()!==0&&(i.texCoord=t.getTexCoord()),Object.keys(t.getExtras()).length>0&&(i.extras=t.getExtras()),this.textureInfoDefMap.set(t,i),i}createPropertyDef(e){const t={};return e.getName()&&(t.name=e.getName()),Object.keys(e.getExtras()).length>0&&(t.extras=e.getExtras()),t}createAccessorDef(e){const t=this.createPropertyDef(e);return t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some(s=>s.getName()==="attributes"&&s.getAttributes().key==="POSITION"||s.getName()==="input")&&(t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround)),e.getNormalized()&&(t.normalized=e.getNormalized()),t}createImageData(e,t,s){if(this.options.format==="GLB")this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{const r=fe.mimeTypeToExtension(s.getMimeType());e.uri=this.imageURIGenerator.createURI(s,r),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,s){const r=this.jsonDoc.resources;if(!(e in r)){r[e]=t;return}if(t===r[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}const n=`Resource URI "${e}" already assigned to different data.`;if(!s){this.logger.warn(n);return}throw new Error(n)}getAccessorUsage(e){const t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return"SPARSE";for(const s of this._doc.getGraph().listParentEdges(e)){const{usage:r}=s.getAttributes();if(r)return r;s.getParent().propertyType!=="Root"&&this.logger.warn(`Missing attribute ".usage" on edge, "${s.getName()}".`)}return"OTHER"}addAccessorToUsageGroup(e,t){const s=this._accessorUsageMap.get(e);if(s&&s!==t)throw new Error(`Accessor with usage "${s}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}},nr=class{multiple;basename;counter={};constructor(e,t){this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();if(this.multiple){const s=this.basename(e);return this.counter[s]=this.counter[s]||1,`${s}_${this.counter[s]++}.${t}`}else return`${this.basename(e)}.${t}`}};function $i(e,t){const s=e.getGraph().listParentEdges(t).find(r=>r.getParent()!==e.getRoot());return s?s.getName().replace(/texture$/i,""):""}const{BufferViewUsage:vt}=ke,{UNSIGNED_INT:Hi,UNSIGNED_SHORT:Ki,UNSIGNED_BYTE:qi}=N.ComponentType,Xi=new Set(["Accessor","Buffer","Material","Mesh"]);var Wi=class{static write(e,t){const s=e.getGraph(),r=e.getRoot(),n={asset:{generator:`glTF-Transform ${ln}`,...r.getAsset()},extras:{...r.getExtras()}},o={json:n,resources:{}},i=new ke(e,o,t),a=t.logger||Wt.DEFAULT_INSTANCE,c=new Set(t.extensions.map(p=>p.EXTENSION_NAME)),l=e.getRoot().listExtensionsUsed().filter(p=>c.has(p.extensionName)).sort((p,x)=>p.extensionName>x.extensionName?1:-1),u=e.getRoot().listExtensionsRequired().filter(p=>c.has(p.extensionName)).sort((p,x)=>p.extensionName>x.extensionName?1:-1);l.length<e.getRoot().listExtensionsUsed().length&&a.warn("Some extensions were not registered for I/O, and will not be written.");for(const p of l){const x=p.prewriteTypes.filter(d=>!Xi.has(d));x.length&&a.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${p.extensionName}, are unsupported. Please file an issue or a PR.`);for(const d of p.writeDependencies)p.install(d,t.dependencies[d])}function h(p,x,d,y){const m=[];let E=0;for(const I of p){const w=i.createAccessorDef(I);w.bufferView=n.bufferViews.length;const R=I.getArray(),v=C.pad(C.toView(R));w.byteOffset=E,E+=v.byteLength,m.push(v),i.accessorIndexMap.set(I,n.accessors.length),n.accessors.push(w)}const b={buffer:x,byteOffset:d,byteLength:C.concat(m).byteLength};return y&&(b.target=y),n.bufferViews.push(b),{buffers:m,byteLength:E}}function f(p,x,d){const y=p[0].getCount();let m=0;for(const R of p){const v=i.createAccessorDef(R);v.bufferView=n.bufferViews.length,v.byteOffset=m;const M=R.getElementSize(),U=R.getComponentSize();m+=C.padNumber(M*U),i.accessorIndexMap.set(R,n.accessors.length),n.accessors.push(v)}const E=y*m,b=new ArrayBuffer(E),I=new DataView(b);for(let R=0;R<y;R++){let v=0;for(const M of p){const U=M.getElementSize(),L=M.getComponentSize(),D=M.getComponentType(),S=M.getArray();for(let W=0;W<U;W++){const ne=R*m+v+W*L,Q=S[R*U+W];switch(D){case N.ComponentType.FLOAT:I.setFloat32(ne,Q,!0);break;case N.ComponentType.BYTE:I.setInt8(ne,Q);break;case N.ComponentType.SHORT:I.setInt16(ne,Q,!0);break;case N.ComponentType.UNSIGNED_BYTE:I.setUint8(ne,Q);break;case N.ComponentType.UNSIGNED_SHORT:I.setUint16(ne,Q,!0);break;case N.ComponentType.UNSIGNED_INT:I.setUint32(ne,Q,!0);break;case N.ComponentType.FLOAT16:I.setFloat16(ne,Q,!0);break;case N.ComponentType.FLOAT64:I.setFloat64(ne,Q,!0);break;default:throw new Error("Unexpected component type: "+D)}}v+=C.padNumber(U*L)}}const w={buffer:x,byteOffset:d,byteLength:E,byteStride:m,target:ke.BufferViewTarget.ARRAY_BUFFER};return n.bufferViews.push(w),{byteLength:E,buffers:[new Uint8Array(b)]}}function g(p,x,d){const y=[];let m=0;const E=new Map;let b=-1/0,I=!1;for(const D of p){const S=i.createAccessorDef(D);n.accessors.push(S),i.accessorIndexMap.set(D,n.accessors.length-1);const W=[],ne=[],Q=[],Tt=new Array(D.getElementSize()).fill(0);for(let Te=0,Et=D.getCount();Te<Et;Te++)if(D.getElement(Te,Q),!B.eq(Q,Tt,0)){b=Math.max(Te,b),W.push(Te);for(let Xe=0;Xe<Q.length;Xe++)ne.push(Q[Xe])}const qe=W.length,at={accessorDef:S,count:qe};if(E.set(D,at),qe===0)continue;qe>D.getCount()/2&&(I=!0);const xt=pt[D.getComponentType()];at.indices=W,at.values=new xt(ne)}if(!Number.isFinite(b))return{buffers:y,byteLength:m};I&&a.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");const w=b<255?Uint8Array:b<65535?Uint16Array:Uint32Array,R=b<255?qi:b<65535?Ki:Hi,v={buffer:x,byteOffset:d+m,byteLength:0};for(const D of p){const S=E.get(D);if(S.count===0)continue;S.indicesByteOffset=v.byteLength;const W=C.pad(C.toView(new w(S.indices)));y.push(W),m+=W.byteLength,v.byteLength+=W.byteLength}n.bufferViews.push(v);const M=n.bufferViews.length-1,U={buffer:x,byteOffset:d+m,byteLength:0};for(const D of p){const S=E.get(D);if(S.count===0)continue;S.valuesByteOffset=U.byteLength;const W=C.pad(C.toView(S.values));y.push(W),m+=W.byteLength,U.byteLength+=W.byteLength}n.bufferViews.push(U);const L=n.bufferViews.length-1;for(const D of p){const S=E.get(D);S.count!==0&&(S.accessorDef.sparse={count:S.count,indices:{bufferView:M,byteOffset:S.indicesByteOffset,componentType:R},values:{bufferView:L,byteOffset:S.valuesByteOffset}})}return{buffers:y,byteLength:m}}if(n.accessors=[],n.bufferViews=[],n.samplers=[],n.textures=[],n.images=r.listTextures().map((p,x)=>{const d=i.createPropertyDef(p);p.getMimeType()&&(d.mimeType=p.getMimeType());const y=p.getImage();return y&&i.createImageData(d,y,p),i.imageIndexMap.set(p,x),d}),l.filter(p=>p.prewriteTypes.includes("Accessor")).forEach(p=>p.prewrite(i,"Accessor")),r.listAccessors().forEach(p=>{const x=i.accessorUsageGroupedByParent,d=i.accessorParents;if(i.accessorIndexMap.has(p))return;const y=i.getAccessorUsage(p);if(i.addAccessorToUsageGroup(p,y),x.has(y)){const m=s.listParents(p).find(E=>E.propertyType!=="Root");d.set(p,m)}}),l.filter(p=>p.prewriteTypes.includes("Buffer")).forEach(p=>p.prewrite(i,"Buffer")),(r.listAccessors().length>0||i.otherBufferViews.size>0||r.listTextures().length>0&&t.format==="GLB")&&r.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");n.buffers=[],r.listBuffers().forEach((p,x)=>{const d=i.createPropertyDef(p),y=i.accessorUsageGroupedByParent,m=p.listParents().filter(M=>M instanceof N),E=new Set(m.map(M=>i.accessorParents.get(M))),b=new Map(Array.from(E).map((M,U)=>[M,U])),I={};for(const M of m){if(i.accessorIndexMap.has(M))continue;const U=i.getAccessorUsage(M);let L=U;if(y.has(U)){const D=i.accessorParents.get(M);L+=`:${b.get(D)}`}I[L]||={usage:U,accessors:[]},I[L].accessors.push(M)}const w=[],R=n.buffers.length;let v=0;for(const{usage:M,accessors:U}of Object.values(I))if(M===vt.ARRAY_BUFFER&&t.vertexLayout==="interleaved"){const L=f(U,R,v);v+=L.byteLength;for(const D of L.buffers)w.push(D)}else if(M===vt.ARRAY_BUFFER)for(const L of U){const D=f([L],R,v);v+=D.byteLength;for(const S of D.buffers)w.push(S)}else if(M===vt.SPARSE){const L=g(U,R,v);v+=L.byteLength;for(const D of L.buffers)w.push(D)}else if(M===vt.ELEMENT_ARRAY_BUFFER){const L=ke.BufferViewTarget.ELEMENT_ARRAY_BUFFER,D=h(U,R,v,L);v+=D.byteLength;for(const S of D.buffers)w.push(S)}else{const L=h(U,R,v);v+=L.byteLength;for(const D of L.buffers)w.push(D)}if(i.imageBufferViews.length&&x===0){for(let M=0;M<i.imageBufferViews.length;M++)if(n.bufferViews[n.images[M].bufferView].byteOffset=v,v+=i.imageBufferViews[M].byteLength,w.push(i.imageBufferViews[M]),v%8){const U=8-v%8;v+=U,w.push(new Uint8Array(U))}}if(i.otherBufferViews.has(p))for(const M of i.otherBufferViews.get(p))n.bufferViews.push({buffer:R,byteOffset:v,byteLength:M.byteLength}),i.otherBufferViewsIndexMap.set(M,n.bufferViews.length-1),v+=M.byteLength,w.push(M);if(v){let M;t.format==="GLB"?M=ze:(M=i.bufferURIGenerator.createURI(p,"bin"),d.uri=M),d.byteLength=v,i.assignResourceURI(M,C.concat(w),!0)}n.buffers.push(d),i.bufferIndexMap.set(p,x)}),r.listAccessors().find(p=>!p.getBuffer())&&a.warn("Skipped writing one or more Accessors: no Buffer assigned."),l.filter(p=>p.prewriteTypes.includes("Material")).forEach(p=>p.prewrite(i,"Material")),n.materials=r.listMaterials().map((p,x)=>{const d=i.createPropertyDef(p);if(p.getAlphaMode()!==nt.AlphaMode.OPAQUE&&(d.alphaMode=p.getAlphaMode()),p.getAlphaMode()===nt.AlphaMode.MASK&&(d.alphaCutoff=p.getAlphaCutoff()),p.getDoubleSided()&&(d.doubleSided=!0),d.pbrMetallicRoughness={},B.eq(p.getBaseColorFactor(),[1,1,1,1])||(d.pbrMetallicRoughness.baseColorFactor=p.getBaseColorFactor()),B.eq(p.getEmissiveFactor(),[0,0,0])||(d.emissiveFactor=p.getEmissiveFactor()),p.getRoughnessFactor()!==1&&(d.pbrMetallicRoughness.roughnessFactor=p.getRoughnessFactor()),p.getMetallicFactor()!==1&&(d.pbrMetallicRoughness.metallicFactor=p.getMetallicFactor()),p.getBaseColorTexture()){const y=p.getBaseColorTexture(),m=p.getBaseColorTextureInfo();d.pbrMetallicRoughness.baseColorTexture=i.createTextureInfoDef(y,m)}if(p.getEmissiveTexture()){const y=p.getEmissiveTexture(),m=p.getEmissiveTextureInfo();d.emissiveTexture=i.createTextureInfoDef(y,m)}if(p.getNormalTexture()){const y=p.getNormalTexture(),m=p.getNormalTextureInfo(),E=i.createTextureInfoDef(y,m);p.getNormalScale()!==1&&(E.scale=p.getNormalScale()),d.normalTexture=E}if(p.getOcclusionTexture()){const y=p.getOcclusionTexture(),m=p.getOcclusionTextureInfo(),E=i.createTextureInfoDef(y,m);p.getOcclusionStrength()!==1&&(E.strength=p.getOcclusionStrength()),d.occlusionTexture=E}if(p.getMetallicRoughnessTexture()){const y=p.getMetallicRoughnessTexture(),m=p.getMetallicRoughnessTextureInfo();d.pbrMetallicRoughness.metallicRoughnessTexture=i.createTextureInfoDef(y,m)}return i.materialIndexMap.set(p,x),d}),l.filter(p=>p.prewriteTypes.includes("Mesh")).forEach(p=>p.prewrite(i,"Mesh")),n.meshes=r.listMeshes().map((p,x)=>{const d=i.createPropertyDef(p);let y=null;return d.primitives=p.listPrimitives().map(m=>{const E={attributes:{}};E.mode=m.getMode();const b=m.getMaterial();b&&(E.material=i.materialIndexMap.get(b)),Object.keys(m.getExtras()).length&&(E.extras=m.getExtras());const I=m.getIndices();I&&(E.indices=i.accessorIndexMap.get(I));for(const w of m.listSemantics())E.attributes[w]=i.accessorIndexMap.get(m.getAttribute(w));for(const w of m.listTargets()){const R={};for(const v of w.listSemantics())R[v]=i.accessorIndexMap.get(w.getAttribute(v));E.targets=E.targets||[],E.targets.push(R)}return m.listTargets().length&&!y&&(y=m.listTargets().map(w=>w.getName())),E}),p.getWeights().length&&(d.weights=p.getWeights()),y&&(d.extras=d.extras||{},d.extras.targetNames=y),i.meshIndexMap.set(p,x),d}),n.cameras=r.listCameras().map((p,x)=>{const d=i.createPropertyDef(p);if(d.type=p.getType(),d.type===Yt.Type.PERSPECTIVE){d.perspective={znear:p.getZNear(),zfar:p.getZFar(),yfov:p.getYFov()};const y=p.getAspectRatio();y!==null&&(d.perspective.aspectRatio=y)}else d.orthographic={znear:p.getZNear(),zfar:p.getZFar(),xmag:p.getXMag(),ymag:p.getYMag()};return i.cameraIndexMap.set(p,x),d}),n.nodes=r.listNodes().map((p,x)=>{const d=i.createPropertyDef(p);return B.eq(p.getTranslation(),[0,0,0])||(d.translation=p.getTranslation()),B.eq(p.getRotation(),[0,0,0,1])||(d.rotation=p.getRotation()),B.eq(p.getScale(),[1,1,1])||(d.scale=p.getScale()),p.getWeights().length&&(d.weights=p.getWeights()),i.nodeIndexMap.set(p,x),d}),n.skins=r.listSkins().map((p,x)=>{const d=i.createPropertyDef(p),y=p.getInverseBindMatrices();y&&(d.inverseBindMatrices=i.accessorIndexMap.get(y));const m=p.getSkeleton();return m&&(d.skeleton=i.nodeIndexMap.get(m)),d.joints=p.listJoints().map(E=>i.nodeIndexMap.get(E)),i.skinIndexMap.set(p,x),d}),r.listNodes().forEach((p,x)=>{const d=n.nodes[x],y=p.getMesh();y&&(d.mesh=i.meshIndexMap.get(y));const m=p.getCamera();m&&(d.camera=i.cameraIndexMap.get(m));const E=p.getSkin();E&&(d.skin=i.skinIndexMap.get(E)),p.listChildren().length>0&&(d.children=p.listChildren().map(b=>i.nodeIndexMap.get(b)))}),n.animations=r.listAnimations().map((p,x)=>{const d=i.createPropertyDef(p),y=new Map;return d.samplers=p.listSamplers().map((m,E)=>{const b=i.createPropertyDef(m);return b.input=i.accessorIndexMap.get(m.getInput()),b.output=i.accessorIndexMap.get(m.getOutput()),b.interpolation=m.getInterpolation(),y.set(m,E),b}),d.channels=p.listChannels().map(m=>{const E=i.createPropertyDef(m);return E.sampler=y.get(m.getSampler()),E.target={node:i.nodeIndexMap.get(m.getTargetNode()),path:m.getTargetPath()},E}),i.animationIndexMap.set(p,x),d}),n.scenes=r.listScenes().map((p,x)=>{const d=i.createPropertyDef(p);return d.nodes=p.listChildren().map(y=>i.nodeIndexMap.get(y)),i.sceneIndexMap.set(p,x),d});const T=r.getDefaultScene();return T&&(n.scene=r.listScenes().indexOf(T)),n.extensionsUsed=l.map(p=>p.extensionName),n.extensionsRequired=u.map(p=>p.extensionName),l.forEach(p=>p.write(i)),Yi(n),o}};function Yi(e){const t=[];for(const s in e){const r=e[s];(Array.isArray(r)&&r.length===0||r===null||r===""||r&&typeof r=="object"&&Object.keys(r).length===0)&&t.push(s)}for(const s of t)delete e[s]}var Ji=class{_logger=Wt.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=!0;lastReadBytes=0;lastWriteBytes=0;setLogger(e){return this._logger=e,this}registerExtensions(e){for(const t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){const t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;const s=ir(t)?this._binaryToJSON(t):{json:JSON.parse(C.decodeText(t)),resources:{}};return await this._readResourcesExternal(s,this.dirname(e)),this._readResourcesInternal(s),s}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),ki.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){const t=this._binaryToJSON(C.assertView(e));this._readResourcesInternal(t);const s=t.json;if(s.buffers&&s.buffers.some(r=>Qi(t,r)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(s.images&&s.images.some(r=>Zi(t,r)))throw new Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(C.assertView(e)))}async writeJSON(e,t={}){if(t.format==="GLB"&&e.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Wi.write(e,{format:t.format||"GLTF",basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(e){const{json:t,resources:s}=await this.writeJSON(e,{format:"GLB"}),r=new Uint32Array([1179937895,2,12]),n=JSON.stringify(t),o=C.pad(C.encodeText(n),32),i=C.toView(new Uint32Array([o.byteLength,1313821514])),a=C.concat([i,o]);r[r.length-1]+=a.byteLength;const c=Object.values(s)[0];if(!c||!c.byteLength)return C.concat([C.toView(r),a]);const l=C.pad(c,0),u=C.toView(new Uint32Array([l.byteLength,5130562])),h=C.concat([u,l]);return r[r.length-1]+=h.byteLength,C.concat([C.toView(r),a,h])}async _readResourcesExternal(e,t){const s=e.json.images||[],r=e.json.buffers||[],n=[...s,...r].map(async o=>{const i=o.uri;if(!i||i.match(/data:/))return Promise.resolve();try{e.resources[i]=await this.readURI(this.resolve(t,i),"view"),this.lastReadBytes+=e.resources[i].byteLength}catch(a){if(!this._strictResources&&s.includes(o))this._logger.warn(`Failed to load image URI, "${i}". ${a}`),e.resources[i]=null;else throw a}});await Promise.all(n)}_readResourcesInternal(e){function t(s){if(s.uri){if(s.uri in e.resources){C.assertView(e.resources[s.uri]);return}if(s.uri.match(/data:/)){const r=`__${ji()}.${rt.extension(s.uri)}`;e.resources[r]=C.createBufferFromDataURI(s.uri),s.uri=r}}}(e.json.images||[]).forEach(s=>{if(s.bufferView===void 0&&s.uri===void 0)throw new Error("Missing resource URI or buffer view.");t(s)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){const{images:t,buffers:s}=e.json;return e={json:{...e.json},resources:{...e.resources}},t&&(e.json.images=t.map(r=>({...r}))),s&&(e.json.buffers=s.map(r=>({...r}))),e}_binaryToJSON(e){if(!ir(e))throw new Error("Invalid glTF 2.0 binary.");const t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==1313821514)throw new Error("Missing required GLB JSON chunk.");const s=20,r=t[0],n=C.decodeText(C.toView(e,s,r)),o=JSON.parse(n),i=s+r;if(e.byteLength<=i)return{json:o,resources:{}};const a=new Uint32Array(e.buffer,e.byteOffset+i,2);if(a[1]!==5130562)return{json:o,resources:{}};const c=a[0],l=C.toView(e,i+8,c);return{json:o,resources:{[ze]:l}}}};function Qi(e,t){return t.uri!==void 0&&!(t.uri in e.resources)}function Zi(e,t){return t.uri!==void 0&&!(t.uri in e.resources)&&t.bufferView===void 0}function ir(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;const t=new Uint32Array(e.buffer,e.byteOffset,3);return t[0]===1179937895&&t[1]===2}var eo=class extends Ji{_fetchConfig;constructor(e=ns.DEFAULT_INIT){super(),this._fetchConfig=e}async readURI(e,t){const s=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await s.arrayBuffer());case"text":return s.text()}}resolve(e,t){return ns.resolve(e,t)}dirname(e){return ns.dirname(e)}},is,or;function to(){if(or)return is;or=1;function e(t){for(var s=new Array(t),r=0;r<t;++r)s[r]=r;return s}return is=e,is}/*!
3
3
  * Determine if an object is a Buffer
4
4
  *
5
5
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -19,5 +19,5 @@ import{a as A}from"./jsx-runtime-DPjLkJKQ.js";import{_ as ft,b3 as on,gu as oi,g
19
19
  `)+`
20
20
  ----------`);var g=new Function("compile",r.join(`
21
21
  `));return g(e.bind(void 0,s))}return fs=t,fs}var hs,hr;function uo(){if(hr)return hs;hr=1;var e=co();function t(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function s(r){var n=new t;n.pre=r.pre,n.body=r.body,n.post=r.post;var o=r.args.slice(0);n.argTypes=o;for(var i=0;i<o.length;++i){var a=o[i];if(a==="array"||typeof a=="object"&&a.blockIndices){if(n.argTypes[i]="array",n.arrayArgs.push(i),n.arrayBlockIndices.push(a.blockIndices?a.blockIndices:0),n.shimArgs.push("array"+i),i<n.pre.args.length&&n.pre.args[i].count>0)throw new Error("cwise: pre() block may not reference array args");if(i<n.post.args.length&&n.post.args[i].count>0)throw new Error("cwise: post() block may not reference array args")}else if(a==="scalar")n.scalarArgs.push(i),n.shimArgs.push("scalar"+i);else if(a==="index"){if(n.indexArgs.push(i),i<n.pre.args.length&&n.pre.args[i].count>0)throw new Error("cwise: pre() block may not reference array index");if(i<n.body.args.length&&n.body.args[i].lvalue)throw new Error("cwise: body() block may not write to array index");if(i<n.post.args.length&&n.post.args[i].count>0)throw new Error("cwise: post() block may not reference array index")}else if(a==="shape"){if(n.shapeArgs.push(i),i<n.pre.args.length&&n.pre.args[i].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(i<n.body.args.length&&n.body.args[i].lvalue)throw new Error("cwise: body() block may not write to array shape");if(i<n.post.args.length&&n.post.args[i].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof a=="object"&&a.offset)n.argTypes[i]="offset",n.offsetArgs.push({array:a.array,offset:a.offset}),n.offsetArgIndex.push(i);else throw new Error("cwise: Unknown argument type "+o[i])}if(n.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(n.pre.args.length>o.length)throw new Error("cwise: Too many arguments in pre() block");if(n.body.args.length>o.length)throw new Error("cwise: Too many arguments in body() block");if(n.post.args.length>o.length)throw new Error("cwise: Too many arguments in post() block");return n.debug=!!r.printCode||!!r.debug,n.funcName=r.funcName||"cwise",n.blockSize=r.blockSize||64,e(n)}return hs=s,hs}var dr;function lo(){return dr||(dr=1,(function(e){var t=uo(),s={body:"",args:[],thisVars:[],localVars:[]};function r(f){if(!f)return s;for(var g=0;g<f.args.length;++g){var T=f.args[g];g===0?f.args[g]={name:T,lvalue:!0,rvalue:!!f.rvalue,count:f.count||1}:f.args[g]={name:T,lvalue:!1,rvalue:!0,count:1}}return f.thisVars||(f.thisVars=[]),f.localVars||(f.localVars=[]),f}function n(f){return t({args:f.args,pre:r(f.pre),body:r(f.body),post:r(f.proc),funcName:f.funcName})}function o(f){for(var g=[],T=0;T<f.args.length;++T)g.push("a"+T);var p=new Function("P",["return function ",f.funcName,"_ndarrayops(",g.join(","),") {P(",g.join(","),");return a0}"].join(""));return p(n(f))}var i={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var f in i){var g=i[f];e[f]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+g+"=b"},funcName:f+"eq"}),e[f+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+g+"=s"},funcName:f+"seq"})}})();var a={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var f in a){var g=a[f];e[f]=o({args:["array","array"],body:{args:["a","b"],body:"a="+g+"b"},funcName:f}),e[f+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+g+"a"},funcName:f+"eq"})}})();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var f in c){var g=c[f];e[f]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:f}),e[f+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:f+"s"}),e[f+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+g+"b"},funcName:f+"eq"}),e[f+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+g+"s"},funcName:f+"seq"})}})();var l=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var f=0;f<l.length;++f){var g=l[f];e[g]=o({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:g}),e[g+"eq"]=o({args:["array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},funcName:g+"eq"})}})();var u=["max","min","atan2","pow"];(function(){for(var f=0;f<u.length;++f){var g=u[f];e[g]=o({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g}),e[g+"s"]=o({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g+"s"}),e[g+"eq"]=o({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},funcName:g+"eq"}),e[g+"seq"]=o({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},funcName:g+"seq"})}})();var h=["atan2","pow"];(function(){for(var f=0;f<h.length;++f){var g=h[f];e[g+"op"]=o({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"op"}),e[g+"ops"]=o({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"ops"}),e[g+"opeq"]=o({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},funcName:g+"opeq"}),e[g+"opseq"]=o({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},funcName:g+"opseq"})}})(),e.any=t({args:["array"],pre:s,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),e.all=t({args:["array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),e.sum=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),e.prod=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),e.norm2squared=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),e.norm2=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),e.norminf=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),e.norm1=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),e.sup=t({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.inf=t({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.argmin=t({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.argmax=t({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),e.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),e.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),e.equals=t({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})})(cs)),cs}lo();function fo(e,t){if(!(e instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");const s=new Blob([e],{type:t});return createImageBitmap(s,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(r=>{const n=new OffscreenCanvas(r.width,r.height).getContext("2d");n.drawImage(r,0,0);const o=n.getImageData(0,0,r.width,r.height);return io(new Uint8Array(o.data),[r.width,r.height,4],[4,4*r.width,1],0)})}async function ho(e,t){return fo(e,t)}const wn=0,go=0,po=0,mo=2,yo=0,Sn=163,Nn=166,To=0,xo=2,Eo=1,bo=64,Hs=0,_o=123,Io=1000066e3;function Ao(){return{vkFormat:Hs,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:wn,levels:[],dataFormatDescriptor:[{vendorId:po,descriptorType:go,versionNumber:mo,colorModel:yo,colorPrimaries:Eo,transferFunction:xo,flags:To,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class ct{constructor(t,s,r,n){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(t.buffer,t.byteOffset+s,r),this._littleEndian=n,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian),s=this._dataView.getUint32(this._offset+4,this._littleEndian),r=t+2**32*s;return this._offset+=8,r}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint8Array(t){const s=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,t);return this._offset+=t,s}_skip(t){return this._offset+=t,this}_scan(t,s=0){const r=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==s&&n<t;)n++,this._offset++;return n<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,n)}}const Z=[171,75,84,88,32,50,48,187,13,10,26,10];function gr(e){return new TextDecoder().decode(e)}function Dt(e){const t=new Uint8Array(e.buffer,e.byteOffset,Z.length);if(t[0]!==Z[0]||t[1]!==Z[1]||t[2]!==Z[2]||t[3]!==Z[3]||t[4]!==Z[4]||t[5]!==Z[5]||t[6]!==Z[6]||t[7]!==Z[7]||t[8]!==Z[8]||t[9]!==Z[9]||t[10]!==Z[10]||t[11]!==Z[11])throw new Error("Missing KTX 2.0 identifier.");const s=Ao(),r=17*Uint32Array.BYTES_PER_ELEMENT,n=new ct(e,Z.length,r,!0);s.vkFormat=n._nextUint32(),s.typeSize=n._nextUint32(),s.pixelWidth=n._nextUint32(),s.pixelHeight=n._nextUint32(),s.pixelDepth=n._nextUint32(),s.layerCount=n._nextUint32(),s.faceCount=n._nextUint32(),s.levelCount=n._nextUint32(),s.supercompressionScheme=n._nextUint32();const o=n._nextUint32(),i=n._nextUint32(),a=n._nextUint32(),c=n._nextUint32(),l=n._nextUint64(),u=n._nextUint64(),h=Math.max(s.levelCount,1)*3*8,f=new ct(e,Z.length+r,h,!0);for(let te=0,ie=Math.max(s.levelCount,1);te<ie;te++)s.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});const g=new ct(e,o,i,!0);g._skip(4);const T=g._nextUint16(),p=g._nextUint16(),x=g._nextUint16(),d=g._nextUint16(),y=g._nextUint8(),m=g._nextUint8(),E=g._nextUint8(),b=g._nextUint8(),I=[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],w=[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],v={vendorId:T,descriptorType:p,versionNumber:x,colorModel:y,colorPrimaries:m,transferFunction:E,flags:b,texelBlockDimension:I,bytesPlane:w,samples:[]},L=(d/4-6)/4;for(let te=0;te<L;te++){const ie={bitOffset:g._nextUint16(),bitLength:g._nextUint8(),channelType:g._nextUint8(),samplePosition:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};ie.channelType&bo?(ie.sampleLower=g._nextInt32(),ie.sampleUpper=g._nextInt32()):(ie.sampleLower=g._nextUint32(),ie.sampleUpper=g._nextUint32()),v.samples[te]=ie}s.dataFormatDescriptor.length=0,s.dataFormatDescriptor.push(v);const D=new ct(e,a,c,!0);for(;D._offset<c;){const te=D._nextUint32(),ie=D._scan(te),bt=gr(ie);if(s.keyValue[bt]=D._nextUint8Array(te-ie.byteLength-1),bt.match(/^ktx/i)){const Zs=gr(s.keyValue[bt]);s.keyValue[bt]=Zs.substring(0,Zs.lastIndexOf("\0"))}const ii=te%4?4-te%4:0;D._skip(ii)}if(u<=0)return s;const S=new ct(e,l,u,!0),W=S._nextUint16(),ne=S._nextUint16(),Q=S._nextUint32(),Tt=S._nextUint32(),qe=S._nextUint32(),at=S._nextUint32(),xt=[];for(let te=0,ie=Math.max(s.levelCount,1);te<ie;te++)xt.push({imageFlags:S._nextUint32(),rgbSliceByteOffset:S._nextUint32(),rgbSliceByteLength:S._nextUint32(),alphaSliceByteOffset:S._nextUint32(),alphaSliceByteLength:S._nextUint32()});const Te=l+S._offset,Et=Te+Q,Xe=Et+Tt,ei=Xe+qe,ti=new Uint8Array(e.buffer,e.byteOffset+Te,Q),si=new Uint8Array(e.buffer,e.byteOffset+Et,Tt),ri=new Uint8Array(e.buffer,e.byteOffset+Xe,qe),ni=new Uint8Array(e.buffer,e.byteOffset+ei,at);return s.globalData={endpointCount:W,selectorCount:ne,imageDescs:xt,endpointsData:ti,selectorsData:si,tablesData:ri,extendedData:ni},s}const xe="EXT_mesh_gpu_instancing",ye="EXT_mesh_features",se="EXT_meshopt_compression",P="EXT_structural_metadata",Rt="EXT_texture_webp",wt="EXT_texture_avif",vo="KHR_accessor_float16",Ro="KHR_accessor_float64",H="KHR_draco_mesh_compression",ge="KHR_lights_punctual",Ee="KHR_materials_anisotropy",be="KHR_materials_clearcoat",_e="KHR_materials_diffuse_transmission",Ie="KHR_materials_dispersion",Ae="KHR_materials_emissive_strength",ve="KHR_materials_ior",Re="KHR_materials_iridescence",we="KHR_materials_pbrSpecularGlossiness",Se="KHR_materials_sheen",Ne="KHR_materials_specular",Me="KHR_materials_transmission",Qe="KHR_materials_unlit",Ce="KHR_materials_volume",oe="KHR_materials_variants",pr="KHR_mesh_primitive_restart",mr="KHR_mesh_quantization",Oe="KHR_node_visibility",St="KHR_texture_basisu",De="KHR_texture_transform",le="KHR_xmp_json_ld";var wo=class extends j{static EXTENSION_NAME=ye;init(){this.extensionName=ye,this.propertyType="FeatureID",this.parentTypes=["Features"]}getDefaults(){return Object.assign(super.getDefaults(),{nullFeatureId:null,label:"",attribute:null,texture:null,propertyTable:null})}getFeatureCount(){return this.get("featureCount")}setFeatureCount(e){return this.set("featureCount",e)}getNullFeatureID(){return this.get("nullFeatureId")}setNullFeatureID(e){return this.set("nullFeatureId",e)}getLabel(){return this.get("label")}setLabel(e){return this.set("label",e)}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getPropertyTable(){return this.getRef("propertyTable")}setPropertyTable(e){return this.setRef("propertyTable",e)}},So=class extends j{static EXTENSION_NAME=ye;init(){this.extensionName=ye,this.propertyType="FeatureIDTexture",this.parentTypes=["FeatureID"]}getDefaults(){const e=new z(this.graph,"textureInfo");return e.setMinFilter(z.MagFilter.NEAREST),e.setMagFilter(z.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}},No=class extends j{static EXTENSION_NAME=ye;init(){this.extensionName=ye,this.propertyType="Features",this.parentTypes=[_.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{featureIds:new $([])})}listFeatureIDs(){return this.listRefs("featureIds")}addFeatureID(e){return this.addRef("featureIds",e)}removeFeatureID(e){return this.removeRef("featureIds",e)}};const ut=ye;var Mo=class extends k{extensionName=ye;static EXTENSION_NAME=ye;createFeatures(){return new No(this.document.getGraph())}createFeatureID(){return new wo(this.document.getGraph())}createFeatureIDTexture(){return new So(this.document.getGraph())}read(e){return(e.jsonDoc.json.meshes||[]).forEach((t,s)=>{(t.primitives||[]).forEach((r,n)=>{this._readPrimitive(e,s,r,n)})}),this}_readPrimitive(e,t,s,r){if(!s.extensions||!s.extensions[ut])return;const n=this.createFeatures(),o=s.extensions[ut];for(const i of o.featureIds){const a=Co(this.document,this,e,i);n.addFeatureID(a)}e.meshes[t].listPrimitives()[r].setExtension(ut,n)}write(e){const t=e.jsonDoc.json.meshes;if(!t)return this;for(const s of this.document.getRoot().listMeshes()){const r=t[e.meshIndexMap.get(s)];s.listPrimitives().forEach((n,o)=>{const i=r.primitives[o];this._writePrimitive(e,n,i)})}return this}_writePrimitive(e,t,s){const r=t.getExtension(ut);if(!r)return;const n={featureIds:[]};r.listFeatureIDs().forEach(o=>{n.featureIds.push(Do(this.document,e,o))}),s.extensions=s.extensions||{},s.extensions[ut]=n}};function Co(e,t,s,r){const n=t.createFeatureID().setFeatureCount(r.featureCount);r.nullFeatureId!==void 0&&n.setNullFeatureID(r.nullFeatureId),r.label!==void 0&&n.setLabel(r.label),r.attribute!==void 0&&n.setAttribute(r.attribute);const o=r.texture;if(o!==void 0){const i=Oo(t,s,o);n.setTexture(i)}if(r.propertyTable!==void 0){const i=e.getRoot().getExtension(P).listPropertyTables();n.setPropertyTable(i[r.propertyTable])}return n}function Oo(e,t,s){const r=e.createFeatureIDTexture(),{json:n}=t.jsonDoc;if(s.channels&&r.setChannels(s.channels),s.index!==void 0){const o=n.textures[s.index].source;r.setTexture(t.textures[o]),t.setTextureInfo(r.getTextureInfo(),s)}return r}function Do(e,t,s){const r=e.getRoot(),n={featureCount:s.getFeatureCount()};if(s.getNullFeatureID()!=null&&(n.nullFeatureId=s.getNullFeatureID()),s.getLabel()&&(n.label=s.getLabel()),s.getAttribute()!=null&&(n.attribute=s.getAttribute()),s.getTexture()){const o=s.getTexture(),i=o.getTexture(),a=o.getTextureInfo();n.texture=t.createTextureInfoDef(i,a);const c=o.getChannels();B.eq(c,[0])||(n.texture.channels=c)}if(s.getPropertyTable()){const o=r.getExtension(P),i=s.getPropertyTable();n.propertyTable=o.listPropertyTables().indexOf(i)}return n}const vs="INSTANCE_ATTRIBUTE";var Po=class extends j{static EXTENSION_NAME=xe;init(){this.extensionName=xe,this.propertyType="InstancedMesh",this.parentTypes=[_.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new J})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:vs})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},jo=class extends k{static EXTENSION_NAME=xe;extensionName=xe;prewriteTypes=[_.ACCESSOR];createInstancedMesh(){return new Po(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,s)=>{if(!t.extensions||!t.extensions.EXT_mesh_gpu_instancing)return;const r=t.extensions[xe],n=this.createInstancedMesh();for(const o in r.attributes)n.setAttribute(o,e.accessors[r.attributes[o]]);e.nodes[s].setExtension(xe,n)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(vs);for(const t of this.properties)for(const s of t.listAttributes())e.addAccessorToUsageGroup(s,vs);return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listNodes().forEach(s=>{const r=s.getExtension(xe);if(r){const n=e.nodeIndexMap.get(s),o=t.json.nodes[n],i={attributes:{}};r.listSemantics().forEach(a=>{const c=r.getAttribute(a);i.attributes[a]=e.accessorIndexMap.get(c)}),o.extensions=o.extensions||{},o.extensions[xe]=i}}),this}};let Fo=(function(e){return e.QUANTIZE="quantize",e.FILTER="filter",e})({});function Uo(e){return!e.extensions||!e.extensions.EXT_meshopt_compression?!1:!!e.extensions[se].fallback}const{BYTE:Bo,SHORT:yr,FLOAT:Lo}=N.ComponentType,{encodeNormalizedInt:Tr,decodeNormalizedInt:Rs}=B;function Vo(e,t,s,r){const{filter:n,bits:o}=r,i={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(s!=="ATTRIBUTES")return i;if(n!=="NONE"){let a=e.getNormalized()?ko(e):new Float32Array(i.array);switch(n){case"EXPONENTIAL":i.byteStride=e.getElementSize()*4,i.componentType=Lo,i.normalized=!1,i.array=t.encodeFilterExp(a,e.getCount(),i.byteStride,o);break;case"OCTAHEDRAL":i.byteStride=o>8?8:4,i.componentType=o>8?yr:Bo,i.normalized=!0,a=e.getElementSize()===3?Go(a):a,i.array=t.encodeFilterOct(a,e.getCount(),i.byteStride,o);break;case"QUATERNION":i.byteStride=8,i.componentType=yr,i.normalized=!0,i.array=t.encodeFilterQuat(a,e.getCount(),i.byteStride,o);break;default:throw new Error("Invalid filter.")}i.min=e.getMin([]),i.max=e.getMax([]),e.getNormalized()&&(i.min=i.min.map(c=>Rs(c,e.getComponentType())),i.max=i.max.map(c=>Rs(c,e.getComponentType()))),i.normalized&&(i.min=i.min.map(c=>Tr(c,i.componentType)),i.max=i.max.map(c=>Tr(c,i.componentType)))}else i.byteStride%4&&(i.array=zo(i.array,e.getElementSize()),i.byteStride=i.array.byteLength/e.getCount());return i}function ko(e){const t=e.getComponentType(),s=e.getArray(),r=new Float32Array(s.length);for(let n=0;n<s.length;n++)r[n]=Rs(s[n],t);return r}function zo(e,t){const s=C.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,r=e.length/t,n=new e.constructor(r*s);for(let o=0;o*t<e.length;o++)for(let i=0;i<t;i++)n[o*s+i]=e[o*t+i];return n}function Go(e){const t=new Float32Array(e.length*4/3);for(let s=0,r=e.length/3;s<r;s++)t[s*4]=e[s*3],t[s*4+1]=e[s*3+1],t[s*4+2]=e[s*3+2];return t}function $o(e,t){return t===ke.BufferViewUsage.ELEMENT_ARRAY_BUFFER?e.listParents().some(s=>s instanceof q&&s.getMode()===q.Mode.TRIANGLES)?"TRIANGLES":"INDICES":"ATTRIBUTES"}function Ho(e,t){const s=t.getGraph().listParentEdges(e).filter(r=>!(r.getParent()instanceof it));for(const r of s){const n=r.getName(),o=r.getAttributes().key||"",i=r.getParent().propertyType===_.PRIMITIVE_TARGET;if(n==="indices")return{filter:"NONE"};if(n==="attributes"){if(o==="POSITION")return{filter:"NONE"};if(o==="TEXCOORD_0")return{filter:"NONE"};if(o.startsWith("JOINTS_"))return{filter:"NONE"};if(o.startsWith("WEIGHTS_"))return{filter:"NONE"};if(o==="NORMAL"||o==="TANGENT")return i?{filter:"NONE"}:{filter:"OCTAHEDRAL",bits:8}}if(n==="output"){const a=Mn(e);return a==="rotation"?{filter:"QUATERNION",bits:16}:a==="translation"?{filter:"EXPONENTIAL",bits:12}:a==="scale"?{filter:"EXPONENTIAL",bits:12}:{filter:"NONE"}}if(n==="input")return{filter:"NONE"};if(n==="inverseBindMatrices")return{filter:"NONE"}}return{filter:"NONE"}}function Mn(e){for(const t of e.listParents())if(t instanceof zs){for(const s of t.listParents())if(s instanceof mt)return s.getTargetPath()}return null}const xr={method:"quantize"};var Pt=class extends k{extensionName=se;prereadTypes=[_.BUFFER,_.PRIMITIVE];prewriteTypes=[_.BUFFER,_.ACCESSOR];readDependencies=["meshopt.decoder"];writeDependencies=["meshopt.encoder"];static EXTENSION_NAME=se;static EncoderMethod=Fo;_decoder=null;_decoderFallbackBufferMap=new Map;_encoder=null;_encoderOptions=xr;_encoderFallbackBuffer=null;_encoderBufferViews={};_encoderBufferViewData={};_encoderBufferViewAccessors={};install(e,t){return e==="meshopt.decoder"&&(this._decoder=t),e==="meshopt.encoder"&&(this._encoder=t),this}setEncoderOptions(e){return this._encoderOptions={...xr,...e},this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${se}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${se}]: Missing WASM support.`)}return t===_.BUFFER?this._prereadBuffers(e):t===_.PRIMITIVE&&this._prereadPrimitives(e),this}_prereadBuffers(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach((s,r)=>{if(!s.extensions||!s.extensions.EXT_meshopt_compression)return;const n=s.extensions[se],o=n.byteOffset||0,i=n.byteLength||0,a=n.count,c=n.byteStride,l=new Uint8Array(a*c),u=t.json.buffers[n.buffer],h=u.uri?t.resources[u.uri]:t.resources[ze],f=C.toView(h,o,i);this._decoder.decodeGltfBuffer(l,a,c,f,n.mode,n.filter),e.bufferViews[r]=l})}_prereadPrimitives(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach(s=>{if(!s.extensions||!s.extensions.EXT_meshopt_compression)return;const r=s.extensions[se],n=e.buffers[r.buffer],o=e.buffers[s.buffer],i=t.json.buffers[s.buffer];Uo(i)&&this._decoderFallbackBufferMap.set(o,n)})}read(e){if(!this.isRequired())return this;for(const[t,s]of this._decoderFallbackBufferMap){for(const r of t.listParents())r instanceof N&&r.swap(t,s);t.dispose()}return this}prewrite(e,t){return t===_.ACCESSOR?this._prewriteAccessors(e):t===_.BUFFER&&this._prewriteBuffers(e),this}_prewriteAccessors(e){const t=e.jsonDoc.json,s=this._encoder,r=this._encoderOptions,n=this.document.getGraph(),o=this.document.createBuffer(),i=this.document.getRoot().listBuffers().indexOf(o);let a=1;const c=new Map,l=u=>{for(const h of n.listParents(u)){if(h.propertyType===_.ROOT)continue;let f=c.get(u);return f===void 0&&c.set(u,f=a++),f}return-1};this._encoderFallbackBuffer=o,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(const u of this.document.getRoot().listAccessors()){if(Mn(u)==="weights"||u.getSparse())continue;const h=e.getAccessorUsage(u),f=e.accessorUsageGroupedByParent.has(h)?l(u):null,g=$o(u,h),T=r.method==="filter"?Ho(u,this.document):{filter:"NONE"},p=Vo(u,s,g,T),{array:x,byteStride:d}=p,y=u.getBuffer();if(!y)throw new Error(`${se}: Missing buffer for accessor.`);const m=this.document.getRoot().listBuffers().indexOf(y),E=[h,f,g,T.filter,d,m].join(":");let b=this._encoderBufferViews[E],I=this._encoderBufferViewData[E],w=this._encoderBufferViewAccessors[E];(!b||!I)&&(w=this._encoderBufferViewAccessors[E]=[],I=this._encoderBufferViewData[E]=[],b=this._encoderBufferViews[E]={buffer:i,target:ke.USAGE_TO_TARGET[h],byteOffset:0,byteLength:0,byteStride:h===ke.BufferViewUsage.ARRAY_BUFFER?d:void 0,extensions:{[se]:{buffer:m,byteOffset:0,byteLength:0,mode:g,filter:T.filter!=="NONE"?T.filter:void 0,byteStride:d,count:0}}});const R=e.createAccessorDef(u);R.componentType=p.componentType,R.normalized=p.normalized,R.byteOffset=b.byteLength,R.min&&p.min&&(R.min=p.min),R.max&&p.max&&(R.max=p.max),e.accessorIndexMap.set(u,t.accessors.length),t.accessors.push(R),w.push(R),I.push(new Uint8Array(x.buffer,x.byteOffset,x.byteLength)),b.byteLength+=x.byteLength,b.extensions.EXT_meshopt_compression.count+=u.getCount()}}_prewriteBuffers(e){const t=this._encoder;for(const s in this._encoderBufferViews){const r=this._encoderBufferViews[s],n=this._encoderBufferViewData[s],o=this.document.getRoot().listBuffers()[r.extensions[se].buffer],i=e.otherBufferViews.get(o)||[],{count:a,byteStride:c,mode:l}=r.extensions[se],u=C.concat(n),h=t.encodeGltfBuffer(u,a,c,l),f=C.pad(h);r.extensions[se].byteLength=h.byteLength,n.length=0,n.push(f),i.push(f),e.otherBufferViews.set(o,i)}}write(e){let t=0;for(const o in this._encoderBufferViews){const i=this._encoderBufferViews[o],a=this._encoderBufferViewData[o][0],c=e.otherBufferViewsIndexMap.get(a),l=this._encoderBufferViewAccessors[o];for(const g of l)g.bufferView=c;const u=e.jsonDoc.json.bufferViews[c],h=u.byteOffset||0;Object.assign(u,i),u.byteOffset=t;const f=u.extensions[se];f.byteOffset=h,t+=C.padNumber(i.byteLength)}const s=this._encoderFallbackBuffer,r=e.bufferIndexMap.get(s),n=e.jsonDoc.json.buffers[r];return n.byteLength=t,n.extensions={[se]:{fallback:!0}},s.dispose(),this}},Ko=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="StructuralMetadata",this.parentTypes=[_.ROOT]}getDefaults(){return Object.assign(super.getDefaults(),{schema:null,schemaUri:"",propertyTables:new re,propertyTextures:new re,propertyAttributes:new re})}getSchema(){return this.getRef("schema")}setSchema(e){return this.setRef("schema",e)}getSchemaUri(){return this.get("schemaUri")}setSchemaUri(e){return this.set("schemaUri",e)}listPropertyTables(){return this.listRefs("propertyTables")}addPropertyTable(e){return this.addRef("propertyTables",e)}removePropertyTable(e){return this.removeRef("propertyTables",e)}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},qo=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="Schema",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",version:"",classes:new J,enums:new J})}getId(){return this.get("id")}setId(e){return this.set("id",e)}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getVersion(){return this.get("version")}setVersion(e){return this.set("version",e)}setClass(e,t){return this.setRefMap("classes",e,t)}getClass(e){return this.getRefMap("classes",e)}listClassKeys(){return this.listRefMapKeys("classes")}listClassValues(){return this.listRefMapValues("classes")}setEnum(e,t){return this.setRefMap("enums",e,t)}getEnum(e){return this.getRefMap("enums",e)}listEnumKeys(){return this.listRefMapKeys("enums")}listEnumValues(){return this.listRefMapValues("enums")}},Xo=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="Class",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",properties:new J})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},Wo=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="ClassProperty",this.parentTypes=["Class"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",componentType:null,enumType:null,array:null,count:null,normalized:null,offset:null,scale:null,max:null,min:null,required:null,noData:null,default:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getComponentType(){return this.get("componentType")}setComponentType(e){return this.set("componentType",e)}getEnumType(){return this.get("enumType")}setEnumType(e){return this.set("enumType",e)}getArray(){return this.get("array")}setArray(e){return this.set("array",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}getRequired(){return this.get("required")}setRequired(e){return this.set("required",e)}getNoData(){return this.get("noData")}setNoData(e){return this.set("noData",e)}getDefault(){return this.get("default")}setDefault(e){return this.set("default",e)}},Yo=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="Enum",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",valueType:"UINT16",values:new re})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValueType(){return this.get("valueType")}setValueType(e){return this.set("valueType",e)}listValues(){return this.listRefs("values")}addEnumValue(e){return this.addRef("values",e)}removeEnumValue(e){return this.removeRef("values",e)}},Jo=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="EnumValue",this.parentTypes=["Enum"]}getDefaults(){return Object.assign(super.getDefaults(),{description:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValue(){return this.get("value")}setValue(e){return this.set("value",e)}},Qo=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="PropertyTable",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new J})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},Zo=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="PropertyTableProperty",this.parentTypes=["PropertyTable"]}getDefaults(){return Object.assign(super.getDefaults(),{arrayOffsets:null,stringOffsets:null,arrayOffsetType:null,stringOffsetType:null,offset:null,scale:null,max:null,min:null})}getValues(){return this.get("values")}setValues(e){return this.set("values",e)}getArrayOffsets(){return this.get("arrayOffsets")}setArrayOffsets(e){return this.set("arrayOffsets",e)}getStringOffsets(){return this.get("stringOffsets")}setStringOffsets(e){return this.set("stringOffsets",e)}getArrayOffsetType(){return this.get("arrayOffsetType")}setArrayOffsetType(e){return this.set("arrayOffsetType",e)}getStringOffsetType(){return this.get("stringOffsetType")}setStringOffsetType(e){return this.set("stringOffsetType",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},ea=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="PropertyTexture",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new J})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},ta=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="PropertyTextureProperty",this.parentTypes=["PropertyTexture"]}getDefaults(){const e=new z(this.graph,"textureInfo");return e.setMinFilter(z.MagFilter.NEAREST),e.setMagFilter(z.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e,offset:null,scale:null,max:null,min:null})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},sa=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="PropertyAttribute",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new J})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},ra=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="PropertyAttributeProperty",this.parentTypes=["PropertyAttribute"]}getDefaults(){return Object.assign(super.getDefaults(),{offset:null,scale:null,max:null,min:null})}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},na=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="NodeStructuralMetadata",this.parentTypes=[_.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{class:"",properties:{}})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getProperties(){return this.get("properties")}setProperties(e){return this.set("properties",e)}},ia=class extends j{static EXTENSION_NAME=P;init(){this.extensionName=P,this.propertyType="MeshPrimitiveStructuralMetadata",this.parentTypes=[_.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{propertyTextures:new re,propertyAttributes:new re})}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},oa=class extends k{extensionName=P;static EXTENSION_NAME=P;prewriteTypes=[_.BUFFER];prereadTypes=[_.SCENE];createStructuralMetadata(){return new Ko(this.document.getGraph())}createSchema(){return new qo(this.document.getGraph())}createClass(){return new Xo(this.document.getGraph())}createClassProperty(){return new Wo(this.document.getGraph())}createEnum(){return new Yo(this.document.getGraph())}createEnumValue(){return new Jo(this.document.getGraph())}createPropertyTable(){return new Qo(this.document.getGraph())}createPropertyTableProperty(){return new Zo(this.document.getGraph())}createPropertyTexture(){return new ea(this.document.getGraph())}createPropertyTextureProperty(){return new ta(this.document.getGraph())}createPropertyAttribute(){return new sa(this.document.getGraph())}createPropertyAttributeProperty(){return new ra(this.document.getGraph())}createNodeStructuralMetadata(){return new na(this.document.getGraph())}createMeshPrimitiveStructuralMetadata(){return new ia(this.document.getGraph())}read(e){return this}preread(e){const t=this.document.getRoot(),{json:s}=e.jsonDoc,r=s.extensions[P],n=aa(this,e,r);return t.setExtension(P,n),(s.meshes||[]).forEach((o,i)=>{const a=e.meshes[i].listPrimitives();(o.primitives||[]).forEach((c,l)=>{const u=a[l];this._readPrimitive(n,u,c)})}),(s.nodes||[]).forEach((o,i)=>{this._readNode(e.nodes[i],o)}),this}_readPrimitive(e,t,s){if(!s.extensions||!s.extensions.EXT_structural_metadata)return;const r=this.createMeshPrimitiveStructuralMetadata(),n=s.extensions[P],o=e.listPropertyTextures(),i=n.propertyTextures||[];for(const l of i){const u=o[l];r.addPropertyTexture(u)}const a=e.listPropertyAttributes(),c=n.propertyAttributes||[];for(const l of c){const u=a[l];r.addPropertyAttribute(u)}t.setExtension(P,r)}_readNode(e,t){if(!t.extensions||!t.extensions.EXT_structural_metadata)return;const s=t.extensions[P],r=this.createNodeStructuralMetadata().setClass(s.class).setProperties(s.properties);e.setExtension(P,r)}write(e){const t=this.document.getRoot(),s=t.getExtension(P);if(!s)return this;const r=e.jsonDoc.json,n=xa(e,s);r.extensions=r.extensions||{},r.extensions[P]=n;const o=t.listMeshes(),i=r.meshes;if(i)for(const l of o){const u=i[e.meshIndexMap.get(l)];l.listPrimitives().forEach((h,f)=>{const g=u.primitives[f];this._writePrimitive(s,h,g)})}const a=t.listNodes(),c=r.nodes;if(c)for(const l of a){const u=e.nodeIndexMap.get(l);this._writeNode(l,c[u])}return this}_writePrimitive(e,t,s){const r=t.getExtension(P);if(!r)return;const n=e.listPropertyTextures(),o=e.listPropertyAttributes();let i,a;const c=r.listPropertyTextures();if(c.length>0){i=[];for(const h of c){const f=n.indexOf(h);if(f>=0)i.push(f);else throw new Error(`${P}: Invalid property texture in mesh primitive`)}}const l=r.listPropertyAttributes();if(l.length>0){a=[];for(const h of l){const f=o.indexOf(h);if(f>=0)a.push(f);else throw new Error(`${P}: Invalid property attribute in mesh primitive`)}}const u={propertyTextures:i,propertyAttributes:a};s.extensions=s.extensions||{},s.extensions[P]=u}_writeNode(e,t){const s=e.getExtension("EXT_structural_metadata");s&&(t.extensions=t.extensions||{},t.extensions[P]={class:s.getClass(),properties:s.getProperties()})}prewrite(e,t){return t===_.BUFFER&&this._prewriteBuffers(e),this}_prewriteBuffers(e){const t=this.document,s=t.getRoot().getExtension(P);e.jsonDoc.json.bufferViews||=[];for(const r of s.listPropertyTables())for(const n of r.listPropertyValues()){const o=Ca(t,e);o.push(n.getValues());const i=n.getArrayOffsets();i&&o.push(i);const a=n.getStringOffsets();a&&o.push(a)}}};function aa(e,t,s){const r=e.createStructuralMetadata();if(s.schema!==void 0){const a=ca(e,s.schema);r.setSchema(a)}else if(s.schemaUri){const a=s.schemaUri;r.setSchemaUri(a)}const n=s.propertyTextures||[];for(const a of n){const c=da(e,t,a);r.addPropertyTexture(c)}const o=s.propertyTables||[];for(const a of o){const c=pa(e,t,a);r.addPropertyTable(c)}const i=s.propertyAttributes||[];for(const a of i){const c=ya(e,a);r.addPropertyAttribute(c)}return r}function ca(e,t){const s=e.createSchema().setId(t.id);t.name!==void 0&&s.setName(t.name),t.description!==void 0&&s.setDescription(t.description),t.version!==void 0&&s.setVersion(t.version);const r=t.classes||{};for(const o of Object.keys(r)){const i=r[o];s.setClass(o,ua(e,i))}const n=t.enums||{};for(const o of Object.keys(n))s.setEnum(o,fa(e,n[o]));return s}function ua(e,t){const s=e.createClass();t.name!==void 0&&s.setName(t.name),t.description!==void 0&&s.setDescription(t.description);const r=t.properties||{};for(const n of Object.keys(r)){const o=la(e,r[n]);s.setProperty(n,o)}return s}function la(e,t){const s=e.createClassProperty().setType(t.type);return t.name!==void 0&&s.setName(t.name),t.description!==void 0&&s.setDescription(t.description),t.componentType!==void 0&&s.setComponentType(t.componentType),t.enumType!==void 0&&s.setEnumType(t.enumType),t.array!==void 0&&s.setArray(t.array),t.count!==void 0&&s.setCount(t.count),t.normalized!==void 0&&s.setNormalized(t.normalized),t.offset!==void 0&&s.setOffset(t.offset),t.scale!==void 0&&s.setScale(t.scale),t.max!==void 0&&s.setMax(t.max),t.min!==void 0&&s.setMin(t.min),t.required!==void 0&&s.setRequired(t.required),t.noData!==void 0&&s.setNoData(t.noData),t.default!==void 0&&s.setDefault(t.default),s}function fa(e,t){const s=e.createEnum();t.name!==void 0&&s.setName(t.name),t.description!==void 0&&s.setDescription(t.description),t.valueType!==void 0&&s.setValueType(t.valueType);const r=t.values||{};for(const n of r)s.addEnumValue(ha(e,n));return s}function ha(e,t){const s=e.createEnumValue();return t.name!==void 0&&s.setName(t.name),t.description!==void 0&&s.setDescription(t.description),t.value!==void 0&&s.setValue(t.value),s}function da(e,t,s){const r=e.createPropertyTexture();r.setClass(s.class),s.name!==void 0&&r.setName(s.name);const n=s.properties||{};for(const o of Object.keys(n)){const i=ga(e,t,n[o]);r.setProperty(o,i)}return r}function ga(e,t,s){const r=e.createPropertyTextureProperty(),n=t.jsonDoc.json.textures||[];s.channels&&r.setChannels(s.channels);const o=n[s.index].source;if(o!==void 0){const i=t.textures[o];r.setTexture(i);const a=r.getTextureInfo();a&&t.setTextureInfo(a,s)}return s.offset!==void 0&&r.setOffset(s.offset),s.scale!==void 0&&r.setScale(s.scale),s.max!==void 0&&r.setMax(s.max),s.min!==void 0&&r.setMin(s.min),r}function pa(e,t,s){const r=e.createPropertyTable().setClass(s.class).setCount(s.count);s.name!==void 0&&r.setName(s.name);const n=s.properties||{};for(const o of Object.keys(n)){const i=ma(e,t,n[o]);r.setProperty(o,i)}return r}function ma(e,t,s){const r=e.createPropertyTableProperty(),n=ds(t,s.values);if(r.setValues(n),s.arrayOffsets!==void 0){const o=ds(t,s.arrayOffsets);r.setArrayOffsets(o)}if(s.stringOffsets!==void 0){const o=ds(t,s.stringOffsets);r.setStringOffsets(o)}return s.arrayOffsetType!==void 0&&r.setArrayOffsetType(s.arrayOffsetType),s.stringOffsetType!==void 0&&r.setStringOffsetType(s.stringOffsetType),s.offset!==void 0&&r.setOffset(s.offset),s.scale!==void 0&&r.setScale(s.scale),s.max!==void 0&&r.setMax(s.max),s.min!==void 0&&r.setMin(s.min),r}function ya(e,t){const s=e.createPropertyAttribute();s.setClass(t.class),t.name!==void 0&&s.setName(t.name);const r=t.properties||{};for(const n of Object.keys(r)){const o=Ta(e,r[n]);s.setProperty(n,o)}return s}function Ta(e,t){const s=e.createPropertyAttributeProperty();return s.setAttribute(t.attribute),t.offset!==void 0&&s.setOffset(t.offset),t.scale!==void 0&&s.setScale(t.scale),t.max!==void 0&&s.setMax(t.max),t.min!==void 0&&s.setMin(t.min),s}function xa(e,t){const s={},r=t.getSchema();r&&(s.schema=Ea(r));const n=t.getSchemaUri();n&&(s.schemaUri=n);const o=t.listPropertyTables();if(o.length>0){const c=[];for(const l of o){const u=va(e,l);c.push(u)}s.propertyTables=c}const i=t.listPropertyTextures();if(i.length>0){const c=[];for(const l of i){const u=Na(e,l);c.push(u)}s.propertyTextures=c}const a=t.listPropertyAttributes();if(a.length>0){const c=[];for(const l of a){const u=wa(l);c.push(u)}s.propertyAttributes=c}return s}function Ea(e){const t={id:e.getId()},s=e.listClassKeys();if(s.length>0){t.classes={};for(const n of s){const o=ba(e.getClass(n));t.classes[n]=o}}const r=e.listEnumKeys();if(r.length>0){t.enums={};for(const n of r){const o=Ia(e.getEnum(n));t.enums[n]=o}}return e.getName()&&(t.name=e.getName()),e.getDescription()&&(t.description=e.getDescription()),e.getVersion()&&(t.version=e.getVersion()),t}function ba(e){const t={},s=e.listPropertyKeys();if(s.length>0){t.properties={};for(const r of s){const n=e.getProperty(r);t.properties[r]=_a(n)}}return e.getName()&&(t.name=e.getName()),e.getDescription()&&(t.description=e.getDescription()),t}function _a(e){const t={type:e.getType()};return e.getArray()&&(t.array=e.getArray()),e.getNormalized()&&(t.normalized=e.getNormalized()),e.getRequired()&&(t.required=e.getRequired()),e.getName()&&(t.name=e.getName()),e.getDescription()&&(t.description=e.getDescription()),e.getComponentType()!=null&&(t.componentType=e.getComponentType()),e.getEnumType()!=null&&(t.enumType=e.getEnumType()),e.getCount()!=null&&(t.count=e.getCount()),e.getOffset()!=null&&(t.offset=e.getOffset()),e.getScale()!=null&&(t.scale=e.getScale()),e.getMax()!=null&&(t.max=e.getMax()),e.getMin()!=null&&(t.min=e.getMin()),e.getNoData()!=null&&(t.noData=e.getNoData()),e.getDefault()!=null&&(t.default=e.getDefault()),t}function Ia(e){const t={values:e.listValues().map(Aa)};return e.getName()&&(t.name=e.getName()),e.getDescription()&&(t.description=e.getDescription()),e.getValueType()!=="UINT16"&&(t.valueType=e.getValueType()),t}function Aa(e){const t={name:e.getName(),value:e.getValue()};return e.getDescription()&&(t.description=e.getDescription()),t}function va(e,t){const s={class:t.getClass(),count:t.getCount()};t.getName()&&(s.name=t.getName());const r=t.listPropertyKeys();if(r.length>0){s.properties={};for(const n of r){const o=Ra(e,t.getProperty(n));s.properties[n]=o}}return s}function Ra(e,t){const s=t.getValues(),r={values:e.otherBufferViewsIndexMap.get(s)};if(t.getArrayOffsets()){const n=t.getArrayOffsets();r.arrayOffsets=e.otherBufferViewsIndexMap.get(n)}if(t.getStringOffsets()){const n=t.getStringOffsets();r.stringOffsets=e.otherBufferViewsIndexMap.get(n)}return t.getArrayOffsetType()!=null&&(r.arrayOffsetType=t.getArrayOffsetType()),t.getStringOffsetType()!=null&&(r.stringOffsetType=t.getStringOffsetType()),t.getOffset()!=null&&(r.offset=t.getOffset()),t.getScale()!=null&&(r.scale=t.getScale()),t.getMax()!=null&&(r.max=t.getMax()),t.getMin()!=null&&(r.min=t.getMin()),r}function wa(e){const t={class:e.getClass()};e.getName()&&(t.name=e.getName());const s=e.listPropertyKeys();if(s.length>0){t.properties={};for(const r of s){const n=Sa(e.getProperty(r));t.properties[r]=n}}return t}function Sa(e){const t={attribute:e.getAttribute()};return e.getOffset()!=null&&(t.offset=e.getOffset()),e.getScale()!=null&&(t.scale=e.getScale()),e.getMax()!=null&&(t.max=e.getMax()),e.getMin()!=null&&(t.min=e.getMin()),t}function Na(e,t){const s={class:t.getClass()};t.getName()&&(s.name=t.getName());const r=t.listPropertyKeys();if(r.length>0){s.properties={};for(const n of r){const o=Ma(e,t.getProperty(n));s.properties[n]=o}}return s}function Ma(e,t){const s=t.getTexture(),r=t.getTextureInfo(),n=t.getChannels(),o=e.createTextureInfoDef(s,r);return B.eq(n,[0])||(o.channels=n),t.getOffset()!=null&&(o.offset=t.getOffset()),t.getScale()!=null&&(o.scale=t.getScale()),t.getMax()!=null&&(o.max=t.getMax()),t.getMin()!=null&&(o.min=t.getMin()),o}function ds(e,t){const s=e.jsonDoc,r=s.json.buffers||[],n=(s.json.bufferViews||[])[t],o=r[n.buffer],i=o.uri?s.resources[o.uri]:s.resources[ze],a=n.byteOffset||0,c=n.byteLength;return i.slice(a,a+c)}function Ca(e,t){const s=e.getRoot().listBuffers()[0];let r=t.otherBufferViews.get(s);return r||(r=[],t.otherBufferViews.set(s,r)),r}var Oa=class{match(e){return e.length>=12&&C.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);let s=Er(t,0);if(!s)return null;let r=s.end;for(;s=Er(t,r);)if(s.type==="meta")r=s.start+4;else if(s.type==="iprp"||s.type==="ipco")r=s.start;else{if(s.type==="ispe")return[t.getUint32(s.start+4),t.getUint32(s.start+8)];if(s.type==="mdat")break;r=s.end}return null}getChannels(e){return 4}},Da=class extends k{extensionName=wt;prereadTypes=[_.TEXTURE];static EXTENSION_NAME=wt;static register(){fe.registerFormat("image/avif",new Oa)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(t=>{t.extensions&&t.extensions.EXT_texture_avif&&(t.source=t.extensions[wt].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if(s.getMimeType()==="image/avif"){const r=e.imageIndexMap.get(s);(t.json.textures||[]).forEach(n=>{n.source===r&&(n.extensions=n.extensions||{},n.extensions[wt]={source:n.source},delete n.source)})}}),this}};function Er(e,t){if(e.byteLength<4+t)return null;const s=e.getUint32(t);return e.byteLength<s+t||s<8?null:{type:C.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+s}}var Pa=class{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){const t=C.decodeText(e.slice(0,4)),s=C.decodeText(e.slice(8,12));if(t!=="RIFF"||s!=="WEBP")return null;const r=new DataView(e.buffer,e.byteOffset);let n=12;for(;n<r.byteLength;){const o=C.decodeText(new Uint8Array([r.getUint8(n),r.getUint8(n+1),r.getUint8(n+2),r.getUint8(n+3)])),i=r.getUint32(n+4,!0);if(o==="VP8 ")return[r.getInt16(n+14,!0)&16383,r.getInt16(n+16,!0)&16383];if(o==="VP8L"){const a=r.getUint8(n+9),c=r.getUint8(n+10),l=r.getUint8(n+11),u=r.getUint8(n+12);return[1+((c&63)<<8|a),1+((u&15)<<10|l<<2|(c&192)>>6)]}n+=8+i+i%2}return null}getChannels(e){return 4}},ja=class extends k{extensionName=Rt;prereadTypes=[_.TEXTURE];static EXTENSION_NAME=Rt;static register(){fe.registerFormat("image/webp",new Pa)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(t=>{t.extensions&&t.extensions.EXT_texture_webp&&(t.source=t.extensions[Rt].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if(s.getMimeType()==="image/webp"){const r=e.imageIndexMap.get(s);(t.json.textures||[]).forEach(n=>{n.source===r&&(n.extensions=n.extensions||{},n.extensions[Rt]={source:n.source},delete n.source)})}}),this}};const br=vo;var Fa=class extends k{extensionName=br;static EXTENSION_NAME=br;read(e){return this}write(e){return this}};const _r=Ro;var Ua=class extends k{extensionName=_r;static EXTENSION_NAME=_r;read(e){return this}write(e){return this}};let X,Cn,On;function Ba(e,t){const s=new X.DecoderBuffer;try{if(s.Init(t,t.length),e.GetEncodedGeometryType(s)!==X.TRIANGULAR_MESH)throw new Error(`[${H}] Unknown geometry type.`);const r=new X.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||r.ptr===0)throw new Error(`[${H}] Decoding failure.`);return r}finally{X.destroy(s)}}function La(e,t){const s=t.num_faces()*3;let r,n;if(t.num_points()<=65534){const o=s*Uint16Array.BYTES_PER_ELEMENT;r=X._malloc(o),e.GetTrianglesUInt16Array(t,o,r),n=new Uint16Array(X.HEAPU16.buffer,r,s).slice()}else{const o=s*Uint32Array.BYTES_PER_ELEMENT;r=X._malloc(o),e.GetTrianglesUInt32Array(t,o,r),n=new Uint32Array(X.HEAPU32.buffer,r,s).slice()}return X._free(r),n}function Va(e,t,s,r){const n=On[r.componentType],o=Cn[r.componentType],i=s.num_components(),a=t.num_points()*i,c=a*o.BYTES_PER_ELEMENT,l=X._malloc(c);e.GetAttributeDataArrayForAllPoints(t,s,n,c,l);const u=new o(X.HEAPF32.buffer,l,a).slice();return X._free(l),u}function ka(e){X=e,Cn={[N.ComponentType.FLOAT]:Float32Array,[N.ComponentType.UNSIGNED_INT]:Uint32Array,[N.ComponentType.UNSIGNED_SHORT]:Uint16Array,[N.ComponentType.UNSIGNED_BYTE]:Uint8Array,[N.ComponentType.SHORT]:Int16Array,[N.ComponentType.BYTE]:Int8Array},On={[N.ComponentType.FLOAT]:X.DT_FLOAT32,[N.ComponentType.UNSIGNED_INT]:X.DT_UINT32,[N.ComponentType.UNSIGNED_SHORT]:X.DT_UINT16,[N.ComponentType.UNSIGNED_BYTE]:X.DT_UINT8,[N.ComponentType.SHORT]:X.DT_INT16,[N.ComponentType.BYTE]:X.DT_INT8}}let ce,za=(function(e){return e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL",e})({});const Dn={POSITION:14,NORMAL:10,COLOR:8,TEX_COORD:12,GENERIC:12},Ir={decodeSpeed:5,encodeSpeed:5,method:1,quantizationBits:Dn,quantizationVolume:"mesh"};function Ga(e){ce=e}function $a(e,t=Ir){const s={...Ir,...t};s.quantizationBits={...Dn,...t.quantizationBits};const r=new ce.MeshBuilder,n=new ce.Mesh,o=new ce.ExpertEncoder(n),i={},a=new ce.DracoInt8Array,c=e.listTargets().length>0;let l=!1;for(const p of e.listSemantics()){const x=e.getAttribute(p);if(x.getSparse()){l=!0;continue}const d=Ha(p),y=Ka(r,x.getComponentType(),n,ce[d],x.getCount(),x.getElementSize(),x.getArray());if(y===-1)throw new Error(`Error compressing "${p}" attribute.`);if(i[p]=y,s.quantizationVolume==="mesh"||p!=="POSITION")o.SetAttributeQuantization(y,s.quantizationBits[d]);else if(typeof s.quantizationVolume=="object"){const{quantizationVolume:m}=s,E=Math.max(m.max[0]-m.min[0],m.max[1]-m.min[1],m.max[2]-m.min[2]);o.SetAttributeExplicitQuantization(y,s.quantizationBits[d],x.getElementSize(),m.min,E)}else throw new Error("Invalid quantization volume state.")}const u=e.getIndices();if(!u)throw new ws("Primitive must have indices.");r.AddFacesToMesh(n,u.getCount()/3,u.getArray()),o.SetSpeedOptions(s.encodeSpeed,s.decodeSpeed),o.SetTrackEncodedProperties(!0),s.method===0||c||l?o.SetEncodingMethod(ce.MESH_SEQUENTIAL_ENCODING):o.SetEncodingMethod(ce.MESH_EDGEBREAKER_ENCODING);const h=o.EncodeToDracoBuffer(!(c||l),a);if(h<=0)throw new ws("Error applying Draco compression.");const f=new Uint8Array(h);for(let p=0;p<h;++p)f[p]=a.GetValue(p);const g=o.GetNumberOfEncodedPoints(),T=o.GetNumberOfEncodedFaces()*3;return ce.destroy(a),ce.destroy(n),ce.destroy(r),ce.destroy(o),{numVertices:g,numIndices:T,data:f,attributeIDs:i}}function Ha(e){return e==="POSITION"?"POSITION":e==="NORMAL"?"NORMAL":e.startsWith("COLOR_")?"COLOR":e.startsWith("TEXCOORD_")?"TEX_COORD":"GENERIC"}function Ka(e,t,s,r,n,o,i){switch(t){case N.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(s,r,n,o,i);case N.ComponentType.BYTE:return e.AddInt8Attribute(s,r,n,o,i);case N.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(s,r,n,o,i);case N.ComponentType.SHORT:return e.AddInt16Attribute(s,r,n,o,i);case N.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(s,r,n,o,i);case N.ComponentType.FLOAT:return e.AddFloatAttribute(s,r,n,o,i);default:throw new Error(`Unexpected component type, "${t}".`)}}var ws=class extends Error{},jt=class extends k{extensionName=H;prereadTypes=[_.PRIMITIVE];prewriteTypes=[_.ACCESSOR];readDependencies=["draco3d.decoder"];writeDependencies=["draco3d.encoder"];static EXTENSION_NAME=H;static EncoderMethod=za;_decoderModule=null;_encoderModule=null;_encoderOptions={};install(e,t){return e==="draco3d.decoder"&&(this._decoderModule=t,ka(this._decoderModule)),e==="draco3d.encoder"&&(this._encoderModule=t,Ga(this._encoderModule)),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.decoder".`);const t=this.document.getLogger(),s=e.jsonDoc,r=new Map;try{const n=s.json.meshes||[];for(const o of n)for(const i of o.primitives){if(!i.extensions||!i.extensions.KHR_draco_mesh_compression)continue;const a=i.extensions[H];let[c,l]=r.get(a.bufferView)||[];if(!l||!c){const u=s.json.bufferViews[a.bufferView],h=s.json.buffers[u.buffer],f=h.uri?s.resources[h.uri]:s.resources[ze],g=u.byteOffset||0,T=u.byteLength,p=C.toView(f,g,T);c=new this._decoderModule.Decoder,l=Ba(c,p),r.set(a.bufferView,[c,l]),t.debug(`[${H}] Decompressed ${p.byteLength} bytes.`)}for(const u in a.attributes){const h=e.jsonDoc.json.accessors[i.attributes[u]],f=c.GetAttributeByUniqueId(l,a.attributes[u]),g=Va(c,l,f,h);e.accessors[i.attributes[u]].setArray(g)}i.indices!==void 0&&e.accessors[i.indices].setArray(La(c,l))}}finally{for(const[n,o]of Array.from(r.values()))this._decoderModule.destroy(n),this._decoderModule.destroy(o)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.encoder".`);const s=this.document.getLogger();s.debug(`[${H}] Compression options: ${JSON.stringify(this._encoderOptions)}`);const r=qa(this.document),n=new Map;let o="mesh";this._encoderOptions.quantizationVolume==="scene"&&(this.document.getRoot().listScenes().length!==1?s.warn(`[${H}]: quantizationVolume=scene requires exactly 1 scene.`):o=hn(this.document.getRoot().listScenes().pop()));for(const i of Array.from(r.keys())){const a=r.get(i);if(!a)throw new Error("Unexpected primitive.");if(n.has(a)){n.set(a,n.get(a));continue}const c=i.getIndices(),l=e.jsonDoc.json.accessors;let u;try{u=$a(i,{...this._encoderOptions,quantizationVolume:o})}catch(g){if(g instanceof ws){s.warn(`[${H}]: ${g.message} Skipping primitive compression.`);continue}throw g}n.set(a,u);const h=e.createAccessorDef(c);h.count=u.numIndices,e.accessorIndexMap.set(c,l.length),l.push(h),u.numVertices>65534&&N.getComponentSize(h.componentType)<=2?h.componentType=N.ComponentType.UNSIGNED_INT:u.numVertices>254&&N.getComponentSize(h.componentType)<=1&&(h.componentType=N.ComponentType.UNSIGNED_SHORT);for(const g of i.listSemantics()){const T=i.getAttribute(g);if(u.attributeIDs[g]===void 0)continue;const p=e.createAccessorDef(T);p.count=u.numVertices,e.accessorIndexMap.set(T,l.length),l.push(p)}const f=i.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];e.otherBufferViews.has(f)||e.otherBufferViews.set(f,[]),e.otherBufferViews.get(f).push(u.data)}return s.debug(`[${H}] Compressed ${r.size} primitives.`),e.extensionData[H]={primitiveHashMap:r,primitiveEncodingMap:n},this}write(e){const t=e.extensionData[H];for(const s of this.document.getRoot().listMeshes()){const r=e.jsonDoc.json.meshes[e.meshIndexMap.get(s)];for(let n=0;n<s.listPrimitives().length;n++){const o=s.listPrimitives()[n],i=r.primitives[n],a=t.primitiveHashMap.get(o);if(!a)continue;const c=t.primitiveEncodingMap.get(a);c&&(i.extensions=i.extensions||{},i.extensions[H]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs})}}if(!t.primitiveHashMap.size){const s=e.jsonDoc.json;s.extensionsUsed=(s.extensionsUsed||[]).filter(r=>r!==H),s.extensionsRequired=(s.extensionsRequired||[]).filter(r=>r!==H)}return this}};function qa(e){const t=e.getLogger(),s=new Set,r=new Set;let n=0,o=0;for(const h of e.getRoot().listMeshes())for(const f of h.listPrimitives())f.getIndices()?f.getMode()!==q.Mode.TRIANGLES?(r.add(f),o++):s.add(f):(r.add(f),n++);n>0&&t.warn(`[${H}] Skipping Draco compression of ${n} non-indexed primitives.`),o>0&&t.warn(`[${H}] Skipping Draco compression of ${o} non-TRIANGLES primitives.`);const i=e.getRoot().listAccessors(),a=new Map;for(let h=0;h<i.length;h++)a.set(i[h],h);const c=new Map,l=new Set,u=new Map;for(const h of Array.from(s)){let f=Ar(h,a);if(l.has(f)){u.set(h,f);continue}if(c.has(h.getIndices())){const g=h.getIndices(),T=g.clone();a.set(T,e.getRoot().listAccessors().length-1),h.swap(g,T)}for(const g of h.listAttributes())if(c.has(g)){const T=g.clone();a.set(T,e.getRoot().listAccessors().length-1),h.swap(g,T)}f=Ar(h,a),l.add(f),u.set(h,f),c.set(h.getIndices(),f);for(const g of h.listAttributes())c.set(g,f)}for(const h of Array.from(c.keys())){const f=new Set(h.listParents().map(g=>g.propertyType));if(f.size!==2||!f.has(_.PRIMITIVE)||!f.has(_.ROOT))throw new Error(`[${H}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const h of Array.from(s)){const f=u.get(h),g=h.getIndices();if(c.get(g)!==f||h.listAttributes().some(T=>c.get(T)!==f))throw new Error(`[${H}] Draco primitives must share all, or no, accessors.`)}for(const h of Array.from(r)){const f=h.getIndices();if(c.has(f)||h.listAttributes().some(g=>c.has(g)))throw new Error(`[${H}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return u}function Ar(e,t){const s=[],r=e.getIndices();s.push(t.get(r));for(const n of e.listAttributes())s.push(t.get(n));return s.sort().join("|")}var vr=class Pn extends j{static EXTENSION_NAME=ge;static Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};init(){this.extensionName=ge,this.propertyType="Light",this.parentTypes=[_.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:Pn.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(t){return this.set("color",t)}getIntensity(){return this.get("intensity")}setIntensity(t){return this.set("intensity",t)}getType(){return this.get("type")}setType(t){return this.set("type",t)}getRange(){return this.get("range")}setRange(t){return this.set("range",t)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(t){return this.set("innerConeAngle",t)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(t){return this.set("outerConeAngle",t)}},Xa=class extends k{extensionName=ge;static EXTENSION_NAME=ge;createLight(e=""){return new vr(this.document.getGraph(),e)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_lights_punctual)return this;const s=(t.json.extensions.KHR_lights_punctual.lights||[]).map(r=>{const n=this.createLight().setName(r.name||"").setType(r.type);return r.extras&&n.setExtras(r.extras),r.color!==void 0&&n.setColor(r.color),r.intensity!==void 0&&n.setIntensity(r.intensity),r.range!==void 0&&n.setRange(r.range),r.spot?.innerConeAngle!==void 0&&n.setInnerConeAngle(r.spot.innerConeAngle),r.spot?.outerConeAngle!==void 0&&n.setOuterConeAngle(r.spot.outerConeAngle),n});return t.json.nodes.forEach((r,n)=>{if(!r.extensions||!r.extensions.KHR_lights_punctual)return;const o=r.extensions[ge];e.nodes[n].setExtension(ge,s[o.light])}),this}write(e){const t=e.jsonDoc;if(this.properties.size===0)return this;const s=[],r=new Map;for(const n of this.properties){const o=n,i=e.createPropertyDef(n);i.type=o.getType(),B.eq(o.getColor(),[1,1,1])||(i.color=o.getColor()),o.getIntensity()!==1&&(i.intensity=o.getIntensity()),o.getRange()!=null&&(i.range=o.getRange()),o.getName()&&(i.name=o.getName()),o.getType()===vr.Type.SPOT&&(i.spot={innerConeAngle:o.getInnerConeAngle(),outerConeAngle:o.getOuterConeAngle()}),s.push(i),r.set(o,s.length-1)}return this.document.getRoot().listNodes().forEach(n=>{const o=n.getExtension(ge);if(o){const i=e.nodeIndexMap.get(n),a=t.json.nodes[i];a.extensions=a.extensions||{},a.extensions[ge]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[ge]={lights:s},this}};const{R:Wa,G:Ya,B:Ja}=de;var Qa=class extends j{static EXTENSION_NAME=Ee;init(){this.extensionName=Ee,this.propertyType="Anisotropy",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new z(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:Wa|Ya|Ja})}},Za=class extends k{static EXTENSION_NAME=Ee;extensionName=Ee;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createAnisotropy(){return new Qa(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_anisotropy){const i=this.createAnisotropy();e.materials[o].setExtension(Ee,i);const a=n.extensions[Ee];if(a.extras&&i.setExtras(a.extras),a.anisotropyStrength!==void 0&&i.setAnisotropyStrength(a.anisotropyStrength),a.anisotropyRotation!==void 0&&i.setAnisotropyRotation(a.anisotropyRotation),a.anisotropyTexture!==void 0){const c=a.anisotropyTexture,l=e.textures[r[c.index].source];i.setAnisotropyTexture(l),e.setTextureInfo(i.getAnisotropyTextureInfo(),c)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Ee);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[Ee]=i,r.getAnisotropyStrength()>0&&(i.anisotropyStrength=r.getAnisotropyStrength()),r.getAnisotropyRotation()!==0&&(i.anisotropyRotation=r.getAnisotropyRotation()),r.getAnisotropyTexture()){const a=r.getAnisotropyTexture(),c=r.getAnisotropyTextureInfo();i.anisotropyTexture=e.createTextureInfoDef(a,c)}}}),this}};const{R:Rr,G:wr,B:ec}=de;var tc=class extends j{static EXTENSION_NAME=be;init(){this.extensionName=be,this.propertyType="Clearcoat",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new z(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new z(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new z(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:Rr})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:wr})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:Rr|wr|ec})}},sc=class extends k{static EXTENSION_NAME=be;extensionName=be;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createClearcoat(){return new tc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_clearcoat){const i=this.createClearcoat();e.materials[o].setExtension(be,i);const a=n.extensions[be];if(a.extras&&i.setExtras(a.extras),a.clearcoatFactor!==void 0&&i.setClearcoatFactor(a.clearcoatFactor),a.clearcoatRoughnessFactor!==void 0&&i.setClearcoatRoughnessFactor(a.clearcoatRoughnessFactor),a.clearcoatTexture!==void 0){const c=a.clearcoatTexture,l=e.textures[r[c.index].source];i.setClearcoatTexture(l),e.setTextureInfo(i.getClearcoatTextureInfo(),c)}if(a.clearcoatRoughnessTexture!==void 0){const c=a.clearcoatRoughnessTexture,l=e.textures[r[c.index].source];i.setClearcoatRoughnessTexture(l),e.setTextureInfo(i.getClearcoatRoughnessTextureInfo(),c)}if(a.clearcoatNormalTexture!==void 0){const c=a.clearcoatNormalTexture,l=e.textures[r[c.index].source];i.setClearcoatNormalTexture(l),e.setTextureInfo(i.getClearcoatNormalTextureInfo(),c),c.scale!==void 0&&i.setClearcoatNormalScale(c.scale)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(be);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[be]=i,i.clearcoatFactor=r.getClearcoatFactor(),i.clearcoatRoughnessFactor=r.getClearcoatRoughnessFactor(),r.getClearcoatTexture()){const a=r.getClearcoatTexture(),c=r.getClearcoatTextureInfo();i.clearcoatTexture=e.createTextureInfoDef(a,c)}if(r.getClearcoatRoughnessTexture()){const a=r.getClearcoatRoughnessTexture(),c=r.getClearcoatRoughnessTextureInfo();i.clearcoatRoughnessTexture=e.createTextureInfoDef(a,c)}if(r.getClearcoatNormalTexture()){const a=r.getClearcoatNormalTexture(),c=r.getClearcoatNormalTextureInfo();i.clearcoatNormalTexture=e.createTextureInfoDef(a,c),r.getClearcoatNormalScale()!==1&&(i.clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}};const{R:rc,G:nc,B:ic,A:oc}=de;var ac=class extends j{static EXTENSION_NAME=_e;init(){this.extensionName=_e,this.propertyType="DiffuseTransmission",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new z(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new z(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:oc})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:rc|nc|ic})}},cc=class extends k{extensionName=_e;static EXTENSION_NAME=_e;createDiffuseTransmission(){return new ac(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_diffuse_transmission){const i=this.createDiffuseTransmission();e.materials[o].setExtension(_e,i);const a=n.extensions[_e];if(a.extras&&i.setExtras(a.extras),a.diffuseTransmissionFactor!==void 0&&i.setDiffuseTransmissionFactor(a.diffuseTransmissionFactor),a.diffuseTransmissionColorFactor!==void 0&&i.setDiffuseTransmissionColorFactor(a.diffuseTransmissionColorFactor),a.diffuseTransmissionTexture!==void 0){const c=a.diffuseTransmissionTexture,l=e.textures[r[c.index].source];i.setDiffuseTransmissionTexture(l),e.setTextureInfo(i.getDiffuseTransmissionTextureInfo(),c)}if(a.diffuseTransmissionColorTexture!==void 0){const c=a.diffuseTransmissionColorTexture,l=e.textures[r[c.index].source];i.setDiffuseTransmissionColorTexture(l),e.setTextureInfo(i.getDiffuseTransmissionColorTextureInfo(),c)}}}),this}write(e){const t=e.jsonDoc;for(const s of this.document.getRoot().listMaterials()){const r=s.getExtension(_e);if(!r)continue;const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[_e]=i,i.diffuseTransmissionFactor=r.getDiffuseTransmissionFactor(),i.diffuseTransmissionColorFactor=r.getDiffuseTransmissionColorFactor(),r.getDiffuseTransmissionTexture()){const a=r.getDiffuseTransmissionTexture(),c=r.getDiffuseTransmissionTextureInfo();i.diffuseTransmissionTexture=e.createTextureInfoDef(a,c)}if(r.getDiffuseTransmissionColorTexture()){const a=r.getDiffuseTransmissionColorTexture(),c=r.getDiffuseTransmissionColorTextureInfo();i.diffuseTransmissionColorTexture=e.createTextureInfoDef(a,c)}}return this}},uc=class extends j{static EXTENSION_NAME=Ie;init(){this.extensionName=Ie,this.propertyType="Dispersion",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}},lc=class extends k{static EXTENSION_NAME=Ie;extensionName=Ie;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createDispersion(){return new uc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions.KHR_materials_dispersion){const r=this.createDispersion();e.materials[s].setExtension(Ie,r);const n=t.extensions[Ie];n.extras&&r.setExtras(n.extras),n.dispersion!==void 0&&r.setDispersion(n.dispersion)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Ie);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);o.extensions=o.extensions||{},o.extensions[Ie]=i,i.dispersion=r.getDispersion()}}),this}},fc=class extends j{static EXTENSION_NAME=Ae;init(){this.extensionName=Ae,this.propertyType="EmissiveStrength",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}},hc=class extends k{static EXTENSION_NAME=Ae;extensionName=Ae;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createEmissiveStrength(){return new fc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions.KHR_materials_emissive_strength){const r=this.createEmissiveStrength();e.materials[s].setExtension(Ae,r);const n=t.extensions[Ae];n.extras&&r.setExtras(n.extras),n.emissiveStrength!==void 0&&r.setEmissiveStrength(n.emissiveStrength)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Ae);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);o.extensions=o.extensions||{},o.extensions[Ae]=i,i.emissiveStrength=r.getEmissiveStrength()}}),this}},dc=class extends j{static EXTENSION_NAME=ve;init(){this.extensionName=ve,this.propertyType="IOR",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}},gc=class extends k{static EXTENSION_NAME=ve;extensionName=ve;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createIOR(){return new dc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions.KHR_materials_ior){const r=this.createIOR();e.materials[s].setExtension(ve,r);const n=t.extensions[ve];n.extras&&r.setExtras(n.extras),n.ior!==void 0&&r.setIOR(n.ior)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(ve);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);o.extensions=o.extensions||{},o.extensions[ve]=i,i.ior=r.getIOR()}}),this}};const{R:pc,G:mc}=de;var yc=class extends j{static EXTENSION_NAME=Re;init(){this.extensionName=Re,this.propertyType="Iridescence",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new z(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new z(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:pc})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:mc})}},Tc=class extends k{static EXTENSION_NAME=Re;extensionName=Re;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createIridescence(){return new yc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_iridescence){const i=this.createIridescence();e.materials[o].setExtension(Re,i);const a=n.extensions[Re];if(a.extras&&i.setExtras(a.extras),a.iridescenceFactor!==void 0&&i.setIridescenceFactor(a.iridescenceFactor),a.iridescenceIor!==void 0&&i.setIridescenceIOR(a.iridescenceIor),a.iridescenceThicknessMinimum!==void 0&&i.setIridescenceThicknessMinimum(a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&i.setIridescenceThicknessMaximum(a.iridescenceThicknessMaximum),a.iridescenceTexture!==void 0){const c=a.iridescenceTexture,l=e.textures[r[c.index].source];i.setIridescenceTexture(l),e.setTextureInfo(i.getIridescenceTextureInfo(),c)}if(a.iridescenceThicknessTexture!==void 0){const c=a.iridescenceThicknessTexture,l=e.textures[r[c.index].source];i.setIridescenceThicknessTexture(l),e.setTextureInfo(i.getIridescenceThicknessTextureInfo(),c)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Re);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[Re]=i,r.getIridescenceFactor()>0&&(i.iridescenceFactor=r.getIridescenceFactor()),r.getIridescenceIOR()!==1.3&&(i.iridescenceIor=r.getIridescenceIOR()),r.getIridescenceThicknessMinimum()!==100&&(i.iridescenceThicknessMinimum=r.getIridescenceThicknessMinimum()),r.getIridescenceThicknessMaximum()!==400&&(i.iridescenceThicknessMaximum=r.getIridescenceThicknessMaximum()),r.getIridescenceTexture()){const a=r.getIridescenceTexture(),c=r.getIridescenceTextureInfo();i.iridescenceTexture=e.createTextureInfoDef(a,c)}if(r.getIridescenceThicknessTexture()){const a=r.getIridescenceThicknessTexture(),c=r.getIridescenceThicknessTextureInfo();i.iridescenceThicknessTexture=e.createTextureInfoDef(a,c)}}}),this}};const{R:Sr,G:Nr,B:Mr,A:Cr}=de;var xc=class extends j{static EXTENSION_NAME=we;init(){this.extensionName=we,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new z(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new z(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:Sr|Nr|Mr|Cr,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:Sr|Nr|Mr|Cr})}},Ec=class extends k{static EXTENSION_NAME=we;extensionName=we;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createPBRSpecularGlossiness(){return new xc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_pbrSpecularGlossiness){const i=this.createPBRSpecularGlossiness();e.materials[o].setExtension(we,i);const a=n.extensions[we];if(a.extras&&i.setExtras(a.extras),a.diffuseFactor!==void 0&&i.setDiffuseFactor(a.diffuseFactor),a.specularFactor!==void 0&&i.setSpecularFactor(a.specularFactor),a.glossinessFactor!==void 0&&i.setGlossinessFactor(a.glossinessFactor),a.diffuseTexture!==void 0){const c=a.diffuseTexture,l=e.textures[r[c.index].source];i.setDiffuseTexture(l),e.setTextureInfo(i.getDiffuseTextureInfo(),c)}if(a.specularGlossinessTexture!==void 0){const c=a.specularGlossinessTexture,l=e.textures[r[c.index].source];i.setSpecularGlossinessTexture(l),e.setTextureInfo(i.getSpecularGlossinessTextureInfo(),c)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(we);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[we]=i,i.diffuseFactor=r.getDiffuseFactor(),i.specularFactor=r.getSpecularFactor(),i.glossinessFactor=r.getGlossinessFactor(),r.getDiffuseTexture()){const a=r.getDiffuseTexture(),c=r.getDiffuseTextureInfo();i.diffuseTexture=e.createTextureInfoDef(a,c)}if(r.getSpecularGlossinessTexture()){const a=r.getSpecularGlossinessTexture(),c=r.getSpecularGlossinessTextureInfo();i.specularGlossinessTexture=e.createTextureInfoDef(a,c)}}}),this}};const{R:bc,G:_c,B:Ic,A:Ac}=de;var vc=class extends j{static EXTENSION_NAME=Se;init(){this.extensionName=Se,this.propertyType="Sheen",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new z(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new z(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:bc|_c|Ic,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:Ac})}},Rc=class extends k{static EXTENSION_NAME=Se;extensionName=Se;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createSheen(){return new vc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_sheen){const i=this.createSheen();e.materials[o].setExtension(Se,i);const a=n.extensions[Se];if(a.extras&&i.setExtras(a.extras),a.sheenColorFactor!==void 0&&i.setSheenColorFactor(a.sheenColorFactor),a.sheenRoughnessFactor!==void 0&&i.setSheenRoughnessFactor(a.sheenRoughnessFactor),a.sheenColorTexture!==void 0){const c=a.sheenColorTexture,l=e.textures[r[c.index].source];i.setSheenColorTexture(l),e.setTextureInfo(i.getSheenColorTextureInfo(),c)}if(a.sheenRoughnessTexture!==void 0){const c=a.sheenRoughnessTexture,l=e.textures[r[c.index].source];i.setSheenRoughnessTexture(l),e.setTextureInfo(i.getSheenRoughnessTextureInfo(),c)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Se);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[Se]=i,i.sheenColorFactor=r.getSheenColorFactor(),i.sheenRoughnessFactor=r.getSheenRoughnessFactor(),r.getSheenColorTexture()){const a=r.getSheenColorTexture(),c=r.getSheenColorTextureInfo();i.sheenColorTexture=e.createTextureInfoDef(a,c)}if(r.getSheenRoughnessTexture()){const a=r.getSheenRoughnessTexture(),c=r.getSheenRoughnessTextureInfo();i.sheenRoughnessTexture=e.createTextureInfoDef(a,c)}}}),this}};const{R:wc,G:Sc,B:Nc,A:Mc}=de;var Cc=class extends j{static EXTENSION_NAME=Ne;init(){this.extensionName=Ne,this.propertyType="Specular",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new z(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new z(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:Mc})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:wc|Sc|Nc,isColor:!0})}},Oc=class extends k{static EXTENSION_NAME=Ne;extensionName=Ne;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createSpecular(){return new Cc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_specular){const i=this.createSpecular();e.materials[o].setExtension(Ne,i);const a=n.extensions[Ne];if(a.extras&&i.setExtras(a.extras),a.specularFactor!==void 0&&i.setSpecularFactor(a.specularFactor),a.specularColorFactor!==void 0&&i.setSpecularColorFactor(a.specularColorFactor),a.specularTexture!==void 0){const c=a.specularTexture,l=e.textures[r[c.index].source];i.setSpecularTexture(l),e.setTextureInfo(i.getSpecularTextureInfo(),c)}if(a.specularColorTexture!==void 0){const c=a.specularColorTexture,l=e.textures[r[c.index].source];i.setSpecularColorTexture(l),e.setTextureInfo(i.getSpecularColorTextureInfo(),c)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Ne);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[Ne]=i,r.getSpecularFactor()!==1&&(i.specularFactor=r.getSpecularFactor()),B.eq(r.getSpecularColorFactor(),[1,1,1])||(i.specularColorFactor=r.getSpecularColorFactor()),r.getSpecularTexture()){const a=r.getSpecularTexture(),c=r.getSpecularTextureInfo();i.specularTexture=e.createTextureInfoDef(a,c)}if(r.getSpecularColorTexture()){const a=r.getSpecularColorTexture(),c=r.getSpecularColorTextureInfo();i.specularColorTexture=e.createTextureInfoDef(a,c)}}}),this}};const{R:Dc}=de;var Pc=class extends j{static EXTENSION_NAME=Me;init(){this.extensionName=Me,this.propertyType="Transmission",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new z(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:Dc})}},jc=class extends k{static EXTENSION_NAME=Me;extensionName=Me;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createTransmission(){return new Pc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_transmission){const i=this.createTransmission();e.materials[o].setExtension(Me,i);const a=n.extensions[Me];if(a.extras&&i.setExtras(a.extras),a.transmissionFactor!==void 0&&i.setTransmissionFactor(a.transmissionFactor),a.transmissionTexture!==void 0){const c=a.transmissionTexture,l=e.textures[r[c.index].source];i.setTransmissionTexture(l),e.setTextureInfo(i.getTransmissionTextureInfo(),c)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Me);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[Me]=i,i.transmissionFactor=r.getTransmissionFactor(),r.getTransmissionTexture()){const a=r.getTransmissionTexture(),c=r.getTransmissionTextureInfo();i.transmissionTexture=e.createTextureInfoDef(a,c)}}}),this}},Fc=class extends j{static EXTENSION_NAME=Qe;init(){this.extensionName=Qe,this.propertyType="Unlit",this.parentTypes=[_.MATERIAL]}},Uc=class extends k{static EXTENSION_NAME=Qe;extensionName=Qe;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createUnlit(){return new Fc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions.KHR_materials_unlit&&e.materials[s].setExtension(Qe,this.createUnlit())}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{if(s.getExtension("KHR_materials_unlit")){const r=e.materialIndexMap.get(s),n=t.json.materials[r];n.extensions=n.extensions||{},n.extensions[Qe]={}}}),this}},Bc=class extends j{static EXTENSION_NAME=oe;init(){this.extensionName=oe,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new $})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}},Lc=class extends j{static EXTENSION_NAME=oe;init(){this.extensionName=oe,this.propertyType="MappingList",this.parentTypes=[_.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new $})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}},Or=class extends j{static EXTENSION_NAME=oe;init(){this.extensionName=oe,this.propertyType="Variant",this.parentTypes=["MappingList"]}},Vc=class extends k{extensionName=oe;static EXTENSION_NAME=oe;createMappingList(){return new Lc(this.document.getGraph())}createVariant(e=""){return new Or(this.document.getGraph(),e)}createMapping(){return new Bc(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter(e=>e instanceof Or)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_materials_variants)return this;const s=(t.json.extensions.KHR_materials_variants.variants||[]).map(r=>this.createVariant().setName(r.name||""));return(t.json.meshes||[]).forEach((r,n)=>{const o=e.meshes[n];(r.primitives||[]).forEach((i,a)=>{if(!i.extensions||!i.extensions.KHR_materials_variants)return;const c=this.createMappingList(),l=i.extensions[oe];for(const u of l.mappings){const h=this.createMapping();u.material!==void 0&&h.setMaterial(e.materials[u.material]);for(const f of u.variants||[])h.addVariant(s[f]);c.addMapping(h)}o.listPrimitives()[a].setExtension(oe,c)})}),this}write(e){const t=e.jsonDoc,s=this.listVariants();if(!s.length)return this;const r=[],n=new Map;for(const o of s)n.set(o,r.length),r.push(e.createPropertyDef(o));for(const o of this.document.getRoot().listMeshes()){const i=e.meshIndexMap.get(o);o.listPrimitives().forEach((a,c)=>{const l=a.getExtension(oe);if(!l)return;const u=e.jsonDoc.json.meshes[i].primitives[c],h=l.listMappings().map(f=>{const g=e.createPropertyDef(f),T=f.getMaterial();return T&&(g.material=e.materialIndexMap.get(T)),g.variants=f.listVariants().map(p=>n.get(p)),g});u.extensions=u.extensions||{},u.extensions[oe]={mappings:h}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[oe]={variants:r},this}};const{G:kc}=de;var zc=class extends j{static EXTENSION_NAME=Ce;init(){this.extensionName=Ce,this.propertyType="Volume",this.parentTypes=[_.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new z(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:kc})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}},Gc=class extends k{static EXTENSION_NAME=Ce;extensionName=Ce;prereadTypes=[_.MESH];prewriteTypes=[_.MESH];createVolume(){return new zc(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,s=t.json.materials||[],r=t.json.textures||[];return s.forEach((n,o)=>{if(n.extensions&&n.extensions.KHR_materials_volume){const i=this.createVolume();e.materials[o].setExtension(Ce,i);const a=n.extensions[Ce];if(a.extras&&i.setExtras(a.extras),a.thicknessFactor!==void 0&&i.setThicknessFactor(a.thicknessFactor),a.attenuationDistance!==void 0&&i.setAttenuationDistance(a.attenuationDistance),a.attenuationColor!==void 0&&i.setAttenuationColor(a.attenuationColor),a.thicknessTexture!==void 0){const c=a.thicknessTexture,l=e.textures[r[c.index].source];i.setThicknessTexture(l),e.setTextureInfo(i.getThicknessTextureInfo(),c)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Ce);if(r){const n=e.materialIndexMap.get(s),o=t.json.materials[n],i=e.createPropertyDef(r);if(o.extensions=o.extensions||{},o.extensions[Ce]=i,r.getThicknessFactor()>0&&(i.thicknessFactor=r.getThicknessFactor()),Number.isFinite(r.getAttenuationDistance())&&(i.attenuationDistance=r.getAttenuationDistance()),B.eq(r.getAttenuationColor(),[1,1,1])||(i.attenuationColor=r.getAttenuationColor()),r.getThicknessTexture()){const a=r.getThicknessTexture(),c=r.getThicknessTextureInfo();i.thicknessTexture=e.createTextureInfoDef(a,c)}}}),this}},$c=class extends k{extensionName=pr;static EXTENSION_NAME=pr;read(e){return this}write(e){return this}},jn=class extends k{extensionName=mr;static EXTENSION_NAME=mr;read(e){return this}write(e){return this}},Hc=class extends j{static EXTENSION_NAME=Oe;init(){this.extensionName=Oe,this.propertyType="Visibility",this.parentTypes=[_.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{visible:!0})}getVisible(){return this.get("visible")}setVisible(e){return this.set("visible",e)}},Kc=class extends k{static EXTENSION_NAME=Oe;extensionName=Oe;createVisibility(){return new Hc(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,s)=>{if(t.extensions&&t.extensions.KHR_node_visibility){const r=this.createVisibility();e.nodes[s].setExtension(Oe,r);const n=t.extensions[Oe];n.visible!==void 0&&r.setVisible(n.visible)}}),this}write(e){const t=e.jsonDoc;for(const s of this.document.getRoot().listNodes()){const r=s.getExtension(Oe);if(!r)continue;const n=e.nodeIndexMap.get(s),o=t.json.nodes[n];o.extensions=o.extensions||{},o.extensions[Oe]={visible:r.getVisible()}}return this}};function qc(e){return e.vkFormat>Hs&&e.vkFormat<=_o}function Dr(e){const t=e.vkFormat===Io&&e.dataFormatDescriptor[0].colorModel===167;return e.vkFormat===Hs||t}var Xc=class{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){const t=Dt(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){const t=Dt(e),s=t.dataFormatDescriptor[0];if(qc(t))return s.samples.length;if(Dr(t))switch(s.colorModel){case Sn:return s.samples.length===2&&(s.samples[1].channelType&15)===15?4:3;case Nn:return(s.samples[0].channelType&15)===3?4:3;default:throw new Error(`Unexpected KTX2 colorModel, "${s.colorModel}".`)}throw new Error(`Unexpected KTX2 vkFormat, "${t.vkFormat}".`)}getVRAMByteLength(e){const t=Dt(e);let s=0;if(Dr(t)){const r=this.getChannels(e)>3;for(let n=0;n<t.levels.length;n++){const o=t.levels[n];if(o.uncompressedByteLength)s+=o.uncompressedByteLength;else{const i=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,n))),a=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,n))),c=r?16:8;s+=i/4*(a/4)*c}}}else for(const r of t.levels)t.supercompressionScheme===wn?s+=r.levelData.byteLength:s+=r.uncompressedByteLength;return s}},Fn=class extends k{static EXTENSION_NAME=St;extensionName=St;prereadTypes=[_.TEXTURE];static register(){fe.registerFormat("image/ktx2",new Xc)}preread(e){return e.jsonDoc.json.textures&&e.jsonDoc.json.textures.forEach(t=>{t.extensions&&t.extensions.KHR_texture_basisu&&(t.source=t.extensions[St].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if(s.getMimeType()==="image/ktx2"){const r=e.imageIndexMap.get(s);t.json.textures.forEach(n=>{n.source===r&&(n.extensions=n.extensions||{},n.extensions[St]={source:n.source},delete n.source)})}}),this}},Wc=class extends j{static EXTENSION_NAME=De;init(){this.extensionName=De,this.propertyType="Transform",this.parentTypes=[_.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}},Yc=class extends k{extensionName=De;static EXTENSION_NAME=De;createTransform(){return new Wc(this.document.getGraph())}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions.KHR_texture_transform)continue;const r=this.createTransform(),n=s.extensions[De];n.offset!==void 0&&r.setOffset(n.offset),n.rotation!==void 0&&r.setRotation(n.rotation),n.scale!==void 0&&r.setScale(n.scale),n.texCoord!==void 0&&r.setTexCoord(n.texCoord),t.setExtension(De,r)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[s,r]of t){const n=s.getExtension(De);if(!n)continue;r.extensions=r.extensions||{};const o={},i=B.eq;i(n.getOffset(),[0,0])||(o.offset=n.getOffset()),n.getRotation()!==0&&(o.rotation=n.getRotation()),i(n.getScale(),[1,1])||(o.scale=n.getScale()),n.getTexCoord()!=null&&(o.texCoord=n.getTexCoord()),r.extensions[De]=o}return this}};const Jc=[_.ROOT,_.SCENE,_.NODE,_.MESH,_.MATERIAL,_.TEXTURE,_.ANIMATION];var Qc=class extends j{static EXTENSION_NAME=le;init(){this.extensionName=le,this.propertyType="Packet",this.parentTypes=Jc}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",{...e})}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){const t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);const s={...this.get("properties")};return t?s[e]=t:delete s[e],this.set("properties",s)}toJSONLD(){return{"@context":gs(this.get("context")),...gs(this.get("properties"))}}fromJSONLD(e){e=gs(e);const t=e["@context"];return t&&this.set("context",t),delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw new Error(`${le}: Missing context for term, "${e}".`)}};function gs(e){return JSON.parse(JSON.stringify(e))}var Zc=class extends k{extensionName=le;static EXTENSION_NAME=le;createPacket(){return new Qc(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){const t=e.jsonDoc.json.extensions?.[le];if(!t||!t.packets)return this;const s=e.jsonDoc.json,r=this.document.getRoot(),n=t.packets.map(a=>this.createPacket().fromJSONLD(a)),o=[[s.asset],s.scenes,s.nodes,s.meshes,s.materials,s.images,s.animations],i=[[r],r.listScenes(),r.listNodes(),r.listMeshes(),r.listMaterials(),r.listTextures(),r.listAnimations()];for(let a=0;a<o.length;a++){const c=o[a]||[];for(let l=0;l<c.length;l++){const u=c[l];if(u.extensions&&u.extensions.KHR_xmp_json_ld){const h=u.extensions[le];i[a][l].setExtension(le,n[h.packet])}}}return this}write(e){const{json:t}=e.jsonDoc,s=[];for(const r of this.properties){s.push(r.toJSONLD());for(const n of r.listParents()){let o;switch(n.propertyType){case _.ROOT:o=t.asset;break;case _.SCENE:o=t.scenes[e.sceneIndexMap.get(n)];break;case _.NODE:o=t.nodes[e.nodeIndexMap.get(n)];break;case _.MESH:o=t.meshes[e.meshIndexMap.get(n)];break;case _.MATERIAL:o=t.materials[e.materialIndexMap.get(n)];break;case _.TEXTURE:o=t.images[e.imageIndexMap.get(n)];break;case _.ANIMATION:o=t.animations[e.animationIndexMap.get(n)];break;default:o=null,this.document.getLogger().warn(`[${le}]: Unsupported parent property, "${n.propertyType}"`)}o&&(o.extensions=o.extensions||{},o.extensions[le]={packet:s.length-1})}}return s.length>0&&(t.extensions=t.extensions||{},t.extensions[le]={packets:s}),this}};const eu=[Fa,Ua,jt,Xa,Za,sc,cc,lc,hc,gc,Tc,Ec,Oc,Rc,jc,Uc,Vc,Gc,$c,jn,Kc,Fn,Yc,Zc],tu=[jo,Mo,Pt,oa,Da,ja,...eu];function He(e,t){return Object.defineProperty(t,"name",{value:e}),t}function Ke(e,t){const s={...e};for(const r in t)t[r]!==void 0&&(s[r]=t[r]);return s}function Ks(e){const t=e.getIndices(),s=e.getAttribute("POSITION");switch(e.getMode()){case q.Mode.POINTS:return t?t.getCount():s.getCount();case q.Mode.LINES:return t?t.getCount()/2:s.getCount()/2;case q.Mode.LINE_LOOP:return t?t.getCount():s.getCount();case q.Mode.LINE_STRIP:return t?t.getCount()-1:s.getCount()-1;case q.Mode.TRIANGLES:return t?t.getCount()/3:s.getCount()/3;case q.Mode.TRIANGLE_STRIP:case q.Mode.TRIANGLE_FAN:return t?t.getCount()-2:s.getCount()-2;default:throw new Error("Unexpected mode: "+e.getMode())}}var ps=class{_map=new Map;get size(){return this._map.size}has(e){return this._map.has(e)}add(e,t){let s=this._map.get(e);return s||(s=new Set,this._map.set(e,s)),s.add(t),this}get(e){return this._map.get(e)||new Set}keys(){return this._map.keys()}};const su=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function Pr(e){return su.format(e)}function ru(e,t,s=2){return(e>t?"–":"+")+(Math.abs(e-t)/e*100).toFixed(s)+"%"}function Jt(e,t){return`${Pr(e)} → ${Pr(t)} (${ru(e,t)})`}function yt(e){const t=[];for(const s of e.listAttributes())t.push(s);for(const s of e.listTargets())for(const r of s.listAttributes())t.push(r);return Array.from(new Set(t))}function nu(e,t,s){e.swap(t,s);for(const r of e.listTargets())r.swap(t,s)}function iu(e){const t=e.getIndices(),s=yt(e);e.dispose(),t&&!jr(t)&&t.dispose();for(const r of s)jr(r)||r.dispose()}function ou(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}function Be(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function au(e,t=e){const s=Un(e,t);for(let r=0;r<s.length;r++)s[r]=r;return s}function Un(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function jr(e){return e.listParents().some(t=>t.propertyType!==_.ROOT)}function Bn(e){for(const t in e)return!1;return!0}function cu(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}var kt=typeof Float32Array<"u"?Float32Array:Array;function uu(e,t){var s=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],f=t[10],g=t[11],T=t[12],p=t[13],x=t[14],d=t[15],y=s*a-r*i,m=s*c-n*i,E=s*l-o*i,b=r*c-n*a,I=r*l-o*a,w=n*l-o*c,R=u*p-h*T,v=u*x-f*T,M=u*d-g*T,U=h*x-f*p,L=h*d-g*p,D=f*d-g*x,S=y*D-m*L+E*U+b*M-I*v+w*R;return S?(S=1/S,e[0]=(a*D-c*L+l*U)*S,e[1]=(n*L-r*D-o*U)*S,e[2]=(p*w-x*I+d*b)*S,e[3]=(f*I-h*w-g*b)*S,e[4]=(c*M-i*D-l*v)*S,e[5]=(s*D-n*M+o*v)*S,e[6]=(x*E-T*w-d*m)*S,e[7]=(u*w-f*E+g*m)*S,e[8]=(i*L-a*M+l*R)*S,e[9]=(r*M-s*L-o*R)*S,e[10]=(T*I-p*E+d*y)*S,e[11]=(h*E-u*I-g*y)*S,e[12]=(a*v-i*U-c*R)*S,e[13]=(s*U-r*v+n*R)*S,e[14]=(p*m-T*b-x*y)*S,e[15]=(u*b-h*m+f*y)*S,e):null}function qs(e,t,s){var r=t[0],n=t[1],o=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],h=t[8],f=t[9],g=t[10],T=t[11],p=t[12],x=t[13],d=t[14],y=t[15],m=s[0],E=s[1],b=s[2],I=s[3];return e[0]=m*r+E*a+b*h+I*p,e[1]=m*n+E*c+b*f+I*x,e[2]=m*o+E*l+b*g+I*d,e[3]=m*i+E*u+b*T+I*y,m=s[4],E=s[5],b=s[6],I=s[7],e[4]=m*r+E*a+b*h+I*p,e[5]=m*n+E*c+b*f+I*x,e[6]=m*o+E*l+b*g+I*d,e[7]=m*i+E*u+b*T+I*y,m=s[8],E=s[9],b=s[10],I=s[11],e[8]=m*r+E*a+b*h+I*p,e[9]=m*n+E*c+b*f+I*x,e[10]=m*o+E*l+b*g+I*d,e[11]=m*i+E*u+b*T+I*y,m=s[12],E=s[13],b=s[14],I=s[15],e[12]=m*r+E*a+b*h+I*p,e[13]=m*n+E*c+b*f+I*x,e[14]=m*o+E*l+b*g+I*d,e[15]=m*i+E*u+b*T+I*y,e}function lu(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function fu(e,t,s,r){var n=t[0],o=t[1],i=t[2],a=t[3],c=n+n,l=o+o,u=i+i,h=n*c,f=n*l,g=n*u,T=o*l,p=o*u,x=i*u,d=a*c,y=a*l,m=a*u,E=r[0],b=r[1],I=r[2];return e[0]=(1-(T+x))*E,e[1]=(f+m)*E,e[2]=(g-y)*E,e[3]=0,e[4]=(f-m)*b,e[5]=(1-(h+x))*b,e[6]=(p+d)*b,e[7]=0,e[8]=(g+y)*I,e[9]=(p-d)*I,e[10]=(1-(h+T))*I,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function ms(e,t){return hu(e,t)}function hu(e,t){const s=[],r=[],n=[];e.traverse(l=>{const u=l.getMesh(),h=l.getExtension("EXT_mesh_gpu_instancing");h&&u?(n.push(u),s.push([h.listAttributes()[0].getCount(),u])):u&&(n.push(u),r.push(u))});const o=n.flatMap(l=>l.listPrimitives()).map(l=>l.getAttribute("POSITION")),i=Array.from(new Set(o)),a=Array.from(new Set(n)),c=Array.from(new Set(a.flatMap(l=>l.listPrimitives())));switch(t){case"render":case"render-cached":return Ze(r.map(l=>Ft(l,t)))+Ze(s.map(([l,u])=>l*Ft(u,t)));case"upload-naive":return Ze(a.map(l=>Ft(l,t)));case"upload":return Ze(i.map(l=>l.getCount()));case"distinct":case"distinct-position":return Xs(t);case"unused":return Ln(c);default:return Ws(t)}}function Ft(e,t){const s=e.listPrimitives(),r=Array.from(new Set(s)),n=Array.from(new Set(r.map(o=>o.getAttribute("POSITION"))));switch(t){case"render":case"render-cached":case"upload-naive":return Ze(s.map(o=>pe(o,t)));case"upload":return Ze(n.map(o=>o.getCount()));case"distinct":case"distinct-position":return Xs(t);case"unused":return Ln(r);default:return Ws(t)}}function pe(e,t){const s=e.getAttribute("POSITION"),r=e.getIndices();if(!s)return 0;switch(t){case"render":return r?r.getCount():s.getCount();case"render-cached":return r?new Set(r.getArray()).size:s.getCount();case"upload-naive":case"upload":return s.getCount();case"distinct":case"distinct-position":return Xs(t);case"unused":return r?s.getCount()-new Set(r.getArray()).size:0;default:return Ws(t)}}function Ze(e){let t=0;for(let s=0;s<e.length;s++)t+=e[s];return t}function Ln(e){const t=new Map;for(const r of e){const n=r.getAttribute("POSITION"),o=r.getIndices(),i=t.get(n)||new Set;i.add(o),t.set(n,i)}let s=0;for(const[r,n]of t){if(n.has(null))continue;const o=new Uint8Array(r.getCount());for(const i of n){const a=i.getArray();for(let c=0,l=a.length;c<l;c++)o[a[c]]=1}for(let i=0,a=r.getCount();i<a;i++)o[i]===0&&s++}return s}function Xs(e){throw new Error(`Not implemented: ${e}`)}function Ws(e){throw new Error(`Unexpected value: ${e}`)}const Pe=2**32-1;var du=class{attributes=[];u8;u32;constructor(e){let t=0;for(const s of yt(e))t+=this._initAttribute(s);this.u8=new Uint8Array(t),this.u32=new Uint32Array(this.u8.buffer)}_initAttribute(e){const t=e.getArray(),s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=e.getElementSize()*e.getComponentSize(),n=C.padNumber(r);return this.attributes.push({u8:s,byteStride:r,paddedByteStride:n}),n}hash(e){let t=0;for(const{u8:s,byteStride:r,paddedByteStride:n}of this.attributes){for(let o=0;o<n;o++)o<r?this.u8[t+o]=s[e*r+o]:this.u8[t+o]=0;t+=n}return gu(0,this.u32)}equal(e,t){for(const{u8:s,byteStride:r}of this.attributes)for(let n=0;n<r;n++)if(s[e*r+n]!==s[t*r+n])return!1;return!0}};function gu(e,t){for(let n=0,o=t.length;n<o;n++){let i=t[n];i=Math.imul(i,1540483477)>>>0,i=(i^i>>24)>>>0,i=Math.imul(i,1540483477)>>>0,e=Math.imul(e,1540483477)>>>0,e=(e^i)>>>0}return e}function pu(e,t,s,r,n=Pe){const o=t-1;let i=s.hash(r)&o;for(let a=0;a<=o;a++){const c=e[i];if(c===n||s.equal(c,r))return i;i=i+a+1&o}throw new Error("Hash table full.")}function zt(e,t,s){const r=$e.fromGraph(e.getGraph());(!t||!s)&&([t,s]=mu(e));const n=e.getIndices(),o=n?n.getArray():null,i=pe(e,"render"),a=r.createAccessor(),c=i,l=Un(c,s);for(let h=0;h<c;h++)l[h]=t[o?o[h]:h];e.setIndices(a.setArray(l));const u=yt(e);for(const h of e.listAttributes()){const f=Be(r,h);Gt(h,n,t,f,s),e.swap(h,f)}for(const h of e.listTargets())for(const f of h.listAttributes()){const g=Be(r,f);Gt(f,n,t,g,s),h.swap(f,g)}n&&n.listParents().length===1&&n.dispose();for(const h of u)h.listParents().length===1&&h.dispose();return e}function Gt(e,t,s,r,n){const o=e.getElementSize(),i=e.getArray(),a=t?t.getArray():null,c=t?t.getCount():e.getCount(),l=new i.constructor(n*o),u=new Uint8Array(n);for(let h=0;h<c;h++){const f=a?a[h]:h,g=s[f];if(!u[g]){for(let T=0;T<o;T++)l[g*o+T]=i[f*o+T];u[g]=1}}return r.setArray(l)}function mu(e){const t=pe(e,"upload"),s=e.getIndices(),r=s?s.getArray():null;if(!s||!r)return[au(t,1e6),t];const n=new Uint32Array(t).fill(Pe);let o=0;for(let i=0;i<r.length;i++){const a=r[i];n[a]===Pe&&(n[a]=o++)}return[n,o]}function yu(){var e=new kt(3);return kt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Tu(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e}function Ss(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e}function Ns(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e}function Fr(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function xu(e,t,s){var r=t[0],n=t[1],o=t[2],i=s[3]*r+s[7]*n+s[11]*o+s[15];return i=i||1,e[0]=(s[0]*r+s[4]*n+s[8]*o+s[12])/i,e[1]=(s[1]*r+s[5]*n+s[9]*o+s[13])/i,e[2]=(s[2]*r+s[6]*n+s[10]*o+s[14])/i,e}var Eu=Tu;(function(){var e=yu();return function(t,s,r,n,o,i){var a,c;for(s||(s=3),r||(r=0),n?c=Math.min(n*s+r,t.length):c=t.length,a=r;a<c;a+=s)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],o(e,e,i),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();const Ms="weld",$t={overwrite:!0};function bu(e=$t){const t=Ke($t,e);return He(Ms,async s=>{const r=s.getLogger();if(s.hasExtension("KHR_mesh_primitive_restart"))throw new Error("weld: Missing support for KHR_mesh_primitive_restart.");for(const n of s.getRoot().listMeshes()){for(const o of n.listPrimitives())Ys(o,t),pe(o,"render")===0&&iu(o);n.listPrimitives().length===0&&n.dispose()}r.debug(`${Ms}: Complete.`)})}function Ys(e,t=$t){const s=e.getGraph(),r=$e.fromGraph(s).getLogger(),n={...$t,...t};if(e.getIndices()&&!n.overwrite||e.getMode()===q.Mode.POINTS)return;const o=e.getAttribute("POSITION").getCount(),i=e.getIndices(),a=i?.getArray(),c=i?i.getCount():o,l=new du(e),u=cu(o+o/4),h=new Uint32Array(u).fill(Pe),f=new Uint32Array(o).fill(Pe);let g=0;for(let T=0;T<c;T++){const p=a?a[T]:T;if(f[p]!==Pe)continue;const x=pu(h,u,l,p,Pe),d=h[x];d===Pe?(h[x]=p,f[p]=g++):f[p]=f[d]}r.debug(`${Ms}: ${Jt(o,g)} vertices.`),zt(e,f,g)}const{TRIANGLES:_u,TRIANGLE_STRIP:Iu,TRIANGLE_FAN:Au}=q.Mode;function vu(e){const t=e.getGraph(),s=$e.fromGraph(t);e.getIndices()||Ys(e);const r=e.getIndices(),n=r.getArray(),o=Ks(e),i=pt[r.getComponentType()],a=new i(o*3),c=e.getMode();if(c===Iu)for(let u=0,h=n.length;u<h-2;u++)u%2?(a[u*3]=n[u+1],a[u*3+1]=n[u],a[u*3+2]=n[u+2]):(a[u*3]=n[u],a[u*3+1]=n[u+1],a[u*3+2]=n[u+2]);else if(c===Au)for(let u=0;u<o;u++)a[u*3]=n[0],a[u*3+1]=n[u+1],a[u*3+2]=n[u+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");e.setMode(_u);const l=s.getRoot();r.listParents().some(u=>u!==l&&u!==e)?e.setIndices(Be(s,r).setArray(a)):r.setArray(a)}const Fe="dedup",ys={keepUniqueNames:!1,propertyTypes:[_.ACCESSOR,_.MESH,_.TEXTURE,_.MATERIAL,_.SKIN]};function Ru(e=ys){const t=Ke(ys,e),s=new Set(t.propertyTypes);for(const r of t.propertyTypes)if(!ys.propertyTypes.includes(r))throw new Error(`${Fe}: Unsupported deduplication on type "${r}".`);return He(Fe,r=>{const n=r.getLogger();s.has(_.ACCESSOR)&&wu(r),s.has(_.TEXTURE)&&Nu(r,t),s.has(_.MATERIAL)&&Mu(r,t),s.has(_.MESH)&&Su(r,t),s.has(_.SKIN)&&Cu(r,t),n.debug(`${Fe}: Complete.`)})}function wu(e){const t=e.getLogger(),s=new Map,r=new Map,n=new Map,o=new Map,i=e.getRoot().listMeshes();i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(g=>a(g,r)),a(f.getIndices(),s)})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers())a(f.getInput(),n),a(f.getOutput(),o);function a(h,f){if(!h)return;const g=[h.getCount(),h.getType(),h.getComponentType(),h.getNormalized(),h.getSparse()].join(":");let T=f.get(g);T||f.set(g,T=new Set),T.add(h)}function c(h,f){for(let g=0;g<h.length;g++){const T=h[g],p=C.toView(T.getArray());if(!f.has(T))for(let x=g+1;x<h.length;x++){const d=h[x];f.has(d)||C.equals(p,C.toView(d.getArray()))&&f.set(d,T)}}}let l=0;const u=new Map;for(const h of[r,s,n,o])for(const f of h.values())l+=f.size,c(Array.from(f),u);t.debug(`${Fe}: Merged ${u.size} of ${l} accessors.`),i.forEach(h=>{h.listPrimitives().forEach(f=>{f.listAttributes().forEach(T=>{u.has(T)&&f.swap(T,u.get(T))});const g=f.getIndices();g&&u.has(g)&&f.swap(g,u.get(g))})});for(const h of e.getRoot().listAnimations())for(const f of h.listSamplers()){const g=f.getInput(),T=f.getOutput();g&&u.has(g)&&f.swap(g,u.get(g)),T&&u.has(T)&&f.swap(T,u.get(T))}Array.from(u.keys()).forEach(h=>h.dispose())}function Su(e,t){const s=e.getLogger(),r=e.getRoot(),n=new Map;r.listAccessors().forEach((a,c)=>n.set(a,c)),r.listMaterials().forEach((a,c)=>n.set(a,c));const o=r.listMeshes().length,i=new Map;for(const a of r.listMeshes()){const c=[];for(const u of a.listPrimitives())c.push(Vn(u,n));let l="";if(t.keepUniqueNames&&(l+=a.getName()+";"),l+=c.join(";"),i.has(l)){const u=i.get(l);a.listParents().forEach(h=>{h.propertyType!==_.ROOT&&h.swap(a,u)}),a.dispose()}else i.set(l,a)}s.debug(`${Fe}: Merged ${o-i.size} of ${o} meshes.`)}function Nu(e,t){const s=e.getLogger(),r=e.getRoot(),n=r.listTextures(),o=new Map;for(let i=0;i<n.length;i++){const a=n[i],c=a.getImage();if(!o.has(a))for(let l=i+1;l<n.length;l++){const u=n[l],h=u.getImage();if(o.has(u)||a.getMimeType()!==u.getMimeType()||t.keepUniqueNames&&a.getName()!==u.getName())continue;const f=a.getSize(),g=u.getSize();!f||!g||f[0]===g[0]&&f[1]===g[1]&&(!c||!h||C.equals(c,h)&&o.set(u,a))}}s.debug(`${Fe}: Merged ${o.size} of ${r.listTextures().length} textures.`),Array.from(o.entries()).forEach(([i,a])=>{i.listParents().forEach(c=>{c instanceof it||c.swap(i,a)}),i.dispose()})}function Mu(e,t){const s=e.getLogger(),r=e.getRoot().listMaterials(),n=new Map,o=new Map,i=new Set;t.keepUniqueNames||i.add("name");for(let a=0;a<r.length;a++){const c=r[a];if(!n.has(c)&&!Ur(c,o))for(let l=a+1;l<r.length;l++){const u=r[l];n.has(u)||Ur(u,o)||c.equals(u,i)&&n.set(u,c)}}s.debug(`${Fe}: Merged ${n.size} of ${r.length} materials.`),Array.from(n.entries()).forEach(([a,c])=>{a.listParents().forEach(l=>{l instanceof it||l.swap(a,c)}),a.dispose()})}function Cu(e,t){const s=e.getLogger(),r=e.getRoot().listSkins(),n=new Map,o=new Set(["joints"]);t.keepUniqueNames||o.add("name");for(let i=0;i<r.length;i++){const a=r[i];if(!n.has(a))for(let c=i+1;c<r.length;c++){const l=r[c];n.has(l)||a.equals(l,o)&&ou(a.listJoints(),l.listJoints())&&n.set(l,a)}}s.debug(`${Fe}: Merged ${n.size} of ${r.length} skins.`),Array.from(n.entries()).forEach(([i,a])=>{i.listParents().forEach(c=>{c instanceof it||c.swap(i,a)}),i.dispose()})}function Vn(e,t){const s=[];for(const r of e.listSemantics()){const n=e.getAttribute(r);s.push(r+":"+t.get(n))}if(e instanceof q){const r=e.getIndices();r&&s.push("indices:"+t.get(r));const n=e.getMaterial();n&&s.push("material:"+t.get(n)),s.push("mode:"+e.getMode());for(const o of e.listTargets())s.push("target:"+Vn(o,t))}return s.join(",")}function Ur(e,t){if(t.has(e))return t.get(e);const s=e.getGraph(),r=new Set,n=s.listParentEdges(e);for(;n.length>0;){const o=n.pop();if(o.getAttributes().modifyChild===!0)return t.set(e,!0),!0;const i=o.getChild();if(!r.has(i))for(const a of s.listChildEdges(i))n.push(a)}return t.set(e,!1),!1}function Cs(e,t,s){const r=new Float32Array(e.length);for(let n=0,o=e.length;n<o;n++)s?r[n]=B.decodeNormalizedInt(e[n],t):r[n]=e[n];return r}const{TEXTURE_INFO:gh,ROOT:ph}=_,Ou="draco",Br={method:"edgebreaker",encodeSpeed:5,decodeSpeed:5,quantizePosition:14,quantizeNormal:10,quantizeColor:8,quantizeTexcoord:12,quantizeGeneric:12,quantizationVolume:"mesh"};function Du(e=Br){const t=Ke(Br,e);return He(Ou,async s=>{if(s.hasExtension("KHR_mesh_primitive_restart"))throw new Error("draco: Missing support for KHR_mesh_primitive_restart.");await s.transform(bu()),s.createExtension(jt).setRequired(!0).setEncoderOptions({method:t.method==="edgebreaker"?jt.EncoderMethod.EDGEBREAKER:jt.EncoderMethod.SEQUENTIAL,encodeSpeed:t.encodeSpeed,decodeSpeed:t.decodeSpeed,quantizationBits:{POSITION:t.quantizePosition,NORMAL:t.quantizeNormal,COLOR:t.quantizeColor,TEX_COORD:t.quantizeTexcoord,GENERIC:t.quantizeGeneric},quantizationVolume:t.quantizationVolume})})}function kn(){var e=new kt(4);return kt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Pu(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e}function ju(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e}function Fu(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e[3]=t[3]*s[3],e}function Uu(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e}function Bu(e){var t=e[0],s=e[1],r=e[2],n=e[3];return Math.sqrt(t*t+s*s+r*r+n*n)}var zn=ju,Lu=Fu,Gn=Bu;(function(){var e=kn();return function(t,s,r,n,o,i){var a,c;for(s||(s=4),r||(r=0),n?c=Math.min(n*s+r,t.length):c=t.length,a=r;a<c;a+=s)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],o(e,e,i),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();const Vu=/color|emissive|diffuse/i;function Js(e){return e.getGraph().listParentEdges(e).some(t=>t.getAttributes().isColor||Vu.test(t.getName()))?"srgb":null}function ku(e){const t=e.getGraph(),s=new Set,r=new Set;function n(o){const i=new Set;for(const a of t.listChildEdges(o))a.getChild()instanceof Ge&&i.add(a.getName()+"Info");for(const a of t.listChildEdges(o)){const c=a.getChild();s.has(c)||(s.add(c),c instanceof z&&i.has(a.getName())?r.add(c):c instanceof j&&n(c))}}return n(e),Array.from(r)}function $n(e){const t=$e.fromGraph(e.getGraph()).getRoot(),s=e.getGraph().listParentEdges(e).filter(r=>r.getParent()!==t).map(r=>r.getName());return Array.from(new Set(s))}const et="prune",Os=3/255,Lr={propertyTypes:[_.NODE,_.SKIN,_.MESH,_.CAMERA,_.PRIMITIVE,_.PRIMITIVE_TARGET,_.ANIMATION,_.MATERIAL,_.TEXTURE,_.ACCESSOR,_.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function Qs(e=Lr){const t=Ke(Lr,e),s=new Set(t.propertyTypes),r=t.keepExtras;return He(et,async n=>{const o=n.getLogger(),i=n.getRoot(),a=n.getGraph(),c=new zu,l=u=>c.dispose(u.target);if(a.addEventListener("node:dispose",l),s.has(_.MESH))for(const u of i.listMeshes())u.listPrimitives().length>0||u.dispose();if(s.has(_.NODE)){if(!t.keepLeaves)for(const u of i.listScenes())Hn(a,u,r);for(const u of i.listNodes())ue(u,r)}if(s.has(_.SKIN))for(const u of i.listSkins())ue(u,r);if(s.has(_.MESH))for(const u of i.listMeshes())ue(u,r);if(s.has(_.CAMERA))for(const u of i.listCameras())ue(u,r);if(s.has(_.PRIMITIVE)&&Vr(a,_.PRIMITIVE,r),s.has(_.PRIMITIVE_TARGET)&&Vr(a,_.PRIMITIVE_TARGET,r),!t.keepAttributes&&s.has(_.ACCESSOR)){const u=new Map;for(const h of i.listMeshes())for(const f of h.listPrimitives()){const g=f.getMaterial();if(!g)continue;const T=Gu(f,Kn(n,f,g));kr(f,T),f.listTargets().forEach(p=>kr(p,T)),u.has(g)?u.get(g).add(f):u.set(g,new Set([f]))}for(const[h,f]of u)$u(h,Array.from(f))}if(s.has(_.ANIMATION))for(const u of i.listAnimations()){for(const h of u.listChannels())h.getTargetNode()||h.dispose();if(u.listChannels().length)u.listSamplers().forEach(h=>ue(h,r));else{const h=u.listSamplers();ue(u,r),h.forEach(f=>ue(f,r))}}if(s.has(_.MATERIAL)&&i.listMaterials().forEach(u=>ue(u,r)),s.has(_.TEXTURE)&&(i.listTextures().forEach(u=>ue(u,r)),t.keepSolidTextures||await Hu(n)),s.has(_.ACCESSOR)&&i.listAccessors().forEach(u=>ue(u,r)),s.has(_.BUFFER)&&i.listBuffers().forEach(u=>ue(u,r)),a.removeEventListener("node:dispose",l),c.empty())o.debug(`${et}: No unused properties found.`);else{const u=c.entries().map(([h,f])=>`${h} (${f})`).join(", ");o.info(`${et}: Removed types... ${u}`)}o.debug(`${et}: Complete.`)})}var zu=class{disposed={};empty(){for(const e in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(e){this.disposed[e.propertyType]=this.disposed[e.propertyType]||0,this.disposed[e.propertyType]++}};function ue(e,t){const s=e.listParents().filter(n=>!(n instanceof it||n instanceof mt)),r=t&&!Bn(e.getExtras());!s.length&&!r&&e.dispose()}function Vr(e,t,s){for(const r of e.listEdges()){const n=r.getParent();n.propertyType===t&&ue(n,s)}}function Hn(e,t,s){if(t.listChildren().forEach(i=>Hn(e,i,s)),t instanceof $s)return;const r=e.listParentEdges(t).some(i=>{const a=i.getParent().propertyType;return a!==_.ROOT&&a!==_.SCENE&&a!==_.NODE}),n=e.listChildren(t).length===0,o=s&&!Bn(t.getExtras());n&&!r&&!o&&t.dispose()}function kr(e,t){for(const s of t)e.setAttribute(s,null)}function Gu(e,t){const s=[];for(const r of e.listSemantics())(r==="NORMAL"&&!t.has(r)||r==="TANGENT"&&!t.has(r)||r.startsWith("TEXCOORD_")&&!t.has(r)||r.startsWith("COLOR_")&&r!=="COLOR_0")&&s.push(r);return s}function Kn(e,t,s,r=new Set){const n=e.getGraph().listChildEdges(s),o=new Set;for(const c of n)c.getChild()instanceof Ge&&o.add(c.getName());for(const c of n){const l=c.getName(),u=c.getChild();u instanceof z&&o.has(l.replace(/Info$/,""))&&r.add(`TEXCOORD_${u.getTexCoord()}`),u instanceof Ge&&l.match(/normalTexture/i)&&r.add("TANGENT"),u instanceof j&&Kn(e,t,u,r)}const i=s instanceof nt&&!s.getExtension("KHR_materials_unlit"),a=t.getMode()===q.Mode.POINTS;return i&&!a&&r.add("NORMAL"),r}function $u(e,t){const s=ku(e),r=new Set(s.map(c=>c.getTexCoord())),n=Array.from(r).sort(),o=new Map(n.map((c,l)=>[c,l])),i=new Map(n.map((c,l)=>[`TEXCOORD_${c}`,`TEXCOORD_${l}`]));for(const c of s){const l=c.getTexCoord();c.setTexCoord(o.get(l))}for(const c of t){const l=c.listSemantics().filter(u=>u.startsWith("TEXCOORD_")).sort();a(c,l),c.listTargets().forEach(u=>a(u,l))}function a(c,l){for(const u of l){const h=c.getAttribute(u);if(!h)continue;const f=i.get(u);f!==u&&(c.setAttribute(f,h),c.setAttribute(u,null))}}}async function Hu(e){const t=e.getRoot(),s=e.getGraph(),r=e.getLogger(),n=t.listTextures().map(async o=>{const i=await qu(o);if(!i)return;Js(o)==="srgb"&&mi.convertSRGBToLinear(i,i);const a=o.getName()||o.getURI(),c=o.getSize()?.join("x"),l=$n(o);for(const u of s.listParentEdges(o)){const h=u.getParent();h!==t&&Ku(h,i,u.getName(),r)&&u.dispose()}o.listParents().length===1&&(o.dispose(),r.debug(`${et}: Removed solid-color texture "${a}" (${c}px ${l.join(", ")})`))});await Promise.all(n)}function Ku(e,t,s,r){if(e instanceof nt)switch(s){case"baseColorTexture":return e.setBaseColorFactor(Lu(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(Eu([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Os;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return Gn(zn(kn(),t,[.5,.5,1,1]))<=Os}return r.warn(`${et}: Detected single-color ${s} texture. Pruning ${s} not yet supported.`),!1}async function qu(e){const t=await Xu(e);if(!t)return null;const s=[1/0,1/0,1/0,1/0],r=[-1/0,-1/0,-1/0,-1/0],n=[0,0,0,0],[o,i]=t.shape;for(let a=0;a<o;a++){for(let c=0;c<i;c++)for(let l=0;l<4;l++)s[l]=Math.min(s[l],t.get(a,c,l)),r[l]=Math.max(r[l],t.get(a,c,l));if(Gn(zn(n,r,s))/255>Os)return null}return Uu(n,Pu(n,r,s),.5/255)}async function Xu(e){try{return await ho(e.getImage(),e.getMimeType())}catch{return null}}function Wu(e){return{scenes:Yu(e),meshes:Ju(e),materials:Qu(e),textures:Zu(e),animations:el(e)}}function Yu(e){return{properties:e.getRoot().listScenes().map(t=>{const s=t.listChildren()[0],r=hn(t);return{name:t.getName(),rootName:s?s.getName():"",bboxMin:zr(r.min),bboxMax:zr(r.max),renderVertexCount:ms(t,"render"),uploadVertexCount:ms(t,"upload"),uploadNaiveVertexCount:ms(t,"upload-naive")}})}}function Ju(e){return{properties:e.getRoot().listMeshes().map(t=>{const s=t.listParents().filter(l=>l.propertyType!==_.ROOT).length;let r=0;const n=new Set,o=new Set,i=new Set;t.listPrimitives().forEach(l=>{for(const h of l.listSemantics()){const f=l.getAttribute(h);n.add(h+":"+Gr(f)),i.add(f)}for(const h of l.listTargets())h.listAttributes().forEach(f=>i.add(f));const u=l.getIndices();u&&(o.add(Gr(u)),i.add(u)),r+=Ks(l)});let a=0;Array.from(i).forEach(l=>a+=l.getArray().byteLength);const c=t.listPrimitives().map(l=>tl[l.getMode()]);return{name:t.getName(),mode:Array.from(new Set(c)),meshPrimitives:t.listPrimitives().length,glPrimitives:r,vertices:Ft(t,"upload"),indices:Array.from(o).sort(),attributes:Array.from(n).sort(),instances:s,size:a}})}}function Qu(e){return{properties:e.getRoot().listMaterials().map(t=>{const s=t.listParents().filter(o=>o.propertyType!==_.ROOT).length,r=new Set(t.listExtensions()),n=e.getGraph().listEdges().filter(o=>{const i=o.getChild(),a=o.getParent();return!!(i instanceof Ge&&a===t||i instanceof Ge&&a instanceof j&&r.has(a))}).map(o=>o.getName());return{name:t.getName(),instances:s,textures:n,alphaMode:t.getAlphaMode(),doubleSided:t.getDoubleSided()}})}}function Zu(e){return{properties:e.getRoot().listTextures().map(t=>{const s=t.listParents().filter(i=>i.propertyType!==_.ROOT).length,r=e.getGraph().listParentEdges(t).filter(i=>i.getParent().propertyType!==_.ROOT).map(i=>i.getName()),n=fe.getSize(t.getImage(),t.getMimeType());let o="";if(t.getMimeType()==="image/ktx2"){const i=Dt(t.getImage()).dataFormatDescriptor[0];i.colorModel===Sn?o="ETC1S":i.colorModel===Nn&&(o="UASTC")}return{name:t.getName(),uri:t.getURI(),slots:Array.from(new Set(r)),instances:s,mimeType:t.getMimeType(),compression:o,resolution:n?n.join("x"):"",size:t.getImage().byteLength,gpuSize:fe.getVRAMByteLength(t.getImage(),t.getMimeType())}})}}function el(e){return{properties:e.getRoot().listAnimations().map(t=>{let s=1/0,r=-1/0;t.listSamplers().forEach(a=>{const c=a.getInput();c&&(s=Math.min(s,c.getMin([])[0]),r=Math.max(r,c.getMax([])[0]))});let n=0,o=0;const i=new Set;return t.listSamplers().forEach(a=>{const c=a.getInput(),l=a.getOutput();c&&(o+=c.getCount(),i.add(c),l&&i.add(l))}),Array.from(i).forEach(a=>{n+=a.getArray().byteLength}),{name:t.getName(),channels:t.listChannels().length,samplers:t.listSamplers().length,duration:Math.round((r-s)*1e3)/1e3,keyframes:o,size:n}})}}const tl=["POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN"],sl={Float32Array:"f32",Uint32Array:"u32",Uint16Array:"u16",Uint8Array:"u8",Int32Array:"i32",Int16Array:"i16",Int8Array:"i8"};function zr(e){for(let t=0;t<e.length;t++)e[t].toFixed&&(e[t]=Number(e[t].toFixed(5)));return e}function Gr(e){const t=e.getArray();return(sl[t.constructor.name]||"?")+(e.getNormalized()?"_norm":"")}const{ROOT:mh,NODE:yh,MESH:Th,PRIMITIVE:xh,ACCESSOR:Eh}=_;function rl(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw new Error("Limit must be positive multiple of four.");const s=e.getAttribute("POSITION").getCount(),r=e.listSemantics().filter(l=>l.startsWith("WEIGHTS_")).length,n=new Uint16Array(r*4),o=new Float32Array(r*4),i=new Float32Array(r*4),a=new Uint32Array(r*4),c=new Uint32Array(r*4);for(let l=0;l<s;l++){Ht(e,l,"WEIGHTS",o),Ht(e,l,"JOINTS",a);for(let u=0;u<r*4;u++)n[u]=u;n.sort((u,h)=>o[u]>o[h]?-1:1);for(let u=0;u<n.length;u++)i[u]=o[n[u]],c[u]=a[n[u]];Kt(e,l,"WEIGHTS",i),Kt(e,l,"JOINTS",c)}for(let l=r;l*4>t;l--){const u=e.getAttribute(`WEIGHTS_${l-1}`),h=e.getAttribute(`JOINTS_${l-1}`);e.setAttribute(`WEIGHTS_${l-1}`,null),e.setAttribute(`JOINTS_${l-1}`,null),u.listParents().length===1&&u.dispose(),h.listParents().length===1&&h.dispose()}nl(e)}function nl(e){if(!il(e))return;const t=e.getAttribute("POSITION").getCount(),s=e.listSemantics().filter(h=>h.startsWith("WEIGHTS_")).length,r=e.getAttribute("WEIGHTS_0"),n=r.getArray(),o=r.getComponentType(),i=r.getNormalized(),a=i?o:void 0,c=i?B.decodeNormalizedInt(1,o):Number.EPSILON,l=new Uint32Array(s*4).fill(0),u=n.slice(0,s*4).fill(0);for(let h=0;h<t;h++){Ht(e,h,"JOINTS",l),Ht(e,h,"WEIGHTS",u,a);let f=$r(u,a);if(f!==0&&f!==1){if(Math.abs(1-f)>c)for(let g=0;g<u.length;g++)if(i){const T=B.decodeNormalizedInt(u[g],o);u[g]=B.encodeNormalizedInt(T/f,o)}else u[g]/=f;if(f=$r(u,a),i&&f!==1){for(let g=u.length-1;g>=0;g--)if(u[g]>0){const T=1-f;u[g]+=Math.sign(T)*B.encodeNormalizedInt(Math.abs(T),o);break}}}for(let g=u.length-1;g>=0;g--)u[g]===0&&(l[g]=0);Kt(e,h,"JOINTS",l),Kt(e,h,"WEIGHTS",u,a)}}function Ht(e,t,s,r,n){let o;const i=[0,0,0,0];for(let a=0;o=e.getAttribute(`${s}_${a}`);a++){o.getElement(t,i);for(let c=0;c<4;c++)n?r[a*4+c]=B.encodeNormalizedInt(i[c],n):r[a*4+c]=i[c]}return r}function Kt(e,t,s,r,n){let o;const i=[0,0,0,0];for(let a=0;o=e.getAttribute(`${s}_${a}`);a++){for(let c=0;c<4;c++)n?i[c]=B.decodeNormalizedInt(r[a*4+c],n):i[c]=r[a*4+c];o.setElement(t,i)}}function $r(e,t){let s=0;for(let r=0;r<e.length;r++)t?s+=B.decodeNormalizedInt(e[r],t):s+=e[r];return s}function il(e){const t=e.listSemantics().filter(n=>n.startsWith("WEIGHTS_")).map(n=>e.getAttribute(n)),s=t.map(n=>n.getNormalized()),r=t.map(n=>n.getComponentType());return new Set(s).size===1&&new Set(r).size===1}const je="quantize",ol=[Int8Array,Int16Array,Int32Array],{TRANSLATION:al,ROTATION:cl,SCALE:ul,WEIGHTS:ll}=mt.TargetPath,fl=[al,cl,ul],Ut={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};function hl(e=Ut){const t=Ke(Ut,{patternTargets:e.pattern||Ut.pattern,...e});return He(je,async s=>{const r=s.getLogger(),n=s.getRoot();if(s.hasExtension("KHR_mesh_primitive_restart"))throw new Error("quantize: Missing support for KHR_mesh_primitive_restart.");let o;t.quantizationVolume==="scene"&&(o=Kr(El(n.listMeshes().map(qr))));for(const i of s.getRoot().listMeshes()){t.quantizationVolume==="mesh"&&(o=Kr(qr(i))),o&&t.pattern.test("POSITION")&&(dl(s,i,o),ml(i,1/o.scale));for(const a of i.listPrimitives()){pe(a,"render")<pe(a,"upload")/2&&zt(a),Hr(s,a,o,t);for(const c of a.listTargets())Hr(s,c,o,t)}}n.listMeshes().flatMap(i=>i.listPrimitives()).some(qn)&&s.createExtension(jn).setRequired(!0),t.cleanup&&await s.transform(Qs({propertyTypes:[_.ACCESSOR,_.SKIN,_.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),Ru({propertyTypes:[_.ACCESSOR,_.MATERIAL,_.SKIN],keepUniqueNames:!0})),r.debug(`${je}: Complete.`)})}function Hr(e,t,s,r){const n=t instanceof An,o=e.getLogger();for(const i of t.listSemantics()){if(!n&&!r.pattern.test(i)||n&&!r.patternTargets.test(i))continue;const a=t.getAttribute(i),{bits:c,ctor:l}=Tl(i,a,o,r);if(!l)continue;if(c<8||c>16)throw new Error(`${je}: Requires bits = 8–16.`);if(a.getComponentSize()<=c/8)continue;const u=a.clone();if(i==="POSITION"){const h=s.scale,f=[];t instanceof q?uu(f,Qt(s)):lu(f,[1/h,1/h,1/h]);for(let g=0,T=[0,0,0],p=u.getCount();g<p;g++)u.getElement(g,T),u.setElement(g,xu(T,T,f))}yl(u,l,c),t.setAttribute(i,u)}if(r.normalizeWeights&&t.getAttribute("WEIGHTS_0")&&rl(t,1/0),t instanceof q&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){const i=t.getIndices();i.setArray(new Uint16Array(i.getArray()))}}function Kr(e){const{min:t,max:s}=e,r=Math.max((s[0]-t[0])/2,(s[1]-t[1])/2,(s[2]-t[2])/2);return{offset:[t[0]+(s[0]-t[0])/2,t[1]+(s[1]-t[1])/2,t[2]+(s[2]-t[2])/2],scale:r}}function dl(e,t,s){const r=Qt(s);for(const n of t.listParents()){if(!(n instanceof Gs))continue;const o=n.listParents().filter(f=>f instanceof mt),i=o.some(f=>fl.includes(f.getTargetPath())),a=n.listChildren().length>0,c=n.getSkin();if(c){n.setSkin(gl(c,s));continue}const l=n.getExtension("EXT_mesh_gpu_instancing");if(l){n.setExtension("EXT_mesh_gpu_instancing",pl(e,l,s));continue}let u;a||i?(u=e.createNode("").setMesh(t),n.addChild(u).setMesh(null),o.filter(f=>f.getTargetPath()===ll).forEach(f=>f.setTargetNode(u))):u=n;const h=u.getMatrix();qs(h,h,r),u.setMatrix(h)}}function gl(e,t){e=e.clone();const s=Qt(t),r=e.getInverseBindMatrices().clone(),n=[];for(let o=0,i=r.getCount();o<i;o++)r.getElement(o,n),qs(n,n,s),r.setElement(o,n);return e.setInverseBindMatrices(r)}function pl(e,t,s){if(!t.getAttribute("TRANSLATION")&&!t.getAttribute("ROTATION")&&!t.getAttribute("SCALE"))return t;t=t.clone();let r=t.getAttribute("TRANSLATION")?.clone();const n=t.getAttribute("ROTATION")?.clone();let o=t.getAttribute("SCALE")?.clone();const i=r||n||o,a=[0,0,0],c=[0,0,0,1],l=[1,1,1];!r&&s.offset&&(r=e.createAccessor().setType("VEC3").setArray(Wr(i.getCount(),a))),!o&&s.scale&&(o=e.createAccessor().setType("VEC3").setArray(Wr(i.getCount(),l)));const u=[0,0,0],h=[0,0,0,1],f=[1,1,1],g=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],T=Qt(s);for(let p=0,x=i.getCount();p<x;p++)B.compose(r?r.getElement(p,u):a,n?n.getElement(p,h):c,o?o.getElement(p,f):l,g),qs(g,g,T),B.decompose(g,u,h,f),r&&r.setElement(p,u),n&&n.setElement(p,h),o&&o.setElement(p,f);return r&&t.setAttribute("TRANSLATION",r),n&&t.setAttribute("ROTATION",n),o&&t.setAttribute("SCALE",o),t}function ml(e,t){for(const s of e.listPrimitives()){let r=s.getMaterial();if(!r)continue;let n=r.getExtension("KHR_materials_volume");!n||n.getThicknessFactor()<=0||(n=n.clone().setThicknessFactor(n.getThicknessFactor()*t),r=r.clone().setExtension("KHR_materials_volume",n),s.setMaterial(r))}}function yl(e,t,s){const r=new t(e.getArray().length),n=ol.includes(t)?1:0,o=s-n,i=t.BYTES_PER_ELEMENT*8-n,a=Math.pow(2,o)-1,c=i-o,l=2*o-i,u=[n>0?-1:0,1];for(let h=0,f=0,g=[];h<e.getCount();h++){e.getElement(h,g);for(let T=0;T<g.length;T++){let p=bl(g[T],u);p=Math.round(Math.abs(p)*a),p=p<<c|p>>l,r[f++]=p*Math.sign(g[T])}}e.setArray(r).setNormalized(!0).setSparse(!1)}function Tl(e,t,s,r){const n=t.getMinNormalized([]),o=t.getMaxNormalized([]);let i,a;if(e==="POSITION")i=r.quantizePosition,a=i<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")i=r.quantizeNormal,a=i<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))i=r.quantizeColor,a=i<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(n.some(c=>c<0)||o.some(c=>c>1))return s.warn(`${je}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=r.quantizeTexcoord,a=i<=8?Uint8Array:Uint16Array}else{if(e.startsWith("JOINTS_"))return i=Math.max(...t.getMax([]))<=255?8:16,a=i<=8?Uint8Array:Uint16Array,t.getComponentSize()>i/8&&t.setArray(new a(t.getArray())),{bits:-1};if(e.startsWith("WEIGHTS_")){if(n.some(c=>c<0)||o.some(c=>c>1))return s.warn(`${je}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=r.quantizeWeight,a=i<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(n.some(c=>c<-1)||o.some(c=>c>1))return s.warn(`${je}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};i=r.quantizeGeneric,a=n.some(c=>c<0)?a=i<=8?Int8Array:Int16Array:a=i<=8?Uint8Array:Uint16Array}else throw new Error(`${je}: Unexpected semantic, "${e}".`)}return{bits:i,ctor:a}}function qr(e){const t=[],s=[];for(const n of e.listPrimitives()){const o=n.getAttribute("POSITION");o&&t.push(o);for(const i of n.listTargets()){const a=i.getAttribute("POSITION");a&&s.push(a)}}if(t.length===0)throw new Error(`${je}: Missing "POSITION" attribute.`);const r=Xr(t,3);if(s.length>0){const{min:n,max:o}=Xr(s,3);Ss(r.min,r.min,Ss(n,Fr(n,n,2),[0,0,0])),Ns(r.max,r.max,Ns(o,Fr(o,o,2),[0,0,0]))}return r}function xl(e,t){const s=t.getComponentSize();if(e==="POSITION"||e==="NORMAL"||e==="TANGENT")return s<4;if(e.startsWith("TEXCOORD_")){const r=t.getComponentType(),n=t.getNormalized();return s<4&&!(n&&r===N.ComponentType.UNSIGNED_BYTE)&&!(n&&r===N.ComponentType.UNSIGNED_SHORT)}return!1}function qn(e){for(const t of e.listSemantics())if(xl(t,e.getAttribute("POSITION")))return!0;return e.propertyType===_.PRIMITIVE?e.listTargets().some(qn):!1}function Xr(e,t){const s=new Array(t).fill(1/0),r=new Array(t).fill(-1/0),n=[],o=[];for(const i of e){i.getMinNormalized(n),i.getMaxNormalized(o);for(let a=0;a<t;a++)s[a]=Math.min(s[a],n[a]),r[a]=Math.max(r[a],o[a])}return{min:s,max:r}}function El(e){const t=e[0];for(const s of e)Ss(t.min,t.min,s.min),Ns(t.max,t.max,s.max);return t}function Qt(e){return fu([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function bl(e,t){return Math.min(Math.max(e,t[0]),t[1])}function Wr(e,t){const s=t.length,r=new Float32Array(e*s);for(let n=0;n<e;n++)r.set(t,n*s);return r}const Nt="reorder",_l={target:"size",cleanup:!0};function Il(e){const t=Ke(_l,e),s=t.encoder;if(!s)throw new Error(`${Nt}: encoder dependency required — install "meshoptimizer".`);return He(Nt,async r=>{const n=r.getLogger();if(r.hasExtension("KHR_mesh_primitive_restart"))throw new Error("reorder: Missing support for KHR_mesh_primitive_restart.");await s.ready;const o=Al(r);for(const i of o.indicesToAttributes.keys()){let a=i.getArray();a instanceof Uint32Array?a=a.slice():a=new Uint32Array(a);const[c,l]=s.reorderMesh(a,o.indicesToMode.get(i)===q.Mode.TRIANGLES,t.target==="size"),u=Be(r,i);u.setArray(l<=65534?new Uint16Array(a):a);for(const h of o.indicesToAttributes.get(i)){const f=Be(r,h);Gt(h,i,c,f,l);for(const g of o.indicesToPrimitives.get(i)){g.getIndices()===i&&g.swap(i,u),g.swap(h,f);for(const T of g.listTargets())T.swap(h,f)}}}t.cleanup&&await r.transform(Qs({propertyTypes:[_.ACCESSOR],keepAttributes:!0,keepIndices:!0})),o.indicesToAttributes.size?n.debug(`${Nt}: Complete.`):n.warn(`${Nt}: No qualifying primitives found; may need to weld first.`)})}function Al(e){const t=new Map,s=new ps,r=new ps,n=new ps;for(const o of e.getRoot().listMeshes())for(const i of o.listPrimitives()){const a=i.getIndices();if(a){t.set(a,i.getMode()),s.add(a,i);for(const c of yt(i))r.add(a,c),n.add(c,i)}}return{indicesToPrimitives:s,indicesToAttributes:r,indicesToMode:t,attributesToPrimitives:n}}const vl={level:"high",...Ut},Yr="meshopt";function Rl(e){const t=Ke(vl,e),s=t.encoder;if(!s)throw new Error(`${Yr}: encoder dependency required — install "meshoptimizer".`);return He(Yr,async r=>{let n,o,i=t.quantizeNormal;if(r.getRoot().listAccessors().length!==0){if(r.hasExtension("KHR_mesh_primitive_restart"))throw new Error("meshopt: Missing support for KHR_mesh_primitive_restart.");t.level==="medium"?(n=/.*/,o=/.*/):(n=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR)(_\d+)?$/,o=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR|NORMAL|TANGENT)(_\d+)?$/,i=Math.min(i,8)),await r.transform(Il({encoder:s,target:"size"}),hl({...t,pattern:n,patternTargets:o,quantizeNormal:i})),r.createExtension(Pt).setRequired(!0).setEncoderOptions({method:t.level==="medium"?Pt.EncoderMethod.QUANTIZE:Pt.EncoderMethod.FILTER})}})}const wl="unweld";function Sl(e,t=new Map){const s=e.getIndices();if(!s)return;const r=e.getGraph(),n=$e.fromGraph(r),o=n.getLogger(),i=e.getAttribute("POSITION").getCount();for(const c of e.listAttributes())e.swap(c,Jr(n,c,s,t)),c.listParents().length===1&&c.dispose();for(const c of e.listTargets())for(const l of c.listAttributes())c.swap(l,Jr(n,l,s,t)),l.listParents().length===1&&l.dispose();const a=e.getAttribute("POSITION").getCount();o.debug(`${wl}: ${Jt(i,a)} vertices.`),e.setIndices(null),s.listParents().length===1&&s.dispose()}function Jr(e,t,s,r){if(r.has(t)&&r.get(t).has(s))return r.get(t).get(s);const n=t.getArray(),o=n.constructor,i=new o(s.getCount()*t.getElementSize()),a=s.getArray(),c=t.getElementSize();for(let u=0,h=s.getCount();u<h;u++)for(let f=0;f<c;f++)i[u*c+f]=n[a[u]*c+f];r.has(t)||r.set(t,new Map);const l=Be(e,t).setArray(i);return r.get(t).set(s,l),l}var Qr;(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(Qr||(Qr={}));Promise.resolve();const Ds="simplify",{POINTS:Nl,LINES:Ml,LINE_STRIP:Cl,LINE_LOOP:Ol,TRIANGLE_STRIP:Dl,TRIANGLE_FAN:Pl}=q.Mode,jl={ratio:0,error:1e-4,lockBorder:!1};function Fl(e,t){const s={...jl,...t},r=s.simplifier,n=e.getGraph(),o=$e.fromGraph(n),i=o.getLogger();switch(e.getMode()){case Nl:return Ul(o,e,s);case Ml:case Cl:case Ol:return i.warn(`${Ds}: Skipping primitive simplification: Unsupported draw mode.`),e;case Dl:case Pl:vu(e)}const a=pe(e,"upload"),c=pe(e,"render");c<a/2&&zt(e);const l=e.getAttribute("POSITION"),u=e.getIndices();let h=l.getArray(),f=u.getArray();h instanceof Float32Array||(h=Cs(h,l.getComponentType(),l.getNormalized())),f instanceof Uint32Array||(f=new Uint32Array(f));const g=Math.floor(s.ratio*c/3)*3,[T,p]=r.simplify(f,h,3,g,s.error,s.lockBorder?["LockBorder"]:[]);e.setIndices(Be(o,u).setArray(T)),u.listParents().length===1&&u.dispose(),zt(e);const x=pe(e,"upload");return x<=65534&&e.getIndices().setArray(new Uint16Array(e.getIndices().getArray())),i.debug(`${Ds}: ${Jt(a,x)} vertices, error: ${p.toFixed(4)}.`),e}function Ul(e,t,s){const r=s.simplifier,n=e.getLogger();t.getIndices()&&Sl(t);const o=t.getAttribute("POSITION"),i=t.getAttribute("COLOR_0"),a=o.getCount();let c=o.getArray(),l=i?i.getArray():void 0;const u=i?i.getComponentSize():void 0;c instanceof Float32Array||(c=Cs(c,o.getComponentType(),o.getNormalized())),l&&!(l instanceof Float32Array)&&(l=Cs(l,o.getComponentType(),o.getNormalized()));const h=Math.floor(s.ratio*a),f=r.simplifyPoints(c,3,h,l,u),[g,T]=r.compactMesh(f);n.debug(`${Ds}: ${Jt(o.getCount(),T)} vertices.`);for(const p of yt(t)){const x=Be(e,p);Gt(p,null,g,x,T),nu(t,p,x),p.listParents().length===1&&p.dispose()}return t}const Bl="/assets/draco_decoder-DsQ12WqX.wasm",Ll="/assets/draco_encoder-2Tcju8Ns.wasm",Ps="/jsm/libs/basis-encoder/";let Ts=null;async function Zr(e){const t=`${Ps}${e}`,s=await fetch(t);if(!s.ok)throw new Error(`The Basis Universal encoder is not being served at ${t} (HTTP ${s.status}). It is vendored under public${Ps} and pinned in vendor/upstream-assets.lock.json.`);return s}function Vl(e){return new Proxy({},{get(t,s){throw new Error(`The vendored Basis encoder reached for require('${e}').${String(s)} — it is loaded with an explicit wasmBinary and must never load anything itself.`)}})}async function en(e){const s=await new Function("require","__dirname","__filename",`${e.glue}
22
- ;return BASIS;`)(Vl,"","")({wasmBinary:e.wasmBinary});return s.initializeBasis(),s}function kl(e){return Ts||(Ts=e?en(e):(async()=>{const[t,s]=await Promise.all([Zr("basis_encoder.js"),Zr("basis_encoder.wasm")]);return en({glue:await t.text(),wasmBinary:new Uint8Array(await s.arrayBuffer())})})()),Ts}let xs=null;function Ye(e,t){const s=e instanceof Error?e.message:String(e);return{available:!1,reason:`${t} failed to load: ${s}`}}function ot(){return xs||(xs=zl()),xs}async function zl(){const e=new eo().registerExtensions(tu),t={};let s={available:!0},r={available:!0},n={available:!0};try{const a=await ft(()=>import("./index-BMxv2MNV.js"),[]);await Promise.all([a.MeshoptDecoder.ready,a.MeshoptEncoder.ready,a.MeshoptSimplifier.ready]),t["meshopt.decoder"]=a.MeshoptDecoder,t["meshopt.encoder"]=a.MeshoptEncoder}catch(a){s=Ye(a,"meshoptimizer decoder"),r=Ye(a,"meshoptimizer encoder"),n=Ye(a,"meshoptimizer simplifier")}let o={available:!0},i={available:!0};try{const a=(await ft(async()=>{const{default:c}=await import("./draco3d-DyZllcka.js").then(l=>l.d);return{default:c}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).default;t["draco3d.decoder"]=await a.createDecoderModule({locateFile:c=>c.endsWith(".wasm")?Bl:c})}catch(a){o=Ye(a,"draco3d decoder")}try{const a=(await ft(async()=>{const{default:c}=await import("./draco3d-DyZllcka.js").then(l=>l.d);return{default:c}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).default;t["draco3d.encoder"]=await a.createEncoderModule({locateFile:c=>c.endsWith(".wasm")?Ll:c})}catch(a){i=Ye(a,"draco3d encoder")}return e.registerDependencies(t),{io:e,capabilities:{meshoptDecoder:s,meshoptEncoder:r,meshoptSimplifier:n,dracoDecoder:o,dracoEncoder:i,ktx2Encoder:await Gl()}}}async function Gl(){const e=`${Ps}basis_encoder.wasm`;try{const t=await fetch(e,{method:"HEAD"});return t.ok?{available:!0}:{available:!1,reason:`The Basis Universal encoder is not being served at ${e} (HTTP ${t.status}).`}}catch(t){return Ye(t,`the Basis Universal encoder at ${e}`)}}async function $l(){const e=await ft(()=>import("./index-BMxv2MNV.js"),[]);return await e.MeshoptSimplifier.ready,e.MeshoptSimplifier}function Hl(e,t){return e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71||e.length<24?null:{width:t.getUint32(16),height:t.getUint32(20)}}function Kl(e,t){if(e[0]!==255||e[1]!==216)return null;let s=2;for(;s+9<e.length;){if(e[s]!==255)return null;const r=e[s+1];if(r>=192&&r<=207&&r!==196&&r!==200&&r!==204)return{width:t.getUint16(s+7),height:t.getUint16(s+5)};s+=2+t.getUint16(s+2)}return null}function ql(e,t){return e[0]!==71||e[1]!==73||e[2]!==70?null:{width:t.getUint16(6,!0),height:t.getUint16(8,!0)}}function Xl(e,t){const s=(r,n)=>n.split("").every((o,i)=>e[r+i]===o.charCodeAt(0));if(!s(0,"RIFF")||!s(8,"WEBP")||e.length<30)return null;if(s(12,"VP8 "))return{width:t.getUint16(26,!0)&16383,height:t.getUint16(28,!0)&16383};if(s(12,"VP8L")){const r=e[21],n=e[22],o=e[23],i=e[24];return{width:1+((n&63)<<8|r),height:1+((i&15)<<10|o<<2|(n&192)>>6)}}return null}function Wl(e){if(e.length<16)return null;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);for(const s of[Hl,Kl,ql,Xl]){const r=s(e,t);if(r)return r}return null}function Yl(e){return Math.ceil(e.width*e.height*4*(4/3))}const Jl=/\.(png|jpe?g|webp|gif|svg|ktx2|basis|bmp|avif)$/i,Ql=/\.(mp3|wav|ogg|m4a|aac|flac|opus)$/i,Zl=/\.(glb|gltf)$/i;function Xn(e){const t=e.toLowerCase();return Zl.test(t)?"model":Jl.test(t)?"image":Ql.test(t)?"audio":t.endsWith(".json")||t.endsWith(".bin")?"data":"other"}function tt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ef(e){const t=tt(e),s=tt(t?.operation),r=t?.createdAt,n=s?.name,o=t?.outputs;if(typeof r!="string"||typeof n!="string"||!Array.isArray(o))return null;const i=o.flatMap(a=>{const c=tt(a)?.path;return typeof c=="string"?[Zt(c)]:[]});return{stamp:{operationName:n,createdAt:r},paths:i}}function tf(e){const t=new Map,s=tt(tt(e)?.operations);if(!s)return t;for(const[r,n]of Object.entries(s)){const o=ef(n);if(o)for(const i of o.paths){const a=t.get(i);(!a||o.stamp.createdAt.localeCompare(a.createdAt)>0)&&t.set(i,{operationId:r,...o.stamp})}}return t}function sf(e){return/(?:^|\/)jsm\//i.test(e)}const rf=/\.(?:tsx?|jsx?|mjs|cjs)$/i,nf="volter.project.json";function of(e){return(e.split("/").pop()??e)===nf}function js(e,t="$"){if(typeof e=="string")return[{path:t,value:e}];if(Array.isArray(e))return e.flatMap((r,n)=>js(r,`${t}[${n}]`));const s=tt(e);return s?Object.entries(s).flatMap(([r,n])=>js(n,`${t}.${r}`)):[]}function Zt(e){return e.split(/[?#]/,1)[0].replace(/^\.\//,"").replace(/^\/+/,"")}class af{keyToPath=new Map;referencesByPath=new Map;constructor(t){for(const s of t)this.keyToPath.set(s.path,s.path),s.path.startsWith("public/")&&this.keyToPath.set(s.path.slice(7),s.path)}resolve(t){return this.keyToPath.get(Zt(t))}add(t,s){const r=this.referencesByPath.get(t)??[];r.some(n=>n.ownerPath===s.ownerPath&&n.jsonPath===s.jsonPath)||(r.push(s),this.referencesByPath.set(t,r))}referencesOf(t){return this.referencesByPath.get(t)??[]}}async function cf(e,t,s){if(!of(t.path))return;let r;try{r=JSON.parse(await e.readText(t.path))}catch{return}for(const n of js(r)){const o=s.resolve(n.value);o&&o!==t.path&&s.add(o,{ownerPath:t.path,kind:"manifest",jsonPath:n.path})}}async function uf(e,t){for(const s of[...e.files,...e.ownerFiles??[]])await cf(e,s,t)}async function lf(e,t){const s=e.files.filter(r=>!r.path.startsWith("public/")&&rf.test(r.path));for(const r of s){let n;try{n=await e.readText(r.path)}catch{continue}for(const[o,i]of t.keyToPath)o.length>4&&n.includes(o)&&t.add(i,{ownerPath:r.path,kind:"code"})}}function ff(e,t){const s=t.includes("/")?t.slice(0,t.lastIndexOf("/")+1):"";return[...e.buffers??[],...e.images??[]].flatMap(({uri:r})=>r&&!r.startsWith("data:")?[`${s}${decodeURIComponent(r)}`]:[])}async function hf(e,t,s){for(const r of t)if(/\.gltf$/i.test(r.path))try{const n=JSON.parse(await e.readText(r.path));for(const o of ff(n,r.path)){const i=s.resolve(o);i&&s.add(i,{ownerPath:r.path,kind:"asset"})}}catch{}}const df=new Set(["node_modules",".git","dist","build",".volter",".ci-scaffold","coverage","test-results","playwright-report"]);async function gf(e){const t=[],s=async n=>{const o=await e.list(n);for(const i of o){const a=n?`${n}/${i.name}`:i.name;i.type==="dir"?df.has(i.name)||await s(a):t.push({path:a,size:i.size??0})}};if(await s(""),Vs(e)){const n=[],o=new Map;try{const a=await fetch("/volter.project.json");if(a.ok){const c=await a.text();o.set("volter.project.json",c),n.push({path:"volter.project.json",size:c.length})}}catch{}let i=null;try{const a=await fetch(`/__editor/volter-file?${new URLSearchParams({path:".volter/provenance.json"})}`);a.ok&&(i=JSON.parse(await a.text()))}catch{i=null}return{files:t,ownerFiles:n,servingRooted:!0,codeReferencesScannable:!1,provenance:i,readBytes:a=>e.readBytes(a),readText:a=>{const c=o.get(Zt(a));return c!==void 0?Promise.resolve(c):e.read(a)}}}let r=null;try{await e.exists(".volter/provenance.json")&&(r=JSON.parse(await e.read(".volter/provenance.json")))}catch{r=null}return{files:t,codeReferencesScannable:!0,provenance:r,readBytes:n=>e.readBytes(n),readText:n=>e.read(n)}}async function pf(e,t,s){const{io:r}=await ot();if(/\.glb$/i.test(e))return r.readBinary(new Uint8Array(t));const n=JSON.parse(new TextDecoder().decode(t)),o={},i=e.includes("/")?e.slice(0,e.lastIndexOf("/")+1):"";for(const{uri:a}of[...n.buffers??[],...n.images??[]])a&&!a.startsWith("data:")&&(o[a]=new Uint8Array(await s.readBytes(`${i}${decodeURIComponent(a)}`)));return r.readJSON({json:n,resources:o})}async function mf(e,t,s){try{const r=await pf(e,t,s),n=Wu(r),o=n.meshes.properties,i=n.textures.properties,a=o.reduce((u,h)=>u+h.size,0),c=i.reduce((u,h)=>u+(h.gpuSize??0),0),l=new Set;for(const u of r.getRoot().listNodes())u.getName()&&u.getMesh()&&!u.getSkin()&&l.add(u.getName());return{model:{meshCount:o.length,materialCount:n.materials.properties.length,textureCount:i.length,animationCount:n.animations.properties.length,glPrimitives:o.reduce((u,h)=>u+h.glPrimitives,0),vertices:o.reduce((u,h)=>u+h.vertices,0),geometryBytes:a,textureGpuBytes:c,unknownTextureCount:i.filter(u=>u.gpuSize===null).length,vramBytes:a+c,textures:i.map(u=>({name:u.name||u.uri,mimeType:u.mimeType,resolution:u.resolution,slots:u.slots,bytes:u.size,gpuBytes:u.gpuSize})),meshNames:[...l]}}}catch(r){return{inspectError:r instanceof Error?r.message:String(r)}}}function yf(e,t){if(t||e.startsWith("public/")||/\.inputmap\.json$/i.test(e))return!0;if(e.startsWith("src/")||e.startsWith("server/")||!e.includes("/"))return!1;const s=Xn(e);return s==="model"||s==="image"||s==="audio"}const Tf=new Set(["model","image","audio","data","other"]),xf=new Set(["model","image","audio"]);function tn(e,t){return t?`/${e}`:e.startsWith("public/")?`/${e.slice(7)}`:null}function Ef(e,t){const s=Zt(t),r=s.startsWith("public/")?s.slice(7):`public/${s}`;return e.get(s)??e.get(r)}async function bf(e,t,s,r){const n=Xn(e.path),o=t.servingRooted===!0,i=sf(e.path);let a;try{a=await t.readBytes(e.path)}catch(f){return{path:e.path,servingPath:tn(e.path,o),category:n,bytes:e.size,sha256:"",inspectError:`unreadable: ${f instanceof Error?f.message:String(f)}`,references:s.referencesOf(e.path),...i?{engineVendored:i}:{}}}let c,l,u;if(n==="model")({model:c,inspectError:u}=await mf(e.path,a,t));else if(n==="image"){const f=Wl(a);f&&(l={...f,gpuBytes:Yl(f)})}const h=Ef(r,e.path);return{path:e.path,servingPath:tn(e.path,o),category:n,bytes:a.byteLength,sha256:await on(a),...c?{model:c}:{},...l?{image:l}:{},...u?{inspectError:u}:{},references:s.referencesOf(e.path),...h?{provenance:h}:{},...i?{engineVendored:i}:{}}}function Wn(e){return e.model?.vramBytes??e.image?.gpuBytes??0}function _f(e){const t=new Map;for(const s of e){const r=t.get(s.category)??{count:0,bytes:0,vram:0};r.count+=1,r.bytes+=s.bytes,r.vram+=Wn(s),t.set(s.category,r)}return[...t.entries()].map(([s,r])=>({category:s,count:r.count,bytes:r.bytes,vramBytes:r.vram})).sort((s,r)=>r.bytes-s.bytes)}function If(e){const t=new Map;for(const s of e){if(!s.sha256)continue;const r=t.get(s.sha256)??[];r.push(s),t.set(s.sha256,r)}return[...t.values()].filter(s=>s.length>1).map(s=>({sha256:s[0].sha256,bytes:s[0].bytes,paths:s.map(r=>r.path).sort(),wastedBytes:s[0].bytes*(s.length-1)})).sort((s,r)=>r.wastedBytes-s.wastedBytes)}async function Af(e){const t=e.servingRooted===!0,s=e.files.filter(c=>yf(c.path,t)),r=tf(e.provenance),n=new af(s);await uf(e,n);const o=e.codeReferencesScannable!==!1;o&&await lf(e,n),await hf(e,s,n);const i=[];for(const c of s)i.push(await bf(c,e,n,r));i.sort((c,l)=>l.bytes-c.bytes||c.path.localeCompare(l.path));const a=i.filter(c=>!c.engineVendored&&Tf.has(c.category)&&c.references.length===0&&(t||c.path.startsWith("public/")||xf.has(c.category))).map(c=>c.path);return{entries:i,totalBytes:i.reduce((c,l)=>c+l.bytes,0),totalVramBytes:i.reduce((c,l)=>c+Wn(l),0),categories:_f(i),unused:a,duplicates:If(i),codeReferencesScanned:o}}async function es(e){const{io:t}=await ot();return t.readBinary(new Uint8Array(e))}async function ts(e,t){const{io:s}=await ot(),r=await s.writeBinary(e);return{bytes:r,beforeBytes:t,afterBytes:r.byteLength}}async function vf(e){const{capabilities:t}=await ot();if(!t.meshoptEncoder.available)throw new Error(t.meshoptEncoder.reason);const s=await ft(()=>import("./index-BMxv2MNV.js"),[]);await s.MeshoptEncoder.ready;const r=await es(e);return await r.transform(Rl({encoder:s.MeshoptEncoder})),ts(r,e.byteLength)}async function Rf(e){const{capabilities:t}=await ot();if(!t.dracoEncoder.available)throw new Error(t.dracoEncoder.reason);const s=await es(e);return await s.transform(Du()),ts(s,e.byteLength)}const wf=128,Sf=new Set(["image/png","image/jpeg"]);function Nf(e,t){return t!=="auto"?t:Js(e)==="srgb"?"etc1s":"uastc"}function Mf(e,t,s){const r=t.getImage(),n=t.getSize(),o=t.getName()||"(unnamed)";if(!r||!n)throw new Error(`Texture "${o}" (${t.getMimeType()}) has no readable image.`);const i=Js(t)==="srgb",a=new e.BasisEncoder;try{a.setCreateKTX2File(!0),a.setKTX2UASTCSupercompression(!0),a.setKTX2AndBasisSRGBTransferFunc(i),a.setDebug(!1),a.setStatusOutput(!1),a.setComputeStats(!1),a.setPerceptual(s==="etc1s"),a.setMipGen(!0),a.setMipSRGB(i),a.setUASTC(s==="uastc"),a.setQualityLevel(wf);const c=t.getMimeType()==="image/png"?e.ldr_image_type.cPNGImage.value:e.ldr_image_type.cJPGImage.value;if(!a.setSliceSourceImage(0,r,0,0,c))throw new Error(`Basis could not read texture "${o}" (${t.getMimeType()}).`);const[l,u]=n,h=new Uint8Array(Math.ceil(l*u*4*1.5)+64*1024),f=a.encode(h);if(f<=0)throw new Error(`The Basis encoder produced no output for texture "${o}".`);return h.slice(0,f)}finally{a.delete()}}async function Cf(e,t={}){const s=await es(e),r=s.getRoot(),n=r.listTextures().filter(l=>Sf.has(l.getMimeType()));if(n.length===0){const l=r.listTextures().map(u=>u.getMimeType());throw new Error(l.length===0?"This model has no textures to compress — KTX2 compresses images, not geometry (use meshopt or Draco).":`None of this model's ${l.length} texture(s) is a PNG or JPEG that Basis can read (found: ${[...new Set(l)].join(", ")}).`)}const o=await kl(t.artifacts),i=t.mode??"auto",a=[];for(const l of n){const u=l.getImage()?.byteLength??0,h=Nf(l,i),f=Mf(o,l,h);a.push({name:l.getName(),slots:$n(l),mode:h,beforeBytes:u,afterBytes:f.byteLength}),l.setImage(f).setMimeType("image/ktx2")}return s.createExtension(Fn).setRequired(!0),{...await ts(s,e.byteLength),textures:a}}const Of=[{suffix:"_LOD1",ratio:.5,error:.001,distance:25},{suffix:"_LOD2",ratio:.15,error:.01,distance:50}];function Yn(e){return e.getSkin()?!0:e.listChildren().some(Yn)}function qt(e){const t=e.getMesh();return[...t?[{node:e,mesh:t}]:[],...e.listChildren().flatMap(qt)]}function sn(e){return qt(e).reduce((t,{mesh:s})=>t+s.listPrimitives().reduce((r,n)=>r+Ks(n),0),0)}function Jn(e,t,s){const r=e.createNode(t.getName()?`${t.getName()}${s}`:"").setTranslation(t.getTranslation()).setRotation(t.getRotation()).setScale(t.getScale()),n=t.getMesh();if(n){const o=e.createMesh(n.getName()?`${n.getName()}${s}`:"");for(const i of n.listPrimitives())o.addPrimitive(i.clone());r.setMesh(o)}for(const o of t.listChildren())r.addChild(Jn(e,o,s));return r}async function Df(e,t,s=Of){const r=await $l(),n=await es(e),o=n.getRoot(),i=o.listNodes().find(f=>f.getName()===t);if(!i)throw new Error(`Node "${t}" was not found in the model.`);if(Yn(i))throw new Error(`Node "${t}" is (or contains) a skinned mesh — LOD generation cannot lift a skinned subtree (atomic-subtree rule).`);if(qt(i).length===0)throw new Error(`Node "${t}" has no mesh to simplify.`);const a=new Set(o.listNodes().map(f=>f.getName()));for(const f of s)if(a.has(`${t}${f.suffix}`))throw new Error(`Node "${t}${f.suffix}" already exists — LOD levels appear to be generated already. Remove them first to regenerate.`);const c=sn(i),l=i.listParents().filter(f=>f.propertyType==="Node"||f.propertyType==="Scene"),u=[];for(const f of s){const g=Jn(n,i,f.suffix);for(const{mesh:T}of qt(g))for(const p of T.listPrimitives())Ys(p),Fl(p,{simplifier:r,ratio:f.ratio,error:f.error});for(const T of l)T.addChild(g);u.push({node:`${t}${f.suffix}`,ratio:f.ratio,distance:f.distance,triangles:sn(g)})}return await n.transform(Qs()),{...await ts(n,e.byteLength),baseNode:t,baseTriangles:c,levels:u}}const he=".volter/provenance.json";function Pf(e){return e.startsWith("public/")?`/${e.slice(7)}`:`/${e}`}function rn(e){return e.startsWith("public/")?e:`public/${e}`}async function jf(e){if(Vs(e)){const t=await fetch(`/__editor/volter-file?${new URLSearchParams({path:he})}`);if(t.status===404)return null;if(!t.ok)throw new Error(`read ${he}: HTTP ${t.status}`);return t.text()}return await e.exists(he)?e.read(he):null}async function Ff(e,t){if(Vs(e)){const s=async()=>{const r=await fetch("/__editor/volter-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:he,content:t,...oi()})});ai(r,`Write ${he} failed`),r.ok||await ci(r,{label:`Write ${he}`,attempted:{[he]:t},reapply:s})};await s();return}await e.write(he,t)}async function Uf(e,t,s){let r={version:1,operations:{}};const n=await jf(e);if(n!==null){const i=JSON.parse(n);if(!i||typeof i!="object"||typeof i.operations!="object")throw new Error(`${he} exists but is not a provenance document`);r=i}const o=`asset-budget-${crypto.randomUUID()}`;r.operations[o]={createdAt:new Date().toISOString(),operation:{name:t.operationName,source:"editor:asset-budget"},input:{path:rn(t.storagePath),bytes:t.beforeBytes,sha256:t.beforeSha256,...t.params?{params:t.params}:{}},outputs:[{path:rn(t.storagePath),bytes:s.byteLength,sha256:await on(s),mediaType:"model/gltf-binary",role:"asset"}]},await Ff(e,`${JSON.stringify(r,null,2)}
22
+ ;return BASIS;`)(Vl,"","")({wasmBinary:e.wasmBinary});return s.initializeBasis(),s}function kl(e){return Ts||(Ts=e?en(e):(async()=>{const[t,s]=await Promise.all([Zr("basis_encoder.js"),Zr("basis_encoder.wasm")]);return en({glue:await t.text(),wasmBinary:new Uint8Array(await s.arrayBuffer())})})()),Ts}let xs=null;function Ye(e,t){const s=e instanceof Error?e.message:String(e);return{available:!1,reason:`${t} failed to load: ${s}`}}function ot(){return xs||(xs=zl()),xs}async function zl(){const e=new eo().registerExtensions(tu),t={};let s={available:!0},r={available:!0},n={available:!0};try{const a=await ft(()=>import("./index-BMxv2MNV.js"),[]);await Promise.all([a.MeshoptDecoder.ready,a.MeshoptEncoder.ready,a.MeshoptSimplifier.ready]),t["meshopt.decoder"]=a.MeshoptDecoder,t["meshopt.encoder"]=a.MeshoptEncoder}catch(a){s=Ye(a,"meshoptimizer decoder"),r=Ye(a,"meshoptimizer encoder"),n=Ye(a,"meshoptimizer simplifier")}let o={available:!0},i={available:!0};try{const a=(await ft(async()=>{const{default:c}=await import("./draco3d-DdFfLaRu.js").then(l=>l.d);return{default:c}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).default;t["draco3d.decoder"]=await a.createDecoderModule({locateFile:c=>c.endsWith(".wasm")?Bl:c})}catch(a){o=Ye(a,"draco3d decoder")}try{const a=(await ft(async()=>{const{default:c}=await import("./draco3d-DdFfLaRu.js").then(l=>l.d);return{default:c}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).default;t["draco3d.encoder"]=await a.createEncoderModule({locateFile:c=>c.endsWith(".wasm")?Ll:c})}catch(a){i=Ye(a,"draco3d encoder")}return e.registerDependencies(t),{io:e,capabilities:{meshoptDecoder:s,meshoptEncoder:r,meshoptSimplifier:n,dracoDecoder:o,dracoEncoder:i,ktx2Encoder:await Gl()}}}async function Gl(){const e=`${Ps}basis_encoder.wasm`;try{const t=await fetch(e,{method:"HEAD"});return t.ok?{available:!0}:{available:!1,reason:`The Basis Universal encoder is not being served at ${e} (HTTP ${t.status}).`}}catch(t){return Ye(t,`the Basis Universal encoder at ${e}`)}}async function $l(){const e=await ft(()=>import("./index-BMxv2MNV.js"),[]);return await e.MeshoptSimplifier.ready,e.MeshoptSimplifier}function Hl(e,t){return e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71||e.length<24?null:{width:t.getUint32(16),height:t.getUint32(20)}}function Kl(e,t){if(e[0]!==255||e[1]!==216)return null;let s=2;for(;s+9<e.length;){if(e[s]!==255)return null;const r=e[s+1];if(r>=192&&r<=207&&r!==196&&r!==200&&r!==204)return{width:t.getUint16(s+7),height:t.getUint16(s+5)};s+=2+t.getUint16(s+2)}return null}function ql(e,t){return e[0]!==71||e[1]!==73||e[2]!==70?null:{width:t.getUint16(6,!0),height:t.getUint16(8,!0)}}function Xl(e,t){const s=(r,n)=>n.split("").every((o,i)=>e[r+i]===o.charCodeAt(0));if(!s(0,"RIFF")||!s(8,"WEBP")||e.length<30)return null;if(s(12,"VP8 "))return{width:t.getUint16(26,!0)&16383,height:t.getUint16(28,!0)&16383};if(s(12,"VP8L")){const r=e[21],n=e[22],o=e[23],i=e[24];return{width:1+((n&63)<<8|r),height:1+((i&15)<<10|o<<2|(n&192)>>6)}}return null}function Wl(e){if(e.length<16)return null;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);for(const s of[Hl,Kl,ql,Xl]){const r=s(e,t);if(r)return r}return null}function Yl(e){return Math.ceil(e.width*e.height*4*(4/3))}const Jl=/\.(png|jpe?g|webp|gif|svg|ktx2|basis|bmp|avif)$/i,Ql=/\.(mp3|wav|ogg|m4a|aac|flac|opus)$/i,Zl=/\.(glb|gltf)$/i;function Xn(e){const t=e.toLowerCase();return Zl.test(t)?"model":Jl.test(t)?"image":Ql.test(t)?"audio":t.endsWith(".json")||t.endsWith(".bin")?"data":"other"}function tt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ef(e){const t=tt(e),s=tt(t?.operation),r=t?.createdAt,n=s?.name,o=t?.outputs;if(typeof r!="string"||typeof n!="string"||!Array.isArray(o))return null;const i=o.flatMap(a=>{const c=tt(a)?.path;return typeof c=="string"?[Zt(c)]:[]});return{stamp:{operationName:n,createdAt:r},paths:i}}function tf(e){const t=new Map,s=tt(tt(e)?.operations);if(!s)return t;for(const[r,n]of Object.entries(s)){const o=ef(n);if(o)for(const i of o.paths){const a=t.get(i);(!a||o.stamp.createdAt.localeCompare(a.createdAt)>0)&&t.set(i,{operationId:r,...o.stamp})}}return t}function sf(e){return/(?:^|\/)jsm\//i.test(e)}const rf=/\.(?:tsx?|jsx?|mjs|cjs)$/i,nf="volter.project.json";function of(e){return(e.split("/").pop()??e)===nf}function js(e,t="$"){if(typeof e=="string")return[{path:t,value:e}];if(Array.isArray(e))return e.flatMap((r,n)=>js(r,`${t}[${n}]`));const s=tt(e);return s?Object.entries(s).flatMap(([r,n])=>js(n,`${t}.${r}`)):[]}function Zt(e){return e.split(/[?#]/,1)[0].replace(/^\.\//,"").replace(/^\/+/,"")}class af{keyToPath=new Map;referencesByPath=new Map;constructor(t){for(const s of t)this.keyToPath.set(s.path,s.path),s.path.startsWith("public/")&&this.keyToPath.set(s.path.slice(7),s.path)}resolve(t){return this.keyToPath.get(Zt(t))}add(t,s){const r=this.referencesByPath.get(t)??[];r.some(n=>n.ownerPath===s.ownerPath&&n.jsonPath===s.jsonPath)||(r.push(s),this.referencesByPath.set(t,r))}referencesOf(t){return this.referencesByPath.get(t)??[]}}async function cf(e,t,s){if(!of(t.path))return;let r;try{r=JSON.parse(await e.readText(t.path))}catch{return}for(const n of js(r)){const o=s.resolve(n.value);o&&o!==t.path&&s.add(o,{ownerPath:t.path,kind:"manifest",jsonPath:n.path})}}async function uf(e,t){for(const s of[...e.files,...e.ownerFiles??[]])await cf(e,s,t)}async function lf(e,t){const s=e.files.filter(r=>!r.path.startsWith("public/")&&rf.test(r.path));for(const r of s){let n;try{n=await e.readText(r.path)}catch{continue}for(const[o,i]of t.keyToPath)o.length>4&&n.includes(o)&&t.add(i,{ownerPath:r.path,kind:"code"})}}function ff(e,t){const s=t.includes("/")?t.slice(0,t.lastIndexOf("/")+1):"";return[...e.buffers??[],...e.images??[]].flatMap(({uri:r})=>r&&!r.startsWith("data:")?[`${s}${decodeURIComponent(r)}`]:[])}async function hf(e,t,s){for(const r of t)if(/\.gltf$/i.test(r.path))try{const n=JSON.parse(await e.readText(r.path));for(const o of ff(n,r.path)){const i=s.resolve(o);i&&s.add(i,{ownerPath:r.path,kind:"asset"})}}catch{}}const df=new Set(["node_modules",".git","dist","build",".volter",".ci-scaffold","coverage","test-results","playwright-report"]);async function gf(e){const t=[],s=async n=>{const o=await e.list(n);for(const i of o){const a=n?`${n}/${i.name}`:i.name;i.type==="dir"?df.has(i.name)||await s(a):t.push({path:a,size:i.size??0})}};if(await s(""),Vs(e)){const n=[],o=new Map;try{const a=await fetch("/volter.project.json");if(a.ok){const c=await a.text();o.set("volter.project.json",c),n.push({path:"volter.project.json",size:c.length})}}catch{}let i=null;try{const a=await fetch(`/__editor/volter-file?${new URLSearchParams({path:".volter/provenance.json"})}`);a.ok&&(i=JSON.parse(await a.text()))}catch{i=null}return{files:t,ownerFiles:n,servingRooted:!0,codeReferencesScannable:!1,provenance:i,readBytes:a=>e.readBytes(a),readText:a=>{const c=o.get(Zt(a));return c!==void 0?Promise.resolve(c):e.read(a)}}}let r=null;try{await e.exists(".volter/provenance.json")&&(r=JSON.parse(await e.read(".volter/provenance.json")))}catch{r=null}return{files:t,codeReferencesScannable:!0,provenance:r,readBytes:n=>e.readBytes(n),readText:n=>e.read(n)}}async function pf(e,t,s){const{io:r}=await ot();if(/\.glb$/i.test(e))return r.readBinary(new Uint8Array(t));const n=JSON.parse(new TextDecoder().decode(t)),o={},i=e.includes("/")?e.slice(0,e.lastIndexOf("/")+1):"";for(const{uri:a}of[...n.buffers??[],...n.images??[]])a&&!a.startsWith("data:")&&(o[a]=new Uint8Array(await s.readBytes(`${i}${decodeURIComponent(a)}`)));return r.readJSON({json:n,resources:o})}async function mf(e,t,s){try{const r=await pf(e,t,s),n=Wu(r),o=n.meshes.properties,i=n.textures.properties,a=o.reduce((u,h)=>u+h.size,0),c=i.reduce((u,h)=>u+(h.gpuSize??0),0),l=new Set;for(const u of r.getRoot().listNodes())u.getName()&&u.getMesh()&&!u.getSkin()&&l.add(u.getName());return{model:{meshCount:o.length,materialCount:n.materials.properties.length,textureCount:i.length,animationCount:n.animations.properties.length,glPrimitives:o.reduce((u,h)=>u+h.glPrimitives,0),vertices:o.reduce((u,h)=>u+h.vertices,0),geometryBytes:a,textureGpuBytes:c,unknownTextureCount:i.filter(u=>u.gpuSize===null).length,vramBytes:a+c,textures:i.map(u=>({name:u.name||u.uri,mimeType:u.mimeType,resolution:u.resolution,slots:u.slots,bytes:u.size,gpuBytes:u.gpuSize})),meshNames:[...l]}}}catch(r){return{inspectError:r instanceof Error?r.message:String(r)}}}function yf(e,t){if(t||e.startsWith("public/")||/\.inputmap\.json$/i.test(e))return!0;if(e.startsWith("src/")||e.startsWith("server/")||!e.includes("/"))return!1;const s=Xn(e);return s==="model"||s==="image"||s==="audio"}const Tf=new Set(["model","image","audio","data","other"]),xf=new Set(["model","image","audio"]);function tn(e,t){return t?`/${e}`:e.startsWith("public/")?`/${e.slice(7)}`:null}function Ef(e,t){const s=Zt(t),r=s.startsWith("public/")?s.slice(7):`public/${s}`;return e.get(s)??e.get(r)}async function bf(e,t,s,r){const n=Xn(e.path),o=t.servingRooted===!0,i=sf(e.path);let a;try{a=await t.readBytes(e.path)}catch(f){return{path:e.path,servingPath:tn(e.path,o),category:n,bytes:e.size,sha256:"",inspectError:`unreadable: ${f instanceof Error?f.message:String(f)}`,references:s.referencesOf(e.path),...i?{engineVendored:i}:{}}}let c,l,u;if(n==="model")({model:c,inspectError:u}=await mf(e.path,a,t));else if(n==="image"){const f=Wl(a);f&&(l={...f,gpuBytes:Yl(f)})}const h=Ef(r,e.path);return{path:e.path,servingPath:tn(e.path,o),category:n,bytes:a.byteLength,sha256:await on(a),...c?{model:c}:{},...l?{image:l}:{},...u?{inspectError:u}:{},references:s.referencesOf(e.path),...h?{provenance:h}:{},...i?{engineVendored:i}:{}}}function Wn(e){return e.model?.vramBytes??e.image?.gpuBytes??0}function _f(e){const t=new Map;for(const s of e){const r=t.get(s.category)??{count:0,bytes:0,vram:0};r.count+=1,r.bytes+=s.bytes,r.vram+=Wn(s),t.set(s.category,r)}return[...t.entries()].map(([s,r])=>({category:s,count:r.count,bytes:r.bytes,vramBytes:r.vram})).sort((s,r)=>r.bytes-s.bytes)}function If(e){const t=new Map;for(const s of e){if(!s.sha256)continue;const r=t.get(s.sha256)??[];r.push(s),t.set(s.sha256,r)}return[...t.values()].filter(s=>s.length>1).map(s=>({sha256:s[0].sha256,bytes:s[0].bytes,paths:s.map(r=>r.path).sort(),wastedBytes:s[0].bytes*(s.length-1)})).sort((s,r)=>r.wastedBytes-s.wastedBytes)}async function Af(e){const t=e.servingRooted===!0,s=e.files.filter(c=>yf(c.path,t)),r=tf(e.provenance),n=new af(s);await uf(e,n);const o=e.codeReferencesScannable!==!1;o&&await lf(e,n),await hf(e,s,n);const i=[];for(const c of s)i.push(await bf(c,e,n,r));i.sort((c,l)=>l.bytes-c.bytes||c.path.localeCompare(l.path));const a=i.filter(c=>!c.engineVendored&&Tf.has(c.category)&&c.references.length===0&&(t||c.path.startsWith("public/")||xf.has(c.category))).map(c=>c.path);return{entries:i,totalBytes:i.reduce((c,l)=>c+l.bytes,0),totalVramBytes:i.reduce((c,l)=>c+Wn(l),0),categories:_f(i),unused:a,duplicates:If(i),codeReferencesScanned:o}}async function es(e){const{io:t}=await ot();return t.readBinary(new Uint8Array(e))}async function ts(e,t){const{io:s}=await ot(),r=await s.writeBinary(e);return{bytes:r,beforeBytes:t,afterBytes:r.byteLength}}async function vf(e){const{capabilities:t}=await ot();if(!t.meshoptEncoder.available)throw new Error(t.meshoptEncoder.reason);const s=await ft(()=>import("./index-BMxv2MNV.js"),[]);await s.MeshoptEncoder.ready;const r=await es(e);return await r.transform(Rl({encoder:s.MeshoptEncoder})),ts(r,e.byteLength)}async function Rf(e){const{capabilities:t}=await ot();if(!t.dracoEncoder.available)throw new Error(t.dracoEncoder.reason);const s=await es(e);return await s.transform(Du()),ts(s,e.byteLength)}const wf=128,Sf=new Set(["image/png","image/jpeg"]);function Nf(e,t){return t!=="auto"?t:Js(e)==="srgb"?"etc1s":"uastc"}function Mf(e,t,s){const r=t.getImage(),n=t.getSize(),o=t.getName()||"(unnamed)";if(!r||!n)throw new Error(`Texture "${o}" (${t.getMimeType()}) has no readable image.`);const i=Js(t)==="srgb",a=new e.BasisEncoder;try{a.setCreateKTX2File(!0),a.setKTX2UASTCSupercompression(!0),a.setKTX2AndBasisSRGBTransferFunc(i),a.setDebug(!1),a.setStatusOutput(!1),a.setComputeStats(!1),a.setPerceptual(s==="etc1s"),a.setMipGen(!0),a.setMipSRGB(i),a.setUASTC(s==="uastc"),a.setQualityLevel(wf);const c=t.getMimeType()==="image/png"?e.ldr_image_type.cPNGImage.value:e.ldr_image_type.cJPGImage.value;if(!a.setSliceSourceImage(0,r,0,0,c))throw new Error(`Basis could not read texture "${o}" (${t.getMimeType()}).`);const[l,u]=n,h=new Uint8Array(Math.ceil(l*u*4*1.5)+64*1024),f=a.encode(h);if(f<=0)throw new Error(`The Basis encoder produced no output for texture "${o}".`);return h.slice(0,f)}finally{a.delete()}}async function Cf(e,t={}){const s=await es(e),r=s.getRoot(),n=r.listTextures().filter(l=>Sf.has(l.getMimeType()));if(n.length===0){const l=r.listTextures().map(u=>u.getMimeType());throw new Error(l.length===0?"This model has no textures to compress — KTX2 compresses images, not geometry (use meshopt or Draco).":`None of this model's ${l.length} texture(s) is a PNG or JPEG that Basis can read (found: ${[...new Set(l)].join(", ")}).`)}const o=await kl(t.artifacts),i=t.mode??"auto",a=[];for(const l of n){const u=l.getImage()?.byteLength??0,h=Nf(l,i),f=Mf(o,l,h);a.push({name:l.getName(),slots:$n(l),mode:h,beforeBytes:u,afterBytes:f.byteLength}),l.setImage(f).setMimeType("image/ktx2")}return s.createExtension(Fn).setRequired(!0),{...await ts(s,e.byteLength),textures:a}}const Of=[{suffix:"_LOD1",ratio:.5,error:.001,distance:25},{suffix:"_LOD2",ratio:.15,error:.01,distance:50}];function Yn(e){return e.getSkin()?!0:e.listChildren().some(Yn)}function qt(e){const t=e.getMesh();return[...t?[{node:e,mesh:t}]:[],...e.listChildren().flatMap(qt)]}function sn(e){return qt(e).reduce((t,{mesh:s})=>t+s.listPrimitives().reduce((r,n)=>r+Ks(n),0),0)}function Jn(e,t,s){const r=e.createNode(t.getName()?`${t.getName()}${s}`:"").setTranslation(t.getTranslation()).setRotation(t.getRotation()).setScale(t.getScale()),n=t.getMesh();if(n){const o=e.createMesh(n.getName()?`${n.getName()}${s}`:"");for(const i of n.listPrimitives())o.addPrimitive(i.clone());r.setMesh(o)}for(const o of t.listChildren())r.addChild(Jn(e,o,s));return r}async function Df(e,t,s=Of){const r=await $l(),n=await es(e),o=n.getRoot(),i=o.listNodes().find(f=>f.getName()===t);if(!i)throw new Error(`Node "${t}" was not found in the model.`);if(Yn(i))throw new Error(`Node "${t}" is (or contains) a skinned mesh — LOD generation cannot lift a skinned subtree (atomic-subtree rule).`);if(qt(i).length===0)throw new Error(`Node "${t}" has no mesh to simplify.`);const a=new Set(o.listNodes().map(f=>f.getName()));for(const f of s)if(a.has(`${t}${f.suffix}`))throw new Error(`Node "${t}${f.suffix}" already exists — LOD levels appear to be generated already. Remove them first to regenerate.`);const c=sn(i),l=i.listParents().filter(f=>f.propertyType==="Node"||f.propertyType==="Scene"),u=[];for(const f of s){const g=Jn(n,i,f.suffix);for(const{mesh:T}of qt(g))for(const p of T.listPrimitives())Ys(p),Fl(p,{simplifier:r,ratio:f.ratio,error:f.error});for(const T of l)T.addChild(g);u.push({node:`${t}${f.suffix}`,ratio:f.ratio,distance:f.distance,triangles:sn(g)})}return await n.transform(Qs()),{...await ts(n,e.byteLength),baseNode:t,baseTriangles:c,levels:u}}const he=".volter/provenance.json";function Pf(e){return e.startsWith("public/")?`/${e.slice(7)}`:`/${e}`}function rn(e){return e.startsWith("public/")?e:`public/${e}`}async function jf(e){if(Vs(e)){const t=await fetch(`/__editor/volter-file?${new URLSearchParams({path:he})}`);if(t.status===404)return null;if(!t.ok)throw new Error(`read ${he}: HTTP ${t.status}`);return t.text()}return await e.exists(he)?e.read(he):null}async function Ff(e,t){if(Vs(e)){const s=async()=>{const r=await fetch("/__editor/volter-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:he,content:t,...oi()})});ai(r,`Write ${he} failed`),r.ok||await ci(r,{label:`Write ${he}`,attempted:{[he]:t},reapply:s})};await s();return}await e.write(he,t)}async function Uf(e,t,s){let r={version:1,operations:{}};const n=await jf(e);if(n!==null){const i=JSON.parse(n);if(!i||typeof i!="object"||typeof i.operations!="object")throw new Error(`${he} exists but is not a provenance document`);r=i}const o=`asset-budget-${crypto.randomUUID()}`;r.operations[o]={createdAt:new Date().toISOString(),operation:{name:t.operationName,source:"editor:asset-budget"},input:{path:rn(t.storagePath),bytes:t.beforeBytes,sha256:t.beforeSha256,...t.params?{params:t.params}:{}},outputs:[{path:rn(t.storagePath),bytes:s.byteLength,sha256:await on(s),mediaType:"model/gltf-binary",role:"asset"}]},await Ff(e,`${JSON.stringify(r,null,2)}
23
23
  `)}async function Bf(e,t,s){await e.write(t.storagePath,s);let r;try{await Uf(e,t,s)}catch(o){r=o instanceof Error?o.message:String(o)}const n=Pf(t.storagePath);return ss(n),ss(n.replace(/^\/+/,"")),ss(t.storagePath),typeof window<"u"&&(window.dispatchEvent(new CustomEvent("editor:asset-mutation",{detail:{type:"change",paths:[t.storagePath,n]}})),window.dispatchEvent(new CustomEvent("editor:assets-changed"))),r?{stampError:r}:{}}const Lf="asset-budget.document";let Fs=null,Qn=0;const Us=new Set;function Vf(){Qn++;for(const e of Us)e()}function kf(e){return Us.add(e),()=>{Us.delete(e)}}function zf(){return Qn}function Gf(){const e=Fs;return e!==null&&(Fs=null),e}function bh(e){return e!==void 0&&(Fs=e,Vf()),ui().workspace.openContributedDocument(Lf)}function ae(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function dt(e){return e>=1e4?`${(e/1e3).toFixed(1)}k`:String(e)}function $f(e){return e.model?`${e.model.unknownTextureCount>0?"≥ ":""}${ae(e.model.vramBytes)}`:e.image?ae(e.image.gpuBytes):"—"}function Hf(e){return e.model?.vramBytes??e.image?.gpuBytes??0}function nn(e,t){switch(t){case"path":return e.path;case"category":return e.category;case"bytes":return e.bytes;case"vram":return Hf(e);case"tris":return e.model?.glPrimitives??-1;case"refs":return e.references.length}}function Kf(e,t,s){return[...e].sort((r,n)=>{const o=nn(r,t),i=nn(n,t),a=typeof o=="string"?o.localeCompare(i):o-i;return a!==0?a*s:r.path.localeCompare(n.path)})}const qf={model:"Models",image:"Images",audio:"Audio",data:"Data",other:"Other"};function Xf(){const[e,t]=Y.useState({report:null,loading:!0,error:null}),[s,r]=Y.useState(!1),n=Y.useRef(0),o=Y.useCallback(()=>{const i=++n.current;t(a=>({...a,loading:!0,error:null})),r(!1),(async()=>{try{const a=await gf(Bt()),c=await Af(a);n.current===i&&t({report:c,loading:!1,error:null})}catch(a){n.current===i&&t({report:null,loading:!1,error:a instanceof Error?a.message:String(a)})}})()},[]);return Y.useEffect(()=>(o(),Bt().watch(()=>r(!0))),[o]),{...e,refresh:o,stale:s}}const Bs={padding:`${O[2]} ${O[4]}`,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},Mt={...Bs,textAlign:"right",fontFamily:gt};function We({label:e,sortKey:t,active:s,direction:r,onSort:n,align:o}){return A.jsx("th",{"aria-sort":s?r===1?"ascending":"descending":"none",style:{padding:0,textAlign:o??"left"},children:A.jsx(st,{type:"button",variant:"ghost",size:"compact","data-testid":`asset-budget-sort-${t}`,onClick:()=>n(t),style:{display:"block",width:"100%",justifyContent:o==="right"?"flex-end":"flex-start"},children:A.jsxs("span",{style:{display:"block",fontSize:F.base,fontWeight:600,color:s?G[1]:G[3],textAlign:o??"left"},children:[e,s?r===1?" ↑":" ↓":""]})})})}function Wf({entry:e}){return e.provenance?A.jsx("span",{"data-testid":"asset-budget-provenance-badge",title:`${e.provenance.operationName} · ${e.provenance.createdAt}`,style:{fontSize:F.xs,fontWeight:700,letterSpacing:.5,color:Es,border:`1px solid ${Es}`,borderRadius:Lt.sm,padding:`0 ${O[2]}`,marginLeft:O[3]},children:"GEN"}):null}function Yf({entry:e,selected:t,onSelect:s}){const r=e.path.split("/").pop()??e.path,n=e.path.slice(0,e.path.length-r.length);return A.jsxs("tr",{"data-testid":"asset-budget-row","data-path":e.path,"data-selected":t?"true":void 0,onClick:()=>s(e.path),style:{cursor:"pointer",background:t?Ls[3]:"transparent",borderTop:`1px solid ${ht[1]}`},children:[A.jsxs("td",{style:{...Bs,maxWidth:0,width:"40%"},title:e.path,children:[A.jsx("span",{style:{color:G[3],fontSize:F.sm},children:n}),A.jsx("span",{style:{color:G[1]},children:r}),A.jsx(Wf,{entry:e}),e.inspectError?A.jsx("span",{title:e.inspectError,"data-testid":"asset-budget-inspect-error",style:{color:Xt,marginLeft:O[3],fontWeight:700},children:"!"}):null]}),A.jsx("td",{style:{...Bs,color:G[3]},children:e.category}),A.jsx("td",{style:Mt,"data-testid":"asset-budget-cell-bytes",children:ae(e.bytes)}),A.jsx("td",{style:Mt,children:$f(e)}),A.jsx("td",{style:Mt,children:e.model?dt(e.model.glPrimitives):"—"}),A.jsx("td",{style:Mt,"data-testid":"asset-budget-cell-refs",children:e.references.length})]})}function Jf({report:e}){return A.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:O[3],padding:`${O[4]} ${O[5]}`},children:[A.jsxs("span",{"data-testid":"asset-budget-totals",style:{fontSize:F.base,color:G[1],background:Ls[3],borderRadius:Lt.sm,padding:`${O[1]} ${O[4]}`},children:[e.entries.length," assets · ",ae(e.totalBytes)," · VRAM est."," ",ae(e.totalVramBytes)]}),e.categories.map(t=>A.jsxs("span",{"data-testid":`asset-budget-category-${t.category}`,style:{fontSize:F.base,color:G[2],border:`1px solid ${ht[1]}`,borderRadius:Lt.sm,padding:`${O[1]} ${O[4]}`},children:[qf[t.category]," ",t.count," · ",ae(t.bytes)]},t.category))]})}function Zn({title:e,testId:t,children:s}){return A.jsxs("div",{"data-testid":t,style:{padding:`${O[3]} ${O[5]}`},children:[A.jsx("div",{style:{fontSize:F.base,fontWeight:600,color:G[2],marginBottom:O[2]},children:e}),s]})}function Qf({report:e,onSelect:t}){return e.unused.length===0?null:A.jsxs(Zn,{title:`Unused assets (${e.unused.length})`,testId:"asset-budget-unused",children:[A.jsxs("div",{"data-testid":"asset-budget-unused-caveat",style:{fontSize:F.sm,color:me,marginBottom:O[2],lineHeight:an.normal},children:["“Unused” = not referenced by the manifest, project code, or another asset.",e.codeReferencesScanned?"":" Code references (src/**) are not scanned in server mode, so an asset used only from code appears here — “unused” does not mean “safe to delete”."]}),e.unused.map(s=>A.jsx(st,{type:"button",variant:"ghost",size:"compact","data-testid":"asset-budget-unused-item","data-path":s,onClick:()=>t(s),style:{display:"block"},children:A.jsx("span",{style:{fontSize:F.base,fontFamily:gt,color:me},children:s})},s))]})}function Zf({report:e}){return e.duplicates.length===0?null:A.jsx(Zn,{title:`Duplicate content (${e.duplicates.length} group${e.duplicates.length>1?"s":""})`,testId:"asset-budget-duplicates",children:e.duplicates.map(t=>A.jsxs("div",{"data-testid":"asset-budget-duplicate-group",style:{marginBottom:O[2]},children:[A.jsxs("span",{style:{fontSize:F.base,color:me},children:[ae(t.wastedBytes)," wasted · ",t.paths.length," copies"]}),t.paths.map(s=>A.jsx("div",{style:{fontSize:F.base,fontFamily:gt,color:G[3]},children:s},s))]},t.sha256))})}function eh({entry:e,onApplied:t,codeReferencesScanned:s}){return e?A.jsxs("div",{"data-testid":"asset-budget-detail",style:{padding:O[6],overflow:"auto",minHeight:0},children:[A.jsx("div",{style:{fontSize:F.md,fontWeight:600,color:G[1],wordBreak:"break-all"},children:e.path}),A.jsxs("div",{style:{fontSize:F.base,color:G[3],marginTop:O[1]},children:[e.category," · ",ae(e.bytes),e.sha256?` · sha256 ${e.sha256.slice(0,12)}…`:""]}),e.provenance?A.jsxs("div",{style:{fontSize:F.base,color:Es,marginTop:O[3]},children:["Generated by ",e.provenance.operationName,A.jsxs("span",{style:{color:G[3]},children:[" · ",e.provenance.createdAt]})]}):null,e.inspectError?A.jsxs("div",{style:{fontSize:F.base,color:Xt,marginTop:O[3]},children:["Inspection failed: ",e.inspectError]}):null,e.model?A.jsx(th,{entry:e}):null,A.jsx(oh,{entry:e,onApplied:t}),A.jsx(ah,{entry:e,codeReferencesScanned:s})]}):A.jsx("div",{style:{padding:O[6],fontSize:F.md,color:G[3]},children:"Select an asset to see its details and references."})}function th({entry:e}){const t=e.model;if(!t)return null;const s=[["Triangles (GL primitives)",dt(t.glPrimitives)],["Vertices",dt(t.vertices)],["Meshes",String(t.meshCount)],["Materials",String(t.materialCount)],["Animations",String(t.animationCount)],["Geometry upload",ae(t.geometryBytes)],["Texture VRAM est.",`${t.unknownTextureCount>0?"≥ ":""}${ae(t.textureGpuBytes)}`]];return A.jsxs("div",{style:{marginTop:O[4]},children:[s.map(([r,n])=>A.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:F.base},children:[A.jsx("span",{style:{color:G[3]},children:r}),A.jsx("span",{style:{color:G[1],fontFamily:gt},children:n})]},r)),t.textures.length>0?A.jsxs("div",{style:{marginTop:O[3]},children:[A.jsx("div",{style:{fontSize:F.base,fontWeight:600,color:G[2]},children:"Textures"}),t.textures.map(r=>A.jsxs("div",{style:{fontSize:F.base,color:G[3]},children:[r.name||"(unnamed)"," · ",r.mimeType," · ",r.resolution," ·"," ",r.gpuBytes===null?"VRAM unknown":ae(r.gpuBytes)]},`${r.name}:${r.slots.join(",")}`))]}):null,t.unknownTextureCount>0?A.jsxs("div",{style:{fontSize:F.sm,color:me,marginTop:O[2]},children:[t.unknownTextureCount," texture(s) have no reliable VRAM estimate — totals are lower bounds."]}):null]})}function sh(){const[e,t]=Y.useState(null);return Y.useEffect(()=>{let s=!0;return ot().then(r=>{s&&t(r.capabilities)}),()=>{s=!1}},[]),e}function rh(e){const t=e.afterBytes-e.beforeBytes,s=e.beforeBytes>0?Math.round(t/e.beforeBytes*100):0;return`${ae(e.beforeBytes)} → ${ae(e.afterBytes)} (${s>0?"+":""}${s}%)`}function Ct({testId:e,label:t,availability:s,busy:r,activeTitle:n,onClick:o}){const i=s?.available?n:s?.reason??"Probing codec availability…";return A.jsx(st,{type:"button",size:"compact","data-testid":e,disabled:r||!s?.available||!o,title:i,onClick:o,children:t})}function nh({pending:e,busy:t,onApply:s,onCancel:r}){return A.jsxs("div",{"data-testid":"asset-budget-op-confirm",style:{marginTop:O[3],padding:O[4],border:`1px solid ${ht[1]}`,borderRadius:Lt.sm},children:[A.jsxs("div",{"data-testid":"asset-budget-op-diff",style:{fontSize:F.base,color:G[1]},children:[e.label,": ",rh(e.outcome)]}),e.lod?A.jsxs("div",{style:{fontSize:F.base,color:G[3],marginTop:O[1]},children:[e.lod.levels.map(n=>`${n.node} ${dt(n.triangles)} tris`).join(" · ")," ","(base ",dt(e.lod.baseTriangles),")"]}):A.jsx("div",{style:{fontSize:F.base,color:me,marginTop:O[1]},children:"Rewrites the file on disk — not undoable from the editor."}),A.jsxs("div",{style:{display:"flex",gap:O[2],marginTop:O[3]},children:[A.jsx(st,{type:"button",size:"compact",variant:"primary","data-testid":"asset-budget-op-apply",disabled:t,onClick:s,children:"Apply"}),A.jsx(st,{type:"button",size:"compact","data-testid":"asset-budget-op-cancel",disabled:t,onClick:r,children:"Cancel"})]})]})}function ih({busy:e,error:t,stampError:s}){return A.jsxs(A.Fragment,{children:[e?A.jsxs("div",{"data-testid":"asset-budget-op-busy",style:{fontSize:F.base,color:G[3],marginTop:O[3]},children:[e,"…"]}):null,t?A.jsx("div",{"data-testid":"asset-budget-op-error",style:{fontSize:F.base,color:Xt,marginTop:O[3]},children:t}):null,s?A.jsx("div",{"data-testid":"asset-budget-stamp-error",style:{fontSize:F.base,color:me,marginTop:O[3]},children:s}):null]})}function oh({entry:e,onApplied:t}){const s=sh(),[r,n]=Y.useState(null),[o,i]=Y.useState(null),[a,c]=Y.useState(null),[l,u]=Y.useState(null),[h,f]=Y.useState("");if(e.category!=="model")return null;if(!/\.glb$/i.test(e.path))return A.jsx("div",{style:{marginTop:O[5],fontSize:F.base,color:G[3]},children:"Optimization supports single-file .glb assets (this is a multi-file .gltf)."});if(e.inspectError)return null;const g=(d,y,m,E)=>{n(d),i(null),c(null),u(null),Bt().readBytes(e.path).then(m).then(b=>{u({label:d,operationName:y,...E?{params:E}:{},outcome:b,..."levels"in b?{lod:b}:{}})}).catch(b=>{i(b instanceof Error?b.message:String(b))}).finally(()=>n(null))},T=()=>{l&&(n(l.label),Bf(Bt(),{operationName:l.operationName,storagePath:e.path,beforeBytes:l.outcome.beforeBytes,beforeSha256:e.sha256,...l.params?{params:l.params}:{}},l.outcome.bytes).then(d=>{d.stampError&&c(`Optimized, but provenance stamp failed: ${d.stampError}`),u(null),t()}).catch(d=>{i(d instanceof Error?d.message:String(d))}).finally(()=>n(null)))},p=e.model?.meshNames??[],x=h||p[0]||"";return A.jsxs("div",{style:{marginTop:O[6]},children:[A.jsx("div",{style:{fontSize:F.base,fontWeight:600,color:G[2],marginBottom:O[2]},children:"Optimize"}),A.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:O[2]},children:[A.jsx(Ct,{testId:"asset-budget-op-meshopt",label:"Compress · meshopt",availability:s?.meshoptEncoder,busy:r!==null,activeTitle:"Reorder + quantize + EXT_meshopt_compression",onClick:()=>g("Meshopt","asset-budget.meshopt",vf,{codec:"meshopt"})}),A.jsx(Ct,{testId:"asset-budget-op-draco",label:"Compress · Draco",availability:s?.dracoEncoder,busy:r!==null,activeTitle:"KHR_draco_mesh_compression",onClick:()=>g("Draco","asset-budget.draco",Rf,{codec:"draco"})}),A.jsx(Ct,{testId:"asset-budget-op-ktx2",label:"Compress textures · KTX2",availability:s?.ktx2Encoder,busy:r!==null,activeTitle:"KHR_texture_basisu — ETC1S for color maps, UASTC for normal/ORM data",onClick:()=>g("KTX2","asset-budget.ktx2",Cf,{codec:"ktx2"})})]}),p.length>0?A.jsxs("div",{style:{display:"flex",gap:O[2],marginTop:O[3]},children:[A.jsx(li,{className:"volter-select","aria-label":"LOD base node","data-testid":"asset-budget-op-lod-node",value:x,onChange:d=>f(d.target.value),style:{flex:1,minWidth:0},children:p.map(d=>A.jsx("option",{value:d,children:d},d))}),A.jsx(Ct,{testId:"asset-budget-op-lod",label:"Generate LOD nodes",availability:s?.meshoptSimplifier,busy:r!==null||!x,activeTitle:"simplify() the chosen node into _LOD1/_LOD2 sibling nodes (additive — base geometry untouched). Add mesh.lod rows from the Mesh inspector.",onClick:()=>g("Generate LODs","asset-budget.lod-levels",d=>Df(d,x),{baseNode:x})})]}):null,l?A.jsx(nh,{pending:l,busy:r!==null,onApply:T,onCancel:()=>u(null)}):null,A.jsx(ih,{busy:r,error:o,stampError:a})]})}function ah({entry:e,codeReferencesScanned:t}){return A.jsxs("div",{style:{marginTop:O[5]},children:[A.jsxs("div",{style:{fontSize:F.base,fontWeight:600,color:G[2]},children:["What uses this (",e.references.length,")"]}),e.engineVendored?A.jsx("div",{"data-testid":"asset-budget-engine-runtime",style:{fontSize:F.base,color:G[3]},children:"Engine runtime (Three.js examples/jsm) — loaded by the engine at runtime, not by project content. Required infrastructure; not safe to delete."}):e.references.length===0?A.jsxs(A.Fragment,{children:[A.jsx("div",{"data-testid":"asset-budget-no-references",style:{fontSize:F.base,color:me},children:"Nothing in this project’s manifest, code, or other assets references this asset."}),t?null:A.jsx("div",{"data-testid":"asset-budget-code-not-scanned",style:{fontSize:F.sm,color:me,marginTop:O[1],lineHeight:an.normal},children:"Code references (src/**) are not scanned in server mode — an asset used only from code will show here. Not necessarily safe to delete."})]}):e.references.map(s=>A.jsxs("div",{"data-testid":"asset-budget-reference",style:{fontSize:F.base,padding:`${O[1]} 0`},children:[A.jsx("span",{style:{color:G[1],fontFamily:gt},children:s.ownerPath}),A.jsxs("span",{style:{color:G[3]},children:[" ","· ",s.kind,s.jsonPath?` · ${s.jsonPath}`:""]})]},`${s.ownerPath}:${s.jsonPath??s.kind}`))]})}function _h(){Y.useSyncExternalStore(kf,zf);const{report:e,loading:t,error:s,refresh:r,stale:n}=Xf(),[o,i]=Y.useState("bytes"),[a,c]=Y.useState(-1),[l,u]=Y.useState(null);Y.useEffect(()=>{if(!e)return;const T=Gf();if(T===null)return;const p=T.replace(/^\/+/,""),x=e.entries.find(d=>d.path===p||d.path===`public/${p}`||`public/${d.path}`===p);x&&u(x.path)},[e]);const h=Y.useCallback(T=>{T===o?c(p=>p===1?-1:1):(i(T),c(T==="path"||T==="category"?1:-1))},[o]),f=e?Kf(e.entries,o,a):[],g=e?.entries.find(T=>T.path===l)??null;return A.jsxs("div",{"data-testid":"asset-budget-document",style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,background:Ls[1],color:G[1],pointerEvents:"auto"},children:[A.jsxs("div",{style:{display:"flex",alignItems:"center",gap:O[4],padding:`${O[3]} ${O[5]}`,borderBottom:`1px solid ${ht[1]}`},children:[A.jsx("span",{style:{fontSize:F.md,fontWeight:600},children:"Asset Budget"}),A.jsx(st,{type:"button",size:"compact","data-testid":"asset-budget-refresh",onClick:r,children:"Refresh"}),n?A.jsx("span",{"data-testid":"asset-budget-stale",style:{fontSize:F.base,color:me},children:"Project files changed — refresh for current numbers."}):null,t?A.jsx("span",{"data-testid":"asset-budget-loading",style:{fontSize:F.base,color:G[3]},children:"Analyzing…"}):null]}),s?A.jsxs("div",{"data-testid":"asset-budget-error",style:{padding:O[6],color:Xt,fontSize:F.md},children:["Analysis failed: ",s]}):null,e?A.jsxs("div",{style:{display:"flex",flex:1,minHeight:0},children:[A.jsxs("div",{style:{flex:2,minWidth:0,overflow:"auto",borderRight:`1px solid ${ht[1]}`},children:[A.jsx(Jf,{report:e}),A.jsxs("table",{"data-testid":"asset-budget-table",style:{width:"100%",borderCollapse:"collapse",fontSize:F.md},children:[A.jsx("thead",{children:A.jsxs("tr",{children:[A.jsx(We,{label:"Asset",sortKey:"path",active:o==="path",direction:a,onSort:h}),A.jsx(We,{label:"Category",sortKey:"category",active:o==="category",direction:a,onSort:h}),A.jsx(We,{label:"Size",sortKey:"bytes",active:o==="bytes",direction:a,onSort:h,align:"right"}),A.jsx(We,{label:"VRAM est.",sortKey:"vram",active:o==="vram",direction:a,onSort:h,align:"right"}),A.jsx(We,{label:"Tris",sortKey:"tris",active:o==="tris",direction:a,onSort:h,align:"right"}),A.jsx(We,{label:"Refs",sortKey:"refs",active:o==="refs",direction:a,onSort:h,align:"right"})]})}),A.jsx("tbody",{children:f.map(T=>A.jsx(Yf,{entry:T,selected:T.path===l,onSelect:u},T.path))})]}),A.jsx(Qf,{report:e,onSelect:u}),A.jsx(Zf,{report:e})]}),A.jsx("div",{style:{flex:1,minWidth:220,overflow:"auto"},children:A.jsx(eh,{entry:g,onApplied:r,codeReferencesScanned:e.codeReferencesScanned})})]}):null]})}export{_h as A,bh as o};