clipoox-render 0.4.3 → 0.4.5

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 (191) hide show
  1. package/package.json +4 -3
  2. package/scripts/render-local.mjs +5160 -1446
  3. package/web/assets/FxEmbed-DbfuM8Yo.js +1 -0
  4. package/web/assets/MotionEmbed-CBQ-8Tzh.js +1 -0
  5. package/web/assets/PluginStore-OOEx0lP5.js +3 -0
  6. package/web/assets/ShotComposer-Cng515xa.js +287 -0
  7. package/web/assets/{ShotComposer-VixLbeMe.css → ShotComposer-deLi4grZ.css} +1 -1
  8. package/web/assets/TemplateEmbed-hjwM2b0o.js +2 -0
  9. package/web/assets/{TimelinePlugins-BYZ9y4m3.js → TimelinePlugins-D-NakABP.js} +4 -4
  10. package/web/assets/TimelineShotFx-D3kGhHN3.js +2 -0
  11. package/web/assets/TransitionEmbed-DR26yI3a.js +1 -0
  12. package/web/assets/{Whiteboard-BP_DvIAV.js → Whiteboard-BhxY0D0Z.js} +3 -3
  13. package/web/assets/aerial-BisYSXzG.js +2 -0
  14. package/web/assets/agentTools-CPFQeiDP.js +2 -0
  15. package/web/assets/aiInbetween-AOOM1e6p.js +2 -0
  16. package/web/assets/analyzerRun-Dtp2o7gT.js +1 -0
  17. package/web/assets/analyzerSandbox-BG_3Cea1.js +33 -0
  18. package/web/assets/api-BFN7blbw.js +3158 -0
  19. package/web/assets/auraTrack-D_gxHNVe.js +1 -0
  20. package/web/assets/breakthrough-0qFpZW-V.js +2 -0
  21. package/web/assets/{cameraPresets-CYw0OdM3.js → cameraPresets-eK3mP7qb.js} +1 -1
  22. package/web/assets/cameraTracker-BAQHuTV-.js +72 -0
  23. package/web/assets/captionLayout-CWPcbid-.js +1 -0
  24. package/web/assets/clientExport-DvpTTndR.js +1 -0
  25. package/web/assets/clientJobs-CIrYTMpn.js +2 -0
  26. package/web/assets/clientJobs-CuuUyhEy.js +1 -0
  27. package/web/assets/cutoutClean-CLYYAuXg.js +1 -0
  28. package/web/assets/depthEstimate-B7D7cGCl.js +1 -0
  29. package/web/assets/directorTools-CJD4Huqk.js +1 -0
  30. package/web/assets/distortFrames-BLt1icUb.js +2 -0
  31. package/web/assets/{distortGL-QalhICvi.js → distortGL-BA5molk-.js} +3 -3
  32. package/web/assets/draco_decoder-C32yEggz.wasm +0 -0
  33. package/web/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
  34. package/web/assets/draco_decoder-fzg4nYZr.js +34 -0
  35. package/web/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
  36. package/web/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
  37. package/web/assets/editTools-NKLsWZD1.js +1 -0
  38. package/web/assets/{engine-BedcnK45.js → engine-DioUF2mX.js} +1 -1
  39. package/web/assets/exportGlb-BOdI9cVS.js +2 -0
  40. package/web/assets/faceTracker-D7CbF-qX.js +1 -0
  41. package/web/assets/fightDirector-CYP8jxo8.js +1 -0
  42. package/web/assets/fightDrama-DIPcRKnc.js +2 -0
  43. package/web/assets/focusTool-vfabPqQ5.js +1 -0
  44. package/web/assets/{frameSink-DeM8xC8_.js → frameSink-DYs2gTzq.js} +3 -3
  45. package/web/assets/glTransitionSources.generated-DM5sRMX2.js +3695 -0
  46. package/web/assets/gltfLoader-U0Eebg7v.js +2 -0
  47. package/web/assets/{gpuCompose-CA3UmOl4.js → gpuCompose-DbnZuelB.js} +1 -1
  48. package/web/assets/gpuExport-CQ7ZhpsX.js +198 -0
  49. package/web/assets/handMatte-DIbMuqCu.js +1 -0
  50. package/web/assets/handTracker-DY_g5Xmg.js +2 -0
  51. package/web/assets/i18n-BJppIrtF.js +3 -0
  52. package/web/assets/index-BfrDwjDI.js +4247 -0
  53. package/web/assets/index-CKtv7gGE.js +9 -0
  54. package/web/assets/{index-D5oyVCRl.js → index-DxdDhmLR.js} +2 -2
  55. package/web/assets/layer-worker-DK67WH1a.js +5 -0
  56. package/web/assets/library-B6KsZUKq.js +1 -0
  57. package/web/assets/lottieLayer-C2YbiXhK.js +161 -0
  58. package/web/assets/{lottie_light_canvas-B-d7-ATe.js → lottie_light_canvas-DX9Wf-DS.js} +1 -1
  59. package/web/assets/main-B27kf5aL.css +1 -0
  60. package/web/assets/main-BKatDoGw.js +309 -0
  61. package/web/assets/mapBake-C-G7WpFM.js +1 -0
  62. package/web/assets/maskTrack-LMrwm5ub.js +1 -0
  63. package/web/assets/matteFixRun-B38CbeEt.js +1 -0
  64. package/web/assets/matteQuality-9X-jgJrH.js +1 -0
  65. package/web/assets/objectLocate-CKi3OTnL.js +1 -0
  66. package/web/assets/objectSegmenter-CziPuM61.js +1 -0
  67. package/web/assets/{objectTrack.worker-BlZkgpOX.js → objectTrack.worker-b7DJ-ub6.js} +196 -196
  68. package/web/assets/pathTracer-bqau16sX.js +2 -0
  69. package/web/assets/pendingMatte-CQb7jPg1.js +2 -0
  70. package/web/assets/personAi-CQntGDqK.js +2 -0
  71. package/web/assets/personHq-B1c0QVJT.js +2 -0
  72. package/web/assets/plateCamera-D7iLiNBy.js +1 -0
  73. package/web/assets/plateCameraMatch-BM88dx-a.js +2 -0
  74. package/web/assets/plateFollow-4iGUDTu1.js +2 -0
  75. package/web/assets/plateMatte-zTyuHHqh.js +2 -0
  76. package/web/assets/plugin-guide.en-DO_fHbzT.js +1 -0
  77. package/web/assets/plugin-guide.vi-CMJDxOhi.js +1 -0
  78. package/web/assets/pluginAutomation-DSg-sYLF.js +1 -0
  79. package/web/assets/poseTracker-DZl8l2qS.js +1 -0
  80. package/web/assets/productTools-B-jh8ukh.js +2 -0
  81. package/web/assets/remote-DJd9xWjn.js +963 -0
  82. package/web/assets/{rigTrack-urT3nDK0.js → rigTrack-XaMj1yaH.js} +1 -1
  83. package/web/assets/rotoMaskStore-DdpmT9C3.js +1 -0
  84. package/web/assets/{rotoMatte-C-2o3vv0.js → rotoMatte-i-cJTYmK.js} +1 -1
  85. package/web/assets/rotoscope-DqRSWmHR.js +1 -0
  86. package/web/assets/sceneTrack-Bbov7zET.js +1 -0
  87. package/web/assets/sceneTrack-DIPzBmMK.js +1 -0
  88. package/web/assets/{sceneTrack.worker-CT4uoTKn.js → sceneTrack.worker-Bav9h0pv.js} +180 -180
  89. package/web/assets/shot-worker-m-q77W9f.js +1 -0
  90. package/web/assets/{shotFxAgent-BFLkqs8v.js → shotFxAgent-DIMS7BGA.js} +2 -2
  91. package/web/assets/{skin-DY4QLaBI.js → skin-DrUzJE1u.js} +1 -1
  92. package/web/assets/{spark.module-DzziUgOj.js → spark.module-Y1SEI8Xz.js} +10 -10
  93. package/web/assets/spellDuel-DNnyQDVr.js +2 -0
  94. package/web/assets/store-GFMJzaWS.js +1 -0
  95. package/web/assets/surfaceLight-C--moyc9.js +1 -0
  96. package/web/assets/surfacePin-B4-1UqXD.js +2 -0
  97. package/web/assets/{textAnimators-DUZjhVGO.js → textAnimators-BVXTl8bU.js} +1 -1
  98. package/web/assets/{thumb-CS0ZuiGS.js → thumb-CTfDJgLp.js} +1 -1
  99. package/web/assets/timeline3d-Dn7PqmEe.js +2 -0
  100. package/web/assets/timeline3dExport-DCOr6ARB.js +1 -0
  101. package/web/assets/timelineComp-Dx_kED5V.js +1 -0
  102. package/web/assets/timelineOps-afzSo188.js +525 -0
  103. package/web/assets/timelineProps-eYgO6gs5.js +1 -0
  104. package/web/assets/timelineText-RKyRP988.js +1 -0
  105. package/web/assets/{titleArt-Drsrtfiv.js → titleArt-CUtA0C3I.js} +4 -4
  106. package/web/assets/{titleFrameBudget-CLZWaFHO.js → titleFrameBudget-X7HLSDre.js} +721 -704
  107. package/web/assets/titleFrames-aMG7HdVe.js +1 -0
  108. package/web/assets/{tool-DktQYmS6.js → tool-DpFjybaq.js} +1 -1
  109. package/web/assets/{tools-Co9aRDiT.js → tools-CeOU0p13.js} +1 -1
  110. package/web/assets/toonTools-DLmo37Z_.js +2 -0
  111. package/web/assets/trackAnchor-hAOtEhKO.js +1 -0
  112. package/web/assets/userFonts-1kuRjWOo.js +1 -0
  113. package/web/assets/{vfxAlpha-71tSN86T.js → vfxAlpha-DxS5-QwY.js} +2 -2
  114. package/web/assets/vfxBackground-CYpaQaTa.js +2 -0
  115. package/web/assets/videoExport-Cg4B2Nyh.js +1 -0
  116. package/web/assets/views-CUXyRb9x.js +1 -0
  117. package/web/assets/weaponDuel-nFECu9nk.js +1 -0
  118. package/web/assets/windowFrames-1wAkkWnv.js +1 -0
  119. package/web/layer-worker.html +3 -3
  120. package/web/shot-worker.html +41 -0
  121. package/web/assets/FxEmbed-BCmj9Q5C.js +0 -1
  122. package/web/assets/GLTFLoader-BHWu1lKg.js +0 -1
  123. package/web/assets/MotionEmbed-CEmbcq8Z.js +0 -1
  124. package/web/assets/PluginStore-C5hyahvG.js +0 -3
  125. package/web/assets/ShotComposer-0DUtMTVI.js +0 -287
  126. package/web/assets/TemplateEmbed-ANxSs7H5.js +0 -2
  127. package/web/assets/TimelineShotFx-q5PQwq-V.js +0 -2
  128. package/web/assets/TransitionEmbed-O6LInGWq.js +0 -1
  129. package/web/assets/aerial-CGLDKKtP.js +0 -2
  130. package/web/assets/agentTools-2Ghb80VH.js +0 -2
  131. package/web/assets/analyzerRun-DRgxrcJA.js +0 -1
  132. package/web/assets/analyzerSandbox-DuIVFnsk.js +0 -33
  133. package/web/assets/api-CJ8PdbfZ.js +0 -3168
  134. package/web/assets/auraTrack-DQw9sVU6.js +0 -1
  135. package/web/assets/breakthrough-BNj_iTDr.js +0 -2
  136. package/web/assets/captionLayout-DvDPTwO9.js +0 -1
  137. package/web/assets/clientExport-xhoXY6Dh.js +0 -1
  138. package/web/assets/depthEstimate-DEpeCojm.js +0 -1
  139. package/web/assets/directorTools-C5CpTmci.js +0 -1
  140. package/web/assets/distortFrames-Dia8O1NM.js +0 -2
  141. package/web/assets/editTools-CY_JrQfw.js +0 -1
  142. package/web/assets/exportEncode-QYsT9JBO.js +0 -1
  143. package/web/assets/exportGlb-TSj09XoV.js +0 -2
  144. package/web/assets/faceTracker-CnCWOwnJ.js +0 -1
  145. package/web/assets/fightDirector-DCI_FWTh.js +0 -1
  146. package/web/assets/fightDrama-Bg7uP_2Q.js +0 -2
  147. package/web/assets/gpuExport-D31azOQA.js +0 -198
  148. package/web/assets/handMatte-Dl-xVXFR.js +0 -1
  149. package/web/assets/handTracker-CplBsAFg.js +0 -2
  150. package/web/assets/layer-worker-DFuo32bk.js +0 -5
  151. package/web/assets/library-BufgA-Pl.js +0 -1
  152. package/web/assets/lottieLayer-DzbA3bHV.js +0 -158
  153. package/web/assets/main-Ca_CVxMz.css +0 -1
  154. package/web/assets/main-VVYiW8XD.js +0 -309
  155. package/web/assets/mapBake-BKOcEd0w.js +0 -1
  156. package/web/assets/maskTrack-CHGXtBRy.js +0 -1
  157. package/web/assets/matteFixRun-vgYrINet.js +0 -1
  158. package/web/assets/objectLocate-BJltm8Ob.js +0 -1
  159. package/web/assets/pendingMatte-BPyzzx4y.js +0 -2
  160. package/web/assets/personAi-gJu03SjU.js +0 -2
  161. package/web/assets/plateCamera-B2JvhjJw.js +0 -1
  162. package/web/assets/plateCameraMatch-ByB9nVQT.js +0 -2
  163. package/web/assets/plateFollow-C9S-l7RH.js +0 -2
  164. package/web/assets/plateMatte-J4qlNHnY.js +0 -2
  165. package/web/assets/plugin-guide.en-CGYh_9Su.js +0 -1
  166. package/web/assets/plugin-guide.vi-DMphSELb.js +0 -1
  167. package/web/assets/pluginAutomation-CkP3tA9r.js +0 -1
  168. package/web/assets/poseTracker-DGLbouqt.js +0 -1
  169. package/web/assets/productTools-CkaWF1bM.js +0 -2
  170. package/web/assets/remote-C7J0Tqhb.js +0 -1433
  171. package/web/assets/rotoMaskStore-DPziPKAN.js +0 -1
  172. package/web/assets/rotoscope-GvPFRUBg.js +0 -1
  173. package/web/assets/shot-worker-6dYkHPoL.js +0 -1
  174. package/web/assets/spellDuel-BD3m2ebA.js +0 -2
  175. package/web/assets/store-DW4E9xnW.js +0 -1
  176. package/web/assets/surfaceLight-aDSYU8Jg.js +0 -1
  177. package/web/assets/surfacePin-m83hCgGP.js +0 -2
  178. package/web/assets/timeline3d-DOw-CpZI.js +0 -2
  179. package/web/assets/timeline3dExport-BtYLU1pw.js +0 -1
  180. package/web/assets/timelineComp-B4GtoH2f.js +0 -1
  181. package/web/assets/timelineProps-D7MVutxu.js +0 -1
  182. package/web/assets/timelineText-BH09jfSM.js +0 -1
  183. package/web/assets/titleFrames-BI1DnLBn.js +0 -1
  184. package/web/assets/toonTools-CD9clJvN.js +0 -2
  185. package/web/assets/trackAnchor-sOjTtd3I.js +0 -1
  186. package/web/assets/userFonts-CwlKh9NR.js +0 -1
  187. package/web/assets/vfxBackground-Bq7lJvmZ.js +0 -2
  188. package/web/assets/videoExport-D4KbireJ.js +0 -1
  189. package/web/assets/views-ozVF4ABO.js +0 -1
  190. package/web/assets/weaponDuel-ZhX-tjGZ.js +0 -1
  191. package/web/assets/windowFrames-CpqX3kOM.js +0 -1
@@ -0,0 +1 @@
1
+ import{b_ as T,ez as ot,eA as rt,jn as it,eE as K,jo as nt,dW as st,eF as lt,eB as O,dY as j,eD as U,eI as q,eH as Q,eJ as X,eG as Z}from"./titleFrameBudget-X7HLSDre.js";import{l as ht,d as dt}from"./titleArt-CUtA0C3I.js";import{i as I,j as mt,s as k,d as P,l as ct,k as G,f as ft,e as J,a as pt,p as ut,t as wt,m as tt}from"./lottieLayer-C2YbiXhK.js";import{wantsFrame as V,SKIPPED_FRAME as gt}from"./frameSink-DYs2gTzq.js";import{t as N}from"./i18n-BJppIrtF.js";import"./textAnimators-BVXTl8bU.js";import"./rigTrack-XaMj1yaH.js";import"./api-BFN7blbw.js";import"./index-CKtv7gGE.js";const xt=e=>U(e.title)||!!e.shape||!!e.motion||!!e.lottie||!!e.card||!!e.geo,Y=e=>e.kind==="image"&&!!e.title?.text&&!e.url&&!U(e.title),H=4,z=192*1024*1024,g=new Map;let A=0;function Et(e,s){if(e.geo||e.shape&&I(e.shape)||e.pin?.scene||e.space)return null;const{start:n,track:h,...i}=e;return JSON.stringify([s,i])}function Mt(e,s){const n=s.reduce((h,i)=>h+i.length,0);if(!(n>z/4)){g.delete(e),g.set(e,{frames:s,bytes:n}),A+=n;for(const[h,i]of g){if(A<=z)break;g.delete(h),A-=i.bytes}}}function Dt(){g.clear(),A=0}const bt=e=>new Promise((s,n)=>e.toBlob(h=>{if(!h)return n(Error("Cannot encode title frame"));const i=new FileReader;i.onload=()=>s(String(i.result).slice(String(i.result).indexOf(",")+1)),i.onerror=()=>n(i.error),i.readAsDataURL(h)},"image/webp",.9));async function Ht(e,s,n,h,i){const{fps:o,width:f,height:S}=T(s),p=T({...s,resolution:"720p"}),F=e.some(t=>t.shape&&I(t.shape))?ot(rt(e)):null,$=!!n.wants;for(const t of e.filter(d=>(xt(d)||Y(d))&&!d.warped)){if(!V(n,"titleFrames",t.id))continue;const d=a=>V(n,"titleFrames",t.id,a),m=Et(t,s),r=m?g.get(m):void 0;if(r){g.delete(m),g.set(m,r);for(const a of r.frames){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");await n.push("titleFrames",t.id,a)}continue}const x=[],E=t.title,M=it(t)||Y(t)?1:Math.ceil(t.duration*o);if(M>1&&Math.ceil(t.duration*o)>3600)throw Error("Mỗi tiêu đề động / Motion tối đa 2 phút khi xuất MP4.");E&&!t.shape&&!t.motion&&!t.lottie&&!t.card&&!t.geo&&await ht(E);const b=t.card?await mt(t.card).catch(a=>{throw Error(N("Thẻ HTML “{0}”: {1}",[t.label,a.message]))}):null,[u,w]=b?[b.width,b.height]:t.geo?[p.width,p.height]:t.lottie?[K(t.lottie).W,K(t.lottie).H]:t.motion?[p.width,p.height]:t.shape?[k(t.shape).W,k(t.shape).H]:[1280,720],C=Object.assign(document.createElement("canvas"),{width:u,height:w}),y=C.getContext("2d");if(!y)throw Error("Canvas unavailable");let R="",D=null;const _=(a,l)=>tt({layer:`export:${a.id}`,motion:a.motion,t:Z(a,l/o),width:u,height:w,duration:X(a),fps:o,surface:a.pin?.scene?Q(a,e,a.start+l/o,u,w):null,space:a.space?(O(e),q(a,e,a.start+l/o,u,w,i)):null}),c=[],L="\0same",W="\0skip",B=t.shape&&!t.motion&&!t.card&&!t.lottie&&!t.geo&&!I(t.shape)?nt(t.shape):null,et=B==null?1/0:Math.max(B,...["trimStart","trimEnd"].flatMap(a=>st(t,a).map(l=>l.time))),v=async()=>{const a=await c.shift();if(a===W){await n.push("titleFrames",t.id,gt);return}if(a===L||a===R){x.push("="),await n.push("titleFrames",t.id,"=");return}R=a,x.push(a),await n.push("titleFrames",t.id,a)};try{for(let a=0;a<M;a++){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");if(!d(a)){c.push(Promise.resolve(W)),c.length>=H&&await v();continue}if(!$&&a>0&&(a-1)/o>et+1e-6){c.push(Promise.resolve(L)),c.length>=H&&await v();continue}if(y.clearRect(0,0,u,w),t.motion){let l;try{l=await(D??_(t,a)),D=a+1<M&&d(a+1)?_(t,a+1):null}catch(at){throw D?.catch(()=>{}),P(`export:${t.id}`),Error(`Motion “${t.label}”: ${at.message}`)}y.drawImage(l,0,0),l.close()}else if(t.lottie)try{await ct(`export:${t.id}`,t.url,{W:u,H:w},lt(t,a/o),C)}catch(l){throw G(`export:${t.id}`),Error(`Lottie “${t.label}”: ${l.message}`)}else if(t.geo)try{await ft(`export:${t.id}`,t.geo,{W:u,H:w},a/o,C,{wait:2e4,duration:t.duration})}catch(l){throw J(`export:${t.id}`),Error(N("Bản đồ “{0}”: {1}",[t.label,l.message]))}else b?y.drawImage(b,0,0):t.shape?(F&&O(F),pt(y,ut(t,e,a/o,f,S),{start:j(t,"trimStart",a/o),end:j(t,"trimEnd",a/o),offset:wt(t.shape)},u,w,a/o)):dt(y,E,{time:a/o,duration:t.duration});c.push(bt(C)),c.length>=H&&await v()}for(;c.length;)await v();m&&!$&&Mt(m,x)}finally{for(const a of c)a.catch(()=>{})}t.motion&&P(`export:${t.id}`),t.lottie&&G(`export:${t.id}`),t.geo&&J(`export:${t.id}`)}}function Ot(e,s,n,h){const{fps:i}=T(n),{width:o,height:f}=T({...n,resolution:"720p"}),S=Math.ceil(e.duration*i)-1,p=Object.assign(document.createElement("canvas"),{width:o,height:f}),F=p.getContext("2d");if(!F)throw Error("Canvas unavailable");const $=r=>tt({layer:`export:${e.id}`,motion:e.motion,t:Z(e,r/i),width:o,height:f,duration:X(e),fps:i,surface:e.pin?.scene?Q(e,s,e.start+r/i,o,f):null,space:e.space?(O(s),q(e,s,e.start+r/i,o,f,h)):null});let t=null,d=-1;const m=r=>{r?.p.then(x=>x.close(),()=>{})};return{W:o,H:f,async frame(r){if(r=Math.max(0,Math.min(S,r)),r===d)return p;for(;t&&t.i<r;){const M=t;t=null,await M.p.then(b=>b.close(),()=>{})}const x=t&&t.i===r?t.p:$(r);t&&t.i!==r&&m(t),t=null;let E;try{E=await x}catch(M){throw P(`export:${e.id}`),Error(`Motion “${e.label}”: ${M.message}`)}return t=r<S?{i:r+1,p:$(r+1)}:null,F.clearRect(0,0,o,f),F.drawImage(E,0,0),E.close(),d=r,p},close(){m(t),t=null,P(`export:${e.id}`)}}}export{Dt as clearFrameCache,Et as frameCacheKey,Ot as liveMotion,Ht as renderTitleFrames};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GLTFExporter-BuGYM-Ik.js","assets/three.module-Bx43vjkH.js"])))=>i.map(i=>d[i]);
2
- import{dU as P}from"./remote-C7J0Tqhb.js";import{_ as R}from"./titleFrameBudget-CLZWaFHO.js";import{Vector3 as S,WebGLRenderer as O,NeutralToneMapping as D,SRGBColorSpace as B,Scene as F,Color as k,HemisphereLight as G,DirectionalLight as C,PerspectiveCamera as $,Mesh as q,Group as _,BufferGeometry as U,BufferAttribute as x,InstancedMesh as W,Matrix4 as Z,MeshPhysicalMaterial as V,DoubleSide as Y,FrontSide as X}from"./three.module-Bx43vjkH.js";const f=Object.freeze({code:24e3,triangles:3e5,instanceTriangles:3e6,meshes:64,instances:2e4,params:12,timeoutMs:8e3,size:500}),J=String.raw`
2
+ import{al as P}from"./remote-DJd9xWjn.js";import{_ as R}from"./titleFrameBudget-X7HLSDre.js";import{Vector3 as S,WebGLRenderer as O,NeutralToneMapping as D,SRGBColorSpace as B,Scene as F,Color as k,HemisphereLight as G,DirectionalLight as C,PerspectiveCamera as $,Mesh as q,Group as _,BufferGeometry as U,BufferAttribute as x,InstancedMesh as W,Matrix4 as Z,MeshPhysicalMaterial as V,DoubleSide as Y,FrontSide as X}from"./three.module-Bx43vjkH.js";const f=Object.freeze({code:24e3,triangles:3e5,instanceTriangles:3e6,meshes:64,instances:2e4,params:12,timeoutMs:8e3,size:500}),J=String.raw`
3
3
  const __codeModel = (() => {
4
4
  const LIM = ${JSON.stringify(f)}
5
5
  let seed = 1, noiseSeed = 1
@@ -1 +1 @@
1
- import{b as N,c as E,a as _,d as D}from"./shotFxAgent-BFLkqs8v.js";import{jj as P,jk as B,gM as h,eL as L,eq as A,dJ as U,dH as X}from"./remote-C7J0Tqhb.js";import"./api-CJ8PdbfZ.js";import"./titleFrameBudget-CLZWaFHO.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";const j=(s,n)=>{const o=h(s);return{anchor:n?(c,d,x)=>n.partPointAt(o,x,c.id,d):void 0,items:s.items,shot:o,at:(c,d)=>{const x=s.items.find(b=>b.id===c.id),k=X(x,o,o.duration?Math.max(0,Math.min(1,d/o.duration)):0);return{position:k.position,rotation:k.rotation}},uid:()=>crypto.randomUUID(),restPose:{...U.Đứng}}},w=(s,n,o)=>({...s,shots:s.shots.map(c=>c.id===s.activeShot?{...c,fxTiming:{...c.fxTiming,[n]:o}}:c)}),v=(s,n)=>{const o=A(s,h(n));return{name:s.name,id:s.id,effect:s.fx.cat??s.fx.preset,preset:s.fx.preset,start_s:o.start,end_s:+(o.start+o.duration).toFixed(2),...s.fx.attach?{attach:s.fx.attach}:{},...s.fx.path?{path:s.fx.path}:{}}};function Y(s,n,o){const c=o.engine();c&&c.sync(o.getStage(),null);const d=o.getStage();if(s==="add_effect"){const t=N(n,j(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;if(e.fx&&e.fx.preset in P&&o.userText!=null&&!B(o.userText))return{ok:!1,error:"blood effects are only used when the user asks for blood (máu / blood) in their message — leave it out"};o.setStage(i=>w({...i,items:[...i.items,e]},e.id,t.timing));const f=h(o.getStage());return{ok:!0,...v(e,o.getStage()),...t.timing.start+t.timing.duration>f.duration+.01?{note:"the effect runs past the end of the shot; shorten it or extend the shot with set_duration"}:{},hint:"render_preview / preview_motion at the effect time to check it is readable"}}if(s==="add_destruction"){const t=E(n,j(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;o.setStage(i=>{const a=w({...i,items:[...i.items,e]},e.id,t.timing);return{...a,shots:a.shots.map(p=>p.id===a.activeShot?{...p,objectKeys:{...p.objectKeys,[e.id]:t.keys}}:p)}});const f=d.items.filter(i=>i.fx?.preset===e.fx.preset&&i.fx?.target?.to===e.fx?.target?.to&&i.id!==e.id).map(i=>i.name);return{ok:!0,...v(e,o.getStage()),target:d.items.find(i=>i.id===e.fx?.target?.to)?.name,recipe:e.fx.params.recipe,...t.keys.length?{sphere_path:t.keys.map(i=>({at_s:+(i.time*h(d).duration).toFixed(2),position:i.position}))}:{mode:e.fx.params.mode},...f.length?{combines_with:f}:{},hint:"render_preview after the sweep / collapse time to see the destruction; remove_effect removes it"}}if(s==="edit_destruction"){const t=_(d.items.filter(m=>m.kind==="fx"&&m.fx?.preset===L),String(n.name));if(!t?.fx)return{ok:!1,error:`no Mix FX named '${String(n.name)}' (add_destruction makes one; scene_summary lists effects)`};const e=h(d),f=e.duration||1,i=[];let a=d;const p=m=>m.map((r,u)=>({id:`${t.id}-k${u}-${Math.round(r.time*1e6)}`,time:r.time,position:r.position,rotation:[...t.rotation],scale:[...t.scale]})),T=m=>{a={...a,shots:a.shots.map(r=>r.id===a.activeShot?{...r,objectKeys:{...r.objectKeys,[t.id]:m}}:r)}};if(n.target!=null){const m=d.items.find(r=>r.name.toLowerCase()===String(n.target).toLowerCase()&&r.kind!=="fx");if(!m)return{ok:!1,error:`no object '${String(n.target)}' to break`};a={...a,items:a.items.map(r=>r.id===t.id?{...r,fx:{...r.fx,target:{to:m.id,part:"center"}}}:r)},i.push(`target ${m.name}`)}if(Array.isArray(n.points)){if(n.points.length<2||n.points.length>24)return{ok:!1,error:"points: 2 to 24 path points"};const m=[];for(const r of n.points){const u=Number(r.time_s),l=r.position;if(!Number.isFinite(u)||u<0||u>f+1e-6)return{ok:!1,error:`time_s ${String(r.time_s)} is outside the shot (0–${f} s)`};if(!Array.isArray(l)||l.length!==3||!l.every(y=>Number.isFinite(Number(y))))return{ok:!1,error:"each point needs position [x, y, z]"};m.push({time:Math.min(1,u/f),position:l.map(Number)})}T(p(m.sort((r,u)=>r.time-u.time))),i.push(`path of ${m.length} points`)}else if(n.sweep===!0){const m=a.items.find(F=>F.id===t.id).fx,r=m.target?.to?c?.objectBounds()[m.target.to]:null;if(!r)return{ok:!1,error:"sweep measures the target: it needs the 3D view (a scene open in the composer or the render machine) and a target"};const u=m.params,l=Number(u.radius)*t.scale[0]+Number(u.falloff)+.3,y=(r.min[1]+r.max[1])/2,K=(r.min[2]+r.max[2])/2,S=A(t,e),M=Math.min(1,S.start/f),O=Math.min(1,(S.start+S.duration)/f);T(p([{time:M,position:[r.min[0]-l,y,K]},{time:O,position:[r.max[0]+l,y,K]}])),i.push("sweep through the target")}if(!i.length)return{ok:!1,error:"give points, sweep or target"};const $=a;return o.setStage(()=>$),{ok:!0,name:t.name,changed:i,path_s:(h($).objectKeys?.[t.id]||[]).map(m=>+(m.time*f).toFixed(3))}}if(s==="update_effect"){const t=_(d.items.filter(a=>a.kind==="fx"),String(n.name));if(!t?.fx)return{ok:!1,error:`no effect named '${String(n.name)}'; use remove_effect / update_effect with the name returned by add_effect (see scene_summary effects)`};const e=h(d),f=A(t,e),i=D(t,n,{...j(d,c),timing:f});return i.ok?(o.setStage(a=>w({...a,items:a.items.map(p=>p.id===t.id?{...p,...i.itemPatch,fx:i.fx}:p)},t.id,{start:i.timing.start,duration:i.timing.duration,...i.timing.loop?{loop:!0}:{}})),{ok:!0,...v(o.getStage().items.find(a=>a.id===t.id),o.getStage())}):{ok:!1,error:i.error}}const x=Array.isArray(n.names)?n.names.map(String):n.name!=null?[String(n.name)]:[],k=[],b=[],g=new Set;for(const t of x){const e=_(d.items.filter(f=>f.kind==="fx"),t);e?(g.add(e.id),k.push(e.name)):b.push(t)}for(const t of d.items)t.trackAnchor&&g.has(t.trackAnchor.effect)&&g.add(t.id);return o.setStage(t=>({...t,items:t.items.filter(e=>!g.has(e.id)),shots:t.shots.map(e=>({...e,...e.fxTiming?{fxTiming:Object.fromEntries(Object.entries(e.fxTiming).filter(([f])=>!g.has(f)))}:{},...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([f])=>!g.has(f)))}:{}}))})),{ok:!b.length,removed:k,missing:b}}export{Y as runFxTool};
1
+ import{b as N,c as E,a as _,d as D}from"./shotFxAgent-DIMS7BGA.js";import{ft as P,fu as B,de as h,bd as U,aU as A,aa as L,a8 as X}from"./remote-DJd9xWjn.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./titleFrameBudget-X7HLSDre.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";const w=(s,n)=>{const o=h(s);return{anchor:n?(c,d,x)=>n.partPointAt(o,x,c.id,d):void 0,items:s.items,shot:o,at:(c,d)=>{const x=s.items.find(b=>b.id===c.id),k=X(x,o,o.duration?Math.max(0,Math.min(1,d/o.duration)):0);return{position:k.position,rotation:k.rotation}},uid:()=>crypto.randomUUID(),restPose:{...L.Đứng}}},v=(s,n,o)=>({...s,shots:s.shots.map(c=>c.id===s.activeShot?{...c,fxTiming:{...c.fxTiming,[n]:o}}:c)}),j=(s,n)=>{const o=A(s,h(n));return{name:s.name,id:s.id,effect:s.fx.cat??s.fx.preset,preset:s.fx.preset,start_s:o.start,end_s:+(o.start+o.duration).toFixed(2),...s.fx.attach?{attach:s.fx.attach}:{},...s.fx.path?{path:s.fx.path}:{}}};function ot(s,n,o){const c=o.engine();c&&c.sync(o.getStage(),null);const d=o.getStage();if(s==="add_effect"){const t=N(n,w(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;if(e.fx&&e.fx.preset in P&&o.userText!=null&&!B(o.userText))return{ok:!1,error:"blood effects are only used when the user asks for blood (máu / blood) in their message — leave it out"};o.setStage(i=>v({...i,items:[...i.items,e]},e.id,t.timing));const f=h(o.getStage());return{ok:!0,...j(e,o.getStage()),...t.timing.start+t.timing.duration>f.duration+.01?{note:"the effect runs past the end of the shot; shorten it or extend the shot with set_duration"}:{},hint:"render_preview / preview_motion at the effect time to check it is readable"}}if(s==="add_destruction"){const t=E(n,w(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;o.setStage(i=>{const a=v({...i,items:[...i.items,e]},e.id,t.timing);return{...a,shots:a.shots.map(p=>p.id===a.activeShot?{...p,objectKeys:{...p.objectKeys,[e.id]:t.keys}}:p)}});const f=d.items.filter(i=>i.fx?.preset===e.fx.preset&&i.fx?.target?.to===e.fx?.target?.to&&i.id!==e.id).map(i=>i.name);return{ok:!0,...j(e,o.getStage()),target:d.items.find(i=>i.id===e.fx?.target?.to)?.name,recipe:e.fx.params.recipe,...t.keys.length?{sphere_path:t.keys.map(i=>({at_s:+(i.time*h(d).duration).toFixed(2),position:i.position}))}:{mode:e.fx.params.mode},...f.length?{combines_with:f}:{},hint:"render_preview after the sweep / collapse time to see the destruction; remove_effect removes it"}}if(s==="edit_destruction"){const t=_(d.items.filter(m=>m.kind==="fx"&&m.fx?.preset===U),String(n.name));if(!t?.fx)return{ok:!1,error:`no Mix FX named '${String(n.name)}' (add_destruction makes one; scene_summary lists effects)`};const e=h(d),f=e.duration||1,i=[];let a=d;const p=m=>m.map((r,u)=>({id:`${t.id}-k${u}-${Math.round(r.time*1e6)}`,time:r.time,position:r.position,rotation:[...t.rotation],scale:[...t.scale]})),T=m=>{a={...a,shots:a.shots.map(r=>r.id===a.activeShot?{...r,objectKeys:{...r.objectKeys,[t.id]:m}}:r)}};if(n.target!=null){const m=d.items.find(r=>r.name.toLowerCase()===String(n.target).toLowerCase()&&r.kind!=="fx");if(!m)return{ok:!1,error:`no object '${String(n.target)}' to break`};a={...a,items:a.items.map(r=>r.id===t.id?{...r,fx:{...r.fx,target:{to:m.id,part:"center"}}}:r)},i.push(`target ${m.name}`)}if(Array.isArray(n.points)){if(n.points.length<2||n.points.length>24)return{ok:!1,error:"points: 2 to 24 path points"};const m=[];for(const r of n.points){const u=Number(r.time_s),l=r.position;if(!Number.isFinite(u)||u<0||u>f+1e-6)return{ok:!1,error:`time_s ${String(r.time_s)} is outside the shot (0–${f} s)`};if(!Array.isArray(l)||l.length!==3||!l.every(y=>Number.isFinite(Number(y))))return{ok:!1,error:"each point needs position [x, y, z]"};m.push({time:Math.min(1,u/f),position:l.map(Number)})}T(p(m.sort((r,u)=>r.time-u.time))),i.push(`path of ${m.length} points`)}else if(n.sweep===!0){const m=a.items.find(M=>M.id===t.id).fx,r=m.target?.to?c?.objectBounds()[m.target.to]:null;if(!r)return{ok:!1,error:"sweep measures the target: it needs the 3D view (a scene open in the composer or the render machine) and a target"};const u=m.params,l=Number(u.radius)*t.scale[0]+Number(u.falloff)+.3,y=(r.min[1]+r.max[1])/2,K=(r.min[2]+r.max[2])/2,S=A(t,e),O=Math.min(1,S.start/f),F=Math.min(1,(S.start+S.duration)/f);T(p([{time:O,position:[r.min[0]-l,y,K]},{time:F,position:[r.max[0]+l,y,K]}])),i.push("sweep through the target")}if(!i.length)return{ok:!1,error:"give points, sweep or target"};const $=a;return o.setStage(()=>$),{ok:!0,name:t.name,changed:i,path_s:(h($).objectKeys?.[t.id]||[]).map(m=>+(m.time*f).toFixed(3))}}if(s==="update_effect"){const t=_(d.items.filter(a=>a.kind==="fx"),String(n.name));if(!t?.fx)return{ok:!1,error:`no effect named '${String(n.name)}'; use remove_effect / update_effect with the name returned by add_effect (see scene_summary effects)`};const e=h(d),f=A(t,e),i=D(t,n,{...w(d,c),timing:f});return i.ok?(o.setStage(a=>v({...a,items:a.items.map(p=>p.id===t.id?{...p,...i.itemPatch,fx:i.fx}:p)},t.id,{start:i.timing.start,duration:i.timing.duration,...i.timing.loop?{loop:!0}:{}})),{ok:!0,...j(o.getStage().items.find(a=>a.id===t.id),o.getStage())}):{ok:!1,error:i.error}}const x=Array.isArray(n.names)?n.names.map(String):n.name!=null?[String(n.name)]:[],k=[],b=[],g=new Set;for(const t of x){const e=_(d.items.filter(f=>f.kind==="fx"),t);e?(g.add(e.id),k.push(e.name)):b.push(t)}for(const t of d.items)t.trackAnchor&&g.has(t.trackAnchor.effect)&&g.add(t.id);return o.setStage(t=>({...t,items:t.items.filter(e=>!g.has(e.id)),shots:t.shots.map(e=>({...e,...e.fxTiming?{fxTiming:Object.fromEntries(Object.entries(e.fxTiming).filter(([f])=>!g.has(f)))}:{},...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([f])=>!g.has(f)))}:{}}))})),{ok:!b.length,removed:k,missing:b}}export{ot as runFxTool};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sceneTrack-Bbov7zET.js","assets/titleFrameBudget-X7HLSDre.js"])))=>i.map(i=>d[i]);
2
+ import{_ as C}from"./titleFrameBudget-X7HLSDre.js";import{de as P,fg as D,bU as L,cv as j,al as U,fv as B,fw as E,fx as F,cm as $,ct as O,cu as I}from"./remote-DJd9xWjn.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";const T=["twos","snap","anticipation","exaggerate","squash","smear"],A=t=>Array.isArray(t)&&t.length===3&&t.every(h=>Number.isFinite(Number(h)))?t.map(Number):null,K=t=>t==="left"?"L":t==="both"?"both":"R",w=t=>Math.round(t*1e3)/1e3;function rt(t,h){const c=h.getStage(),d=P(c),a=t.on!==!1&&t.on!=="false",s={on:a};if(t.amount!=null){const r=Number(t.amount);if(!Number.isFinite(r))return{ok:!1,error:"amount must be a number 0–1"};s.amount=Math.max(0,Math.min(1,r))}for(const r of T)typeof t[r]=="boolean"&&(s[r]=t[r]);if(t.shot_default){const r=O({...d.toon||I,...s});return h.setStage(m=>({...m,shots:m.shots.map(f=>f.id===d.id?{...f,toon:r}:f)})),{ok:!0,shot_default:r,note:"every person / prop without its own setting uses it (set_toon on a name overrides one object)"}}const o=Array.isArray(t.names)?t.names.map(String):t.name!=null?[String(t.name)]:[];if(!o.length)return{ok:!1,error:"give names (people / props) or shot_default:true"};let l;try{l=o.map(r=>D(c,r))}catch(r){return{ok:!1,error:r.message}}const k=l.filter(r=>!["person","prop","box","sphere","cylinder","model"].includes(r.kind));if(k.length)return{ok:!1,error:`the cartoon style works on people, props and simple objects, not on ${k.map(r=>`'${r.name}' (${r.kind})`).join(", ")}`};const u={};return h.setStage(r=>({...r,items:r.items.map(m=>{if(!l.some(p=>p.id===m.id))return m;const f=O({...O(m.toon)||I,...s});return u[m.name]=f,{...m,toon:f}})})),{ok:!0,toon:u,note:a?"applied at render time on top of the keyed motion (anticipation before strong moves, overshoot + settle after stops, snappy key poses, exaggerated angles, squash & stretch, smears); keys are unchanged":"off: the keyed motion plays exactly as keyed"}}async function at(t,h){const c=h.getStage(),d=P(c),a=String(t.action||"drop");if(!["drop","bounce","hold","throw","catch","dribble"].includes(a))return{ok:!1,error:`unknown action '${a}'; use drop, bounce, hold, throw, catch or dribble`};const s=Math.max(0,Math.min(d.duration,Number(t.time??0)||0));let o;if(t.person!=null){try{o=D(c,String(t.person))}catch(e){return{ok:!1,error:e.message}}if(!L(o))return{ok:!1,error:`'${o.name}' is not a person`}}if(["hold","throw","dribble","catch"].includes(a)&&!o&&a!=="throw")return{ok:!1,error:`${a} needs person`};let l=t.name!=null?c.items.find(e=>e.name===String(t.name)&&e.kind==="prop"&&e.prop?.kind==="ball"):void 0;const k=!l,u=A(t.position),r=j.radius;if(!l){const e=o?[o.position[0]+Math.sin(o.rotation[1]*Math.PI/180)*.6,o.position[1]+r,o.position[2]+Math.cos(o.rotation[1]*Math.PI/180)*.6]:[0,r,0];l=U(c,{kind:"prop",name:String(t.name||"Bóng rổ"),prop:{kind:"ball"},color:"#d8641c",position:u?[u[0],Math.max(r,u[1]),u[2]]:e})}t.toon!==!1&&!l.toon&&(l={...l,toon:{on:!0,amount:Math.max(0,Math.min(1,Number(t.amount??.6)))}}),t.bounciness!=null&&(l={...l,ball:{restitution:Math.max(.3,Math.min(.95,Number(t.bounciness)||j.restitution))}});const m=K(t.hand),f=(d.ball?.[l.id]||[]).filter(e=>e.t<s-1e-6),p=[],y=A(t.velocity);let x=A(t.target),b=null;if(a==="throw"&&!y&&!x&&t.target_person==null){if(b=B((await E(h,c)).colliders,o?.position??l.position),!b&&t.target==="hoop")return{ok:!1,error:"no hoop in the scene: build_set a court with parts named rim / vành rổ and backboard / bảng rổ, or give target [x,y,z]"};b&&(x=[...b.rim])}let v;if(t.target_person!=null)try{v=D(c,String(t.target_person))}catch(e){return{ok:!1,error:e.message}}if(a==="drop"||a==="bounce")p.push({t:s,kind:"launch",from:u??[...l.position],vel:y??(a==="bounce"?[0,3.5,0]:[0,0,0])});else if(a==="hold")p.push({t:s,kind:"hold",by:o.id,hand:m});else if(a==="dribble")p.push({t:s,kind:"dribble",by:o.id,hand:m==="both"?"R":m,period:Math.max(.3,Math.min(1.2,Number(t.period)||.55))});else if(a==="throw"){const e=[...f].reverse().find(g=>g.kind==="hold"||g.kind==="dribble");if(o&&!(e&&"by"in e&&e.by===o.id))p.push({t:Math.max(0,s-.001),kind:"hold",by:o.id,hand:m});else if(!o&&!e)return{ok:!1,error:"throw needs person (or an earlier hold / dribble of this ball)"};const i=t.arrive!=null?Math.max(.2,Number(t.arrive)):void 0;p.push({t:s,kind:"throw",...y?{vel:y}:v?{to:{by:v.id,hand:"both"},arrive:i??.9}:{to:x??[l.position[0],3.05,l.position[2]+4],...i?{arrive:i}:{},apex:Number(t.apex)||(b?1:.9),...b?{net:!0}:{}}}),v&&p.push({t:s+(i??.9),kind:"hold",by:v.id,hand:"both"})}else if(a==="catch"){const e=Math.max(.3,Math.min(3,Number(t.flight)||.9)),i=u??(o?[o.position[0]+Math.sin(o.rotation[1]*Math.PI/180)*4.5,o.position[1]+1.5,o.position[2]+Math.cos(o.rotation[1]*Math.PI/180)*4.5]:[...l.position]);p.push({t:Math.max(0,s-e),kind:"launch",from:i,to:{by:o.id,hand:m}},{t:s,kind:"hold",by:o.id,hand:m})}const N=[...f.filter(e=>!p.some(i=>i.t<=e.t+1e-6)),...p].sort((e,i)=>e.t-i.t),_=l.id,M=l;h.setStage(e=>({...e,items:k?[...e.items,M]:e.items.map(i=>i.id===_?M:i),shots:e.shots.map(i=>i.id===d.id?{...i,ball:{...i.ball,[_]:N}}:i)}));const S=p.find(e=>e.kind==="launch"&&Array.isArray(e.vel)),n=S&&S.kind==="launch"?F(S.from??M.position,S.vel,S.t,d.duration,{radius:r,restitution:M.ball?.restitution}).impacts.slice(0,8).map(e=>w(e.time)):void 0;return{ok:!0,name:M.name,created:k,...b?{hoop:"aimed through the rim centre, drops through the net"}:{},events:N.map(e=>({...e,t:w(e.t)})),...n?{bounce_times:n}:{},note:"the ball moves analytically (ballistic arcs, bounces losing height by its bounciness, squash on each bounce with the cartoon style on); it follows the hand while held / dribbled"}}async function st(t,h){const c=h.getStage(),d=P(c),a=await C(()=>import("./sceneTrack-Bbov7zET.js").then(n=>n.X),__vite__mapDeps([0,1]));let s;if(t.all_props===!0)s=c.items.filter(n=>!n.hidden&&["box","sphere","cylinder","prop","proxy","model"].includes(n.kind)&&!a.dropUnavailable(n));else{const n=Array.isArray(t.objects)?t.objects.map(String):Array.isArray(t.names)?t.names.map(String):[];if(!n.length)return{ok:!1,error:"give objects (names) or all_props:true"};try{s=n.map(i=>D(c,i))}catch(i){return{ok:!1,error:i.message}}const e=s.map(i=>[i,a.dropUnavailable(i)]).filter(([,i])=>i);if(e.length)return{ok:!1,error:`cannot drop ${e.map(([i])=>`'${i.name}' (${i.kind}${i.locked?", locked":i.hold?", held":""})`).join(", ")}: physics_drop moves objects and props, not people, effects, sets or the floor`}}if(s=s.filter(n=>!(n.kind==="prop"&&n.prop?.kind==="ball"&&d.ball?.[n.id]?.length)),!s.length)return{ok:!1,error:"nothing to drop (a ball with add_ball motion keeps its own motion)"};if(s.length>a.MAX_PHYSICS_BODIES)return{ok:!1,error:`at most ${a.MAX_PHYSICS_BODIES} objects per drop`};const o=Math.max(0,Math.min(d.duration,Number(t.time??0)||0)),l=d.duration-o;if(l<a.DROP_SECONDS.min)return{ok:!1,error:`time ${w(o)} s is too close to the end of the shot (${d.duration} s)`};const k=Math.min(l,Math.max(1,Math.min(a.DROP_SECONDS.max,Number(t.duration)||a.DROP_SECONDS.default))),u=o/d.duration,r=a.DROP_MODES.includes(t.mode)?t.mode:"above",m=t.bounciness,f=typeof m=="number"||m==="bouncy"||m==="heavy"?m:"normal",p=h.engine(),y=s.map(n=>n.id);p&&p.sync(c,null);const x=p?.physicsShapes(y)??{},b=(await E(h,c)).colliders.filter(n=>!y.includes(n.itemId)),v={},N=s.map(n=>{const e=$(n,d,u),i=[...d.objectKeys?.[n.id]||[]].filter(g=>g.time<u-1e-6).sort((g,R)=>g.time-R.time).pop();return v[n.id]=i,{id:n.id,position:e.position,rotation:e.rotation,shape:a.shapeKind(n),...x[n.id]??a.fallbackShape(n)}}),_=await a.bakeDrop({bodies:N,statics:b,mode:r,bounciness:f,duration:k,start:o,shotDuration:d.duration,height:Number(t.height)||void 0,strength:Number(t.strength)||void 0,velocity:A(t.velocity)??void 0,seed:t.seed!=null?String(t.seed):y.join(","),before:v,seam:d.lockUntil?d.lockUntil/d.duration:null}),M=Object.fromEntries(s.map(n=>[n.id,$(n,d,u).scale]));h.setStage(n=>a.applyDropKeys(n,d.id,_.tracks,{scale:M,lifted:r==="above"}));const S={};for(const n of s){const e=_.tracks[n.id];e&&(S[n.name]={keys:e.keys.length,rest:e.rest,settled_at:e.settledAt==null?null:w(o+e.settledAt)})}return{ok:!0,mode:r,from:w(o),until:w(o+k),objects:S,settled:_.settled,note:"baked into ordinary keys (no physics at playback); their keys after `from` were replaced. Run again with another seed for a different tumble."}}export{at as addBall,st as physicsDrop,rt as setToon};
@@ -0,0 +1 @@
1
+ import{b as v,de as b,fr as _,a8 as M}from"./remote-DJd9xWjn.js";import{a as F}from"./shotFxAgent-DIMS7BGA.js";import{c_ as N,c$ as y,d0 as A}from"./timelineOps-afzSo188.js";import{Vector3 as j}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./titleFrameBudget-X7HLSDre.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./rigTrack-XaMj1yaH.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./clientJobs-CuuUyhEy.js";const C=4,T=1.25;function w(t,c,r){return t.updateMatrixWorld(),new j(c*2-1,1-r*2,.5).unproject(t).sub(t.position).normalize()}function S(t,c,r){const o=b(t),s=Math.max(1e-6,o.duration),f=t.items.find(n=>n.kind==="person"&&!n.hidden);return c.points.map(([n,d,l])=>{const m=Math.max(0,Math.min(1,n/s)),p=_(o,m),a=w(p,d,l);let u=r??NaN;if(!Number.isFinite(u)&&f){const h=M(f,o,m);u=new j(h.position[0],h.position[1]+T*Math.max(.3,h.scale[1]),h.position[2]).sub(p.position).dot(a)}(!Number.isFinite(u)||u<.3)&&(u=C);const k=p.position.clone().addScaledVector(a,u);return{t:m,d:u,position:[k.x,k.y,k.z].map(h=>Math.round(h*1e4)/1e4)}})}function J(t,c,r,o,s){const f=b(t),n=Math.max(1e-6,f.duration),d=_(f,Math.max(0,Math.min(1,c/n))),l=w(d,r,o);if(s&&l.y<-.01){const m=-d.position.y/l.y;if(m>.3&&m<80){const p=d.position.clone().addScaledVector(l,m);return[p.x,0,p.z].map(a=>Math.round(a*1e4)/1e4)}}return S(t,{points:[[Math.max(0,Math.min(n,c)),r,o]]})[0].position}function K(t,c,r){const o=b(c).duration;try{if(t.track!=null)return N(t.track,o);const s=String(t.source??"");if(!y.includes(s))return`give track {fps, points} or source ${y.join(" / ")}`;const f=c.plate?.timelineClipId,n=f?r.timelineClip?.(f):void 0;return n?A(n,s,{side:t.side==="left"?"left":"right",point:typeof t.point=="string"?t.point:"palm",...typeof t.object=="string"?{object:t.object}:{},to:o}):"the Timeline clip of this VFX scene is not open in this tab: pass `track` (MCP: shot_run_tool follow_track with timeline {project_id, clip_id} fills it)"}catch(s){return s.message}}function Q(t,c){const r=c.getStage();if(!r.plate)return{ok:!1,error:"follow_track needs a VFX scene: one made from a filmed Timeline clip (MCP shot_create_scene with from_clip, or the clip's 3D button)"};const o=F(r.items.filter(i=>i.kind==="fx"),String(t.name??""));if(!o?.fx)return{ok:!1,error:`no effect named '${String(t.name)}' (scene_summary lists the effects)`};const s=r.items.find(i=>i.trackAnchor?.effect===o.id);if(t.stop===!0)return s?(c.setStage(i=>({...i,items:i.items.filter(e=>e.id!==s.id).map(e=>e.id===o.id?{...e,fx:{...e.fx,...e.fx.attach?.to===s.id?{attach:void 0}:{},...e.fx.target?.to===s.id?{target:void 0}:{}}}:e),shots:i.shots.map(e=>({...e,...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([$])=>$!==s.id))}:{}}))})),{ok:!0,name:o.name,stopped:!0}):{ok:!1,error:`${o.name} follows no track`};const f=K(t,r,c);if(typeof f=="string")return{ok:!1,error:f};const n=t.depth_m==null?void 0:Number(t.depth_m);if(n!==void 0&&!(n>=.3&&n<=200))return{ok:!1,error:"depth_m must be 0.3–200 (metres from the camera)"};const d=t.offset==null?void 0:Array.isArray(t.offset)&&t.offset.length===3&&t.offset.every(i=>Number.isFinite(Number(i))&&Math.abs(Number(i))<=20)?t.offset.map(Number):null;if(d===null)return{ok:!1,error:"offset must be [x, y, z] metres (±20)"};const l=t.role==="target"?"target":"attach",m=S(r,f,n),p=t.track!=null?"given":t.source==="hand"?`hand:${t.side==="left"?"left":"right"}:${typeof t.point=="string"?t.point:"palm"}`:t.source==="object"&&typeof t.object=="string"?`object:${t.object}`:String(t.source),a=s?{...s,trackAnchor:{effect:o.id,source:p}}:{...v("sphere",r.items.length),name:`${o.name} · điểm bám`.slice(0,60),color:"#ffffff",trackAnchor:{effect:o.id,source:p}};a.position=m[0].position,a.rotation=[0,0,0],a.scale=[1,1,1];const u=m.map((i,e)=>({id:`${a.id}-t${e}`,time:i.t,position:i.position,rotation:[0,0,0],scale:[1,1,1]})),k={...o.fx,...l==="attach"?{attach:{to:a.id,follow:"position",...d?{offset:d}:{}}}:{target:{to:a.id,part:"center"}}};c.setStage(i=>({...i,items:[...i.items.filter(e=>e.id!==a.id).map(e=>e.id===o.id?{...e,fx:k}:e),a],shots:i.shots.map(e=>e.id===i.activeShot?{...e,objectKeys:{...e.objectKeys,[a.id]:u}}:e)}));const h=m.map(i=>i.d).sort((i,e)=>i-e),x=b(r).duration;return{ok:!0,name:o.name,anchor:a.name,source:p,role:l,samples:m.length,from_s:+f.points[0][0].toFixed(2),to_s:+f.points.at(-1)[0].toFixed(2),depth_m:+h[h.length>>1].toFixed(2),note:`${o.name} now ${l==="attach"?"rides on":"aims at"} the tracked point (${m.length} keys over ${x.toFixed(1)} s, ${n?`${n} m from the camera`:"at the filmed person's distance (the stand-in; run follow_plate first for a person who walks toward / away from the camera)"}). Re-run after the track changes; stop:true detaches. Export again (export_video vfx) to update the Timeline passes.`}}export{Q as followTrack,J as scenePoint,S as trackWorldPoints};
@@ -0,0 +1 @@
1
+ import{r as p}from"./index-CKtv7gGE.js";import{bQ as b,bR as S,u as U,bS as _}from"./api-BFN7blbw.js";import{u as C}from"./store-GFMJzaWS.js";import{i as w}from"./textAnimators-BVXTl8bU.js";import{t as f}from"./i18n-BJppIrtF.js";import"./titleFrameBudget-X7HLSDre.js";let r={fonts:[],loaded:!1,error:null};const l=new Set,u=t=>{r={...r,...t},l.forEach(o=>o())},E=t=>(l.add(t),()=>{l.delete(t)}),$=()=>p.useSyncExternalStore(E,()=>r),v=()=>r,x={ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2"},B=".ttf,.otf,.woff,.woff2,font/ttf,font/otf,font/woff,font/woff2",d=10,c=new Map;function h(t){if(!t.url||c.has(t.family)||typeof FontFace>"u")return;const o=new FontFace(t.family,`url(${JSON.stringify(t.url)})`,{weight:t.wght?`${t.wght[0]} ${t.wght[1]}`:"1 1000",style:"normal",display:"block"});document.fonts.add(o),c.set(t.family,o)}function m(t){const o=c.get(t);o&&(document.fonts.delete(o),c.delete(t))}let a=null,g=!1;function y(t=!1){return g||(g=!0,C.subscribe((o,e)=>{const n=o.user?.uid??null,i=e.user?.uid??null;if(n!==i)if(n)y(!0);else{for(const s of r.fonts)m(s.family);a=Promise.resolve(),u({fonts:[],loaded:!0,error:null})}})),a&&!t||(a=b().then(o=>{const e=(Array.isArray(o?.fonts)?o.fonts:[]).filter(n=>n&&w(n.family)&&typeof n.name=="string");for(const n of r.fonts)e.some(i=>i.family===n.family)||m(n.family);for(const n of e)try{h(n)}catch{}u({fonts:e,loaded:!0,error:null})}).catch(o=>{u({loaded:!0,error:o?.message||"fonts"})})),a}const P=()=>y();function z(t){return t?w(t)?r.fonts.find(o=>o.family===t)?.name??f("Font đã xoá"):t:"Arial"}const L=t=>!!t&&w(t)&&r.loaded&&!r.error&&!r.fonts.some(o=>o.family===t);function R(t){const o=t?.code;return o==="bad_font"?f("File này không phải font dùng được (.ttf, .otf, .woff, .woff2 · không nhận bộ .ttc · tối đa {0} MB).",[String(d)]):o==="font_limit"?f("Tối đa 50 font — xoá bớt font không dùng rồi tải lên lại."):o==="font_rights"?f("Cần xác nhận bạn có quyền dùng font trước khi tải lên."):o==="font_not_found"?f("Không tìm thấy font."):t?.message||String(t)}async function q(t,o){const e=(t.name.match(/\.([a-z0-9]+)$/i)?.[1]||"").toLowerCase(),n=x[e];if(!n)throw new Error(f("Chỉ nhận file font .ttf, .otf, .woff hoặc .woff2"));if(t.size>d*1024*1024)throw new Error(f("Font tối đa {0} MB",[String(d)]));const i=await U(new File([t],t.name,{type:n}),o,"font"),s=await _({gcsUri:i.gcsUri,rightsConfirmed:!0});return h(s.font),u({fonts:[s.font,...r.fonts.filter(F=>F.family!==s.font.family)]}),s}async function J(t){await S(t.id),m(t.family),u({fonts:r.fonts.filter(o=>o.id!==t.id)})}export{B as FONT_ACCEPT,d as FONT_MAX_MB,x as FONT_TYPES,R as fontError,z as fontLabel,L as isMissingCustomFont,y as loadUserFonts,J as removeUserFont,q as uploadUserFont,$ as useUserFonts,P as userFontsReady,v as userFontsState};
@@ -1,4 +1,4 @@
1
- import{i9 as D}from"./remote-C7J0Tqhb.js";import{FramebufferTexture as F,ShaderMaterial as S,Color as w,WebGLRenderTarget as k,NoColorSpace as O,HalfFloatType as A,UnsignedByteType as I}from"./three.module-Bx43vjkH.js";import"./api-CJ8PdbfZ.js";import"./titleFrameBudget-CLZWaFHO.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";const U=new S({uniforms:{tC:{value:null},tB:{value:null},tW:{value:null},uOcc:{value:0}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:`uniform sampler2D tC, tB, tW; uniform float uOcc; varying vec2 vUv;
1
+ import{eK as D}from"./remote-DJd9xWjn.js";import{FramebufferTexture as F,ShaderMaterial as S,Color as w,WebGLRenderTarget as k,NoColorSpace as O,HalfFloatType as A,UnsignedByteType as I}from"./three.module-Bx43vjkH.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./titleFrameBudget-X7HLSDre.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";const U=new S({uniforms:{tC:{value:null},tB:{value:null},tW:{value:null},uOcc:{value:0}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:`uniform sampler2D tC, tB, tW; uniform float uOcc; varying vec2 vUv;
2
2
  void main() {
3
3
  vec3 b = texture2D(tB, vUv).rgb, w = texture2D(tW, vUv).rgb;
4
4
  float occ = clamp(1.0 - max(max(w.r - b.r, w.g - b.g), w.b - b.b), 0.0, 1.0);
@@ -6,4 +6,4 @@ import{i9 as D}from"./remote-C7J0Tqhb.js";import{FramebufferTexture as F,ShaderM
6
6
  vec3 c = texture2D(tC, vUv).rgb;
7
7
  float a = max(occ, max(max(c.r, c.g), c.b));
8
8
  gl_FragColor = vec4(a > 0.002 ? clamp(c / a, 0.0, 1.0) : vec3(0.0), a);
9
- }`,depthTest:!1,depthWrite:!1}),n=(t,l,e)=>new k(t,l,{type:e?A:I,depthBuffer:e,samples:e?4:0,colorSpace:O});function j(t,l,e){const v=n(l,e,!0),i=n(l,e,!0),f=n(l,e,!1),g=new F(l,e),y=new D(U),T=new Uint8Array(l*e*4),B=new w(0,0,0),M=new w(1,1,1),C=(o,u,s,r)=>{const a=o.background,c=t.getRenderTarget();try{o.background=B,t.setRenderTarget(s),t.clear(),t.render(o,u),o.background=M,t.setRenderTarget(r),t.clear(),t.render(o,u)}finally{o.background=a,t.setRenderTarget(c)}},R=(o,u,s,r)=>{const a=U.uniforms;a.tB.value=u.texture,a.tW.value=s.texture,a.tC.value=g,a.uOcc.value=o?1:0,t.setRenderTarget(r),y.render(t),t.setRenderTarget(null)};return{frame(o,u,s){t.setRenderTarget(null),t.copyFramebufferToTexture(g),C(o,u,v,i),R(!1,v,i,f),t.readRenderTargetPixels(f,0,0,l,e,T);const r=s.createImageData(l,e),a=l*4;for(let c=0;c<e;c++)r.data.set(T.subarray((e-1-c)*a,(e-c)*a),c*a);s.putImageData(r,0,0)},occlusion(o,u,s=8){const r=Math.max(16,Math.round(l/s)),a=Math.max(16,Math.round(e/s)),c=n(r,a,!0),b=n(r,a,!0),x=n(r,a,!1),d=new Uint8Array(r*a*4);try{C(o,u,c,b),R(!0,c,b,x),t.readRenderTargetPixels(x,0,0,r,a,d);const m=[];for(let p=0;p<d.length;p+=4)m.push(d[p]);return m.sort((p,W)=>p-W),m[Math.floor(m.length*.98)]/255}finally{c.dispose(),b.dispose(),x.dispose()}},dispose(){v.dispose(),i.dispose(),f.dispose(),g.dispose(),y.dispose()}}}export{j as createVfxAlpha};
9
+ }`,depthTest:!1,depthWrite:!1}),n=(t,l,e)=>new k(t,l,{type:e?A:I,depthBuffer:e,samples:e?4:0,colorSpace:O});function Z(t,l,e){const i=n(l,e,!0),v=n(l,e,!0),f=n(l,e,!1),g=new F(l,e),y=new D(U),T=new Uint8Array(l*e*4),B=new w(0,0,0),M=new w(1,1,1),C=(o,u,s,r)=>{const a=o.background,c=t.getRenderTarget();try{o.background=B,t.setRenderTarget(s),t.clear(),t.render(o,u),o.background=M,t.setRenderTarget(r),t.clear(),t.render(o,u)}finally{o.background=a,t.setRenderTarget(c)}},R=(o,u,s,r)=>{const a=U.uniforms;a.tB.value=u.texture,a.tW.value=s.texture,a.tC.value=g,a.uOcc.value=o?1:0,t.setRenderTarget(r),y.render(t),t.setRenderTarget(null)};return{frame(o,u,s){t.setRenderTarget(null),t.copyFramebufferToTexture(g),C(o,u,i,v),R(!1,i,v,f),t.readRenderTargetPixels(f,0,0,l,e,T);const r=s.createImageData(l,e),a=l*4;for(let c=0;c<e;c++)r.data.set(T.subarray((e-1-c)*a,(e-c)*a),c*a);s.putImageData(r,0,0)},occlusion(o,u,s=8){const r=Math.max(16,Math.round(l/s)),a=Math.max(16,Math.round(e/s)),c=n(r,a,!0),b=n(r,a,!0),x=n(r,a,!1),d=new Uint8Array(r*a*4);try{C(o,u,c,b),R(!0,c,b,x),t.readRenderTargetPixels(x,0,0,r,a,d);const m=[];for(let p=0;p<d.length;p+=4)m.push(d[p]);return m.sort((p,W)=>p-W),m[Math.floor(m.length*.98)]/255}finally{c.dispose(),b.dispose(),x.dispose()}},dispose(){i.dispose(),v.dispose(),f.dispose(),g.dispose(),y.dispose()}}}export{Z as createVfxAlpha};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShotComposer-Cng515xa.js","assets/titleFrameBudget-X7HLSDre.js","assets/remote-DJd9xWjn.js","assets/index-CKtv7gGE.js","assets/i18n-BJppIrtF.js","assets/api-BFN7blbw.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-GFMJzaWS.js","assets/rotoMaskStore-DdpmT9C3.js","assets/sceneTrack-Bbov7zET.js","assets/timelineOps-afzSo188.js","assets/cameraTracker-BAQHuTV-.js","assets/textAnimators-BVXTl8bU.js","assets/timelineComp-Dx_kED5V.js","assets/rigTrack-XaMj1yaH.js","assets/clientJobs-CuuUyhEy.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/tool-DpFjybaq.js","assets/timelineProps-eYgO6gs5.js","assets/thumb-CTfDJgLp.js","assets/shotFxAgent-DIMS7BGA.js","assets/cameraPresets-eK3mP7qb.js","assets/weaponDuel-nFECu9nk.js","assets/skin-DrUzJE1u.js","assets/views-CUXyRb9x.js","assets/motionBlur-uAm030t9.js","assets/library-B6KsZUKq.js","assets/ShotComposer-deLi4grZ.css"])))=>i.map(i=>d[i]);
2
+ import{_ as l}from"./titleFrameBudget-X7HLSDre.js";import{R as h}from"./index-CKtv7gGE.js";import{V as w}from"./remote-DJd9xWjn.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";let p=Promise.resolve();const c=o=>new Promise(r=>setTimeout(r,o));function T(o,r,{timeoutMs:d=6e4}={}){const n=async()=>{const e=document.createElement("div");Object.assign(e.style,{position:"fixed",left:"-20000px",top:"0",width:"960px",height:"540px",pointerEvents:"none",contain:"strict"}),e.setAttribute("aria-hidden","true"),document.body.appendChild(e);const m=w.createRoot(e);try{const{default:u}=await l(async()=>{const{default:t}=await import("./ShotComposer-Cng515xa.js");return{default:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]));let i=null;m.render(h.createElement(u,{nodeId:o,background:t=>{i=t}}));const s=Date.now()+d;for(;!i?.ready();){if(Date.now()>s)throw new Error("3D Shot did not start in time");await c(60)}for(;;)try{return await r(i)}catch(t){if(!/chưa tải xong/.test(t.message)||Date.now()>s)throw t;await c(500)}}finally{m.unmount(),e.remove()}},a=p.then(n,n);return p=a.catch(()=>{}),a}export{T as withBackgroundScene};
@@ -0,0 +1 @@
1
+ import{dc as S}from"./remote-DJd9xWjn.js";import{s as U}from"./motionBlur-uAm030t9.js";import{M as ot}from"./motionBlur-uAm030t9.js";import{bF as C,c as M}from"./id3-arvEpAg7.js";import{S as O,B as D,O as H,W as P,a as B,C as I}from"./output-p-Q7qous.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./titleFrameBudget-X7HLSDre.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";async function et(s,T,m){const{start:u,end:F,fps:r,signal:d,progress:w}=m,a=F-u,n=Math.ceil(a*r);if(!(a>0)||!Number.isFinite(a)||!S.includes(r))throw new Error("Khoảng thời gian hoặc FPS không hợp lệ");const f=new C({bitrate:m.height>=1080?6e6:3e6}),o=m.alpha===!0,g=o?"vp9":"avc",k=o?"webm":"mp4";if(!await M(g,{width:s.width,height:s.height,quality:f}))throw new Error(o?"Trình duyệt chưa hỗ trợ xuất VP9 có kênh trong suốt. Hãy dùng Chrome/Edge mới.":"Trình duyệt chưa hỗ trợ xuất H.264. Hãy dùng Chrome/Edge mới, hoặc thử 720p.");let h,c;const l=`camera-export-${crypto.randomUUID()}.${k}`;let t;const y=async()=>{h&&await h.removeEntry(l).catch(()=>{})};try{let i;if(navigator.storage?.getDirectory)h=await navigator.storage.getDirectory(),c=await h.getFileHandle(l,{create:!0}),i=new O(await c.createWritable(),{chunked:!0,chunkSize:1024*1024});else{if(a*(m.height>=1080?6e6:3e6)/8>1e8)throw new Error("Trình duyệt này thiếu bộ nhớ tạm cho video dài. Dùng Chrome/Edge hoặc xuất một đoạn ngắn hơn.");i=new D}t=new H({format:o?new P:new B({fastStart:"reserve"}),target:i});const p=new I(s,{codec:g,quality:f,...o?{alpha:"keep"}:{}});t.addVideoTrack(p,{frameRate:r,maximumPacketCount:n}),await t.start();for(let e=0;e<n;e++){d.throwIfAborted();const b=e/r,x=Math.min(1/r,a-b);await T(u+(n>1?e/(n-1):0)*a),await p.add(b,x,{keyFrame:e%r===0}),e%6===0&&(w(Math.round((e+1)/n*95)),await new Promise(E=>setTimeout(E,0)))}d.throwIfAborted(),p.close(),await t.finalize();const v=c?await c.getFile():new Blob([i.buffer],{type:o?"video/webm":"video/mp4"});return w(100),{blob:v,cleanup:y}}catch(i){throw t&&t.state!=="finalized"&&t.state!=="canceled"&&await t.cancel().catch(()=>{}),await y(),i}}export{ot as MOTION_BLUR,et as encodeCameraVideo,U as shutterTimes};
@@ -0,0 +1 @@
1
+ import{Bone as k,SkinnedMesh as g,Vector3 as a,Scene as L,Color as M,MeshLambertMaterial as b,HemisphereLight as S,DirectionalLight as h,WebGLRenderer as z,OrthographicCamera as C}from"./three.module-Bx43vjkH.js";import{a as D}from"./gltfLoader-U0Eebg7v.js";import{f as E}from"./skin-DrUzJE1u.js";import"./remote-DJd9xWjn.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./titleFrameBudget-X7HLSDre.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";const B=640;function N(y,p=B){const t=D(y);t.position.set(0,0,0),t.quaternion.identity(),t.scale.set(1,1,1);const c=[];t.traverse(e=>{e.userData.rigOverlay&&c.push(e),e instanceof k&&e.quaternion.identity()}),c.forEach(e=>e.parent?.remove(e)),t.traverse(e=>{e instanceof g&&e.skeleton.pose()});const m=E(t),n=m.getCenter(new a),f=m.getSize(new a),r=Math.max(f.x,f.y,f.z)/2*1.08,o=new L;o.background=new M("#ffffff");const d=new b({color:"#8d949b"});o.overrideMaterial=d,o.add(new S("#ffffff","#5a6066",2.2));const l=new h("#ffffff",1.4);l.position.set(.4,1,1),o.add(l);const u=new h("#ffffff",.6);u.position.set(1,.5,.3),o.add(u),o.add(t);const i=new z({antialias:!0,preserveDrawingBuffer:!0});i.setSize(p,p,!1);const s=new C(-r,r,r,-r,.01,100),w=e=>(s.position.copy(n).add(e),s.up.set(0,1,0),s.lookAt(n),s.updateProjectionMatrix(),i.render(o,s),i.domElement.toDataURL("image/jpeg",.88));try{const e=r*4,x=w(new a(0,0,e)),v=w(new a(e,0,0));return{front:x,side:v,frame:{cx:n.x,cy:n.y,cz:n.z,half:r}}}finally{d.dispose(),i.dispose(),i.forceContextLoss(),t.traverse(e=>{e instanceof g&&e.skeleton.dispose()})}}export{B as VIEW_SIZE,N as renderRigViews};
@@ -0,0 +1 @@
1
+ import{f6 as pt,f7 as Y,bS as ut,bR as mt,bU as Z,bW as U,ei as kt,b as bt,bX as gt,c5 as tt,c6 as et,ee as Mt,cm as yt,eh as wt}from"./remote-DJd9xWjn.js";import{m as vt}from"./rigTrack-XaMj1yaH.js";const z=t=>pt(t)??(Y(t)?{clip:Y(t),pack:{id:"fist"}}:null),st=Object.freeze({spear:{"spear-thrust":"thrust","spear-overhead":"high","spear-sweep":"low","spear-spin":"side","spear-dive-thrust":"thrust"},katana:{"katana-overhead":"high","katana-diagonal":"high","katana-horizontal":"side","katana-rising":"side","katana-thrust":"thrust","katana-spin-cut":"side"},staff:{"staff-jab":"thrust","staff-overhead":"high","staff-sweep":"low","staff-rising":"side","staff-spin":"side"},fist:{"fist-lunge-punch":"thrust","fist-rising-uppercut":"side","fist-flying-kick":"side","fist-ground-slam":"high","fist-low-lunge":"thrust"}}),it={high:"block-high",side:"block-side",thrust:"block-side",low:null},jt=Object.freeze({spear:1.42,katana:.98,staff:1.1,fist:0}),Ot={body:.05,blocked:.22,miss:.18},Kt=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(z(t).clip),at.set(t,e)),e},At=(t,e)=>t[Math.max(0,Math.min(t.length-1,Math.round(e*30)))];function lt(t){const e=z(t).clip.keys.filter(i=>i.strike).at(-1);return e?e.t:0}const Ft=t=>z(t).clip.keys.filter(e=>e.strike).at(-1)?.limb??"handR",ot=(t,e)=>At(dt(t),e).dz??0;function St(t){const{pack:e}=z(t),i=dt(t),l=lt(t),o=Ft(t);let f=0;for(const h of i){if(Math.abs(h.t-l)>.1)continue;if(e.id==="fist"){const j=vt(h.pose),m=j[o.replace("foot","toe")];f=Math.max(f,m[2]-j.pelvis[2]);continue}const r=ut(h.pose),u=r.front[2]+r.dir[2]*jt[e.id];f=Math.max(f,u)}return f}function $t(t){let e=t>>>0||1;return()=>{e=e+1831565813>>>0;let i=Math.imul(e^e>>>15,1|e);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}function Tt(t,e=4,i=1){const l=$t(i),o=[];let f=0,h=["",""];for(let r=0;r<e;r++){r>0&&l()<.62&&(f=1-f);const u=t[f],j=t[1-f],m=Object.keys(st[u]).filter($=>$!==h[f]),b=m[Math.floor(l()*m.length)],C=st[u][b];h[f]=b;const a=l();let y=r===e-1?"body":a<.5?"blocked":a<.78?"miss":"body";y==="blocked"&&!it[C]&&(y="miss");const S=`${j}-${y==="blocked"?it[C]:y==="miss"?"dodge-back":"hit"}`,D=lt(b),O=z(S).clip.contact??0,g=Math.max(Kt,St(b)+Ot[y]+ot(b,D)+ot(S,O));o.push({attacker:f,attack:b,defence:S,result:y,strike:D,contact:O,gap:Math.round(g*1e3)/1e3})}return o}const R=[.18,.42],nt=t=>(t.kind==="model"?(t.model?.height??2)/1.8:Mt(t))*(t.scale[1]||1),q=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const i=v(t),l=i.duration/e,o=h=>h?.map(r=>({...r,time:Math.min(1,r.time*l)})),f={...i,duration:e,cameraKeys:o(i.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(i.objectKeys||{}).map(([h,r])=>[h,o(r)||[]])),...i.impacts?{impacts:o(i.impacts)}:{},...i.flight?{flight:Object.fromEntries(Object.entries(i.flight).map(([h,r])=>[h,o(r)||[]]))}:{},...i.focus?.keys?{focus:{...i.focus,keys:o(i.focus.keys)}}:{}};return{...t,shots:t.shots.map(h=>h.id===i.id?f:h)}}const ct=(t,e,i)=>{const l=v(t);return{...t,shots:t.shots.map(o=>o.id===l.id?{...o,objectKeys:{...o.objectKeys,[e]:i(o.objectKeys?.[e]||[],o)}}:o)}},T=(t,e,i)=>{const l=v(t),o=yt(t.items.find(f=>f.id===e.id),l,Math.min(1,i/l.duration));return{position:o.position,yaw:o.rotation[1]}};function zt(t,e,i){const l=t.items.find(s=>s.id===e.a),o=t.items.find(s=>s.id===e.b);if(!l||!o||!Z(l)||!Z(o))return{ok:!1,error:"two people are needed"};if(l.id===o.id)return{ok:!1,error:"two different people are needed"};const f=Math.max(1,Math.min(10,Math.round(e.exchanges))),h=Tt(e.packs,f,e.seed),r=[l,o],u=[nt(l),nt(o)],j=[],m=Math.max(0,e.start),b=v(t),C=m+.5+h.reduce((s,c)=>s+Math.max(U(c.attack).duration,c.strike-c.contact+U(c.defence).duration)+1.4+R[1],0);let a=C>b.duration?rt(t,Math.min(300,C)):t;const M=T(a,l,m),y=h[0].gap*(u[0]+u[1])/2,S=[Math.sin(q(M.yaw)),0,Math.cos(q(M.yaw))],D=[M.position[0]+S[0]*y,M.position[1],M.position[2]+S[2]*y];for(const[s,c,n]of[[l,M.position,M.yaw],[o,D,M.yaw+180]])a=ct(a,s.id,(d,k)=>[...d.filter(p=>p.time*k.duration<m-1e-6),{id:i(),time:m/k.duration,position:c.map(p=>+p.toFixed(3)),rotation:[0,+n.toFixed(1),0],scale:s.scale}]);const O=(s,c,n)=>{const d=v(a),k=U(c),p=wt(a,r[s].id,k,{start:n/d.duration,newId:i,loop:!1});if(!p.ok)throw new Error(`${r[s].name}: ${p.error}`);return a=p.stage,n+k.duration};let g=m+.35,$=m;const E=[];let x=(e.seed*9301+49297)%233280;const ht=()=>(x=(x*9301+49297)%233280,x/233280);try{h.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const K=T(a,r[0],g).position,A=T(a,r[1],g).position;return Math.hypot(A[0]-K[0],A[2]-K[2])};for(let K=0;K<3;K++){const A=p()-s.gap*k;if(Math.abs(A)<.3*k)break;A>0?g=O(n,`${e.packs[n]}-advance`,g):g=O(d,`${e.packs[d]}-retreat`,g)}const N=Math.max(0,s.contact-s.strike),w=g+N,_=w+s.strike-s.contact,P=p()-s.gap*k,W=O(n,s.attack,w),ft=O(d,s.defence,_),H=r[n],B=T(a,H,w).yaw,G=[Math.sin(q(B)),Math.cos(q(B))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,P));a=ct(a,H.id,(K,A)=>K.map(F=>{const I=F.time*A.duration;if(I<w-1e-6||I>W+1e-6)return F;const L=Math.min(1,(I-w)/Math.max(.001,s.strike)),X=L*L*(3-2*L),Q={...F,position:[+(F.position[0]+G[0]*V*X).toFixed(3),F.position[1],+(F.position[2]+G[1]*V*X).toFixed(3)]};return F.strike&&Math.abs(I-J)<.06?{...Q,hit:s.result}:Q})),E.push({...s,time:+J.toFixed(2),attackerName:H.name}),$=Math.max(W,ft),g=$+R[0]+(R[1]-R[0])*ht(),c===h.length-1&&j.push(`${r[d].name} dính đòn kết`)})}catch(s){return{ok:!1,error:s.message}}if(v(a).duration>b.duration&&(a=rt(a,Math.max(b.duration,Math.min(300,Math.ceil(($+.6)*10)/10)))),a=kt(a).stage,e.packs.includes("fist")){const s=v(a),c=[],n={};E.forEach((d,k)=>{if(d.result==="miss"||e.packs[d.attacker]!=="fist")return;const p=T(a,r[0],d.time).position,N=T(a,r[1],d.time).position,w=(u[0]+u[1])/2,_=`duelfx-${r[d.attacker].id}-${Math.round(d.time*1e3)}`,P=d.result==="body";c.push({...bt("fx",a.items.length+c.length),id:_,name:`Vòng xung kích ${c.length+1}`,position:[+((p[0]+N[0])/2).toFixed(2),0,+((p[2]+N[2])/2).toFixed(2)],color:P?"#ffd27a":"#9fdcff",fx:{preset:"vong_xung_kich",cat:"vong-xung-kich",intensity:P?.9:.75,seed:500+k,start:d.time,duration:.6,loop:!1,auto:"hit",params:{size:(P?1.05:.85)*w,height:+(1.35*w).toFixed(2),hits:1,gap:.3}}}),n[_]={start:d.time,duration:.6}}),c.length&&(a={...a,items:[...a.items,...c],shots:a.shots.map(d=>d.id===s.id?{...d,fxTiming:{...d.fxTiming,...n}}:d)})}if(e.hitStops!==!1){const s=v(a);let c=gt(s.timing,s.duration);c=tt(c,E.filter(n=>n.result==="blocked").map(n=>n.time),et.light,s.duration),c=tt(c,E.filter(n=>n.result==="body").map(n=>n.time),et.heavy,s.duration),a={...a,shots:a.shots.map(n=>n.id===s.id&&c?{...n,timing:c}:n)}}return{ok:!0,stage:a,plan:E,end:+$.toFixed(2),notes:j}}export{st as D,zt as s};
@@ -0,0 +1 @@
1
+ import{k9 as P,a7 as b,U as W,$ as y,Z as E,a0 as F,j1 as x}from"./titleFrameBudget-X7HLSDre.js";import"./rotoMatte-i-cJTYmK.js";import"./api-BFN7blbw.js";import"./i18n-BJppIrtF.js";import"./index-CKtv7gGE.js";import"./store-GFMJzaWS.js";const _=t=>P(t).length>0,O=new Map;function D(t){const r=t.face??t.colorPerson??t.person??t.roto??t.mask;if(r?.mw&&r?.mh)return Promise.resolve(r.mh/r.mw);let o=O.get(t.url);return o||(o=new Promise(n=>{if(t.kind==="image"){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a.naturalHeight/Math.max(1,a.naturalWidth)),a.onerror=()=>n(9/16),a.src=t.url;return}const e=document.createElement("video");e.preload="metadata",e.muted=!0,e.crossOrigin="anonymous",e.onloadedmetadata=()=>{n(e.videoHeight/Math.max(1,e.videoWidth)),e.removeAttribute("src"),e.load()},e.onerror=()=>n(9/16),e.src=t.url}),O.set(t.url,o)),o}function I(t,r,o,n,e,a,g){const i=W(t.grade)[r],h=t.colorPerson?E(t.colorPerson):null,p=F(i,t,o,a,h),c=g??document.createElement("canvas");(c.width!==n||c.height!==e)&&Object.assign(c,{width:n,height:e});const l=c.getContext("2d"),d=l.createImageData(n,e);for(let w=0;w<e;w++)for(let u=0;u<n;u++){const m=(w*n+u)*4,s=Math.round(p((u+.5)/n,(w+.5)/e,0,0,0)*255);d.data[m]=d.data[m+1]=d.data[m+2]=s,d.data[m+3]=255}return l.putImageData(d,0,0),c}async function B(t,r,o,n){const e=document.createElement("canvas");for(const{key:a,k:g,clip:i}of P(t)){if(o.wants&&!o.wants("windowFrames",a))continue;i.colorPerson&&await b(i.colorPerson);const h=await D(i),p=x,c=Math.max(2,Math.min(x*2,Math.round(p*h))),l=W(i.grade)[g],d=Math.ceil(i.duration*r),w=!!l.motion;let u="",m="";for(let s=0;s<d;s++){if(n?.aborted)throw new DOMException("Export cancelled","AbortError");if(o.wants&&!o.wants("windowFrames",a,s)){await o.push("windowFrames",a,""),m="";continue}if(w){const f=JSON.stringify(y(l,i,s/r));if(s&&f===m){await o.push("windowFrames",a,"=");continue}m=f}I(i,g,s/r,p,c,h,e);const M=e.toDataURL("image/webp",.9),v=M.slice(M.indexOf(",")+1);if(v===u){await o.push("windowFrames",a,"=");continue}u=v,await o.push("windowFrames",a,v),s%5===0&&await new Promise(f=>setTimeout(f,0))}}}export{_ as hasMovingWindows,D as pictureAspect,B as renderWindowFrames,I as windowMatteImage};
@@ -4,9 +4,9 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="robots" content="noindex" />
6
6
  <title>Timeline layer worker</title>
7
- <script type="module" crossorigin src="/assets/layer-worker-DFuo32bk.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-CLZWaFHO.js">
9
- <link rel="modulepreload" crossorigin href="/assets/frameSink-DeM8xC8_.js">
7
+ <script type="module" crossorigin src="/assets/layer-worker-DK67WH1a.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-X7HLSDre.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/frameSink-DYs2gTzq.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
@@ -0,0 +1,41 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="robots" content="noindex" />
6
+ <title>3D Shot worker</title>
7
+ <script type="module" crossorigin src="/assets/shot-worker-m-q77W9f.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-X7HLSDre.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/index-CKtv7gGE.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/i18n-BJppIrtF.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/api-BFN7blbw.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/three.module-Bx43vjkH.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/gltfLoader-U0Eebg7v.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/store-GFMJzaWS.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/sceneTrack-Bbov7zET.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/rotoMaskStore-DdpmT9C3.js">
17
+ <link rel="modulepreload" crossorigin href="/assets/textAnimators-BVXTl8bU.js">
18
+ <link rel="modulepreload" crossorigin href="/assets/cameraTracker-BAQHuTV-.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/timelineComp-Dx_kED5V.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/rigTrack-XaMj1yaH.js">
21
+ <link rel="modulepreload" crossorigin href="/assets/clientJobs-CuuUyhEy.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/timelineOps-afzSo188.js">
23
+ <link rel="modulepreload" crossorigin href="/assets/remote-DJd9xWjn.js">
24
+ <link rel="modulepreload" crossorigin href="/assets/RoomEnvironment-Dmv_G5ka.js">
25
+ <link rel="modulepreload" crossorigin href="/assets/tool-DpFjybaq.js">
26
+ <link rel="modulepreload" crossorigin href="/assets/timelineProps-eYgO6gs5.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/thumb-CTfDJgLp.js">
28
+ <link rel="modulepreload" crossorigin href="/assets/shotFxAgent-DIMS7BGA.js">
29
+ <link rel="modulepreload" crossorigin href="/assets/cameraPresets-eK3mP7qb.js">
30
+ <link rel="modulepreload" crossorigin href="/assets/weaponDuel-nFECu9nk.js">
31
+ <link rel="modulepreload" crossorigin href="/assets/skin-DrUzJE1u.js">
32
+ <link rel="modulepreload" crossorigin href="/assets/views-CUXyRb9x.js">
33
+ <link rel="modulepreload" crossorigin href="/assets/motionBlur-uAm030t9.js">
34
+ <link rel="modulepreload" crossorigin href="/assets/library-B6KsZUKq.js">
35
+ <link rel="modulepreload" crossorigin href="/assets/ShotComposer-Cng515xa.js">
36
+ <link rel="stylesheet" crossorigin href="/assets/ShotComposer-deLi4grZ.css">
37
+ </head>
38
+ <body>
39
+ <div id="root"></div>
40
+ </body>
41
+ </html>
@@ -1 +0,0 @@
1
- import{j as d,dy as y,dz as w}from"./remote-C7J0Tqhb.js";import{r as p}from"./api-CJ8PdbfZ.js";import{t as b,a as E,d as u}from"./thumb-CS0ZuiGS.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./titleFrameBudget-CLZWaFHO.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.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 +0,0 @@
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 +0,0 @@
1
- import{j as w,dx as F}from"./remote-C7J0Tqhb.js";import{r as l}from"./api-CJ8PdbfZ.js";import{d as M,m as E}from"./lottieLayer-DzbA3bHV.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./titleFrameBudget-CLZWaFHO.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.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),[x,y]=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"){y(""),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){y(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"}),x&&w.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:x})]})}export{z as default};
@@ -1,3 +0,0 @@
1
- import{r as Te,j as n}from"./remote-C7J0Tqhb.js";import{u as ke,r as l,t as a}from"./api-CJ8PdbfZ.js";import{au as Ae,av as Ee,aw as Ie,ax as we,ay as ye,az as Z,aA as _,T as Q,aB as Ve,O as Fe,aC as Ke,A as Oe,N as Re,aD as Be,q as qe,aE as Ge,aF as J,aG as He,aH as _e,e as ze,aI as We,aJ as Xe}from"./main-VVYiW8XD.js";import{d as Qe,k as Je,m as Ye,l as Ze}from"./lottieLayer-DzbA3bHV.js";import{p as en}from"./TimelinePlugins-BYZ9y4m3.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./titleFrameBudget-CLZWaFHO.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";import"./spark.module-DzziUgOj.js";import"./userFonts-CwlKh9NR.js";import"./timeline3d-DOw-CpZI.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-QYsT9JBO.js";import"./captionLayout-DvDPTwO9.js";import"./timelineText-BH09jfSM.js";import"./titleArt-Drsrtfiv.js";import"./rotoMatte-C-2o3vv0.js";import"./distortGL-QalhICvi.js";import"./motionBlur-uAm030t9.js";import"./pluginAutomation-CkP3tA9r.js";const Se=[{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"}],B=s=>s.kind==="pack"&&!!s.kit?.modelAssets,ie=s=>B(s)?"kit":s.kind,q=s=>s.kind==="link"&&!!s.link,nn=s=>{s.link&&window.open(s.link.url,"_blank","noopener,noreferrer")},Ce=(s,r)=>s>=1024*1024?`${(s/1024/1024).toFixed(s>=10*1024*1024?0:1).replace(".",r==="en"?".":",")} MB`:`${Math.max(1,Math.round(s/1024))} KB`,le=({n:s=28})=>n.jsx("span",{className:"ps-wave","aria-hidden":!0,children:Array.from({length:s},(r,c)=>n.jsx("i",{style:{height:`${18+Math.round(72*Math.abs(Math.sin(c*1.37)*Math.cos(c*.41)))}%`}},c))}),Le=(s,r)=>Se.find(c=>c.id===s)?.[r==="en"?"en":"vi"]??s,sn=5e3,an=600*1e3,Ne=s=>s.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/gi,"d").toLowerCase(),Y=s=>(s.passVnd??0)>0||(s.passUsd??0)>0,tn=s=>{const r=(c,h)=>c>0&&h>0?Math.min(c,h):c>0?c:h;return _({priceVnd:r(s.priceVnd,s.passVnd??0),priceUsd:r(s.priceUsd,s.passUsd??0)})};function Fn({installed:s,initialId:r=null,onClose:c,onInstalled:h,onUse:v,toast:o}){const x=ke(),u=x==="en"?"en":"vi",[j,y]=l.useState(null),[g,S]=l.useState([]),[M,D]=l.useState(""),[p,i]=l.useState("all"),[d,b]=l.useState("all"),[C,V]=l.useState(""),[z,A]=l.useState(0),[w,U]=l.useState(null),[E,N]=l.useState(!1),[P,L]=l.useState(),[T,F]=l.useState("");l.useEffect(()=>{const e=window.setTimeout(()=>F(C.trim()),250);return()=>window.clearTimeout(e)},[C]);const I=l.useCallback(e=>Ae({q:T||void 0,kind:d==="all"?void 0:d==="pack"?"niche":d,price:p==="free"?"free":p==="paid"?"paid":void 0,limit:Xe,cursor:e||void 0}),[T,d,p]),K=l.useRef(null),O=l.useRef(0),[k,R]=l.useState(null),[re,ce]=l.useState(""),[W,ee]=l.useState({}),[ne,Me]=l.useState(""),G=l.useCallback(()=>Ee().then(e=>(S(e.owned),e.owned)).catch(()=>[]),[]),[oe,De]=l.useState(!1);l.useEffect(()=>{G().finally(()=>De(!0))},[G]),l.useEffect(()=>{if(p==="owned")return;const e=++O.current;y(null),D(""),I().then(t=>{e===O.current&&(y(t.items),A(t.total??t.items.length),U(t.nextCursor??null),L(t.facets))},t=>{e===O.current&&(y([]),U(null),D(t.message))})},[I,p]);const se=l.useCallback(()=>{if(!w||E||p==="owned")return;const e=O.current;N(!0),I(w).then(t=>{e===O.current&&(y(m=>{const f=new Set((m??[]).map($=>$.id));return[...m??[],...t.items.filter($=>!f.has($.id))]}),U(t.nextCursor??null))},t=>{e===O.current&&D(t.message)}).finally(()=>N(!1))},[w,E,p,I]);l.useEffect(()=>{const e=K.current;if(!e||!w)return;const t=new IntersectionObserver(m=>{m.some(f=>f.isIntersecting)&&se()},{rootMargin:"600px"});return t.observe(e),()=>t.disconnect()},[w,se,j]);const de=l.useRef(!1);l.useEffect(()=>{if(!r||de.current||j===null||!oe)return;de.current=!0;const e=j.find(t=>t.id===r)??g.find(t=>t.storeId===r&&t.item)?.item;e?R(e):Ie(r).then(t=>R(t.item),()=>o(a("Không tìm thấy plug-in này trong kho."),"error"))},[r,j,g,oe,o]),l.useEffect(()=>{const e=t=>{t.key==="Escape"&&(t.stopPropagation(),k?R(null):c())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[k,c]);const he=Object.keys(W).join(",");l.useEffect(()=>{if(!he)return;const e=window.setInterval(()=>{G().then(t=>{ee(m=>{const f={...m};for(const $ of Object.keys(f))(xe(t,$)||Date.now()-f[$]>an)&&delete f[$];return f})})},sn);return()=>window.clearInterval(e)},[he,G]);const H=e=>g.some(t=>t.storeId===e&&t.owned),ae=e=>g.find(t=>t.storeId===e),ue=e=>g.some(t=>t.storeId===e&&t.status==="refunded"),me=e=>s.some(t=>t.id===e&&t.source?.store===e),te=async e=>{ce(e.id);try{await Be(e.id),h(),qe(),Me(e.id),o(a("Đã cài “{0}” vào Plug-in của tôi",[e.name[u]]),"ok")}catch(t){const m=en(t);o(m.text,"error")}finally{ce("")}},pe=l.useRef({}),ge=e=>e?.owned?e.expiresAt?String(e.expiresAt):"life":"none",xe=(e,t)=>{const m=e.find(f=>f.storeId===t);return!!m?.owned&&ge(m)!==(pe.current[t]??"none")},fe=(e,t)=>{pe.current[e.id]=ge(ae(e.id)),Re(e.id,t),ee(m=>({...m,[e.id]:Date.now()}))},Ue=async e=>{const t=await G();xe(t,e)?(ee(m=>{const f={...m};return delete f[e],f}),o(a("Thanh toán xong — plug-in đã thuộc về bạn"),"ok")):o(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")},$e=g.filter(e=>e.item).map(e=>e.item),X=(p==="owned"?$e:(j??[]).filter(e=>p==="all"||(p==="free"?e.free:!e.free))).filter(e=>(d==="all"||ie(e)===d)&&(!C.trim()||Ne(C).split(/\s+/).every(t=>Ne(`${e.name.vi} ${e.name.en} ${e.description.vi} ${e.description.en} ${e.author.name} ${e.tags.join(" ")}`).includes(t)))),Pe=[{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")}],ve=(e,t)=>re===e.id?n.jsxs("button",{className:t,disabled:!0,children:[n.jsx("i",{className:"spin"})," ",a("Đang cài…")]}):me(e.id)||ne===e.id?n.jsxs(n.Fragment,{children:[v?n.jsxs("button",{className:`${t} ps-use`,onClick:()=>v(e.id),children:["✓ ",a("Đã cài · Dùng ngay")]}):n.jsxs("span",{className:`${t} ps-use`,role:"status",children:["✓ ",a("Đã cài")]}),n.jsx("button",{className:"ps-reinstall",title:a("Cài lại plug-in"),onClick:()=>void te(e),children:a("Cài lại")})]}):n.jsx("button",{className:t,onClick:()=>void te(e),children:a("Cài plug-in")}),je=(e,t=!1)=>{const m=`ad-use${t?" ps-big":""}`;if(q(e))return n.jsxs("button",{className:m,onClick:()=>nn(e),children:[e.link.label?.[u]||a("Hướng dẫn cài")," ↗"]});if(e.free)return ve(e,m);if(W[e.id])return n.jsx("button",{className:`${m} ps-wait`,onClick:()=>void Ue(e.id),children:a("Đã thanh toán? Kiểm tra lại")});if(e.kind==="sfxlib"||Y(e)){const f=ae(e.id);if(!t&&!f?.owned)return n.jsx("button",{className:m,onClick:()=>R(e),children:f?.expiresAt?a("Gia hạn"):a("Xem & mua")});if(t)return n.jsx(hn,{item:e,owned:f,busy:re===e.id,installed:me(e.id),onInstall:()=>void te(e),onBuy:$=>fe(e,$)})}return H(e.id)?ve(e,m):n.jsx("button",{className:m,onClick:()=>fe(e),children:a("Mua · {0}",[_(e)])})},be=e=>{if(e.free)return n.jsx("span",{className:"ps-price free",children:a("Miễn phí")});const t=ae(e.id);return t?.owned?n.jsxs("span",{className:"ps-price owned",children:["✓ ",t.expiresAt?a("Vé đến {0}",[Q(t.expiresAt,x)]):a("Đã sở hữu")]}):n.jsx("span",{className:"ps-price",children:e.kind==="sfxlib"||Y(e)?(e.passVnd||e.passUsd)&&!(e.priceVnd||e.priceUsd)?a("{0} / 30 ngày",[Z(e)]):a("từ {0}",[tn(e)]):_(e)})};return Te.createPortal(n.jsx("div",{className:"ad-backdrop",role:"dialog","aria-modal":"true","aria-label":a("Kho Plug-in"),onMouseDown:e=>{e.target===e.currentTarget&&c()},children:n.jsxs("section",{className:"ad-drawer ps-drawer",onMouseDown:e=>e.stopPropagation(),children:[n.jsxs("header",{className:"ad-head",children:[n.jsxs("div",{className:"ad-title",children:["🛍 ",a("Kho Plug-in")]}),n.jsxs("span",{className:"ad-count",children:[p==="owned"?X.length:Math.max(z,X.length)," ",a("mục")]}),n.jsx("div",{className:"grow"}),n.jsx("button",{className:"ad-iconbtn",title:a("Đóng"),"aria-label":a("Đóng"),onClick:c,children:"✕"})]}),n.jsx("nav",{className:"ad-sources",children:Pe.map(e=>n.jsxs("button",{className:`ad-tab${p===e.id?" on":""}`,"aria-pressed":p===e.id,onClick:()=>i(e.id),children:[e.id==="all"&&n.jsx("span",{className:"ad-pin",children:"⧉"}),e.label,e.id==="owned"&&g.filter(t=>t.owned).length>0&&n.jsx("span",{className:"ps-n",children:g.filter(t=>t.owned).length})]},e.id))}),n.jsxs("div",{className:"ad-tools",children:[n.jsx("input",{className:"ad-search","aria-label":a("Tìm plug-in"),placeholder:a("Tìm plug-in, tác giả, thẻ…"),value:C,onChange:e=>V(e.target.value),onKeyDown:e=>e.stopPropagation()}),n.jsx("div",{className:"ad-chips",role:"group","aria-label":a("Loại plug-in"),children:Se.map(e=>{const t=e.id==="all"||p==="owned"?void 0:P?.kinds?.[e.id];return P&&e.id!=="all"&&p!=="owned"&&d!==e.id&&!t?null:n.jsxs("button",{className:`ad-chip${d===e.id?" on":""}`,"aria-pressed":d===e.id,onClick:()=>b(e.id),children:[e[u],t!==void 0&&n.jsx("span",{className:"ps-n",children:t.toLocaleString(u==="en"?"en-US":"vi-VN")})]},e.id)})})]}),n.jsxs("div",{className:"ad-notice",children:[n.jsxs("b",{children:["⧉ ",a("Plug-in không tốn credit.")]})," ",d==="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.")]}),n.jsxs("div",{className:"ad-content",children:[M&&n.jsx("p",{role:"alert",className:"ad-alert",children:M}),j===null&&n.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),j!==null&&!X.length&&n.jsx("div",{className:"ad-empty",children:p==="owned"?a("Bạn chưa mua plug-in nào."):C?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.")}),n.jsx("div",{className:"ad-grid",children:X.map(e=>n.jsxs("article",{className:"ad-card ps-card","data-store":e.id,children:[n.jsxs("button",{className:"ad-prev ps-open","aria-label":a("Xem {0}",[e.name[u]]),onClick:()=>R(e),children:[e.thumbnailUrl?n.jsx("img",{src:e.thumbnailUrl,alt:"",loading:"lazy"}):e.kind==="sfx"||e.kind==="sfxlib"?n.jsx(le,{}):n.jsx("span",{className:"ad-ph",children:"⧉"}),n.jsx("span",{className:"ad-badge",children:(q(e)?e.link.platform:Le(ie(e),x)).toUpperCase()}),e.featured&&n.jsxs("span",{className:"ps-featured",title:a("Đối tác tiên phong của Clipoox"),children:["★ ",a("Đối tác tiên phong")]}),e.private&&n.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")]})]}),n.jsxs("div",{className:"ad-meta",children:[n.jsx("div",{className:"ad-name",title:e.name[u],children:e.name[u]}),n.jsxs("div",{className:"ad-sub ps-sub",children:[n.jsxs("span",{className:"ps-by",children:[e.author.name," · v",e.version]}),be(e)]}),e.kind==="pack"&&!B(e)&&n.jsxs("div",{className:"ps-sounds-meta",children:["⧉ ",a("{0} mục trong gói",[e.itemCount??0])]}),B(e)&&n.jsxs("div",{className:"ps-kit-meta",children:["◈ ",n.jsx("b",{children:e.kit.items})," ",a("mục")," · ",n.jsx("b",{children:e.kit.models})," ",a("mô hình 3D")," · ",n.jsx("b",{children:e.kit.looks})," ",a("look")," · ",Ce(e.kit.bytes,u)]}),q(e)&&n.jsxs("div",{className:"ps-sounds-meta",children:["↗ ",a("Cài trong {0} trên máy bạn",[e.link.platform])]}),e.kind==="sfx"&&n.jsxs("div",{className:"ps-sounds-meta",children:["♪ ",a("{0} âm thanh",[e.soundCount??0])," · ",we(e.totalDuration)]}),e.kind==="sfxlib"&&n.jsxs("div",{className:"ps-sounds-meta",children:["📚 ",a("{0} âm thanh",[(e.soundCount??0).toLocaleString(u==="en"?"en-US":"vi-VN")])," · ",ye(e.totalDuration,u)]}),(e.kind==="sfxlib"||Y(e))&&!e.free&&!H(e.id)&&n.jsx("div",{className:"ps-sounds-meta ps-lib-prices",children:[e.passVnd||e.passUsd?a("{0} / 30 ngày",[Z(e)]):"",e.priceVnd||e.priceUsd?a("{0} trọn đời",[_(e)]):""].filter(Boolean).join(" · ")}),ne===e.id&&n.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi")]}),W[e.id]&&n.jsxs("div",{className:"ps-waiting",role:"status",children:[n.jsx("i",{className:"spin"}),a("Đang chờ thanh toán…")]}),ue(e.id)&&!H(e.id)&&n.jsx("div",{className:"ps-waiting bad",children:a("Đơn đã hoàn tiền")}),n.jsx("div",{className:"ad-actions",children:je(e)})]})]},e.id))}),p!=="owned"&&w&&n.jsx("div",{ref:K,className:"ps-more",role:"status",children:E?n.jsxs(n.Fragment,{children:[n.jsx("i",{className:"spin"})," ",a("Đang tải thêm…")]}):n.jsx("button",{className:"ad-chip",onClick:se,children:a("Xem thêm")})})]}),k&&n.jsx(ln,{item:k,locale:u,owned:H(k.id),free:k.free,waiting:!!W[k.id],refunded:ue(k.id),action:je(k,!0),price:be(k),installed:ne===k.id,onClose:()=>R(null)},`${k.id}:${H(k.id)}`)]})}),document.body)}function ln({item:s,locale:r,owned:c,free:h,waiting:v,refunded:o,action:x,price:u,installed:j,onClose:y}){const g=l.useRef(null),[S,M]=l.useState(!1),[D,p]=l.useState(!1);return l.useEffect(()=>{if(!(h||c)||s.kind==="recipe"||s.kind==="sfx"||s.kind==="pack"||s.kind==="sfxlib"||s.kind==="link")return;let i=!0,d=0,b=null;const C=`store-preview:${s.id}`,V={v:""},z=performance.now();return(async()=>{try{b=await Ve(s.id)}catch{i&&p(!0);return}if(!i||!b)return;const A=b.manifest,w=640,U=360;if(A.kind==="motion"){const E=Fe(A,b.entry,{}),N=A.duration,P=async()=>{if(i){try{const L=await Ye({layer:C,motion:E,t:(performance.now()-z)/1e3%N,width:w,height:U,duration:N}),T=g.current?.getContext("2d");T&&i&&(T.clearRect(0,0,w,U),T.drawImage(L,0,0),M(!0)),L.close()}catch{}d=requestAnimationFrame(()=>void P())}};P()}else{const E=await Ke(b.lottie,A,Oe(A,{}));V.v=URL.createObjectURL(new Blob([JSON.stringify(E)],{type:"application/json"}));const N=b.lottie.meta,P=Math.min(w/N.w,U/N.h),L={W:Math.max(2,Math.round(N.w*P/2)*2),H:Math.max(2,Math.round(N.h*P/2)*2)},T=N.op-N.ip,F=document.createElement("canvas");F.width=L.W,F.height=L.H;const I=async()=>{if(i){try{await Ze(C,V.v,L,Math.floor((performance.now()-z)/1e3*N.fr%T),F);const K=g.current?.getContext("2d");K&&i&&(K.clearRect(0,0,w,U),K.drawImage(F,(w-L.W)/2,(U-L.H)/2),M(!0))}catch{}d=requestAnimationFrame(()=>void I())}};I()}})(),()=>{i=!1,cancelAnimationFrame(d),Qe(C),Je(C),V.v&&URL.revokeObjectURL(V.v)}},[s.id,s.kind,h,c]),n.jsx("div",{className:"ad-preview-modal",onMouseDown:i=>{i.target===i.currentTarget&&y()},children:n.jsxs("div",{className:"ad-preview-box ps-detail",role:"dialog","aria-label":s.name[r],children:[n.jsxs("header",{children:[n.jsx("b",{children:s.name[r]}),n.jsx("button",{className:"ad-iconbtn","aria-label":a("Đóng"),onClick:y,children:"✕"})]}),s.kind==="sfxlib"?n.jsx(dn,{item:s,locale:r}):s.kind==="sfx"?n.jsx(on,{item:s,locale:r,owned:c,free:h}):n.jsxs("div",{className:"ps-stage",children:[n.jsx("canvas",{ref:g,width:640,height:360,style:{display:S?"block":"none"}}),!S&&(s.previewUrl&&/\.(mp4|webm)(\?|$)/.test(s.previewUrl)?n.jsx("video",{src:s.previewUrl,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):s.previewUrl||s.thumbnailUrl?n.jsx("img",{src:s.previewUrl||s.thumbnailUrl,alt:""}):n.jsx("span",{className:"ad-ph",children:"⧉"})),n.jsx("span",{className:"ps-stage-note",children:S?a("Xem thử trực tiếp trong sandbox"):h||c?D?a("Không tải được bản xem thử"):s.kind==="recipe"?a("Công thức chạy trên clip bạn chọn"):s.kind==="pack"?a("Gói {0} mục — cài rồi dùng từng mục trong tab Plug-in",[s.itemCount??0]):q(s)?a("Cài trong {0} trên máy bạn — không cài vào Timeline",[s.link.platform]):a("Đang tải bản xem thử…"):a("Mua để xem thử trực tiếp và dùng")})]}),s.kind==="pack"&&n.jsx(cn,{item:s,locale:r}),n.jsxs("div",{className:"ps-info",children:[s.featured&&n.jsxs("p",{className:"ps-featured-line",children:["★ ",a("Đối tác tiên phong của Clipoox")]}),s.private&&n.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.")]}),n.jsxs("div",{className:"ps-row",children:[u,n.jsxs("span",{className:"ps-kind",children:[q(s)?s.link.platform:Le(ie(s),r)," · v",s.version," · ",s.author.name,s.kit?` · ${Ce(s.kit.bytes,r)}`:"",B(s)?` · ${a("GLB ≤ 20 MB, ≤ 300 000 tam giác")}`:""]})]}),n.jsx("p",{children:s.description[r]}),q(s)&&s.link.commands.length>0&&n.jsx(rn,{commands:s.link.commands}),s.params.length>0&&n.jsxs("p",{className:"ps-params",children:[n.jsxs("b",{children:[a("Tham số chỉnh được"),":"]})," ",s.params.map(i=>i.label[r]).join(" · ")]}),v&&n.jsxs("div",{className:"ps-waiting",role:"status",children:[n.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.")]}),o&&!c&&n.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.")}),j&&n.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.")]}),n.jsx("div",{className:"ad-actions",children:x}),B(s)&&!h&&!c&&n.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.")]}),B(s)&&(h||c)&&n.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.")}),!h&&!c&&s.kind!=="sfxlib"&&!Y(s)&&n.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 rn({commands:s}){const[r,c]=l.useState(!1),h=()=>{navigator.clipboard?.writeText(s.join(`
2
- `)).then(()=>{c(!0),window.setTimeout(()=>c(!1),2e3)},()=>{})};return n.jsxs("div",{className:"ps-cmds",children:[n.jsxs("div",{className:"ps-cmds-head",children:[n.jsx("b",{children:a("Lệnh cài")}),n.jsx("span",{className:"muted",children:a("chạy trong terminal trên máy bạn")}),n.jsx("button",{className:"ad-chip",onClick:h,children:r?`✓ ${a("Đã chép")}`:a("Chép lệnh")})]}),n.jsx("pre",{children:s.join(`
3
- `)})]})}function cn({item:s,locale:r}){const[c,h]=l.useState(null);if(l.useEffect(()=>{let o=!0;return We(s.id).then(x=>{o&&h(x.items)},()=>{o&&h([])}),()=>{o=!1}},[s.id]),!c?.length)return null;const v=o=>o.kind==="model"?a("Mô hình"):o.kind==="lut"?"Look":o.kind==="motion"&&o.engine==="3d"?"3D":o.kind==="recipe"?a("Combo"):o.kind==="lottie"?"Lottie":"2D";return n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"ps-items-head",children:[n.jsx("b",{children:a("{0} mục trong gói",[c.length])})," · ",n.jsx("span",{className:"muted",children:a("ảnh chụp từ lần chạy thử")})]}),n.jsx("div",{className:"ps-items",children:c.slice(0,24).map(o=>n.jsxs("figure",{children:[o.thumbnail?n.jsx("img",{src:`data:${o.thumbnail.type};base64,${o.thumbnail.data}`,alt:""}):n.jsx("span",{className:"ph",children:o.kind==="model"?"◈":"✦"}),n.jsxs("figcaption",{title:o.name[r],children:[v(o)," · ",o.name[r]]})]},o.id))})]})}function on({item:s,locale:r,owned:c,free:h}){const[v,o]=l.useState(null),[x,u]=l.useState(!1),[j,y]=l.useState(!1),[g,S]=l.useState(null),M=l.useRef(null),D=l.useRef(0);l.useEffect(()=>{let i=!0;return _e(s.id).then(d=>{i&&(o(d.sounds),u(d.full))},()=>{i&&y(!0)}),()=>{i=!1,M.current?.pause(),window.clearTimeout(D.current)}},[s.id,c,h]);const p=i=>{if(M.current?.pause(),window.clearTimeout(D.current),g===i.id||!i.url){S(null);return}const d=new Audio(i.url);M.current=d,d.volume=.8,S(i.id),d.onended=()=>S(b=>b===i.id?null:b),i.preview&&(D.current=window.setTimeout(()=>{d.pause(),S(b=>b===i.id?null:b)},J.previewSeconds*1e3+300)),d.play().catch(()=>S(null))};return n.jsxs("div",{className:"ps-sounds","data-full":x?"1":"0",children:[n.jsxs("div",{className:"ps-sounds-head",children:[s.thumbnailUrl?n.jsx("img",{src:s.thumbnailUrl,alt:""}):n.jsx(le,{n:40}),n.jsxs("div",{children:[n.jsxs("b",{children:["♪ ",a("{0} âm thanh",[s.soundCount??v?.length??0])," · ",we(s.totalDuration)]}),n.jsx("small",{className:"muted",children:x?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.",[J.previewCount,J.previewSeconds])})]})]}),j&&n.jsx("p",{className:"ad-alert",role:"alert",children:a("Không tải được bản xem thử")}),v===null&&!j&&n.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),v&&n.jsx("ul",{className:"ps-sound-list","aria-label":a("Âm thanh trong gói"),children:v.map(i=>{const d=i.name?.[r]||i.name?.vi||i.id;return n.jsxs("li",{className:`${g===i.id?"on":""}${i.url?"":" locked"}`,"data-store-sound":i.id,children:[n.jsx("button",{className:"tl-sfx-play",disabled:!i.url,"aria-label":i.url?`${a("Nghe thử")} ${d}`:a("Mua để nghe {0}",[d]),title:i.url?a("Nghe thử"):a("Mua để nghe"),onClick:()=>p(i),children:i.url?g===i.id?"■":"▶":"🔒"}),n.jsxs("span",{className:"ps-sound-name",children:[n.jsxs("span",{className:"ell",children:[d,i.loop?" ↻":""]}),n.jsxs("small",{className:"muted ell",children:[ze(i.category,r),i.tags.length?` · ${i.tags.slice(0,3).join(", ")}`:""]})]}),n.jsxs("small",{className:"muted",children:[i.preview&&(i.previewSeconds??0)<i.duration-.05?`▶ ${(i.previewSeconds??0).toFixed(1)}s / `:"",i.duration.toFixed(1),"s"]})]},i.id)})})]})}function dn({item:s,locale:r}){const c=l.useCallback(x=>Ge(s.id,x),[s.id]),[h,v]=l.useState(null),o=l.useCallback(async x=>{const u=await c(x);return v(u.access.full),u},[c]);return n.jsxs("div",{className:"ps-sounds","data-full":h?"1":"0",children:[n.jsxs("div",{className:"ps-sounds-head",children:[s.thumbnailUrl?n.jsx("img",{src:s.thumbnailUrl,alt:""}):n.jsx(le,{n:40}),n.jsxs("div",{children:[n.jsxs("b",{children:["📚 ",a("{0} âm thanh",[(s.soundCount??0).toLocaleString(r==="en"?"en-US":"vi-VN")])," · ",ye(s.totalDuration,r)]}),n.jsxs("div",{className:"ps-stats",children:[(s.folders?.length??0)>0&&n.jsxs("span",{children:[n.jsx("b",{children:s.folders.length})," ",a("thư mục")]}),n.jsxs("span",{children:[n.jsx("b",{children:"48 kHz"})," stereo"]}),n.jsxs("span",{children:["v",s.version]})]}),n.jsx("small",{className:"muted",children:h?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.",[J.previewSeconds])})]})]}),n.jsx(He,{libId:s.id,fetchPage:o,variant:"store"})]})}function hn({item:s,owned:r,busy:c,installed:h,onInstall:v,onBuy:o}){const x=ke(),u=s.kind==="sfxlib",j=(s.passVnd??0)>0||(s.passUsd??0)>0,y=s.priceVnd>0||s.priceUsd>0,g=n.jsx("button",{className:"ad-use ps-big",disabled:c,onClick:v,children:c?a("Đang cài…"):h?a("Cài lại"):a("Cài plug-in")});return r?.owned&&!r.expiresAt?g:r?.owned?n.jsxs("div",{className:"ps-lib-buy-wrap",children:[g,j&&n.jsx("button",{className:"ad-use ps-big ps-alt",onClick:()=>o("pass"),children:a("Gia hạn thêm 30 ngày · {0}",[Z(s)])}),n.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.",[Q(r.expiresAt,x)])})]}):n.jsxs("div",{className:"ps-lib-buy-wrap",children:[r?.expiresAt&&n.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.",[Q(r.expiresAt,x)]):a("Vé 30 ngày đã hết hạn ngày {0}. Lớp đã thêm vào video vẫn giữ nguyên.",[Q(r.expiresAt,x)])}),n.jsxs("div",{className:"ps-lib-buy",children:[j&&n.jsxs("button",{className:"ad-use ps-big",onClick:()=>o("pass"),children:[a("Vé 30 ngày · {0}",[Z(s)]),n.jsx("small",{children:a("Trả lại để gia hạn, không tự trừ tiền")})]}),y&&n.jsxs("button",{className:"ad-use ps-big",onClick:()=>o("lifetime"),children:[a("Mua trọn đời · {0}",[_(s)]),n.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")})]})]}),n.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{Fn as default};