clipoox-render 0.2.0 → 0.3.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 (131) hide show
  1. package/dist/server-text/titleRaster.js +1394 -0
  2. package/package.json +5 -3
  3. package/scripts/render-local.mjs +1514 -1379
  4. package/shared/transitionStarterPack.json +261 -0
  5. package/web/assets/{FxEmbed-BymBArNa.js → FxEmbed-D7k1ThAF.js} +1 -1
  6. package/web/assets/{GLTFLoader-Dy6SrZg8.js → GLTFLoader-BHWu1lKg.js} +1 -1
  7. package/web/assets/{MotionEmbed-PmXWSWe5.js → MotionEmbed-DFni5IAh.js} +1 -1
  8. package/web/assets/PluginStore-BrupM_8E.js +3 -0
  9. package/web/assets/{ShotComposer-Dprx-Yi7.js → ShotComposer-BLztjSKy.js} +4 -4
  10. package/web/assets/TemplateEmbed-BbAimhLj.js +2 -0
  11. package/web/assets/TimelinePlugins-BI1bE9pX.js +5 -0
  12. package/web/assets/TimelinePlugins-DYarX9RK.css +1 -0
  13. package/web/assets/TimelineShotFx-CQN3WIfN.js +2 -0
  14. package/web/assets/TransitionEmbed-CmoIrHVr.js +1 -0
  15. package/web/assets/{Whiteboard-DybaKCdo.js → Whiteboard-DMk0unYK.js} +3 -3
  16. package/web/assets/aerial-DT_gUtSh.js +2 -0
  17. package/web/assets/{agentTools-CxZqRLeR.js → agentTools-qOww5RUs.js} +2 -2
  18. package/web/assets/analyzerRun-B2FLUp4G.js +1 -0
  19. package/web/assets/{analyzerSandbox-DO5ZTv5q.js → analyzerSandbox-CJVsEhrg.js} +2 -2
  20. package/web/assets/{api-BsKbf3l3.js → api-QBI5GJTZ.js} +148 -148
  21. package/web/assets/auraTrack-CEs_Q9EP.js +1 -0
  22. package/web/assets/{breakthrough-Dv1bndQb.js → breakthrough-DvkxvNK9.js} +2 -2
  23. package/web/assets/{cameraPresets-B234aNzE.js → cameraPresets-4pFeF2YG.js} +1 -1
  24. package/web/assets/{captionLayout-CNgb471H.js → captionLayout-C67EMVI1.js} +1 -1
  25. package/web/assets/{clientExport-NtJmxOYP.js → clientExport-C4VgAJtO.js} +1 -1
  26. package/web/assets/{depthEstimate-wVYSJtW8.js → depthEstimate-mnXDZMW-.js} +1 -1
  27. package/web/assets/{directorTools-BqFcShgT.js → directorTools-BOHZjcww.js} +1 -1
  28. package/web/assets/{distortFrames-D3TQNcJA.js → distortFrames-Csuj2jHE.js} +2 -2
  29. package/web/assets/{distortGL-BklPDXPq.js → distortGL-BaXfN0IK.js} +2 -2
  30. package/web/assets/{editTools-BQlG5WB_.js → editTools-m0VGPmfF.js} +1 -1
  31. package/web/assets/{exportEncode-CaKEPgsy.js → exportEncode-D9OT7_5k.js} +1 -1
  32. package/web/assets/{exportGlb-DstxwzH5.js → exportGlb-CLfTnbMG.js} +1 -1
  33. package/web/assets/faceTracker-W0iZSiMe.js +1 -0
  34. package/web/assets/fightDirector-CECPf2iH.js +1 -0
  35. package/web/assets/{fightDrama-G7bXfpQu.js → fightDrama-CqNoa5XI.js} +2 -2
  36. package/web/assets/{frameSink-Dj71jCRb.js → frameSink-BGRj7wqY.js} +3 -3
  37. package/web/assets/{gpuCompose-DIxBHlTa.js → gpuCompose-CIEoLFem.js} +1 -1
  38. package/web/assets/gpuExport-uyOAyrhm.js +190 -0
  39. package/web/assets/handMatte-mHxZwLZD.js +1 -0
  40. package/web/assets/handTracker-dTVeSUzt.js +2 -0
  41. package/web/assets/{index-CZn97Ygs.js → index-D7M5t2re.js} +1 -1
  42. package/web/assets/layer-worker-Cp0pjurp.js +5 -0
  43. package/web/assets/library-Dsz_MLyd.js +1 -0
  44. package/web/assets/{lottieLayer-CfUPParC.js → lottieLayer-CDCGeJyv.js} +5 -5
  45. package/web/assets/{lottie_light_canvas-7iv3btPX.js → lottie_light_canvas-BblLU4nU.js} +1 -1
  46. package/web/assets/main-BQ8IY0WV.css +1 -0
  47. package/web/assets/{main-M1vRa-gd.js → main-CVRIuDW2.js} +76 -76
  48. package/web/assets/{mapBake-lPNhNZgv.js → mapBake-CNMOKXA7.js} +1 -1
  49. package/web/assets/maskTrack-Dtv6Jr06.js +1 -0
  50. package/web/assets/matteFixRun-BLDH2AjH.js +1 -0
  51. package/web/assets/{objectLocate-BDqfSo9J.js → objectLocate-Cy3IFBSF.js} +1 -1
  52. package/web/assets/{objectTrack.worker-ENzKeSiV.js → objectTrack.worker-BlZkgpOX.js} +483 -352
  53. package/web/assets/pendingMatte-C2AWApuv.js +2 -0
  54. package/web/assets/personAi-DPUnoymj.js +2 -0
  55. package/web/assets/plateCamera-C96L5GKm.js +1 -0
  56. package/web/assets/{plateCameraMatch-D41LQrsm.js → plateCameraMatch-Chk-ZjDi.js} +2 -2
  57. package/web/assets/{plateFollow-CNfi4xuP.js → plateFollow-B9_QTgvo.js} +2 -2
  58. package/web/assets/plateMatte-BiqyI_8x.js +2 -0
  59. package/web/assets/{pluginAutomation-BtQ_w2TB.js → pluginAutomation-5DYldFrb.js} +1 -1
  60. package/web/assets/poseTracker-PuI8vWpR.js +1 -0
  61. package/web/assets/{productTools-r2RgILaA.js → productTools-B1h5cgyt.js} +2 -2
  62. package/web/assets/remote-BJdzzFZg.js +1241 -0
  63. package/web/assets/{rigTrack-Bx9QHlFv.js → rigTrack-CUt4O67J.js} +1 -1
  64. package/web/assets/{rotoMaskStore-pxpRt5Cj.js → rotoMaskStore-DIi45swK.js} +1 -1
  65. package/web/assets/{rotoMatte-DyXlW4jK.js → rotoMatte-013RKqHu.js} +1 -1
  66. package/web/assets/{rotoscope-GORCSVBr.js → rotoscope-d_TUxa-J.js} +1 -1
  67. package/web/assets/{sceneTrack.worker-CEvCN5OB.js → sceneTrack.worker-CT4uoTKn.js} +475 -344
  68. package/web/assets/{shot-worker-B8JWkmBz.js → shot-worker-B1iZT6F5.js} +1 -1
  69. package/web/assets/{shotFxAgent-CzHfe75S.js → shotFxAgent-BDfe73TP.js} +2 -2
  70. package/web/assets/{skin-BkaT2QuX.js → skin-GDY3QPkV.js} +1 -1
  71. package/web/assets/{spark.module-BRT8yMS4.js → spark.module-DdwuJ_hb.js} +1 -1
  72. package/web/assets/{spellDuel-BUy289OT.js → spellDuel-DjNN00bv.js} +2 -2
  73. package/web/assets/{store-BSSbvpzr.js → store-2zneEhhu.js} +1 -1
  74. package/web/assets/{surfaceLight-CMaBhZ_d.js → surfaceLight-B_SYg_f8.js} +1 -1
  75. package/web/assets/surfacePin-zDPmq-hH.js +2 -0
  76. package/web/assets/{textAnimators-Cihw35O8.js → textAnimators-Bdt5LWXk.js} +1 -1
  77. package/web/assets/{thumb-Cs636sYt.js → thumb-byAKvhQP.js} +1 -1
  78. package/web/assets/timeline3d-YIIk_Kn2.js +2 -0
  79. package/web/assets/timeline3dExport-CEH1RjNf.js +1 -0
  80. package/web/assets/{timelineComp-CRRzLazc.js → timelineComp-B73i_8vD.js} +1 -1
  81. package/web/assets/{timelineProps-tN2YsMYN.js → timelineProps-B2pnudeT.js} +1 -1
  82. package/web/assets/{timelineText-CkoUgWcY.js → timelineText-BcL4Pw3C.js} +1 -1
  83. package/web/assets/{titleArt-CcTdJuOC.js → titleArt-hb_T45WJ.js} +5 -5
  84. package/web/assets/{titleFrameBudget-3MFHWIT6.js → titleFrameBudget-Cml-MO53.js} +970 -839
  85. package/web/assets/titleFrames-Dw0PEBdV.js +1 -0
  86. package/web/assets/{tool-BhIsq238.js → tool-Bt9bclIf.js} +1 -1
  87. package/web/assets/{tools-DMUnabc_.js → tools-BXeJbgZJ.js} +1 -1
  88. package/web/assets/{toonTools-CICrV3QB.js → toonTools-u7Y9fdEZ.js} +2 -2
  89. package/web/assets/trackAnchor-9MnVHe4S.js +1 -0
  90. package/web/assets/{userFonts-BZ4QL-zq.js → userFonts-BHduCNtc.js} +1 -1
  91. package/web/assets/{vfxAlpha-D3Dk1tfF.js → vfxAlpha-DpV4rbI-.js} +1 -1
  92. package/web/assets/vfxBackground-Ddviync5.js +2 -0
  93. package/web/assets/{videoExport-l5MGvMn_.js → videoExport-z5WjM0hw.js} +1 -1
  94. package/web/assets/{views-BdWnG2xK.js → views-CsrYzCSR.js} +1 -1
  95. package/web/assets/weaponDuel-CLLgv5A4.js +1 -0
  96. package/web/assets/{windowFrames-CoIyWqxr.js → windowFrames-BQEWQkEs.js} +1 -1
  97. package/web/layer-worker.html +3 -3
  98. package/web/assets/PluginStore-BVsm6n6N.js +0 -3
  99. package/web/assets/TemplateEmbed-CrZXoUk_.js +0 -2
  100. package/web/assets/TimelinePlugins-B1KGtbmb.js +0 -5
  101. package/web/assets/TimelinePlugins-B5WmAawO.css +0 -1
  102. package/web/assets/TimelineShotFx-DoLx312Y.js +0 -2
  103. package/web/assets/TransitionEmbed-C5SUosv2.js +0 -1
  104. package/web/assets/aerial-DSt_mJNA.js +0 -2
  105. package/web/assets/analyzerRun-DCJwb_-Z.js +0 -1
  106. package/web/assets/auraTrack-QR0WqBHp.js +0 -1
  107. package/web/assets/desktop-BWhFnYwd.js +0 -1
  108. package/web/assets/faceTracker-DWxxieVC.js +0 -1
  109. package/web/assets/fightDirector-OMlPZgjv.js +0 -1
  110. package/web/assets/gpuExport-CPSw_dmq.js +0 -189
  111. package/web/assets/handMatte-DHsHHz4m.js +0 -1
  112. package/web/assets/handTracker-D_O-C4Dw.js +0 -2
  113. package/web/assets/layer-worker-Bar7WgOA.js +0 -5
  114. package/web/assets/library-BtBrCaFk.js +0 -1
  115. package/web/assets/main-BPmr0TOL.css +0 -1
  116. package/web/assets/maskTrack-D2jUh7aw.js +0 -1
  117. package/web/assets/matteFixRun-B7tWV9Y1.js +0 -1
  118. package/web/assets/pendingMatte-q35zVaiB.js +0 -2
  119. package/web/assets/personAi-ZjQVo-80.js +0 -2
  120. package/web/assets/plateCamera-A2E_WO_x.js +0 -1
  121. package/web/assets/plateMatte-BdIxGhw5.js +0 -2
  122. package/web/assets/poseTracker-DVX__OK7.js +0 -1
  123. package/web/assets/remote-sTZauTqM.js +0 -1220
  124. package/web/assets/surfacePin-DM9b9ubh.js +0 -2
  125. package/web/assets/timeline3d-BEuZZOxM.js +0 -2
  126. package/web/assets/timeline3dExport-CmSI_pjv.js +0 -1
  127. package/web/assets/titleFrames-w-iWje9N.js +0 -1
  128. package/web/assets/trackAnchor-D2bB5mZE.js +0 -1
  129. package/web/assets/vfxBackground-CHlCg8lb.js +0 -2
  130. package/web/assets/vfxTrack-CqiQDEYm.js +0 -1
  131. package/web/assets/weaponDuel-B2wTffPC.js +0 -1
@@ -3996,6 +3996,267 @@
3996
3996
  }
3997
3997
  ]
3998
3998
  }
3999
+ },
4000
+ {
4001
+ "id": "grid-pop",
4002
+ "name": "Lưới ô bật",
4003
+ "category": "Hình",
4004
+ "duration": 0.6,
4005
+ "version": 1,
4006
+ "sortOrder": 1210,
4007
+ "tags": [
4008
+ "grid",
4009
+ "checker",
4010
+ "block",
4011
+ "editorial",
4012
+ "katana",
4013
+ "beat"
4014
+ ],
4015
+ "mask": {
4016
+ "type": "grid",
4017
+ "count": 10,
4018
+ "feather": 0.03
4019
+ }
4020
+ },
4021
+ {
4022
+ "id": "grid-pop-fine",
4023
+ "name": "Lưới ô nhỏ",
4024
+ "category": "Hình",
4025
+ "duration": 0.5,
4026
+ "version": 1,
4027
+ "sortOrder": 1211,
4028
+ "tags": [
4029
+ "grid",
4030
+ "checker",
4031
+ "block",
4032
+ "pixel",
4033
+ "editorial",
4034
+ "katana"
4035
+ ],
4036
+ "mask": {
4037
+ "type": "grid",
4038
+ "count": 18,
4039
+ "feather": 0.03
4040
+ }
4041
+ },
4042
+ {
4043
+ "id": "grid-flash-lime",
4044
+ "name": "Lưới ô loé lime",
4045
+ "category": "Hình",
4046
+ "duration": 0.6,
4047
+ "version": 1,
4048
+ "sortOrder": 1212,
4049
+ "tags": [
4050
+ "grid",
4051
+ "checker",
4052
+ "flash",
4053
+ "lime",
4054
+ "clipoox",
4055
+ "katana",
4056
+ "beat"
4057
+ ],
4058
+ "mask": {
4059
+ "type": "grid",
4060
+ "count": 8,
4061
+ "feather": 0.03
4062
+ },
4063
+ "flash": {
4064
+ "color": "#a3ff00",
4065
+ "opacity": [
4066
+ {
4067
+ "t": 0,
4068
+ "v": 0,
4069
+ "ease": "ease-out"
4070
+ },
4071
+ {
4072
+ "t": 0.4,
4073
+ "v": 0.65,
4074
+ "ease": "ease-in"
4075
+ },
4076
+ {
4077
+ "t": 1,
4078
+ "v": 0
4079
+ }
4080
+ ]
4081
+ }
4082
+ },
4083
+ {
4084
+ "id": "light-streak",
4085
+ "name": "Vệt sáng lướt",
4086
+ "category": "Hiệu ứng",
4087
+ "duration": 0.5,
4088
+ "version": 1,
4089
+ "sortOrder": 1220,
4090
+ "tags": [
4091
+ "light",
4092
+ "streak",
4093
+ "speed",
4094
+ "whoosh",
4095
+ "flare",
4096
+ "katana",
4097
+ "impact"
4098
+ ],
4099
+ "a": {
4100
+ "dirBlur": [
4101
+ {
4102
+ "t": 0,
4103
+ "v": 0,
4104
+ "ease": "expo-in"
4105
+ },
4106
+ {
4107
+ "t": 0.5,
4108
+ "v": 1
4109
+ }
4110
+ ],
4111
+ "exposure": [
4112
+ {
4113
+ "t": 0,
4114
+ "v": 0,
4115
+ "ease": "expo-in"
4116
+ },
4117
+ {
4118
+ "t": 0.5,
4119
+ "v": 0.7
4120
+ }
4121
+ ]
4122
+ },
4123
+ "b": {
4124
+ "dirBlur": [
4125
+ {
4126
+ "t": 0,
4127
+ "v": 1,
4128
+ "ease": "hold"
4129
+ },
4130
+ {
4131
+ "t": 0.5,
4132
+ "v": 1,
4133
+ "ease": "expo-out"
4134
+ },
4135
+ {
4136
+ "t": 1,
4137
+ "v": 0
4138
+ }
4139
+ ],
4140
+ "exposure": [
4141
+ {
4142
+ "t": 0,
4143
+ "v": 0.7,
4144
+ "ease": "hold"
4145
+ },
4146
+ {
4147
+ "t": 0.5,
4148
+ "v": 0.7,
4149
+ "ease": "expo-out"
4150
+ },
4151
+ {
4152
+ "t": 1,
4153
+ "v": 0
4154
+ }
4155
+ ],
4156
+ "opacity": [
4157
+ {
4158
+ "t": 0,
4159
+ "v": 0,
4160
+ "ease": "hold"
4161
+ },
4162
+ {
4163
+ "t": 0.5,
4164
+ "v": 1
4165
+ }
4166
+ ]
4167
+ },
4168
+ "light": {
4169
+ "kind": "flare",
4170
+ "color": "#ffffff",
4171
+ "color2": "#cfe3ff",
4172
+ "cx": 0.5,
4173
+ "cy": 0.5,
4174
+ "opacity": [
4175
+ {
4176
+ "t": 0,
4177
+ "v": 0,
4178
+ "ease": "expo-in"
4179
+ },
4180
+ {
4181
+ "t": 0.5,
4182
+ "v": 1,
4183
+ "ease": "expo-out"
4184
+ },
4185
+ {
4186
+ "t": 1,
4187
+ "v": 0
4188
+ }
4189
+ ]
4190
+ }
4191
+ },
4192
+ {
4193
+ "id": "light-streak-diagonal",
4194
+ "name": "Vệt sáng quét chéo",
4195
+ "category": "Hiệu ứng",
4196
+ "duration": 0.55,
4197
+ "version": 1,
4198
+ "sortOrder": 1221,
4199
+ "tags": [
4200
+ "light",
4201
+ "streak",
4202
+ "diagonal",
4203
+ "sweep",
4204
+ "wipe",
4205
+ "katana"
4206
+ ],
4207
+ "a": {
4208
+ "dirBlur": [
4209
+ {
4210
+ "t": 0,
4211
+ "v": 0,
4212
+ "ease": "ease-in"
4213
+ },
4214
+ {
4215
+ "t": 0.6,
4216
+ "v": 0.8
4217
+ }
4218
+ ]
4219
+ },
4220
+ "b": {
4221
+ "dirBlur": [
4222
+ {
4223
+ "t": 0.3,
4224
+ "v": 0.8,
4225
+ "ease": "expo-out"
4226
+ },
4227
+ {
4228
+ "t": 1,
4229
+ "v": 0
4230
+ }
4231
+ ]
4232
+ },
4233
+ "mask": {
4234
+ "type": "wipe",
4235
+ "angle": -30,
4236
+ "feather": 0.22
4237
+ },
4238
+ "light": {
4239
+ "kind": "leak",
4240
+ "color": "#ffffff",
4241
+ "color2": "#dfe8ff",
4242
+ "angle": -30,
4243
+ "opacity": [
4244
+ {
4245
+ "t": 0,
4246
+ "v": 0,
4247
+ "ease": "ease-out"
4248
+ },
4249
+ {
4250
+ "t": 0.45,
4251
+ "v": 1,
4252
+ "ease": "ease-in"
4253
+ },
4254
+ {
4255
+ "t": 1,
4256
+ "v": 0
4257
+ }
4258
+ ]
4259
+ }
3999
4260
  }
4000
4261
  ]
4001
4262
  }
@@ -1 +1 @@
1
- import{j as d,dp as y,dq as w}from"./remote-sTZauTqM.js";import{r as p}from"./api-BsKbf3l3.js";import{t as b,a as E,d as u}from"./thumb-Cs636sYt.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./titleFrameBudget-3MFHWIT6.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const j=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],x=960,h=540;function F(i){const r=i&&typeof i=="object"?i:{},m=y({...r,name:String(r.name||"preview").slice(0,60),category:r.category||"tu-tien"});let o=5381;for(const l of JSON.stringify(m))o=(o<<5)+o+l.charCodeAt(0)|0;return w({id:(o>>>0).toString(16).padStart(32,"0"),...m})}function D(){const i=p.useRef(null),[r,m]=p.useState(null),[o,l]=p.useState("");return p.useEffect(()=>{const s=(t,a)=>t.source?.postMessage(a,{targetOrigin:t.origin}),c=t=>{if(!j.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const a="id"in t.data?t.data.id:null;let n;try{n=F(t.data.fx)}catch(e){t.data.type==="clipoox-fx-play"&&l(e.message),s(t,{type:"clipoox-fx-error",id:a,error:e.message});return}if(t.data.type==="clipoox-fx-play"){l(""),m(n);return}if(t.data.type==="clipoox-fx-thumb")try{const e=Object.assign(document.createElement("canvas"),{width:480,height:270}),f=e.getContext("2d");if(!f)throw Error("canvas");const g=Number.isFinite(t.data.t)?Math.max(0,Number(t.data.t)):E(n);u(f,n,g,480,270),s(t,{type:"clipoox-fx-thumb",id:a,webp:e.toDataURL("image/webp",.85)})}catch(e){s(t,{type:"clipoox-fx-error",id:a,error:e.message})}};return window.addEventListener("message",c),window.parent?.postMessage({type:"clipoox-fx-ready"},"*"),()=>window.removeEventListener("message",c)},[]),p.useEffect(()=>{const s=i.current,c=s?.getContext("2d");if(!r||!s||!c)return;let t=0;const a=performance.now(),n=b(r),e=()=>{u(c,r,(performance.now()-a)/1e3%n,x,h),t=requestAnimationFrame(e)};return t=requestAnimationFrame(e),()=>cancelAnimationFrame(t)},[r]),d.jsxs("div",{style:{margin:0,background:"#0a0e14",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[d.jsx("canvas",{ref:i,width:x,height:h,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"FX preview"}),o&&d.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,right:8,color:"#ff8080",font:"12px sans-serif"},children:o})]})}export{D as default,F as previewEntry};
1
+ import{j as d,dq as y,dr as w}from"./remote-BJdzzFZg.js";import{r as p}from"./api-QBI5GJTZ.js";import{t as b,a as E,d as u}from"./thumb-byAKvhQP.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./titleFrameBudget-Cml-MO53.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const j=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],x=960,h=540;function F(i){const r=i&&typeof i=="object"?i:{},m=y({...r,name:String(r.name||"preview").slice(0,60),category:r.category||"tu-tien"});let o=5381;for(const l of JSON.stringify(m))o=(o<<5)+o+l.charCodeAt(0)|0;return w({id:(o>>>0).toString(16).padStart(32,"0"),...m})}function D(){const i=p.useRef(null),[r,m]=p.useState(null),[o,l]=p.useState("");return p.useEffect(()=>{const s=(t,a)=>t.source?.postMessage(a,{targetOrigin:t.origin}),c=t=>{if(!j.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const a="id"in t.data?t.data.id:null;let n;try{n=F(t.data.fx)}catch(e){t.data.type==="clipoox-fx-play"&&l(e.message),s(t,{type:"clipoox-fx-error",id:a,error:e.message});return}if(t.data.type==="clipoox-fx-play"){l(""),m(n);return}if(t.data.type==="clipoox-fx-thumb")try{const e=Object.assign(document.createElement("canvas"),{width:480,height:270}),f=e.getContext("2d");if(!f)throw Error("canvas");const g=Number.isFinite(t.data.t)?Math.max(0,Number(t.data.t)):E(n);u(f,n,g,480,270),s(t,{type:"clipoox-fx-thumb",id:a,webp:e.toDataURL("image/webp",.85)})}catch(e){s(t,{type:"clipoox-fx-error",id:a,error:e.message})}};return window.addEventListener("message",c),window.parent?.postMessage({type:"clipoox-fx-ready"},"*"),()=>window.removeEventListener("message",c)},[]),p.useEffect(()=>{const s=i.current,c=s?.getContext("2d");if(!r||!s||!c)return;let t=0;const a=performance.now(),n=b(r),e=()=>{u(c,r,(performance.now()-a)/1e3%n,x,h),t=requestAnimationFrame(e)};return t=requestAnimationFrame(e),()=>cancelAnimationFrame(t)},[r]),d.jsxs("div",{style:{margin:0,background:"#0a0e14",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[d.jsx("canvas",{ref:i,width:x,height:h,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"FX preview"}),o&&d.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,right:8,color:"#ff8080",font:"12px sans-serif"},children:o})]})}export{D as default,F as previewEntry};
@@ -1 +1 @@
1
- import{TrianglesDrawMode as De,TriangleFanDrawMode as ue,TriangleStripDrawMode as Le,BufferAttribute as Q,BufferGeometry as Se,Loader as Ue,LoaderUtils as J,FileLoader as we,MeshPhysicalMaterial as k,Vector2 as Ie,Color as v,LinearSRGBColorSpace as F,SRGBColorSpace as Z,SpotLight as Be,PointLight as Ke,DirectionalLight as je,Matrix4 as ee,InstancedMesh as ze,Vector3 as G,Quaternion as Ne,InstancedBufferAttribute as Ve,Object3D as Oe,TextureLoader as Xe,ImageBitmapLoader as qe,InterleavedBuffer as We,LinearMipmapLinearFilter as Ce,NearestMipmapLinearFilter as Ye,LinearMipmapNearestFilter as Qe,NearestMipmapNearestFilter as Je,LinearFilter as le,NearestFilter as ke,RepeatWrapping as fe,MirroredRepeatWrapping as Ze,ClampToEdgeWrapping as $e,PointsMaterial as et,Material as re,LineBasicMaterial as tt,MeshStandardMaterial as Fe,DoubleSide as nt,MeshBasicMaterial as Y,PropertyBinding as st,SkinnedMesh as rt,Mesh as it,LineSegments as ot,Line as at,LineLoop as ct,Points as ut,Group as ie,PerspectiveCamera as lt,MathUtils as ft,OrthographicCamera as ht,Skeleton as dt,AnimationClip as pt,Bone as mt,InterpolateDiscrete as gt,InterpolateLinear as He,InterleavedBufferAttribute as Tt,Texture as pe,VectorKeyframeTrack as me,NumberKeyframeTrack as ge,QuaternionKeyframeTrack as Te,ColorManagement as Re,FrontSide as Rt,Interpolant as Et,Box3 as xt,Sphere as At}from"./three.module-Bx43vjkH.js";function rn(f,t=!1){const e=f[0].index!==null,s=new Set(Object.keys(f[0].attributes)),n=new Set(Object.keys(f[0].morphAttributes)),r={},i={},u=f[0].morphTargetsRelative,o=new Se;let c=0;for(let a=0;a<f.length;++a){const l=f[a];let h=0;if(e!==(l.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in l.attributes){if(!s.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;r[d]===void 0&&(r[d]=[]),r[d].push(l.attributes[d]),h++}if(h!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". Make sure all geometries have the same number of attributes."),null;if(u!==l.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in l.morphAttributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphAttributes must be consistent throughout all geometries."),null;i[d]===void 0&&(i[d]=[]),i[d].push(l.morphAttributes[d])}if(t){let d;if(e)d=l.index.count;else if(l.attributes.position!==void 0)d=l.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". The geometry must have either an index or a position attribute"),null;o.addGroup(c,d,a),c+=d}}if(e){let a=0;const l=[];for(let h=0;h<f.length;++h){const d=f[h].index;for(let m=0;m<d.count;++m)l.push(d.getX(m)+a);a+=f[h].attributes.position.count}o.setIndex(l)}for(const a in r){const l=Ee(r[a]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" attribute."),null;o.setAttribute(a,l)}for(const a in i){const l=i[a][0].length;if(l!==0){o.morphAttributes=o.morphAttributes||{},o.morphAttributes[a]=[];for(let h=0;h<l;++h){const d=[];for(let T=0;T<i[a].length;++T)d.push(i[a][T][h]);const m=Ee(d);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" morphAttribute."),null;o.morphAttributes[a].push(m)}}}return o}function Ee(f){let t,e,s,n=-1,r=0;for(let c=0;c<f.length;++c){const a=f[c];if(t===void 0&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=a.itemSize),e!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=a.normalized),s!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=a.gpuType),n!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=a.count*e}const i=new t(r),u=new Q(i,e,s);let o=0;for(let c=0;c<f.length;++c){const a=f[c];if(a.isInterleavedBufferAttribute){const l=o/e;for(let h=0,d=a.count;h<d;h++)for(let m=0;m<e;m++){const T=a.getComponent(h,m);u.setComponent(h+l,m,T)}}else i.set(a.array,o);o+=a.count*e}return n!==void 0&&(u.gpuType=n),u}function xe(f,t){if(t===De)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(t===ue||t===Le){let e=f.getIndex();if(e===null){const i=[],u=f.getAttribute("position");if(u!==void 0){for(let o=0;o<u.count;o++)i.push(o);f.setIndex(i),e=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const s=e.count-2,n=[];if(t===ue)for(let i=1;i<=s;i++)n.push(e.getX(0)),n.push(e.getX(i)),n.push(e.getX(i+1));else for(let i=0;i<s;i++)i%2===0?(n.push(e.getX(i)),n.push(e.getX(i+1)),n.push(e.getX(i+2))):(n.push(e.getX(i+2)),n.push(e.getX(i+1)),n.push(e.getX(i)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=f.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),f}function on(f,t=Math.PI/3){const e=f.index?f.toNonIndexed():f,s=e.attributes.position,n=s.count;let r;if(s.isBufferAttribute===!0&&s.itemSize===3&&s.normalized===!1)r=s.array;else{r=new Float64Array(n*3);for(let p=0;p<n;p++)r[3*p+0]=s.getX(p),r[3*p+1]=s.getY(p),r[3*p+2]=s.getZ(p)}const i=Math.cos(t),u=(1+1e-10)*100,o=n/3,c=new Float64Array(o*3);for(let p=0;p<o;p++){const x=9*p,L=r[x+0],_=r[x+1],w=r[x+2],M=r[x+3],S=r[x+4],I=r[x+5],O=r[x+6],D=r[x+7],U=r[x+8],B=O-M,K=D-S,$=U-I,j=L-M,X=_-S,q=w-I,z=K*q-$*X,te=$*j-B*q,ne=B*X-K*j,se=1/(Math.sqrt(z*z+te*te+ne*ne)||1);c[3*p+0]=z*se,c[3*p+1]=te*se,c[3*p+2]=ne*se}const a=new Int32Array(n),l=new Int32Array(n*3);let h=1;for(;h<n*2;)h<<=1;const d=h-1,m=new Int32Array(h);let T=0;for(let p=0;p<n;p++){const x=3*p,L=~~(r[x+0]*u),_=~~(r[x+1]*u),w=~~(r[x+2]*u);let M=(Math.imul(L,73856093)^Math.imul(_,19349663)^Math.imul(w,83492791))&d;for(;;){const S=m[M];if(S===0){const O=3*T;l[O+0]=L,l[O+1]=_,l[O+2]=w,m[M]=T+1,a[p]=T++;break}const I=3*(S-1);if(l[I+0]===L&&l[I+1]===_&&l[I+2]===w){a[p]=S-1;break}M=M+1&d}}const g=new Int32Array(T+1);for(let p=0;p<n;p++)g[a[p]+1]++;for(let p=0;p<T;p++)g[p+1]+=g[p];const R=new Int32Array(n),y=g.slice(0,T);for(let p=0;p<o;p++){const x=3*p;R[y[a[x+0]]++]=p,R[y[a[x+1]]++]=p,R[y[a[x+2]]++]=p}const A=new Float32Array(n*3);for(let p=0;p<o;p++){const x=3*p,L=c[x+0],_=c[x+1],w=c[x+2];for(let M=0;M<3;M++){const S=x+M,I=a[S];let O=0,D=0,U=0;for(let K=g[I],$=g[I+1];K<$;K++){const j=3*R[K],X=c[j+0],q=c[j+1],z=c[j+2];L*X+_*q+w*z>i&&(O+=X,D+=q,U+=z)}const B=1/(Math.sqrt(O*O+D*D+U*U)||1);A[3*S+0]=O*B,A[3*S+1]=D*B,A[3*S+2]=U*B}}return e.setAttribute("normal",new Q(A,3,!1)),e}function yt(f){const t=new Map,e=new Map,s=f.clone();return Pe(f,s,function(n,r){t.set(r,n),e.set(n,r)}),s.traverse(function(n){if(!n.isSkinnedMesh)return;const r=n,i=t.get(n),u=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=u.map(function(o){return e.get(o)}),r.bind(r.skeleton,r.bindMatrix)}),s}function Pe(f,t,e){e(f,t);for(let s=0;s<f.children.length;s++)Pe(f.children[s],t.children[s],e)}class bt extends Ue{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new wt(e)}),this.register(function(e){return new It(e)}),this.register(function(e){return new vt(e)}),this.register(function(e){return new Dt(e)}),this.register(function(e){return new Ut(e)}),this.register(function(e){return new Ot(e)}),this.register(function(e){return new Ct(e)}),this.register(function(e){return new kt(e)}),this.register(function(e){return new Ft(e)}),this.register(function(e){return new St(e)}),this.register(function(e){return new Ht(e)}),this.register(function(e){return new Nt(e)}),this.register(function(e){return new Gt(e)}),this.register(function(e){return new Pt(e)}),this.register(function(e){return new Mt(e)}),this.register(function(e){return new Ae(e,E.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new Ae(e,E.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Bt(e)})}load(t,e,s,n){const r=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const c=J.extractUrlBase(t);i=J.resolveURL(c,this.path)}else i=J.extractUrlBase(t);this.manager.itemStart(t);const u=function(c){n?n(c):console.error(c),r.manager.itemError(t),r.manager.itemEnd(t)},o=new we(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{r.parse(c,i,function(a){e(a),r.manager.itemEnd(t)},u)}catch(a){u(a)}},s,u)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let r;const i={},u={},o=new TextDecoder;if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===Ge){try{i[E.KHR_BINARY_GLTF]=new Kt(t)}catch(l){n&&n(l);return}r=JSON.parse(i[E.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t));else r=t;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new tn(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let a=0;a<this.pluginCallbacks.length;a++){const l=this.pluginCallbacks[a](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),u[l.name]=l,i[l.name]=!0}if(r.extensionsUsed)for(let a=0;a<r.extensionsUsed.length;++a){const l=r.extensionsUsed[a],h=r.extensionsRequired||[];switch(l){case E.KHR_MATERIALS_UNLIT:i[l]=new Lt;break;case E.KHR_DRACO_MESH_COMPRESSION:i[l]=new jt(r,this.dracoLoader);break;case E.KHR_TEXTURE_TRANSFORM:i[l]=new zt;break;case E.KHR_MESH_QUANTIZATION:i[l]=new Vt;break;default:h.indexOf(l)>=0&&u[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(i),c.setPlugins(u),c.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,r){s.parse(t,e,n,r)})}}function _t(){let f={};return{get:function(t){return f[t]},add:function(t,e){f[t]=e},remove:function(t){delete f[t]},removeAll:function(){f={}}}}function b(f,t,e){const s=f.json.materials[t];return s.extensions&&s.extensions[e]?s.extensions[e]:null}const E={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Mt{constructor(t){this.parser=t,this.name=E.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const r=e[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let n=e.cache.get(s);if(n)return n;const r=e.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let c;const a=new v(16777215);o.color!==void 0&&a.setRGB(o.color[0],o.color[1],o.color[2],F);const l=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new je(a),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Ke(a),c.distance=l;break;case"spot":c=new Be(a),c.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),C(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+t),n=Promise.resolve(c),e.cache.add(s,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,r=s.json.nodes[t],u=(r.extensions&&r.extensions[this.name]||{}).light;return u===void 0?null:this._loadLight(u).then(function(o){return s._getNodeRef(e.cache,u,o)})}}class Lt{constructor(){this.name=E.KHR_MATERIALS_UNLIT}getMaterialType(){return Y}extendParams(t,e,s){const n=[];t.color=new v(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const i=r.baseColorFactor;t.color.setRGB(i[0],i[1],i[2],F),t.opacity=i[3]}r.baseColorTexture!==void 0&&n.push(s.assignTexture(t,"map",r.baseColorTexture,Z))}return Promise.all(n)}}class St{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class wt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const r=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new Ie(r,r)}return Promise.all(n)}}class It{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_DISPERSION}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class Nt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(n)}}class Ot{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_SHEEN}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];if(e.sheenColor=new v(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){const r=s.sheenColorFactor;e.sheenColor.setRGB(r[0],r[1],r[2],F)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(e,"sheenColorMap",s.sheenColorTexture,Z)),s.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(n)}}class Ct{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(n)}}class kt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_VOLUME}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const r=s.attenuationColor||[1,1,1];return e.attenuationColor=new v().setRGB(r[0],r[1],r[2],F),Promise.all(n)}}class Ft{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_IOR}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}}class Ht{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_SPECULAR}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&n.push(this.parser.assignTexture(e,"specularIntensityMap",s.specularTexture));const r=s.specularColorFactor||[1,1,1];return e.specularColor=new v().setRGB(r[0],r[1],r[2],F),s.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(e,"specularColorMap",s.specularColorTexture,Z)),Promise.all(n)}}class Pt{constructor(t){this.parser=t,this.name=E.EXT_MATERIALS_BUMP}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&n.push(this.parser.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(n)}}class Gt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(n)}}class vt{constructor(t){this.parser=t,this.name=E.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],i=e.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,i)}}class Dt{constructor(t){this.parser=t,this.name=E.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,s=this.parser,n=s.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const i=r.extensions[e],u=n.images[i.source];let o=s.textureLoader;if(u.uri){const c=s.options.manager.getHandler(u.uri);c!==null&&(o=c)}return s.loadTextureImage(t,i.source,o)}}class Ut{constructor(t){this.parser=t,this.name=E.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,s=this.parser,n=s.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const i=r.extensions[e],u=n.images[i.source];let o=s.textureLoader;if(u.uri){const c=s.options.manager.getHandler(u.uri);c!==null&&(o=c)}return s.loadTextureImage(t,i.source,o)}}class Ae{constructor(t,e){this.name=e,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(u){const o=n.byteOffset||0,c=n.byteLength||0,a=n.count,l=n.byteStride,h=new Uint8Array(u,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,l,h,n.mode,n.filter).then(function(d){return d.buffer}):i.ready.then(function(){const d=new ArrayBuffer(a*l);return i.decodeGltfBuffer(new Uint8Array(d),a,l,h,n.mode,n.filter),d})})}else return null}}class Bt{constructor(t){this.name=E.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=e.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const i=s.extensions[this.name].attributes,u=[],o={};for(const c in i)u.push(this.parser.getDependency("accessor",i[c]).then(a=>(o[c]=a,o[c])));return u.length<1?null:(u.push(this.parser.createNodeMesh(t)),Promise.all(u).then(c=>{const a=c.pop(),l=a.isGroup?a.children:[a],h=c[0].count,d=[];for(const m of l){const T=new ee,g=new G,R=new Ne,y=new G(1,1,1),A=new ze(m.geometry,m.material,h);for(let p=0;p<h;p++)o.TRANSLATION&&g.fromBufferAttribute(o.TRANSLATION,p),o.ROTATION&&R.fromBufferAttribute(o.ROTATION,p),o.SCALE&&y.fromBufferAttribute(o.SCALE,p),A.setMatrixAt(p,T.compose(g,R,y));for(const p in o)if(p==="_COLOR_0"){const x=o[p];A.instanceColor=new Ve(x.array,x.itemSize,x.normalized)}else p!=="TRANSLATION"&&p!=="ROTATION"&&p!=="SCALE"&&m.geometry.setAttribute(p,o[p]);Oe.prototype.copy.call(A,m),this.parser.assignFinalMaterial(A),d.push(A)}return a.isGroup?(a.clear(),a.add(...d),a):d[0]}))}}const Ge="glTF",W=12,ye={JSON:1313821514,BIN:5130562};class Kt{constructor(t){this.name=E.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,W),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Ge)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-W,r=new DataView(t,W);let i=0;for(;i<n;){const u=r.getUint32(i,!0);i+=4;const o=r.getUint32(i,!0);if(i+=4,o===ye.JSON){const c=new Uint8Array(t,W+i,u);this.content=s.decode(c)}else if(o===ye.BIN){const c=W+i;this.body=t.slice(c,c+u)}i+=u}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class jt{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=E.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,i=t.extensions[this.name].attributes,u={},o={},c={};for(const a in i){const l=he[a]||a.toLowerCase();u[l]=i[a]}for(const a in t.attributes){const l=he[a]||a.toLowerCase();if(i[a]!==void 0){const h=s.accessors[t.attributes[a]],d=V[h.componentType];c[l]=d.name,o[l]=h.normalized===!0}}return e.getDependency("bufferView",r).then(function(a){return new Promise(function(l,h){n.decodeDracoFile(a,function(d){for(const m in d.attributes){const T=d.attributes[m],g=o[m];g!==void 0&&(T.normalized=g)}l(d)},u,c,F,h)})})}}class zt{constructor(){this.name=E.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Vt{constructor(){this.name=E.KHR_MESH_QUANTIZATION}}class ve extends Et{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let i=0;i!==n;i++)e[i]=s[r+i];return e}interpolate_(t,e,s,n){const r=this.resultBuffer,i=this.sampleValues,u=this.valueSize,o=u*2,c=u*3,a=n-e,l=(s-e)/a,h=l*l,d=h*l,m=t*c,T=m-c,g=-2*d+3*h,R=d-h,y=1-g,A=R-h+l;for(let p=0;p!==u;p++){const x=i[T+p+u],L=i[T+p+o]*a,_=i[m+p+u],w=i[m+p]*a;r[p]=y*x+A*L+g*_+R*w}return r}}const Xt=new Ne;class qt extends ve{interpolate_(t,e,s,n){const r=super.interpolate_(t,e,s,n);return Xt.fromArray(r).normalize().toArray(r),r}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},V={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},be={9728:ke,9729:le,9984:Je,9985:Qe,9986:Ye,9987:Ce},_e={33071:$e,33648:Ze,10497:fe},oe={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},he={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Wt={CUBICSPLINE:void 0,LINEAR:He,STEP:gt},ae={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Yt(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new Fe({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Rt})),f.DefaultMaterial}function P(f,t,e){for(const s in e.extensions)f[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function C(f,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(f.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Qt(f,t,e){let s=!1,n=!1,r=!1;for(let c=0,a=t.length;c<a;c++){const l=t[c];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(n=!0),l.COLOR_0!==void 0&&(r=!0),s&&n&&r)break}if(!s&&!n&&!r)return Promise.resolve(f);const i=[],u=[],o=[];for(let c=0,a=t.length;c<a;c++){const l=t[c];if(s){const h=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):f.attributes.position;i.push(h)}if(n){const h=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):f.attributes.normal;u.push(h)}if(r){const h=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(i),Promise.all(u),Promise.all(o)]).then(function(c){const a=c[0],l=c[1],h=c[2];return s&&(f.morphAttributes.position=a),n&&(f.morphAttributes.normal=l),r&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function Jt(f,t){if(f.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)f.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(f.morphTargetInfluences.length===e.length){f.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)f.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Zt(f){let t;const e=f.extensions&&f.extensions[E.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+ce(e.attributes):t=f.indices+":"+ce(f.attributes)+":"+f.mode,f.targets!==void 0)for(let s=0,n=f.targets.length;s<n;s++)t+=":"+ce(f.targets[s]);return t}function ce(f){let t="";const e=Object.keys(f).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+":"+f[e[s]]+";";return t}function de(f){switch(f){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function $t(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const en=new ee;class tn{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new _t,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,r=!1,i=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const u=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(u)===!0;const o=u.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,r=u.indexOf("Firefox")>-1,i=r?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||r&&i<98?this.textureLoader=new Xe(this.options.manager):this.textureLoader=new qe(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new we(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){const u={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:s,userData:{}};return P(r,u,n),C(u,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(u)})).then(function(){for(const o of u.scenes)o.updateMatrixWorld();t(u)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const i=e[n].joints;for(let u=0,o=i.length;u<o;u++)t[i[u]].isBone=!0}for(let n=0,r=t.length;n<r;n++){const i=t[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),r=(i,u)=>{const o=this.associations.get(i);o!=null&&this.associations.set(u,o);for(const[c,a]of i.children.entries())r(a,u.children[c])};return r(s,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const n=t(e[s]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&s.push(r)}return s}getDependency(t,e){const s=t+":"+e;let n=this.cache.get(s);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(r,i){return s.getDependency(t,i)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,i){s.load(J.resolveURL(e.uri,n.path),r,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const n=e.byteLength||0,r=e.byteOffset||0;return s.slice(r,r+n)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const i=oe[n.type],u=V[n.componentType],o=n.normalized===!0,c=new u(n.count*i);return Promise.resolve(new Q(c,i,o))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(i){const u=i[0],o=oe[n.type],c=V[n.componentType],a=c.BYTES_PER_ELEMENT,l=a*o,h=n.byteOffset||0,d=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0;let T,g;if(d&&d!==l){const R=Math.floor(h/d),y="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+R+":"+n.count;let A=e.cache.get(y);A||(T=new c(u,R*d,n.count*d/a),A=new We(T,d/a),e.cache.add(y,A)),g=new Tt(A,o,h%d/a,m)}else u===null?T=new c(n.count*o):T=new c(u,h,n.count*o),g=new Q(T,o,m);if(n.sparse!==void 0){const R=oe.SCALAR,y=V[n.sparse.indices.componentType],A=n.sparse.indices.byteOffset||0,p=n.sparse.values.byteOffset||0,x=new y(i[1],A,n.sparse.count*R),L=new c(i[2],p,n.sparse.count*o);u!==null&&(g=new Q(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let _=0,w=x.length;_<w;_++){const M=x[_];if(g.setX(M,L[_*o]),o>=2&&g.setY(M,L[_*o+1]),o>=3&&g.setZ(M,L[_*o+2]),o>=4&&g.setW(M,L[_*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(t){const e=this.json,s=this.options,r=e.textures[t].source,i=e.images[r];let u=this.textureLoader;if(i.uri){const o=s.manager.getHandler(i.uri);o!==null&&(u=o)}return this.loadTextureImage(t,r,u)}loadTextureImage(t,e,s){const n=this,r=this.json,i=r.textures[t],u=r.images[e],o=(u.uri||u.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(a){a.flipY=!1,a.name=i.name||u.name||"",a.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(a.name=u.uri);const h=(r.samplers||{})[i.sampler]||{};return a.magFilter=be[h.magFilter]||le,a.minFilter=be[h.minFilter]||Ce,a.wrapS=_e[h.wrapS]||fe,a.wrapT=_e[h.wrapT]||fe,a.generateMipmaps=!a.isCompressedTexture&&a.minFilter!==ke&&a.minFilter!==le,n.associations.set(a,{textures:t}),a}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const s=this,n=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());const i=n.images[t],u=self.URL||self.webkitURL;let o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=s.getDependency("bufferView",i.bufferView).then(function(l){c=!0;const h=new Blob([l],{type:i.mimeType});return o=u.createObjectURL(h),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const a=Promise.resolve(o).then(function(l){return new Promise(function(h,d){let m=h;e.isImageBitmapLoader===!0&&(m=function(T){const g=new pe(T);g.needsUpdate=!0,h(g)}),e.load(J.resolveURL(l,r.path),m,void 0,d)})}).then(function(l){return c===!0&&u.revokeObjectURL(o),C(l,i),l.userData.mimeType=i.mimeType||$t(i.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),l});return this.sourceCache[t]=a,a}assignTexture(t,e,s,n){const r=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),r.extensions[E.KHR_TEXTURE_TRANSFORM]){const u=s.extensions!==void 0?s.extensions[E.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const o=r.associations.get(i);i=r.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(i,u),r.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),t[e]=i,i})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,i=e.attributes.normal===void 0;if(t.isPoints){const u="PointsMaterial:"+s.uuid;let o=this.cache.get(u);o||(o=new et,re.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(u,o)),s=o}else if(t.isLine){const u="LineBasicMaterial:"+s.uuid;let o=this.cache.get(u);o||(o=new tt,re.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(u,o)),s=o}if(n||r||i){let u="ClonedMaterial:"+s.uuid+":";n&&(u+="derivative-tangents:"),r&&(u+="vertex-colors:"),i&&(u+="flat-shading:");let o=this.cache.get(u);o||(o=s.clone(),r&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(u,o),this.associations.set(o,this.associations.get(s))),s=o}t.material=s}getMaterialType(){return Fe}loadMaterial(t){const e=this,s=this.json,n=this.extensions,r=s.materials[t];let i;const u={},o=r.extensions||{},c=[];if(o[E.KHR_MATERIALS_UNLIT]){const l=n[E.KHR_MATERIALS_UNLIT];i=l.getMaterialType(),c.push(l.extendParams(u,r,e))}else{const l=r.pbrMetallicRoughness||{};if(u.color=new v(1,1,1),u.opacity=1,Array.isArray(l.baseColorFactor)){const h=l.baseColorFactor;u.color.setRGB(h[0],h[1],h[2],F),u.opacity=h[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(u,"map",l.baseColorTexture,Z)),u.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,u.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(u,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(u,"roughnessMap",l.metallicRoughnessTexture))),i=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(t,u)})))}r.doubleSided===!0&&(u.side=nt);const a=r.alphaMode||ae.OPAQUE;if(a===ae.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,a===ae.MASK&&(u.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==Y&&(c.push(e.assignTexture(u,"normalMap",r.normalTexture)),u.normalScale=new Ie(1,1),r.normalTexture.scale!==void 0)){const l=r.normalTexture.scale;u.normalScale.set(l,l)}if(r.occlusionTexture!==void 0&&i!==Y&&(c.push(e.assignTexture(u,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==Y){const l=r.emissiveFactor;u.emissive=new v().setRGB(l[0],l[1],l[2],F)}return r.emissiveTexture!==void 0&&i!==Y&&c.push(e.assignTexture(u,"emissiveMap",r.emissiveTexture,Z)),Promise.all(c).then(function(){const l=new i(u);return r.name&&(l.name=r.name),C(l,r),e.associations.set(l,{materials:t}),r.extensions&&P(n,l,r),l})}createUniqueName(t){const e=st.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function r(u){return s[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,e).then(function(o){return Me(o,u,e)})}const i=[];for(let u=0,o=t.length;u<o;u++){const c=t[u],a=Zt(c),l=n[a];if(l)i.push(l.promise);else{let h;c.extensions&&c.extensions[E.KHR_DRACO_MESH_COMPRESSION]?h=r(c):h=Me(new Se,c,e),n[a]={primitive:c,promise:h},i.push(h)}}return Promise.all(i)}loadMesh(t){const e=this,s=this.json,n=this.extensions,r=s.meshes[t],i=r.primitives,u=[];for(let o=0,c=i.length;o<c;o++){const a=i[o].material===void 0?Yt(this.cache):this.getDependency("material",i[o].material);u.push(a)}return u.push(e.loadGeometries(i)),Promise.all(u).then(function(o){const c=o.slice(0,o.length-1),a=o[o.length-1],l=[];for(let d=0,m=a.length;d<m;d++){const T=a[d],g=i[d];let R;const y=c[d];if(g.mode===N.TRIANGLES||g.mode===N.TRIANGLE_STRIP||g.mode===N.TRIANGLE_FAN||g.mode===void 0)R=r.isSkinnedMesh===!0?new rt(T,y):new it(T,y),R.isSkinnedMesh===!0&&R.normalizeSkinWeights(),g.mode===N.TRIANGLE_STRIP?R.geometry=xe(R.geometry,Le):g.mode===N.TRIANGLE_FAN&&(R.geometry=xe(R.geometry,ue));else if(g.mode===N.LINES)R=new ot(T,y);else if(g.mode===N.LINE_STRIP)R=new at(T,y);else if(g.mode===N.LINE_LOOP)R=new ct(T,y);else if(g.mode===N.POINTS)R=new ut(T,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(R.geometry.morphAttributes).length>0&&Jt(R,r),R.name=e.createUniqueName(r.name||"mesh_"+t),C(R,r),g.extensions&&P(n,R,g),e.assignFinalMaterial(R),l.push(R)}for(let d=0,m=l.length;d<m;d++)e.associations.set(l[d],{meshes:t,primitives:d});if(l.length===1)return r.extensions&&P(n,l[0],r),l[0];const h=new ie;r.extensions&&P(n,h,r),e.associations.set(h,{meshes:t});for(let d=0,m=l.length;d<m;d++)h.add(l[d]);return h})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new lt(ft.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(e=new ht(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),C(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let n=0,r=e.joints.length;n<r;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const r=n.pop(),i=n,u=[],o=[];for(let c=0,a=i.length;c<a;c++){const l=i[c];if(l){u.push(l);const h=new ee;r!==null&&h.fromArray(r.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new dt(u,o)})}loadAnimation(t){const e=this.json,s=this,n=e.animations[t],r=n.name?n.name:"animation_"+t,i=[],u=[],o=[],c=[],a=[];for(let l=0,h=n.channels.length;l<h;l++){const d=n.channels[l],m=n.samplers[d.sampler],T=d.target,g=T.node,R=n.parameters!==void 0?n.parameters[m.input]:m.input,y=n.parameters!==void 0?n.parameters[m.output]:m.output;T.node!==void 0&&(i.push(this.getDependency("node",g)),u.push(this.getDependency("accessor",R)),o.push(this.getDependency("accessor",y)),c.push(m),a.push(T))}return Promise.all([Promise.all(i),Promise.all(u),Promise.all(o),Promise.all(c),Promise.all(a)]).then(function(l){const h=l[0],d=l[1],m=l[2],T=l[3],g=l[4],R=[];for(let A=0,p=h.length;A<p;A++){const x=h[A],L=d[A],_=m[A],w=T[A],M=g[A];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const S=s._createAnimationTracks(x,L,_,w,M);if(S)for(let I=0;I<S.length;I++)R.push(S[I])}const y=new pt(r,void 0,R);return C(y,n),y})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(r){const i=s._getNodeRef(s.meshCache,n.mesh,r);return n.weights!==void 0&&i.traverse(function(u){if(u.isMesh)for(let o=0,c=n.weights.length;o<c;o++)u.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(t){const e=this.json,s=this,n=e.nodes[t],r=s._loadNodeShallow(t),i=[],u=n.children||[];for(let c=0,a=u.length;c<a;c++)i.push(s.getDependency("node",u[c]));const o=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),o]).then(function(c){const a=c[0],l=c[1],h=c[2];h!==null&&a.traverse(function(d){d.isSkinnedMesh&&d.bind(h,en)});for(let d=0,m=l.length;d<m;d++)a.add(l[d]);if(a.userData.pivot!==void 0&&l.length>0){const d=a.userData.pivot,m=l[0];a.pivot=new G().fromArray(d),a.position.x-=d[0],a.position.y-=d[1],a.position.z-=d[2],m.position.set(0,0,0),delete a.userData.pivot}return a})}_loadNodeShallow(t){const e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const r=e.nodes[t],i=r.name?n.createUniqueName(r.name):"",u=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return o&&u.push(o),r.camera!==void 0&&u.push(n.getDependency("camera",r.camera).then(function(c){return n._getNodeRef(n.cameraCache,r.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){u.push(c)}),this.nodeCache[t]=Promise.all(u).then(function(c){let a;if(r.isBone===!0?a=new mt:c.length>1?a=new ie:c.length===1?a=c[0]:a=new Oe,a!==c[0])for(let l=0,h=c.length;l<h;l++)a.add(c[l]);if(r.name&&(a.userData.name=r.name,a.name=i),C(a,r),r.extensions&&P(s,a,r),r.matrix!==void 0){const l=new ee;l.fromArray(r.matrix),a.applyMatrix4(l)}else r.translation!==void 0&&a.position.fromArray(r.translation),r.rotation!==void 0&&a.quaternion.fromArray(r.rotation),r.scale!==void 0&&a.scale.fromArray(r.scale);if(!n.associations.has(a))n.associations.set(a,{});else if(r.mesh!==void 0&&n.meshCache.refs[r.mesh]>1){const l=n.associations.get(a);n.associations.set(a,{...l})}return n.associations.get(a).nodes=t,a}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,r=new ie;s.name&&(r.name=n.createUniqueName(s.name)),C(r,s),s.extensions&&P(e,r,s);const i=s.nodes||[],u=[];for(let o=0,c=i.length;o<c;o++)u.push(n.getDependency("node",i[o]));return Promise.all(u).then(function(o){for(let a=0,l=o.length;a<l;a++){const h=o[a];h.parent!==null?r.add(yt(h)):r.add(h)}const c=a=>{const l=new Map;for(const[h,d]of n.associations)(h instanceof re||h instanceof pe)&&l.set(h,d);return a.traverse(h=>{const d=n.associations.get(h);d!=null&&l.set(h,d)}),l};return n.associations=c(r),r})}_createAnimationTracks(t,e,s,n,r){const i=[],u=t.name?t.name:t.uuid,o=[];function c(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}H[r.path]===H.weights?(c(t),t.isGroup&&t.children.forEach(c)):o.push(u);let a;switch(H[r.path]){case H.weights:a=ge;break;case H.rotation:a=Te;break;case H.translation:case H.scale:a=me;break;default:switch(s.itemSize){case 1:a=ge;break;case 2:case 3:default:a=me;break}break}const l=n.interpolation!==void 0?Wt[n.interpolation]:He,h=this._getArrayFromAccessor(s);for(let d=0,m=o.length;d<m;d++){const T=new a(o[d]+"."+H[r.path],e.array,h,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),i.push(T)}return i}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=de(e.constructor),n=new Float32Array(e.length);for(let r=0,i=e.length;r<i;r++)n[r]=e[r]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const n=this instanceof Te?qt:ve;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function nn(f,t,e){const s=t.attributes,n=new xt;if(s.POSITION!==void 0){const u=e.json.accessors[s.POSITION],o=u.min,c=u.max;if(o!==void 0&&c!==void 0){if(n.set(new G(o[0],o[1],o[2]),new G(c[0],c[1],c[2])),u.normalized){const a=de(V[u.componentType]);n.min.multiplyScalar(a),n.max.multiplyScalar(a)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=t.targets;if(r!==void 0){const u=new G,o=new G;for(let c=0,a=r.length;c<a;c++){const l=r[c];if(l.POSITION!==void 0){const h=e.json.accessors[l.POSITION],d=h.min,m=h.max;if(d!==void 0&&m!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),h.normalized){const T=de(V[h.componentType]);o.multiplyScalar(T)}u.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(u)}f.boundingBox=n;const i=new At;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,f.boundingSphere=i}function Me(f,t,e){const s=t.attributes,n=[];function r(i,u){return e.getDependency("accessor",i).then(function(o){f.setAttribute(u,o)})}for(const i in s){const u=he[i]||i.toLowerCase();u in f.attributes||n.push(r(s[i],u))}if(t.indices!==void 0&&!f.index){const i=e.getDependency("accessor",t.indices).then(function(u){f.setIndex(u)});n.push(i)}return Re.workingColorSpace!==F&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Re.workingColorSpace}" not supported.`),C(f,t),nn(f,t,e),Promise.all(n).then(function(){return t.targets!==void 0?Qt(f,t.targets,e):f})}const an=Object.freeze(Object.defineProperty({__proto__:null,GLTFLoader:bt},Symbol.toStringTag,{value:"Module"}));export{bt as G,an as a,yt as c,rn as m,on as t};
1
+ import{BufferAttribute as Q,TrianglesDrawMode as De,TriangleFanDrawMode as ue,TriangleStripDrawMode as Le,BufferGeometry as Se,Loader as Ue,LoaderUtils as J,FileLoader as we,MeshPhysicalMaterial as k,Vector2 as Ie,Color as v,LinearSRGBColorSpace as F,SRGBColorSpace as Z,SpotLight as Be,PointLight as Ke,DirectionalLight as je,Matrix4 as ee,InstancedMesh as ze,Vector3 as G,Quaternion as Ne,InstancedBufferAttribute as Ve,Object3D as Oe,TextureLoader as Xe,ImageBitmapLoader as qe,InterleavedBuffer as We,LinearMipmapLinearFilter as Ce,NearestMipmapLinearFilter as Ye,LinearMipmapNearestFilter as Qe,NearestMipmapNearestFilter as Je,LinearFilter as le,NearestFilter as ke,RepeatWrapping as fe,MirroredRepeatWrapping as Ze,ClampToEdgeWrapping as $e,PointsMaterial as et,Material as re,LineBasicMaterial as tt,MeshStandardMaterial as Fe,DoubleSide as nt,MeshBasicMaterial as Y,PropertyBinding as st,SkinnedMesh as rt,Mesh as it,LineSegments as ot,Line as at,LineLoop as ct,Points as ut,Group as ie,PerspectiveCamera as lt,MathUtils as ft,OrthographicCamera as ht,Skeleton as dt,AnimationClip as pt,Bone as mt,InterpolateDiscrete as gt,InterpolateLinear as He,InterleavedBufferAttribute as Tt,Texture as pe,VectorKeyframeTrack as me,NumberKeyframeTrack as ge,QuaternionKeyframeTrack as Te,ColorManagement as Re,FrontSide as Rt,Interpolant as Et,Box3 as xt,Sphere as At}from"./three.module-Bx43vjkH.js";function rn(f,t=!1){const e=f[0].index!==null,s=new Set(Object.keys(f[0].attributes)),n=new Set(Object.keys(f[0].morphAttributes)),r={},i={},u=f[0].morphTargetsRelative,o=new Se;let c=0;for(let a=0;a<f.length;++a){const l=f[a];let h=0;if(e!==(l.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in l.attributes){if(!s.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;r[d]===void 0&&(r[d]=[]),r[d].push(l.attributes[d]),h++}if(h!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". Make sure all geometries have the same number of attributes."),null;if(u!==l.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in l.morphAttributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphAttributes must be consistent throughout all geometries."),null;i[d]===void 0&&(i[d]=[]),i[d].push(l.morphAttributes[d])}if(t){let d;if(e)d=l.index.count;else if(l.attributes.position!==void 0)d=l.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". The geometry must have either an index or a position attribute"),null;o.addGroup(c,d,a),c+=d}}if(e){let a=0;const l=[];for(let h=0;h<f.length;++h){const d=f[h].index;for(let m=0;m<d.count;++m)l.push(d.getX(m)+a);a+=f[h].attributes.position.count}o.setIndex(l)}for(const a in r){const l=Ee(r[a]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" attribute."),null;o.setAttribute(a,l)}for(const a in i){const l=i[a][0].length;if(l!==0){o.morphAttributes=o.morphAttributes||{},o.morphAttributes[a]=[];for(let h=0;h<l;++h){const d=[];for(let T=0;T<i[a].length;++T)d.push(i[a][T][h]);const m=Ee(d);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" morphAttribute."),null;o.morphAttributes[a].push(m)}}}return o}function Ee(f){let t,e,s,n=-1,r=0;for(let c=0;c<f.length;++c){const a=f[c];if(t===void 0&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=a.itemSize),e!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=a.normalized),s!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=a.gpuType),n!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=a.count*e}const i=new t(r),u=new Q(i,e,s);let o=0;for(let c=0;c<f.length;++c){const a=f[c];if(a.isInterleavedBufferAttribute){const l=o/e;for(let h=0,d=a.count;h<d;h++)for(let m=0;m<e;m++){const T=a.getComponent(h,m);u.setComponent(h+l,m,T)}}else i.set(a.array,o);o+=a.count*e}return n!==void 0&&(u.gpuType=n),u}function xe(f,t){if(t===De)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(t===ue||t===Le){let e=f.getIndex();if(e===null){const i=[],u=f.getAttribute("position");if(u!==void 0){for(let o=0;o<u.count;o++)i.push(o);f.setIndex(i),e=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const s=e.count-2,n=[];if(t===ue)for(let i=1;i<=s;i++)n.push(e.getX(0)),n.push(e.getX(i)),n.push(e.getX(i+1));else for(let i=0;i<s;i++)i%2===0?(n.push(e.getX(i)),n.push(e.getX(i+1)),n.push(e.getX(i+2))):(n.push(e.getX(i+2)),n.push(e.getX(i+1)),n.push(e.getX(i)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=f.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),f}function on(f,t=Math.PI/3){const e=f.index?f.toNonIndexed():f,s=e.attributes.position,n=s.count;let r;if(s.isBufferAttribute===!0&&s.itemSize===3&&s.normalized===!1)r=s.array;else{r=new Float64Array(n*3);for(let p=0;p<n;p++)r[3*p+0]=s.getX(p),r[3*p+1]=s.getY(p),r[3*p+2]=s.getZ(p)}const i=Math.cos(t),u=(1+1e-10)*100,o=n/3,c=new Float64Array(o*3);for(let p=0;p<o;p++){const x=9*p,L=r[x+0],_=r[x+1],w=r[x+2],M=r[x+3],S=r[x+4],I=r[x+5],O=r[x+6],D=r[x+7],U=r[x+8],B=O-M,K=D-S,$=U-I,j=L-M,X=_-S,q=w-I,z=K*q-$*X,te=$*j-B*q,ne=B*X-K*j,se=1/(Math.sqrt(z*z+te*te+ne*ne)||1);c[3*p+0]=z*se,c[3*p+1]=te*se,c[3*p+2]=ne*se}const a=new Int32Array(n),l=new Int32Array(n*3);let h=1;for(;h<n*2;)h<<=1;const d=h-1,m=new Int32Array(h);let T=0;for(let p=0;p<n;p++){const x=3*p,L=~~(r[x+0]*u),_=~~(r[x+1]*u),w=~~(r[x+2]*u);let M=(Math.imul(L,73856093)^Math.imul(_,19349663)^Math.imul(w,83492791))&d;for(;;){const S=m[M];if(S===0){const O=3*T;l[O+0]=L,l[O+1]=_,l[O+2]=w,m[M]=T+1,a[p]=T++;break}const I=3*(S-1);if(l[I+0]===L&&l[I+1]===_&&l[I+2]===w){a[p]=S-1;break}M=M+1&d}}const g=new Int32Array(T+1);for(let p=0;p<n;p++)g[a[p]+1]++;for(let p=0;p<T;p++)g[p+1]+=g[p];const R=new Int32Array(n),y=g.slice(0,T);for(let p=0;p<o;p++){const x=3*p;R[y[a[x+0]]++]=p,R[y[a[x+1]]++]=p,R[y[a[x+2]]++]=p}const A=new Float32Array(n*3);for(let p=0;p<o;p++){const x=3*p,L=c[x+0],_=c[x+1],w=c[x+2];for(let M=0;M<3;M++){const S=x+M,I=a[S];let O=0,D=0,U=0;for(let K=g[I],$=g[I+1];K<$;K++){const j=3*R[K],X=c[j+0],q=c[j+1],z=c[j+2];L*X+_*q+w*z>i&&(O+=X,D+=q,U+=z)}const B=1/(Math.sqrt(O*O+D*D+U*U)||1);A[3*S+0]=O*B,A[3*S+1]=D*B,A[3*S+2]=U*B}}return e.setAttribute("normal",new Q(A,3,!1)),e}function yt(f){const t=new Map,e=new Map,s=f.clone();return Pe(f,s,function(n,r){t.set(r,n),e.set(n,r)}),s.traverse(function(n){if(!n.isSkinnedMesh)return;const r=n,i=t.get(n),u=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=u.map(function(o){return e.get(o)}),r.bind(r.skeleton,r.bindMatrix)}),s}function Pe(f,t,e){e(f,t);for(let s=0;s<f.children.length;s++)Pe(f.children[s],t.children[s],e)}class bt extends Ue{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new wt(e)}),this.register(function(e){return new It(e)}),this.register(function(e){return new vt(e)}),this.register(function(e){return new Dt(e)}),this.register(function(e){return new Ut(e)}),this.register(function(e){return new Ot(e)}),this.register(function(e){return new Ct(e)}),this.register(function(e){return new kt(e)}),this.register(function(e){return new Ft(e)}),this.register(function(e){return new St(e)}),this.register(function(e){return new Ht(e)}),this.register(function(e){return new Nt(e)}),this.register(function(e){return new Gt(e)}),this.register(function(e){return new Pt(e)}),this.register(function(e){return new Mt(e)}),this.register(function(e){return new Ae(e,E.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new Ae(e,E.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Bt(e)})}load(t,e,s,n){const r=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const c=J.extractUrlBase(t);i=J.resolveURL(c,this.path)}else i=J.extractUrlBase(t);this.manager.itemStart(t);const u=function(c){n?n(c):console.error(c),r.manager.itemError(t),r.manager.itemEnd(t)},o=new we(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{r.parse(c,i,function(a){e(a),r.manager.itemEnd(t)},u)}catch(a){u(a)}},s,u)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let r;const i={},u={},o=new TextDecoder;if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===Ge){try{i[E.KHR_BINARY_GLTF]=new Kt(t)}catch(l){n&&n(l);return}r=JSON.parse(i[E.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t));else r=t;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new tn(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let a=0;a<this.pluginCallbacks.length;a++){const l=this.pluginCallbacks[a](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),u[l.name]=l,i[l.name]=!0}if(r.extensionsUsed)for(let a=0;a<r.extensionsUsed.length;++a){const l=r.extensionsUsed[a],h=r.extensionsRequired||[];switch(l){case E.KHR_MATERIALS_UNLIT:i[l]=new Lt;break;case E.KHR_DRACO_MESH_COMPRESSION:i[l]=new jt(r,this.dracoLoader);break;case E.KHR_TEXTURE_TRANSFORM:i[l]=new zt;break;case E.KHR_MESH_QUANTIZATION:i[l]=new Vt;break;default:h.indexOf(l)>=0&&u[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(i),c.setPlugins(u),c.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,r){s.parse(t,e,n,r)})}}function _t(){let f={};return{get:function(t){return f[t]},add:function(t,e){f[t]=e},remove:function(t){delete f[t]},removeAll:function(){f={}}}}function b(f,t,e){const s=f.json.materials[t];return s.extensions&&s.extensions[e]?s.extensions[e]:null}const E={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Mt{constructor(t){this.parser=t,this.name=E.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const r=e[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let n=e.cache.get(s);if(n)return n;const r=e.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let c;const a=new v(16777215);o.color!==void 0&&a.setRGB(o.color[0],o.color[1],o.color[2],F);const l=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new je(a),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Ke(a),c.distance=l;break;case"spot":c=new Be(a),c.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),C(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+t),n=Promise.resolve(c),e.cache.add(s,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,r=s.json.nodes[t],u=(r.extensions&&r.extensions[this.name]||{}).light;return u===void 0?null:this._loadLight(u).then(function(o){return s._getNodeRef(e.cache,u,o)})}}class Lt{constructor(){this.name=E.KHR_MATERIALS_UNLIT}getMaterialType(){return Y}extendParams(t,e,s){const n=[];t.color=new v(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const i=r.baseColorFactor;t.color.setRGB(i[0],i[1],i[2],F),t.opacity=i[3]}r.baseColorTexture!==void 0&&n.push(s.assignTexture(t,"map",r.baseColorTexture,Z))}return Promise.all(n)}}class St{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class wt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const r=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new Ie(r,r)}return Promise.all(n)}}class It{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_DISPERSION}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class Nt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(n)}}class Ot{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_SHEEN}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];if(e.sheenColor=new v(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){const r=s.sheenColorFactor;e.sheenColor.setRGB(r[0],r[1],r[2],F)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(e,"sheenColorMap",s.sheenColorTexture,Z)),s.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(n)}}class Ct{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(n)}}class kt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_VOLUME}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const r=s.attenuationColor||[1,1,1];return e.attenuationColor=new v().setRGB(r[0],r[1],r[2],F),Promise.all(n)}}class Ft{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_IOR}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}}class Ht{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_SPECULAR}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&n.push(this.parser.assignTexture(e,"specularIntensityMap",s.specularTexture));const r=s.specularColorFactor||[1,1,1];return e.specularColor=new v().setRGB(r[0],r[1],r[2],F),s.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(e,"specularColorMap",s.specularColorTexture,Z)),Promise.all(n)}}class Pt{constructor(t){this.parser=t,this.name=E.EXT_MATERIALS_BUMP}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&n.push(this.parser.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(n)}}class Gt{constructor(t){this.parser=t,this.name=E.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return b(this.parser,t,this.name)!==null?k:null}extendMaterialParams(t,e){const s=b(this.parser,t,this.name);if(s===null)return Promise.resolve();const n=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(n)}}class vt{constructor(t){this.parser=t,this.name=E.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],i=e.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,i)}}class Dt{constructor(t){this.parser=t,this.name=E.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,s=this.parser,n=s.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const i=r.extensions[e],u=n.images[i.source];let o=s.textureLoader;if(u.uri){const c=s.options.manager.getHandler(u.uri);c!==null&&(o=c)}return s.loadTextureImage(t,i.source,o)}}class Ut{constructor(t){this.parser=t,this.name=E.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,s=this.parser,n=s.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const i=r.extensions[e],u=n.images[i.source];let o=s.textureLoader;if(u.uri){const c=s.options.manager.getHandler(u.uri);c!==null&&(o=c)}return s.loadTextureImage(t,i.source,o)}}class Ae{constructor(t,e){this.name=e,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(u){const o=n.byteOffset||0,c=n.byteLength||0,a=n.count,l=n.byteStride,h=new Uint8Array(u,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,l,h,n.mode,n.filter).then(function(d){return d.buffer}):i.ready.then(function(){const d=new ArrayBuffer(a*l);return i.decodeGltfBuffer(new Uint8Array(d),a,l,h,n.mode,n.filter),d})})}else return null}}class Bt{constructor(t){this.name=E.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=e.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const i=s.extensions[this.name].attributes,u=[],o={};for(const c in i)u.push(this.parser.getDependency("accessor",i[c]).then(a=>(o[c]=a,o[c])));return u.length<1?null:(u.push(this.parser.createNodeMesh(t)),Promise.all(u).then(c=>{const a=c.pop(),l=a.isGroup?a.children:[a],h=c[0].count,d=[];for(const m of l){const T=new ee,g=new G,R=new Ne,y=new G(1,1,1),A=new ze(m.geometry,m.material,h);for(let p=0;p<h;p++)o.TRANSLATION&&g.fromBufferAttribute(o.TRANSLATION,p),o.ROTATION&&R.fromBufferAttribute(o.ROTATION,p),o.SCALE&&y.fromBufferAttribute(o.SCALE,p),A.setMatrixAt(p,T.compose(g,R,y));for(const p in o)if(p==="_COLOR_0"){const x=o[p];A.instanceColor=new Ve(x.array,x.itemSize,x.normalized)}else p!=="TRANSLATION"&&p!=="ROTATION"&&p!=="SCALE"&&m.geometry.setAttribute(p,o[p]);Oe.prototype.copy.call(A,m),this.parser.assignFinalMaterial(A),d.push(A)}return a.isGroup?(a.clear(),a.add(...d),a):d[0]}))}}const Ge="glTF",W=12,ye={JSON:1313821514,BIN:5130562};class Kt{constructor(t){this.name=E.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,W),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Ge)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-W,r=new DataView(t,W);let i=0;for(;i<n;){const u=r.getUint32(i,!0);i+=4;const o=r.getUint32(i,!0);if(i+=4,o===ye.JSON){const c=new Uint8Array(t,W+i,u);this.content=s.decode(c)}else if(o===ye.BIN){const c=W+i;this.body=t.slice(c,c+u)}i+=u}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class jt{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=E.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,i=t.extensions[this.name].attributes,u={},o={},c={};for(const a in i){const l=he[a]||a.toLowerCase();u[l]=i[a]}for(const a in t.attributes){const l=he[a]||a.toLowerCase();if(i[a]!==void 0){const h=s.accessors[t.attributes[a]],d=V[h.componentType];c[l]=d.name,o[l]=h.normalized===!0}}return e.getDependency("bufferView",r).then(function(a){return new Promise(function(l,h){n.decodeDracoFile(a,function(d){for(const m in d.attributes){const T=d.attributes[m],g=o[m];g!==void 0&&(T.normalized=g)}l(d)},u,c,F,h)})})}}class zt{constructor(){this.name=E.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Vt{constructor(){this.name=E.KHR_MESH_QUANTIZATION}}class ve extends Et{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let i=0;i!==n;i++)e[i]=s[r+i];return e}interpolate_(t,e,s,n){const r=this.resultBuffer,i=this.sampleValues,u=this.valueSize,o=u*2,c=u*3,a=n-e,l=(s-e)/a,h=l*l,d=h*l,m=t*c,T=m-c,g=-2*d+3*h,R=d-h,y=1-g,A=R-h+l;for(let p=0;p!==u;p++){const x=i[T+p+u],L=i[T+p+o]*a,_=i[m+p+u],w=i[m+p]*a;r[p]=y*x+A*L+g*_+R*w}return r}}const Xt=new Ne;class qt extends ve{interpolate_(t,e,s,n){const r=super.interpolate_(t,e,s,n);return Xt.fromArray(r).normalize().toArray(r),r}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},V={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},be={9728:ke,9729:le,9984:Je,9985:Qe,9986:Ye,9987:Ce},_e={33071:$e,33648:Ze,10497:fe},oe={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},he={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Wt={CUBICSPLINE:void 0,LINEAR:He,STEP:gt},ae={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Yt(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new Fe({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Rt})),f.DefaultMaterial}function P(f,t,e){for(const s in e.extensions)f[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function C(f,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(f.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Qt(f,t,e){let s=!1,n=!1,r=!1;for(let c=0,a=t.length;c<a;c++){const l=t[c];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(n=!0),l.COLOR_0!==void 0&&(r=!0),s&&n&&r)break}if(!s&&!n&&!r)return Promise.resolve(f);const i=[],u=[],o=[];for(let c=0,a=t.length;c<a;c++){const l=t[c];if(s){const h=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):f.attributes.position;i.push(h)}if(n){const h=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):f.attributes.normal;u.push(h)}if(r){const h=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(i),Promise.all(u),Promise.all(o)]).then(function(c){const a=c[0],l=c[1],h=c[2];return s&&(f.morphAttributes.position=a),n&&(f.morphAttributes.normal=l),r&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function Jt(f,t){if(f.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)f.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(f.morphTargetInfluences.length===e.length){f.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)f.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Zt(f){let t;const e=f.extensions&&f.extensions[E.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+ce(e.attributes):t=f.indices+":"+ce(f.attributes)+":"+f.mode,f.targets!==void 0)for(let s=0,n=f.targets.length;s<n;s++)t+=":"+ce(f.targets[s]);return t}function ce(f){let t="";const e=Object.keys(f).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+":"+f[e[s]]+";";return t}function de(f){switch(f){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function $t(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const en=new ee;class tn{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new _t,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,r=!1,i=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const u=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(u)===!0;const o=u.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,r=u.indexOf("Firefox")>-1,i=r?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||r&&i<98?this.textureLoader=new Xe(this.options.manager):this.textureLoader=new qe(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new we(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){const u={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:s,userData:{}};return P(r,u,n),C(u,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(u)})).then(function(){for(const o of u.scenes)o.updateMatrixWorld();t(u)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const i=e[n].joints;for(let u=0,o=i.length;u<o;u++)t[i[u]].isBone=!0}for(let n=0,r=t.length;n<r;n++){const i=t[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),r=(i,u)=>{const o=this.associations.get(i);o!=null&&this.associations.set(u,o);for(const[c,a]of i.children.entries())r(a,u.children[c])};return r(s,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const n=t(e[s]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let n=0;n<e.length;n++){const r=t(e[n]);r&&s.push(r)}return s}getDependency(t,e){const s=t+":"+e;let n=this.cache.get(s);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(r,i){return s.getDependency(t,i)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,i){s.load(J.resolveURL(e.uri,n.path),r,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const n=e.byteLength||0,r=e.byteOffset||0;return s.slice(r,r+n)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const i=oe[n.type],u=V[n.componentType],o=n.normalized===!0,c=new u(n.count*i);return Promise.resolve(new Q(c,i,o))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(i){const u=i[0],o=oe[n.type],c=V[n.componentType],a=c.BYTES_PER_ELEMENT,l=a*o,h=n.byteOffset||0,d=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0;let T,g;if(d&&d!==l){const R=Math.floor(h/d),y="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+R+":"+n.count;let A=e.cache.get(y);A||(T=new c(u,R*d,n.count*d/a),A=new We(T,d/a),e.cache.add(y,A)),g=new Tt(A,o,h%d/a,m)}else u===null?T=new c(n.count*o):T=new c(u,h,n.count*o),g=new Q(T,o,m);if(n.sparse!==void 0){const R=oe.SCALAR,y=V[n.sparse.indices.componentType],A=n.sparse.indices.byteOffset||0,p=n.sparse.values.byteOffset||0,x=new y(i[1],A,n.sparse.count*R),L=new c(i[2],p,n.sparse.count*o);u!==null&&(g=new Q(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let _=0,w=x.length;_<w;_++){const M=x[_];if(g.setX(M,L[_*o]),o>=2&&g.setY(M,L[_*o+1]),o>=3&&g.setZ(M,L[_*o+2]),o>=4&&g.setW(M,L[_*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(t){const e=this.json,s=this.options,r=e.textures[t].source,i=e.images[r];let u=this.textureLoader;if(i.uri){const o=s.manager.getHandler(i.uri);o!==null&&(u=o)}return this.loadTextureImage(t,r,u)}loadTextureImage(t,e,s){const n=this,r=this.json,i=r.textures[t],u=r.images[e],o=(u.uri||u.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(a){a.flipY=!1,a.name=i.name||u.name||"",a.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(a.name=u.uri);const h=(r.samplers||{})[i.sampler]||{};return a.magFilter=be[h.magFilter]||le,a.minFilter=be[h.minFilter]||Ce,a.wrapS=_e[h.wrapS]||fe,a.wrapT=_e[h.wrapT]||fe,a.generateMipmaps=!a.isCompressedTexture&&a.minFilter!==ke&&a.minFilter!==le,n.associations.set(a,{textures:t}),a}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const s=this,n=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());const i=n.images[t],u=self.URL||self.webkitURL;let o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=s.getDependency("bufferView",i.bufferView).then(function(l){c=!0;const h=new Blob([l],{type:i.mimeType});return o=u.createObjectURL(h),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const a=Promise.resolve(o).then(function(l){return new Promise(function(h,d){let m=h;e.isImageBitmapLoader===!0&&(m=function(T){const g=new pe(T);g.needsUpdate=!0,h(g)}),e.load(J.resolveURL(l,r.path),m,void 0,d)})}).then(function(l){return c===!0&&u.revokeObjectURL(o),C(l,i),l.userData.mimeType=i.mimeType||$t(i.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),l});return this.sourceCache[t]=a,a}assignTexture(t,e,s,n){const r=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),r.extensions[E.KHR_TEXTURE_TRANSFORM]){const u=s.extensions!==void 0?s.extensions[E.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const o=r.associations.get(i);i=r.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(i,u),r.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),t[e]=i,i})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,i=e.attributes.normal===void 0;if(t.isPoints){const u="PointsMaterial:"+s.uuid;let o=this.cache.get(u);o||(o=new et,re.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(u,o)),s=o}else if(t.isLine){const u="LineBasicMaterial:"+s.uuid;let o=this.cache.get(u);o||(o=new tt,re.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(u,o)),s=o}if(n||r||i){let u="ClonedMaterial:"+s.uuid+":";n&&(u+="derivative-tangents:"),r&&(u+="vertex-colors:"),i&&(u+="flat-shading:");let o=this.cache.get(u);o||(o=s.clone(),r&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(u,o),this.associations.set(o,this.associations.get(s))),s=o}t.material=s}getMaterialType(){return Fe}loadMaterial(t){const e=this,s=this.json,n=this.extensions,r=s.materials[t];let i;const u={},o=r.extensions||{},c=[];if(o[E.KHR_MATERIALS_UNLIT]){const l=n[E.KHR_MATERIALS_UNLIT];i=l.getMaterialType(),c.push(l.extendParams(u,r,e))}else{const l=r.pbrMetallicRoughness||{};if(u.color=new v(1,1,1),u.opacity=1,Array.isArray(l.baseColorFactor)){const h=l.baseColorFactor;u.color.setRGB(h[0],h[1],h[2],F),u.opacity=h[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(u,"map",l.baseColorTexture,Z)),u.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,u.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(u,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(u,"roughnessMap",l.metallicRoughnessTexture))),i=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(t,u)})))}r.doubleSided===!0&&(u.side=nt);const a=r.alphaMode||ae.OPAQUE;if(a===ae.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,a===ae.MASK&&(u.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==Y&&(c.push(e.assignTexture(u,"normalMap",r.normalTexture)),u.normalScale=new Ie(1,1),r.normalTexture.scale!==void 0)){const l=r.normalTexture.scale;u.normalScale.set(l,l)}if(r.occlusionTexture!==void 0&&i!==Y&&(c.push(e.assignTexture(u,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==Y){const l=r.emissiveFactor;u.emissive=new v().setRGB(l[0],l[1],l[2],F)}return r.emissiveTexture!==void 0&&i!==Y&&c.push(e.assignTexture(u,"emissiveMap",r.emissiveTexture,Z)),Promise.all(c).then(function(){const l=new i(u);return r.name&&(l.name=r.name),C(l,r),e.associations.set(l,{materials:t}),r.extensions&&P(n,l,r),l})}createUniqueName(t){const e=st.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function r(u){return s[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,e).then(function(o){return Me(o,u,e)})}const i=[];for(let u=0,o=t.length;u<o;u++){const c=t[u],a=Zt(c),l=n[a];if(l)i.push(l.promise);else{let h;c.extensions&&c.extensions[E.KHR_DRACO_MESH_COMPRESSION]?h=r(c):h=Me(new Se,c,e),n[a]={primitive:c,promise:h},i.push(h)}}return Promise.all(i)}loadMesh(t){const e=this,s=this.json,n=this.extensions,r=s.meshes[t],i=r.primitives,u=[];for(let o=0,c=i.length;o<c;o++){const a=i[o].material===void 0?Yt(this.cache):this.getDependency("material",i[o].material);u.push(a)}return u.push(e.loadGeometries(i)),Promise.all(u).then(function(o){const c=o.slice(0,o.length-1),a=o[o.length-1],l=[];for(let d=0,m=a.length;d<m;d++){const T=a[d],g=i[d];let R;const y=c[d];if(g.mode===N.TRIANGLES||g.mode===N.TRIANGLE_STRIP||g.mode===N.TRIANGLE_FAN||g.mode===void 0)R=r.isSkinnedMesh===!0?new rt(T,y):new it(T,y),R.isSkinnedMesh===!0&&R.normalizeSkinWeights(),g.mode===N.TRIANGLE_STRIP?R.geometry=xe(R.geometry,Le):g.mode===N.TRIANGLE_FAN&&(R.geometry=xe(R.geometry,ue));else if(g.mode===N.LINES)R=new ot(T,y);else if(g.mode===N.LINE_STRIP)R=new at(T,y);else if(g.mode===N.LINE_LOOP)R=new ct(T,y);else if(g.mode===N.POINTS)R=new ut(T,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(R.geometry.morphAttributes).length>0&&Jt(R,r),R.name=e.createUniqueName(r.name||"mesh_"+t),C(R,r),g.extensions&&P(n,R,g),e.assignFinalMaterial(R),l.push(R)}for(let d=0,m=l.length;d<m;d++)e.associations.set(l[d],{meshes:t,primitives:d});if(l.length===1)return r.extensions&&P(n,l[0],r),l[0];const h=new ie;r.extensions&&P(n,h,r),e.associations.set(h,{meshes:t});for(let d=0,m=l.length;d<m;d++)h.add(l[d]);return h})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new lt(ft.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(e=new ht(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),C(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let n=0,r=e.joints.length;n<r;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const r=n.pop(),i=n,u=[],o=[];for(let c=0,a=i.length;c<a;c++){const l=i[c];if(l){u.push(l);const h=new ee;r!==null&&h.fromArray(r.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new dt(u,o)})}loadAnimation(t){const e=this.json,s=this,n=e.animations[t],r=n.name?n.name:"animation_"+t,i=[],u=[],o=[],c=[],a=[];for(let l=0,h=n.channels.length;l<h;l++){const d=n.channels[l],m=n.samplers[d.sampler],T=d.target,g=T.node,R=n.parameters!==void 0?n.parameters[m.input]:m.input,y=n.parameters!==void 0?n.parameters[m.output]:m.output;T.node!==void 0&&(i.push(this.getDependency("node",g)),u.push(this.getDependency("accessor",R)),o.push(this.getDependency("accessor",y)),c.push(m),a.push(T))}return Promise.all([Promise.all(i),Promise.all(u),Promise.all(o),Promise.all(c),Promise.all(a)]).then(function(l){const h=l[0],d=l[1],m=l[2],T=l[3],g=l[4],R=[];for(let A=0,p=h.length;A<p;A++){const x=h[A],L=d[A],_=m[A],w=T[A],M=g[A];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const S=s._createAnimationTracks(x,L,_,w,M);if(S)for(let I=0;I<S.length;I++)R.push(S[I])}const y=new pt(r,void 0,R);return C(y,n),y})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(r){const i=s._getNodeRef(s.meshCache,n.mesh,r);return n.weights!==void 0&&i.traverse(function(u){if(u.isMesh)for(let o=0,c=n.weights.length;o<c;o++)u.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(t){const e=this.json,s=this,n=e.nodes[t],r=s._loadNodeShallow(t),i=[],u=n.children||[];for(let c=0,a=u.length;c<a;c++)i.push(s.getDependency("node",u[c]));const o=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),o]).then(function(c){const a=c[0],l=c[1],h=c[2];h!==null&&a.traverse(function(d){d.isSkinnedMesh&&d.bind(h,en)});for(let d=0,m=l.length;d<m;d++)a.add(l[d]);if(a.userData.pivot!==void 0&&l.length>0){const d=a.userData.pivot,m=l[0];a.pivot=new G().fromArray(d),a.position.x-=d[0],a.position.y-=d[1],a.position.z-=d[2],m.position.set(0,0,0),delete a.userData.pivot}return a})}_loadNodeShallow(t){const e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const r=e.nodes[t],i=r.name?n.createUniqueName(r.name):"",u=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return o&&u.push(o),r.camera!==void 0&&u.push(n.getDependency("camera",r.camera).then(function(c){return n._getNodeRef(n.cameraCache,r.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){u.push(c)}),this.nodeCache[t]=Promise.all(u).then(function(c){let a;if(r.isBone===!0?a=new mt:c.length>1?a=new ie:c.length===1?a=c[0]:a=new Oe,a!==c[0])for(let l=0,h=c.length;l<h;l++)a.add(c[l]);if(r.name&&(a.userData.name=r.name,a.name=i),C(a,r),r.extensions&&P(s,a,r),r.matrix!==void 0){const l=new ee;l.fromArray(r.matrix),a.applyMatrix4(l)}else r.translation!==void 0&&a.position.fromArray(r.translation),r.rotation!==void 0&&a.quaternion.fromArray(r.rotation),r.scale!==void 0&&a.scale.fromArray(r.scale);if(!n.associations.has(a))n.associations.set(a,{});else if(r.mesh!==void 0&&n.meshCache.refs[r.mesh]>1){const l=n.associations.get(a);n.associations.set(a,{...l})}return n.associations.get(a).nodes=t,a}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,r=new ie;s.name&&(r.name=n.createUniqueName(s.name)),C(r,s),s.extensions&&P(e,r,s);const i=s.nodes||[],u=[];for(let o=0,c=i.length;o<c;o++)u.push(n.getDependency("node",i[o]));return Promise.all(u).then(function(o){for(let a=0,l=o.length;a<l;a++){const h=o[a];h.parent!==null?r.add(yt(h)):r.add(h)}const c=a=>{const l=new Map;for(const[h,d]of n.associations)(h instanceof re||h instanceof pe)&&l.set(h,d);return a.traverse(h=>{const d=n.associations.get(h);d!=null&&l.set(h,d)}),l};return n.associations=c(r),r})}_createAnimationTracks(t,e,s,n,r){const i=[],u=t.name?t.name:t.uuid,o=[];function c(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}H[r.path]===H.weights?(c(t),t.isGroup&&t.children.forEach(c)):o.push(u);let a;switch(H[r.path]){case H.weights:a=ge;break;case H.rotation:a=Te;break;case H.translation:case H.scale:a=me;break;default:switch(s.itemSize){case 1:a=ge;break;case 2:case 3:default:a=me;break}break}const l=n.interpolation!==void 0?Wt[n.interpolation]:He,h=this._getArrayFromAccessor(s);for(let d=0,m=o.length;d<m;d++){const T=new a(o[d]+"."+H[r.path],e.array,h,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),i.push(T)}return i}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=de(e.constructor),n=new Float32Array(e.length);for(let r=0,i=e.length;r<i;r++)n[r]=e[r]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const n=this instanceof Te?qt:ve;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function nn(f,t,e){const s=t.attributes,n=new xt;if(s.POSITION!==void 0){const u=e.json.accessors[s.POSITION],o=u.min,c=u.max;if(o!==void 0&&c!==void 0){if(n.set(new G(o[0],o[1],o[2]),new G(c[0],c[1],c[2])),u.normalized){const a=de(V[u.componentType]);n.min.multiplyScalar(a),n.max.multiplyScalar(a)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=t.targets;if(r!==void 0){const u=new G,o=new G;for(let c=0,a=r.length;c<a;c++){const l=r[c];if(l.POSITION!==void 0){const h=e.json.accessors[l.POSITION],d=h.min,m=h.max;if(d!==void 0&&m!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),h.normalized){const T=de(V[h.componentType]);o.multiplyScalar(T)}u.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(u)}f.boundingBox=n;const i=new At;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,f.boundingSphere=i}function Me(f,t,e){const s=t.attributes,n=[];function r(i,u){return e.getDependency("accessor",i).then(function(o){f.setAttribute(u,o)})}for(const i in s){const u=he[i]||i.toLowerCase();u in f.attributes||n.push(r(s[i],u))}if(t.indices!==void 0&&!f.index){const i=e.getDependency("accessor",t.indices).then(function(u){f.setIndex(u)});n.push(i)}return Re.workingColorSpace!==F&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Re.workingColorSpace}" not supported.`),C(f,t),nn(f,t,e),Promise.all(n).then(function(){return t.targets!==void 0?Qt(f,t.targets,e):f})}const an=Object.freeze(Object.defineProperty({__proto__:null,GLTFLoader:bt},Symbol.toStringTag,{value:"Module"}));export{bt as G,an as a,yt as c,rn as m,on as t};
@@ -1 +1 @@
1
- import{j as w,dn as F}from"./remote-sTZauTqM.js";import{r as l}from"./api-BsKbf3l3.js";import{d as M,m as E}from"./lottieLayer-CfUPParC.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./titleFrameBudget-3MFHWIT6.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const I=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],j={"16:9":[1280,720],"9:16":[720,1280],"1:1":[960,960],"4:5":[768,960]},L=f=>j[f.aspect??"16:9"]??j["16:9"];function z(){const f=l.useRef(null),[o,R]=l.useState(null),[y,x]=l.useState(""),b=l.useRef(Promise.resolve());return l.useEffect(()=>{const a=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),h=async t=>{if(!I.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const i="id"in t.data?t.data.id:null;let e;try{e=F(t.data.motion)}catch(n){a(t,{type:"clipoox-motion-error",id:i,error:n.message});return}if(t.data.type==="clipoox-motion-play"){x(""),R(e);return}if(t.data.type==="clipoox-motion-thumb"){const[n,u]=L(e),m=480/Math.max(n,u),s=Math.round(n*m),d=Math.round(u*m);try{const p=await E({layer:"embed:thumb",motion:{v:1,code:e.code,params:e.params},t:Number.isFinite(t.data.t)?Math.max(0,Math.min(e.duration,Number(t.data.t))):e.duration*.55,width:s,height:d,duration:e.duration}),c=Object.assign(document.createElement("canvas"),{width:s,height:d}),g=c.getContext("2d");if(!g)throw Error("canvas");g.fillStyle="#16181c",g.fillRect(0,0,s,d),g.drawImage(p,0,0),p.close(),a(t,{type:"clipoox-motion-thumb",id:i,webp:c.toDataURL("image/webp",.85)})}catch(p){a(t,{type:"clipoox-motion-error",id:i,error:p.message})}finally{M("embed:thumb")}}},r=t=>{b.current=b.current.then(()=>h(t)).catch(()=>{})};return window.addEventListener("message",r),window.parent?.postMessage({type:"clipoox-motion-ready"},"*"),()=>window.removeEventListener("message",r)},[]),l.useEffect(()=>{const a=f.current,h=a?.getContext("2d");if(!o||!a||!h)return;let r=!0,t=0;const i=performance.now(),[e,n]=L(o),u=Math.min(1,960/Math.max(e,n)),m=Math.round(e*u),s=Math.round(n*u);a.width=m,a.height=s;const d=async()=>{if(!r)return;const p=(performance.now()-i)/1e3%(o.duration+.8);try{const c=await E({layer:"embed:play",motion:{v:1,code:o.code,params:o.params},t:Math.min(p,o.duration),width:m,height:s,duration:o.duration});r&&(h.clearRect(0,0,m,s),h.drawImage(c,0,0)),c.close()}catch(c){if(r){x(c.message);return}}r&&(t=requestAnimationFrame(()=>void d()))};return d(),()=>{r=!1,cancelAnimationFrame(t),M("embed:play")}},[o]),w.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[w.jsx("canvas",{ref:f,width:1280,height:720,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Motion preview"}),y&&w.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:y})]})}export{z as default};
1
+ import{j as w,dp as F}from"./remote-BJdzzFZg.js";import{r as l}from"./api-QBI5GJTZ.js";import{d as M,m as E}from"./lottieLayer-CDCGeJyv.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./titleFrameBudget-Cml-MO53.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const I=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],j={"16:9":[1280,720],"9:16":[720,1280],"1:1":[960,960],"4:5":[768,960]},L=f=>j[f.aspect??"16:9"]??j["16:9"];function z(){const f=l.useRef(null),[o,R]=l.useState(null),[y,x]=l.useState(""),b=l.useRef(Promise.resolve());return l.useEffect(()=>{const a=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),h=async t=>{if(!I.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const i="id"in t.data?t.data.id:null;let e;try{e=F(t.data.motion)}catch(n){a(t,{type:"clipoox-motion-error",id:i,error:n.message});return}if(t.data.type==="clipoox-motion-play"){x(""),R(e);return}if(t.data.type==="clipoox-motion-thumb"){const[n,u]=L(e),m=480/Math.max(n,u),s=Math.round(n*m),d=Math.round(u*m);try{const p=await E({layer:"embed:thumb",motion:{v:1,code:e.code,params:e.params},t:Number.isFinite(t.data.t)?Math.max(0,Math.min(e.duration,Number(t.data.t))):e.duration*.55,width:s,height:d,duration:e.duration}),c=Object.assign(document.createElement("canvas"),{width:s,height:d}),g=c.getContext("2d");if(!g)throw Error("canvas");g.fillStyle="#16181c",g.fillRect(0,0,s,d),g.drawImage(p,0,0),p.close(),a(t,{type:"clipoox-motion-thumb",id:i,webp:c.toDataURL("image/webp",.85)})}catch(p){a(t,{type:"clipoox-motion-error",id:i,error:p.message})}finally{M("embed:thumb")}}},r=t=>{b.current=b.current.then(()=>h(t)).catch(()=>{})};return window.addEventListener("message",r),window.parent?.postMessage({type:"clipoox-motion-ready"},"*"),()=>window.removeEventListener("message",r)},[]),l.useEffect(()=>{const a=f.current,h=a?.getContext("2d");if(!o||!a||!h)return;let r=!0,t=0;const i=performance.now(),[e,n]=L(o),u=Math.min(1,960/Math.max(e,n)),m=Math.round(e*u),s=Math.round(n*u);a.width=m,a.height=s;const d=async()=>{if(!r)return;const p=(performance.now()-i)/1e3%(o.duration+.8);try{const c=await E({layer:"embed:play",motion:{v:1,code:o.code,params:o.params},t:Math.min(p,o.duration),width:m,height:s,duration:o.duration});r&&(h.clearRect(0,0,m,s),h.drawImage(c,0,0)),c.close()}catch(c){if(r){x(c.message);return}}r&&(t=requestAnimationFrame(()=>void d()))};return d(),()=>{r=!1,cancelAnimationFrame(t),M("embed:play")}},[o]),w.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[w.jsx("canvas",{ref:f,width:1280,height:720,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Motion preview"}),y&&w.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:y})]})}export{z as default};
@@ -0,0 +1,3 @@
1
+ import{r as bn,j as s}from"./remote-BJdzzFZg.js";import{u as hn,r as d,t as a}from"./api-QBI5GJTZ.js";import{at as kn,au as Nn,av as un,aw as pn,ax as W,ay as R,R as H,az as wn,N as yn,aA as Cn,z as Sn,M as Ln,aB as Mn,o as Dn,aC as Un,aD as q,aE as $n,aF as Pn,e as Tn,aG as An}from"./main-CVRIuDW2.js";import{d as Vn,k as Kn,m as En,l as In}from"./lottieLayer-CDCGeJyv.js";import{p as Fn}from"./TimelinePlugins-BI1bE9pX.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./titleFrameBudget-Cml-MO53.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";import"./pluginAutomation-5DYldFrb.js";const mn=[{id:"all",vi:"Tất cả",en:"All"},{id:"motion",vi:"Motion",en:"Motion"},{id:"lottie",vi:"Lottie",en:"Lottie"},{id:"recipe",vi:"Công thức",en:"Recipe"},{id:"sfx",vi:"Âm thanh",en:"Sounds"},{id:"pack",vi:"Gói ngách",en:"Niche pack"},{id:"kit",vi:"Bộ 3D",en:"3D kit"},{id:"sfxlib",vi:"Kho âm thanh",en:"Sound library"},{id:"link",vi:"Cho AI agent",en:"AI agents"}],I=e=>e.kind==="pack"&&!!e.kit?.modelAssets,Q=e=>I(e)?"kit":e.kind,F=e=>e.kind==="link"&&!!e.link,Bn=e=>{e.link&&window.open(e.link.url,"_blank","noopener,noreferrer")},gn=(e,l)=>e>=1024*1024?`${(e/1024/1024).toFixed(e>=10*1024*1024?0:1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,Y=({n:e=28})=>s.jsx("span",{className:"ps-wave","aria-hidden":!0,children:Array.from({length:e},(l,r)=>s.jsx("i",{style:{height:`${18+Math.round(72*Math.abs(Math.sin(r*1.37)*Math.cos(r*.41)))}%`}},r))}),xn=(e,l)=>mn.find(r=>r.id===e)?.[l==="en"?"en":"vi"]??e,On=5e3,Rn=600*1e3,on=e=>e.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/gi,"d").toLowerCase(),z=e=>(e.passVnd??0)>0||(e.passUsd??0)>0,Gn=e=>{const l=(r,o)=>r>0&&o>0?Math.min(r,o):r>0?r:o;return R({priceVnd:l(e.priceVnd,e.passVnd??0),priceUsd:l(e.priceUsd,e.passUsd??0)})};function Ns({installed:e,initialId:l=null,onClose:r,onInstalled:o,onUse:j,toast:c}){const m=hn(),u=m==="en"?"en":"vi",[f,L]=d.useState(null),[p,N]=d.useState([]),[M,A]=d.useState(""),[C,t]=d.useState("all"),[h,v]=d.useState("all"),[D,K]=d.useState(""),[x,w]=d.useState(null),[$,P]=d.useState(""),[T,b]=d.useState({}),[U,S]=d.useState(""),y=d.useCallback(()=>kn().then(n=>(N(n.owned),n.owned)).catch(()=>[]),[]),[V,G]=d.useState(!1);d.useEffect(()=>{Nn().then(n=>L(n.items),n=>{L([]),A(n.message)}),y().finally(()=>G(!0))},[y]);const E=d.useRef(!1);d.useEffect(()=>{if(!l||E.current||f===null||!V)return;E.current=!0;const n=f.find(i=>i.id===l)??p.find(i=>i.storeId===l&&i.item)?.item;n?w(n):c(a("Không tìm thấy plug-in này trong kho."),"error")},[l,f,p,V,c]),d.useEffect(()=>{const n=i=>{i.key==="Escape"&&(i.stopPropagation(),x?w(null):r())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[x,r]);const Z=Object.keys(T).join(",");d.useEffect(()=>{if(!Z)return;const n=window.setInterval(()=>{y().then(i=>{b(g=>{const k={...g};for(const O of Object.keys(k))(tn(i,O)||Date.now()-k[O]>Rn)&&delete k[O];return k})})},On);return()=>window.clearInterval(n)},[Z,y]);const B=n=>p.some(i=>i.storeId===n&&i.owned),_=n=>p.find(i=>i.storeId===n),nn=n=>p.some(i=>i.storeId===n&&i.status==="refunded"),sn=n=>e.some(i=>i.id===n&&i.source?.store===n),X=async n=>{P(n.id);try{await Mn(n.id),o(),Dn(),S(n.id),c(a("Đã cài “{0}” vào Plug-in của tôi",[n.name[u]]),"ok")}catch(i){const g=Fn(i);c(g.text,"error")}finally{P("")}},en=d.useRef({}),an=n=>n?.owned?n.expiresAt?String(n.expiresAt):"life":"none",tn=(n,i)=>{const g=n.find(k=>k.storeId===i);return!!g?.owned&&an(g)!==(en.current[i]??"none")},ln=(n,i)=>{en.current[n.id]=an(_(n.id)),Ln(n.id,i),b(g=>({...g,[n.id]:Date.now()}))},jn=async n=>{const i=await y();tn(i,n)?(b(g=>{const k={...g};return delete k[n],k}),c(a("Thanh toán xong — plug-in đã thuộc về bạn"),"ok")):c(a("Chưa thấy thanh toán. Nếu bạn vừa chuyển khoản, đợi một chút rồi kiểm tra lại."),"error")},fn=p.filter(n=>n.item).map(n=>n.item),J=(C==="owned"?fn:(f??[]).filter(n=>C==="all"||(C==="free"?n.free:!n.free))).filter(n=>(h==="all"||Q(n)===h)&&(!D.trim()||on(D).split(/\s+/).every(i=>on(`${n.name.vi} ${n.name.en} ${n.description.vi} ${n.description.en} ${n.author.name} ${n.tags.join(" ")}`).includes(i)))),vn=[{id:"all",label:a("Plug-in")},{id:"free",label:a("Miễn phí")},{id:"paid",label:a("Trả phí")},{id:"owned",label:a("Đã sở hữu")}],rn=(n,i)=>$===n.id?s.jsxs("button",{className:i,disabled:!0,children:[s.jsx("i",{className:"spin"})," ",a("Đang cài…")]}):sn(n.id)||U===n.id?s.jsxs(s.Fragment,{children:[j?s.jsxs("button",{className:`${i} ps-use`,onClick:()=>j(n.id),children:["✓ ",a("Đã cài · Dùng ngay")]}):s.jsxs("span",{className:`${i} ps-use`,role:"status",children:["✓ ",a("Đã cài")]}),s.jsx("button",{className:"ps-reinstall",title:a("Cài lại plug-in"),onClick:()=>void X(n),children:a("Cài lại")})]}):s.jsx("button",{className:i,onClick:()=>void X(n),children:a("Cài plug-in")}),cn=(n,i=!1)=>{const g=`ad-use${i?" ps-big":""}`;if(F(n))return s.jsxs("button",{className:g,onClick:()=>Bn(n),children:[n.link.label?.[u]||a("Hướng dẫn cài")," ↗"]});if(n.free)return rn(n,g);if(T[n.id])return s.jsx("button",{className:`${g} ps-wait`,onClick:()=>void jn(n.id),children:a("Đã thanh toán? Kiểm tra lại")});if(n.kind==="sfxlib"||z(n)){const k=_(n.id);if(!i&&!k?.owned)return s.jsx("button",{className:g,onClick:()=>w(n),children:k?.expiresAt?a("Gia hạn"):a("Xem & mua")});if(i)return s.jsx(Xn,{item:n,owned:k,busy:$===n.id,installed:sn(n.id),onInstall:()=>void X(n),onBuy:O=>ln(n,O)})}return B(n.id)?rn(n,g):s.jsx("button",{className:g,onClick:()=>ln(n),children:a("Mua · {0}",[R(n)])})},dn=n=>{if(n.free)return s.jsx("span",{className:"ps-price free",children:a("Miễn phí")});const i=_(n.id);return i?.owned?s.jsxs("span",{className:"ps-price owned",children:["✓ ",i.expiresAt?a("Vé đến {0}",[H(i.expiresAt,m)]):a("Đã sở hữu")]}):s.jsx("span",{className:"ps-price",children:n.kind==="sfxlib"||z(n)?(n.passVnd||n.passUsd)&&!(n.priceVnd||n.priceUsd)?a("{0} / 30 ngày",[W(n)]):a("từ {0}",[Gn(n)]):R(n)})};return bn.createPortal(s.jsx("div",{className:"ad-backdrop",role:"dialog","aria-modal":"true","aria-label":a("Kho Plug-in"),onMouseDown:n=>{n.target===n.currentTarget&&r()},children:s.jsxs("section",{className:"ad-drawer ps-drawer",onMouseDown:n=>n.stopPropagation(),children:[s.jsxs("header",{className:"ad-head",children:[s.jsxs("div",{className:"ad-title",children:["🛍 ",a("Kho Plug-in")]}),s.jsxs("span",{className:"ad-count",children:[J.length," ",a("mục")]}),s.jsx("div",{className:"grow"}),s.jsx("button",{className:"ad-iconbtn",title:a("Đóng"),"aria-label":a("Đóng"),onClick:r,children:"✕"})]}),s.jsx("nav",{className:"ad-sources",children:vn.map(n=>s.jsxs("button",{className:`ad-tab${C===n.id?" on":""}`,"aria-pressed":C===n.id,onClick:()=>t(n.id),children:[n.id==="all"&&s.jsx("span",{className:"ad-pin",children:"⧉"}),n.label,n.id==="owned"&&p.filter(i=>i.owned).length>0&&s.jsx("span",{className:"ps-n",children:p.filter(i=>i.owned).length})]},n.id))}),s.jsxs("div",{className:"ad-tools",children:[s.jsx("input",{className:"ad-search","aria-label":a("Tìm plug-in"),placeholder:a("Tìm plug-in, tác giả, thẻ…"),value:D,onChange:n=>K(n.target.value),onKeyDown:n=>n.stopPropagation()}),s.jsx("div",{className:"ad-chips",role:"group","aria-label":a("Loại plug-in"),children:mn.map(n=>s.jsx("button",{className:`ad-chip${h===n.id?" on":""}`,"aria-pressed":h===n.id,onClick:()=>v(n.id),children:n[u]},n.id))})]}),s.jsxs("div",{className:"ad-notice",children:[s.jsxs("b",{children:["⧉ ",a("Plug-in không tốn credit.")]})," ",h==="sfxlib"?a("Kho âm thanh: mua một lần hoặc vé 30 ngày trên clipoox.com, tính là 1 plug-in; âm chỉ chép vào dự án khi bạn dùng."):a("Bản miễn phí cài ngay; bản trả phí mua một lần hoặc vé 30 ngày trên clipoox.com (chuyển khoản / thẻ), không tự trừ tiền.")]}),s.jsxs("div",{className:"ad-content",children:[M&&s.jsx("p",{role:"alert",className:"ad-alert",children:M}),f===null&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),f!==null&&!J.length&&s.jsx("div",{className:"ad-empty",children:C==="owned"?a("Bạn chưa mua plug-in nào."):D?a("Không có plug-in khớp tìm kiếm."):a("Kho chưa có plug-in nào trong nhóm này.")}),s.jsx("div",{className:"ad-grid",children:J.map(n=>s.jsxs("article",{className:"ad-card ps-card","data-store":n.id,children:[s.jsxs("button",{className:"ad-prev ps-open","aria-label":a("Xem {0}",[n.name[u]]),onClick:()=>w(n),children:[n.thumbnailUrl?s.jsx("img",{src:n.thumbnailUrl,alt:"",loading:"lazy"}):n.kind==="sfx"||n.kind==="sfxlib"?s.jsx(Y,{}):s.jsx("span",{className:"ad-ph",children:"⧉"}),s.jsx("span",{className:"ad-badge",children:(F(n)?n.link.platform:xn(Q(n),m)).toUpperCase()}),n.featured&&s.jsxs("span",{className:"ps-featured",title:a("Đối tác tiên phong của Clipoox"),children:["★ ",a("Đối tác tiên phong")]}),n.private&&s.jsxs("span",{className:"ps-private",title:a("Chỉ các tài khoản được Clipoox chọn mới thấy gói này"),children:["🔒 ",a("Gói riêng")]})]}),s.jsxs("div",{className:"ad-meta",children:[s.jsx("div",{className:"ad-name",title:n.name[u],children:n.name[u]}),s.jsxs("div",{className:"ad-sub ps-sub",children:[s.jsxs("span",{className:"ps-by",children:[n.author.name," · v",n.version]}),dn(n)]}),n.kind==="pack"&&!I(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["⧉ ",a("{0} mục trong gói",[n.itemCount??0])]}),I(n)&&s.jsxs("div",{className:"ps-kit-meta",children:["◈ ",s.jsx("b",{children:n.kit.items})," ",a("mục")," · ",s.jsx("b",{children:n.kit.models})," ",a("mô hình 3D")," · ",s.jsx("b",{children:n.kit.looks})," ",a("look")," · ",gn(n.kit.bytes,u)]}),F(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["↗ ",a("Cài trong {0} trên máy bạn",[n.link.platform])]}),n.kind==="sfx"&&s.jsxs("div",{className:"ps-sounds-meta",children:["♪ ",a("{0} âm thanh",[n.soundCount??0])," · ",un(n.totalDuration)]}),n.kind==="sfxlib"&&s.jsxs("div",{className:"ps-sounds-meta",children:["📚 ",a("{0} âm thanh",[(n.soundCount??0).toLocaleString(u==="en"?"en-US":"vi-VN")])," · ",pn(n.totalDuration,u)]}),(n.kind==="sfxlib"||z(n))&&!n.free&&!B(n.id)&&s.jsx("div",{className:"ps-sounds-meta ps-lib-prices",children:[n.passVnd||n.passUsd?a("{0} / 30 ngày",[W(n)]):"",n.priceVnd||n.priceUsd?a("{0} trọn đời",[R(n)]):""].filter(Boolean).join(" · ")}),U===n.id&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi")]}),T[n.id]&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán…")]}),nn(n.id)&&!B(n.id)&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn đã hoàn tiền")}),s.jsx("div",{className:"ad-actions",children:cn(n)})]})]},n.id))})]}),x&&s.jsx(Hn,{item:x,locale:u,owned:B(x.id),free:x.free,waiting:!!T[x.id],refunded:nn(x.id),action:cn(x,!0),price:dn(x),installed:U===x.id,onClose:()=>w(null)},`${x.id}:${B(x.id)}`)]})}),document.body)}function Hn({item:e,locale:l,owned:r,free:o,waiting:j,refunded:c,action:m,price:u,installed:f,onClose:L}){const p=d.useRef(null),[N,M]=d.useState(!1),[A,C]=d.useState(!1);return d.useEffect(()=>{if(!(o||r)||e.kind==="recipe"||e.kind==="sfx"||e.kind==="pack"||e.kind==="sfxlib"||e.kind==="link")return;let t=!0,h=0,v=null;const D=`store-preview:${e.id}`,K={v:""},x=performance.now();return(async()=>{try{v=await wn(e.id)}catch{t&&C(!0);return}if(!t||!v)return;const w=v.manifest,$=640,P=360;if(w.kind==="motion"){const T=yn(w,v.entry,{}),b=w.duration,U=async()=>{if(t){try{const S=await En({layer:D,motion:T,t:(performance.now()-x)/1e3%b,width:$,height:P,duration:b}),y=p.current?.getContext("2d");y&&t&&(y.clearRect(0,0,$,P),y.drawImage(S,0,0),M(!0)),S.close()}catch{}h=requestAnimationFrame(()=>void U())}};U()}else{const T=await Cn(v.lottie,w,Sn(w,{}));K.v=URL.createObjectURL(new Blob([JSON.stringify(T)],{type:"application/json"}));const b=v.lottie.meta,U=Math.min($/b.w,P/b.h),S={W:Math.max(2,Math.round(b.w*U/2)*2),H:Math.max(2,Math.round(b.h*U/2)*2)},y=b.op-b.ip,V=document.createElement("canvas");V.width=S.W,V.height=S.H;const G=async()=>{if(t){try{await In(D,K.v,S,Math.floor((performance.now()-x)/1e3*b.fr%y),V);const E=p.current?.getContext("2d");E&&t&&(E.clearRect(0,0,$,P),E.drawImage(V,($-S.W)/2,(P-S.H)/2),M(!0))}catch{}h=requestAnimationFrame(()=>void G())}};G()}})(),()=>{t=!1,cancelAnimationFrame(h),Vn(D),Kn(D),K.v&&URL.revokeObjectURL(K.v)}},[e.id,e.kind,o,r]),s.jsx("div",{className:"ad-preview-modal",onMouseDown:t=>{t.target===t.currentTarget&&L()},children:s.jsxs("div",{className:"ad-preview-box ps-detail",role:"dialog","aria-label":e.name[l],children:[s.jsxs("header",{children:[s.jsx("b",{children:e.name[l]}),s.jsx("button",{className:"ad-iconbtn","aria-label":a("Đóng"),onClick:L,children:"✕"})]}),e.kind==="sfxlib"?s.jsx(_n,{item:e,locale:l}):e.kind==="sfx"?s.jsx(Wn,{item:e,locale:l,owned:r,free:o}):s.jsxs("div",{className:"ps-stage",children:[s.jsx("canvas",{ref:p,width:640,height:360,style:{display:N?"block":"none"}}),!N&&(e.previewUrl&&/\.(mp4|webm)(\?|$)/.test(e.previewUrl)?s.jsx("video",{src:e.previewUrl,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):e.previewUrl||e.thumbnailUrl?s.jsx("img",{src:e.previewUrl||e.thumbnailUrl,alt:""}):s.jsx("span",{className:"ad-ph",children:"⧉"})),s.jsx("span",{className:"ps-stage-note",children:N?a("Xem thử trực tiếp trong sandbox"):o||r?A?a("Không tải được bản xem thử"):e.kind==="recipe"?a("Công thức chạy trên clip bạn chọn"):e.kind==="pack"?a("Gói {0} mục — cài rồi dùng từng mục trong tab Plug-in",[e.itemCount??0]):F(e)?a("Cài trong {0} trên máy bạn — không cài vào Timeline",[e.link.platform]):a("Đang tải bản xem thử…"):a("Mua để xem thử trực tiếp và dùng")})]}),e.kind==="pack"&&s.jsx(zn,{item:e,locale:l}),s.jsxs("div",{className:"ps-info",children:[e.featured&&s.jsxs("p",{className:"ps-featured-line",children:["★ ",a("Đối tác tiên phong của Clipoox")]}),e.private&&s.jsxs("p",{className:"ps-private-line",children:["🔒 ",a("Gói riêng: chỉ các tài khoản được Clipoox chọn mới thấy và cài được.")]}),s.jsxs("div",{className:"ps-row",children:[u,s.jsxs("span",{className:"ps-kind",children:[F(e)?e.link.platform:xn(Q(e),l)," · v",e.version," · ",e.author.name,e.kit?` · ${gn(e.kit.bytes,l)}`:"",I(e)?` · ${a("GLB ≤ 20 MB, ≤ 300 000 tam giác")}`:""]})]}),s.jsx("p",{children:e.description[l]}),F(e)&&e.link.commands.length>0&&s.jsx(qn,{commands:e.link.commands}),e.params.length>0&&s.jsxs("p",{className:"ps-params",children:[s.jsxs("b",{children:[a("Tham số chỉnh được"),":"]})," ",e.params.map(t=>t.label[l]).join(" · ")]}),j&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán… Hoàn tất trên trang clipoox.com vừa mở, rồi quay lại đây.")]}),c&&!r&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn mua này đã được hoàn tiền nên không cài mới được. Các clip đã dùng vẫn giữ nguyên.")}),f&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi — mở tab Plug-in để dùng.")]}),s.jsx("div",{className:"ad-actions",children:m}),I(e)&&!o&&!r&&s.jsxs("div",{className:"ps-lock",children:["🔒 ",a("Mô hình và texture chỉ tải về máy sau khi mua. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")]}),I(e)&&(o||r)&&s.jsx("small",{className:"muted",children:a("Tài nguyên 3D chỉ chép vào dự án khi bạn dùng một mục. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")}),!o&&!r&&e.kind!=="sfxlib"&&!z(e)&&s.jsx("small",{className:"muted",children:a("Thanh toán một lần trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit.")})]})]})})}function qn({commands:e}){const[l,r]=d.useState(!1),o=()=>{navigator.clipboard?.writeText(e.join(`
2
+ `)).then(()=>{r(!0),window.setTimeout(()=>r(!1),2e3)},()=>{})};return s.jsxs("div",{className:"ps-cmds",children:[s.jsxs("div",{className:"ps-cmds-head",children:[s.jsx("b",{children:a("Lệnh cài")}),s.jsx("span",{className:"muted",children:a("chạy trong terminal trên máy bạn")}),s.jsx("button",{className:"ad-chip",onClick:o,children:l?`✓ ${a("Đã chép")}`:a("Chép lệnh")})]}),s.jsx("pre",{children:e.join(`
3
+ `)})]})}function zn({item:e,locale:l}){const[r,o]=d.useState(null);if(d.useEffect(()=>{let c=!0;return An(e.id).then(m=>{c&&o(m.items)},()=>{c&&o([])}),()=>{c=!1}},[e.id]),!r?.length)return null;const j=c=>c.kind==="model"?a("Mô hình"):c.kind==="lut"?"Look":c.kind==="motion"&&c.engine==="3d"?"3D":c.kind==="recipe"?a("Combo"):c.kind==="lottie"?"Lottie":"2D";return s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"ps-items-head",children:[s.jsx("b",{children:a("{0} mục trong gói",[r.length])})," · ",s.jsx("span",{className:"muted",children:a("ảnh chụp từ lần chạy thử")})]}),s.jsx("div",{className:"ps-items",children:r.slice(0,24).map(c=>s.jsxs("figure",{children:[c.thumbnail?s.jsx("img",{src:`data:${c.thumbnail.type};base64,${c.thumbnail.data}`,alt:""}):s.jsx("span",{className:"ph",children:c.kind==="model"?"◈":"✦"}),s.jsxs("figcaption",{title:c.name[l],children:[j(c)," · ",c.name[l]]})]},c.id))})]})}function Wn({item:e,locale:l,owned:r,free:o}){const[j,c]=d.useState(null),[m,u]=d.useState(!1),[f,L]=d.useState(!1),[p,N]=d.useState(null),M=d.useRef(null),A=d.useRef(0);d.useEffect(()=>{let t=!0;return Pn(e.id).then(h=>{t&&(c(h.sounds),u(h.full))},()=>{t&&L(!0)}),()=>{t=!1,M.current?.pause(),window.clearTimeout(A.current)}},[e.id,r,o]);const C=t=>{if(M.current?.pause(),window.clearTimeout(A.current),p===t.id||!t.url){N(null);return}const h=new Audio(t.url);M.current=h,h.volume=.8,N(t.id),h.onended=()=>N(v=>v===t.id?null:v),t.preview&&(A.current=window.setTimeout(()=>{h.pause(),N(v=>v===t.id?null:v)},q.previewSeconds*1e3+300)),h.play().catch(()=>N(null))};return s.jsxs("div",{className:"ps-sounds","data-full":m?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Y,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["♪ ",a("{0} âm thanh",[e.soundCount??j?.length??0])," · ",un(e.totalDuration)]}),s.jsx("small",{className:"muted",children:m?a("Nghe đầy đủ — bấm ▶"):a("Nghe thử {0} âm thanh đầu, mỗi âm tối đa {1} giây. Mua để nghe đủ và dùng.",[q.previewCount,q.previewSeconds])})]})]}),f&&s.jsx("p",{className:"ad-alert",role:"alert",children:a("Không tải được bản xem thử")}),j===null&&!f&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),j&&s.jsx("ul",{className:"ps-sound-list","aria-label":a("Âm thanh trong gói"),children:j.map(t=>{const h=t.name?.[l]||t.name?.vi||t.id;return s.jsxs("li",{className:`${p===t.id?"on":""}${t.url?"":" locked"}`,"data-store-sound":t.id,children:[s.jsx("button",{className:"tl-sfx-play",disabled:!t.url,"aria-label":t.url?`${a("Nghe thử")} ${h}`:a("Mua để nghe {0}",[h]),title:t.url?a("Nghe thử"):a("Mua để nghe"),onClick:()=>C(t),children:t.url?p===t.id?"■":"▶":"🔒"}),s.jsxs("span",{className:"ps-sound-name",children:[s.jsxs("span",{className:"ell",children:[h,t.loop?" ↻":""]}),s.jsxs("small",{className:"muted ell",children:[Tn(t.category,l),t.tags.length?` · ${t.tags.slice(0,3).join(", ")}`:""]})]}),s.jsxs("small",{className:"muted",children:[t.preview&&(t.previewSeconds??0)<t.duration-.05?`▶ ${(t.previewSeconds??0).toFixed(1)}s / `:"",t.duration.toFixed(1),"s"]})]},t.id)})})]})}function _n({item:e,locale:l}){const r=d.useCallback(m=>Un(e.id,m),[e.id]),[o,j]=d.useState(null),c=d.useCallback(async m=>{const u=await r(m);return j(u.access.full),u},[r]);return s.jsxs("div",{className:"ps-sounds","data-full":o?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Y,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["📚 ",a("{0} âm thanh",[(e.soundCount??0).toLocaleString(l==="en"?"en-US":"vi-VN")])," · ",pn(e.totalDuration,l)]}),s.jsxs("div",{className:"ps-stats",children:[(e.folders?.length??0)>0&&s.jsxs("span",{children:[s.jsx("b",{children:e.folders.length})," ",a("thư mục")]}),s.jsxs("span",{children:[s.jsx("b",{children:"48 kHz"})," stereo"]}),s.jsxs("span",{children:["v",e.version]})]}),s.jsx("small",{className:"muted",children:o?a("Nghe đầy đủ — thêm âm từ mục SFX của Timeline."):a("Nghe thử mọi âm ({0} giây, chất lượng thấp). Mua để nghe đủ và dùng.",[q.previewSeconds])})]})]}),s.jsx($n,{libId:e.id,fetchPage:c,variant:"store"})]})}function Xn({item:e,owned:l,busy:r,installed:o,onInstall:j,onBuy:c}){const m=hn(),u=e.kind==="sfxlib",f=(e.passVnd??0)>0||(e.passUsd??0)>0,L=e.priceVnd>0||e.priceUsd>0,p=s.jsx("button",{className:"ad-use ps-big",disabled:r,onClick:j,children:r?a("Đang cài…"):o?a("Cài lại"):a("Cài plug-in")});return l?.owned&&!l.expiresAt?p:l?.owned?s.jsxs("div",{className:"ps-lib-buy-wrap",children:[p,f&&s.jsx("button",{className:"ad-use ps-big ps-alt",onClick:()=>c("pass"),children:a("Gia hạn thêm 30 ngày · {0}",[W(e)])}),s.jsx("small",{className:"muted",children:a("Vé đến {0}. Gia hạn cộng nối từ ngày đó, không tự trừ tiền.",[H(l.expiresAt,m)])})]}):s.jsxs("div",{className:"ps-lib-buy-wrap",children:[l?.expiresAt&&s.jsx("div",{className:"ps-waiting",children:u?a("Vé 30 ngày đã hết hạn ngày {0}. Âm đã dùng trong dự án vẫn giữ nguyên.",[H(l.expiresAt,m)]):a("Vé 30 ngày đã hết hạn ngày {0}. Lớp đã thêm vào video vẫn giữ nguyên.",[H(l.expiresAt,m)])}),s.jsxs("div",{className:"ps-lib-buy",children:[f&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("pass"),children:[a("Vé 30 ngày · {0}",[W(e)]),s.jsx("small",{children:a("Trả lại để gia hạn, không tự trừ tiền")})]}),L&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("lifetime"),children:[a("Mua trọn đời · {0}",[R(e)]),s.jsx("small",{children:u?a("Một lần, gồm các đợt âm mới"):a("Một lần, dùng mãi mãi")})]})]}),s.jsx("small",{className:"muted",children:u?a("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Âm đã dùng trong dự án vẫn giữ khi vé hết hạn."):a("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Hết vé thì không thêm mới được; lớp đã thêm vào video vẫn giữ nguyên.")})]})}export{Ns as default};