zigbee2mqtt-windfront 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/dist/assets/{About-i-o7Fha7.js → About-BjjkLPGF.js} +2 -2
  2. package/dist/assets/About-BjjkLPGF.js.br +0 -0
  3. package/dist/assets/{ActivityPage-GriRdyJK.js → ActivityPage-D8tN_mhu.js} +1 -1
  4. package/dist/assets/ActivityPage-D8tN_mhu.js.br +0 -0
  5. package/dist/assets/{Availability-YPjK9GZh.js → Availability-ChpD5KfG.js} +1 -1
  6. package/dist/assets/Availability-ChpD5KfG.js.br +0 -0
  7. package/dist/assets/Bind-DCoy61S7.js +1 -0
  8. package/dist/assets/Bind-DCoy61S7.js.br +0 -0
  9. package/dist/assets/{BindRow-D9Od6x88.js → BindRow-nmfFVYoP.js} +1 -1
  10. package/dist/assets/BindRow-nmfFVYoP.js.br +0 -0
  11. package/dist/assets/BindingsPage-NlmNzolq.js +1 -0
  12. package/dist/assets/BindingsPage-NlmNzolq.js.br +0 -0
  13. package/dist/assets/Bridge-DFI7IofN.js +1 -0
  14. package/dist/assets/Bridge-DFI7IofN.js.br +0 -0
  15. package/dist/assets/{CheckboxField-DDGxPCob.js → CheckboxField-BG1LLMGl.js} +1 -1
  16. package/dist/assets/CheckboxField-BG1LLMGl.js.br +2 -0
  17. package/dist/assets/ClusterSinglePicker-BftJs6_P.js +1 -0
  18. package/dist/assets/ClusterSinglePicker-BftJs6_P.js.br +0 -0
  19. package/dist/assets/{Clusters-DchCgFcV.js → Clusters-Cv06_EfE.js} +1 -1
  20. package/dist/assets/Clusters-Cv06_EfE.js.br +0 -0
  21. package/dist/assets/{ContributePage-CyXoSvR_.js → ContributePage-DgB19g-n.js} +1 -1
  22. package/dist/assets/ContributePage-DgB19g-n.js.br +0 -0
  23. package/dist/assets/{Dashboard-Bl8dJ0ah.js → Dashboard-D8eCMg1E.js} +1 -1
  24. package/dist/assets/Dashboard-D8eCMg1E.js.br +0 -0
  25. package/dist/assets/{DashboardFeatureWrapper-UEMN2W33.js → DashboardFeatureWrapper-BneTc8AG.js} +1 -1
  26. package/dist/assets/DashboardFeatureWrapper-BneTc8AG.js.br +0 -0
  27. package/dist/assets/{DebouncedInput-B_mSPoL2.js → DebouncedInput-DiI3jY3Y.js} +1 -1
  28. package/dist/assets/DebouncedInput-DiI3jY3Y.js.br +0 -0
  29. package/dist/assets/DevConsole-BuvrFNnY.js +1 -0
  30. package/dist/assets/DevConsole-BuvrFNnY.js.br +0 -0
  31. package/dist/assets/DevConsole-DPZ5Q1SV.js +7 -0
  32. package/dist/assets/DevConsole-DPZ5Q1SV.js.br +0 -0
  33. package/dist/assets/{DeviceCard-CE7t_uOW.js → DeviceCard-CbA-Muhm.js} +1 -1
  34. package/dist/assets/DeviceCard-CbA-Muhm.js.br +0 -0
  35. package/dist/assets/DeviceImage-2MDqGl5C.js +1 -0
  36. package/dist/assets/DeviceImage-2MDqGl5C.js.br +0 -0
  37. package/dist/assets/{DeviceInfo-BGYj26ZS.js → DeviceInfo-2jbuHZ-h.js} +3 -3
  38. package/dist/assets/DeviceInfo-2jbuHZ-h.js.br +0 -0
  39. package/dist/assets/{DevicePage-D4AS3RcM.js → DevicePage-ZszWuDsI.js} +2 -2
  40. package/dist/assets/DevicePage-ZszWuDsI.js.br +0 -0
  41. package/dist/assets/{DevicePicker-Eg-X3fKz.js → DevicePicker-B_PDo9wi.js} +1 -1
  42. package/dist/assets/DevicePicker-B_PDo9wi.js.br +0 -0
  43. package/dist/assets/DeviceSettings-DWB0mi-3.js +1 -0
  44. package/dist/assets/DeviceSettings-DWB0mi-3.js.br +0 -0
  45. package/dist/assets/DeviceSpecificSettings-DjEM0kVL.js +1 -0
  46. package/dist/assets/DeviceSpecificSettings-DjEM0kVL.js.br +0 -0
  47. package/dist/assets/Devices-JfRo8T0C.js +1 -0
  48. package/dist/assets/Devices-JfRo8T0C.js.br +0 -0
  49. package/dist/assets/{DevicesPage-WM7hxalV.js → DevicesPage-XrSyXmD5.js} +1 -1
  50. package/dist/assets/DevicesPage-XrSyXmD5.js.br +0 -0
  51. package/dist/assets/{DisplayValue-BZ-eaAKu.js → DisplayValue-CApLeme3.js} +1 -1
  52. package/dist/assets/DisplayValue-CApLeme3.js.br +0 -0
  53. package/dist/assets/{Duration-CzwYBX29.js → Duration-B_1JBNda.js} +1 -1
  54. package/dist/assets/Duration-B_1JBNda.js.br +0 -0
  55. package/dist/assets/{EndpointPicker-DtqElVGb.js → EndpointPicker-CrX12uJY.js} +1 -1
  56. package/dist/assets/EndpointPicker-CrX12uJY.js.br +0 -0
  57. package/dist/assets/{Exposes-DfrJAUra.js → Exposes-DER69NVK.js} +1 -1
  58. package/dist/assets/Exposes-DER69NVK.js.br +0 -0
  59. package/dist/assets/{Feature-BJ8zY1Ga.js → Feature-DYcNfxa0.js} +1 -1
  60. package/dist/assets/Feature-DYcNfxa0.js.br +0 -0
  61. package/dist/assets/FrontendSettingsPage-D8hy8YoU.js +1 -0
  62. package/dist/assets/FrontendSettingsPage-D8hy8YoU.js.br +0 -0
  63. package/dist/assets/{GroupPage-fVYGZqzs.js → GroupPage-BFXg0-R1.js} +2 -2
  64. package/dist/assets/GroupPage-BFXg0-R1.js.br +0 -0
  65. package/dist/assets/{GroupSettings-2DGc5J43.js → GroupSettings-KjnM44Jv.js} +1 -1
  66. package/dist/assets/GroupSettings-KjnM44Jv.js.br +0 -0
  67. package/dist/assets/{Groups-9FD4ZbHT.js → Groups-Da6Rz4iJ.js} +1 -1
  68. package/dist/assets/Groups-Da6Rz4iJ.js.br +0 -0
  69. package/dist/assets/{GroupsPage-DIXFxgLg.js → GroupsPage-Cwb8IGSP.js} +1 -1
  70. package/dist/assets/GroupsPage-Cwb8IGSP.js.br +0 -0
  71. package/dist/assets/{Health-BwDAB_DL.js → Health-BgieGgKo.js} +1 -1
  72. package/dist/assets/Health-BgieGgKo.js.br +0 -0
  73. package/dist/assets/HomePage-McIsQE6S.js +1 -0
  74. package/dist/assets/HomePage-McIsQE6S.js.br +0 -0
  75. package/dist/assets/{IndeterminateCheckbox-xTLsM_wF.js → IndeterminateCheckbox-C3pUYBaD.js} +1 -1
  76. package/dist/assets/IndeterminateCheckbox-C3pUYBaD.js.br +1 -0
  77. package/dist/assets/InfoAlert-vRBz3Nln.js +1 -0
  78. package/dist/assets/InfoAlert-vRBz3Nln.js.br +0 -0
  79. package/dist/assets/{InputField-BYfjYPOY.js → InputField-D-x1inWL.js} +1 -1
  80. package/dist/assets/InputField-D-x1inWL.js.br +0 -0
  81. package/dist/assets/{Json-Bv-xu1u4.js → Json-BMewAsAW.js} +1 -1
  82. package/dist/assets/Json-BMewAsAW.js.br +0 -0
  83. package/dist/assets/{LastSeen-DA4kaWWb.js → LastSeen-Dn358ZkP.js} +1 -1
  84. package/dist/assets/LastSeen-Dn358ZkP.js.br +0 -0
  85. package/dist/assets/{LogsPage-DggXPpYo.js → LogsPage-DzKwBLUx.js} +1 -1
  86. package/dist/assets/LogsPage-DzKwBLUx.js.br +0 -0
  87. package/dist/assets/Lqi-79tfQuJa.js +1 -0
  88. package/dist/assets/Lqi-79tfQuJa.js.br +0 -0
  89. package/dist/assets/NetworkPage-B9T2nSXp.js +2 -0
  90. package/dist/assets/NetworkPage-B9T2nSXp.js.br +0 -0
  91. package/dist/assets/{NumberField-DVKVcA4j.js → NumberField-C3FamvUt.js} +1 -1
  92. package/dist/assets/NumberField-C3FamvUt.js.br +0 -0
  93. package/dist/assets/{OtaPage-Bam-Dpba.js → OtaPage-Ch0houzc.js} +1 -1
  94. package/dist/assets/OtaPage-Ch0houzc.js.br +0 -0
  95. package/dist/assets/PowerSource-CCIOw1ZA.js +1 -0
  96. package/dist/assets/PowerSource-CCIOw1ZA.js.br +0 -0
  97. package/dist/assets/RawNetworkData-D2vUMp1M.js +20 -0
  98. package/dist/assets/RawNetworkData-D2vUMp1M.js.br +0 -0
  99. package/dist/assets/{RawNetworkMap-C2gM7U6b.js → RawNetworkMap-BIzbLBhk.js} +2 -2
  100. package/dist/assets/RawNetworkMap-BIzbLBhk.js.br +0 -0
  101. package/dist/assets/{RecallRemove-ByQ3RXQY.js → RecallRemove-BPgeFxBf.js} +1 -1
  102. package/dist/assets/RecallRemove-BPgeFxBf.js.br +0 -0
  103. package/dist/assets/{RemoveDeviceModal-BFCk98E2.js → RemoveDeviceModal-BYx8ukJs.js} +1 -1
  104. package/dist/assets/RemoveDeviceModal-BYx8ukJs.js.br +0 -0
  105. package/dist/assets/Reporting-CW5TBnNZ.js +1 -0
  106. package/dist/assets/Reporting-CW5TBnNZ.js.br +0 -0
  107. package/dist/assets/ReportingPage-DPwg661I.js +1 -0
  108. package/dist/assets/ReportingPage-DPwg661I.js.br +0 -0
  109. package/dist/assets/ReportingRow-CCSmWGA-.js +1 -0
  110. package/dist/assets/ReportingRow-CCSmWGA-.js.br +0 -0
  111. package/dist/assets/{Scene-BJBl-O9V.js → Scene-CDTm8d_V.js} +1 -1
  112. package/dist/assets/Scene-CDTm8d_V.js.br +0 -0
  113. package/dist/assets/{SelectField-CGrVloaL.js → SelectField-Cy49-kUL.js} +1 -1
  114. package/dist/assets/SelectField-Cy49-kUL.js.br +0 -0
  115. package/dist/assets/{Settings-CGw2oF0C.js → Settings-DqV5iq7V.js} +1 -1
  116. package/dist/assets/Settings-DqV5iq7V.js.br +2 -0
  117. package/dist/assets/{SettingsList-CTeXhdEC.js → SettingsList-etcr6VWn.js} +1 -1
  118. package/dist/assets/SettingsList-etcr6VWn.js.br +0 -0
  119. package/dist/assets/SettingsPage-CIr69H-r.js +2 -0
  120. package/dist/assets/SettingsPage-CIr69H-r.js.br +0 -0
  121. package/dist/assets/State-IcdNV1n6.js +1 -0
  122. package/dist/assets/State-IcdNV1n6.js.br +0 -0
  123. package/dist/assets/Table-BKRTiwxS.js +1 -0
  124. package/dist/assets/Table-BKRTiwxS.js.br +0 -0
  125. package/dist/assets/{TextareaField-Dnm7VOj3.js → TextareaField-CnqB7i_A.js} +1 -1
  126. package/dist/assets/TextareaField-CnqB7i_A.js.br +0 -0
  127. package/dist/assets/{TimeAgo-BBbvibZK.js → TimeAgo-DfV_oP-E.js} +1 -1
  128. package/dist/assets/TimeAgo-DfV_oP-E.js.br +0 -0
  129. package/dist/assets/{Tools-BWzGZOoh.js → Tools-BdpmwKVP.js} +1 -1
  130. package/dist/assets/Tools-BdpmwKVP.js.br +0 -0
  131. package/dist/assets/TouchlinkPage-CgvNTyev.js +1 -0
  132. package/dist/assets/TouchlinkPage-CgvNTyev.js.br +0 -0
  133. package/dist/assets/{VendorLink-Cx9U94p9.js → VendorLink-BuoMohq1.js} +1 -1
  134. package/dist/assets/VendorLink-BuoMohq1.js.br +0 -0
  135. package/dist/assets/{_createCompounder-DvelL9we.js → _createCompounder-Cpit22M8.js} +1 -1
  136. package/dist/assets/_createCompounder-Cpit22M8.js.br +0 -0
  137. package/dist/assets/{floating-ui.react-MIvSYIT3.js → floating-ui.react-CwAhhbbA.js} +1 -1
  138. package/dist/assets/floating-ui.react-CwAhhbbA.js.br +0 -0
  139. package/dist/assets/{index-BWJZAMXy.js → index-Du_VEcSu.js} +1 -1
  140. package/dist/assets/index-Du_VEcSu.js.br +0 -0
  141. package/dist/assets/index-DvPcNtN4.js +579 -0
  142. package/dist/assets/index-DvPcNtN4.js.br +0 -0
  143. package/dist/assets/{index-BnCNGENq.js → index-oBzWmaJ3.js} +1 -1
  144. package/dist/assets/index-oBzWmaJ3.js.br +0 -0
  145. package/dist/assets/{index-Zvf07u5t.css → index-uKtJ6Klq.css} +1 -1
  146. package/dist/assets/index-uKtJ6Klq.css.br +0 -0
  147. package/dist/assets/{isObjectLike-D2GWafVk.js → isObjectLike-BbV-G3AH.js} +1 -1
  148. package/dist/assets/isObjectLike-BbV-G3AH.js.br +0 -0
  149. package/dist/assets/{jszip.min-CkTd3RZ4.js → jszip.min-DpqEU-AC.js} +1 -1
  150. package/dist/assets/jszip.min-DpqEU-AC.js.br +0 -0
  151. package/dist/assets/{merge-D15LJ0wW.js → merge-BrLzJdog.js} +1 -1
  152. package/dist/assets/merge-BrLzJdog.js.br +0 -0
  153. package/dist/assets/snakeCase-tFFG4Nty.js +1 -0
  154. package/dist/assets/snakeCase-tFFG4Nty.js.br +0 -0
  155. package/dist/assets/{useColumnCount-CDIFEtdP.js → useColumnCount-D651_cRH.js} +1 -1
  156. package/dist/assets/useColumnCount-D651_cRH.js.br +0 -0
  157. package/dist/assets/{useSearch-CiQm9ZMA.js → useSearch-RmJYqgpp.js} +1 -1
  158. package/dist/assets/useSearch-RmJYqgpp.js.br +0 -0
  159. package/dist/assets/{useTable-CC5yv3vQ.js → useTable-veJjfSQc.js} +1 -1
  160. package/dist/assets/useTable-veJjfSQc.js.br +0 -0
  161. package/dist/index.html +2 -2
  162. package/dist/index.html.br +0 -0
  163. package/package.json +13 -13
  164. package/dist/assets/About-i-o7Fha7.js.br +0 -0
  165. package/dist/assets/ActivityPage-GriRdyJK.js.br +0 -0
  166. package/dist/assets/Availability-YPjK9GZh.js.br +0 -0
  167. package/dist/assets/Bind-Cvv2GXES.js +0 -1
  168. package/dist/assets/Bind-Cvv2GXES.js.br +0 -0
  169. package/dist/assets/BindRow-D9Od6x88.js.br +0 -0
  170. package/dist/assets/BindingsPage-MMC7xnsC.js +0 -1
  171. package/dist/assets/BindingsPage-MMC7xnsC.js.br +0 -0
  172. package/dist/assets/Bridge-C1yjMZnP.js +0 -1
  173. package/dist/assets/Bridge-C1yjMZnP.js.br +0 -0
  174. package/dist/assets/CheckboxField-DDGxPCob.js.br +0 -0
  175. package/dist/assets/ClusterSinglePicker-wRw4n9xD.js +0 -1
  176. package/dist/assets/ClusterSinglePicker-wRw4n9xD.js.br +0 -0
  177. package/dist/assets/Clusters-DchCgFcV.js.br +0 -0
  178. package/dist/assets/ContributePage-CyXoSvR_.js.br +0 -0
  179. package/dist/assets/Dashboard-Bl8dJ0ah.js.br +0 -0
  180. package/dist/assets/DashboardFeatureWrapper-UEMN2W33.js.br +0 -0
  181. package/dist/assets/DebouncedInput-B_mSPoL2.js.br +0 -0
  182. package/dist/assets/DevConsole-BGDUMunS.js +0 -1
  183. package/dist/assets/DevConsole-BGDUMunS.js.br +0 -0
  184. package/dist/assets/DevConsole-DAJXOXwE.js +0 -7
  185. package/dist/assets/DevConsole-DAJXOXwE.js.br +0 -0
  186. package/dist/assets/DeviceCard-CE7t_uOW.js.br +0 -0
  187. package/dist/assets/DeviceImage-C6iSUjiJ.js +0 -1
  188. package/dist/assets/DeviceImage-C6iSUjiJ.js.br +0 -0
  189. package/dist/assets/DeviceInfo-BGYj26ZS.js.br +0 -0
  190. package/dist/assets/DevicePage-D4AS3RcM.js.br +0 -0
  191. package/dist/assets/DevicePicker-Eg-X3fKz.js.br +0 -0
  192. package/dist/assets/DeviceSettings-CduJmEdd.js +0 -1
  193. package/dist/assets/DeviceSettings-CduJmEdd.js.br +0 -0
  194. package/dist/assets/DeviceSpecificSettings-DW4AG8ZF.js +0 -1
  195. package/dist/assets/DeviceSpecificSettings-DW4AG8ZF.js.br +0 -0
  196. package/dist/assets/Devices-BFJMMQk1.js +0 -1
  197. package/dist/assets/Devices-BFJMMQk1.js.br +0 -0
  198. package/dist/assets/DevicesPage-WM7hxalV.js.br +0 -0
  199. package/dist/assets/DisplayValue-BZ-eaAKu.js.br +0 -0
  200. package/dist/assets/Duration-CzwYBX29.js.br +0 -0
  201. package/dist/assets/EndpointPicker-DtqElVGb.js.br +0 -0
  202. package/dist/assets/Exposes-DfrJAUra.js.br +0 -0
  203. package/dist/assets/Feature-BJ8zY1Ga.js.br +0 -0
  204. package/dist/assets/FrontendSettingsPage-CA1akody.js +0 -1
  205. package/dist/assets/FrontendSettingsPage-CA1akody.js.br +0 -0
  206. package/dist/assets/GroupPage-fVYGZqzs.js.br +0 -0
  207. package/dist/assets/GroupSettings-2DGc5J43.js.br +0 -0
  208. package/dist/assets/Groups-9FD4ZbHT.js.br +0 -0
  209. package/dist/assets/GroupsPage-DIXFxgLg.js.br +0 -0
  210. package/dist/assets/Health-BwDAB_DL.js.br +0 -0
  211. package/dist/assets/HomePage-CA93CxkX.js +0 -1
  212. package/dist/assets/HomePage-CA93CxkX.js.br +0 -0
  213. package/dist/assets/IndeterminateCheckbox-xTLsM_wF.js.br +0 -0
  214. package/dist/assets/InfoAlert-BEMI4UFc.js +0 -1
  215. package/dist/assets/InfoAlert-BEMI4UFc.js.br +0 -0
  216. package/dist/assets/InputField-BYfjYPOY.js.br +0 -0
  217. package/dist/assets/Json-Bv-xu1u4.js.br +0 -0
  218. package/dist/assets/LastSeen-DA4kaWWb.js.br +0 -0
  219. package/dist/assets/LogsPage-DggXPpYo.js.br +0 -0
  220. package/dist/assets/Lqi-BLFaxsM9.js +0 -1
  221. package/dist/assets/Lqi-BLFaxsM9.js.br +0 -0
  222. package/dist/assets/NetworkPage-fX6p5Jft.js +0 -2
  223. package/dist/assets/NetworkPage-fX6p5Jft.js.br +0 -0
  224. package/dist/assets/NumberField-DVKVcA4j.js.br +0 -0
  225. package/dist/assets/OtaPage-Bam-Dpba.js.br +0 -0
  226. package/dist/assets/PowerSource-D71Ibdxv.js +0 -1
  227. package/dist/assets/PowerSource-D71Ibdxv.js.br +0 -0
  228. package/dist/assets/RawNetworkData-CTWMGGj7.js +0 -20
  229. package/dist/assets/RawNetworkData-CTWMGGj7.js.br +0 -0
  230. package/dist/assets/RawNetworkMap-C2gM7U6b.js.br +0 -0
  231. package/dist/assets/RecallRemove-ByQ3RXQY.js.br +0 -0
  232. package/dist/assets/RemoveDeviceModal-BFCk98E2.js.br +0 -0
  233. package/dist/assets/Reporting-BkJlvwAN.js +0 -1
  234. package/dist/assets/Reporting-BkJlvwAN.js.br +0 -0
  235. package/dist/assets/ReportingPage-BohlZbl0.js +0 -1
  236. package/dist/assets/ReportingPage-BohlZbl0.js.br +0 -0
  237. package/dist/assets/ReportingRow-CxmihB6I.js +0 -1
  238. package/dist/assets/ReportingRow-CxmihB6I.js.br +0 -0
  239. package/dist/assets/Scene-BJBl-O9V.js.br +0 -0
  240. package/dist/assets/SelectField-CGrVloaL.js.br +0 -0
  241. package/dist/assets/Settings-CGw2oF0C.js.br +0 -0
  242. package/dist/assets/SettingsList-CTeXhdEC.js.br +0 -0
  243. package/dist/assets/SettingsPage-prek-fOp.js +0 -2
  244. package/dist/assets/SettingsPage-prek-fOp.js.br +0 -0
  245. package/dist/assets/State-B1hWOtmK.js +0 -1
  246. package/dist/assets/State-B1hWOtmK.js.br +0 -0
  247. package/dist/assets/Table-DQSQ_sYq.js +0 -1
  248. package/dist/assets/Table-DQSQ_sYq.js.br +0 -0
  249. package/dist/assets/TextareaField-Dnm7VOj3.js.br +0 -0
  250. package/dist/assets/TimeAgo-BBbvibZK.js.br +0 -0
  251. package/dist/assets/Tools-BWzGZOoh.js.br +0 -0
  252. package/dist/assets/TouchlinkPage-C3ESWw4F.js +0 -1
  253. package/dist/assets/TouchlinkPage-C3ESWw4F.js.br +0 -0
  254. package/dist/assets/VendorLink-Cx9U94p9.js.br +0 -0
  255. package/dist/assets/_createCompounder-DvelL9we.js.br +0 -0
  256. package/dist/assets/floating-ui.react-MIvSYIT3.js.br +0 -0
  257. package/dist/assets/index-BWJZAMXy.js.br +0 -2
  258. package/dist/assets/index-BnCNGENq.js.br +0 -0
  259. package/dist/assets/index-O2DLxYbj.js +0 -579
  260. package/dist/assets/index-O2DLxYbj.js.br +0 -0
  261. package/dist/assets/index-Zvf07u5t.css.br +0 -0
  262. package/dist/assets/isObjectLike-D2GWafVk.js.br +0 -0
  263. package/dist/assets/jszip.min-CkTd3RZ4.js.br +0 -0
  264. package/dist/assets/merge-D15LJ0wW.js.br +0 -0
  265. package/dist/assets/snakeCase-DDe65ywx.js +0 -1
  266. package/dist/assets/snakeCase-DDe65ywx.js.br +0 -0
  267. package/dist/assets/useColumnCount-CDIFEtdP.js.br +0 -0
  268. package/dist/assets/useSearch-CiQm9ZMA.js.br +0 -0
  269. package/dist/assets/useTable-CC5yv3vQ.js.br +0 -0
@@ -1,4 +1,4 @@
1
- import{b2 as gA,b3 as PU,aL as po,b4 as zU,b5 as nf,r as K,j as he,b6 as FU,b7 as BU,b8 as kU,C as vA,u as wg,t as GU,F as Yn,ag as HU,B as Lr,b9 as VU,ba as WU,f as XU,bb as jU,bc as qU,bd as YU,be as ZU,bf as KU,bg as JU,ao as iu,bh as QU,bi as $U,bj as eO,Z as tO,bk as kv,a as nO,l as qS,aw as YS}from"./index-O2DLxYbj.js";import{m as iO}from"./merge-D15LJ0wW.js";import{g as rO,a as sO}from"./index-BWJZAMXy.js";import{E as _l,Z as hi,N as im,c as fh}from"./index-Bs7zcW7e.js";import"./envs-CSqIi4cL.js";import"./isObjectLike-D2GWafVk.js";import"./isObject--vsEa_js.js";var Gv={exports:{}},Qs={};var ZS;function aO(){return ZS||(ZS=1,Qs.ConcurrentRoot=1,Qs.ContinuousEventPriority=8,Qs.DefaultEventPriority=32,Qs.DiscreteEventPriority=2,Qs.IdleEventPriority=268435456,Qs.LegacyRoot=0,Qs.NoEventPriority=0),Qs}var KS;function oO(){return KS||(KS=1,Gv.exports=aO()),Gv.exports}var rm=oO();const Tg="180",yA={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lO={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},_A=0,H_=1,xA=2,cO=3,bA=0,Ag=1,rf=2,is=3,ya=0,Fi=1,zn=2,pa=0,xl=1,V_=2,W_=3,X_=4,SA=5,io=100,EA=101,MA=102,wA=103,TA=104,AA=200,CA=201,RA=202,DA=203,vm=204,ym=205,UA=206,OA=207,LA=208,IA=209,NA=210,PA=211,zA=212,FA=213,BA=214,_m=0,xm=1,bm=2,wl=3,Sm=4,Em=5,Mm=6,wm=7,Kf=0,kA=1,GA=2,Ts=0,HA=1,VA=2,WA=3,zx=4,XA=5,jA=6,qA=7,j_="attached",YA="detached",Cg=300,_a=301,co=302,xf=303,bf=304,wu=306,Sf=1e3,Fr=1001,Ef=1002,vi=1003,Fx=1004,uO=1004,Qc=1005,hO=1005,Fn=1006,sf=1007,fO=1007,Ms=1008,dO=1008,Gr=1009,Bx=1010,kx=1011,lu=1012,Rg=1013,xa=1014,Qi=1015,Tu=1016,Dg=1017,Ug=1018,cu=1020,Gx=35902,Hx=35899,Vx=1021,Wx=1022,Di=1023,uu=1026,hu=1027,Og=1028,Jf=1029,Xx=1030,Lg=1031,pO=1032,Ig=1033,af=33776,of=33777,lf=33778,cf=33779,Tm=35840,Am=35841,Cm=35842,Rm=35843,Dm=36196,Um=37492,Om=37496,Lm=37808,Im=37809,Nm=37810,Pm=37811,zm=37812,Fm=37813,Bm=37814,km=37815,Gm=37816,Hm=37817,Vm=37818,Wm=37819,Xm=37820,jm=37821,qm=36492,Ym=36494,Zm=36495,Km=36283,Jm=36284,Qm=36285,$m=36286,ZA=2200,KA=2201,JA=2202,Mf=2300,eg=2301,sm=2302,ml=2400,gl=2401,wf=2402,Ng=2500,jx=2501,mO=0,gO=1,vO=2,QA=3200,qx=3201,yO=3202,_O=3203,mo=0,$A=1,ha="",Ri="srgb",uo="srgb-linear",Tf="linear",an="srgb",xO=0,hl=7680,bO=7681,SO=7682,EO=7683,MO=34055,wO=34056,TO=5386,AO=512,CO=513,RO=514,DO=515,UO=516,OO=517,LO=518,q_=519,e2=512,t2=513,n2=514,Yx=515,i2=516,r2=517,s2=518,a2=519,Af=35044,IO=35048,NO=35040,PO=35045,zO=35049,FO=35041,BO=35046,kO=35050,GO=35042,HO="100",Y_="300 es",yr=2e3,fu=2001,VO={COMPUTE:"compute",RENDER:"render"},WO={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},XO={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};let Ds=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}};const Ti=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let JS=1234567;const bl=Math.PI/180,du=180/Math.PI;function _r(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ti[i&255]+Ti[i>>8&255]+Ti[i>>16&255]+Ti[i>>24&255]+"-"+Ti[e&255]+Ti[e>>8&255]+"-"+Ti[e>>16&15|64]+Ti[e>>24&255]+"-"+Ti[t&63|128]+Ti[t>>8&255]+"-"+Ti[t>>16&255]+Ti[t>>24&255]+Ti[n&255]+Ti[n>>8&255]+Ti[n>>16&255]+Ti[n>>24&255]).toLowerCase()}function St(i,e,t){return Math.max(e,Math.min(t,i))}function Zx(i,e){return(i%e+e)%e}function jO(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function qO(i,e,t){return i!==e?(t-i)/(e-i):0}function uf(i,e,t){return(1-t)*i+t*e}function YO(i,e,t,n){return uf(i,e,1-Math.exp(-t*n))}function ZO(i,e=1){return e-Math.abs(Zx(i,e*2)-e)}function KO(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function JO(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function QO(i,e){return i+Math.floor(Math.random()*(e-i+1))}function $O(i,e){return i+Math.random()*(e-i)}function eL(i){return i*(.5-Math.random())}function tL(i){i!==void 0&&(JS=i);let e=JS+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function nL(i){return i*bl}function iL(i){return i*du}function rL(i){return(i&i-1)===0&&i!==0}function sL(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function aL(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function oL(i,e,t,n,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),d=s((e-n)/2),p=a((e-n)/2),m=s((n-e)/2),v=a((n-e)/2);switch(r){case"XYX":i.set(o*h,l*d,l*p,o*c);break;case"YZY":i.set(l*p,o*h,l*d,o*c);break;case"ZXZ":i.set(l*d,l*p,o*h,o*c);break;case"XZX":i.set(o*h,l*v,l*m,o*c);break;case"YXY":i.set(l*m,o*h,l*v,o*c);break;case"ZYZ":i.set(l*v,l*m,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Pi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Ot(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const tg={DEG2RAD:bl,RAD2DEG:du,generateUUID:_r,clamp:St,euclideanModulo:Zx,mapLinear:jO,inverseLerp:qO,lerp:uf,damp:YO,pingpong:ZO,smoothstep:KO,smootherstep:JO,randInt:QO,randFloat:$O,randFloatSpread:eL,seededRandom:tL,degToRad:nL,radToDeg:iL,isPowerOfTwo:rL,ceilPowerOfTwo:sL,floorPowerOfTwo:aL,setQuaternionFromProperEuler:oL,normalize:Ot,denormalize:Pi};class ke{constructor(e=0,t=0){ke.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(St(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(St(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class yi{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],d=n[r+3];const p=s[a+0],m=s[a+1],v=s[a+2],x=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d;return}if(o===1){e[t+0]=p,e[t+1]=m,e[t+2]=v,e[t+3]=x;return}if(d!==x||l!==p||c!==m||h!==v){let _=1-o;const g=l*p+c*m+h*v+d*x,b=g>=0?1:-1,E=1-g*g;if(E>Number.EPSILON){const w=Math.sqrt(E),T=Math.atan2(w,g*b);_=Math.sin(_*T)/w,o=Math.sin(o*T)/w}const S=o*b;if(l=l*_+p*S,c=c*_+m*S,h=h*_+v*S,d=d*_+x*S,_===1-o){const w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],d=s[a],p=s[a+1],m=s[a+2],v=s[a+3];return e[t]=o*v+h*d+l*m-c*p,e[t+1]=l*v+h*p+c*d-o*m,e[t+2]=c*v+h*m+o*p-l*d,e[t+3]=h*v-o*d-l*p-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),d=o(s/2),p=l(n/2),m=l(r/2),v=l(s/2);switch(a){case"XYZ":this._x=p*h*d+c*m*v,this._y=c*m*d-p*h*v,this._z=c*h*v+p*m*d,this._w=c*h*d-p*m*v;break;case"YXZ":this._x=p*h*d+c*m*v,this._y=c*m*d-p*h*v,this._z=c*h*v-p*m*d,this._w=c*h*d+p*m*v;break;case"ZXY":this._x=p*h*d-c*m*v,this._y=c*m*d+p*h*v,this._z=c*h*v+p*m*d,this._w=c*h*d-p*m*v;break;case"ZYX":this._x=p*h*d-c*m*v,this._y=c*m*d+p*h*v,this._z=c*h*v-p*m*d,this._w=c*h*d+p*m*v;break;case"YZX":this._x=p*h*d+c*m*v,this._y=c*m*d+p*h*v,this._z=c*h*v-p*m*d,this._w=c*h*d-p*m*v;break;case"XZY":this._x=p*h*d-c*m*v,this._y=c*m*d-p*h*v,this._z=c*h*v+p*m*d,this._w=c*h*d+p*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],p=n+o+d;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(h-l)*m,this._y=(s-c)*m,this._z=(a-r)*m}else if(n>o&&n>d){const m=2*Math.sqrt(1+n-o-d);this._w=(h-l)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(s+c)/m}else if(o>d){const m=2*Math.sqrt(1+o-n-d);this._w=(s-c)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+d-n-o);this._w=(a-r)/m,this._x=(s+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(St(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),d=Math.sin((1-t)*h)/c,p=Math.sin(t*h)/c;return this._w=a*d+this._w*p,this._x=n*d+this._x*p,this._y=r*d+this._y*p,this._z=s*d+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class j{constructor(e=0,t=0,n=0){j.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(QS.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(QS.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),d=2*(s*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-s*d,this.z=r+l*d+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(St(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Hv.copy(this).projectOnVector(e),this.sub(Hv)}reflect(e){return this.sub(Hv.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(St(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hv=new j,QS=new yi;class At{constructor(e,t,n,r,s,a,o,l,c){At.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],p=n[2],m=n[5],v=n[8],x=r[0],_=r[3],g=r[6],b=r[1],E=r[4],S=r[7],w=r[2],T=r[5],R=r[8];return s[0]=a*x+o*b+l*w,s[3]=a*_+o*E+l*T,s[6]=a*g+o*S+l*R,s[1]=c*x+h*b+d*w,s[4]=c*_+h*E+d*T,s[7]=c*g+h*S+d*R,s[2]=p*x+m*b+v*w,s[5]=p*_+m*E+v*T,s[8]=p*g+m*S+v*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,p=o*l-h*s,m=c*s-a*l,v=t*d+n*p+r*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/v;return e[0]=d*x,e[1]=(r*c-h*n)*x,e[2]=(o*n-r*a)*x,e[3]=p*x,e[4]=(h*t-r*l)*x,e[5]=(r*s-o*t)*x,e[6]=m*x,e[7]=(n*l-c*t)*x,e[8]=(a*t-n*s)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Vv.makeScale(e,t)),this}rotate(e){return this.premultiply(Vv.makeRotation(-e)),this}translate(e,t){return this.premultiply(Vv.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Vv=new At;function o2(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}const lL={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function $c(i,e){return new lL[i](e)}function Cf(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function l2(){const i=Cf("canvas");return i.style.display="block",i}const $S={};function Rf(i){i in $S||($S[i]=!0,console.warn(i))}function cL(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const eE=new At().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),tE=new At().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function uL(){const i={enabled:!0,workingColorSpace:uo,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===an&&(r.r=ma(r.r),r.g=ma(r.g),r.b=ma(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===an&&(r.r=ru(r.r),r.g=ru(r.g),r.b=ru(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===ha?Tf:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Rf("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Rf("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[uo]:{primaries:e,whitePoint:n,transfer:Tf,toXYZ:eE,fromXYZ:tE,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ri},outputColorSpaceConfig:{drawingBufferColorSpace:Ri}},[Ri]:{primaries:e,whitePoint:n,transfer:an,toXYZ:eE,fromXYZ:tE,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ri}}}),i}const Gt=uL();function ma(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ru(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let gc;class c2{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{gc===void 0&&(gc=Cf("canvas")),gc.width=e.width,gc.height=e.height;const r=gc.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=gc}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Cf("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=ma(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ma(t[n]/255)*255):t[n]=ma(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hL=0;class ro{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hL++}),this.uuid=_r(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Wv(r[a].image)):s.push(Wv(r[a]))}else s=Wv(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function Wv(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?c2.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let fL=0;const Xv=new j;class Dn extends Ds{constructor(e=Dn.DEFAULT_IMAGE,t=Dn.DEFAULT_MAPPING,n=Fr,r=Fr,s=Fn,a=Ms,o=Di,l=Gr,c=Dn.DEFAULT_ANISOTROPY,h=ha){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:fL++}),this.uuid=_r(),this.name="",this.source=new ro(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new At,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Xv).x}get height(){return this.source.getSize(Xv).y}get depth(){return this.source.getSize(Xv).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Cg)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Sf:e.x=e.x-Math.floor(e.x);break;case Fr:e.x=e.x<0?0:1;break;case Ef:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Sf:e.y=e.y-Math.floor(e.y);break;case Fr:e.y=e.y<0?0:1;break;case Ef:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Dn.DEFAULT_IMAGE=null;Dn.DEFAULT_MAPPING=Cg;Dn.DEFAULT_ANISOTROPY=1;class Bt{constructor(e=0,t=0,n=0,r=1){Bt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const l=e.elements,c=l[0],h=l[4],d=l[8],p=l[1],m=l[5],v=l[9],x=l[2],_=l[6],g=l[10];if(Math.abs(h-p)<.01&&Math.abs(d-x)<.01&&Math.abs(v-_)<.01){if(Math.abs(h+p)<.1&&Math.abs(d+x)<.1&&Math.abs(v+_)<.1&&Math.abs(c+m+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,S=(m+1)/2,w=(g+1)/2,T=(h+p)/4,R=(d+x)/4,U=(v+_)/4;return E>S&&E>w?E<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(E),r=T/n,s=R/n):S>w?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=T/r,s=U/r):w<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(w),n=R/s,r=U/s),this.set(n,r,s,t),this}let b=Math.sqrt((_-v)*(_-v)+(d-x)*(d-x)+(p-h)*(p-h));return Math.abs(b)<.001&&(b=1),this.x=(_-v)/b,this.y=(d-x)/b,this.z=(p-h)/b,this.w=Math.acos((c+m+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this.w=St(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this.w=St(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(St(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Kx extends Ds{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Bt(0,0,e,t),this.scissorTest=!1,this.viewport=new Bt(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new Dn(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Fn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new ro(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Rs extends Kx{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Pg extends Dn{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vi,this.minFilter=vi,this.wrapR=Fr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class dL extends Rs{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Pg(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class zg extends Dn{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vi,this.minFilter=vi,this.wrapR=Fr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class pL extends Rs{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new zg(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class Qn{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kr.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Kr.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Kr):Kr.fromBufferAttribute(s,a),Kr.applyMatrix4(e.matrixWorld),this.expandByPoint(Kr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Xd.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Xd.copy(n.boundingBox)),Xd.applyMatrix4(e.matrixWorld),this.union(Xd)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kr),Kr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(dh),jd.subVectors(this.max,dh),vc.subVectors(e.a,dh),yc.subVectors(e.b,dh),_c.subVectors(e.c,dh),ja.subVectors(yc,vc),qa.subVectors(_c,yc),jo.subVectors(vc,_c);let t=[0,-ja.z,ja.y,0,-qa.z,qa.y,0,-jo.z,jo.y,ja.z,0,-ja.x,qa.z,0,-qa.x,jo.z,0,-jo.x,-ja.y,ja.x,0,-qa.y,qa.x,0,-jo.y,jo.x,0];return!jv(t,vc,yc,_c,jd)||(t=[1,0,0,0,1,0,0,0,1],!jv(t,vc,yc,_c,jd))?!1:(qd.crossVectors(ja,qa),t=[qd.x,qd.y,qd.z],jv(t,vc,yc,_c,jd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:($s[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$s[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$s[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$s[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$s[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$s[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$s[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$s[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($s),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const $s=[new j,new j,new j,new j,new j,new j,new j,new j],Kr=new j,Xd=new Qn,vc=new j,yc=new j,_c=new j,ja=new j,qa=new j,jo=new j,dh=new j,jd=new j,qd=new j,qo=new j;function jv(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){qo.fromArray(i,s);const o=r.x*Math.abs(qo.x)+r.y*Math.abs(qo.y)+r.z*Math.abs(qo.z),l=e.dot(qo),c=t.dot(qo),h=n.dot(qo);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const mL=new Qn,ph=new j,qv=new j;let ri=class{constructor(e=new j,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):mL.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ph.subVectors(e,this.center);const t=ph.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(ph,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(qv.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ph.copy(e.center).add(qv)),this.expandByPoint(ph.copy(e.center).sub(qv))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const ea=new j,Yv=new j,Yd=new j,Ya=new j,Zv=new j,Zd=new j,Kv=new j;class Au{constructor(e=new j,t=new j(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ea)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ea.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ea.copy(this.origin).addScaledVector(this.direction,t),ea.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Yv.copy(e).add(t).multiplyScalar(.5),Yd.copy(t).sub(e).normalize(),Ya.copy(this.origin).sub(Yv);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Yd),o=Ya.dot(this.direction),l=-Ya.dot(Yd),c=Ya.lengthSq(),h=Math.abs(1-a*a);let d,p,m,v;if(h>0)if(d=a*l-o,p=a*o-l,v=s*h,d>=0)if(p>=-v)if(p<=v){const x=1/h;d*=x,p*=x,m=d*(d+a*p+2*o)+p*(a*d+p+2*l)+c}else p=s,d=Math.max(0,-(a*p+o)),m=-d*d+p*(p+2*l)+c;else p=-s,d=Math.max(0,-(a*p+o)),m=-d*d+p*(p+2*l)+c;else p<=-v?(d=Math.max(0,-(-a*s+o)),p=d>0?-s:Math.min(Math.max(-s,-l),s),m=-d*d+p*(p+2*l)+c):p<=v?(d=0,p=Math.min(Math.max(-s,-l),s),m=p*(p+2*l)+c):(d=Math.max(0,-(a*s+o)),p=d>0?s:Math.min(Math.max(-s,-l),s),m=-d*d+p*(p+2*l)+c);else p=a>0?-s:s,d=Math.max(0,-(a*p+o)),m=-d*d+p*(p+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Yv).addScaledVector(Yd,p),m}intersectSphere(e,t){ea.subVectors(e.center,this.origin);const n=ea.dot(this.direction),r=ea.dot(ea)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,p=this.origin;return c>=0?(n=(e.min.x-p.x)*c,r=(e.max.x-p.x)*c):(n=(e.max.x-p.x)*c,r=(e.min.x-p.x)*c),h>=0?(s=(e.min.y-p.y)*h,a=(e.max.y-p.y)*h):(s=(e.max.y-p.y)*h,a=(e.min.y-p.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),d>=0?(o=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(o=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ea)!==null}intersectTriangle(e,t,n,r,s){Zv.subVectors(t,e),Zd.subVectors(n,e),Kv.crossVectors(Zv,Zd);let a=this.direction.dot(Kv),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ya.subVectors(this.origin,e);const l=o*this.direction.dot(Zd.crossVectors(Ya,Zd));if(l<0)return null;const c=o*this.direction.dot(Zv.cross(Ya));if(c<0||l+c>a)return null;const h=-o*Ya.dot(Kv);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class bt{constructor(e,t,n,r,s,a,o,l,c,h,d,p,m,v,x,_){bt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c,h,d,p,m,v,x,_)}set(e,t,n,r,s,a,o,l,c,h,d,p,m,v,x,_){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=h,g[10]=d,g[14]=p,g[3]=m,g[7]=v,g[11]=x,g[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new bt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/xc.setFromMatrixColumn(e,0).length(),s=1/xc.setFromMatrixColumn(e,1).length(),a=1/xc.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const p=a*h,m=a*d,v=o*h,x=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=m+v*c,t[5]=p-x*c,t[9]=-o*l,t[2]=x-p*c,t[6]=v+m*c,t[10]=a*l}else if(e.order==="YXZ"){const p=l*h,m=l*d,v=c*h,x=c*d;t[0]=p+x*o,t[4]=v*o-m,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=m*o-v,t[6]=x+p*o,t[10]=a*l}else if(e.order==="ZXY"){const p=l*h,m=l*d,v=c*h,x=c*d;t[0]=p-x*o,t[4]=-a*d,t[8]=v+m*o,t[1]=m+v*o,t[5]=a*h,t[9]=x-p*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const p=a*h,m=a*d,v=o*h,x=o*d;t[0]=l*h,t[4]=v*c-m,t[8]=p*c+x,t[1]=l*d,t[5]=x*c+p,t[9]=m*c-v,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const p=a*l,m=a*c,v=o*l,x=o*c;t[0]=l*h,t[4]=x-p*d,t[8]=v*d+m,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=m*d+v,t[10]=p-x*d}else if(e.order==="XZY"){const p=a*l,m=a*c,v=o*l,x=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=p*d+x,t[5]=a*h,t[9]=m*d-v,t[2]=v*d-m,t[6]=o*h,t[10]=x*d+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(gL,e,vL)}lookAt(e,t,n){const r=this.elements;return mr.subVectors(e,t),mr.lengthSq()===0&&(mr.z=1),mr.normalize(),Za.crossVectors(n,mr),Za.lengthSq()===0&&(Math.abs(n.z)===1?mr.x+=1e-4:mr.z+=1e-4,mr.normalize(),Za.crossVectors(n,mr)),Za.normalize(),Kd.crossVectors(mr,Za),r[0]=Za.x,r[4]=Kd.x,r[8]=mr.x,r[1]=Za.y,r[5]=Kd.y,r[9]=mr.y,r[2]=Za.z,r[6]=Kd.z,r[10]=mr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],p=n[9],m=n[13],v=n[2],x=n[6],_=n[10],g=n[14],b=n[3],E=n[7],S=n[11],w=n[15],T=r[0],R=r[4],U=r[8],A=r[12],D=r[1],L=r[5],P=r[9],I=r[13],V=r[2],H=r[6],z=r[10],O=r[14],B=r[3],G=r[7],X=r[11],k=r[15];return s[0]=a*T+o*D+l*V+c*B,s[4]=a*R+o*L+l*H+c*G,s[8]=a*U+o*P+l*z+c*X,s[12]=a*A+o*I+l*O+c*k,s[1]=h*T+d*D+p*V+m*B,s[5]=h*R+d*L+p*H+m*G,s[9]=h*U+d*P+p*z+m*X,s[13]=h*A+d*I+p*O+m*k,s[2]=v*T+x*D+_*V+g*B,s[6]=v*R+x*L+_*H+g*G,s[10]=v*U+x*P+_*z+g*X,s[14]=v*A+x*I+_*O+g*k,s[3]=b*T+E*D+S*V+w*B,s[7]=b*R+E*L+S*H+w*G,s[11]=b*U+E*P+S*z+w*X,s[15]=b*A+E*I+S*O+w*k,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],p=e[10],m=e[14],v=e[3],x=e[7],_=e[11],g=e[15];return v*(+s*l*d-r*c*d-s*o*p+n*c*p+r*o*m-n*l*m)+x*(+t*l*m-t*c*p+s*a*p-r*a*m+r*c*h-s*l*h)+_*(+t*c*d-t*o*m-s*a*d+n*a*m+s*o*h-n*c*h)+g*(-r*o*h-t*l*d+t*o*p+r*a*d-n*a*p+n*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],p=e[10],m=e[11],v=e[12],x=e[13],_=e[14],g=e[15],b=d*_*c-x*p*c+x*l*m-o*_*m-d*l*g+o*p*g,E=v*p*c-h*_*c-v*l*m+a*_*m+h*l*g-a*p*g,S=h*x*c-v*d*c+v*o*m-a*x*m-h*o*g+a*d*g,w=v*d*l-h*x*l-v*o*p+a*x*p+h*o*_-a*d*_,T=t*b+n*E+r*S+s*w;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/T;return e[0]=b*R,e[1]=(x*p*s-d*_*s-x*r*m+n*_*m+d*r*g-n*p*g)*R,e[2]=(o*_*s-x*l*s+x*r*c-n*_*c-o*r*g+n*l*g)*R,e[3]=(d*l*s-o*p*s-d*r*c+n*p*c+o*r*m-n*l*m)*R,e[4]=E*R,e[5]=(h*_*s-v*p*s+v*r*m-t*_*m-h*r*g+t*p*g)*R,e[6]=(v*l*s-a*_*s-v*r*c+t*_*c+a*r*g-t*l*g)*R,e[7]=(a*p*s-h*l*s+h*r*c-t*p*c-a*r*m+t*l*m)*R,e[8]=S*R,e[9]=(v*d*s-h*x*s-v*n*m+t*x*m+h*n*g-t*d*g)*R,e[10]=(a*x*s-v*o*s+v*n*c-t*x*c-a*n*g+t*o*g)*R,e[11]=(h*o*s-a*d*s-h*n*c+t*d*c+a*n*m-t*o*m)*R,e[12]=w*R,e[13]=(h*x*r-v*d*r+v*n*p-t*x*p-h*n*_+t*d*_)*R,e[14]=(v*o*r-a*x*r-v*n*l+t*x*l+a*n*_-t*o*_)*R,e[15]=(a*d*r-h*o*r+h*n*l-t*d*l-a*n*p+t*o*p)*R,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,p=s*c,m=s*h,v=s*d,x=a*h,_=a*d,g=o*d,b=l*c,E=l*h,S=l*d,w=n.x,T=n.y,R=n.z;return r[0]=(1-(x+g))*w,r[1]=(m+S)*w,r[2]=(v-E)*w,r[3]=0,r[4]=(m-S)*T,r[5]=(1-(p+g))*T,r[6]=(_+b)*T,r[7]=0,r[8]=(v+E)*R,r[9]=(_-b)*R,r[10]=(1-(p+x))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=xc.set(r[0],r[1],r[2]).length();const a=xc.set(r[4],r[5],r[6]).length(),o=xc.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Jr.copy(this);const c=1/s,h=1/a,d=1/o;return Jr.elements[0]*=c,Jr.elements[1]*=c,Jr.elements[2]*=c,Jr.elements[4]*=h,Jr.elements[5]*=h,Jr.elements[6]*=h,Jr.elements[8]*=d,Jr.elements[9]*=d,Jr.elements[10]*=d,t.setFromRotationMatrix(Jr),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=yr,l=!1){const c=this.elements,h=2*s/(t-e),d=2*s/(n-r),p=(t+e)/(t-e),m=(n+r)/(n-r);let v,x;if(l)v=s/(a-s),x=a*s/(a-s);else if(o===yr)v=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===fu)v=-a/(a-s),x=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=d,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=v,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=yr,l=!1){const c=this.elements,h=2/(t-e),d=2/(n-r),p=-(t+e)/(t-e),m=-(n+r)/(n-r);let v,x;if(l)v=1/(a-s),x=a/(a-s);else if(o===yr)v=-2/(a-s),x=-(a+s)/(a-s);else if(o===fu)v=-1/(a-s),x=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=d,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=v,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const xc=new j,Jr=new bt,gL=new j(0,0,0),vL=new j(1,1,1),Za=new j,Kd=new j,mr=new j,nE=new bt,iE=new yi;class Bi{constructor(e=0,t=0,n=0,r=Bi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],d=r[2],p=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(St(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-St(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(St(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-St(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(St(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-St(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return nE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(nE,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return iE.setFromEuler(this),this.setFromQuaternion(iE,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Bi.DEFAULT_ORDER="XYZ";class pu{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let yL=0;const rE=new j,bc=new yi,ta=new bt,Jd=new j,mh=new j,_L=new j,xL=new yi,sE=new j(1,0,0),aE=new j(0,1,0),oE=new j(0,0,1),lE={type:"added"},bL={type:"removed"},Sc={type:"childadded",child:null},Jv={type:"childremoved",child:null};class Xt extends Ds{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:yL++}),this.uuid=_r(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Xt.DEFAULT_UP.clone();const e=new j,t=new Bi,n=new yi,r=new j(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new bt},normalMatrix:{value:new At}}),this.matrix=new bt,this.matrixWorld=new bt,this.matrixAutoUpdate=Xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return bc.setFromAxisAngle(e,t),this.quaternion.multiply(bc),this}rotateOnWorldAxis(e,t){return bc.setFromAxisAngle(e,t),this.quaternion.premultiply(bc),this}rotateX(e){return this.rotateOnAxis(sE,e)}rotateY(e){return this.rotateOnAxis(aE,e)}rotateZ(e){return this.rotateOnAxis(oE,e)}translateOnAxis(e,t){return rE.copy(e).applyQuaternion(this.quaternion),this.position.add(rE.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(sE,e)}translateY(e){return this.translateOnAxis(aE,e)}translateZ(e){return this.translateOnAxis(oE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ta.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Jd.copy(e):Jd.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),mh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ta.lookAt(mh,Jd,this.up):ta.lookAt(Jd,mh,this.up),this.quaternion.setFromRotationMatrix(ta),r&&(ta.extractRotation(r.matrixWorld),bc.setFromRotationMatrix(ta),this.quaternion.premultiply(bc.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(lE),Sc.child=e,this.dispatchEvent(Sc),Sc.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(bL),Jv.child=e,this.dispatchEvent(Jv),Jv.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ta.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ta.multiply(e.parent.matrixWorld)),e.applyMatrix4(ta),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(lE),Sc.child=e,this.dispatchEvent(Sc),Sc.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,e,_L),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,xL,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),p=a(e.skeletons),m=a(e.animations),v=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),p.length>0&&(n.skeletons=p),m.length>0&&(n.animations=m),v.length>0&&(n.nodes=v)}return n.object=r,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Xt.DEFAULT_UP=new j(0,1,0);Xt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Qr=new j,na=new j,Qv=new j,ia=new j,Ec=new j,Mc=new j,cE=new j,$v=new j,ey=new j,ty=new j,ny=new Bt,iy=new Bt,ry=new Bt;class Ji{constructor(e=new j,t=new j,n=new j){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Qr.subVectors(e,t),r.cross(Qr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Qr.subVectors(r,t),na.subVectors(n,t),Qv.subVectors(e,t);const a=Qr.dot(Qr),o=Qr.dot(na),l=Qr.dot(Qv),c=na.dot(na),h=na.dot(Qv),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const p=1/d,m=(c*l-o*h)*p,v=(a*h-o*l)*p;return s.set(1-m-v,v,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,ia)===null?!1:ia.x>=0&&ia.y>=0&&ia.x+ia.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,ia)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,ia.x),l.addScaledVector(a,ia.y),l.addScaledVector(o,ia.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return ny.setScalar(0),iy.setScalar(0),ry.setScalar(0),ny.fromBufferAttribute(e,t),iy.fromBufferAttribute(e,n),ry.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ny,s.x),a.addScaledVector(iy,s.y),a.addScaledVector(ry,s.z),a}static isFrontFacing(e,t,n,r){return Qr.subVectors(n,t),na.subVectors(e,t),Qr.cross(na).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Qr.subVectors(this.c,this.b),na.subVectors(this.a,this.b),Qr.cross(na).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ji.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ji.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Ji.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Ji.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ji.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;Ec.subVectors(r,n),Mc.subVectors(s,n),$v.subVectors(e,n);const l=Ec.dot($v),c=Mc.dot($v);if(l<=0&&c<=0)return t.copy(n);ey.subVectors(e,r);const h=Ec.dot(ey),d=Mc.dot(ey);if(h>=0&&d<=h)return t.copy(r);const p=l*d-h*c;if(p<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Ec,a);ty.subVectors(e,s);const m=Ec.dot(ty),v=Mc.dot(ty);if(v>=0&&m<=v)return t.copy(s);const x=m*c-l*v;if(x<=0&&c>=0&&v<=0)return o=c/(c-v),t.copy(n).addScaledVector(Mc,o);const _=h*v-m*d;if(_<=0&&d-h>=0&&m-v>=0)return cE.subVectors(s,r),o=(d-h)/(d-h+(m-v)),t.copy(r).addScaledVector(cE,o);const g=1/(_+x+p);return a=x*g,o=p*g,t.copy(n).addScaledVector(Ec,a).addScaledVector(Mc,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const u2={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ka={h:0,s:0,l:0},Qd={h:0,s:0,l:0};function sy(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let Ye=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ri){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Gt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Gt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Gt.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Gt.workingColorSpace){if(e=Zx(e,1),t=St(t,0,1),n=St(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=sy(a,s,e+1/3),this.g=sy(a,s,e),this.b=sy(a,s,e-1/3)}return Gt.colorSpaceToWorking(this,r),this}setStyle(e,t=Ri){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ri){const n=u2[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ma(e.r),this.g=ma(e.g),this.b=ma(e.b),this}copyLinearToSRGB(e){return this.r=ru(e.r),this.g=ru(e.g),this.b=ru(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ri){return Gt.workingToColorSpace(Ai.copy(this),e),Math.round(St(Ai.r*255,0,255))*65536+Math.round(St(Ai.g*255,0,255))*256+Math.round(St(Ai.b*255,0,255))}getHexString(e=Ri){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Gt.workingColorSpace){Gt.workingToColorSpace(Ai.copy(this),t);const n=Ai.r,r=Ai.g,s=Ai.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-n)/d+2;break;case s:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Gt.workingColorSpace){return Gt.workingToColorSpace(Ai.copy(this),t),e.r=Ai.r,e.g=Ai.g,e.b=Ai.b,e}getStyle(e=Ri){Gt.workingToColorSpace(Ai.copy(this),e);const t=Ai.r,n=Ai.g,r=Ai.b;return e!==Ri?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Ka),this.setHSL(Ka.h+e,Ka.s+t,Ka.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ka),e.getHSL(Qd);const n=uf(Ka.h,Qd.h,t),r=uf(Ka.s,Qd.s,t),s=uf(Ka.l,Qd.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Ai=new Ye;Ye.NAMES=u2;let SL=0;class Ui extends Ds{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:SL++}),this.uuid=_r(),this.name="",this.type="Material",this.blending=xl,this.side=ya,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vm,this.blendDst=ym,this.blendEquation=io,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ye(0,0,0),this.blendAlpha=0,this.depthFunc=wl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=q_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=hl,this.stencilZFail=hl,this.stencilZPass=hl,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==xl&&(n.blending=this.blending),this.side!==ya&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==vm&&(n.blendSrc=this.blendSrc),this.blendDst!==ym&&(n.blendDst=this.blendDst),this.blendEquation!==io&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==wl&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==q_&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==hl&&(n.stencilFail=this.stencilFail),this.stencilZFail!==hl&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==hl&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ea extends Ui{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.combine=Kf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const fa=EL();function EL(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,r[l]=24,r[l|256]=24):(n[l]=31744,n[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function Zi(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=St(i,-65504,65504),fa.floatView[0]=i;const e=fa.uint32View[0],t=e>>23&511;return fa.baseTable[t]+((e&8388607)>>fa.shiftTable[t])}function Yh(i){const e=i>>10;return fa.uint32View[0]=fa.mantissaTable[fa.offsetTable[e]+(i&1023)]+fa.exponentTable[e],fa.floatView[0]}class ML{static toHalfFloat(e){return Zi(e)}static fromHalfFloat(e){return Yh(e)}}const qn=new j,$d=new ke;let wL=0;class $t{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:wL++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Af,this.updateRanges=[],this.gpuType=Qi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)$d.fromBufferAttribute(this,t),$d.applyMatrix3(e),this.setXY(t,$d.x,$d.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyMatrix3(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyMatrix4(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyNormalMatrix(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.transformDirection(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Pi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Ot(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Pi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Pi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Pi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Pi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array),s=Ot(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Af&&(e.usage=this.usage),e}}class TL extends $t{constructor(e,t,n){super(new Int8Array(e),t,n)}}class AL extends $t{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class CL extends $t{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class RL extends $t{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Jx extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class DL extends $t{constructor(e,t,n){super(new Int32Array(e),t,n)}}class Qx extends $t{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class UL extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Yh(this.array[e*this.itemSize]);return this.normalized&&(t=Pi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize]=Zi(t),this}getY(e){let t=Yh(this.array[e*this.itemSize+1]);return this.normalized&&(t=Pi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+1]=Zi(t),this}getZ(e){let t=Yh(this.array[e*this.itemSize+2]);return this.normalized&&(t=Pi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+2]=Zi(t),this}getW(e){let t=Yh(this.array[e*this.itemSize+3]);return this.normalized&&(t=Pi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+3]=Zi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array)),this.array[e+0]=Zi(t),this.array[e+1]=Zi(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array)),this.array[e+0]=Zi(t),this.array[e+1]=Zi(n),this.array[e+2]=Zi(r),this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array),s=Ot(s,this.array)),this.array[e+0]=Zi(t),this.array[e+1]=Zi(n),this.array[e+2]=Zi(r),this.array[e+3]=Zi(s),this}}class ft extends $t{constructor(e,t,n){super(new Float32Array(e),t,n)}}let OL=0;const Ur=new bt,ay=new Xt,wc=new j,gr=new Qn,gh=new Qn,ui=new j;class Rt extends Ds{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:OL++}),this.uuid=_r(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(o2(e)?Qx:Jx)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new At().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ur.makeRotationFromQuaternion(e),this.applyMatrix4(Ur),this}rotateX(e){return Ur.makeRotationX(e),this.applyMatrix4(Ur),this}rotateY(e){return Ur.makeRotationY(e),this.applyMatrix4(Ur),this}rotateZ(e){return Ur.makeRotationZ(e),this.applyMatrix4(Ur),this}translate(e,t,n){return Ur.makeTranslation(e,t,n),this.applyMatrix4(Ur),this}scale(e,t,n){return Ur.makeScale(e,t,n),this.applyMatrix4(Ur),this}lookAt(e){return ay.lookAt(e),ay.updateMatrix(),this.applyMatrix4(ay.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wc).negate(),this.translate(wc.x,wc.y,wc.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new ft(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Qn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];gr.setFromBufferAttribute(s),this.morphTargetsRelative?(ui.addVectors(this.boundingBox.min,gr.min),this.boundingBox.expandByPoint(ui),ui.addVectors(this.boundingBox.max,gr.max),this.boundingBox.expandByPoint(ui)):(this.boundingBox.expandByPoint(gr.min),this.boundingBox.expandByPoint(gr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ri);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){const n=this.boundingSphere.center;if(gr.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];gh.setFromBufferAttribute(o),this.morphTargetsRelative?(ui.addVectors(gr.min,gh.min),gr.expandByPoint(ui),ui.addVectors(gr.max,gh.max),gr.expandByPoint(ui)):(gr.expandByPoint(gh.min),gr.expandByPoint(gh.max))}gr.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)ui.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(ui));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ui.fromBufferAttribute(o,c),l&&(wc.fromBufferAttribute(e,c),ui.add(wc)),r=Math.max(r,n.distanceToSquared(ui))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new $t(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let U=0;U<n.count;U++)o[U]=new j,l[U]=new j;const c=new j,h=new j,d=new j,p=new ke,m=new ke,v=new ke,x=new j,_=new j;function g(U,A,D){c.fromBufferAttribute(n,U),h.fromBufferAttribute(n,A),d.fromBufferAttribute(n,D),p.fromBufferAttribute(s,U),m.fromBufferAttribute(s,A),v.fromBufferAttribute(s,D),h.sub(c),d.sub(c),m.sub(p),v.sub(p);const L=1/(m.x*v.y-v.x*m.y);isFinite(L)&&(x.copy(h).multiplyScalar(v.y).addScaledVector(d,-m.y).multiplyScalar(L),_.copy(d).multiplyScalar(m.x).addScaledVector(h,-v.x).multiplyScalar(L),o[U].add(x),o[A].add(x),o[D].add(x),l[U].add(_),l[A].add(_),l[D].add(_))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let U=0,A=b.length;U<A;++U){const D=b[U],L=D.start,P=D.count;for(let I=L,V=L+P;I<V;I+=3)g(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const E=new j,S=new j,w=new j,T=new j;function R(U){w.fromBufferAttribute(r,U),T.copy(w);const A=o[U];E.copy(A),E.sub(w.multiplyScalar(w.dot(A))).normalize(),S.crossVectors(T,A);const L=S.dot(l[U])<0?-1:1;a.setXYZW(U,E.x,E.y,E.z,L)}for(let U=0,A=b.length;U<A;++U){const D=b[U],L=D.start,P=D.count;for(let I=L,V=L+P;I<V;I+=3)R(e.getX(I+0)),R(e.getX(I+1)),R(e.getX(I+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new $t(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let p=0,m=n.count;p<m;p++)n.setXYZ(p,0,0,0);const r=new j,s=new j,a=new j,o=new j,l=new j,c=new j,h=new j,d=new j;if(e)for(let p=0,m=e.count;p<m;p+=3){const v=e.getX(p+0),x=e.getX(p+1),_=e.getX(p+2);r.fromBufferAttribute(t,v),s.fromBufferAttribute(t,x),a.fromBufferAttribute(t,_),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),o.fromBufferAttribute(n,v),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,_),o.add(h),l.add(h),c.add(h),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let p=0,m=t.count;p<m;p+=3)r.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),a.fromBufferAttribute(t,p+2),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),n.setXYZ(p+0,h.x,h.y,h.z),n.setXYZ(p+1,h.x,h.y,h.z),n.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)ui.fromBufferAttribute(e,t),ui.normalize(),e.setXYZ(t,ui.x,ui.y,ui.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,p=new c.constructor(l.length*h);let m=0,v=0;for(let x=0,_=l.length;x<_;x++){o.isInterleavedBufferAttribute?m=l[x]*o.data.stride+o.offset:m=l[x]*h;for(let g=0;g<h;g++)p[v++]=c[m++]}return new $t(p,h,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Rt,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=e(p,n);l.push(m)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,p=c.length;d<p;d++){const m=c[d];h.push(m.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let p=0,m=d.length;p<m;p++)h.push(d[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const uE=new bt,Yo=new Au,ep=new ri,hE=new j,tp=new j,np=new j,ip=new j,oy=new j,rp=new j,fE=new j,sp=new j;class mn extends Xt{constructor(e=new Rt,t=new Ea){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){rp.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(oy.fromBufferAttribute(d,e),a?rp.addScaledVector(oy,h):rp.addScaledVector(oy.sub(t),h))}t.add(rp)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ep.copy(n.boundingSphere),ep.applyMatrix4(s),Yo.copy(e.ray).recast(e.near),!(ep.containsPoint(Yo.origin)===!1&&(Yo.intersectSphere(ep,hE)===null||Yo.origin.distanceToSquared(hE)>(e.far-e.near)**2))&&(uE.copy(s).invert(),Yo.copy(e.ray).applyMatrix4(uE),!(n.boundingBox!==null&&Yo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Yo)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,p=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,x=p.length;v<x;v++){const _=p[v],g=a[_.materialIndex],b=Math.max(_.start,m.start),E=Math.min(o.count,Math.min(_.start+_.count,m.start+m.count));for(let S=b,w=E;S<w;S+=3){const T=o.getX(S),R=o.getX(S+1),U=o.getX(S+2);r=ap(this,g,e,n,c,h,d,T,R,U),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),x=Math.min(o.count,m.start+m.count);for(let _=v,g=x;_<g;_+=3){const b=o.getX(_),E=o.getX(_+1),S=o.getX(_+2);r=ap(this,a,e,n,c,h,d,b,E,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let v=0,x=p.length;v<x;v++){const _=p[v],g=a[_.materialIndex],b=Math.max(_.start,m.start),E=Math.min(l.count,Math.min(_.start+_.count,m.start+m.count));for(let S=b,w=E;S<w;S+=3){const T=S,R=S+1,U=S+2;r=ap(this,g,e,n,c,h,d,T,R,U),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let _=v,g=x;_<g;_+=3){const b=_,E=_+1,S=_+2;r=ap(this,a,e,n,c,h,d,b,E,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}}}function LL(i,e,t,n,r,s,a,o){let l;if(e.side===Fi?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===ya,o),l===null)return null;sp.copy(o),sp.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(sp);return c<t.near||c>t.far?null:{distance:c,point:sp.clone(),object:i}}function ap(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,tp),i.getVertexPosition(l,np),i.getVertexPosition(c,ip);const h=LL(i,e,t,n,tp,np,ip,fE);if(h){const d=new j;Ji.getBarycoord(fE,tp,np,ip,d),r&&(h.uv=Ji.getInterpolatedAttribute(r,o,l,c,d,new ke)),s&&(h.uv1=Ji.getInterpolatedAttribute(s,o,l,c,d,new ke)),a&&(h.normal=Ji.getInterpolatedAttribute(a,o,l,c,d,new j),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new j,materialIndex:0};Ji.getNormal(tp,np,ip,p.normal),h.face=p,h.barycoord=d}return h}class go extends Rt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let p=0,m=0;v("z","y","x",-1,-1,n,t,e,a,s,0),v("z","y","x",1,-1,n,t,-e,a,s,1),v("x","z","y",1,1,e,n,t,r,a,2),v("x","z","y",1,-1,e,n,-t,r,a,3),v("x","y","z",1,-1,e,t,n,r,s,4),v("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new ft(c,3)),this.setAttribute("normal",new ft(h,3)),this.setAttribute("uv",new ft(d,2));function v(x,_,g,b,E,S,w,T,R,U,A){const D=S/R,L=w/U,P=S/2,I=w/2,V=T/2,H=R+1,z=U+1;let O=0,B=0;const G=new j;for(let X=0;X<z;X++){const k=X*L-I;for(let Y=0;Y<H;Y++){const Q=Y*D-P;G[x]=Q*b,G[_]=k*E,G[g]=V,c.push(G.x,G.y,G.z),G[x]=0,G[_]=0,G[g]=T>0?1:-1,h.push(G.x,G.y,G.z),d.push(Y/R),d.push(1-X/U),O+=1}}for(let X=0;X<U;X++)for(let k=0;k<R;k++){const Y=p+k+H*X,Q=p+k+H*(X+1),te=p+(k+1)+H*(X+1),ee=p+(k+1)+H*X;l.push(Y,Q,ee),l.push(Q,te,ee),B+=6}o.addGroup(m,B,A),m+=B,p+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new go(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function mu(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Ni(i){const e={};for(let t=0;t<i.length;t++){const n=mu(i[t]);for(const r in n)e[r]=n[r]}return e}function IL(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function h2(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Gt.workingColorSpace}const $x={clone:mu,merge:Ni};var NL=`void main() {
1
+ import{b4 as gA,b5 as PU,aO as po,b6 as zU,b7 as nf,r as K,j as he,b8 as FU,b9 as BU,ba as kU,E as vA,u as wg,t as GU,F as Yn,ai as HU,B as Lr,bb as VU,bc as WU,f as XU,bd as jU,be as qU,bf as YU,bg as ZU,bh as KU,bi as JU,ar as iu,bj as QU,bk as $U,bl as eO,$ as tO,bm as kv,a as nO,m as qS,az as YS}from"./index-DvPcNtN4.js";import{m as iO}from"./merge-BrLzJdog.js";import{g as rO,a as sO}from"./index-Du_VEcSu.js";import{E as _l,Z as hi,N as im,c as fh}from"./index-Bs7zcW7e.js";import"./envs-CSqIi4cL.js";import"./isObjectLike-BbV-G3AH.js";import"./isObject--vsEa_js.js";var Gv={exports:{}},Qs={};var ZS;function aO(){return ZS||(ZS=1,Qs.ConcurrentRoot=1,Qs.ContinuousEventPriority=8,Qs.DefaultEventPriority=32,Qs.DiscreteEventPriority=2,Qs.IdleEventPriority=268435456,Qs.LegacyRoot=0,Qs.NoEventPriority=0),Qs}var KS;function oO(){return KS||(KS=1,Gv.exports=aO()),Gv.exports}var rm=oO();const Tg="180",yA={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lO={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},_A=0,H_=1,xA=2,cO=3,bA=0,Ag=1,rf=2,is=3,ya=0,Fi=1,zn=2,pa=0,xl=1,V_=2,W_=3,X_=4,SA=5,io=100,EA=101,MA=102,wA=103,TA=104,AA=200,CA=201,RA=202,DA=203,vm=204,ym=205,UA=206,OA=207,LA=208,IA=209,NA=210,PA=211,zA=212,FA=213,BA=214,_m=0,xm=1,bm=2,wl=3,Sm=4,Em=5,Mm=6,wm=7,Kf=0,kA=1,GA=2,Ts=0,HA=1,VA=2,WA=3,zx=4,XA=5,jA=6,qA=7,j_="attached",YA="detached",Cg=300,_a=301,co=302,xf=303,bf=304,wu=306,Sf=1e3,Fr=1001,Ef=1002,vi=1003,Fx=1004,uO=1004,Qc=1005,hO=1005,Fn=1006,sf=1007,fO=1007,Ms=1008,dO=1008,Gr=1009,Bx=1010,kx=1011,lu=1012,Rg=1013,xa=1014,Qi=1015,Tu=1016,Dg=1017,Ug=1018,cu=1020,Gx=35902,Hx=35899,Vx=1021,Wx=1022,Di=1023,uu=1026,hu=1027,Og=1028,Jf=1029,Xx=1030,Lg=1031,pO=1032,Ig=1033,af=33776,of=33777,lf=33778,cf=33779,Tm=35840,Am=35841,Cm=35842,Rm=35843,Dm=36196,Um=37492,Om=37496,Lm=37808,Im=37809,Nm=37810,Pm=37811,zm=37812,Fm=37813,Bm=37814,km=37815,Gm=37816,Hm=37817,Vm=37818,Wm=37819,Xm=37820,jm=37821,qm=36492,Ym=36494,Zm=36495,Km=36283,Jm=36284,Qm=36285,$m=36286,ZA=2200,KA=2201,JA=2202,Mf=2300,eg=2301,sm=2302,ml=2400,gl=2401,wf=2402,Ng=2500,jx=2501,mO=0,gO=1,vO=2,QA=3200,qx=3201,yO=3202,_O=3203,mo=0,$A=1,ha="",Ri="srgb",uo="srgb-linear",Tf="linear",an="srgb",xO=0,hl=7680,bO=7681,SO=7682,EO=7683,MO=34055,wO=34056,TO=5386,AO=512,CO=513,RO=514,DO=515,UO=516,OO=517,LO=518,q_=519,e2=512,t2=513,n2=514,Yx=515,i2=516,r2=517,s2=518,a2=519,Af=35044,IO=35048,NO=35040,PO=35045,zO=35049,FO=35041,BO=35046,kO=35050,GO=35042,HO="100",Y_="300 es",yr=2e3,fu=2001,VO={COMPUTE:"compute",RENDER:"render"},WO={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},XO={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};let Ds=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}};const Ti=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let JS=1234567;const bl=Math.PI/180,du=180/Math.PI;function _r(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ti[i&255]+Ti[i>>8&255]+Ti[i>>16&255]+Ti[i>>24&255]+"-"+Ti[e&255]+Ti[e>>8&255]+"-"+Ti[e>>16&15|64]+Ti[e>>24&255]+"-"+Ti[t&63|128]+Ti[t>>8&255]+"-"+Ti[t>>16&255]+Ti[t>>24&255]+Ti[n&255]+Ti[n>>8&255]+Ti[n>>16&255]+Ti[n>>24&255]).toLowerCase()}function St(i,e,t){return Math.max(e,Math.min(t,i))}function Zx(i,e){return(i%e+e)%e}function jO(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function qO(i,e,t){return i!==e?(t-i)/(e-i):0}function uf(i,e,t){return(1-t)*i+t*e}function YO(i,e,t,n){return uf(i,e,1-Math.exp(-t*n))}function ZO(i,e=1){return e-Math.abs(Zx(i,e*2)-e)}function KO(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function JO(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function QO(i,e){return i+Math.floor(Math.random()*(e-i+1))}function $O(i,e){return i+Math.random()*(e-i)}function eL(i){return i*(.5-Math.random())}function tL(i){i!==void 0&&(JS=i);let e=JS+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function nL(i){return i*bl}function iL(i){return i*du}function rL(i){return(i&i-1)===0&&i!==0}function sL(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function aL(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function oL(i,e,t,n,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),d=s((e-n)/2),p=a((e-n)/2),m=s((n-e)/2),v=a((n-e)/2);switch(r){case"XYX":i.set(o*h,l*d,l*p,o*c);break;case"YZY":i.set(l*p,o*h,l*d,o*c);break;case"ZXZ":i.set(l*d,l*p,o*h,o*c);break;case"XZX":i.set(o*h,l*v,l*m,o*c);break;case"YXY":i.set(l*m,o*h,l*v,o*c);break;case"ZYZ":i.set(l*v,l*m,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Pi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Ot(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const tg={DEG2RAD:bl,RAD2DEG:du,generateUUID:_r,clamp:St,euclideanModulo:Zx,mapLinear:jO,inverseLerp:qO,lerp:uf,damp:YO,pingpong:ZO,smoothstep:KO,smootherstep:JO,randInt:QO,randFloat:$O,randFloatSpread:eL,seededRandom:tL,degToRad:nL,radToDeg:iL,isPowerOfTwo:rL,ceilPowerOfTwo:sL,floorPowerOfTwo:aL,setQuaternionFromProperEuler:oL,normalize:Ot,denormalize:Pi};class ke{constructor(e=0,t=0){ke.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(St(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(St(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class yi{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],d=n[r+3];const p=s[a+0],m=s[a+1],v=s[a+2],x=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d;return}if(o===1){e[t+0]=p,e[t+1]=m,e[t+2]=v,e[t+3]=x;return}if(d!==x||l!==p||c!==m||h!==v){let _=1-o;const g=l*p+c*m+h*v+d*x,b=g>=0?1:-1,E=1-g*g;if(E>Number.EPSILON){const w=Math.sqrt(E),T=Math.atan2(w,g*b);_=Math.sin(_*T)/w,o=Math.sin(o*T)/w}const S=o*b;if(l=l*_+p*S,c=c*_+m*S,h=h*_+v*S,d=d*_+x*S,_===1-o){const w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],d=s[a],p=s[a+1],m=s[a+2],v=s[a+3];return e[t]=o*v+h*d+l*m-c*p,e[t+1]=l*v+h*p+c*d-o*m,e[t+2]=c*v+h*m+o*p-l*d,e[t+3]=h*v-o*d-l*p-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),d=o(s/2),p=l(n/2),m=l(r/2),v=l(s/2);switch(a){case"XYZ":this._x=p*h*d+c*m*v,this._y=c*m*d-p*h*v,this._z=c*h*v+p*m*d,this._w=c*h*d-p*m*v;break;case"YXZ":this._x=p*h*d+c*m*v,this._y=c*m*d-p*h*v,this._z=c*h*v-p*m*d,this._w=c*h*d+p*m*v;break;case"ZXY":this._x=p*h*d-c*m*v,this._y=c*m*d+p*h*v,this._z=c*h*v+p*m*d,this._w=c*h*d-p*m*v;break;case"ZYX":this._x=p*h*d-c*m*v,this._y=c*m*d+p*h*v,this._z=c*h*v-p*m*d,this._w=c*h*d+p*m*v;break;case"YZX":this._x=p*h*d+c*m*v,this._y=c*m*d+p*h*v,this._z=c*h*v-p*m*d,this._w=c*h*d-p*m*v;break;case"XZY":this._x=p*h*d-c*m*v,this._y=c*m*d-p*h*v,this._z=c*h*v+p*m*d,this._w=c*h*d+p*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],p=n+o+d;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(h-l)*m,this._y=(s-c)*m,this._z=(a-r)*m}else if(n>o&&n>d){const m=2*Math.sqrt(1+n-o-d);this._w=(h-l)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(s+c)/m}else if(o>d){const m=2*Math.sqrt(1+o-n-d);this._w=(s-c)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+d-n-o);this._w=(a-r)/m,this._x=(s+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(St(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),d=Math.sin((1-t)*h)/c,p=Math.sin(t*h)/c;return this._w=a*d+this._w*p,this._x=n*d+this._x*p,this._y=r*d+this._y*p,this._z=s*d+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class j{constructor(e=0,t=0,n=0){j.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(QS.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(QS.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),d=2*(s*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-s*d,this.z=r+l*d+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(St(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Hv.copy(this).projectOnVector(e),this.sub(Hv)}reflect(e){return this.sub(Hv.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(St(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hv=new j,QS=new yi;class At{constructor(e,t,n,r,s,a,o,l,c){At.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],p=n[2],m=n[5],v=n[8],x=r[0],_=r[3],g=r[6],b=r[1],E=r[4],S=r[7],w=r[2],T=r[5],R=r[8];return s[0]=a*x+o*b+l*w,s[3]=a*_+o*E+l*T,s[6]=a*g+o*S+l*R,s[1]=c*x+h*b+d*w,s[4]=c*_+h*E+d*T,s[7]=c*g+h*S+d*R,s[2]=p*x+m*b+v*w,s[5]=p*_+m*E+v*T,s[8]=p*g+m*S+v*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,p=o*l-h*s,m=c*s-a*l,v=t*d+n*p+r*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/v;return e[0]=d*x,e[1]=(r*c-h*n)*x,e[2]=(o*n-r*a)*x,e[3]=p*x,e[4]=(h*t-r*l)*x,e[5]=(r*s-o*t)*x,e[6]=m*x,e[7]=(n*l-c*t)*x,e[8]=(a*t-n*s)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Vv.makeScale(e,t)),this}rotate(e){return this.premultiply(Vv.makeRotation(-e)),this}translate(e,t){return this.premultiply(Vv.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Vv=new At;function o2(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}const lL={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function $c(i,e){return new lL[i](e)}function Cf(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function l2(){const i=Cf("canvas");return i.style.display="block",i}const $S={};function Rf(i){i in $S||($S[i]=!0,console.warn(i))}function cL(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const eE=new At().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),tE=new At().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function uL(){const i={enabled:!0,workingColorSpace:uo,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===an&&(r.r=ma(r.r),r.g=ma(r.g),r.b=ma(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===an&&(r.r=ru(r.r),r.g=ru(r.g),r.b=ru(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===ha?Tf:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Rf("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Rf("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[uo]:{primaries:e,whitePoint:n,transfer:Tf,toXYZ:eE,fromXYZ:tE,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ri},outputColorSpaceConfig:{drawingBufferColorSpace:Ri}},[Ri]:{primaries:e,whitePoint:n,transfer:an,toXYZ:eE,fromXYZ:tE,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ri}}}),i}const Gt=uL();function ma(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ru(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let gc;class c2{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{gc===void 0&&(gc=Cf("canvas")),gc.width=e.width,gc.height=e.height;const r=gc.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=gc}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Cf("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=ma(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ma(t[n]/255)*255):t[n]=ma(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hL=0;class ro{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hL++}),this.uuid=_r(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Wv(r[a].image)):s.push(Wv(r[a]))}else s=Wv(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function Wv(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?c2.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let fL=0;const Xv=new j;class Dn extends Ds{constructor(e=Dn.DEFAULT_IMAGE,t=Dn.DEFAULT_MAPPING,n=Fr,r=Fr,s=Fn,a=Ms,o=Di,l=Gr,c=Dn.DEFAULT_ANISOTROPY,h=ha){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:fL++}),this.uuid=_r(),this.name="",this.source=new ro(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new At,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Xv).x}get height(){return this.source.getSize(Xv).y}get depth(){return this.source.getSize(Xv).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Cg)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Sf:e.x=e.x-Math.floor(e.x);break;case Fr:e.x=e.x<0?0:1;break;case Ef:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Sf:e.y=e.y-Math.floor(e.y);break;case Fr:e.y=e.y<0?0:1;break;case Ef:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Dn.DEFAULT_IMAGE=null;Dn.DEFAULT_MAPPING=Cg;Dn.DEFAULT_ANISOTROPY=1;class Bt{constructor(e=0,t=0,n=0,r=1){Bt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const l=e.elements,c=l[0],h=l[4],d=l[8],p=l[1],m=l[5],v=l[9],x=l[2],_=l[6],g=l[10];if(Math.abs(h-p)<.01&&Math.abs(d-x)<.01&&Math.abs(v-_)<.01){if(Math.abs(h+p)<.1&&Math.abs(d+x)<.1&&Math.abs(v+_)<.1&&Math.abs(c+m+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,S=(m+1)/2,w=(g+1)/2,T=(h+p)/4,R=(d+x)/4,U=(v+_)/4;return E>S&&E>w?E<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(E),r=T/n,s=R/n):S>w?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=T/r,s=U/r):w<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(w),n=R/s,r=U/s),this.set(n,r,s,t),this}let b=Math.sqrt((_-v)*(_-v)+(d-x)*(d-x)+(p-h)*(p-h));return Math.abs(b)<.001&&(b=1),this.x=(_-v)/b,this.y=(d-x)/b,this.z=(p-h)/b,this.w=Math.acos((c+m+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=St(this.x,e.x,t.x),this.y=St(this.y,e.y,t.y),this.z=St(this.z,e.z,t.z),this.w=St(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=St(this.x,e,t),this.y=St(this.y,e,t),this.z=St(this.z,e,t),this.w=St(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(St(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Kx extends Ds{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Bt(0,0,e,t),this.scissorTest=!1,this.viewport=new Bt(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new Dn(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Fn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new ro(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Rs extends Kx{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Pg extends Dn{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vi,this.minFilter=vi,this.wrapR=Fr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class dL extends Rs{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Pg(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class zg extends Dn{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vi,this.minFilter=vi,this.wrapR=Fr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class pL extends Rs{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new zg(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class Qn{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kr.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Kr.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Kr):Kr.fromBufferAttribute(s,a),Kr.applyMatrix4(e.matrixWorld),this.expandByPoint(Kr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Xd.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Xd.copy(n.boundingBox)),Xd.applyMatrix4(e.matrixWorld),this.union(Xd)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kr),Kr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(dh),jd.subVectors(this.max,dh),vc.subVectors(e.a,dh),yc.subVectors(e.b,dh),_c.subVectors(e.c,dh),ja.subVectors(yc,vc),qa.subVectors(_c,yc),jo.subVectors(vc,_c);let t=[0,-ja.z,ja.y,0,-qa.z,qa.y,0,-jo.z,jo.y,ja.z,0,-ja.x,qa.z,0,-qa.x,jo.z,0,-jo.x,-ja.y,ja.x,0,-qa.y,qa.x,0,-jo.y,jo.x,0];return!jv(t,vc,yc,_c,jd)||(t=[1,0,0,0,1,0,0,0,1],!jv(t,vc,yc,_c,jd))?!1:(qd.crossVectors(ja,qa),t=[qd.x,qd.y,qd.z],jv(t,vc,yc,_c,jd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:($s[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$s[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$s[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$s[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$s[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$s[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$s[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$s[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($s),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const $s=[new j,new j,new j,new j,new j,new j,new j,new j],Kr=new j,Xd=new Qn,vc=new j,yc=new j,_c=new j,ja=new j,qa=new j,jo=new j,dh=new j,jd=new j,qd=new j,qo=new j;function jv(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){qo.fromArray(i,s);const o=r.x*Math.abs(qo.x)+r.y*Math.abs(qo.y)+r.z*Math.abs(qo.z),l=e.dot(qo),c=t.dot(qo),h=n.dot(qo);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const mL=new Qn,ph=new j,qv=new j;let ri=class{constructor(e=new j,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):mL.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ph.subVectors(e,this.center);const t=ph.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(ph,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(qv.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ph.copy(e.center).add(qv)),this.expandByPoint(ph.copy(e.center).sub(qv))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const ea=new j,Yv=new j,Yd=new j,Ya=new j,Zv=new j,Zd=new j,Kv=new j;class Au{constructor(e=new j,t=new j(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ea)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ea.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ea.copy(this.origin).addScaledVector(this.direction,t),ea.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Yv.copy(e).add(t).multiplyScalar(.5),Yd.copy(t).sub(e).normalize(),Ya.copy(this.origin).sub(Yv);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Yd),o=Ya.dot(this.direction),l=-Ya.dot(Yd),c=Ya.lengthSq(),h=Math.abs(1-a*a);let d,p,m,v;if(h>0)if(d=a*l-o,p=a*o-l,v=s*h,d>=0)if(p>=-v)if(p<=v){const x=1/h;d*=x,p*=x,m=d*(d+a*p+2*o)+p*(a*d+p+2*l)+c}else p=s,d=Math.max(0,-(a*p+o)),m=-d*d+p*(p+2*l)+c;else p=-s,d=Math.max(0,-(a*p+o)),m=-d*d+p*(p+2*l)+c;else p<=-v?(d=Math.max(0,-(-a*s+o)),p=d>0?-s:Math.min(Math.max(-s,-l),s),m=-d*d+p*(p+2*l)+c):p<=v?(d=0,p=Math.min(Math.max(-s,-l),s),m=p*(p+2*l)+c):(d=Math.max(0,-(a*s+o)),p=d>0?s:Math.min(Math.max(-s,-l),s),m=-d*d+p*(p+2*l)+c);else p=a>0?-s:s,d=Math.max(0,-(a*p+o)),m=-d*d+p*(p+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Yv).addScaledVector(Yd,p),m}intersectSphere(e,t){ea.subVectors(e.center,this.origin);const n=ea.dot(this.direction),r=ea.dot(ea)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,p=this.origin;return c>=0?(n=(e.min.x-p.x)*c,r=(e.max.x-p.x)*c):(n=(e.max.x-p.x)*c,r=(e.min.x-p.x)*c),h>=0?(s=(e.min.y-p.y)*h,a=(e.max.y-p.y)*h):(s=(e.max.y-p.y)*h,a=(e.min.y-p.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),d>=0?(o=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(o=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ea)!==null}intersectTriangle(e,t,n,r,s){Zv.subVectors(t,e),Zd.subVectors(n,e),Kv.crossVectors(Zv,Zd);let a=this.direction.dot(Kv),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ya.subVectors(this.origin,e);const l=o*this.direction.dot(Zd.crossVectors(Ya,Zd));if(l<0)return null;const c=o*this.direction.dot(Zv.cross(Ya));if(c<0||l+c>a)return null;const h=-o*Ya.dot(Kv);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class bt{constructor(e,t,n,r,s,a,o,l,c,h,d,p,m,v,x,_){bt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c,h,d,p,m,v,x,_)}set(e,t,n,r,s,a,o,l,c,h,d,p,m,v,x,_){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=s,g[5]=a,g[9]=o,g[13]=l,g[2]=c,g[6]=h,g[10]=d,g[14]=p,g[3]=m,g[7]=v,g[11]=x,g[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new bt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/xc.setFromMatrixColumn(e,0).length(),s=1/xc.setFromMatrixColumn(e,1).length(),a=1/xc.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const p=a*h,m=a*d,v=o*h,x=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=m+v*c,t[5]=p-x*c,t[9]=-o*l,t[2]=x-p*c,t[6]=v+m*c,t[10]=a*l}else if(e.order==="YXZ"){const p=l*h,m=l*d,v=c*h,x=c*d;t[0]=p+x*o,t[4]=v*o-m,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=m*o-v,t[6]=x+p*o,t[10]=a*l}else if(e.order==="ZXY"){const p=l*h,m=l*d,v=c*h,x=c*d;t[0]=p-x*o,t[4]=-a*d,t[8]=v+m*o,t[1]=m+v*o,t[5]=a*h,t[9]=x-p*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const p=a*h,m=a*d,v=o*h,x=o*d;t[0]=l*h,t[4]=v*c-m,t[8]=p*c+x,t[1]=l*d,t[5]=x*c+p,t[9]=m*c-v,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const p=a*l,m=a*c,v=o*l,x=o*c;t[0]=l*h,t[4]=x-p*d,t[8]=v*d+m,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=m*d+v,t[10]=p-x*d}else if(e.order==="XZY"){const p=a*l,m=a*c,v=o*l,x=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=p*d+x,t[5]=a*h,t[9]=m*d-v,t[2]=v*d-m,t[6]=o*h,t[10]=x*d+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(gL,e,vL)}lookAt(e,t,n){const r=this.elements;return mr.subVectors(e,t),mr.lengthSq()===0&&(mr.z=1),mr.normalize(),Za.crossVectors(n,mr),Za.lengthSq()===0&&(Math.abs(n.z)===1?mr.x+=1e-4:mr.z+=1e-4,mr.normalize(),Za.crossVectors(n,mr)),Za.normalize(),Kd.crossVectors(mr,Za),r[0]=Za.x,r[4]=Kd.x,r[8]=mr.x,r[1]=Za.y,r[5]=Kd.y,r[9]=mr.y,r[2]=Za.z,r[6]=Kd.z,r[10]=mr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],p=n[9],m=n[13],v=n[2],x=n[6],_=n[10],g=n[14],b=n[3],E=n[7],S=n[11],w=n[15],T=r[0],R=r[4],U=r[8],A=r[12],D=r[1],L=r[5],P=r[9],I=r[13],V=r[2],H=r[6],z=r[10],O=r[14],B=r[3],G=r[7],X=r[11],k=r[15];return s[0]=a*T+o*D+l*V+c*B,s[4]=a*R+o*L+l*H+c*G,s[8]=a*U+o*P+l*z+c*X,s[12]=a*A+o*I+l*O+c*k,s[1]=h*T+d*D+p*V+m*B,s[5]=h*R+d*L+p*H+m*G,s[9]=h*U+d*P+p*z+m*X,s[13]=h*A+d*I+p*O+m*k,s[2]=v*T+x*D+_*V+g*B,s[6]=v*R+x*L+_*H+g*G,s[10]=v*U+x*P+_*z+g*X,s[14]=v*A+x*I+_*O+g*k,s[3]=b*T+E*D+S*V+w*B,s[7]=b*R+E*L+S*H+w*G,s[11]=b*U+E*P+S*z+w*X,s[15]=b*A+E*I+S*O+w*k,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],p=e[10],m=e[14],v=e[3],x=e[7],_=e[11],g=e[15];return v*(+s*l*d-r*c*d-s*o*p+n*c*p+r*o*m-n*l*m)+x*(+t*l*m-t*c*p+s*a*p-r*a*m+r*c*h-s*l*h)+_*(+t*c*d-t*o*m-s*a*d+n*a*m+s*o*h-n*c*h)+g*(-r*o*h-t*l*d+t*o*p+r*a*d-n*a*p+n*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],p=e[10],m=e[11],v=e[12],x=e[13],_=e[14],g=e[15],b=d*_*c-x*p*c+x*l*m-o*_*m-d*l*g+o*p*g,E=v*p*c-h*_*c-v*l*m+a*_*m+h*l*g-a*p*g,S=h*x*c-v*d*c+v*o*m-a*x*m-h*o*g+a*d*g,w=v*d*l-h*x*l-v*o*p+a*x*p+h*o*_-a*d*_,T=t*b+n*E+r*S+s*w;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/T;return e[0]=b*R,e[1]=(x*p*s-d*_*s-x*r*m+n*_*m+d*r*g-n*p*g)*R,e[2]=(o*_*s-x*l*s+x*r*c-n*_*c-o*r*g+n*l*g)*R,e[3]=(d*l*s-o*p*s-d*r*c+n*p*c+o*r*m-n*l*m)*R,e[4]=E*R,e[5]=(h*_*s-v*p*s+v*r*m-t*_*m-h*r*g+t*p*g)*R,e[6]=(v*l*s-a*_*s-v*r*c+t*_*c+a*r*g-t*l*g)*R,e[7]=(a*p*s-h*l*s+h*r*c-t*p*c-a*r*m+t*l*m)*R,e[8]=S*R,e[9]=(v*d*s-h*x*s-v*n*m+t*x*m+h*n*g-t*d*g)*R,e[10]=(a*x*s-v*o*s+v*n*c-t*x*c-a*n*g+t*o*g)*R,e[11]=(h*o*s-a*d*s-h*n*c+t*d*c+a*n*m-t*o*m)*R,e[12]=w*R,e[13]=(h*x*r-v*d*r+v*n*p-t*x*p-h*n*_+t*d*_)*R,e[14]=(v*o*r-a*x*r-v*n*l+t*x*l+a*n*_-t*o*_)*R,e[15]=(a*d*r-h*o*r+h*n*l-t*d*l-a*n*p+t*o*p)*R,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,p=s*c,m=s*h,v=s*d,x=a*h,_=a*d,g=o*d,b=l*c,E=l*h,S=l*d,w=n.x,T=n.y,R=n.z;return r[0]=(1-(x+g))*w,r[1]=(m+S)*w,r[2]=(v-E)*w,r[3]=0,r[4]=(m-S)*T,r[5]=(1-(p+g))*T,r[6]=(_+b)*T,r[7]=0,r[8]=(v+E)*R,r[9]=(_-b)*R,r[10]=(1-(p+x))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=xc.set(r[0],r[1],r[2]).length();const a=xc.set(r[4],r[5],r[6]).length(),o=xc.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Jr.copy(this);const c=1/s,h=1/a,d=1/o;return Jr.elements[0]*=c,Jr.elements[1]*=c,Jr.elements[2]*=c,Jr.elements[4]*=h,Jr.elements[5]*=h,Jr.elements[6]*=h,Jr.elements[8]*=d,Jr.elements[9]*=d,Jr.elements[10]*=d,t.setFromRotationMatrix(Jr),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=yr,l=!1){const c=this.elements,h=2*s/(t-e),d=2*s/(n-r),p=(t+e)/(t-e),m=(n+r)/(n-r);let v,x;if(l)v=s/(a-s),x=a*s/(a-s);else if(o===yr)v=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===fu)v=-a/(a-s),x=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=d,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=v,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=yr,l=!1){const c=this.elements,h=2/(t-e),d=2/(n-r),p=-(t+e)/(t-e),m=-(n+r)/(n-r);let v,x;if(l)v=1/(a-s),x=a/(a-s);else if(o===yr)v=-2/(a-s),x=-(a+s)/(a-s);else if(o===fu)v=-1/(a-s),x=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=d,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=v,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const xc=new j,Jr=new bt,gL=new j(0,0,0),vL=new j(1,1,1),Za=new j,Kd=new j,mr=new j,nE=new bt,iE=new yi;class Bi{constructor(e=0,t=0,n=0,r=Bi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],d=r[2],p=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(St(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-St(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(St(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-St(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(St(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-St(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return nE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(nE,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return iE.setFromEuler(this),this.setFromQuaternion(iE,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Bi.DEFAULT_ORDER="XYZ";class pu{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let yL=0;const rE=new j,bc=new yi,ta=new bt,Jd=new j,mh=new j,_L=new j,xL=new yi,sE=new j(1,0,0),aE=new j(0,1,0),oE=new j(0,0,1),lE={type:"added"},bL={type:"removed"},Sc={type:"childadded",child:null},Jv={type:"childremoved",child:null};class Xt extends Ds{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:yL++}),this.uuid=_r(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Xt.DEFAULT_UP.clone();const e=new j,t=new Bi,n=new yi,r=new j(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new bt},normalMatrix:{value:new At}}),this.matrix=new bt,this.matrixWorld=new bt,this.matrixAutoUpdate=Xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return bc.setFromAxisAngle(e,t),this.quaternion.multiply(bc),this}rotateOnWorldAxis(e,t){return bc.setFromAxisAngle(e,t),this.quaternion.premultiply(bc),this}rotateX(e){return this.rotateOnAxis(sE,e)}rotateY(e){return this.rotateOnAxis(aE,e)}rotateZ(e){return this.rotateOnAxis(oE,e)}translateOnAxis(e,t){return rE.copy(e).applyQuaternion(this.quaternion),this.position.add(rE.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(sE,e)}translateY(e){return this.translateOnAxis(aE,e)}translateZ(e){return this.translateOnAxis(oE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ta.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Jd.copy(e):Jd.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),mh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ta.lookAt(mh,Jd,this.up):ta.lookAt(Jd,mh,this.up),this.quaternion.setFromRotationMatrix(ta),r&&(ta.extractRotation(r.matrixWorld),bc.setFromRotationMatrix(ta),this.quaternion.premultiply(bc.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(lE),Sc.child=e,this.dispatchEvent(Sc),Sc.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(bL),Jv.child=e,this.dispatchEvent(Jv),Jv.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ta.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ta.multiply(e.parent.matrixWorld)),e.applyMatrix4(ta),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(lE),Sc.child=e,this.dispatchEvent(Sc),Sc.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,e,_L),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,xL,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),p=a(e.skeletons),m=a(e.animations),v=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),p.length>0&&(n.skeletons=p),m.length>0&&(n.animations=m),v.length>0&&(n.nodes=v)}return n.object=r,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Xt.DEFAULT_UP=new j(0,1,0);Xt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Qr=new j,na=new j,Qv=new j,ia=new j,Ec=new j,Mc=new j,cE=new j,$v=new j,ey=new j,ty=new j,ny=new Bt,iy=new Bt,ry=new Bt;class Ji{constructor(e=new j,t=new j,n=new j){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Qr.subVectors(e,t),r.cross(Qr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Qr.subVectors(r,t),na.subVectors(n,t),Qv.subVectors(e,t);const a=Qr.dot(Qr),o=Qr.dot(na),l=Qr.dot(Qv),c=na.dot(na),h=na.dot(Qv),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const p=1/d,m=(c*l-o*h)*p,v=(a*h-o*l)*p;return s.set(1-m-v,v,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,ia)===null?!1:ia.x>=0&&ia.y>=0&&ia.x+ia.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,ia)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,ia.x),l.addScaledVector(a,ia.y),l.addScaledVector(o,ia.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return ny.setScalar(0),iy.setScalar(0),ry.setScalar(0),ny.fromBufferAttribute(e,t),iy.fromBufferAttribute(e,n),ry.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ny,s.x),a.addScaledVector(iy,s.y),a.addScaledVector(ry,s.z),a}static isFrontFacing(e,t,n,r){return Qr.subVectors(n,t),na.subVectors(e,t),Qr.cross(na).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Qr.subVectors(this.c,this.b),na.subVectors(this.a,this.b),Qr.cross(na).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ji.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ji.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Ji.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Ji.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ji.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;Ec.subVectors(r,n),Mc.subVectors(s,n),$v.subVectors(e,n);const l=Ec.dot($v),c=Mc.dot($v);if(l<=0&&c<=0)return t.copy(n);ey.subVectors(e,r);const h=Ec.dot(ey),d=Mc.dot(ey);if(h>=0&&d<=h)return t.copy(r);const p=l*d-h*c;if(p<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Ec,a);ty.subVectors(e,s);const m=Ec.dot(ty),v=Mc.dot(ty);if(v>=0&&m<=v)return t.copy(s);const x=m*c-l*v;if(x<=0&&c>=0&&v<=0)return o=c/(c-v),t.copy(n).addScaledVector(Mc,o);const _=h*v-m*d;if(_<=0&&d-h>=0&&m-v>=0)return cE.subVectors(s,r),o=(d-h)/(d-h+(m-v)),t.copy(r).addScaledVector(cE,o);const g=1/(_+x+p);return a=x*g,o=p*g,t.copy(n).addScaledVector(Ec,a).addScaledVector(Mc,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const u2={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ka={h:0,s:0,l:0},Qd={h:0,s:0,l:0};function sy(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let Ye=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ri){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Gt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Gt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Gt.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Gt.workingColorSpace){if(e=Zx(e,1),t=St(t,0,1),n=St(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=sy(a,s,e+1/3),this.g=sy(a,s,e),this.b=sy(a,s,e-1/3)}return Gt.colorSpaceToWorking(this,r),this}setStyle(e,t=Ri){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ri){const n=u2[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ma(e.r),this.g=ma(e.g),this.b=ma(e.b),this}copyLinearToSRGB(e){return this.r=ru(e.r),this.g=ru(e.g),this.b=ru(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ri){return Gt.workingToColorSpace(Ai.copy(this),e),Math.round(St(Ai.r*255,0,255))*65536+Math.round(St(Ai.g*255,0,255))*256+Math.round(St(Ai.b*255,0,255))}getHexString(e=Ri){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Gt.workingColorSpace){Gt.workingToColorSpace(Ai.copy(this),t);const n=Ai.r,r=Ai.g,s=Ai.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-n)/d+2;break;case s:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Gt.workingColorSpace){return Gt.workingToColorSpace(Ai.copy(this),t),e.r=Ai.r,e.g=Ai.g,e.b=Ai.b,e}getStyle(e=Ri){Gt.workingToColorSpace(Ai.copy(this),e);const t=Ai.r,n=Ai.g,r=Ai.b;return e!==Ri?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Ka),this.setHSL(Ka.h+e,Ka.s+t,Ka.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Ka),e.getHSL(Qd);const n=uf(Ka.h,Qd.h,t),r=uf(Ka.s,Qd.s,t),s=uf(Ka.l,Qd.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Ai=new Ye;Ye.NAMES=u2;let SL=0;class Ui extends Ds{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:SL++}),this.uuid=_r(),this.name="",this.type="Material",this.blending=xl,this.side=ya,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vm,this.blendDst=ym,this.blendEquation=io,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ye(0,0,0),this.blendAlpha=0,this.depthFunc=wl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=q_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=hl,this.stencilZFail=hl,this.stencilZPass=hl,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==xl&&(n.blending=this.blending),this.side!==ya&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==vm&&(n.blendSrc=this.blendSrc),this.blendDst!==ym&&(n.blendDst=this.blendDst),this.blendEquation!==io&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==wl&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==q_&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==hl&&(n.stencilFail=this.stencilFail),this.stencilZFail!==hl&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==hl&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ea extends Ui{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.combine=Kf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const fa=EL();function EL(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,r[l]=24,r[l|256]=24):(n[l]=31744,n[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function Zi(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=St(i,-65504,65504),fa.floatView[0]=i;const e=fa.uint32View[0],t=e>>23&511;return fa.baseTable[t]+((e&8388607)>>fa.shiftTable[t])}function Yh(i){const e=i>>10;return fa.uint32View[0]=fa.mantissaTable[fa.offsetTable[e]+(i&1023)]+fa.exponentTable[e],fa.floatView[0]}class ML{static toHalfFloat(e){return Zi(e)}static fromHalfFloat(e){return Yh(e)}}const qn=new j,$d=new ke;let wL=0;class $t{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:wL++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Af,this.updateRanges=[],this.gpuType=Qi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)$d.fromBufferAttribute(this,t),$d.applyMatrix3(e),this.setXY(t,$d.x,$d.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyMatrix3(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyMatrix4(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyNormalMatrix(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.transformDirection(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Pi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Ot(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Pi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Pi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Pi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Pi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array),s=Ot(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Af&&(e.usage=this.usage),e}}class TL extends $t{constructor(e,t,n){super(new Int8Array(e),t,n)}}class AL extends $t{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class CL extends $t{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class RL extends $t{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Jx extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class DL extends $t{constructor(e,t,n){super(new Int32Array(e),t,n)}}class Qx extends $t{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class UL extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Yh(this.array[e*this.itemSize]);return this.normalized&&(t=Pi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize]=Zi(t),this}getY(e){let t=Yh(this.array[e*this.itemSize+1]);return this.normalized&&(t=Pi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+1]=Zi(t),this}getZ(e){let t=Yh(this.array[e*this.itemSize+2]);return this.normalized&&(t=Pi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+2]=Zi(t),this}getW(e){let t=Yh(this.array[e*this.itemSize+3]);return this.normalized&&(t=Pi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ot(t,this.array)),this.array[e*this.itemSize+3]=Zi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array)),this.array[e+0]=Zi(t),this.array[e+1]=Zi(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array)),this.array[e+0]=Zi(t),this.array[e+1]=Zi(n),this.array[e+2]=Zi(r),this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Ot(t,this.array),n=Ot(n,this.array),r=Ot(r,this.array),s=Ot(s,this.array)),this.array[e+0]=Zi(t),this.array[e+1]=Zi(n),this.array[e+2]=Zi(r),this.array[e+3]=Zi(s),this}}class ft extends $t{constructor(e,t,n){super(new Float32Array(e),t,n)}}let OL=0;const Ur=new bt,ay=new Xt,wc=new j,gr=new Qn,gh=new Qn,ui=new j;class Rt extends Ds{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:OL++}),this.uuid=_r(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(o2(e)?Qx:Jx)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new At().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ur.makeRotationFromQuaternion(e),this.applyMatrix4(Ur),this}rotateX(e){return Ur.makeRotationX(e),this.applyMatrix4(Ur),this}rotateY(e){return Ur.makeRotationY(e),this.applyMatrix4(Ur),this}rotateZ(e){return Ur.makeRotationZ(e),this.applyMatrix4(Ur),this}translate(e,t,n){return Ur.makeTranslation(e,t,n),this.applyMatrix4(Ur),this}scale(e,t,n){return Ur.makeScale(e,t,n),this.applyMatrix4(Ur),this}lookAt(e){return ay.lookAt(e),ay.updateMatrix(),this.applyMatrix4(ay.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wc).negate(),this.translate(wc.x,wc.y,wc.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new ft(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Qn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];gr.setFromBufferAttribute(s),this.morphTargetsRelative?(ui.addVectors(this.boundingBox.min,gr.min),this.boundingBox.expandByPoint(ui),ui.addVectors(this.boundingBox.max,gr.max),this.boundingBox.expandByPoint(ui)):(this.boundingBox.expandByPoint(gr.min),this.boundingBox.expandByPoint(gr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ri);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){const n=this.boundingSphere.center;if(gr.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];gh.setFromBufferAttribute(o),this.morphTargetsRelative?(ui.addVectors(gr.min,gh.min),gr.expandByPoint(ui),ui.addVectors(gr.max,gh.max),gr.expandByPoint(ui)):(gr.expandByPoint(gh.min),gr.expandByPoint(gh.max))}gr.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)ui.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(ui));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ui.fromBufferAttribute(o,c),l&&(wc.fromBufferAttribute(e,c),ui.add(wc)),r=Math.max(r,n.distanceToSquared(ui))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new $t(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let U=0;U<n.count;U++)o[U]=new j,l[U]=new j;const c=new j,h=new j,d=new j,p=new ke,m=new ke,v=new ke,x=new j,_=new j;function g(U,A,D){c.fromBufferAttribute(n,U),h.fromBufferAttribute(n,A),d.fromBufferAttribute(n,D),p.fromBufferAttribute(s,U),m.fromBufferAttribute(s,A),v.fromBufferAttribute(s,D),h.sub(c),d.sub(c),m.sub(p),v.sub(p);const L=1/(m.x*v.y-v.x*m.y);isFinite(L)&&(x.copy(h).multiplyScalar(v.y).addScaledVector(d,-m.y).multiplyScalar(L),_.copy(d).multiplyScalar(m.x).addScaledVector(h,-v.x).multiplyScalar(L),o[U].add(x),o[A].add(x),o[D].add(x),l[U].add(_),l[A].add(_),l[D].add(_))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let U=0,A=b.length;U<A;++U){const D=b[U],L=D.start,P=D.count;for(let I=L,V=L+P;I<V;I+=3)g(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const E=new j,S=new j,w=new j,T=new j;function R(U){w.fromBufferAttribute(r,U),T.copy(w);const A=o[U];E.copy(A),E.sub(w.multiplyScalar(w.dot(A))).normalize(),S.crossVectors(T,A);const L=S.dot(l[U])<0?-1:1;a.setXYZW(U,E.x,E.y,E.z,L)}for(let U=0,A=b.length;U<A;++U){const D=b[U],L=D.start,P=D.count;for(let I=L,V=L+P;I<V;I+=3)R(e.getX(I+0)),R(e.getX(I+1)),R(e.getX(I+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new $t(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let p=0,m=n.count;p<m;p++)n.setXYZ(p,0,0,0);const r=new j,s=new j,a=new j,o=new j,l=new j,c=new j,h=new j,d=new j;if(e)for(let p=0,m=e.count;p<m;p+=3){const v=e.getX(p+0),x=e.getX(p+1),_=e.getX(p+2);r.fromBufferAttribute(t,v),s.fromBufferAttribute(t,x),a.fromBufferAttribute(t,_),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),o.fromBufferAttribute(n,v),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,_),o.add(h),l.add(h),c.add(h),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let p=0,m=t.count;p<m;p+=3)r.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),a.fromBufferAttribute(t,p+2),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),n.setXYZ(p+0,h.x,h.y,h.z),n.setXYZ(p+1,h.x,h.y,h.z),n.setXYZ(p+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)ui.fromBufferAttribute(e,t),ui.normalize(),e.setXYZ(t,ui.x,ui.y,ui.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,p=new c.constructor(l.length*h);let m=0,v=0;for(let x=0,_=l.length;x<_;x++){o.isInterleavedBufferAttribute?m=l[x]*o.data.stride+o.offset:m=l[x]*h;for(let g=0;g<h;g++)p[v++]=c[m++]}return new $t(p,h,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Rt,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=e(p,n);l.push(m)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,p=c.length;d<p;d++){const m=c[d];h.push(m.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let p=0,m=d.length;p<m;p++)h.push(d[p].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const uE=new bt,Yo=new Au,ep=new ri,hE=new j,tp=new j,np=new j,ip=new j,oy=new j,rp=new j,fE=new j,sp=new j;class mn extends Xt{constructor(e=new Rt,t=new Ea){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){rp.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(oy.fromBufferAttribute(d,e),a?rp.addScaledVector(oy,h):rp.addScaledVector(oy.sub(t),h))}t.add(rp)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ep.copy(n.boundingSphere),ep.applyMatrix4(s),Yo.copy(e.ray).recast(e.near),!(ep.containsPoint(Yo.origin)===!1&&(Yo.intersectSphere(ep,hE)===null||Yo.origin.distanceToSquared(hE)>(e.far-e.near)**2))&&(uE.copy(s).invert(),Yo.copy(e.ray).applyMatrix4(uE),!(n.boundingBox!==null&&Yo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Yo)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,p=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,x=p.length;v<x;v++){const _=p[v],g=a[_.materialIndex],b=Math.max(_.start,m.start),E=Math.min(o.count,Math.min(_.start+_.count,m.start+m.count));for(let S=b,w=E;S<w;S+=3){const T=o.getX(S),R=o.getX(S+1),U=o.getX(S+2);r=ap(this,g,e,n,c,h,d,T,R,U),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),x=Math.min(o.count,m.start+m.count);for(let _=v,g=x;_<g;_+=3){const b=o.getX(_),E=o.getX(_+1),S=o.getX(_+2);r=ap(this,a,e,n,c,h,d,b,E,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let v=0,x=p.length;v<x;v++){const _=p[v],g=a[_.materialIndex],b=Math.max(_.start,m.start),E=Math.min(l.count,Math.min(_.start+_.count,m.start+m.count));for(let S=b,w=E;S<w;S+=3){const T=S,R=S+1,U=S+2;r=ap(this,g,e,n,c,h,d,T,R,U),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let _=v,g=x;_<g;_+=3){const b=_,E=_+1,S=_+2;r=ap(this,a,e,n,c,h,d,b,E,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}}}function LL(i,e,t,n,r,s,a,o){let l;if(e.side===Fi?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===ya,o),l===null)return null;sp.copy(o),sp.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(sp);return c<t.near||c>t.far?null:{distance:c,point:sp.clone(),object:i}}function ap(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,tp),i.getVertexPosition(l,np),i.getVertexPosition(c,ip);const h=LL(i,e,t,n,tp,np,ip,fE);if(h){const d=new j;Ji.getBarycoord(fE,tp,np,ip,d),r&&(h.uv=Ji.getInterpolatedAttribute(r,o,l,c,d,new ke)),s&&(h.uv1=Ji.getInterpolatedAttribute(s,o,l,c,d,new ke)),a&&(h.normal=Ji.getInterpolatedAttribute(a,o,l,c,d,new j),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new j,materialIndex:0};Ji.getNormal(tp,np,ip,p.normal),h.face=p,h.barycoord=d}return h}class go extends Rt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let p=0,m=0;v("z","y","x",-1,-1,n,t,e,a,s,0),v("z","y","x",1,-1,n,t,-e,a,s,1),v("x","z","y",1,1,e,n,t,r,a,2),v("x","z","y",1,-1,e,n,-t,r,a,3),v("x","y","z",1,-1,e,t,n,r,s,4),v("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new ft(c,3)),this.setAttribute("normal",new ft(h,3)),this.setAttribute("uv",new ft(d,2));function v(x,_,g,b,E,S,w,T,R,U,A){const D=S/R,L=w/U,P=S/2,I=w/2,V=T/2,H=R+1,z=U+1;let O=0,B=0;const G=new j;for(let X=0;X<z;X++){const k=X*L-I;for(let Y=0;Y<H;Y++){const Q=Y*D-P;G[x]=Q*b,G[_]=k*E,G[g]=V,c.push(G.x,G.y,G.z),G[x]=0,G[_]=0,G[g]=T>0?1:-1,h.push(G.x,G.y,G.z),d.push(Y/R),d.push(1-X/U),O+=1}}for(let X=0;X<U;X++)for(let k=0;k<R;k++){const Y=p+k+H*X,Q=p+k+H*(X+1),te=p+(k+1)+H*(X+1),ee=p+(k+1)+H*X;l.push(Y,Q,ee),l.push(Q,te,ee),B+=6}o.addGroup(m,B,A),m+=B,p+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new go(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function mu(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Ni(i){const e={};for(let t=0;t<i.length;t++){const n=mu(i[t]);for(const r in n)e[r]=n[r]}return e}function IL(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function h2(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Gt.workingColorSpace}const $x={clone:mu,merge:Ni};var NL=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
3
  }`,PL=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -4184,4 +4184,4 @@ vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
4184
4184
 
4185
4185
  gl_FragColor = vec4(color, opacity);
4186
4186
  }
4187
- `,zW=({curveOffset:i,animated:e,color:t="#000",curve:n,curved:r=!1,dashed:s=!1,dashArray:a=[3,1],id:o,opacity:l=1,size:c=1,renderOrder:h=-1,onContextMenu:d,onClick:p,onPointerOver:m,onPointerOut:v})=>{const x=K.useRef(null),_=tt(T=>T.draggingIds.length>0),g=K.useMemo(()=>new Ye(t),[t]),b=tt(T=>T.centerPosition),E=K.useRef(!1),S=K.useMemo(()=>{if(!s)return null;const[T,R]=a;return new Hr({uniforms:{color:{value:g},opacity:{value:l},dashSize:{value:T},gapSize:{value:R},lineLength:{value:n.getLength()}},vertexShader:NW,fragmentShader:PW,transparent:!0,depthTest:!1})},[s,g,l,n,a]),{lineOpacity:w}=er({from:{lineOpacity:0},to:{lineOpacity:l},config:{...tr,duration:e?void 0:0}});return er(()=>{const T=n.getPoint(0),R=n.getPoint(1);return{from:{fromVertices:E.current?[R?.x,R?.y,R?.z||0]:[b?.x,b?.y,b?.z||0],toVertices:[T?.x,T?.y,T?.z||0]},to:{fromVertices:[T?.x,T?.y,T?.z||0],toVertices:[R?.x,R?.y,R?.z||0]},onChange:U=>{const{fromVertices:A,toVertices:D}=U.value,L=new j(...A),P=new j(...D),I=Zf(L,0,P,0,r,i);if(x.current){const V=s?c*.4:c/2;x.current.copy(new fo(I,20,V,5,!1))}},config:{...tr,duration:e&&!_?void 0:0}}},[e,_,n,c,s,r,i]),K.useEffect(()=>{E.current=!0},[]),he.jsxs("mesh",{userData:{id:o,type:"edge"},renderOrder:h,onPointerOver:m,onPointerOut:v,onClick:p,onPointerDown:T=>{T.nativeEvent.buttons===2&&T.stopPropagation()},onContextMenu:T=>{T.nativeEvent.preventDefault(),T.stopPropagation(),d()},children:[he.jsx("tubeGeometry",{attach:"geometry",ref:x}),s?he.jsx("primitive",{attach:"material",object:S}):he.jsx(An.meshBasicMaterial,{attach:"material",opacity:w,fog:!0,transparent:!0,color:g})]})},uA=3,FW=({animated:i,arrowPlacement:e="end",contextMenu:t,disabled:n,labelPlacement:r="inline",id:s,interpolation:a,labelFontUrl:o,onContextMenu:l,onClick:c,onPointerOver:h,onPointerOut:d,subLabelPlacement:p="below"})=>{const m=tt(F=>F.theme),v=tt(F=>F.draggingIds.length>0),[x,_]=K.useState(!1),[g,b]=K.useState(!1),E=tt(F=>F.edges),S=E.find(F=>F.id===s),{target:w,source:T,label:R,subLabel:U,labelVisible:A=!1,size:D=1,fill:L,dashed:P=!1,dashArray:I=[3,1]}=S,V=S.subLabelPlacement||p,H=tt(F=>F.nodes.find(ne=>ne.id===T)),z=tt(F=>F.nodes.find(ne=>ne.id===w)),O=H.id===z.id,B=(D+m.edge.label.fontSize)/2,[G,X]=K.useMemo(()=>MD(D),[D]),k=S.interpolation||a,Y=S.arrowPlacement||e,{curveOffset:Q,curved:te}=K.useMemo(()=>EW({edge:S,edges:E,curved:k==="curved"}),[S,E,k]),[ee,ie,re]=K.useMemo(()=>{const F=Eu(H),ne=H.size,Se=Eu(z),_e=z.size;let me=Zf(F,ne,Se,_e,te,Q);const[ze,Ne]=ED(Y,me,G);return Y==="end"&&(me=Zf(F,ne,ze,0,te,Q)),[me,ze,Ne]},[H,z,te,Q,Y,G]),de=K.useMemo(()=>{let F=AD(H.position,z.position,TD(B,r));if(te){const ne=new j().subVectors(F,ee.getPoint(.5));switch(r){case"above":ne.y=ne.y-uA;break;case"below":ne.y=ne.y+uA;break}F=F.sub(ne)}return F},[H.position,z.position,B,r,te,ee]),Ae=tt(F=>F.centerPosition),Me=tt(F=>F.selections?.includes(s)),ve=tt(F=>F.selections?.length),fe=tt(F=>F.actives?.includes(s)),J=x||fe||Me,oe=ve?Me||fe?m.edge.selectedOpacity:m.edge.inactiveOpacity:m.edge.opacity,se=K.useMemo(()=>MW(H.position,z.position,V),[H.position,z.position,V]),[{labelPosition:$}]=er(()=>({from:{labelPosition:Ae?[Ae.x,Ae.y,Ae.z]:[0,0,0]},to:{labelPosition:[de.x,de.y,de.z]},config:{...tr,duration:i&&!v?void 0:0}}),[de,i,v]),pe=K.useMemo(()=>new Bi(0,0,r==="natural"?0:Math.atan((z.position.y-H.position.y)/(z.position.x-H.position.x))),[z.position.x,z.position.y,H.position.x,H.position.y,r]);El(x&&!v&&c!==void 0,"pointer");const{pointerOver:ye,pointerOut:xe}=hb({disabled:n,onPointerOver:F=>{_(!0),h?.(S,F)},onPointerOut:F=>{_(!1),d?.(S,F)}}),be=K.useMemo(()=>CD(H),[H]),ue=K.useMemo(()=>{if(Y==="none")return null;let F,ne;return O&&be?Y==="mid"?(F=be.getPointAt(.25),ne=be.getTangentAt(.25)):(F=be.getPointAt(.58),ne=be.getTangentAt(.58)):(F=ie,ne=re),he.jsx(UW,{animated:i,color:J?m.arrow.activeFill:L||m.arrow.fill,length:G,opacity:oe,position:F,rotation:ne,size:X,onActive:_,onContextMenu:()=>{n||(b(!0),l?.(S))}})},[L,i,G,Y,ie,re,X,n,S,J,l,oe,m.arrow.activeFill,m.arrow.fill,O,be]),He=K.useMemo(()=>A&&R&&he.jsxs(An.group,{position:$,onContextMenu:()=>{n||(b(!0),l?.(S))},onPointerOver:ye,onPointerOut:xe,children:[he.jsx(Mu,{text:R,ellipsis:15,fontUrl:o,stroke:m.edge.label.stroke,color:J?m.edge.label.activeColor:m.edge.label.color,opacity:oe,fontSize:m.edge.label.fontSize,rotation:pe,active:J}),U&&he.jsx("group",{position:[se.x,se.y,0],children:he.jsx(Mu,{text:U,ellipsis:15,fontUrl:o,stroke:m.edge.subLabel?.stroke||m.edge.label.stroke,active:J,color:J?m.edge.subLabel?.activeColor||m.edge.label.activeColor:m.edge.subLabel?.color||m.edge.label.color,opacity:oe,fontSize:m.edge.subLabel?.fontSize||m.edge.label.fontSize*.8,rotation:pe})})]}),[n,S,J,R,U,o,$,se,pe,A,l,xe,ye,oe,m.edge.label.activeColor,m.edge.label.color,m.edge.label.fontSize,m.edge.label.stroke,m.edge.subLabel?.stroke,m.edge.subLabel?.activeColor,m.edge.subLabel?.color,m.edge.subLabel?.fontSize]),W=K.useMemo(()=>g&&t&&he.jsx(tb,{prepend:!0,center:!0,position:de,children:t({data:S,onClose:()=>b(!1)})}),[g,t,de,S]);return he.jsxs("group",{position:[0,0,J?1:0],children:[O&&be?he.jsx(IW,{id:s,curve:be,size:D,animated:i,color:J?m.edge.activeFill:L||m.edge.fill,opacity:oe,onClick:F=>{n||c?.(S,F)},onContextMenu:()=>{n||(b(!0),l?.(S))},onPointerOver:ye,onPointerOut:xe}):he.jsx(zW,{curveOffset:Q,animated:i,color:J?m.edge.activeFill:L||m.edge.fill,curve:ee,curved:te,dashed:P,dashArray:I,id:s,opacity:oe,size:D,renderOrder:J?0:-1,onClick:F=>{n||c?.(S,F)},onPointerOver:ye,onPointerOut:xe,onContextMenu:()=>{n||(b(!0),l?.(S))}}),ue,He,W]})},BW=({animated:i,color:e,contextMenu:t,edge:n,labelFontUrl:r,labelPlacement:s="inline",opacity:a,active:o})=>{const l=tt(L=>L.theme),{target:c,source:h,label:d,labelVisible:p=!1,size:m=1}=n,v=tt(L=>L.nodes),[x,_]=K.useMemo(()=>[v.find(L=>L.id===h),v.find(L=>L.id===c)],[v,h,c]),g=tt(L=>L.draggingIds.length>0),b=K.useMemo(()=>(m+l.edge.label.fontSize)/2,[m,l.edge.label.fontSize]),E=K.useMemo(()=>AD(x.position,_.position,TD(b,s)),[x.position,_.position,b,s]),S=tt(L=>L.edgeContextMenus),w=tt(L=>L.setEdgeContextMenus),[{labelPosition:T}]=er(()=>({from:{labelPosition:[0,0,0]},to:{labelPosition:[E.x,E.y,E.z]},config:{...tr,duration:i&&!g?void 0:0}}),[E,i,g]),R=K.useCallback(L=>{const P=new Set(S);P.delete(L),w(P)},[S,w]),U=K.useMemo(()=>new Bi(0,0,s==="natural"?0:Math.atan((_.position.y-x.position.y)/(_.position.x-x.position.x))),[_.position.x,_.position.y,x.position.x,x.position.y,s]),A=K.useMemo(()=>({prepend:!0,center:!0,position:E}),[E]),D=K.useMemo(()=>({text:d,ellipsis:15,fontUrl:r,stroke:l.edge.label.stroke,color:e,opacity:a,fontSize:l.edge.label.fontSize,rotation:U,active:o}),[d,r,l.edge.label.stroke,e,a,l.edge.label.fontSize,U,o]);return he.jsxs("group",{children:[p&&d&&he.jsx(An.group,{position:T,children:he.jsx(Mu,{...D})}),t&&S.has(n.id)&&he.jsx(tb,{...A,children:t({data:n,onClose:()=>R(n.id)})})]})};function kW(i,e){const t=K.useRef(i),n=K.useRef(null);K.useEffect(()=>{t.current=i;const a=i.getAttribute("position");n.current=new Float32Array(a.array.length)},[i]);const r=K.useCallback(()=>{const a=t.current.getAttribute("position");return{from:new Float32Array(a.array.length),to:a.array}},[]),s=K.useCallback(a=>{const o=n.current;o.set(a);const l=new $t(o,3,!1);t.current.setAttribute("position",l),l.needsUpdate=!0},[]);er(()=>{if(!e)return null;const a=r();return{from:{positions:a.from},to:{positions:a.to},onChange:o=>{s(o.value.positions)},config:{...tr,duration:e?void 0:0}}},[e,r,s])}function GW(i,e,t){const[{activeOpacity:n,inactiveOpacity:r}]=er(()=>({from:{activeOpacity:0,inactiveOpacity:0},to:{activeOpacity:e?t.edge.selectedOpacity:t.edge.opacity,inactiveOpacity:e?t.edge.inactiveOpacity:t.edge.opacity},config:{...tr,duration:i?void 0:0}}),[i,e,t]);return{activeOpacity:n,inactiveOpacity:r}}function HW(i,e,t){const n=K.useRef(i);K.useEffect(()=>{n.current=i},[i]);const r=tt(p=>p.edgeContextMenus),s=tt(K.useCallback(p=>p.setEdgeContextMenus,[])),a=tt(K.useCallback(p=>p.setHoveredEdgeIds,[])),o=K.useRef(!1),l=K.useCallback(()=>{o.current=!0},[]),c=K.useRef(!1),h=K.useCallback(()=>{c.current=!0},[]),d=K.useCallback((p,m)=>{const{onClick:v,onContextMenu:x,onPointerOver:_,onPointerOut:g}=n.current;if(v&&o.current&&!t){o.current=!1;for(const E of m)v(E)}if((e||x)&&c.current&&!t){c.current=!1;const E=new Set(r);let S=!1;for(const w of m)r.has(w.id)||(E.add(w.id),S=!0,x?.(w));S&&s(E)}const b=m.length>0?m.map(E=>E.id):[];a(b),_&&m.filter(S=>!p.includes(S)).forEach(S=>{_(S)}),g&&p.filter(S=>!m.includes(S)).forEach(S=>{g(S)})},[e,t,r,s,a]);return{handleClick:l,handleContextMenu:h,handleIntersections:d}}const hA=dW();function VW(i,e){const t=K.useRef(null),n=tt(l=>l.theme);tt(l=>{t.current=l});const r=K.useRef(new Map),s=K.useRef(null),a=K.useCallback(l=>{const c=[],h=r.current,{nodes:d}=t.current,p=new Map(d.map(m=>[m.id,m]));return i!=="none"&&!s.current&&(s.current=new Cu(0,1,1,20,1,!0)),l.forEach(m=>{const{target:v,source:x,size:_=1}=m,g=p.get(x),b=p.get(v);if(!g||!b)return;const E=`${g.position.x},${g.position.y},${b.position.x},${b.position.y},${_}`,S=g.id===b.id,T=(m.interpolation||e)==="curved",R=m.arrowPlacement||i;if(h.has(E)){c.push(h.get(E));return}const U=Eu(g),A=g.size,D=Eu(b),L=b.size;let P;S?P=CD(g):P=Zf(U,A,D,L,T);const I=m.dashed,V=I?_*.4:_/2;let H;if(I?H=sA(P,V,new Ye(m.fill??n.edge.fill),m.dashArray):H=new fo(P,20,V,5,!1),R==="none"){if(!I){const te=new Ye(m.fill??n.edge.fill);gm(H,te)}c.push(H),h.set(E,H);return}const[z,O]=MD(_),B=s.current.clone();B.scale(O,z,O);let G,X;S?R==="mid"?(G=P.getPointAt(.25),X=P.getTangentAt(.25)):(G=P.getPointAt(.58),X=P.getTangentAt(.58)):[G,X]=ED(R,P,z);const k=new yi;if(k.setFromUnitVectors(new j(0,1,0),X),B.applyQuaternion(k),B.translate(G.x,G.y,G.z),R&&R==="end"&&!S){const te=Zf(U,A,G,0,T);I?H=sA(te,V,new Ye(m.fill??n.edge.fill),m.dashArray):H=new fo(te,20,V,5,!1)}const Y=new Ye(m.fill??n.edge.fill);I||gm(H,Y),gm(B,Y);const Q=Jh([H,B]);Q.userData={...Q.userData,type:"edge"},c.push(Q),h.set(E,Q)}),c},[i,e,n.edge.fill]),o=K.useCallback((l,c)=>{const h=a(l),d=a(c);return Jh([d.length?Jh(d):hA,h.length?Jh(h):hA],!0)},[a]);return{getGeometries:a,getGeometry:o}}const WW=({interpolation:i="linear",arrowPlacement:e="end",labelPlacement:t="inline",animated:n,contextMenu:r,disabled:s,edges:a,labelFontUrl:o,onClick:l,onContextMenu:c,onPointerOut:h,onPointerOver:d})=>{const p=tt(k=>k.theme),{getGeometries:m,getGeometry:v}=VW(e,i),x=tt(k=>k.draggingIds),_=tt(k=>k.edgeMeshes),g=tt(k=>k.setEdgeMeshes),b=tt(k=>k.actives||[]),E=tt(k=>k.selections||[]),S=tt(k=>k.hoveredEdgeIds||[]),[w,T,R,U]=K.useMemo(()=>{const k=[],Y=[],Q=[],te=[];return a.forEach(ee=>{if(x.includes(ee.source)||x.includes(ee.target)){E.includes(ee.id)||b.includes(ee.id)||S.includes(ee.id)?Q.push(ee):te.push(ee);return}E.includes(ee.id)||b.includes(ee.id)||S.includes(ee.id)?k.push(ee):Y.push(ee)}),[k,Y,Q,te]},[a,b,E,x,S]),A=!!E.length,D=K.useMemo(()=>v(w,T),[v,w,T]),{activeOpacity:L,inactiveOpacity:P}=GW(n,A,p);kW(D,n),K.useEffect(()=>{if(x.length===0){const Y=m(a).map(Q=>new mn(Q));g(Y)}},[m,g,a,x.length]);const I=K.useRef(new mn),V=K.useRef(new mn),H=K.useCallback(k=>{if(!k.camera)return[];const Y=k.intersectObjects(_);return Y.length?Y.map(Q=>a[_.indexOf(Q.object)]):[]},[_,a]),{handleClick:z,handleContextMenu:O,handleIntersections:B}=HW({onClick:l,onContextMenu:c,onPointerOut:h,onPointerOver:d},r,s),G=K.useRef([]),X=K.useRef([]);return u0(k=>{if(I.current.geometry=D,s)return;const Y=G.current;if((x.length||x.length===0&&Y!==null)&&(V.current.geometry=v(R,U)),G.current=x,x.length)return;const Q=X.current,te=H(k.raycaster);B(Q,te),te.join()!==Q.join()&&(V.current.geometry=v(te,[])),X.current=te}),he.jsxs("group",{onClick:z,onContextMenu:O,children:[he.jsxs("mesh",{ref:I,children:[he.jsx(An.meshBasicMaterial,{attach:"material-0",depthTest:!1,fog:!0,opacity:P,side:zn,transparent:!0,vertexColors:!0}),he.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:zn,transparent:!0})]}),he.jsxs("mesh",{ref:V,children:[he.jsx(An.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:P,side:zn,transparent:!0}),he.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:zn,transparent:!0})]}),a.map(k=>{const Y=E.includes(k.id),Q=b.includes(k.id),te=S.includes(k.id);return he.jsx(BW,{animated:n,contextMenu:r,color:Y||Q||te?p.edge.label.activeColor:p.edge.label.color,disabled:s,edge:k,labelFontUrl:o,labelPlacement:t,active:Y||Q||te},k.id)})]})},XW=({image:i,id:e,size:t,opacity:n=1,animated:r})=>{const s=K.useMemo(()=>new q2().load(i),[i]),{scale:a,spriteOpacity:o}=er({from:{scale:[1e-5,1e-5,1e-5],spriteOpacity:0},to:{scale:[t,t,t],spriteOpacity:n},config:{...tr,duration:r?void 0:0}});return he.jsx(An.sprite,{userData:{id:e,type:"node"},scale:a,children:he.jsx(An.spriteMaterial,{attach:"material",opacity:o,fog:!0,depthTest:!1,transparent:!0,side:zn,children:he.jsx("primitive",{attach:"map",object:s,minFilter:Fn})})})},jW=({color:i="#D8E6EA",size:e=1,opacity:t=.5,animated:n,strokeWidth:r=5,innerRadius:s=4,segments:a=25})=>{const o=K.useMemo(()=>new Ye(i),[i]),{ringSize:l,ringOpacity:c}=er({from:{ringOpacity:0,ringSize:[1e-5,1e-5,1e-5]},to:{ringOpacity:t,ringSize:[e/2,e/2,1]},config:{...tr,duration:n?void 0:0}}),h=r/10,d=s+h;return he.jsx(KR,{position:[0,0,1],children:he.jsxs(An.mesh,{scale:l,raycast:t>0?void 0:()=>[],children:[he.jsx("ringGeometry",{attach:"geometry",args:[s,d,a]}),he.jsx(An.meshBasicMaterial,{attach:"material",color:o,transparent:!0,depthTest:!1,opacity:c,side:zn,fog:!0})]})})},qW=({color:i,id:e,size:t,selected:n,opacity:r=1,animated:s})=>{const{scale:a,nodeOpacity:o}=er({from:{scale:[1e-5,1e-5,1e-5],nodeOpacity:0},to:{scale:[t,t,t],nodeOpacity:r},config:{...tr,duration:s?void 0:0}}),l=K.useMemo(()=>new Ye(i),[i]),c=tt(h=>h.theme);return he.jsxs(he.Fragment,{children:[he.jsxs(An.mesh,{userData:{id:e,type:"node"},scale:a,children:[he.jsx("sphereGeometry",{attach:"geometry",args:[1,25,25]}),he.jsx(An.meshPhongMaterial,{attach:"material",side:zn,transparent:!0,fog:!0,opacity:o,color:l,emissive:l,emissiveIntensity:.7})]}),he.jsx(jW,{opacity:n?.5:0,size:t,animated:s,color:n?c.ring.activeFill:c.ring.fill})]})},YW=({animated:i,disabled:e,id:t,draggable:n=!1,labelFontUrl:r,contextMenu:s,onClick:a,onDoubleClick:o,onPointerOver:l,onDragged:c,onPointerOut:h,onContextMenu:d,renderNode:p,constrainDragging:m})=>{const v=w0(),x=tt(ue=>ue.theme),_=tt(ue=>ue.nodes.find(He=>He.id===t)),g=tt(ue=>ue.edges),b=tt(ue=>ue.draggingIds),E=tt(ue=>ue.collapsedNodeIds),S=tt(ue=>ue.addDraggingId),w=tt(ue=>ue.removeDraggingId),T=tt(ue=>ue.setHoveredNodeId),R=tt(ue=>ue.setNodePosition),U=tt(ue=>ue.setCollapsedNodeIds),A=tt(ue=>ue.collapsedNodeIds.includes(t)),D=tt(ue=>ue.actives?.includes(t)),L=tt(ue=>ue.selections?.includes(t)),P=tt(ue=>ue.selections?.length>0),I=tt(ue=>ue.centerPosition),V=tt(ue=>ue.clusters.get(_.cluster)),H=b.includes(t),z=b.length>0,{position:O,label:B,subLabel:G,size:X=7,labelVisible:k=!0}=_,Y=K.useRef(null),[Q,te]=K.useState(!1),[ee,ie]=K.useState(!1),re=Q||L||D,de=P?re?x.node.selectedOpacity:x.node.inactiveOpacity:x.node.opacity,Ae=K.useMemo(()=>g.filter(He=>He.source===t).length>0||A,[g,t,A]),Me=K.useCallback(()=>{Ae&&U(A?E.filter(ue=>ue!==t):[...E,t])},[Ae,E,t,A,U]),[{nodePosition:ve,labelPosition:fe}]=er(()=>({from:{nodePosition:I?[I.x,I.y,0]:[0,0,0],labelPosition:[0,-(X+7),2]},to:{nodePosition:O?[O.x,O.y,re?O.z+1:O.z]:[0,0,0],labelPosition:[0,-(X+7),2]},config:{...tr,duration:i&&!z?void 0:0}}),[H,O,i,X,re]),J=ND({draggable:n,position:O,bounds:m?V?.position:void 0,set:ue=>R(t,ue),onDragStart:()=>{S(t),te(!0)},onDragEnd:()=>{w(t),c?.(_)}});El(Q&&!z&&a!==void 0,"pointer"),El(Q&&n&&!H&&a===void 0,"grab"),El(H,"grabbing");const oe=re||H,se=oe?x.node.activeFill:_.fill||x.node.fill,{pointerOver:$,pointerOut:pe}=hb({disabled:e||H,onPointerOver:ue=>{v.freeze(),te(!0),l?.(_,ue),T(t)},onPointerOut:ue=>{v.unFreeze(),te(!1),h?.(_,ue),T(null)}}),ye=K.useMemo(()=>p?p({id:t,color:se,size:X,active:oe,opacity:de,animated:i,selected:L,node:_}):he.jsx(he.Fragment,{children:_.icon?he.jsx(XW,{id:t,image:_.icon||"",size:X+8,opacity:de,animated:i,color:se,node:_,active:oe,selected:L}):he.jsx(qW,{id:t,size:X,opacity:de,animated:i,color:se,node:_,active:oe,selected:L})}),[p,t,se,X,oe,de,i,L,_]),xe=K.useMemo(()=>k&&(k||L||Q)&&B&&he.jsxs(An.group,{position:fe,children:[he.jsx(Mu,{text:B,fontUrl:r,opacity:de,stroke:x.node.label.stroke,backgroundColor:x.node.label.backgroundColor,backgroundOpacity:x.node.label.backgroundOpacity,padding:x.node.label.padding,strokeColor:x.node.label.strokeColor,strokeWidth:x.node.label.strokeWidth,radius:x.node.label.radius,active:L||Q||H||D,color:L||Q||H||D?x.node.label.activeColor:x.node.label.color}),G&&he.jsx("group",{position:[0,-(X-3),0],children:he.jsx(Mu,{text:G,fontUrl:r,fontSize:5,opacity:de,stroke:x.node.subLabel?.stroke,active:L||Q||H||D,color:L||Q||H||D?x.node.subLabel?.activeColor:x.node.subLabel?.color})})]}),[Q,D,H,L,B,r,fe,k,X,de,G,x.node.label.activeColor,x.node.label.color,x.node.label.stroke,x.node.label.backgroundColor,x.node.label.backgroundOpacity,x.node.label.padding,x.node.label.strokeColor,x.node.label.strokeWidth,x.node.label.radius,x.node.subLabel?.activeColor,x.node.subLabel?.color,x.node.subLabel?.stroke]),be=K.useMemo(()=>ee&&s&&he.jsx(tb,{prepend:!0,center:!0,children:s({data:_,canCollapse:Ae,isCollapsed:A,onCollapse:Me,onClose:()=>ie(!1)})}),[ee,s,_,Ae,A,Me]);return he.jsxs(An.group,{renderOrder:1,userData:{id:t,type:"node"},ref:Y,position:ve,onPointerOver:$,onPointerOut:pe,onClick:ue=>{!e&&!H&&a?.(_,{canCollapse:Ae,isCollapsed:A},ue)},onDoubleClick:ue=>{!e&&!H&&o?.(_,ue)},onContextMenu:()=>{e||(ie(!0),d?.(_,{canCollapse:Ae,isCollapsed:A,onCollapse:Me}))},...J(),children:[ye,be,xe]})};function ZW(i){return new Promise((e,t)=>{let n;function r(){n?e(n):(n=i.step(),r())}r()})}function Fl(i){const e=[],t=[];return i.forEachNode((n,r)=>{e.push({...r,id:n,radius:r.size||1})}),i.forEachEdge((n,r)=>{t.push({...r,id:n})}),{nodes:e,edges:t}}function KW({graph:i,radius:e,drags:t,getNodePosition:n}){const r=K8(i,{scale:e}),{nodes:s,edges:a}=Fl(i);return{step(){return!0},getNodePosition(o){if(n){const l=n(o,{graph:i,drags:t,nodes:s,edges:a});if(l)return l}return t?.[o]?.position?t?.[o]?.position:r?.[o]}}}function JW({graph:i,radius:e=40,drags:t,getNodePosition:n,concentricSpacing:r=100}){const{nodes:s,edges:a}=Fl(i),o={},l=v=>{const x=2*Math.PI*(e+v*r);return Math.floor(x/40)},c=new Map,h=[];for(const v of s){const _=i.getNodeAttribute(v.id,"data")?.level;typeof _=="number"&&_>=0?(c.has(_)||c.set(_,[]),c.get(_).push(v.id)):h.push({id:v.id,metric:i.degree(v.id)})}h.sort((v,x)=>x.metric-v.metric);for(const[v,x]of c.entries()){const _=x.length,g=e+v*r;for(let b=0;b<_;b++){const E=2*Math.PI*b/_;o[x[b]]={x:g*Math.cos(E),y:g*Math.sin(E)}}}const d=new Set(c.keys());let p=0,m=0;for(;m<h.length;){for(;d.has(p);)p++;const v=l(p),x=e+p*r;for(let _=0;_<v&&m<h.length;_++){const g=2*Math.PI*_/v;o[h[m].id]={x:x*Math.cos(g),y:x*Math.sin(g)},m++}p++}return{step(){return!0},getNodePosition(v){if(n){const x=n(v,{graph:i,drags:t,nodes:s,edges:a});if(x)return x}return t?.[v]?.position?t[v].position:o[v]}}}function QW({graph:i,drags:e,getNodePosition:t}){const{nodes:n,edges:r}=Fl(i);return{step(){return!0},getNodePosition(s){return t(s,{graph:i,drags:e,nodes:n,edges:r})}}}function PD(i,e=[]){const t=e.length;for(const n of i){const r=e.indexOf(n);if(r>-1){const s=[...e.slice(r),n].map(a=>a.data.id);throw new Error(`Invalid Graph: Circular node path detected: ${s.join(" -> ")}.`)}t>n.depth&&(n.depth=t,PD(n.out,[...e,n]))}}function zD(i,e){let t=!1;const n=i.reduce((a,o)=>({...a,[o.id]:{data:o,out:[],depth:-1,ins:[]}}),{});try{for(const a of e){const o=a.source,l=a.target;if(!n.hasOwnProperty(o))throw new Error(`Missing source Node ${o}`);if(!n.hasOwnProperty(l))throw new Error(`Missing target Node ${l}`);const c=n[o],h=n[l];h.ins.push(c),c.out.push(h)}PD(Object.values(n))}catch{t=!0}const r=Object.keys(n).map(a=>n[a].depth),s=Math.max(...r);return{invalid:t,depths:n,maxDepth:s||1}}function $W({graph:i,drags:e,iterations:t,...n}){$8.assign(i);const r=s7(i,{iterations:t,settings:n});return{step(){return!0},getNodePosition(s){return e?.[s]?.position||r?.[s]}}}function eX(){const i=O=>()=>O;let t=O=>O.index,n=[],r=[],s,a,o=[100,100],l=i(1),c=i(-1),h=i(100),d=i(.1);const p={};let m=.1,v=.001,x=[],_=[0,0],g,b=O=>O.cluster,E="treemap",S=!0,w=.1;function T(O){if(!S)return T;E==="force"&&(g.tick(),I());for(let B=0,G=n.length,X,k=O*w;B<G;++B)X=n[B],X.vx+=(p[b(X)].x-X.x)*k,X.vy+=(p[b(X)].y-X.y)*k}function R(){n&&(E==="treemap"?V():z())}T.initialize=function(O){n=O,R()};function U(O){const B=b(O.source),G=b(O.target);return B<=G?B+"~"+G:G+"~"+B}function A(O){let B=new Map,G={};return O.forEach(function(X){B.has(b(X))||B.set(b(X),{count:0,sumforceNodeSize:0})}),O.forEach(function(X){G=B.get(b(X)),G.count=G.count+1,G.sumforceNodeSize=G.sumforceNodeSize+Math.PI*(l(X)*l(X))*1.3,B.set(b(X),G)}),B}function D(O){const B=new Map,G=[];return O.forEach(function(X){let k=U(X),Y;B.has(k)?Y=B.get(k):Y=0,Y+=1,B.set(k,Y)}),B.forEach(function(X,k){let Y,Q;Y=k.split("~")[0],Q=k.split("~")[1],Y!==void 0&&Q!==void 0&&G.push({source:Y,target:Q,count:X})}),G}function L(){const O=[],B=[],G=new Map;let X,k,Y,Q,te;Q=A(n),te=D(r);for(X of Q.keys())Y=Q.get(X),O.push({id:X,size:Y.count,r:Math.sqrt(Y.sumforceNodeSize/Math.PI)}),G.set(X,k);return te.forEach(function(ee){const ie=G.get(ee.source),re=G.get(ee.target);ie!==void 0&&re!==void 0&&B.push({source:ie,target:re,count:ee.count})}),{nodes:O,links:B}}function P(){const O=[];let B,G,X;X=A(T.nodes());for(B of X.keys())G=X.get(B),O.push({id:B,size:G.count});return{id:"clustersTree",children:O}}function I(){return p.none={x:0,y:0},x.forEach(function(O){E==="treemap"?p[O.data.id]={x:O.x0+(O.x1-O.x0)/2-_[0],y:O.y0+(O.y1-O.y0)/2-_[1]}:p[O.id]={x:O.x-_[0],y:O.y-_[1]}}),p}function V(){const O=iW().size(T.size());a=M0(P()).sum(B=>B.radius).sort(function(B,G){return G.height-B.height||G.value-B.value}),x=O(a).leaves(),I()}function H(){let O=0;n.length!==0&&r.forEach(function(B){let G,X;if(n){if(G=B.source,X=B.target,typeof B.source!="object"&&(G=n.find(k=>k.id===B.source)),typeof B.target!="object"&&(X=n.find(k=>k.id===B.target)),G===void 0||X===void 0)throw Error("Error setting links, couldnt find nodes for a link (see it on the console)");B.source=G,B.target=X,B.index=O++}})}function z(){let O;!n||!n.length||(H(),O=L(),s.size>0&&O.nodes.forEach(B=>{B.fx=s.get(B.id)?.position?.x,B.fy=s.get(B.id)?.position?.y}),g=_D(O.nodes).force("x",Ix(o[0]/2).strength(.1)).force("y",Nx(o[1]/2).strength(.1)).force("collide",fD(B=>B.r).iterations(4)).force("charge",xD().strength(c)).force("links",dD(O.nodes.length?O.links:[]).distance(h).strength(d)),x=g.nodes(),I())}return T.template=function(O){return arguments.length?(E=O,R(),T):E},T.groupBy=function(O){return arguments.length?typeof O=="string"?(b=function(B){return B[O]},T):(b=O,T):b},T.enableGrouping=function(O){return arguments.length?(S=O,T):S},T.strength=function(O){return arguments.length?(w=O,T):w},T.getLinkStrength=function(O){return S?b(O.source)===b(O.target)?typeof m=="function"?m(O):m:typeof v=="function"?v(O):v:typeof m=="function"?m(O):m},T.id=function(O){return arguments.length?(t=O,T):t},T.size=function(O){return arguments.length?(o=O,T):o},T.linkStrengthInterCluster=function(O){return arguments.length?(v=O,T):v},T.linkStrengthIntraCluster=function(O){return arguments.length?(m=O,T):m},T.nodes=function(O){return arguments.length?(n=O,T):n},T.links=function(O){return arguments.length?(O===null?r=[]:r=O,R(),T):r},T.template=function(O){return arguments.length?(E=O,R(),T):E},T.forceNodeSize=function(O){return arguments.length?(l=typeof O=="function"?O:i(+O),R(),T):l},T.nodeSize=T.forceNodeSize,T.forceCharge=function(O){return arguments.length?(c=typeof O=="function"?O:i(+O),R(),T):c},T.forceLinkDistance=function(O){return arguments.length?(h=typeof O=="function"?O:i(+O),R(),T):h},T.forceLinkStrength=function(O){return arguments.length?(d=typeof O=="function"?O:i(+O),R(),T):d},T.offset=function(O){return arguments.length?(_=typeof O=="function"?O:i(+O),T):_},T.getFocis=I,T.setClusters=function(O){return s=O,T},T}const fA=["radialin","radialout"];function tX({nodes:i,edges:e,mode:t="lr",nodeLevelRatio:n=2}){const{depths:r,maxDepth:s,invalid:a}=zD(i,e);if(a)return null;const o=fA.includes(t)?1:5,l=i.length/s*n*o;if(t){const c=(m,v)=>x=>m?(r[x.id].depth-s/2)*l*(v?-1:1):void 0,h=c(["lr","rl"].includes(t),t==="rl"),d=c(["td","bu"].includes(t),t==="td"),p=c(["zin","zout"].includes(t),t==="zout");i.forEach(m=>{m.fx=h(m),m.fy=d(m),m.fz=p(m)})}return fA.includes(t)?_9(c=>{const h=r[c.id];return(t==="radialin"?s-h.depth:h.depth)*l}).strength(1):null}function to({graph:i,nodeLevelRatio:e=2,mode:t=null,dimensions:n=2,nodeStrength:r=-250,linkDistance:s=50,clusterStrength:a=.5,linkStrengthInterCluster:o=.01,linkStrengthIntraCluster:l=.5,forceLinkDistance:c=100,forceLinkStrength:h=.1,clusterType:d="force",forceCharge:p=-700,getNodePosition:m,drags:v,clusters:x,clusterAttribute:_,forceLayout:g}){const{nodes:b,edges:E}=Fl(i),w=n===2&&E.length>25?r*2:r;let T,R;g==="forceDirected2d"?(T=Ix(),R=Nx()):(T=Ix(600).strength(.05),R=Nx(600).strength(.05));const U=_D().force("center",a7(0,0)).force("link",dD()).force("charge",xD().strength(w)).force("x",T).force("y",R).force("z",x9()).force("collide",fD(P=>P.radius+10)).force("dagRadial",tX({nodes:b,edges:E,mode:t,nodeLevelRatio:e})).stop();let A;if(_){let P=p;if(b?.length){const I=Math.ceil(b.length/200);P=p*I}A=eX().setClusters(x).strength(a).template(d).groupBy(I=>I.data[_]).links(E).size([100,100]).linkStrengthInterCluster(o).linkStrengthIntraCluster(l).forceLinkDistance(c).forceLinkStrength(h).forceCharge(P).forceNodeSize(I=>I.radius)}let D=U.numDimensions(n).nodes(b);if(A&&(D=D.force("group",A)),s){let P=D.force("link");P&&(P.id(I=>I.id).links(E).distance(s),A&&(P=P.strength(A?.getLinkStrength??.1)))}const L=new Map(b.map(P=>[P.id,P]));return{step(){for(;U.alpha()>.01;)U.tick();return!0},getNodePosition(P){if(m){const I=m(P,{graph:i,drags:v,nodes:b,edges:E});if(I)return I}return v?.[P]?.position?v?.[P]?.position:L.get(P)}}}const nX={td:{x:"x",y:"y",factor:-1},lr:{x:"y",y:"x",factor:1}};function dA({graph:i,drags:e,mode:t="td",nodeSeparation:n=1,nodeSize:r=[50,50],getNodePosition:s}){const{nodes:a,edges:o}=Fl(i),{depths:l}=zD(a,o),c=Object.keys(l).map(x=>l[x]),h=X9().id(x=>x.data.id).parentId(x=>x.ins?.[0]?.data?.id)(c),p=Q9().separation(()=>n).nodeSize(r)(M0(h)).descendants(),m=nX[t],v=new Map(a.map(x=>{const{x:_,y:g}=p.find(b=>b.data.id===x.id);return[x.id,{...x,[m.x]:_*m.factor,[m.y]:g*m.factor,z:0}]}));return{step(){return!0},getNodePosition(x){if(s){const _=s(x,{graph:i,drags:e,nodes:a,edges:o});if(_)return _}return e?.[x]?.position?e?.[x]?.position:v.get(x)}}}function pA(i,e,t){const n=Math.acos(1-2*(i+.5)/e),r=Math.PI*(1+Math.sqrt(5))*(i+.5),s=t*Math.sin(n)*Math.cos(r),a=t*Math.sin(n)*Math.sin(r),o=t*Math.cos(n);return new j(s,a,o)}function iX({graph:i,radius:e=40,drags:t,getNodePosition:n,concentricSpacing:r=100}){const{nodes:s,edges:a}=Fl(i),o={},l=v=>{const x=2*Math.PI*(e+v*r);return Math.floor(x/40)},c=new Map,h=[];for(const v of s){const _=i.getNodeAttribute(v.id,"data")?.level;typeof _=="number"&&_>=0?(c.has(_)||c.set(_,[]),c.get(_).push(v.id)):h.push({id:v.id,metric:i.degree(v.id)})}h.sort((v,x)=>x.metric-v.metric);for(const[v,x]of c.entries()){const _=x.length,g=e+v*r;for(const[b,E]of x.entries()){const S=pA(b,_,g);o[E]={x:S.x,y:S.y,z:S.z}}}const d=new Set(c.keys());let p=0,m=0;for(;m<h.length;){for(;d.has(p);)p++;const v=l(p),x=e+p*r;for(let _=0;_<v&&m<h.length;_++){const g=pA(_,v,x);o[h[m].id]={x:g.x,y:g.y,z:g.z},m++}p++}return{step(){return!0},getNodePosition(v){if(n){const x=n(v,{graph:i,drags:t,nodes:s,edges:a});if(x)return x}return t?.[v]?.position?t[v].position:o[v]}}}function rX({graph:i,margin:e,drags:t,getNodePosition:n,ratio:r,gridSize:s,maxIterations:a}){const{nodes:o,edges:l}=Fl(i),c=cW(i,{maxIterations:a,inputReducer:(h,d)=>({...d,x:d.x||0,y:d.y||0}),settings:{ratio:r,margin:e,gridSize:s}});return{step(){return!0},getNodePosition(h){if(n){const d=n(h,{graph:i,drags:t,nodes:o,edges:l});if(d)return d}return t?.[h]?.position?t?.[h]?.position:c?.[h]}}}const sX=["forceDirected2d","treeTd2d","treeLr2d","radialOut2d","treeTd3d","treeLr3d","radialOut3d","forceDirected3d"];function aX({type:i,...e}){if(sX.includes(i)){const{nodeStrength:t,linkDistance:n,nodeLevelRatio:r}=e;if(i==="forceDirected2d")return to({...e,dimensions:2,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i});if(i==="treeTd2d")return to({...e,mode:"td",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="treeLr2d")return to({...e,mode:"lr",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="radialOut2d")return to({...e,mode:"radialout",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="treeTd3d")return to({...e,mode:"td",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50});if(i==="treeLr3d")return to({...e,mode:"lr",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50,forceLayout:i});if(i==="radialOut3d")return to({...e,mode:"radialout",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="forceDirected3d")return to({...e,dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i})}else if(i==="circular2d"){const{radius:t}=e;return KW({...e,radius:t||300})}else{if(i==="concentric2d")return JW(e);if(i==="concentric3d")return iX(e);if(i==="hierarchicalTd")return dA({...e,mode:"td"});if(i==="hierarchicalLr")return dA({...e,mode:"lr"});if(i==="nooverlap"){const{graph:t,maxIterations:n,ratio:r,margin:s,gridSize:a,...o}=e;return rX({graph:t,margin:s||10,maxIterations:n||50,ratio:r||10,gridSize:a||20,...o})}else if(i==="forceatlas2"){const{graph:t,iterations:n,gravity:r,scalingRatio:s,...a}=e;return $W({type:"forceatlas2",graph:t,...a,scalingRatio:s||100,gravity:r||10,iterations:n||50})}else if(i==="custom")return QW({...e})}throw new Error(`Layout ${i} not found.`)}const oX=({layoutType:i,sizingType:e,labelType:t,sizingAttribute:n,clusterAttribute:r,selections:s,nodes:a,edges:o,actives:l,collapsedNodeIds:c,defaultNodeSize:h,maxNodeSize:d,minNodeSize:p,layoutOverrides:m,constrainDragging:v})=>{const x=tt(k=>k.graph),_=tt(k=>k.clusters),g=tt(k=>k.nodes),b=tt(k=>k.setClusters),E=tt(k=>k.collapsedNodeIds),S=tt(k=>k.setEdges),w=tt(k=>k.nodes),T=tt(k=>k.setNodes),R=tt(k=>k.setSelections),U=tt(k=>k.setActives),A=tt(k=>k.drags),D=tt(k=>k.setDrags),L=tt(k=>k.setCollapsedNodeIds),P=K.useRef(!1),I=K.useRef(null),V=Jn(k=>k.camera),H=K.useRef(A),z=K.useRef([]);K.useEffect(()=>{if(!r)return;const k=g.map(Q=>Q.id),Y=a.find(Q=>!k.includes(Q.id));if(Y){const Q=Y.data[r],te=_.get(Q),ee={...H.current};te?.nodes?.forEach(ie=>ee[ie.id]=void 0),H.current=ee,D(ee)}},[g,a,r,_,D]);const{visibleEdges:O,visibleNodes:B}=K.useMemo(()=>RW({collapsedIds:E,nodes:a,edges:o}),[E,a,o]),G=K.useCallback(k=>{const Y={...H.current};k.forEach(Q=>Y[Q.id]=Q),H.current=Y,D(Y)},[D]),X=K.useCallback(async k=>{I.current=k||aX({...m,type:i,graph:x,drags:H.current,clusters:z?.current,clusterAttribute:r}),await ZW(I.current);const Y=xW({graph:x,layout:I.current,sizingType:e,labelType:t,sizingAttribute:n,maxNodeSize:d,minNodeSize:p,defaultNodeSize:h,clusterAttribute:r}),Q=fW({nodes:Y.nodes,clusterAttribute:r});v&&Q.forEach(te=>{z.current.get(te.label)?.nodes.length===te.nodes.length&&(te.position=z.current?.get(te.label)?.position??te.position)}),S(Y.edges),T(Y.nodes),b(Q),r&&G(Y.nodes)},[m,i,r,e,t,n,d,p,h,S,T,b]);return K.useEffect(()=>{H.current=A},[A,r,X]),K.useEffect(()=>{z.current=_},[_]),K.useEffect(()=>{const k=w.map(Q=>({...Q,labelVisible:wD({nodeCount:w?.length,labelType:t,camera:V,nodePosition:Q?.position})("node",Q?.size)}));k.some((Q,te)=>Q.labelVisible!==w[te].labelVisible)&&T(k)},[V,V.zoom,V.position.z,T,w,t]),K.useEffect(()=>{P.current&&R(s)},[s,R]),K.useEffect(()=>{P.current&&U(l)},[l,U]),K.useEffect(()=>{async function k(){P.current=!1,_W(x,B,O),await X(),requestAnimationFrame(()=>P.current=!0)}k()},[B,O]),K.useEffect(()=>{P.current&&L(c)},[c,L]),K.useEffect(()=>{P.current&&(H.current={},D({}),X())},[i,X,D]),K.useEffect(()=>{P.current&&X(I.current)},[e,n,t,X]),{updateLayout:X}},lX=i=>i.reduceEdges((e,t,n,r,s)=>{const a=`${r}-${s}`,o={id:t,source:r,target:s,...n},l=e.get(a);return l?l.push(o):e.set(a,[o]),e},new Map),cX=(i,e)=>{if(!i||i.size===0)return[];const t=lX(i),n=[],r=e==="all"||e==="edges";for(const[s,a]of t){const[o,l]=s.split("-"),c=a[0];if(!o||!l||!c)continue;const h=c.size||1,d=h+a.length*h*.5,p=a.length>1,m=p?`${a.length} edges`:c.label,v={...c,source:o,target:l,label:m,labelVisible:r,size:d,data:{...c.data||{},originalEdges:a,count:a.length,isAggregated:p,originalSize:h}};n.push(v)}return n},uX=K.forwardRef(({onNodeClick:i,onNodeDoubleClick:e,onNodeContextMenu:t,onEdgeContextMenu:n,onEdgeClick:r,onEdgePointerOver:s,onEdgePointerOut:a,onNodePointerOver:o,onNodePointerOut:l,onClusterClick:c,onNodeDragged:h,onClusterDragged:d,onClusterPointerOver:p,onClusterPointerOut:m,contextMenu:v,animated:x,disabled:_,draggable:g,constrainDragging:b=!1,edgeLabelPosition:E,edgeArrowPosition:S,edgeInterpolation:w="linear",labelFontUrl:T,renderNode:R,onRenderCluster:U,aggregateEdges:A,...D},L)=>{const{layoutType:P,clusterAttribute:I,labelType:V}=D,H=Jn(fe=>fe.gl),z=Jn(fe=>fe.scene),O=Jn(fe=>fe.camera),{updateLayout:B}=oX({...D,constrainDragging:b});if(I&&!(P==="forceDirected2d"||P==="forceDirected3d"))throw new Error("Clustering is only supported for the force directed layouts.");const G=tt(fe=>fe.graph),X=tt(fe=>fe.nodes),k=tt(fe=>fe.edges),Y=tt(fe=>fe.setEdges),Q=tt(fe=>[...fe.clusters.values()]),te=K.useMemo(()=>A?cX(G,V):k,[k,A,G,V]);K.useEffect(()=>{A&&k.length!==te.length&&Y(te)},[te,k.length,Y,A]);const{centerNodesById:ee,fitNodesInViewById:ie,isCentered:re}=DW({animated:x,disabled:_,layoutType:P});K.useImperativeHandle(L,()=>({centerGraph:ee,fitNodesInView:ie,graph:G,renderScene:()=>H.render(z,O)}),[ee,ie,G,H,z,O]);const de=K.useCallback(fe=>{h?.(fe),I&&B()},[I,h,B]),Ae=K.useMemo(()=>X.map(fe=>he.jsx(YW,{id:fe?.id,labelFontUrl:T,draggable:g,constrainDragging:b,disabled:_,animated:x,contextMenu:v,renderNode:R,onClick:i,onDoubleClick:e,onContextMenu:t,onPointerOver:o,onPointerOut:l,onDragged:de},fe?.id)),[b,x,v,_,g,T,X,i,t,e,de,l,o,R]),Me=K.useMemo(()=>x?te.map(fe=>he.jsx(FW,{id:fe.id,disabled:_,animated:x,labelFontUrl:T,labelPlacement:E,arrowPlacement:S,interpolation:w,contextMenu:v,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a},fe.id)):he.jsx(WW,{edges:te,disabled:_,animated:x,labelFontUrl:T,labelPlacement:E,arrowPlacement:S,interpolation:w,contextMenu:v,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a}),[x,v,_,S,w,E,te,T,r,n,a,s]),ve=K.useMemo(()=>Q.map(fe=>he.jsx(LW,{animated:x,disabled:_,draggable:g,labelFontUrl:T,onClick:c,onPointerOver:p,onPointerOut:m,onDragged:d,onRender:U,...fe},fe.label)),[x,Q,_,g,T,c,m,p,d,U]);return re&&he.jsxs(K.Fragment,{children:[Me,Ae,ve]})});function G_(i,e,t){e=Array.isArray(e)?e:[e];const n=[],r=[];for(const s of e){const a=[...i.inEdgeEntries(s)??[],...i.outEdgeEntries(s)??[]];if(a)for(const o of a){const l=o.attributes.id;if(t==="in"?o.target===s&&!r.includes(l)&&r.push(l):t==="out"?o.source===s&&!r.includes(l)&&r.push(l):r.includes(l)||r.push(l),t==="out"||t==="all"){const c=o.target;n.includes(c)||n.push(c)}(t==="in"||t==="all")&&(n.includes(o.source)||n.push(o.source))}}return{nodes:n,edges:r}}function nm(i,e,t){const{offsetX:n,offsetY:r}=i,{width:s,height:a}=t;e.set(n/s*2-1,-(r/a)*2+1)}function hX(i){const e=document.createElement("div");return e.style.pointerEvents="none",e.style.border=i.lasso.border,e.style.backgroundColor=i.lasso.background,e.style.position="fixed",e}const fX=({children:i,type:e="none",onLasso:t,onLassoEnd:n,disabled:r})=>{const s=tt(L=>L.theme),a=Jn(L=>L.camera),o=Jn(L=>L.gl),l=Jn(L=>L.setEvents),c=Jn(L=>L.size),h=Jn(L=>L.get),d=Jn(L=>L.scene),p=w0(),m=tt(L=>L.actives),v=tt(L=>L.setActives),x=tt(L=>L.edges),_=tt(L=>L.edgeMeshes),g=K.useRef(null),b=K.useRef(null),E=K.useRef(hX(s)),S=K.useRef(null),w=K.useRef(!1),T=K.useRef(h().events.enabled),R=K.useRef(p.controls?.enabled),U=K.useCallback(L=>{if(w.current){const[P,I,V]=S.current;V.x=Math.max(P.x,L.clientX),V.y=Math.max(P.y,L.clientY),I.x=Math.min(P.x,L.clientX),I.y=Math.min(P.y,L.clientY),E.current.style.left=`${I.x}px`,E.current.style.top=`${I.y}px`,E.current.style.width=`${V.x-I.x}px`,E.current.style.height=`${V.y-I.y}px`,nm(L,g.current.endPoint,c),nm(L,b.current.endPoint,c);const H=[],z=b.current.select().sort(B=>B.uuid).filter(B=>B.geometry?.userData?.type===e||e==="all").map(B=>x[_.indexOf(B)].id);H.push(...z);const O=g.current.select().sort(B=>B.uuid).filter(B=>B.isMesh&&B.userData?.id&&(B.userData?.type===e||e==="all")).map(B=>B.userData.id);H.push(...O),requestAnimationFrame(()=>{v(H),t?.(H)}),document.addEventListener("pointermove",U,{passive:!0,capture:!0,once:!0})}},[c,x,_,e,v,t]),A=K.useCallback(()=>{w.current&&(l({enabled:T.current}),w.current=!1,E.current.parentElement?.removeChild(E.current),p.controls.enabled=R.current,n?.(m),document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",A))},[l,p.controls,n,m,U]),D=K.useCallback(L=>{if(L.shiftKey){T.current=h().events.enabled,R.current=p.controls?.enabled,g.current=new rw(a,d);const P=new Gg;_.length&&P.add(..._),b.current=new rw(a,P),S.current=[new ke,new ke,new ke];const[I]=S.current;p.controls.enabled=!1,l({enabled:!1}),w.current=!0,o.domElement.parentElement?.appendChild(E.current),E.current.style.left=`${L.clientX}px`,E.current.style.top=`${L.clientY}px`,E.current.style.width="0px",E.current.style.height="0px",I.x=L.clientX,I.y=L.clientY,nm(L,g.current.startPoint,c),nm(L,b.current.startPoint,c),document.addEventListener("pointermove",U,{passive:!0,capture:!0,once:!0}),document.addEventListener("pointerup",A,{passive:!0})}},[a,p.controls,_,h,o.domElement.parentElement,U,A,d,l,c]);return K.useEffect(()=>{if(!(r||e==="none"))return typeof window<"u"&&(document.addEventListener("pointerdown",D,{passive:!0}),document.addEventListener("pointermove",U,{passive:!0}),document.addEventListener("pointerup",A,{passive:!0})),()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",D),document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",A))}},[e,r,D,U,A]),he.jsx("group",{children:i})},FD={canvas:{background:"#fff"},node:{fill:"#7CA0AB",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{color:"#2A6475",stroke:"#fff",activeColor:"#1DE9AC"},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#D8E6EA",activeFill:"#1DE9AC"},edge:{fill:"#D8E6EA",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475",activeColor:"#1DE9AC",fontSize:6},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},arrow:{fill:"#D8E6EA",activeFill:"#1DE9AC"},cluster:{stroke:"#D8E6EA",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475"}}},dX="_canvas_670zp_1",pX={canvas:dX},mX={alpha:!0,antialias:!0},gX={position:[0,0,1e3],near:5,far:5e4,fov:10},vX=K.forwardRef(({cameraMode:i="pan",layoutType:e="forceDirected2d",sizingType:t="default",labelType:n="auto",theme:r=FD,animated:s=!0,defaultNodeSize:a=7,minNodeSize:o=5,maxNodeSize:l=15,lassoType:c="none",glOptions:h={},edges:d,children:p,nodes:m,minDistance:v,maxDistance:x,minZoom:_,maxZoom:g,onCanvasClick:b,disabled:E,onLasso:S,onLassoEnd:w,aggregateEdges:T,...R},U)=>{const A=K.useRef(null),D=K.useRef(null),L=K.useRef(null);K.useImperativeHandle(U,()=>({centerGraph:(B,G)=>A.current?.centerGraph(B,G),fitNodesInView:(B,G)=>A.current?.fitNodesInView(B,G),zoomIn:()=>{const B=D.current?.controls;if(!B)return;const G=B.distance,X=B.camera.zoom,k=X+X/2,Y=G/k;(!v||Y>=v)&&D.current?.zoomIn()},zoomOut:()=>{const B=D.current?.controls;if(!B)return;const G=B.distance,X=B.camera.zoom,k=X-X/2,Y=G/k;(!x||Y<=x)&&D.current?.zoomOut()},dollyIn:B=>D.current?.dollyIn(B),dollyOut:B=>D.current?.dollyOut(B),panLeft:()=>D.current?.panLeft(),panRight:()=>D.current?.panRight(),panDown:()=>D.current?.panDown(),panUp:()=>D.current?.panUp(),resetControls:B=>D.current?.resetControls(B),getControls:()=>D.current?.controls,getGraph:()=>A.current?.graph,exportCanvas:()=>(A.current.renderScene(),L.current.toDataURL()),freeze:()=>D.current?.freeze(),unFreeze:()=>D.current?.unFreeze()}));const{selections:P,actives:I,collapsedNodeIds:V}=R,H=d.length+m.length>400?!1:s,z=K.useMemo(()=>({...h,...mX}),[h]),O=K.useRef(RD({selections:P,actives:I,theme:r,collapsedNodeIds:V})).current;return K.useEffect(()=>{O.getState().setTheme(r)},[r,O]),he.jsx("div",{className:pX.canvas,children:he.jsx(L5,{orthographic:i==="orthographic",legacy:!0,linear:!0,ref:L,flat:!0,gl:z,camera:gX,onPointerMissed:b,children:he.jsxs(wW,{store:O,children:[r.canvas?.background&&he.jsx("color",{attach:"background",args:[r.canvas.background]}),he.jsx("ambientLight",{intensity:1}),p,r.canvas?.fog&&he.jsx("fog",{attach:"fog",args:[r.canvas.fog,4e3,9e3]}),he.jsx(TW,{mode:i,ref:D,disabled:E,minDistance:v,maxDistance:x,minZoom:_,maxZoom:g,animated:s,children:he.jsx(fX,{disabled:E,type:c,onLasso:S,onLassoEnd:w,children:he.jsx(K.Suspense,{children:he.jsx(uX,{ref:A,disabled:E,animated:H,edges:d,nodes:m,layoutType:e,sizingType:t,labelType:n,defaultNodeSize:a,minNodeSize:o,maxNodeSize:l,aggregateEdges:T,...R})})})})]})})})}),yX=({selections:i=[],nodes:e=[],actives:t=[],focusOnSelect:n=!0,type:r="single",pathHoverType:s="out",pathSelectionType:a="direct",ref:o,disabled:l,onSelection:c})=>{const[h,d]=K.useState([]),[p,m]=K.useState(t),[v,x]=K.useState(i),[_,g]=K.useState(!1),b=r==="multi"||r==="multiModifier",E=K.useCallback(O=>{if(!l&&O){O=Array.isArray(O)?O:[O];const B=O.filter(G=>!v.includes(G));if(B.length){const G=[...v,...B];c?.(G),x(G)}}},[l,v,c]),S=K.useCallback(O=>{if(!l&&O){O=Array.isArray(O)?O:[O];const B=v.filter(G=>!O.includes(G));c?.(B),x(B)}},[l,v,c]),w=K.useCallback((O=[])=>{l||(O=Array.isArray(O)?O:[O],m([]),x(O),c?.(O))},[l,c]),T=K.useCallback(O=>{v.includes(O)?S(O):b?E(O):w(O)},[E,w,v,b,S]),R=K.useCallback(O=>{if(b?r==="multiModifier"?_?E(O.id):w(O.id):E(O.id):w(O.id),n===!0||n==="singleOnly"&&!_){if(!o.current)throw new Error("No ref found for the graph canvas.");const B=o.current.getGraph(),{nodes:G}=G_(B,[O.id],a);o.current.fitNodesInView([O.id,...G],{fitOnlyIfNodesNotInView:!0})}},[E,w,n,b,_,a,o,r]),U=K.useCallback((O,B)=>{const G=o.current.getGraph();if(!G)throw new Error("Graph is not initialized");const X=bW(G,O,B);w([O,B]);const k=[];for(let Y=0;Y<X.length-1;Y++){const Q=X[Y],te=X[Y+1],ee=G.getEdgeAttributes(Q,te);ee&&k.push(ee.id)}m([...X.map(Y=>Y),...k])},[w,o]),A=K.useCallback(O=>{const B=O.target,G=rA(B),X=O.metaKey||O.ctrlKey;G&&X&&g(!0)},[]),D=K.useCallback(O=>{const B=O.target,G=rA(B),X=["Meta","Control"].includes(O.key);G&&X&&g(!1)},[]);K.useEffect(()=>(typeof window<"u"&&(window.addEventListener("keydown",A),window.addEventListener("keyup",D)),()=>{typeof window<"u"&&(window.removeEventListener("keydown",A),window.removeEventListener("keyup",D))}),[A,D]);const L=K.useCallback(O=>{if(O.button!==2&&(v.length||p.length)&&(w(),g(!1),n&&v.length===1)){if(!o.current)throw new Error("No ref found for the graph canvas.");o.current.fitNodesInView([],{fitOnlyIfNodesNotInView:!0})}},[w,n,p.length,v.length,o]),P=K.useCallback(O=>{m(O)},[]),I=K.useCallback(O=>{w(O)},[w]),V=K.useCallback(O=>{if(s){const B=o.current.getGraph();if(!B)throw new Error("No ref found for the graph canvas.");const{nodes:G,edges:X}=G_(B,[O.id],s);d([...G,...X])}},[s,o]),H=K.useCallback(()=>{s&&d([])},[s]);return K.useEffect(()=>{if(a!=="direct"&&v.length>0){const O=o.current?.getGraph();if(O){const{nodes:B,edges:G}=G_(O,v,a);m([...B,...G])}}},[v,a,o]),{actives:K.useMemo(()=>[...p,...h],[p,h]),onNodeClick:R,onNodePointerOver:V,onNodePointerOut:H,onLasso:P,onLassoEnd:I,selectNodePaths:U,onCanvasClick:L,selections:v,clearSelections:w,addSelection:E,removeSelection:S,toggleSelection:T,setSelections:x}},_X=""+new URL("NotoSans-Regular-D96CXwz4.ttf",import.meta.url).href,xX=K.memo(({data:i,onCollapse:e,isCollapsed:t,canCollapse:n,onClose:r})=>{const{t:s}=wg(["network","zigbee","common"]);let a;if(i.parent){const o=i.parent.lastIndexOf(` - ${s(l=>l.children)}`);a=o>-1?i.parent.slice(0,o):i.parent}return he.jsx("div",{className:"card bg-base-100 shadow-sm",children:he.jsxs("div",{className:"card-body",children:[he.jsx("h2",{className:"card-title",children:i.friendlyName}),he.jsx("span",{children:i.type}),he.jsx("span",{title:s(o=>o.ieee_address,{ns:"zigbee"}),children:i.ieeeAddr}),he.jsxs("span",{title:s(o=>o.network_address_hex,{ns:"zigbee"}),className:"justify-self-end",children:[GU(i.networkAddress,4)," | ",he.jsx("span",{title:s(o=>o.network_address_dec,{ns:"zigbee"}),children:i.networkAddress})]}),a&&he.jsxs("span",{children:[s(o=>o.parent),": ",a]}),i.failed&&i.failed.length>0&&he.jsxs("div",{className:"badge badge-ghost",children:[he.jsx(Yn,{icon:HU,className:"text-error",beatFade:!0}),s(o=>o.failed,{ns:"common"}),": ",i.failed]}),he.jsxs("div",{className:"card-actions justify-end mt-2",children:[n&&he.jsx(Lr,{className:"btn btn-square btn-primary",onClick:e,children:he.jsx(Yn,{icon:t?VU:WU})}),he.jsx(Lr,{className:"btn btn-square btn-neutral",onClick:r,children:he.jsx(Yn,{icon:XU})})]})]})})}),mA=K.memo(i=>{const{label:e,icon:t,onChange:n,onSubmit:r,defaultValue:s,...a}=i,[o,l]=K.useState(s);K.useEffect(()=>{l(s)},[s]);const c=K.useCallback(d=>{l(d.target.value?d.target.valueAsNumber:""),n?.(d)},[n]),h=K.useCallback(d=>{r?.(o,!d.target.validationMessage)},[r,o]);return he.jsxs("div",{className:"flex flex-row flex-wrap items-center gap-2 bg-base-100 rounded-box px-2 pb-1",title:e,children:[he.jsx(Yn,{icon:t}),he.jsxs("div",{children:[he.jsx("input",{className:"range range-xs",onChange:c,onTouchEnd:h,onMouseUp:h,onKeyUp:h,...a,type:"range",value:o}),he.jsxs("div",{className:"flex justify-between px-1 mt-1 text-xs",children:[he.jsx("span",{children:i.min}),he.jsx("span",{children:o}),he.jsx("span",{children:i.max})]})]})]})}),bX=K.memo(({graphRef:i,config:e,setConfig:t,nodes:n,showParents:r,setShowParents:s,showChildren:a,setShowChildren:o,showSiblings:l,setShowSiblings:c})=>{const{t:h}=wg(["network","common"]),d=K.useMemo(()=>{const v=n.map(x=>[x.id,x.data.type!=="Coordinator"?`${x.data.type[0]} - ${x.label}`:x.label]);return v.sort(([,x],[,_])=>x.localeCompare(_)),v.map(([x,_])=>he.jsx("option",{value:x,children:_},x))},[n]),p=K.useCallback(()=>{i.current&&jU(i.current.exportCanvas(),`network-map-${Date.now()}.png`)},[i]),m=K.useCallback(v=>{if(v.target.value){const x=[v.target.value];i.current?.centerGraph(x),i.current?.fitNodesInView(x)}},[i]);return he.jsxs(he.Fragment,{children:[he.jsxs("div",{className:"absolute z-9 top-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-start max-w-[calc(100vw-19rem)] md:max-w-none",children:[he.jsx(Lr,{title:h(v=>v.download_image),className:"btn btn-square btn-neutral btn-sm tooltip-right",onClick:p,children:he.jsx(Yn,{icon:qU})}),he.jsx(Lr,{title:h(v=>v.reset_controls),className:"btn btn-square btn-neutral btn-sm tooltip-right",onClick:()=>{i.current?.resetControls()},children:he.jsx(Yn,{icon:YU})}),he.jsx(Lr,{title:h(v=>v.fit_view),className:"btn btn-square btn-neutral btn-sm tooltip-bottom",onClick:()=>{i.current?.centerGraph(),i.current?.fitNodesInView()},children:he.jsx(Yn,{icon:ZU})}),he.jsx(Lr,{title:h(v=>v.zoom_in),className:"btn btn-square btn-neutral btn-sm tooltip-bottom",onClick:()=>{i.current?.zoomIn()},children:he.jsx(Yn,{icon:KU})}),he.jsx(Lr,{title:h(v=>v.zoom_out),className:"btn btn-square btn-neutral btn-sm tooltip-bottom",onClick:()=>{i.current?.zoomOut()},children:he.jsx(Yn,{icon:JU})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${r?"":"btn-outline"}`,item:!r,onClick:s,title:h(v=>v.parent),children:he.jsx(Yn,{icon:iu,style:{color:_l[hi.NeighborIsParent]}})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${a?"":"btn-outline"}`,item:!a,onClick:o,title:h(v=>v.child),children:he.jsx(Yn,{icon:iu,style:{color:_l[hi.NeighborIsAChild]}})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${l?"":"btn-outline"}`,item:!l,onClick:c,title:h(v=>v.sibling),children:he.jsx(Yn,{icon:iu,style:{color:_l[hi.NeighborIsASibling]}})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${e.showIcons?"":"btn-outline"}`,item:!e.showIcons,onClick:v=>t(x=>({...x,showIcons:v})),title:h(v=>v.icons),children:he.jsx(Yn,{icon:QU})}),he.jsxs("select",{className:"select select-sm w-36",defaultValue:"",onChange:m,children:[he.jsx("option",{value:"",children:h(v=>v.find_node)}),d]})]}),he.jsxs("div",{className:"absolute z-9 top-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-start justify-end",children:[he.jsxs("select",{className:"select select-sm w-36",value:e.layoutType,onChange:v=>v.target.value&&t(x=>({...x,layoutType:v.target.value})),children:[he.jsx("option",{value:"",disabled:!0,children:h(v=>v.layout_type)}),he.jsx("option",{value:"forceDirected2d",children:"forceDirected2d"}),he.jsx("option",{value:"forceDirected3d",children:"forceDirected3d"}),he.jsx("option",{value:"radialOut2d",children:"radialOut2d"}),he.jsx("option",{value:"radialOut3d",children:"radialOut3d"}),he.jsx("option",{value:"concentric2d",children:"concentric2d"}),he.jsx("option",{value:"concentric3d",children:"concentric3d"}),he.jsx("option",{value:"circular2d",children:"circular2d"})]}),he.jsxs("select",{className:"select select-sm w-36",value:e.labelType,onChange:v=>v.target.value&&t(x=>({...x,labelType:v.target.value})),children:[he.jsx("option",{value:"",disabled:!0,children:h(v=>v.label_type)}),he.jsx("option",{value:"all",children:"all"}),he.jsx("option",{value:"auto",children:"auto"}),he.jsx("option",{value:"none",children:"none"}),he.jsx("option",{value:"nodes",children:"nodes"}),he.jsx("option",{value:"edges",children:"edges"})]})]}),he.jsxs("div",{className:"absolute z-9 bottom-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-end",children:[he.jsx(mA,{name:"node_strength",label:h(v=>v.node_strength),icon:$U,onSubmit:(v,x)=>x&&typeof v=="number"&&t(_=>({..._,nodeStrength:v})),min:-1e3,max:-100,step:10,defaultValue:e.nodeStrength}),he.jsx(mA,{name:"link_distance",label:h(v=>v.link_distance),icon:eO,onSubmit:(v,x)=>x&&typeof v=="number"&&t(_=>({..._,linkDistance:v})),min:10,max:200,step:5,defaultValue:e.linkDistance})]}),he.jsx("div",{className:"absolute z-9 bottom-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-end justify-end",children:he.jsx(Lr,{title:h(v=>v.scroll_to_top,{ns:"common"}),className:"btn btn-primary btn-square ml-auto tooltip-left",onClick:()=>{window.scrollTo(0,0)},children:he.jsx(Yn,{icon:tO})})})]})}),SX=K.memo(()=>{const{t:i}=wg("network");return he.jsxs("details",{className:"collapse collapse-arrow rounded-b-none",children:[he.jsx("summary",{className:"collapse-title font-semibold",children:i(e=>e.legend)}),he.jsxs("div",{className:"collapse-content text-sm",children:[he.jsxs("div",{className:"flex flex-row flex-wrap gap-3 mb-2",children:[he.jsxs("div",{children:[he.jsxs("p",{children:[i(e=>e.nodes),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:im.Coordinator},children:[he.jsx(Yn,{icon:kv})," Coordinator"]}),he.jsxs("li",{style:{color:im.Router},children:[he.jsx(Yn,{icon:kv})," Router"]}),he.jsxs("li",{style:{color:im.EndDevice},children:[he.jsx(Yn,{icon:kv})," EndDevice"]})]})]}),he.jsxs("div",{children:[he.jsxs("p",{children:[i(e=>e.edges),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:_l[hi.NeighborIsParent]},children:[he.jsx(Yn,{icon:iu})," ",i(e=>e.parent)]}),he.jsxs("li",{style:{color:_l[hi.NeighborIsAChild]},children:[he.jsx(Yn,{icon:iu})," ",i(e=>e.child)]}),he.jsxs("li",{style:{color:_l[hi.NeighborIsASibling]},children:[he.jsx(Yn,{icon:iu})," ",i(e=>e.sibling)]})]})]})]}),he.jsx("p",{children:i(e=>e.legend_node_siblings)}),he.jsx("p",{children:i(e=>e.legend_node_size)}),he.jsx("p",{children:i(e=>e.legend_node_select)}),he.jsx("p",{children:i(e=>e.legend_node_fold)}),he.jsx("p",{children:i(e=>e.legend_edge_toggle)})]})]})}),GX=K.memo(({sourceIdx:i,map:e})=>{const{t}=wg("network"),n=nO(vA(S=>S.devices[i])),[r,s]=K.useState(qS.get(YS,{layoutType:"forceDirected2d",labelType:"all",nodeStrength:-750,linkDistance:50,showIcons:!1})),[a,o]=K.useState(!0),[l,c]=K.useState(!0),[h,d]=K.useState(!0),p=K.useRef(null);K.useEffect(()=>{qS.set(YS,r)},[r]),K.useEffect(()=>{p.current&&(p.current.resetControls(),p.current.centerGraph(),p.current.fitNodesInView())},[r.layoutType]);const m=K.useMemo(()=>{const S=new OffscreenCanvas(1,1).getContext("2d"),w=getComputedStyle(document.documentElement),T=fh(S,w.getPropertyValue("--color-base-100")),R=fh(S,w.getPropertyValue("--color-base-200")),U=fh(S,w.getPropertyValue("--color-base-content")),A=fh(S,w.getPropertyValue("--color-primary")),D=fh(S,w.getPropertyValue("--color-accent"));return iO({},FD,{canvas:{background:T},node:{activeFill:D,label:{color:U,stroke:R,activeColor:D},subLabel:{color:U,stroke:"transparent",activeColor:D}},lasso:{border:`1px solid ${A}`,background:"rgba(75, 160, 255, 0.1)"},ring:{fill:U,activeFill:D},edge:{fill:U,activeFill:D,label:{stroke:R,color:U,activeColor:D},subLabel:{color:U,stroke:"transparent",activeColor:D}},arrow:{fill:U,activeFill:D},cluster:{stroke:U,label:{stroke:R,color:U}}})},[]),[v,x]=K.useMemo(()=>{const S=[],w=[],T=[];for(const A of e.nodes){const D=n.find(V=>V.ieee_address===A.ieeeAddr),L=e.links.find(V=>V.relationship===hi.NeighborIsParent&&V.target.ieeeAddr===A.ieeeAddr);let P=L?e.nodes.find(V=>V.ieeeAddr===L.source.ieeeAddr)?.friendlyName:void 0;if(!L){const V=e.links.find(H=>H.relationship===hi.NeighborIsAChild&&H.source.ieeeAddr===A.ieeeAddr);P=V?e.nodes.find(H=>H.ieeeAddr===V.target.ieeeAddr)?.friendlyName:void 0,P&&(P+=` - ${t(H=>H.children)}`)}let I;r.showIcons&&D&&(I=D.definition?.icon??rO(D),I===sO&&(I=void 0)),S.push({id:A.ieeeAddr,data:{...A,parent:P},label:A.friendlyName,labelVisible:!0,fill:im[A.type],icon:I})}const R=new Map;for(const A of e.links){if(!a&&A.relationship===hi.NeighborIsParent||!l&&A.relationship===hi.NeighborIsAChild||!h&&A.relationship===hi.NeighborIsASibling)continue;if(A.relationship===hi.NeighborIsASibling){const L=R.get(A.source.ieeeAddr);(!L||A.depth<L.depth||A.lqi>L.lqi||L.lqi===A.lqi&&A.depth<L.depth)&&R.set(A.source.ieeeAddr,A);continue}const D=e.links.find(L=>L.source.ieeeAddr===A.target.ieeeAddr&&L.target.ieeeAddr===A.source.ieeeAddr);A.relationship===hi.NeighborIsAChild&&D?.relationship===hi.NeighborIsParent||T.push([A,D])}for(const[,A]of R){const D=e.links.find(L=>L.source.ieeeAddr===A.target.ieeeAddr&&L.target.ieeeAddr===A.source.ieeeAddr);T.push([A,D])}const U=[];for(const[A,D]of T)U.includes(A)||A.relationship===hi.NeighborIsASibling&&(D?.relationship===hi.NeighborIsParent||D?.relationship===hi.NeighborIsAChild)||w.push({id:`${A.source.ieeeAddr}-${A.target.ieeeAddr}-${A.relationship}`,data:A,label:D?`${A.lqi} / ${D.lqi??"?"}`:`${A.lqi}`,size:A.relationship===hi.NoneOfTheAbove?.5:1,labelVisible:!0,source:A.source.ieeeAddr,target:A.target.ieeeAddr,fill:_l[A.relationship]});return[S,w]},[e,a,l,h,t,n,r.showIcons]),{selections:_,actives:g,onNodeClick:b,onCanvasClick:E}=yX({ref:p,nodes:v,type:"single",pathSelectionType:"out",focusOnSelect:!1});return he.jsxs(he.Fragment,{children:[he.jsx(SX,{}),he.jsxs("div",{className:"relative h-screen",children:[he.jsx(bX,{graphRef:p,config:r,setConfig:s,nodes:v,showParents:a,setShowParents:o,showChildren:l,setShowChildren:c,showSiblings:h,setShowSiblings:d}),he.jsx(vX,{ref:p,theme:m,nodes:v,edges:x,clusterAttribute:r.layoutType.startsWith("forceDirected")?"parent":void 0,selections:_,actives:g,onCanvasClick:E,onNodeClick:b,layoutType:r.layoutType,layoutOverrides:{nodeStrength:r.nodeStrength,linkDistance:r.linkDistance},sizingType:"centrality",labelType:r.labelType,labelFontUrl:_X,edgeLabelPosition:"natural",lassoType:"node",cameraMode:r.layoutType.endsWith("3d")?"rotate":"pan",draggable:!0,animated:!1,contextMenu:({data:{data:S},onCollapse:w,isCollapsed:T,canCollapse:R,onClose:U})=>S.friendlyName?he.jsx(xX,{data:S,onCollapse:w,isCollapsed:T,canCollapse:R,onClose:U}):null})]})]})});export{GX as default};
4187
+ `,zW=({curveOffset:i,animated:e,color:t="#000",curve:n,curved:r=!1,dashed:s=!1,dashArray:a=[3,1],id:o,opacity:l=1,size:c=1,renderOrder:h=-1,onContextMenu:d,onClick:p,onPointerOver:m,onPointerOut:v})=>{const x=K.useRef(null),_=tt(T=>T.draggingIds.length>0),g=K.useMemo(()=>new Ye(t),[t]),b=tt(T=>T.centerPosition),E=K.useRef(!1),S=K.useMemo(()=>{if(!s)return null;const[T,R]=a;return new Hr({uniforms:{color:{value:g},opacity:{value:l},dashSize:{value:T},gapSize:{value:R},lineLength:{value:n.getLength()}},vertexShader:NW,fragmentShader:PW,transparent:!0,depthTest:!1})},[s,g,l,n,a]),{lineOpacity:w}=er({from:{lineOpacity:0},to:{lineOpacity:l},config:{...tr,duration:e?void 0:0}});return er(()=>{const T=n.getPoint(0),R=n.getPoint(1);return{from:{fromVertices:E.current?[R?.x,R?.y,R?.z||0]:[b?.x,b?.y,b?.z||0],toVertices:[T?.x,T?.y,T?.z||0]},to:{fromVertices:[T?.x,T?.y,T?.z||0],toVertices:[R?.x,R?.y,R?.z||0]},onChange:U=>{const{fromVertices:A,toVertices:D}=U.value,L=new j(...A),P=new j(...D),I=Zf(L,0,P,0,r,i);if(x.current){const V=s?c*.4:c/2;x.current.copy(new fo(I,20,V,5,!1))}},config:{...tr,duration:e&&!_?void 0:0}}},[e,_,n,c,s,r,i]),K.useEffect(()=>{E.current=!0},[]),he.jsxs("mesh",{userData:{id:o,type:"edge"},renderOrder:h,onPointerOver:m,onPointerOut:v,onClick:p,onPointerDown:T=>{T.nativeEvent.buttons===2&&T.stopPropagation()},onContextMenu:T=>{T.nativeEvent.preventDefault(),T.stopPropagation(),d()},children:[he.jsx("tubeGeometry",{attach:"geometry",ref:x}),s?he.jsx("primitive",{attach:"material",object:S}):he.jsx(An.meshBasicMaterial,{attach:"material",opacity:w,fog:!0,transparent:!0,color:g})]})},uA=3,FW=({animated:i,arrowPlacement:e="end",contextMenu:t,disabled:n,labelPlacement:r="inline",id:s,interpolation:a,labelFontUrl:o,onContextMenu:l,onClick:c,onPointerOver:h,onPointerOut:d,subLabelPlacement:p="below"})=>{const m=tt(F=>F.theme),v=tt(F=>F.draggingIds.length>0),[x,_]=K.useState(!1),[g,b]=K.useState(!1),E=tt(F=>F.edges),S=E.find(F=>F.id===s),{target:w,source:T,label:R,subLabel:U,labelVisible:A=!1,size:D=1,fill:L,dashed:P=!1,dashArray:I=[3,1]}=S,V=S.subLabelPlacement||p,H=tt(F=>F.nodes.find(ne=>ne.id===T)),z=tt(F=>F.nodes.find(ne=>ne.id===w)),O=H.id===z.id,B=(D+m.edge.label.fontSize)/2,[G,X]=K.useMemo(()=>MD(D),[D]),k=S.interpolation||a,Y=S.arrowPlacement||e,{curveOffset:Q,curved:te}=K.useMemo(()=>EW({edge:S,edges:E,curved:k==="curved"}),[S,E,k]),[ee,ie,re]=K.useMemo(()=>{const F=Eu(H),ne=H.size,Se=Eu(z),_e=z.size;let me=Zf(F,ne,Se,_e,te,Q);const[ze,Ne]=ED(Y,me,G);return Y==="end"&&(me=Zf(F,ne,ze,0,te,Q)),[me,ze,Ne]},[H,z,te,Q,Y,G]),de=K.useMemo(()=>{let F=AD(H.position,z.position,TD(B,r));if(te){const ne=new j().subVectors(F,ee.getPoint(.5));switch(r){case"above":ne.y=ne.y-uA;break;case"below":ne.y=ne.y+uA;break}F=F.sub(ne)}return F},[H.position,z.position,B,r,te,ee]),Ae=tt(F=>F.centerPosition),Me=tt(F=>F.selections?.includes(s)),ve=tt(F=>F.selections?.length),fe=tt(F=>F.actives?.includes(s)),J=x||fe||Me,oe=ve?Me||fe?m.edge.selectedOpacity:m.edge.inactiveOpacity:m.edge.opacity,se=K.useMemo(()=>MW(H.position,z.position,V),[H.position,z.position,V]),[{labelPosition:$}]=er(()=>({from:{labelPosition:Ae?[Ae.x,Ae.y,Ae.z]:[0,0,0]},to:{labelPosition:[de.x,de.y,de.z]},config:{...tr,duration:i&&!v?void 0:0}}),[de,i,v]),pe=K.useMemo(()=>new Bi(0,0,r==="natural"?0:Math.atan((z.position.y-H.position.y)/(z.position.x-H.position.x))),[z.position.x,z.position.y,H.position.x,H.position.y,r]);El(x&&!v&&c!==void 0,"pointer");const{pointerOver:ye,pointerOut:xe}=hb({disabled:n,onPointerOver:F=>{_(!0),h?.(S,F)},onPointerOut:F=>{_(!1),d?.(S,F)}}),be=K.useMemo(()=>CD(H),[H]),ue=K.useMemo(()=>{if(Y==="none")return null;let F,ne;return O&&be?Y==="mid"?(F=be.getPointAt(.25),ne=be.getTangentAt(.25)):(F=be.getPointAt(.58),ne=be.getTangentAt(.58)):(F=ie,ne=re),he.jsx(UW,{animated:i,color:J?m.arrow.activeFill:L||m.arrow.fill,length:G,opacity:oe,position:F,rotation:ne,size:X,onActive:_,onContextMenu:()=>{n||(b(!0),l?.(S))}})},[L,i,G,Y,ie,re,X,n,S,J,l,oe,m.arrow.activeFill,m.arrow.fill,O,be]),He=K.useMemo(()=>A&&R&&he.jsxs(An.group,{position:$,onContextMenu:()=>{n||(b(!0),l?.(S))},onPointerOver:ye,onPointerOut:xe,children:[he.jsx(Mu,{text:R,ellipsis:15,fontUrl:o,stroke:m.edge.label.stroke,color:J?m.edge.label.activeColor:m.edge.label.color,opacity:oe,fontSize:m.edge.label.fontSize,rotation:pe,active:J}),U&&he.jsx("group",{position:[se.x,se.y,0],children:he.jsx(Mu,{text:U,ellipsis:15,fontUrl:o,stroke:m.edge.subLabel?.stroke||m.edge.label.stroke,active:J,color:J?m.edge.subLabel?.activeColor||m.edge.label.activeColor:m.edge.subLabel?.color||m.edge.label.color,opacity:oe,fontSize:m.edge.subLabel?.fontSize||m.edge.label.fontSize*.8,rotation:pe})})]}),[n,S,J,R,U,o,$,se,pe,A,l,xe,ye,oe,m.edge.label.activeColor,m.edge.label.color,m.edge.label.fontSize,m.edge.label.stroke,m.edge.subLabel?.stroke,m.edge.subLabel?.activeColor,m.edge.subLabel?.color,m.edge.subLabel?.fontSize]),W=K.useMemo(()=>g&&t&&he.jsx(tb,{prepend:!0,center:!0,position:de,children:t({data:S,onClose:()=>b(!1)})}),[g,t,de,S]);return he.jsxs("group",{position:[0,0,J?1:0],children:[O&&be?he.jsx(IW,{id:s,curve:be,size:D,animated:i,color:J?m.edge.activeFill:L||m.edge.fill,opacity:oe,onClick:F=>{n||c?.(S,F)},onContextMenu:()=>{n||(b(!0),l?.(S))},onPointerOver:ye,onPointerOut:xe}):he.jsx(zW,{curveOffset:Q,animated:i,color:J?m.edge.activeFill:L||m.edge.fill,curve:ee,curved:te,dashed:P,dashArray:I,id:s,opacity:oe,size:D,renderOrder:J?0:-1,onClick:F=>{n||c?.(S,F)},onPointerOver:ye,onPointerOut:xe,onContextMenu:()=>{n||(b(!0),l?.(S))}}),ue,He,W]})},BW=({animated:i,color:e,contextMenu:t,edge:n,labelFontUrl:r,labelPlacement:s="inline",opacity:a,active:o})=>{const l=tt(L=>L.theme),{target:c,source:h,label:d,labelVisible:p=!1,size:m=1}=n,v=tt(L=>L.nodes),[x,_]=K.useMemo(()=>[v.find(L=>L.id===h),v.find(L=>L.id===c)],[v,h,c]),g=tt(L=>L.draggingIds.length>0),b=K.useMemo(()=>(m+l.edge.label.fontSize)/2,[m,l.edge.label.fontSize]),E=K.useMemo(()=>AD(x.position,_.position,TD(b,s)),[x.position,_.position,b,s]),S=tt(L=>L.edgeContextMenus),w=tt(L=>L.setEdgeContextMenus),[{labelPosition:T}]=er(()=>({from:{labelPosition:[0,0,0]},to:{labelPosition:[E.x,E.y,E.z]},config:{...tr,duration:i&&!g?void 0:0}}),[E,i,g]),R=K.useCallback(L=>{const P=new Set(S);P.delete(L),w(P)},[S,w]),U=K.useMemo(()=>new Bi(0,0,s==="natural"?0:Math.atan((_.position.y-x.position.y)/(_.position.x-x.position.x))),[_.position.x,_.position.y,x.position.x,x.position.y,s]),A=K.useMemo(()=>({prepend:!0,center:!0,position:E}),[E]),D=K.useMemo(()=>({text:d,ellipsis:15,fontUrl:r,stroke:l.edge.label.stroke,color:e,opacity:a,fontSize:l.edge.label.fontSize,rotation:U,active:o}),[d,r,l.edge.label.stroke,e,a,l.edge.label.fontSize,U,o]);return he.jsxs("group",{children:[p&&d&&he.jsx(An.group,{position:T,children:he.jsx(Mu,{...D})}),t&&S.has(n.id)&&he.jsx(tb,{...A,children:t({data:n,onClose:()=>R(n.id)})})]})};function kW(i,e){const t=K.useRef(i),n=K.useRef(null);K.useEffect(()=>{t.current=i;const a=i.getAttribute("position");n.current=new Float32Array(a.array.length)},[i]);const r=K.useCallback(()=>{const a=t.current.getAttribute("position");return{from:new Float32Array(a.array.length),to:a.array}},[]),s=K.useCallback(a=>{const o=n.current;o.set(a);const l=new $t(o,3,!1);t.current.setAttribute("position",l),l.needsUpdate=!0},[]);er(()=>{if(!e)return null;const a=r();return{from:{positions:a.from},to:{positions:a.to},onChange:o=>{s(o.value.positions)},config:{...tr,duration:e?void 0:0}}},[e,r,s])}function GW(i,e,t){const[{activeOpacity:n,inactiveOpacity:r}]=er(()=>({from:{activeOpacity:0,inactiveOpacity:0},to:{activeOpacity:e?t.edge.selectedOpacity:t.edge.opacity,inactiveOpacity:e?t.edge.inactiveOpacity:t.edge.opacity},config:{...tr,duration:i?void 0:0}}),[i,e,t]);return{activeOpacity:n,inactiveOpacity:r}}function HW(i,e,t){const n=K.useRef(i);K.useEffect(()=>{n.current=i},[i]);const r=tt(p=>p.edgeContextMenus),s=tt(K.useCallback(p=>p.setEdgeContextMenus,[])),a=tt(K.useCallback(p=>p.setHoveredEdgeIds,[])),o=K.useRef(!1),l=K.useCallback(()=>{o.current=!0},[]),c=K.useRef(!1),h=K.useCallback(()=>{c.current=!0},[]),d=K.useCallback((p,m)=>{const{onClick:v,onContextMenu:x,onPointerOver:_,onPointerOut:g}=n.current;if(v&&o.current&&!t){o.current=!1;for(const E of m)v(E)}if((e||x)&&c.current&&!t){c.current=!1;const E=new Set(r);let S=!1;for(const w of m)r.has(w.id)||(E.add(w.id),S=!0,x?.(w));S&&s(E)}const b=m.length>0?m.map(E=>E.id):[];a(b),_&&m.filter(S=>!p.includes(S)).forEach(S=>{_(S)}),g&&p.filter(S=>!m.includes(S)).forEach(S=>{g(S)})},[e,t,r,s,a]);return{handleClick:l,handleContextMenu:h,handleIntersections:d}}const hA=dW();function VW(i,e){const t=K.useRef(null),n=tt(l=>l.theme);tt(l=>{t.current=l});const r=K.useRef(new Map),s=K.useRef(null),a=K.useCallback(l=>{const c=[],h=r.current,{nodes:d}=t.current,p=new Map(d.map(m=>[m.id,m]));return i!=="none"&&!s.current&&(s.current=new Cu(0,1,1,20,1,!0)),l.forEach(m=>{const{target:v,source:x,size:_=1}=m,g=p.get(x),b=p.get(v);if(!g||!b)return;const E=`${g.position.x},${g.position.y},${b.position.x},${b.position.y},${_}`,S=g.id===b.id,T=(m.interpolation||e)==="curved",R=m.arrowPlacement||i;if(h.has(E)){c.push(h.get(E));return}const U=Eu(g),A=g.size,D=Eu(b),L=b.size;let P;S?P=CD(g):P=Zf(U,A,D,L,T);const I=m.dashed,V=I?_*.4:_/2;let H;if(I?H=sA(P,V,new Ye(m.fill??n.edge.fill),m.dashArray):H=new fo(P,20,V,5,!1),R==="none"){if(!I){const te=new Ye(m.fill??n.edge.fill);gm(H,te)}c.push(H),h.set(E,H);return}const[z,O]=MD(_),B=s.current.clone();B.scale(O,z,O);let G,X;S?R==="mid"?(G=P.getPointAt(.25),X=P.getTangentAt(.25)):(G=P.getPointAt(.58),X=P.getTangentAt(.58)):[G,X]=ED(R,P,z);const k=new yi;if(k.setFromUnitVectors(new j(0,1,0),X),B.applyQuaternion(k),B.translate(G.x,G.y,G.z),R&&R==="end"&&!S){const te=Zf(U,A,G,0,T);I?H=sA(te,V,new Ye(m.fill??n.edge.fill),m.dashArray):H=new fo(te,20,V,5,!1)}const Y=new Ye(m.fill??n.edge.fill);I||gm(H,Y),gm(B,Y);const Q=Jh([H,B]);Q.userData={...Q.userData,type:"edge"},c.push(Q),h.set(E,Q)}),c},[i,e,n.edge.fill]),o=K.useCallback((l,c)=>{const h=a(l),d=a(c);return Jh([d.length?Jh(d):hA,h.length?Jh(h):hA],!0)},[a]);return{getGeometries:a,getGeometry:o}}const WW=({interpolation:i="linear",arrowPlacement:e="end",labelPlacement:t="inline",animated:n,contextMenu:r,disabled:s,edges:a,labelFontUrl:o,onClick:l,onContextMenu:c,onPointerOut:h,onPointerOver:d})=>{const p=tt(k=>k.theme),{getGeometries:m,getGeometry:v}=VW(e,i),x=tt(k=>k.draggingIds),_=tt(k=>k.edgeMeshes),g=tt(k=>k.setEdgeMeshes),b=tt(k=>k.actives||[]),E=tt(k=>k.selections||[]),S=tt(k=>k.hoveredEdgeIds||[]),[w,T,R,U]=K.useMemo(()=>{const k=[],Y=[],Q=[],te=[];return a.forEach(ee=>{if(x.includes(ee.source)||x.includes(ee.target)){E.includes(ee.id)||b.includes(ee.id)||S.includes(ee.id)?Q.push(ee):te.push(ee);return}E.includes(ee.id)||b.includes(ee.id)||S.includes(ee.id)?k.push(ee):Y.push(ee)}),[k,Y,Q,te]},[a,b,E,x,S]),A=!!E.length,D=K.useMemo(()=>v(w,T),[v,w,T]),{activeOpacity:L,inactiveOpacity:P}=GW(n,A,p);kW(D,n),K.useEffect(()=>{if(x.length===0){const Y=m(a).map(Q=>new mn(Q));g(Y)}},[m,g,a,x.length]);const I=K.useRef(new mn),V=K.useRef(new mn),H=K.useCallback(k=>{if(!k.camera)return[];const Y=k.intersectObjects(_);return Y.length?Y.map(Q=>a[_.indexOf(Q.object)]):[]},[_,a]),{handleClick:z,handleContextMenu:O,handleIntersections:B}=HW({onClick:l,onContextMenu:c,onPointerOut:h,onPointerOver:d},r,s),G=K.useRef([]),X=K.useRef([]);return u0(k=>{if(I.current.geometry=D,s)return;const Y=G.current;if((x.length||x.length===0&&Y!==null)&&(V.current.geometry=v(R,U)),G.current=x,x.length)return;const Q=X.current,te=H(k.raycaster);B(Q,te),te.join()!==Q.join()&&(V.current.geometry=v(te,[])),X.current=te}),he.jsxs("group",{onClick:z,onContextMenu:O,children:[he.jsxs("mesh",{ref:I,children:[he.jsx(An.meshBasicMaterial,{attach:"material-0",depthTest:!1,fog:!0,opacity:P,side:zn,transparent:!0,vertexColors:!0}),he.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:zn,transparent:!0})]}),he.jsxs("mesh",{ref:V,children:[he.jsx(An.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:P,side:zn,transparent:!0}),he.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:zn,transparent:!0})]}),a.map(k=>{const Y=E.includes(k.id),Q=b.includes(k.id),te=S.includes(k.id);return he.jsx(BW,{animated:n,contextMenu:r,color:Y||Q||te?p.edge.label.activeColor:p.edge.label.color,disabled:s,edge:k,labelFontUrl:o,labelPlacement:t,active:Y||Q||te},k.id)})]})},XW=({image:i,id:e,size:t,opacity:n=1,animated:r})=>{const s=K.useMemo(()=>new q2().load(i),[i]),{scale:a,spriteOpacity:o}=er({from:{scale:[1e-5,1e-5,1e-5],spriteOpacity:0},to:{scale:[t,t,t],spriteOpacity:n},config:{...tr,duration:r?void 0:0}});return he.jsx(An.sprite,{userData:{id:e,type:"node"},scale:a,children:he.jsx(An.spriteMaterial,{attach:"material",opacity:o,fog:!0,depthTest:!1,transparent:!0,side:zn,children:he.jsx("primitive",{attach:"map",object:s,minFilter:Fn})})})},jW=({color:i="#D8E6EA",size:e=1,opacity:t=.5,animated:n,strokeWidth:r=5,innerRadius:s=4,segments:a=25})=>{const o=K.useMemo(()=>new Ye(i),[i]),{ringSize:l,ringOpacity:c}=er({from:{ringOpacity:0,ringSize:[1e-5,1e-5,1e-5]},to:{ringOpacity:t,ringSize:[e/2,e/2,1]},config:{...tr,duration:n?void 0:0}}),h=r/10,d=s+h;return he.jsx(KR,{position:[0,0,1],children:he.jsxs(An.mesh,{scale:l,raycast:t>0?void 0:()=>[],children:[he.jsx("ringGeometry",{attach:"geometry",args:[s,d,a]}),he.jsx(An.meshBasicMaterial,{attach:"material",color:o,transparent:!0,depthTest:!1,opacity:c,side:zn,fog:!0})]})})},qW=({color:i,id:e,size:t,selected:n,opacity:r=1,animated:s})=>{const{scale:a,nodeOpacity:o}=er({from:{scale:[1e-5,1e-5,1e-5],nodeOpacity:0},to:{scale:[t,t,t],nodeOpacity:r},config:{...tr,duration:s?void 0:0}}),l=K.useMemo(()=>new Ye(i),[i]),c=tt(h=>h.theme);return he.jsxs(he.Fragment,{children:[he.jsxs(An.mesh,{userData:{id:e,type:"node"},scale:a,children:[he.jsx("sphereGeometry",{attach:"geometry",args:[1,25,25]}),he.jsx(An.meshPhongMaterial,{attach:"material",side:zn,transparent:!0,fog:!0,opacity:o,color:l,emissive:l,emissiveIntensity:.7})]}),he.jsx(jW,{opacity:n?.5:0,size:t,animated:s,color:n?c.ring.activeFill:c.ring.fill})]})},YW=({animated:i,disabled:e,id:t,draggable:n=!1,labelFontUrl:r,contextMenu:s,onClick:a,onDoubleClick:o,onPointerOver:l,onDragged:c,onPointerOut:h,onContextMenu:d,renderNode:p,constrainDragging:m})=>{const v=w0(),x=tt(ue=>ue.theme),_=tt(ue=>ue.nodes.find(He=>He.id===t)),g=tt(ue=>ue.edges),b=tt(ue=>ue.draggingIds),E=tt(ue=>ue.collapsedNodeIds),S=tt(ue=>ue.addDraggingId),w=tt(ue=>ue.removeDraggingId),T=tt(ue=>ue.setHoveredNodeId),R=tt(ue=>ue.setNodePosition),U=tt(ue=>ue.setCollapsedNodeIds),A=tt(ue=>ue.collapsedNodeIds.includes(t)),D=tt(ue=>ue.actives?.includes(t)),L=tt(ue=>ue.selections?.includes(t)),P=tt(ue=>ue.selections?.length>0),I=tt(ue=>ue.centerPosition),V=tt(ue=>ue.clusters.get(_.cluster)),H=b.includes(t),z=b.length>0,{position:O,label:B,subLabel:G,size:X=7,labelVisible:k=!0}=_,Y=K.useRef(null),[Q,te]=K.useState(!1),[ee,ie]=K.useState(!1),re=Q||L||D,de=P?re?x.node.selectedOpacity:x.node.inactiveOpacity:x.node.opacity,Ae=K.useMemo(()=>g.filter(He=>He.source===t).length>0||A,[g,t,A]),Me=K.useCallback(()=>{Ae&&U(A?E.filter(ue=>ue!==t):[...E,t])},[Ae,E,t,A,U]),[{nodePosition:ve,labelPosition:fe}]=er(()=>({from:{nodePosition:I?[I.x,I.y,0]:[0,0,0],labelPosition:[0,-(X+7),2]},to:{nodePosition:O?[O.x,O.y,re?O.z+1:O.z]:[0,0,0],labelPosition:[0,-(X+7),2]},config:{...tr,duration:i&&!z?void 0:0}}),[H,O,i,X,re]),J=ND({draggable:n,position:O,bounds:m?V?.position:void 0,set:ue=>R(t,ue),onDragStart:()=>{S(t),te(!0)},onDragEnd:()=>{w(t),c?.(_)}});El(Q&&!z&&a!==void 0,"pointer"),El(Q&&n&&!H&&a===void 0,"grab"),El(H,"grabbing");const oe=re||H,se=oe?x.node.activeFill:_.fill||x.node.fill,{pointerOver:$,pointerOut:pe}=hb({disabled:e||H,onPointerOver:ue=>{v.freeze(),te(!0),l?.(_,ue),T(t)},onPointerOut:ue=>{v.unFreeze(),te(!1),h?.(_,ue),T(null)}}),ye=K.useMemo(()=>p?p({id:t,color:se,size:X,active:oe,opacity:de,animated:i,selected:L,node:_}):he.jsx(he.Fragment,{children:_.icon?he.jsx(XW,{id:t,image:_.icon||"",size:X+8,opacity:de,animated:i,color:se,node:_,active:oe,selected:L}):he.jsx(qW,{id:t,size:X,opacity:de,animated:i,color:se,node:_,active:oe,selected:L})}),[p,t,se,X,oe,de,i,L,_]),xe=K.useMemo(()=>k&&(k||L||Q)&&B&&he.jsxs(An.group,{position:fe,children:[he.jsx(Mu,{text:B,fontUrl:r,opacity:de,stroke:x.node.label.stroke,backgroundColor:x.node.label.backgroundColor,backgroundOpacity:x.node.label.backgroundOpacity,padding:x.node.label.padding,strokeColor:x.node.label.strokeColor,strokeWidth:x.node.label.strokeWidth,radius:x.node.label.radius,active:L||Q||H||D,color:L||Q||H||D?x.node.label.activeColor:x.node.label.color}),G&&he.jsx("group",{position:[0,-(X-3),0],children:he.jsx(Mu,{text:G,fontUrl:r,fontSize:5,opacity:de,stroke:x.node.subLabel?.stroke,active:L||Q||H||D,color:L||Q||H||D?x.node.subLabel?.activeColor:x.node.subLabel?.color})})]}),[Q,D,H,L,B,r,fe,k,X,de,G,x.node.label.activeColor,x.node.label.color,x.node.label.stroke,x.node.label.backgroundColor,x.node.label.backgroundOpacity,x.node.label.padding,x.node.label.strokeColor,x.node.label.strokeWidth,x.node.label.radius,x.node.subLabel?.activeColor,x.node.subLabel?.color,x.node.subLabel?.stroke]),be=K.useMemo(()=>ee&&s&&he.jsx(tb,{prepend:!0,center:!0,children:s({data:_,canCollapse:Ae,isCollapsed:A,onCollapse:Me,onClose:()=>ie(!1)})}),[ee,s,_,Ae,A,Me]);return he.jsxs(An.group,{renderOrder:1,userData:{id:t,type:"node"},ref:Y,position:ve,onPointerOver:$,onPointerOut:pe,onClick:ue=>{!e&&!H&&a?.(_,{canCollapse:Ae,isCollapsed:A},ue)},onDoubleClick:ue=>{!e&&!H&&o?.(_,ue)},onContextMenu:()=>{e||(ie(!0),d?.(_,{canCollapse:Ae,isCollapsed:A,onCollapse:Me}))},...J(),children:[ye,be,xe]})};function ZW(i){return new Promise((e,t)=>{let n;function r(){n?e(n):(n=i.step(),r())}r()})}function Fl(i){const e=[],t=[];return i.forEachNode((n,r)=>{e.push({...r,id:n,radius:r.size||1})}),i.forEachEdge((n,r)=>{t.push({...r,id:n})}),{nodes:e,edges:t}}function KW({graph:i,radius:e,drags:t,getNodePosition:n}){const r=K8(i,{scale:e}),{nodes:s,edges:a}=Fl(i);return{step(){return!0},getNodePosition(o){if(n){const l=n(o,{graph:i,drags:t,nodes:s,edges:a});if(l)return l}return t?.[o]?.position?t?.[o]?.position:r?.[o]}}}function JW({graph:i,radius:e=40,drags:t,getNodePosition:n,concentricSpacing:r=100}){const{nodes:s,edges:a}=Fl(i),o={},l=v=>{const x=2*Math.PI*(e+v*r);return Math.floor(x/40)},c=new Map,h=[];for(const v of s){const _=i.getNodeAttribute(v.id,"data")?.level;typeof _=="number"&&_>=0?(c.has(_)||c.set(_,[]),c.get(_).push(v.id)):h.push({id:v.id,metric:i.degree(v.id)})}h.sort((v,x)=>x.metric-v.metric);for(const[v,x]of c.entries()){const _=x.length,g=e+v*r;for(let b=0;b<_;b++){const E=2*Math.PI*b/_;o[x[b]]={x:g*Math.cos(E),y:g*Math.sin(E)}}}const d=new Set(c.keys());let p=0,m=0;for(;m<h.length;){for(;d.has(p);)p++;const v=l(p),x=e+p*r;for(let _=0;_<v&&m<h.length;_++){const g=2*Math.PI*_/v;o[h[m].id]={x:x*Math.cos(g),y:x*Math.sin(g)},m++}p++}return{step(){return!0},getNodePosition(v){if(n){const x=n(v,{graph:i,drags:t,nodes:s,edges:a});if(x)return x}return t?.[v]?.position?t[v].position:o[v]}}}function QW({graph:i,drags:e,getNodePosition:t}){const{nodes:n,edges:r}=Fl(i);return{step(){return!0},getNodePosition(s){return t(s,{graph:i,drags:e,nodes:n,edges:r})}}}function PD(i,e=[]){const t=e.length;for(const n of i){const r=e.indexOf(n);if(r>-1){const s=[...e.slice(r),n].map(a=>a.data.id);throw new Error(`Invalid Graph: Circular node path detected: ${s.join(" -> ")}.`)}t>n.depth&&(n.depth=t,PD(n.out,[...e,n]))}}function zD(i,e){let t=!1;const n=i.reduce((a,o)=>({...a,[o.id]:{data:o,out:[],depth:-1,ins:[]}}),{});try{for(const a of e){const o=a.source,l=a.target;if(!n.hasOwnProperty(o))throw new Error(`Missing source Node ${o}`);if(!n.hasOwnProperty(l))throw new Error(`Missing target Node ${l}`);const c=n[o],h=n[l];h.ins.push(c),c.out.push(h)}PD(Object.values(n))}catch{t=!0}const r=Object.keys(n).map(a=>n[a].depth),s=Math.max(...r);return{invalid:t,depths:n,maxDepth:s||1}}function $W({graph:i,drags:e,iterations:t,...n}){$8.assign(i);const r=s7(i,{iterations:t,settings:n});return{step(){return!0},getNodePosition(s){return e?.[s]?.position||r?.[s]}}}function eX(){const i=O=>()=>O;let t=O=>O.index,n=[],r=[],s,a,o=[100,100],l=i(1),c=i(-1),h=i(100),d=i(.1);const p={};let m=.1,v=.001,x=[],_=[0,0],g,b=O=>O.cluster,E="treemap",S=!0,w=.1;function T(O){if(!S)return T;E==="force"&&(g.tick(),I());for(let B=0,G=n.length,X,k=O*w;B<G;++B)X=n[B],X.vx+=(p[b(X)].x-X.x)*k,X.vy+=(p[b(X)].y-X.y)*k}function R(){n&&(E==="treemap"?V():z())}T.initialize=function(O){n=O,R()};function U(O){const B=b(O.source),G=b(O.target);return B<=G?B+"~"+G:G+"~"+B}function A(O){let B=new Map,G={};return O.forEach(function(X){B.has(b(X))||B.set(b(X),{count:0,sumforceNodeSize:0})}),O.forEach(function(X){G=B.get(b(X)),G.count=G.count+1,G.sumforceNodeSize=G.sumforceNodeSize+Math.PI*(l(X)*l(X))*1.3,B.set(b(X),G)}),B}function D(O){const B=new Map,G=[];return O.forEach(function(X){let k=U(X),Y;B.has(k)?Y=B.get(k):Y=0,Y+=1,B.set(k,Y)}),B.forEach(function(X,k){let Y,Q;Y=k.split("~")[0],Q=k.split("~")[1],Y!==void 0&&Q!==void 0&&G.push({source:Y,target:Q,count:X})}),G}function L(){const O=[],B=[],G=new Map;let X,k,Y,Q,te;Q=A(n),te=D(r);for(X of Q.keys())Y=Q.get(X),O.push({id:X,size:Y.count,r:Math.sqrt(Y.sumforceNodeSize/Math.PI)}),G.set(X,k);return te.forEach(function(ee){const ie=G.get(ee.source),re=G.get(ee.target);ie!==void 0&&re!==void 0&&B.push({source:ie,target:re,count:ee.count})}),{nodes:O,links:B}}function P(){const O=[];let B,G,X;X=A(T.nodes());for(B of X.keys())G=X.get(B),O.push({id:B,size:G.count});return{id:"clustersTree",children:O}}function I(){return p.none={x:0,y:0},x.forEach(function(O){E==="treemap"?p[O.data.id]={x:O.x0+(O.x1-O.x0)/2-_[0],y:O.y0+(O.y1-O.y0)/2-_[1]}:p[O.id]={x:O.x-_[0],y:O.y-_[1]}}),p}function V(){const O=iW().size(T.size());a=M0(P()).sum(B=>B.radius).sort(function(B,G){return G.height-B.height||G.value-B.value}),x=O(a).leaves(),I()}function H(){let O=0;n.length!==0&&r.forEach(function(B){let G,X;if(n){if(G=B.source,X=B.target,typeof B.source!="object"&&(G=n.find(k=>k.id===B.source)),typeof B.target!="object"&&(X=n.find(k=>k.id===B.target)),G===void 0||X===void 0)throw Error("Error setting links, couldnt find nodes for a link (see it on the console)");B.source=G,B.target=X,B.index=O++}})}function z(){let O;!n||!n.length||(H(),O=L(),s.size>0&&O.nodes.forEach(B=>{B.fx=s.get(B.id)?.position?.x,B.fy=s.get(B.id)?.position?.y}),g=_D(O.nodes).force("x",Ix(o[0]/2).strength(.1)).force("y",Nx(o[1]/2).strength(.1)).force("collide",fD(B=>B.r).iterations(4)).force("charge",xD().strength(c)).force("links",dD(O.nodes.length?O.links:[]).distance(h).strength(d)),x=g.nodes(),I())}return T.template=function(O){return arguments.length?(E=O,R(),T):E},T.groupBy=function(O){return arguments.length?typeof O=="string"?(b=function(B){return B[O]},T):(b=O,T):b},T.enableGrouping=function(O){return arguments.length?(S=O,T):S},T.strength=function(O){return arguments.length?(w=O,T):w},T.getLinkStrength=function(O){return S?b(O.source)===b(O.target)?typeof m=="function"?m(O):m:typeof v=="function"?v(O):v:typeof m=="function"?m(O):m},T.id=function(O){return arguments.length?(t=O,T):t},T.size=function(O){return arguments.length?(o=O,T):o},T.linkStrengthInterCluster=function(O){return arguments.length?(v=O,T):v},T.linkStrengthIntraCluster=function(O){return arguments.length?(m=O,T):m},T.nodes=function(O){return arguments.length?(n=O,T):n},T.links=function(O){return arguments.length?(O===null?r=[]:r=O,R(),T):r},T.template=function(O){return arguments.length?(E=O,R(),T):E},T.forceNodeSize=function(O){return arguments.length?(l=typeof O=="function"?O:i(+O),R(),T):l},T.nodeSize=T.forceNodeSize,T.forceCharge=function(O){return arguments.length?(c=typeof O=="function"?O:i(+O),R(),T):c},T.forceLinkDistance=function(O){return arguments.length?(h=typeof O=="function"?O:i(+O),R(),T):h},T.forceLinkStrength=function(O){return arguments.length?(d=typeof O=="function"?O:i(+O),R(),T):d},T.offset=function(O){return arguments.length?(_=typeof O=="function"?O:i(+O),T):_},T.getFocis=I,T.setClusters=function(O){return s=O,T},T}const fA=["radialin","radialout"];function tX({nodes:i,edges:e,mode:t="lr",nodeLevelRatio:n=2}){const{depths:r,maxDepth:s,invalid:a}=zD(i,e);if(a)return null;const o=fA.includes(t)?1:5,l=i.length/s*n*o;if(t){const c=(m,v)=>x=>m?(r[x.id].depth-s/2)*l*(v?-1:1):void 0,h=c(["lr","rl"].includes(t),t==="rl"),d=c(["td","bu"].includes(t),t==="td"),p=c(["zin","zout"].includes(t),t==="zout");i.forEach(m=>{m.fx=h(m),m.fy=d(m),m.fz=p(m)})}return fA.includes(t)?_9(c=>{const h=r[c.id];return(t==="radialin"?s-h.depth:h.depth)*l}).strength(1):null}function to({graph:i,nodeLevelRatio:e=2,mode:t=null,dimensions:n=2,nodeStrength:r=-250,linkDistance:s=50,clusterStrength:a=.5,linkStrengthInterCluster:o=.01,linkStrengthIntraCluster:l=.5,forceLinkDistance:c=100,forceLinkStrength:h=.1,clusterType:d="force",forceCharge:p=-700,getNodePosition:m,drags:v,clusters:x,clusterAttribute:_,forceLayout:g}){const{nodes:b,edges:E}=Fl(i),w=n===2&&E.length>25?r*2:r;let T,R;g==="forceDirected2d"?(T=Ix(),R=Nx()):(T=Ix(600).strength(.05),R=Nx(600).strength(.05));const U=_D().force("center",a7(0,0)).force("link",dD()).force("charge",xD().strength(w)).force("x",T).force("y",R).force("z",x9()).force("collide",fD(P=>P.radius+10)).force("dagRadial",tX({nodes:b,edges:E,mode:t,nodeLevelRatio:e})).stop();let A;if(_){let P=p;if(b?.length){const I=Math.ceil(b.length/200);P=p*I}A=eX().setClusters(x).strength(a).template(d).groupBy(I=>I.data[_]).links(E).size([100,100]).linkStrengthInterCluster(o).linkStrengthIntraCluster(l).forceLinkDistance(c).forceLinkStrength(h).forceCharge(P).forceNodeSize(I=>I.radius)}let D=U.numDimensions(n).nodes(b);if(A&&(D=D.force("group",A)),s){let P=D.force("link");P&&(P.id(I=>I.id).links(E).distance(s),A&&(P=P.strength(A?.getLinkStrength??.1)))}const L=new Map(b.map(P=>[P.id,P]));return{step(){for(;U.alpha()>.01;)U.tick();return!0},getNodePosition(P){if(m){const I=m(P,{graph:i,drags:v,nodes:b,edges:E});if(I)return I}return v?.[P]?.position?v?.[P]?.position:L.get(P)}}}const nX={td:{x:"x",y:"y",factor:-1},lr:{x:"y",y:"x",factor:1}};function dA({graph:i,drags:e,mode:t="td",nodeSeparation:n=1,nodeSize:r=[50,50],getNodePosition:s}){const{nodes:a,edges:o}=Fl(i),{depths:l}=zD(a,o),c=Object.keys(l).map(x=>l[x]),h=X9().id(x=>x.data.id).parentId(x=>x.ins?.[0]?.data?.id)(c),p=Q9().separation(()=>n).nodeSize(r)(M0(h)).descendants(),m=nX[t],v=new Map(a.map(x=>{const{x:_,y:g}=p.find(b=>b.data.id===x.id);return[x.id,{...x,[m.x]:_*m.factor,[m.y]:g*m.factor,z:0}]}));return{step(){return!0},getNodePosition(x){if(s){const _=s(x,{graph:i,drags:e,nodes:a,edges:o});if(_)return _}return e?.[x]?.position?e?.[x]?.position:v.get(x)}}}function pA(i,e,t){const n=Math.acos(1-2*(i+.5)/e),r=Math.PI*(1+Math.sqrt(5))*(i+.5),s=t*Math.sin(n)*Math.cos(r),a=t*Math.sin(n)*Math.sin(r),o=t*Math.cos(n);return new j(s,a,o)}function iX({graph:i,radius:e=40,drags:t,getNodePosition:n,concentricSpacing:r=100}){const{nodes:s,edges:a}=Fl(i),o={},l=v=>{const x=2*Math.PI*(e+v*r);return Math.floor(x/40)},c=new Map,h=[];for(const v of s){const _=i.getNodeAttribute(v.id,"data")?.level;typeof _=="number"&&_>=0?(c.has(_)||c.set(_,[]),c.get(_).push(v.id)):h.push({id:v.id,metric:i.degree(v.id)})}h.sort((v,x)=>x.metric-v.metric);for(const[v,x]of c.entries()){const _=x.length,g=e+v*r;for(const[b,E]of x.entries()){const S=pA(b,_,g);o[E]={x:S.x,y:S.y,z:S.z}}}const d=new Set(c.keys());let p=0,m=0;for(;m<h.length;){for(;d.has(p);)p++;const v=l(p),x=e+p*r;for(let _=0;_<v&&m<h.length;_++){const g=pA(_,v,x);o[h[m].id]={x:g.x,y:g.y,z:g.z},m++}p++}return{step(){return!0},getNodePosition(v){if(n){const x=n(v,{graph:i,drags:t,nodes:s,edges:a});if(x)return x}return t?.[v]?.position?t[v].position:o[v]}}}function rX({graph:i,margin:e,drags:t,getNodePosition:n,ratio:r,gridSize:s,maxIterations:a}){const{nodes:o,edges:l}=Fl(i),c=cW(i,{maxIterations:a,inputReducer:(h,d)=>({...d,x:d.x||0,y:d.y||0}),settings:{ratio:r,margin:e,gridSize:s}});return{step(){return!0},getNodePosition(h){if(n){const d=n(h,{graph:i,drags:t,nodes:o,edges:l});if(d)return d}return t?.[h]?.position?t?.[h]?.position:c?.[h]}}}const sX=["forceDirected2d","treeTd2d","treeLr2d","radialOut2d","treeTd3d","treeLr3d","radialOut3d","forceDirected3d"];function aX({type:i,...e}){if(sX.includes(i)){const{nodeStrength:t,linkDistance:n,nodeLevelRatio:r}=e;if(i==="forceDirected2d")return to({...e,dimensions:2,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i});if(i==="treeTd2d")return to({...e,mode:"td",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="treeLr2d")return to({...e,mode:"lr",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:i});if(i==="radialOut2d")return to({...e,mode:"radialout",dimensions:2,nodeLevelRatio:r||5,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="treeTd3d")return to({...e,mode:"td",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50});if(i==="treeLr3d")return to({...e,mode:"lr",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||50,forceLayout:i});if(i==="radialOut3d")return to({...e,mode:"radialout",dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-500,linkDistance:n||100,forceLayout:i});if(i==="forceDirected3d")return to({...e,dimensions:3,nodeLevelRatio:r||2,nodeStrength:t||-250,linkDistance:n,forceLayout:i})}else if(i==="circular2d"){const{radius:t}=e;return KW({...e,radius:t||300})}else{if(i==="concentric2d")return JW(e);if(i==="concentric3d")return iX(e);if(i==="hierarchicalTd")return dA({...e,mode:"td"});if(i==="hierarchicalLr")return dA({...e,mode:"lr"});if(i==="nooverlap"){const{graph:t,maxIterations:n,ratio:r,margin:s,gridSize:a,...o}=e;return rX({graph:t,margin:s||10,maxIterations:n||50,ratio:r||10,gridSize:a||20,...o})}else if(i==="forceatlas2"){const{graph:t,iterations:n,gravity:r,scalingRatio:s,...a}=e;return $W({type:"forceatlas2",graph:t,...a,scalingRatio:s||100,gravity:r||10,iterations:n||50})}else if(i==="custom")return QW({...e})}throw new Error(`Layout ${i} not found.`)}const oX=({layoutType:i,sizingType:e,labelType:t,sizingAttribute:n,clusterAttribute:r,selections:s,nodes:a,edges:o,actives:l,collapsedNodeIds:c,defaultNodeSize:h,maxNodeSize:d,minNodeSize:p,layoutOverrides:m,constrainDragging:v})=>{const x=tt(k=>k.graph),_=tt(k=>k.clusters),g=tt(k=>k.nodes),b=tt(k=>k.setClusters),E=tt(k=>k.collapsedNodeIds),S=tt(k=>k.setEdges),w=tt(k=>k.nodes),T=tt(k=>k.setNodes),R=tt(k=>k.setSelections),U=tt(k=>k.setActives),A=tt(k=>k.drags),D=tt(k=>k.setDrags),L=tt(k=>k.setCollapsedNodeIds),P=K.useRef(!1),I=K.useRef(null),V=Jn(k=>k.camera),H=K.useRef(A),z=K.useRef([]);K.useEffect(()=>{if(!r)return;const k=g.map(Q=>Q.id),Y=a.find(Q=>!k.includes(Q.id));if(Y){const Q=Y.data[r],te=_.get(Q),ee={...H.current};te?.nodes?.forEach(ie=>ee[ie.id]=void 0),H.current=ee,D(ee)}},[g,a,r,_,D]);const{visibleEdges:O,visibleNodes:B}=K.useMemo(()=>RW({collapsedIds:E,nodes:a,edges:o}),[E,a,o]),G=K.useCallback(k=>{const Y={...H.current};k.forEach(Q=>Y[Q.id]=Q),H.current=Y,D(Y)},[D]),X=K.useCallback(async k=>{I.current=k||aX({...m,type:i,graph:x,drags:H.current,clusters:z?.current,clusterAttribute:r}),await ZW(I.current);const Y=xW({graph:x,layout:I.current,sizingType:e,labelType:t,sizingAttribute:n,maxNodeSize:d,minNodeSize:p,defaultNodeSize:h,clusterAttribute:r}),Q=fW({nodes:Y.nodes,clusterAttribute:r});v&&Q.forEach(te=>{z.current.get(te.label)?.nodes.length===te.nodes.length&&(te.position=z.current?.get(te.label)?.position??te.position)}),S(Y.edges),T(Y.nodes),b(Q),r&&G(Y.nodes)},[m,i,r,e,t,n,d,p,h,S,T,b]);return K.useEffect(()=>{H.current=A},[A,r,X]),K.useEffect(()=>{z.current=_},[_]),K.useEffect(()=>{const k=w.map(Q=>({...Q,labelVisible:wD({nodeCount:w?.length,labelType:t,camera:V,nodePosition:Q?.position})("node",Q?.size)}));k.some((Q,te)=>Q.labelVisible!==w[te].labelVisible)&&T(k)},[V,V.zoom,V.position.z,T,w,t]),K.useEffect(()=>{P.current&&R(s)},[s,R]),K.useEffect(()=>{P.current&&U(l)},[l,U]),K.useEffect(()=>{async function k(){P.current=!1,_W(x,B,O),await X(),requestAnimationFrame(()=>P.current=!0)}k()},[B,O]),K.useEffect(()=>{P.current&&L(c)},[c,L]),K.useEffect(()=>{P.current&&(H.current={},D({}),X())},[i,X,D]),K.useEffect(()=>{P.current&&X(I.current)},[e,n,t,X]),{updateLayout:X}},lX=i=>i.reduceEdges((e,t,n,r,s)=>{const a=`${r}-${s}`,o={id:t,source:r,target:s,...n},l=e.get(a);return l?l.push(o):e.set(a,[o]),e},new Map),cX=(i,e)=>{if(!i||i.size===0)return[];const t=lX(i),n=[],r=e==="all"||e==="edges";for(const[s,a]of t){const[o,l]=s.split("-"),c=a[0];if(!o||!l||!c)continue;const h=c.size||1,d=h+a.length*h*.5,p=a.length>1,m=p?`${a.length} edges`:c.label,v={...c,source:o,target:l,label:m,labelVisible:r,size:d,data:{...c.data||{},originalEdges:a,count:a.length,isAggregated:p,originalSize:h}};n.push(v)}return n},uX=K.forwardRef(({onNodeClick:i,onNodeDoubleClick:e,onNodeContextMenu:t,onEdgeContextMenu:n,onEdgeClick:r,onEdgePointerOver:s,onEdgePointerOut:a,onNodePointerOver:o,onNodePointerOut:l,onClusterClick:c,onNodeDragged:h,onClusterDragged:d,onClusterPointerOver:p,onClusterPointerOut:m,contextMenu:v,animated:x,disabled:_,draggable:g,constrainDragging:b=!1,edgeLabelPosition:E,edgeArrowPosition:S,edgeInterpolation:w="linear",labelFontUrl:T,renderNode:R,onRenderCluster:U,aggregateEdges:A,...D},L)=>{const{layoutType:P,clusterAttribute:I,labelType:V}=D,H=Jn(fe=>fe.gl),z=Jn(fe=>fe.scene),O=Jn(fe=>fe.camera),{updateLayout:B}=oX({...D,constrainDragging:b});if(I&&!(P==="forceDirected2d"||P==="forceDirected3d"))throw new Error("Clustering is only supported for the force directed layouts.");const G=tt(fe=>fe.graph),X=tt(fe=>fe.nodes),k=tt(fe=>fe.edges),Y=tt(fe=>fe.setEdges),Q=tt(fe=>[...fe.clusters.values()]),te=K.useMemo(()=>A?cX(G,V):k,[k,A,G,V]);K.useEffect(()=>{A&&k.length!==te.length&&Y(te)},[te,k.length,Y,A]);const{centerNodesById:ee,fitNodesInViewById:ie,isCentered:re}=DW({animated:x,disabled:_,layoutType:P});K.useImperativeHandle(L,()=>({centerGraph:ee,fitNodesInView:ie,graph:G,renderScene:()=>H.render(z,O)}),[ee,ie,G,H,z,O]);const de=K.useCallback(fe=>{h?.(fe),I&&B()},[I,h,B]),Ae=K.useMemo(()=>X.map(fe=>he.jsx(YW,{id:fe?.id,labelFontUrl:T,draggable:g,constrainDragging:b,disabled:_,animated:x,contextMenu:v,renderNode:R,onClick:i,onDoubleClick:e,onContextMenu:t,onPointerOver:o,onPointerOut:l,onDragged:de},fe?.id)),[b,x,v,_,g,T,X,i,t,e,de,l,o,R]),Me=K.useMemo(()=>x?te.map(fe=>he.jsx(FW,{id:fe.id,disabled:_,animated:x,labelFontUrl:T,labelPlacement:E,arrowPlacement:S,interpolation:w,contextMenu:v,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a},fe.id)):he.jsx(WW,{edges:te,disabled:_,animated:x,labelFontUrl:T,labelPlacement:E,arrowPlacement:S,interpolation:w,contextMenu:v,onClick:r,onContextMenu:n,onPointerOver:s,onPointerOut:a}),[x,v,_,S,w,E,te,T,r,n,a,s]),ve=K.useMemo(()=>Q.map(fe=>he.jsx(LW,{animated:x,disabled:_,draggable:g,labelFontUrl:T,onClick:c,onPointerOver:p,onPointerOut:m,onDragged:d,onRender:U,...fe},fe.label)),[x,Q,_,g,T,c,m,p,d,U]);return re&&he.jsxs(K.Fragment,{children:[Me,Ae,ve]})});function G_(i,e,t){e=Array.isArray(e)?e:[e];const n=[],r=[];for(const s of e){const a=[...i.inEdgeEntries(s)??[],...i.outEdgeEntries(s)??[]];if(a)for(const o of a){const l=o.attributes.id;if(t==="in"?o.target===s&&!r.includes(l)&&r.push(l):t==="out"?o.source===s&&!r.includes(l)&&r.push(l):r.includes(l)||r.push(l),t==="out"||t==="all"){const c=o.target;n.includes(c)||n.push(c)}(t==="in"||t==="all")&&(n.includes(o.source)||n.push(o.source))}}return{nodes:n,edges:r}}function nm(i,e,t){const{offsetX:n,offsetY:r}=i,{width:s,height:a}=t;e.set(n/s*2-1,-(r/a)*2+1)}function hX(i){const e=document.createElement("div");return e.style.pointerEvents="none",e.style.border=i.lasso.border,e.style.backgroundColor=i.lasso.background,e.style.position="fixed",e}const fX=({children:i,type:e="none",onLasso:t,onLassoEnd:n,disabled:r})=>{const s=tt(L=>L.theme),a=Jn(L=>L.camera),o=Jn(L=>L.gl),l=Jn(L=>L.setEvents),c=Jn(L=>L.size),h=Jn(L=>L.get),d=Jn(L=>L.scene),p=w0(),m=tt(L=>L.actives),v=tt(L=>L.setActives),x=tt(L=>L.edges),_=tt(L=>L.edgeMeshes),g=K.useRef(null),b=K.useRef(null),E=K.useRef(hX(s)),S=K.useRef(null),w=K.useRef(!1),T=K.useRef(h().events.enabled),R=K.useRef(p.controls?.enabled),U=K.useCallback(L=>{if(w.current){const[P,I,V]=S.current;V.x=Math.max(P.x,L.clientX),V.y=Math.max(P.y,L.clientY),I.x=Math.min(P.x,L.clientX),I.y=Math.min(P.y,L.clientY),E.current.style.left=`${I.x}px`,E.current.style.top=`${I.y}px`,E.current.style.width=`${V.x-I.x}px`,E.current.style.height=`${V.y-I.y}px`,nm(L,g.current.endPoint,c),nm(L,b.current.endPoint,c);const H=[],z=b.current.select().sort(B=>B.uuid).filter(B=>B.geometry?.userData?.type===e||e==="all").map(B=>x[_.indexOf(B)].id);H.push(...z);const O=g.current.select().sort(B=>B.uuid).filter(B=>B.isMesh&&B.userData?.id&&(B.userData?.type===e||e==="all")).map(B=>B.userData.id);H.push(...O),requestAnimationFrame(()=>{v(H),t?.(H)}),document.addEventListener("pointermove",U,{passive:!0,capture:!0,once:!0})}},[c,x,_,e,v,t]),A=K.useCallback(()=>{w.current&&(l({enabled:T.current}),w.current=!1,E.current.parentElement?.removeChild(E.current),p.controls.enabled=R.current,n?.(m),document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",A))},[l,p.controls,n,m,U]),D=K.useCallback(L=>{if(L.shiftKey){T.current=h().events.enabled,R.current=p.controls?.enabled,g.current=new rw(a,d);const P=new Gg;_.length&&P.add(..._),b.current=new rw(a,P),S.current=[new ke,new ke,new ke];const[I]=S.current;p.controls.enabled=!1,l({enabled:!1}),w.current=!0,o.domElement.parentElement?.appendChild(E.current),E.current.style.left=`${L.clientX}px`,E.current.style.top=`${L.clientY}px`,E.current.style.width="0px",E.current.style.height="0px",I.x=L.clientX,I.y=L.clientY,nm(L,g.current.startPoint,c),nm(L,b.current.startPoint,c),document.addEventListener("pointermove",U,{passive:!0,capture:!0,once:!0}),document.addEventListener("pointerup",A,{passive:!0})}},[a,p.controls,_,h,o.domElement.parentElement,U,A,d,l,c]);return K.useEffect(()=>{if(!(r||e==="none"))return typeof window<"u"&&(document.addEventListener("pointerdown",D,{passive:!0}),document.addEventListener("pointermove",U,{passive:!0}),document.addEventListener("pointerup",A,{passive:!0})),()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",D),document.removeEventListener("pointermove",U),document.removeEventListener("pointerup",A))}},[e,r,D,U,A]),he.jsx("group",{children:i})},FD={canvas:{background:"#fff"},node:{fill:"#7CA0AB",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{color:"#2A6475",stroke:"#fff",activeColor:"#1DE9AC"},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#D8E6EA",activeFill:"#1DE9AC"},edge:{fill:"#D8E6EA",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475",activeColor:"#1DE9AC",fontSize:6},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},arrow:{fill:"#D8E6EA",activeFill:"#1DE9AC"},cluster:{stroke:"#D8E6EA",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475"}}},dX="_canvas_670zp_1",pX={canvas:dX},mX={alpha:!0,antialias:!0},gX={position:[0,0,1e3],near:5,far:5e4,fov:10},vX=K.forwardRef(({cameraMode:i="pan",layoutType:e="forceDirected2d",sizingType:t="default",labelType:n="auto",theme:r=FD,animated:s=!0,defaultNodeSize:a=7,minNodeSize:o=5,maxNodeSize:l=15,lassoType:c="none",glOptions:h={},edges:d,children:p,nodes:m,minDistance:v,maxDistance:x,minZoom:_,maxZoom:g,onCanvasClick:b,disabled:E,onLasso:S,onLassoEnd:w,aggregateEdges:T,...R},U)=>{const A=K.useRef(null),D=K.useRef(null),L=K.useRef(null);K.useImperativeHandle(U,()=>({centerGraph:(B,G)=>A.current?.centerGraph(B,G),fitNodesInView:(B,G)=>A.current?.fitNodesInView(B,G),zoomIn:()=>{const B=D.current?.controls;if(!B)return;const G=B.distance,X=B.camera.zoom,k=X+X/2,Y=G/k;(!v||Y>=v)&&D.current?.zoomIn()},zoomOut:()=>{const B=D.current?.controls;if(!B)return;const G=B.distance,X=B.camera.zoom,k=X-X/2,Y=G/k;(!x||Y<=x)&&D.current?.zoomOut()},dollyIn:B=>D.current?.dollyIn(B),dollyOut:B=>D.current?.dollyOut(B),panLeft:()=>D.current?.panLeft(),panRight:()=>D.current?.panRight(),panDown:()=>D.current?.panDown(),panUp:()=>D.current?.panUp(),resetControls:B=>D.current?.resetControls(B),getControls:()=>D.current?.controls,getGraph:()=>A.current?.graph,exportCanvas:()=>(A.current.renderScene(),L.current.toDataURL()),freeze:()=>D.current?.freeze(),unFreeze:()=>D.current?.unFreeze()}));const{selections:P,actives:I,collapsedNodeIds:V}=R,H=d.length+m.length>400?!1:s,z=K.useMemo(()=>({...h,...mX}),[h]),O=K.useRef(RD({selections:P,actives:I,theme:r,collapsedNodeIds:V})).current;return K.useEffect(()=>{O.getState().setTheme(r)},[r,O]),he.jsx("div",{className:pX.canvas,children:he.jsx(L5,{orthographic:i==="orthographic",legacy:!0,linear:!0,ref:L,flat:!0,gl:z,camera:gX,onPointerMissed:b,children:he.jsxs(wW,{store:O,children:[r.canvas?.background&&he.jsx("color",{attach:"background",args:[r.canvas.background]}),he.jsx("ambientLight",{intensity:1}),p,r.canvas?.fog&&he.jsx("fog",{attach:"fog",args:[r.canvas.fog,4e3,9e3]}),he.jsx(TW,{mode:i,ref:D,disabled:E,minDistance:v,maxDistance:x,minZoom:_,maxZoom:g,animated:s,children:he.jsx(fX,{disabled:E,type:c,onLasso:S,onLassoEnd:w,children:he.jsx(K.Suspense,{children:he.jsx(uX,{ref:A,disabled:E,animated:H,edges:d,nodes:m,layoutType:e,sizingType:t,labelType:n,defaultNodeSize:a,minNodeSize:o,maxNodeSize:l,aggregateEdges:T,...R})})})})]})})})}),yX=({selections:i=[],nodes:e=[],actives:t=[],focusOnSelect:n=!0,type:r="single",pathHoverType:s="out",pathSelectionType:a="direct",ref:o,disabled:l,onSelection:c})=>{const[h,d]=K.useState([]),[p,m]=K.useState(t),[v,x]=K.useState(i),[_,g]=K.useState(!1),b=r==="multi"||r==="multiModifier",E=K.useCallback(O=>{if(!l&&O){O=Array.isArray(O)?O:[O];const B=O.filter(G=>!v.includes(G));if(B.length){const G=[...v,...B];c?.(G),x(G)}}},[l,v,c]),S=K.useCallback(O=>{if(!l&&O){O=Array.isArray(O)?O:[O];const B=v.filter(G=>!O.includes(G));c?.(B),x(B)}},[l,v,c]),w=K.useCallback((O=[])=>{l||(O=Array.isArray(O)?O:[O],m([]),x(O),c?.(O))},[l,c]),T=K.useCallback(O=>{v.includes(O)?S(O):b?E(O):w(O)},[E,w,v,b,S]),R=K.useCallback(O=>{if(b?r==="multiModifier"?_?E(O.id):w(O.id):E(O.id):w(O.id),n===!0||n==="singleOnly"&&!_){if(!o.current)throw new Error("No ref found for the graph canvas.");const B=o.current.getGraph(),{nodes:G}=G_(B,[O.id],a);o.current.fitNodesInView([O.id,...G],{fitOnlyIfNodesNotInView:!0})}},[E,w,n,b,_,a,o,r]),U=K.useCallback((O,B)=>{const G=o.current.getGraph();if(!G)throw new Error("Graph is not initialized");const X=bW(G,O,B);w([O,B]);const k=[];for(let Y=0;Y<X.length-1;Y++){const Q=X[Y],te=X[Y+1],ee=G.getEdgeAttributes(Q,te);ee&&k.push(ee.id)}m([...X.map(Y=>Y),...k])},[w,o]),A=K.useCallback(O=>{const B=O.target,G=rA(B),X=O.metaKey||O.ctrlKey;G&&X&&g(!0)},[]),D=K.useCallback(O=>{const B=O.target,G=rA(B),X=["Meta","Control"].includes(O.key);G&&X&&g(!1)},[]);K.useEffect(()=>(typeof window<"u"&&(window.addEventListener("keydown",A),window.addEventListener("keyup",D)),()=>{typeof window<"u"&&(window.removeEventListener("keydown",A),window.removeEventListener("keyup",D))}),[A,D]);const L=K.useCallback(O=>{if(O.button!==2&&(v.length||p.length)&&(w(),g(!1),n&&v.length===1)){if(!o.current)throw new Error("No ref found for the graph canvas.");o.current.fitNodesInView([],{fitOnlyIfNodesNotInView:!0})}},[w,n,p.length,v.length,o]),P=K.useCallback(O=>{m(O)},[]),I=K.useCallback(O=>{w(O)},[w]),V=K.useCallback(O=>{if(s){const B=o.current.getGraph();if(!B)throw new Error("No ref found for the graph canvas.");const{nodes:G,edges:X}=G_(B,[O.id],s);d([...G,...X])}},[s,o]),H=K.useCallback(()=>{s&&d([])},[s]);return K.useEffect(()=>{if(a!=="direct"&&v.length>0){const O=o.current?.getGraph();if(O){const{nodes:B,edges:G}=G_(O,v,a);m([...B,...G])}}},[v,a,o]),{actives:K.useMemo(()=>[...p,...h],[p,h]),onNodeClick:R,onNodePointerOver:V,onNodePointerOut:H,onLasso:P,onLassoEnd:I,selectNodePaths:U,onCanvasClick:L,selections:v,clearSelections:w,addSelection:E,removeSelection:S,toggleSelection:T,setSelections:x}},_X=""+new URL("NotoSans-Regular-D96CXwz4.ttf",import.meta.url).href,xX=K.memo(({data:i,onCollapse:e,isCollapsed:t,canCollapse:n,onClose:r})=>{const{t:s}=wg(["network","zigbee","common"]);let a;if(i.parent){const o=i.parent.lastIndexOf(` - ${s(l=>l.children)}`);a=o>-1?i.parent.slice(0,o):i.parent}return he.jsx("div",{className:"card bg-base-100 card-border border-base-300 shadow-md",children:he.jsxs("div",{className:"card-body",children:[he.jsx("h2",{className:"card-title",children:i.friendlyName}),he.jsx("span",{children:i.type}),he.jsx("span",{title:s(o=>o.ieee_address,{ns:"zigbee"}),children:i.ieeeAddr}),he.jsxs("span",{title:s(o=>o.network_address_hex,{ns:"zigbee"}),className:"justify-self-end",children:[GU(i.networkAddress,4)," | ",he.jsx("span",{title:s(o=>o.network_address_dec,{ns:"zigbee"}),children:i.networkAddress})]}),a&&he.jsxs("span",{children:[s(o=>o.parent),": ",a]}),i.failed&&i.failed.length>0&&he.jsxs("div",{className:"badge badge-ghost",children:[he.jsx(Yn,{icon:HU,className:"text-error",beatFade:!0}),s(o=>o.failed,{ns:"common"}),": ",i.failed]}),he.jsxs("div",{className:"card-actions justify-end mt-2",children:[n&&he.jsx(Lr,{className:"btn btn-square btn-primary",onClick:e,children:he.jsx(Yn,{icon:t?VU:WU})}),he.jsx(Lr,{className:"btn btn-square btn-neutral",onClick:r,children:he.jsx(Yn,{icon:XU})})]})]})})}),mA=K.memo(i=>{const{label:e,icon:t,onChange:n,onSubmit:r,defaultValue:s,...a}=i,[o,l]=K.useState(s);K.useEffect(()=>{l(s)},[s]);const c=K.useCallback(d=>{l(d.target.value?d.target.valueAsNumber:""),n?.(d)},[n]),h=K.useCallback(d=>{r?.(o,!d.target.validationMessage)},[r,o]);return he.jsxs("div",{className:"flex flex-row flex-wrap items-center gap-2 bg-base-100 rounded-box px-2 pb-1",title:e,children:[he.jsx(Yn,{icon:t}),he.jsxs("div",{children:[he.jsx("input",{className:"range range-xs",onChange:c,onTouchEnd:h,onMouseUp:h,onKeyUp:h,...a,type:"range",value:o}),he.jsxs("div",{className:"flex justify-between px-1 mt-1 text-xs",children:[he.jsx("span",{children:i.min}),he.jsx("span",{children:o}),he.jsx("span",{children:i.max})]})]})]})}),bX=K.memo(({graphRef:i,config:e,setConfig:t,nodes:n,showParents:r,setShowParents:s,showChildren:a,setShowChildren:o,showSiblings:l,setShowSiblings:c})=>{const{t:h}=wg(["network","common"]),d=K.useMemo(()=>{const v=n.map(x=>[x.id,x.data.type!=="Coordinator"?`${x.data.type[0]} - ${x.label}`:x.label]);return v.sort(([,x],[,_])=>x.localeCompare(_)),v.map(([x,_])=>he.jsx("option",{value:x,children:_},x))},[n]),p=K.useCallback(()=>{i.current&&jU(i.current.exportCanvas(),`network-map-${Date.now()}.png`)},[i]),m=K.useCallback(v=>{if(v.target.value){const x=[v.target.value];i.current?.centerGraph(x),i.current?.fitNodesInView(x)}},[i]);return he.jsxs(he.Fragment,{children:[he.jsxs("div",{className:"absolute z-9 top-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-start max-w-[calc(100vw-19rem)] md:max-w-none",children:[he.jsx(Lr,{title:h(v=>v.download_image),className:"btn btn-square btn-neutral btn-sm tooltip-right",onClick:p,children:he.jsx(Yn,{icon:qU})}),he.jsx(Lr,{title:h(v=>v.reset_controls),className:"btn btn-square btn-neutral btn-sm tooltip-right",onClick:()=>{i.current?.resetControls()},children:he.jsx(Yn,{icon:YU})}),he.jsx(Lr,{title:h(v=>v.fit_view),className:"btn btn-square btn-neutral btn-sm tooltip-bottom",onClick:()=>{i.current?.centerGraph(),i.current?.fitNodesInView()},children:he.jsx(Yn,{icon:ZU})}),he.jsx(Lr,{title:h(v=>v.zoom_in),className:"btn btn-square btn-neutral btn-sm tooltip-bottom",onClick:()=>{i.current?.zoomIn()},children:he.jsx(Yn,{icon:KU})}),he.jsx(Lr,{title:h(v=>v.zoom_out),className:"btn btn-square btn-neutral btn-sm tooltip-bottom",onClick:()=>{i.current?.zoomOut()},children:he.jsx(Yn,{icon:JU})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${r?"":"btn-outline"}`,item:!r,onClick:s,title:h(v=>v.parent),children:he.jsx(Yn,{icon:iu,style:{color:_l[hi.NeighborIsParent]}})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${a?"":"btn-outline"}`,item:!a,onClick:o,title:h(v=>v.child),children:he.jsx(Yn,{icon:iu,style:{color:_l[hi.NeighborIsAChild]}})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${l?"":"btn-outline"}`,item:!l,onClick:c,title:h(v=>v.sibling),children:he.jsx(Yn,{icon:iu,style:{color:_l[hi.NeighborIsASibling]}})}),he.jsx(Lr,{className:`btn btn-square btn-neutral btn-sm tooltip-bottom ${e.showIcons?"":"btn-outline"}`,item:!e.showIcons,onClick:v=>t(x=>({...x,showIcons:v})),title:h(v=>v.icons),children:he.jsx(Yn,{icon:QU})}),he.jsxs("select",{className:"select select-sm w-36",defaultValue:"",onChange:m,children:[he.jsx("option",{value:"",children:h(v=>v.find_node)}),d]})]}),he.jsxs("div",{className:"absolute z-9 top-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-start justify-end",children:[he.jsxs("select",{className:"select select-sm w-36",value:e.layoutType,onChange:v=>v.target.value&&t(x=>({...x,layoutType:v.target.value})),children:[he.jsx("option",{value:"",disabled:!0,children:h(v=>v.layout_type)}),he.jsx("option",{value:"forceDirected2d",children:"forceDirected2d"}),he.jsx("option",{value:"forceDirected3d",children:"forceDirected3d"}),he.jsx("option",{value:"radialOut2d",children:"radialOut2d"}),he.jsx("option",{value:"radialOut3d",children:"radialOut3d"}),he.jsx("option",{value:"concentric2d",children:"concentric2d"}),he.jsx("option",{value:"concentric3d",children:"concentric3d"}),he.jsx("option",{value:"circular2d",children:"circular2d"})]}),he.jsxs("select",{className:"select select-sm w-36",value:e.labelType,onChange:v=>v.target.value&&t(x=>({...x,labelType:v.target.value})),children:[he.jsx("option",{value:"",disabled:!0,children:h(v=>v.label_type)}),he.jsx("option",{value:"all",children:"all"}),he.jsx("option",{value:"auto",children:"auto"}),he.jsx("option",{value:"none",children:"none"}),he.jsx("option",{value:"nodes",children:"nodes"}),he.jsx("option",{value:"edges",children:"edges"})]})]}),he.jsxs("div",{className:"absolute z-9 bottom-0 left-0 p-1 flex flex-row flex-wrap gap-1 items-end",children:[he.jsx(mA,{name:"node_strength",label:h(v=>v.node_strength),icon:$U,onSubmit:(v,x)=>x&&typeof v=="number"&&t(_=>({..._,nodeStrength:v})),min:-1e3,max:-100,step:10,defaultValue:e.nodeStrength}),he.jsx(mA,{name:"link_distance",label:h(v=>v.link_distance),icon:eO,onSubmit:(v,x)=>x&&typeof v=="number"&&t(_=>({..._,linkDistance:v})),min:10,max:200,step:5,defaultValue:e.linkDistance})]}),he.jsx("div",{className:"absolute z-9 bottom-0 right-0 p-1 flex flex-row flex-wrap gap-1 items-end justify-end",children:he.jsx(Lr,{title:h(v=>v.scroll_to_top,{ns:"common"}),className:"btn btn-primary btn-square ml-auto tooltip-left",onClick:()=>{window.scrollTo(0,0)},children:he.jsx(Yn,{icon:tO})})})]})}),SX=K.memo(()=>{const{t:i}=wg("network");return he.jsxs("details",{className:"collapse collapse-arrow rounded-b-none",children:[he.jsx("summary",{className:"collapse-title font-semibold",children:i(e=>e.legend)}),he.jsxs("div",{className:"collapse-content text-sm",children:[he.jsxs("div",{className:"flex flex-row flex-wrap gap-3 mb-2",children:[he.jsxs("div",{children:[he.jsxs("p",{children:[i(e=>e.nodes),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:im.Coordinator},children:[he.jsx(Yn,{icon:kv})," Coordinator"]}),he.jsxs("li",{style:{color:im.Router},children:[he.jsx(Yn,{icon:kv})," Router"]}),he.jsxs("li",{style:{color:im.EndDevice},children:[he.jsx(Yn,{icon:kv})," EndDevice"]})]})]}),he.jsxs("div",{children:[he.jsxs("p",{children:[i(e=>e.edges),":"]}),he.jsxs("ul",{className:"list-none list-inside",children:[he.jsxs("li",{style:{color:_l[hi.NeighborIsParent]},children:[he.jsx(Yn,{icon:iu})," ",i(e=>e.parent)]}),he.jsxs("li",{style:{color:_l[hi.NeighborIsAChild]},children:[he.jsx(Yn,{icon:iu})," ",i(e=>e.child)]}),he.jsxs("li",{style:{color:_l[hi.NeighborIsASibling]},children:[he.jsx(Yn,{icon:iu})," ",i(e=>e.sibling)]})]})]})]}),he.jsx("p",{children:i(e=>e.legend_node_siblings)}),he.jsx("p",{children:i(e=>e.legend_node_size)}),he.jsx("p",{children:i(e=>e.legend_node_select)}),he.jsx("p",{children:i(e=>e.legend_node_fold)}),he.jsx("p",{children:i(e=>e.legend_edge_toggle)})]})]})}),GX=K.memo(({sourceIdx:i,map:e})=>{const{t}=wg("network"),n=nO(vA(S=>S.devices[i])),[r,s]=K.useState(qS.get(YS,{layoutType:"forceDirected2d",labelType:"all",nodeStrength:-750,linkDistance:50,showIcons:!1})),[a,o]=K.useState(!0),[l,c]=K.useState(!0),[h,d]=K.useState(!0),p=K.useRef(null);K.useEffect(()=>{qS.set(YS,r)},[r]),K.useEffect(()=>{p.current&&(p.current.resetControls(),p.current.centerGraph(),p.current.fitNodesInView())},[r.layoutType]);const m=K.useMemo(()=>{const S=new OffscreenCanvas(1,1).getContext("2d"),w=getComputedStyle(document.documentElement),T=fh(S,w.getPropertyValue("--color-base-100")),R=fh(S,w.getPropertyValue("--color-base-200")),U=fh(S,w.getPropertyValue("--color-base-content")),A=fh(S,w.getPropertyValue("--color-primary")),D=fh(S,w.getPropertyValue("--color-accent"));return iO({},FD,{canvas:{background:T},node:{activeFill:D,label:{color:U,stroke:R,activeColor:D},subLabel:{color:U,stroke:"transparent",activeColor:D}},lasso:{border:`1px solid ${A}`,background:"rgba(75, 160, 255, 0.1)"},ring:{fill:U,activeFill:D},edge:{fill:U,activeFill:D,label:{stroke:R,color:U,activeColor:D},subLabel:{color:U,stroke:"transparent",activeColor:D}},arrow:{fill:U,activeFill:D},cluster:{stroke:U,label:{stroke:R,color:U}}})},[]),[v,x]=K.useMemo(()=>{const S=[],w=[],T=[];for(const A of e.nodes){const D=n.find(V=>V.ieee_address===A.ieeeAddr),L=e.links.find(V=>V.relationship===hi.NeighborIsParent&&V.target.ieeeAddr===A.ieeeAddr);let P=L?e.nodes.find(V=>V.ieeeAddr===L.source.ieeeAddr)?.friendlyName:void 0;if(!L){const V=e.links.find(H=>H.relationship===hi.NeighborIsAChild&&H.source.ieeeAddr===A.ieeeAddr);P=V?e.nodes.find(H=>H.ieeeAddr===V.target.ieeeAddr)?.friendlyName:void 0,P&&(P+=` - ${t(H=>H.children)}`)}let I;r.showIcons&&D&&(I=D.definition?.icon??rO(D),I===sO&&(I=void 0)),S.push({id:A.ieeeAddr,data:{...A,parent:P},label:A.friendlyName,labelVisible:!0,fill:im[A.type],icon:I})}const R=new Map;for(const A of e.links){if(!a&&A.relationship===hi.NeighborIsParent||!l&&A.relationship===hi.NeighborIsAChild||!h&&A.relationship===hi.NeighborIsASibling)continue;if(A.relationship===hi.NeighborIsASibling){const L=R.get(A.source.ieeeAddr);(!L||A.depth<L.depth||A.lqi>L.lqi||L.lqi===A.lqi&&A.depth<L.depth)&&R.set(A.source.ieeeAddr,A);continue}const D=e.links.find(L=>L.source.ieeeAddr===A.target.ieeeAddr&&L.target.ieeeAddr===A.source.ieeeAddr);A.relationship===hi.NeighborIsAChild&&D?.relationship===hi.NeighborIsParent||T.push([A,D])}for(const[,A]of R){const D=e.links.find(L=>L.source.ieeeAddr===A.target.ieeeAddr&&L.target.ieeeAddr===A.source.ieeeAddr);T.push([A,D])}const U=[];for(const[A,D]of T)U.includes(A)||A.relationship===hi.NeighborIsASibling&&(D?.relationship===hi.NeighborIsParent||D?.relationship===hi.NeighborIsAChild)||w.push({id:`${A.source.ieeeAddr}-${A.target.ieeeAddr}-${A.relationship}`,data:A,label:D?`${A.lqi} / ${D.lqi??"?"}`:`${A.lqi}`,size:A.relationship===hi.NoneOfTheAbove?.5:1,labelVisible:!0,source:A.source.ieeeAddr,target:A.target.ieeeAddr,fill:_l[A.relationship]});return[S,w]},[e,a,l,h,t,n,r.showIcons]),{selections:_,actives:g,onNodeClick:b,onCanvasClick:E}=yX({ref:p,nodes:v,type:"single",pathSelectionType:"out",focusOnSelect:!1});return he.jsxs(he.Fragment,{children:[he.jsx(SX,{}),he.jsxs("div",{className:"relative h-screen z-6",children:[he.jsx(bX,{graphRef:p,config:r,setConfig:s,nodes:v,showParents:a,setShowParents:o,showChildren:l,setShowChildren:c,showSiblings:h,setShowSiblings:d}),he.jsx(vX,{ref:p,theme:m,nodes:v,edges:x,clusterAttribute:r.layoutType.startsWith("forceDirected")?"parent":void 0,selections:_,actives:g,onCanvasClick:E,onNodeClick:b,layoutType:r.layoutType,layoutOverrides:{nodeStrength:r.nodeStrength,linkDistance:r.linkDistance},sizingType:"centrality",labelType:r.labelType,labelFontUrl:_X,edgeLabelPosition:"natural",lassoType:"node",cameraMode:r.layoutType.endsWith("3d")?"rotate":"pan",draggable:!0,animated:!1,contextMenu:({data:{data:S},onCollapse:w,isCollapsed:T,canCollapse:R,onClose:U})=>S.friendlyName?he.jsx(xX,{data:S,onCollapse:w,isCollapsed:T,canCollapse:R,onClose:U}):null})]})]})});export{GX as default};