clipoox-render 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/server-text/titleRaster.js +1394 -0
  2. package/package.json +5 -3
  3. package/scripts/render-local.mjs +1617 -1481
  4. package/shared/transitionStarterPack.json +261 -0
  5. package/web/assets/FxEmbed-D7k1ThAF.js +1 -0
  6. package/web/assets/{GLTFLoader-Dy6SrZg8.js → GLTFLoader-BHWu1lKg.js} +1 -1
  7. package/web/assets/MotionEmbed-DFni5IAh.js +1 -0
  8. package/web/assets/PluginStore-BrupM_8E.js +3 -0
  9. package/web/assets/{ShotComposer-AHScyNYv.js → ShotComposer-BLztjSKy.js} +4 -4
  10. package/web/assets/TemplateEmbed-BbAimhLj.js +2 -0
  11. package/web/assets/TimelinePlugins-BI1bE9pX.js +5 -0
  12. package/web/assets/TimelinePlugins-DYarX9RK.css +1 -0
  13. package/web/assets/TimelineShotFx-CQN3WIfN.js +2 -0
  14. package/web/assets/TransitionEmbed-CmoIrHVr.js +1 -0
  15. package/web/assets/{Whiteboard-C9Mwa3nF.js → Whiteboard-DMk0unYK.js} +3 -3
  16. package/web/assets/aerial-DT_gUtSh.js +2 -0
  17. package/web/assets/agentTools-qOww5RUs.js +2 -0
  18. package/web/assets/analyzerRun-B2FLUp4G.js +1 -0
  19. package/web/assets/{analyzerSandbox-DQGHjUCa.js → analyzerSandbox-CJVsEhrg.js} +2 -2
  20. package/web/assets/{api-C5pOWyBM.js → api-QBI5GJTZ.js} +148 -148
  21. package/web/assets/auraTrack-CEs_Q9EP.js +1 -0
  22. package/web/assets/breakthrough-DvkxvNK9.js +2 -0
  23. package/web/assets/{cameraPresets-CeStHDvF.js → cameraPresets-4pFeF2YG.js} +1 -1
  24. package/web/assets/{captionLayout-BAdmqwdS.js → captionLayout-C67EMVI1.js} +1 -1
  25. package/web/assets/clientExport-C4VgAJtO.js +1 -0
  26. package/web/assets/{depthEstimate-1OjTo_pb.js → depthEstimate-mnXDZMW-.js} +1 -1
  27. package/web/assets/directorTools-BOHZjcww.js +1 -0
  28. package/web/assets/{distortFrames-D39fkQ_H.js → distortFrames-Csuj2jHE.js} +2 -2
  29. package/web/assets/{distortGL-5uNfls9s.js → distortGL-BaXfN0IK.js} +2 -2
  30. package/web/assets/editTools-m0VGPmfF.js +1 -0
  31. package/web/assets/{exportEncode-pFxeatJt.js → exportEncode-D9OT7_5k.js} +1 -1
  32. package/web/assets/exportGlb-CLfTnbMG.js +2 -0
  33. package/web/assets/faceTracker-W0iZSiMe.js +1 -0
  34. package/web/assets/fightDirector-CECPf2iH.js +1 -0
  35. package/web/assets/fightDrama-CqNoa5XI.js +2 -0
  36. package/web/assets/{frameSink-CB1EghW0.js → frameSink-BGRj7wqY.js} +3 -3
  37. package/web/assets/{gpuCompose-EfzSAeMh.js → gpuCompose-CIEoLFem.js} +1 -1
  38. package/web/assets/gpuExport-uyOAyrhm.js +190 -0
  39. package/web/assets/handMatte-mHxZwLZD.js +1 -0
  40. package/web/assets/handTracker-dTVeSUzt.js +2 -0
  41. package/web/assets/{index-BGZJld3s.js → index-D7M5t2re.js} +1 -1
  42. package/web/assets/layer-worker-Cp0pjurp.js +5 -0
  43. package/web/assets/library-Dsz_MLyd.js +1 -0
  44. package/web/assets/{lottieLayer-BhLbZOpr.js → lottieLayer-CDCGeJyv.js} +5 -5
  45. package/web/assets/{lottie_light_canvas-D9fsNLID.js → lottie_light_canvas-BblLU4nU.js} +1 -1
  46. package/web/assets/main-BQ8IY0WV.css +1 -0
  47. package/web/assets/{main-BNZrzSIG.js → main-CVRIuDW2.js} +76 -76
  48. package/web/assets/{mapBake-BAG6i5fI.js → mapBake-CNMOKXA7.js} +1 -1
  49. package/web/assets/maskTrack-Dtv6Jr06.js +1 -0
  50. package/web/assets/matteFixRun-BLDH2AjH.js +1 -0
  51. package/web/assets/motionBlur-uAm030t9.js +1 -0
  52. package/web/assets/{objectLocate-Dhktxe5z.js → objectLocate-Cy3IFBSF.js} +1 -1
  53. package/web/assets/{objectTrack.worker-ENzKeSiV.js → objectTrack.worker-BlZkgpOX.js} +483 -352
  54. package/web/assets/pendingMatte-C2AWApuv.js +2 -0
  55. package/web/assets/personAi-DPUnoymj.js +2 -0
  56. package/web/assets/plateCamera-C96L5GKm.js +1 -0
  57. package/web/assets/plateCameraMatch-Chk-ZjDi.js +2 -0
  58. package/web/assets/plateFollow-B9_QTgvo.js +2 -0
  59. package/web/assets/plateMatte-BiqyI_8x.js +2 -0
  60. package/web/assets/{pluginAutomation-DdZOnpoV.js → pluginAutomation-5DYldFrb.js} +1 -1
  61. package/web/assets/poseTracker-PuI8vWpR.js +1 -0
  62. package/web/assets/productTools-B1h5cgyt.js +2 -0
  63. package/web/assets/remote-BJdzzFZg.js +1241 -0
  64. package/web/assets/rigTrack-CUt4O67J.js +1 -0
  65. package/web/assets/{rotoMaskStore-DrRawyH9.js → rotoMaskStore-DIi45swK.js} +1 -1
  66. package/web/assets/{rotoMatte-2EcyuvBX.js → rotoMatte-013RKqHu.js} +1 -1
  67. package/web/assets/rotoscope-d_TUxa-J.js +1 -0
  68. package/web/assets/{sceneTrack.worker-CEvCN5OB.js → sceneTrack.worker-CT4uoTKn.js} +475 -344
  69. package/web/assets/shot-worker-B1iZT6F5.js +1 -0
  70. package/web/assets/{shotFxAgent-CETPcjzU.js → shotFxAgent-BDfe73TP.js} +2 -2
  71. package/web/assets/{skin-BQG1Iz6Q.js → skin-GDY3QPkV.js} +1 -1
  72. package/web/assets/{spark.module-CMSPLU2n.js → spark.module-DdwuJ_hb.js} +10 -10
  73. package/web/assets/spellDuel-DjNN00bv.js +2 -0
  74. package/web/assets/{store-Dxq3MZF3.js → store-2zneEhhu.js} +1 -1
  75. package/web/assets/{surfaceLight-B_OSTxcx.js → surfaceLight-B_SYg_f8.js} +1 -1
  76. package/web/assets/surfacePin-zDPmq-hH.js +2 -0
  77. package/web/assets/textAnimators-Bdt5LWXk.js +1 -0
  78. package/web/assets/{thumb-xLFX6lDN.js → thumb-byAKvhQP.js} +1 -1
  79. package/web/assets/timeline3d-YIIk_Kn2.js +2 -0
  80. package/web/assets/timeline3dExport-CEH1RjNf.js +1 -0
  81. package/web/assets/timelineComp-B73i_8vD.js +1 -0
  82. package/web/assets/timelineProps-B2pnudeT.js +1 -0
  83. package/web/assets/timelineText-BcL4Pw3C.js +1 -0
  84. package/web/assets/{titleArt-CAOxtyHl.js → titleArt-hb_T45WJ.js} +5 -5
  85. package/web/assets/{titleFrameBudget-BjW--v_T.js → titleFrameBudget-Cml-MO53.js} +970 -839
  86. package/web/assets/titleFrames-Dw0PEBdV.js +1 -0
  87. package/web/assets/{tool-DEWWeyCz.js → tool-Bt9bclIf.js} +1 -1
  88. package/web/assets/tools-BXeJbgZJ.js +1 -0
  89. package/web/assets/toonTools-u7Y9fdEZ.js +2 -0
  90. package/web/assets/trackAnchor-9MnVHe4S.js +1 -0
  91. package/web/assets/userFonts-BHduCNtc.js +1 -0
  92. package/web/assets/{vfxAlpha-vbbI-03F.js → vfxAlpha-DpV4rbI-.js} +2 -2
  93. package/web/assets/vfxBackground-Ddviync5.js +2 -0
  94. package/web/assets/videoExport-z5WjM0hw.js +1 -0
  95. package/web/assets/views-CsrYzCSR.js +1 -0
  96. package/web/assets/weaponDuel-CLLgv5A4.js +1 -0
  97. package/web/assets/{windowFrames-DydW5Al5.js → windowFrames-BQEWQkEs.js} +1 -1
  98. package/web/layer-worker.html +3 -3
  99. package/web/assets/FxEmbed-B5TQxKxk.js +0 -1
  100. package/web/assets/MotionEmbed-Catb_GgA.js +0 -1
  101. package/web/assets/PluginStore-8TjQawtB.js +0 -3
  102. package/web/assets/TemplateEmbed-Cao8Z5fY.js +0 -2
  103. package/web/assets/TimelinePlugins-B5WmAawO.css +0 -1
  104. package/web/assets/TimelinePlugins-CkP5P9b_.js +0 -5
  105. package/web/assets/TimelineShotFx-DvmPZQXM.js +0 -2
  106. package/web/assets/TransitionEmbed-o4UxJ35e.js +0 -1
  107. package/web/assets/aerial-BPRLPci2.js +0 -2
  108. package/web/assets/agentTools-CSnN-LvS.js +0 -2
  109. package/web/assets/analyzerRun-5zJsmMS1.js +0 -1
  110. package/web/assets/auraTrack-pF-WhpH3.js +0 -1
  111. package/web/assets/breakthrough-DQN1i-Pw.js +0 -2
  112. package/web/assets/clientExport-Ca9a3Jiy.js +0 -1
  113. package/web/assets/desktop-BWhFnYwd.js +0 -1
  114. package/web/assets/directorTools-CvmghG_6.js +0 -1
  115. package/web/assets/editTools-CUoVvupD.js +0 -1
  116. package/web/assets/exportGlb-MK05aKqH.js +0 -2
  117. package/web/assets/faceTracker-_rQOgBvX.js +0 -1
  118. package/web/assets/fightDirector-Dt60kfbV.js +0 -1
  119. package/web/assets/fightDrama-py4jxSdn.js +0 -2
  120. package/web/assets/gpuExport-Cnv2NfEb.js +0 -189
  121. package/web/assets/handMatte-DZCsuqD2.js +0 -1
  122. package/web/assets/handTracker-Btr9L-Hu.js +0 -2
  123. package/web/assets/layer-worker-Rbo-YZv-.js +0 -5
  124. package/web/assets/library-CdukL2BW.js +0 -1
  125. package/web/assets/main-By_IEoB_.css +0 -1
  126. package/web/assets/maskTrack-AZwAVz1c.js +0 -1
  127. package/web/assets/matteFixRun-wTHGiGGf.js +0 -1
  128. package/web/assets/pendingMatte-iKz2-XBZ.js +0 -2
  129. package/web/assets/personAi-BEVyjCii.js +0 -2
  130. package/web/assets/plateCamera-D_J3-X06.js +0 -1
  131. package/web/assets/plateCameraMatch-C0peOvBn.js +0 -2
  132. package/web/assets/plateFollow-BbJMVxfg.js +0 -2
  133. package/web/assets/plateMatte-u5wKpsUN.js +0 -2
  134. package/web/assets/poseTracker--VJYw-hX.js +0 -1
  135. package/web/assets/productTools-DbhbyJxx.js +0 -2
  136. package/web/assets/remote-DXG553d8.js +0 -1220
  137. package/web/assets/rigTrack-CW9_kg5j.js +0 -1
  138. package/web/assets/rotoscope-_CYT-9ry.js +0 -1
  139. package/web/assets/shot-worker-BxIzQRZh.js +0 -1
  140. package/web/assets/spellDuel-eZvRwaxi.js +0 -2
  141. package/web/assets/surfacePin-CfLBhSrm.js +0 -2
  142. package/web/assets/timeline3d-DqXTKdEK.js +0 -2
  143. package/web/assets/timeline3dExport-MWomW4fF.js +0 -1
  144. package/web/assets/timelineProps-KL6XCR4Q.js +0 -1
  145. package/web/assets/timelineText-DEK2BRyU.js +0 -1
  146. package/web/assets/titleFrames-WfiLHzjf.js +0 -1
  147. package/web/assets/tools-CBfIZX8_.js +0 -1
  148. package/web/assets/toonTools-D7jucq3t.js +0 -2
  149. package/web/assets/trackAnchor-DFqKIb8a.js +0 -1
  150. package/web/assets/userFonts-txN4I-eo.js +0 -1
  151. package/web/assets/vfxBackground-C1dHlJN6.js +0 -2
  152. package/web/assets/vfxTrack-BmxWjlDi.js +0 -1
  153. package/web/assets/videoExport-DiNI9GY1.js +0 -1
  154. package/web/assets/views-sH39zgjD.js +0 -1
  155. package/web/assets/weaponDuel-CEvRDeuE.js +0 -1
@@ -0,0 +1 @@
1
+ import{b$ as T,eO as ot,eP as rt,lX as nt,eT as B,lY as it,ea as st,eU as lt,eQ as H,ec as V,eS as X,eX as Q,eW as q,eY as z,eV as Z}from"./titleFrameBudget-Cml-MO53.js";import{l as ht,d as dt}from"./titleArt-hb_T45WJ.js";import{i as R,j as ct,s as k,d as P,l as mt,k as Y,f as ft,e as j,a as ut,p as pt,t as wt,m as tt}from"./lottieLayer-CDCGeJyv.js";import{wantsFrame as G,SKIPPED_FRAME as gt}from"./frameSink-BGRj7wqY.js";import{t as J}from"./api-QBI5GJTZ.js";import"./textAnimators-Bdt5LWXk.js";import"./rigTrack-CUt4O67J.js";const xt=e=>X(e.title)||!!e.shape||!!e.motion||!!e.lottie||!!e.card||!!e.geo,N=e=>e.kind==="image"&&!!e.title?.text&&!e.url&&!X(e.title),D=4,U=192*1024*1024,g=new Map;let A=0;function Et(e,s){if(e.geo||e.shape&&R(e.shape)||e.pin?.scene||e.space)return null;const{start:i,track:h,...n}=e;return JSON.stringify([s,n])}function Mt(e,s){const i=s.reduce((h,n)=>h+n.length,0);if(!(i>U/4)){g.delete(e),g.set(e,{frames:s,bytes:i}),A+=i;for(const[h,n]of g){if(A<=U)break;g.delete(h),A-=n.bytes}}}function Tt(){g.clear(),A=0}const bt=e=>new Promise((s,i)=>e.toBlob(h=>{if(!h)return i(Error("Cannot encode title frame"));const n=new FileReader;n.onload=()=>s(String(n.result).slice(String(n.result).indexOf(",")+1)),n.onerror=()=>i(n.error),n.readAsDataURL(h)},"image/webp",.9));async function Pt(e,s,i,h,n){const{fps:o,width:f,height:S}=T(s),u=T({...s,resolution:"720p"}),y=e.some(t=>t.shape&&R(t.shape))?ot(rt(e)):null,$=!!i.wants;for(const t of e.filter(d=>(xt(d)||N(d))&&!d.warped)){if(!G(i,"titleFrames",t.id))continue;const d=a=>G(i,"titleFrames",t.id,a),c=Et(t,s),r=c?g.get(c):void 0;if(r){g.delete(c),g.set(c,r);for(const a of r.frames){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");await i.push("titleFrames",t.id,a)}continue}const x=[],E=t.title,M=nt(t)||N(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 ct(t.card).catch(a=>{throw Error(J("Thẻ HTML “{0}”: {1}",[t.label,a.message]))}):null,[p,w]=b?[b.width,b.height]:t.geo?[u.width,u.height]:t.lottie?[B(t.lottie).W,B(t.lottie).H]:t.motion?[u.width,u.height]:t.shape?[k(t.shape).W,k(t.shape).H]:[1280,720],C=Object.assign(document.createElement("canvas"),{width:p,height:w}),F=C.getContext("2d");if(!F)throw Error("Canvas unavailable");let I="",O=null;const L=(a,l)=>tt({layer:`export:${a.id}`,motion:a.motion,t:Z(a,l/o),width:p,height:w,duration:z(a),fps:o,surface:a.pin?.scene?q(a,e,a.start+l/o,p,w):null,space:a.space?(H(e),Q(a,e,a.start+l/o,p,w,n)):null}),m=[],W="\0same",_="\0skip",K=t.shape&&!t.motion&&!t.card&&!t.lottie&&!t.geo&&!R(t.shape)?it(t.shape):null,et=K==null?1/0:Math.max(K,...["trimStart","trimEnd"].flatMap(a=>st(t,a).map(l=>l.time))),v=async()=>{const a=await m.shift();if(a===_){await i.push("titleFrames",t.id,gt);return}if(a===W||a===I){x.push("="),await i.push("titleFrames",t.id,"=");return}I=a,x.push(a),await i.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)){m.push(Promise.resolve(_)),m.length>=D&&await v();continue}if(!$&&a>0&&(a-1)/o>et+1e-6){m.push(Promise.resolve(W)),m.length>=D&&await v();continue}if(F.clearRect(0,0,p,w),t.motion){let l;try{l=await(O??L(t,a)),O=a+1<M&&d(a+1)?L(t,a+1):null}catch(at){throw O?.catch(()=>{}),P(`export:${t.id}`),Error(`Motion “${t.label}”: ${at.message}`)}F.drawImage(l,0,0),l.close()}else if(t.lottie)try{await mt(`export:${t.id}`,t.url,{W:p,H:w},lt(t,a/o),C)}catch(l){throw Y(`export:${t.id}`),Error(`Lottie “${t.label}”: ${l.message}`)}else if(t.geo)try{await ft(`export:${t.id}`,t.geo,{W:p,H:w},a/o,C,{wait:2e4,duration:t.duration})}catch(l){throw j(`export:${t.id}`),Error(J("Bản đồ “{0}”: {1}",[t.label,l.message]))}else b?F.drawImage(b,0,0):t.shape?(y&&H(y),ut(F,pt(t,e,a/o,f,S),{start:V(t,"trimStart",a/o),end:V(t,"trimEnd",a/o),offset:wt(t.shape)},p,w,a/o)):dt(F,E,{time:a/o,duration:t.duration});m.push(bt(C)),m.length>=D&&await v()}for(;m.length;)await v();c&&!$&&Mt(c,x)}finally{for(const a of m)a.catch(()=>{})}t.motion&&P(`export:${t.id}`),t.lottie&&Y(`export:${t.id}`),t.geo&&j(`export:${t.id}`)}}function Ot(e,s,i,h){const{fps:n}=T(i),{width:o,height:f}=T({...i,resolution:"720p"}),S=Math.ceil(e.duration*n)-1,u=Object.assign(document.createElement("canvas"),{width:o,height:f}),y=u.getContext("2d");if(!y)throw Error("Canvas unavailable");const $=r=>tt({layer:`export:${e.id}`,motion:e.motion,t:Z(e,r/n),width:o,height:f,duration:z(e),fps:n,surface:e.pin?.scene?q(e,s,e.start+r/n,o,f):null,space:e.space?(H(s),Q(e,s,e.start+r/n,o,f,h)):null});let t=null,d=-1;const c=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 u;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&&c(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,y.clearRect(0,0,o,f),y.drawImage(E,0,0),E.close(),d=r,u},close(){c(t),t=null,P(`export:${e.id}`)}}}export{Tt as clearFrameCache,Et as frameCacheKey,Ot as liveMotion,Pt 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{dZ as P}from"./remote-DXG553d8.js";import{_ as R}from"./titleFrameBudget-BjW--v_T.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{dM as P}from"./remote-BJdzzFZg.js";import{_ as R}from"./titleFrameBudget-Cml-MO53.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
@@ -0,0 +1 @@
1
+ import{b as N,c as E,a as _,d as D}from"./shotFxAgent-BDfe73TP.js";import{jb as B,jc as P,gE as h,eD as z,ei as A,dB as L,dz as U}from"./remote-BJdzzFZg.js";import"./api-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.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=U(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}}},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 B&&o.userText!=null&&!P(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===z),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,{...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};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-DIi45swK.js","assets/titleFrameBudget-Cml-MO53.js","assets/api-QBI5GJTZ.js"])))=>i.map(i=>d[i]);
2
+ import{_ as C}from"./titleFrameBudget-Cml-MO53.js";import{gE as O,iQ as j,fi as L,fV as P,dM as T,jd as U,je as E,jf as B,fM as $,fT as D,fU as I}from"./remote-BJdzzFZg.js";import"./api-QBI5GJTZ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const F=["twos","snap","anticipation","exaggerate","squash","smear"],A=t=>Array.isArray(t)&&t.length===3&&t.every(p=>Number.isFinite(Number(p)))?t.map(Number):null,K=t=>t==="left"?"L":t==="both"?"both":"R",w=t=>Math.round(t*1e3)/1e3;function Z(t,p){const c=p.getStage(),d=O(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 F)typeof t[r]=="boolean"&&(s[r]=t[r]);if(t.shot_default){const r=D({...d.toon||I,...s});return p.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=>j(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 p.setStage(r=>({...r,items:r.items.map(m=>{if(!l.some(h=>h.id===m.id))return m;const f=D({...D(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 tt(t,p){const c=p.getStage(),d=O(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=j(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=P.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=T(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)||P.restitution))}});const m=K(t.hand),f=(d.ball?.[l.id]||[]).filter(e=>e.t<s-1e-6),h=[],y=A(t.velocity);let N=A(t.target),b=null;if(a==="throw"&&!y&&!N&&t.target_person==null){if(b=U((await E(p,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&&(N=[...b.rim])}let v;if(t.target_person!=null)try{v=j(c,String(t.target_person))}catch(e){return{ok:!1,error:e.message}}if(a==="drop"||a==="bounce")h.push({t:s,kind:"launch",from:u??[...l.position],vel:y??(a==="bounce"?[0,3.5,0]:[0,0,0])});else if(a==="hold")h.push({t:s,kind:"hold",by:o.id,hand:m});else if(a==="dribble")h.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))h.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;h.push({t:s,kind:"throw",...y?{vel:y}:v?{to:{by:v.id,hand:"both"},arrive:i??.9}:{to:N??[l.position[0],3.05,l.position[2]+4],...i?{arrive:i}:{},apex:Number(t.apex)||(b?1:.9),...b?{net:!0}:{}}}),v&&h.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]);h.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 x=[...f.filter(e=>!h.some(i=>i.t<=e.t+1e-6)),...h].sort((e,i)=>e.t-i.t),_=l.id,S=l;p.setStage(e=>({...e,items:k?[...e.items,S]:e.items.map(i=>i.id===_?S:i),shots:e.shots.map(i=>i.id===d.id?{...i,ball:{...i.ball,[_]:x}}:i)}));const M=h.find(e=>e.kind==="launch"&&Array.isArray(e.vel)),n=M&&M.kind==="launch"?B(M.from??S.position,M.vel,M.t,d.duration,{radius:r,restitution:S.ball?.restitution}).impacts.slice(0,8).map(e=>w(e.time)):void 0;return{ok:!0,name:S.name,created:k,...b?{hoop:"aimed through the rim centre, drops through the net"}:{},events:x.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 et(t,p){const c=p.getStage(),d=O(c),a=await C(()=>import("./rotoMaskStore-DIi45swK.js").then(n=>n.W),__vite__mapDeps([0,1,2]));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=>j(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",h=p.engine(),y=s.map(n=>n.id);h&&h.sync(c,null);const N=h?.physicsShapes(y)??{},b=(await E(p,c)).colliders.filter(n=>!y.includes(n.itemId)),v={},x=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),...N[n.id]??a.fallbackShape(n)}}),_=await a.bakeDrop({bodies:x,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}),S=Object.fromEntries(s.map(n=>[n.id,$(n,d,u).scale]));p.setStage(n=>a.applyDropKeys(n,d.id,_.tracks,{scale:S,lifted:r==="above"}));const M={};for(const n of s){const e=_.tracks[n.id];e&&(M[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:M,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{tt as addBall,et as physicsDrop,Z as setToon};
@@ -0,0 +1 @@
1
+ import{b as M,gE as b,j6 as j,dz as $,j8 as F,j9 as y,ja as N}from"./remote-BJdzzFZg.js";import{a as A}from"./shotFxAgent-BDfe73TP.js";import{Vector3 as _}from"./three.module-Bx43vjkH.js";import"./api-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const C=4,T=1.25;function w(t,c,r){return t.updateMatrixWorld(),new _(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=j(o,m),a=w(p,d,l);let u=r??NaN;if(!Number.isFinite(u)&&f){const h=$(f,o,m);u=new _(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 H(t,c,r,o,s){const f=b(t),n=Math.max(1e-6,f.duration),d=j(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 F(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?N(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 L(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=A(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(([v])=>v!==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}}:{...M("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{L as followTrack,H as scenePoint,S as trackWorldPoints};
@@ -0,0 +1 @@
1
+ import{t as f,bY as p,bZ as b,c as S,b_ as _,r as U}from"./api-QBI5GJTZ.js";import{u as C}from"./store-2zneEhhu.js";import{i as w}from"./textAnimators-Bdt5LWXk.js";import"./titleFrameBudget-Cml-MO53.js";let e={fonts:[],loaded:!1,error:null};const l=new Set,c=t=>{e={...e,...t},l.forEach(o=>o())},E=t=>(l.add(t),()=>{l.delete(t)}),N=()=>U.useSyncExternalStore(E,()=>e),O=()=>e,x={ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2"},$=".ttf,.otf,.woff,.woff2,font/ttf,font/otf,font/woff,font/woff2",d=10,u=new Map;function h(t){if(!t.url||u.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),u.set(t.family,o)}function m(t){const o=u.get(t);o&&(document.fonts.delete(o),u.delete(t))}let a=null,g=!1;function y(t=!1){return g||(g=!0,C.subscribe((o,r)=>{const n=o.user?.uid??null,i=r.user?.uid??null;if(n!==i)if(n)y(!0);else{for(const s of e.fonts)m(s.family);a=Promise.resolve(),c({fonts:[],loaded:!0,error:null})}})),a&&!t||(a=p().then(o=>{const r=(Array.isArray(o?.fonts)?o.fonts:[]).filter(n=>n&&w(n.family)&&typeof n.name=="string");for(const n of e.fonts)r.some(i=>i.family===n.family)||m(n.family);for(const n of r)try{h(n)}catch{}c({fonts:r,loaded:!0,error:null})}).catch(o=>{c({loaded:!0,error:o?.message||"fonts"})})),a}const v=()=>y();function B(t){return t?w(t)?e.fonts.find(o=>o.family===t)?.name??f("Font đã xoá"):t:"Arial"}const P=t=>!!t&&w(t)&&e.loaded&&!e.error&&!e.fonts.some(o=>o.family===t);function z(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 L(t,o){const r=(t.name.match(/\.([a-z0-9]+)$/i)?.[1]||"").toLowerCase(),n=x[r];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 S(new File([t],t.name,{type:n}),o,"font"),s=await _({gcsUri:i.gcsUri,rightsConfirmed:!0});return h(s.font),c({fonts:[s.font,...e.fonts.filter(F=>F.family!==s.font.family)]}),s}async function Y(t){await b(t.id),m(t.family),c({fonts:e.fonts.filter(o=>o.id!==t.id)})}export{$ as FONT_ACCEPT,d as FONT_MAX_MB,x as FONT_TYPES,z as fontError,B as fontLabel,P as isMissingCustomFont,y as loadUserFonts,Y as removeUserFont,L as uploadUserFont,N as useUserFonts,v as userFontsReady,O as userFontsState};
@@ -1,4 +1,4 @@
1
- import{ii as D}from"./remote-DXG553d8.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-C5pOWyBM.js";import"./titleFrameBudget-BjW--v_T.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.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{i4 as D}from"./remote-BJdzzFZg.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-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.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{ii as D}from"./remote-DXG553d8.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 Q(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{Q 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 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};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShotComposer-BLztjSKy.js","assets/titleFrameBudget-Cml-MO53.js","assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/tool-Bt9bclIf.js","assets/timelineProps-B2pnudeT.js","assets/thumb-byAKvhQP.js","assets/shotFxAgent-BDfe73TP.js","assets/cameraPresets-4pFeF2YG.js","assets/weaponDuel-CLLgv5A4.js","assets/skin-GDY3QPkV.js","assets/views-CsrYzCSR.js","assets/motionBlur-uAm030t9.js","assets/library-Dsz_MLyd.js","assets/ShotComposer-VixLbeMe.css"])))=>i.map(i=>d[i]);
2
+ import{_ as l}from"./titleFrameBudget-Cml-MO53.js";import{R as h}from"./api-QBI5GJTZ.js";import{dj as w}from"./remote-BJdzzFZg.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";let m=Promise.resolve();const p=o=>new Promise(r=>setTimeout(r,o));function R(o,r,{timeoutMs:d=6e4}={}){const i=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 s=w.createRoot(e);try{const{default:u}=await l(async()=>{const{default:t}=await import("./ShotComposer-BLztjSKy.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]));let n=null;s.render(h.createElement(u,{nodeId:o,background:t=>{n=t}}));const c=Date.now()+d;for(;!n?.ready();){if(Date.now()>c)throw new Error("3D Shot did not start in time");await p(60)}for(;;)try{return await r(n)}catch(t){if(!/chưa tải xong/.test(t.message)||Date.now()>c)throw t;await p(500)}}finally{s.unmount(),e.remove()}},a=m.then(i,i);return m=a.catch(()=>{}),a}export{R as withBackgroundScene};
@@ -0,0 +1 @@
1
+ import{gC as F}from"./remote-BJdzzFZg.js";import{s as U}from"./motionBlur-uAm030t9.js";import{M as Y}from"./motionBlur-uAm030t9.js";import{bD as S,c as M}from"./id3-BCR9Bqgo.js";import{S as O,B as D,O as H,W as P,a as B,C as I}from"./output-BwZzMbp-.js";import"./api-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";async function G(s,T,h){const{start:d,end:k,fps:a,signal:w,progress:p}=h,r=k-d,n=Math.ceil(r*a);if(!(r>0)||!Number.isFinite(r)||!F.includes(a))throw new Error("Khoảng thời gian hoặc FPS không hợp lệ");const g=new S({bitrate:h.height>=1080?6e6:3e6}),o=h.alpha===!0,f=o?"vp9":"avc",v=o?"webm":"mp4";if(!await M(f,{width:s.width,height:s.height,quality:g}))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 m,c;const l=`camera-export-${crypto.randomUUID()}.${v}`;let t;const y=async()=>{m&&await m.removeEntry(l).catch(()=>{})};try{let i;if(navigator.storage?.getDirectory)m=await navigator.storage.getDirectory(),c=await m.getFileHandle(l,{create:!0}),i=new O(await c.createWritable(),{chunked:!0,chunkSize:1024*1024});else{if(r*(h.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 u=new I(s,{codec:f,quality:g,...o?{alpha:"keep"}:{}});t.addVideoTrack(u,{frameRate:a,maximumPacketCount:n}),await t.start();for(let e=0;e<n;e++){w.throwIfAborted();const b=e/a,C=Math.min(1/a,r-b);await T(d+(n>1?e/(n-1):0)*r),await u.add(b,C,{keyFrame:e%a===0}),e%6===0&&(p(Math.round((e+1)/n*95)),await new Promise(E=>setTimeout(E,0)))}w.throwIfAborted(),u.close(),await t.finalize();const x=c?await c.getFile():new Blob([i.buffer],{type:o?"video/webm":"video/mp4"});return p(100),{blob:x,cleanup:y}}catch(i){throw t&&t.state!=="finalized"&&t.state!=="canceled"&&await t.cancel().catch(()=>{}),await y(),i}}export{Y as MOTION_BLUR,G 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{c as D}from"./GLTFLoader-BHWu1lKg.js";import{f as E}from"./skin-GDY3QPkV.js";import"./remote-BJdzzFZg.js";import"./api-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const B=640;function U(y,c=B){const t=D(y);t.position.set(0,0,0),t.quaternion.identity(),t.scale.set(1,1,1);const p=[];t.traverse(e=>{e.userData.rigOverlay&&p.push(e),e instanceof k&&e.quaternion.identity()}),p.forEach(e=>e.parent?.remove(e)),t.traverse(e=>{e instanceof g&&e.skeleton.pose()});const d=E(t),n=d.getCenter(new a),f=d.getSize(new a),r=Math.max(f.x,f.y,f.z)/2*1.08,o=new L;o.background=new M("#ffffff");const m=new b({color:"#8d949b"});o.overrideMaterial=m,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(c,c,!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{m.dispose(),i.dispose(),i.forceContextLoss(),t.traverse(e=>{e instanceof g&&e.skeleton.dispose()})}}export{B as VIEW_SIZE,U as renderRigViews};
@@ -0,0 +1 @@
1
+ import{iu as pt,iv as Y,fg as ut,ff as mt,fi as Z,fk as B,hz as kt,b as gt,fl as bt,fv as tt,fw as et,hv as Mt,fM as yt,hy as wt}from"./remote-BJdzzFZg.js";import{F as vt}from"./rigTrack-CUt4O67J.js";const P=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},Ft=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(P(t).clip),at.set(t,e)),e},Kt=(t,e)=>t[Math.max(0,Math.min(t.length-1,Math.round(e*30)))];function lt(t){const e=P(t).clip.keys.filter(a=>a.strike).at(-1);return e?e.t:0}const At=t=>P(t).clip.keys.filter(e=>e.strike).at(-1)?.limb??"handR",ot=(t,e)=>Kt(dt(t),e).dz??0;function $t(t){const{pack:e}=P(t),a=dt(t),l=lt(t),o=At(t);let f=0;for(const h of a){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 St(t){let e=t>>>0||1;return()=>{e=e+1831565813>>>0;let a=Math.imul(e^e>>>15,1|e);return a=a+Math.imul(a^a>>>7,61|a)^a,((a^a>>>14)>>>0)/4294967296}}function Tt(t,e=4,a=1){const l=St(a),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(S=>S!==h[f]),g=m[Math.floor(l()*m.length)],z=st[u][g];h[f]=g;const i=l();let y=r===e-1?"body":i<.5?"blocked":i<.78?"miss":"body";y==="blocked"&&!it[z]&&(y="miss");const $=`${j}-${y==="blocked"?it[z]:y==="miss"?"dodge-back":"hit"}`,D=lt(g),O=P($).clip.contact??0,b=Math.max(Ft,$t(g)+Ot[y]+ot(g,D)+ot($,O));o.push({attacker:f,attack:g,defence:$,result:y,strike:D,contact:O,gap:Math.round(b*1e3)/1e3})}return o}const q=[.18,.42],nt=t=>(t.kind==="model"?(t.model?.height??2)/1.8:Mt(t))*(t.scale[1]||1),x=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const a=v(t),l=a.duration/e,o=h=>h?.map(r=>({...r,time:Math.min(1,r.time*l)})),f={...a,duration:e,cameraKeys:o(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([h,r])=>[h,o(r)||[]])),...a.impacts?{impacts:o(a.impacts)}:{},...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([h,r])=>[h,o(r)||[]]))}:{}};return{...t,shots:t.shots.map(h=>h.id===a.id?f:h)}}const ct=(t,e,a)=>{const l=v(t);return{...t,shots:t.shots.map(o=>o.id===l.id?{...o,objectKeys:{...o.objectKeys,[e]:a(o.objectKeys?.[e]||[],o)}}:o)}},T=(t,e,a)=>{const l=v(t),o=yt(t.items.find(f=>f.id===e.id),l,Math.min(1,a/l.duration));return{position:o.position,yaw:o.rotation[1]}};function Pt(t,e,a){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),g=v(t),z=m+.5+h.reduce((s,c)=>s+Math.max(B(c.attack).duration,c.strike-c.contact+B(c.defence).duration)+1.4+q[1],0);let i=z>g.duration?rt(t,Math.min(300,z)):t;const M=T(i,l,m),y=h[0].gap*(u[0]+u[1])/2,$=[Math.sin(x(M.yaw)),0,Math.cos(x(M.yaw))],D=[M.position[0]+$[0]*y,M.position[1],M.position[2]+$[2]*y];for(const[s,c,n]of[[l,M.position,M.yaw],[o,D,M.yaw+180]])i=ct(i,s.id,(d,k)=>[...d.filter(p=>p.time*k.duration<m-1e-6),{id:a(),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(i),k=B(c),p=wt(i,r[s].id,k,{start:n/d.duration,newId:a,loop:!1});if(!p.ok)throw new Error(`${r[s].name}: ${p.error}`);return i=p.stage,n+k.duration};let b=m+.35,S=m;const C=[];let H=(e.seed*9301+49297)%233280;const ht=()=>(H=(H*9301+49297)%233280,H/233280);try{h.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const F=T(i,r[0],b).position,K=T(i,r[1],b).position;return Math.hypot(K[0]-F[0],K[2]-F[2])};for(let F=0;F<3;F++){const K=p()-s.gap*k;if(Math.abs(K)<.3*k)break;K>0?b=O(n,`${e.packs[n]}-advance`,b):b=O(d,`${e.packs[d]}-retreat`,b)}const N=Math.max(0,s.contact-s.strike),w=b+N,_=w+s.strike-s.contact,E=p()-s.gap*k,G=O(n,s.attack,w),ft=O(d,s.defence,_),L=r[n],U=T(i,L,w).yaw,W=[Math.sin(x(U)),Math.cos(x(U))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,E));i=ct(i,L.id,(F,K)=>F.map(A=>{const I=A.time*K.duration;if(I<w-1e-6||I>G+1e-6)return A;const R=Math.min(1,(I-w)/Math.max(.001,s.strike)),Q=R*R*(3-2*R),X={...A,position:[+(A.position[0]+W[0]*V*Q).toFixed(3),A.position[1],+(A.position[2]+W[1]*V*Q).toFixed(3)]};return A.strike&&Math.abs(I-J)<.06?{...X,hit:s.result}:X})),C.push({...s,time:+J.toFixed(2),attackerName:L.name}),S=Math.max(G,ft),b=S+q[0]+(q[1]-q[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(i).duration>g.duration&&(i=rt(i,Math.max(g.duration,Math.min(300,Math.ceil((S+.6)*10)/10)))),i=kt(i).stage,e.packs.includes("fist")){const s=v(i),c=[],n={};C.forEach((d,k)=>{if(d.result==="miss"||e.packs[d.attacker]!=="fist")return;const p=T(i,r[0],d.time).position,N=T(i,r[1],d.time).position,w=(u[0]+u[1])/2,_=`duelfx-${r[d.attacker].id}-${Math.round(d.time*1e3)}`,E=d.result==="body";c.push({...gt("fx",i.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:E?"#ffd27a":"#9fdcff",fx:{preset:"vong_xung_kich",cat:"vong-xung-kich",intensity:E?.9:.75,seed:500+k,start:d.time,duration:.6,loop:!1,auto:"hit",params:{size:(E?1.05:.85)*w,height:+(1.35*w).toFixed(2),hits:1,gap:.3}}}),n[_]={start:d.time,duration:.6}}),c.length&&(i={...i,items:[...i.items,...c],shots:i.shots.map(d=>d.id===s.id?{...d,fxTiming:{...d.fxTiming,...n}}:d)})}if(e.hitStops!==!1){const s=v(i);let c=bt(s.timing,s.duration);c=tt(c,C.filter(n=>n.result==="blocked").map(n=>n.time),et.light,s.duration),c=tt(c,C.filter(n=>n.result==="body").map(n=>n.time),et.heavy,s.duration),i={...i,shots:i.shots.map(n=>n.id===s.id&&c?{...n,timing:c}:n)}}return{ok:!0,stage:i,plan:C,end:+S.toFixed(2),notes:j}}export{st as D,Pt as s};
@@ -1 +1 @@
1
- import{mC as P,a7 as b,U as W,$ as y,Z as E,a0 as F,lz as x}from"./titleFrameBudget-BjW--v_T.js";import"./rotoMatte-2EcyuvBX.js";import"./api-C5pOWyBM.js";import"./store-Dxq3MZF3.js";const N=e=>P(e).length>0,O=new Map;function D(e){const r=e.face??e.colorPerson??e.person??e.roto??e.mask;if(r?.mw&&r?.mh)return Promise.resolve(r.mh/r.mw);let o=O.get(e.url);return o||(o=new Promise(n=>{if(e.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=e.url;return}const t=document.createElement("video");t.preload="metadata",t.muted=!0,t.crossOrigin="anonymous",t.onloadedmetadata=()=>{n(t.videoHeight/Math.max(1,t.videoWidth)),t.removeAttribute("src"),t.load()},t.onerror=()=>n(9/16),t.src=e.url}),O.set(e.url,o)),o}function I(e,r,o,n,t,a,g){const i=W(e.grade)[r],h=e.colorPerson?E(e.colorPerson):null,f=F(i,e,o,a,h),c=g??document.createElement("canvas");(c.width!==n||c.height!==t)&&Object.assign(c,{width:n,height:t});const l=c.getContext("2d"),d=l.createImageData(n,t);for(let w=0;w<t;w++)for(let u=0;u<n;u++){const m=(w*n+u)*4,s=Math.round(f((u+.5)/n,(w+.5)/t,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 U(e,r,o,n){const t=document.createElement("canvas");for(const{key:a,k:g,clip:i}of P(e)){if(o.wants&&!o.wants("windowFrames",a))continue;i.colorPerson&&await b(i.colorPerson);const h=await D(i),f=x,c=Math.max(2,Math.min(x*2,Math.round(f*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 p=JSON.stringify(y(l,i,s/r));if(s&&p===m){await o.push("windowFrames",a,"=");continue}m=p}I(i,g,s/r,f,c,h,t);const M=t.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(p=>setTimeout(p,0))}}}export{N as hasMovingWindows,D as pictureAspect,U as renderWindowFrames,I as windowMatteImage};
1
+ import{mJ as P,a7 as b,U as W,$ as y,Z as E,a0 as F,lA as x}from"./titleFrameBudget-Cml-MO53.js";import"./rotoMatte-013RKqHu.js";import"./api-QBI5GJTZ.js";import"./store-2zneEhhu.js";const N=e=>P(e).length>0,O=new Map;function D(e){const r=e.face??e.colorPerson??e.person??e.roto??e.mask;if(r?.mw&&r?.mh)return Promise.resolve(r.mh/r.mw);let o=O.get(e.url);return o||(o=new Promise(n=>{if(e.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=e.url;return}const t=document.createElement("video");t.preload="metadata",t.muted=!0,t.crossOrigin="anonymous",t.onloadedmetadata=()=>{n(t.videoHeight/Math.max(1,t.videoWidth)),t.removeAttribute("src"),t.load()},t.onerror=()=>n(9/16),t.src=e.url}),O.set(e.url,o)),o}function A(e,r,o,n,t,a,g){const i=W(e.grade)[r],h=e.colorPerson?E(e.colorPerson):null,f=F(i,e,o,a,h),c=g??document.createElement("canvas");(c.width!==n||c.height!==t)&&Object.assign(c,{width:n,height:t});const l=c.getContext("2d"),d=l.createImageData(n,t);for(let w=0;w<t;w++)for(let u=0;u<n;u++){const m=(w*n+u)*4,s=Math.round(f((u+.5)/n,(w+.5)/t,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 U(e,r,o,n){const t=document.createElement("canvas");for(const{key:a,k:g,clip:i}of P(e)){if(o.wants&&!o.wants("windowFrames",a))continue;i.colorPerson&&await b(i.colorPerson);const h=await D(i),f=x,c=Math.max(2,Math.min(x*2,Math.round(f*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 p=JSON.stringify(y(l,i,s/r));if(s&&p===m){await o.push("windowFrames",a,"=");continue}m=p}A(i,g,s/r,f,c,h,t);const M=t.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(p=>setTimeout(p,0))}}}export{N as hasMovingWindows,D as pictureAspect,U as renderWindowFrames,A 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-Rbo-YZv-.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-BjW--v_T.js">
9
- <link rel="modulepreload" crossorigin href="/assets/frameSink-CB1EghW0.js">
7
+ <script type="module" crossorigin src="/assets/layer-worker-Cp0pjurp.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-Cml-MO53.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/frameSink-BGRj7wqY.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
@@ -1 +0,0 @@
1
- import{j as d,dD as y,dE as w}from"./remote-DXG553d8.js";import{r as p}from"./api-C5pOWyBM.js";import{t as b,a as E,d as u}from"./thumb-xLFX6lDN.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.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 N(){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{N as default,F as previewEntry};
@@ -1 +0,0 @@
1
- import{j as w,dC as F}from"./remote-DXG553d8.js";import{r as l}from"./api-C5pOWyBM.js";import{d as M,m as E}from"./lottieLayer-BhLbZOpr.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.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 P(){const f=l.useRef(null),[o,R]=l.useState(null),[y,x]=l.useState(""),b=l.useRef(Promise.resolve());return l.useEffect(()=>{const a=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),h=async t=>{if(!I.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const i="id"in t.data?t.data.id:null;let e;try{e=F(t.data.motion)}catch(n){a(t,{type:"clipoox-motion-error",id:i,error:n.message});return}if(t.data.type==="clipoox-motion-play"){x(""),R(e);return}if(t.data.type==="clipoox-motion-thumb"){const[n,u]=L(e),m=480/Math.max(n,u),s=Math.round(n*m),d=Math.round(u*m);try{const p=await E({layer:"embed:thumb",motion:{v:1,code:e.code,params:e.params},t:Number.isFinite(t.data.t)?Math.max(0,Math.min(e.duration,Number(t.data.t))):e.duration*.55,width:s,height:d,duration:e.duration}),c=Object.assign(document.createElement("canvas"),{width:s,height:d}),g=c.getContext("2d");if(!g)throw Error("canvas");g.fillStyle="#16181c",g.fillRect(0,0,s,d),g.drawImage(p,0,0),p.close(),a(t,{type:"clipoox-motion-thumb",id:i,webp:c.toDataURL("image/webp",.85)})}catch(p){a(t,{type:"clipoox-motion-error",id:i,error:p.message})}finally{M("embed:thumb")}}},r=t=>{b.current=b.current.then(()=>h(t)).catch(()=>{})};return window.addEventListener("message",r),window.parent?.postMessage({type:"clipoox-motion-ready"},"*"),()=>window.removeEventListener("message",r)},[]),l.useEffect(()=>{const a=f.current,h=a?.getContext("2d");if(!o||!a||!h)return;let r=!0,t=0;const i=performance.now(),[e,n]=L(o),u=Math.min(1,960/Math.max(e,n)),m=Math.round(e*u),s=Math.round(n*u);a.width=m,a.height=s;const d=async()=>{if(!r)return;const p=(performance.now()-i)/1e3%(o.duration+.8);try{const c=await E({layer:"embed:play",motion:{v:1,code:o.code,params:o.params},t:Math.min(p,o.duration),width:m,height:s,duration:o.duration});r&&(h.clearRect(0,0,m,s),h.drawImage(c,0,0)),c.close()}catch(c){if(r){x(c.message);return}}r&&(t=requestAnimationFrame(()=>void d()))};return d(),()=>{r=!1,cancelAnimationFrame(t),M("embed:play")}},[o]),w.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[w.jsx("canvas",{ref:f,width:1280,height:720,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Motion preview"}),y&&w.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:y})]})}export{P as default};
@@ -1,3 +0,0 @@
1
- import{r as vn,j as s}from"./remote-DXG553d8.js";import{u as on,r as d,t as a}from"./api-C5pOWyBM.js";import{ao as bn,ap as Nn,aq as hn,ar as un,as as q,at as R,au as X,av as kn,M as wn,aw as yn,z as Cn,ax as Sn,ay as Ln,o as Mn,az as Dn,aA as H,aB as Un,aC as $n,e as Pn,aD as Tn}from"./main-BNZrzSIG.js";import{d as An,k as In,m as Kn,l as En}from"./lottieLayer-BhLbZOpr.js";import{p as Vn}from"./TimelinePlugins-CkP5P9b_.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";import"./spark.module-CMSPLU2n.js";import"./userFonts-txN4I-eo.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./titleArt-CAOxtyHl.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.js";import"./pluginAutomation-DdZOnpoV.js";const pn=[{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"}],V=e=>e.kind==="pack"&&!!e.kit?.modelAssets,J=e=>V(e)?"kit":e.kind,F=e=>e.kind==="link"&&!!e.link,Fn=e=>{e.link&&window.open(e.link.url,"_blank","noopener,noreferrer")},mn=(e,l)=>e>=1024*1024?`${(e/1024/1024).toFixed(e>=10*1024*1024?0:1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,Q=({n:e=28})=>s.jsx("span",{className:"ps-wave","aria-hidden":!0,children:Array.from({length:e},(l,r)=>s.jsx("i",{style:{height:`${18+Math.round(72*Math.abs(Math.sin(r*1.37)*Math.cos(r*.41)))}%`}},r))}),gn=(e,l)=>pn.find(r=>r.id===e)?.[l==="en"?"en":"vi"]??e,Bn=5e3,On=600*1e3,dn=e=>e.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/gi,"d").toLowerCase(),Rn=e=>{const l=(r,o)=>r>0&&o>0?Math.min(r,o):r>0?r:o;return R({priceVnd:l(e.priceVnd,e.passVnd??0),priceUsd:l(e.priceUsd,e.passUsd??0)})};function vs({installed:e,initialId:l=null,onClose:r,onInstalled:o,onUse:j,toast:c}){const p=on(),u=p==="en"?"en":"vi",[b,C]=d.useState(null),[g,k]=d.useState([]),[M,A]=d.useState(""),[S,t]=d.useState("all"),[h,f]=d.useState("all"),[D,K]=d.useState(""),[x,w]=d.useState(null),[$,P]=d.useState(""),[T,v]=d.useState({}),[U,L]=d.useState(""),y=d.useCallback(()=>bn().then(n=>(k(n.owned),n.owned)).catch(()=>[]),[]),[I,G]=d.useState(!1);d.useEffect(()=>{Nn().then(n=>C(n.items),n=>{C([]),A(n.message)}),y().finally(()=>G(!0))},[y]);const E=d.useRef(!1);d.useEffect(()=>{if(!l||E.current||b===null||!I)return;E.current=!0;const n=b.find(i=>i.id===l)??g.find(i=>i.storeId===l&&i.item)?.item;n?w(n):c(a("Không tìm thấy plug-in này trong kho."),"error")},[l,b,g,I,c]),d.useEffect(()=>{const n=i=>{i.key==="Escape"&&(i.stopPropagation(),x?w(null):r())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[x,r]);const Y=Object.keys(T).join(",");d.useEffect(()=>{if(!Y)return;const n=window.setInterval(()=>{y().then(i=>{v(m=>{const N={...m};for(const O of Object.keys(N))(an(i,O)||Date.now()-N[O]>On)&&delete N[O];return N})})},Bn);return()=>window.clearInterval(n)},[Y,y]);const B=n=>g.some(i=>i.storeId===n&&i.owned),z=n=>g.find(i=>i.storeId===n),Z=n=>g.some(i=>i.storeId===n&&i.status==="refunded"),nn=n=>e.some(i=>i.id===n&&i.source?.store===n),W=async n=>{P(n.id);try{await Ln(n.id),o(),Mn(),L(n.id),c(a("Đã cài “{0}” vào Plug-in của tôi",[n.name[u]]),"ok")}catch(i){const m=Vn(i);c(m.text,"error")}finally{P("")}},sn=d.useRef({}),en=n=>n?.owned?n.expiresAt?String(n.expiresAt):"life":"none",an=(n,i)=>{const m=n.find(N=>N.storeId===i);return!!m?.owned&&en(m)!==(sn.current[i]??"none")},tn=(n,i)=>{sn.current[n.id]=en(z(n.id)),Sn(n.id,i),v(m=>({...m,[n.id]:Date.now()}))},xn=async n=>{const i=await y();an(i,n)?(v(m=>{const N={...m};return delete N[n],N}),c(a("Thanh toán xong — plug-in đã thuộc về bạn"),"ok")):c(a("Chưa thấy thanh toán. Nếu bạn vừa chuyển khoản, đợi một chút rồi kiểm tra lại."),"error")},jn=g.filter(n=>n.item).map(n=>n.item),_=(S==="owned"?jn:(b??[]).filter(n=>S==="all"||(S==="free"?n.free:!n.free))).filter(n=>(h==="all"||J(n)===h)&&(!D.trim()||dn(D).split(/\s+/).every(i=>dn(`${n.name.vi} ${n.name.en} ${n.description.vi} ${n.description.en} ${n.author.name} ${n.tags.join(" ")}`).includes(i)))),fn=[{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")}],ln=(n,i)=>$===n.id?s.jsxs("button",{className:i,disabled:!0,children:[s.jsx("i",{className:"spin"})," ",a("Đang cài…")]}):nn(n.id)||U===n.id?s.jsxs(s.Fragment,{children:[j?s.jsxs("button",{className:`${i} ps-use`,onClick:()=>j(n.id),children:["✓ ",a("Đã cài · Dùng ngay")]}):s.jsxs("span",{className:`${i} ps-use`,role:"status",children:["✓ ",a("Đã cài")]}),s.jsx("button",{className:"ps-reinstall",title:a("Cài lại plug-in"),onClick:()=>void W(n),children:a("Cài lại")})]}):s.jsx("button",{className:i,onClick:()=>void W(n),children:a("Cài plug-in")}),rn=(n,i=!1)=>{const m=`ad-use${i?" ps-big":""}`;if(F(n))return s.jsxs("button",{className:m,onClick:()=>Fn(n),children:[n.link.label?.[u]||a("Hướng dẫn cài")," ↗"]});if(n.free)return ln(n,m);if(T[n.id])return s.jsx("button",{className:`${m} ps-wait`,onClick:()=>void xn(n.id),children:a("Đã thanh toán? Kiểm tra lại")});if(n.kind==="sfxlib"){const N=z(n.id);if(!i&&!N?.owned)return s.jsx("button",{className:m,onClick:()=>w(n),children:N?.expiresAt?a("Gia hạn"):a("Xem & mua")});if(i)return s.jsx(_n,{item:n,owned:N,busy:$===n.id,installed:nn(n.id),onInstall:()=>void W(n),onBuy:O=>tn(n,O)})}return B(n.id)?ln(n,m):s.jsx("button",{className:m,onClick:()=>tn(n),children:a("Mua · {0}",[R(n)])})},cn=n=>{if(n.free)return s.jsx("span",{className:"ps-price free",children:a("Miễn phí")});const i=z(n.id);return i?.owned?s.jsxs("span",{className:"ps-price owned",children:["✓ ",i.expiresAt?a("Vé đến {0}",[X(i.expiresAt,p)]):a("Đã sở hữu")]}):s.jsx("span",{className:"ps-price",children:n.kind==="sfxlib"?(n.passVnd||n.passUsd)&&!(n.priceVnd||n.priceUsd)?a("{0} / 30 ngày",[q(n)]):a("từ {0}",[Rn(n)]):R(n)})};return vn.createPortal(s.jsx("div",{className:"ad-backdrop",role:"dialog","aria-modal":"true","aria-label":a("Kho Plug-in"),onMouseDown:n=>{n.target===n.currentTarget&&r()},children:s.jsxs("section",{className:"ad-drawer ps-drawer",onMouseDown:n=>n.stopPropagation(),children:[s.jsxs("header",{className:"ad-head",children:[s.jsxs("div",{className:"ad-title",children:["🛍 ",a("Kho Plug-in")]}),s.jsxs("span",{className:"ad-count",children:[_.length," ",a("mục")]}),s.jsx("div",{className:"grow"}),s.jsx("button",{className:"ad-iconbtn",title:a("Đóng"),"aria-label":a("Đóng"),onClick:r,children:"✕"})]}),s.jsx("nav",{className:"ad-sources",children:fn.map(n=>s.jsxs("button",{className:`ad-tab${S===n.id?" on":""}`,"aria-pressed":S===n.id,onClick:()=>t(n.id),children:[n.id==="all"&&s.jsx("span",{className:"ad-pin",children:"⧉"}),n.label,n.id==="owned"&&g.filter(i=>i.owned).length>0&&s.jsx("span",{className:"ps-n",children:g.filter(i=>i.owned).length})]},n.id))}),s.jsxs("div",{className:"ad-tools",children:[s.jsx("input",{className:"ad-search","aria-label":a("Tìm plug-in"),placeholder:a("Tìm plug-in, tác giả, thẻ…"),value:D,onChange:n=>K(n.target.value),onKeyDown:n=>n.stopPropagation()}),s.jsx("div",{className:"ad-chips",role:"group","aria-label":a("Loại plug-in"),children:pn.map(n=>s.jsx("button",{className:`ad-chip${h===n.id?" on":""}`,"aria-pressed":h===n.id,onClick:()=>f(n.id),children:n[u]},n.id))})]}),s.jsxs("div",{className:"ad-notice",children:[s.jsxs("b",{children:["⧉ ",a("Plug-in không tốn credit.")]})," ",h==="sfxlib"?a("Kho âm thanh: mua một lần hoặc vé 30 ngày trên clipoox.com, tính là 1 plug-in; âm chỉ chép vào dự án khi bạn dùng."):a("Bản miễn phí cài ngay; bản trả phí mua một lần trên clipoox.com (chuyển khoản / thẻ), cài lại bất cứ lúc nào.")]}),s.jsxs("div",{className:"ad-content",children:[M&&s.jsx("p",{role:"alert",className:"ad-alert",children:M}),b===null&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),b!==null&&!_.length&&s.jsx("div",{className:"ad-empty",children:S==="owned"?a("Bạn chưa mua plug-in nào."):D?a("Không có plug-in khớp tìm kiếm."):a("Kho chưa có plug-in nào trong nhóm này.")}),s.jsx("div",{className:"ad-grid",children:_.map(n=>s.jsxs("article",{className:"ad-card ps-card","data-store":n.id,children:[s.jsxs("button",{className:"ad-prev ps-open","aria-label":a("Xem {0}",[n.name[u]]),onClick:()=>w(n),children:[n.thumbnailUrl?s.jsx("img",{src:n.thumbnailUrl,alt:"",loading:"lazy"}):n.kind==="sfx"||n.kind==="sfxlib"?s.jsx(Q,{}):s.jsx("span",{className:"ad-ph",children:"⧉"}),s.jsx("span",{className:"ad-badge",children:(F(n)?n.link.platform:gn(J(n),p)).toUpperCase()}),n.featured&&s.jsxs("span",{className:"ps-featured",title:a("Đối tác tiên phong của Clipoox"),children:["★ ",a("Đối tác tiên phong")]}),n.private&&s.jsxs("span",{className:"ps-private",title:a("Chỉ các tài khoản được Clipoox chọn mới thấy gói này"),children:["🔒 ",a("Gói riêng")]})]}),s.jsxs("div",{className:"ad-meta",children:[s.jsx("div",{className:"ad-name",title:n.name[u],children:n.name[u]}),s.jsxs("div",{className:"ad-sub ps-sub",children:[s.jsxs("span",{className:"ps-by",children:[n.author.name," · v",n.version]}),cn(n)]}),n.kind==="pack"&&!V(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["⧉ ",a("{0} mục trong gói",[n.itemCount??0])]}),V(n)&&s.jsxs("div",{className:"ps-kit-meta",children:["◈ ",s.jsx("b",{children:n.kit.items})," ",a("mục")," · ",s.jsx("b",{children:n.kit.models})," ",a("mô hình 3D")," · ",s.jsx("b",{children:n.kit.looks})," ",a("look")," · ",mn(n.kit.bytes,u)]}),F(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["↗ ",a("Cài trong {0} trên máy bạn",[n.link.platform])]}),n.kind==="sfx"&&s.jsxs("div",{className:"ps-sounds-meta",children:["♪ ",a("{0} âm thanh",[n.soundCount??0])," · ",hn(n.totalDuration)]}),n.kind==="sfxlib"&&s.jsxs("div",{className:"ps-sounds-meta",children:["📚 ",a("{0} âm thanh",[(n.soundCount??0).toLocaleString(u==="en"?"en-US":"vi-VN")])," · ",un(n.totalDuration,u)]}),n.kind==="sfxlib"&&!n.free&&!B(n.id)&&s.jsx("div",{className:"ps-sounds-meta ps-lib-prices",children:[n.passVnd||n.passUsd?a("{0} / 30 ngày",[q(n)]):"",n.priceVnd||n.priceUsd?a("{0} trọn đời",[R(n)]):""].filter(Boolean).join(" · ")}),U===n.id&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi")]}),T[n.id]&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán…")]}),Z(n.id)&&!B(n.id)&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn đã hoàn tiền")}),s.jsx("div",{className:"ad-actions",children:rn(n)})]})]},n.id))})]}),x&&s.jsx(Gn,{item:x,locale:u,owned:B(x.id),free:x.free,waiting:!!T[x.id],refunded:Z(x.id),action:rn(x,!0),price:cn(x),installed:U===x.id,onClose:()=>w(null)},`${x.id}:${B(x.id)}`)]})}),document.body)}function Gn({item:e,locale:l,owned:r,free:o,waiting:j,refunded:c,action:p,price:u,installed:b,onClose:C}){const g=d.useRef(null),[k,M]=d.useState(!1),[A,S]=d.useState(!1);return d.useEffect(()=>{if(!(o||r)||e.kind==="recipe"||e.kind==="sfx"||e.kind==="pack"||e.kind==="sfxlib"||e.kind==="link")return;let t=!0,h=0,f=null;const D=`store-preview:${e.id}`,K={v:""},x=performance.now();return(async()=>{try{f=await kn(e.id)}catch{t&&S(!0);return}if(!t||!f)return;const w=f.manifest,$=640,P=360;if(w.kind==="motion"){const T=wn(w,f.entry,{}),v=w.duration,U=async()=>{if(t){try{const L=await Kn({layer:D,motion:T,t:(performance.now()-x)/1e3%v,width:$,height:P,duration:v}),y=g.current?.getContext("2d");y&&t&&(y.clearRect(0,0,$,P),y.drawImage(L,0,0),M(!0)),L.close()}catch{}h=requestAnimationFrame(()=>void U())}};U()}else{const T=await yn(f.lottie,w,Cn(w,{}));K.v=URL.createObjectURL(new Blob([JSON.stringify(T)],{type:"application/json"}));const v=f.lottie.meta,U=Math.min($/v.w,P/v.h),L={W:Math.max(2,Math.round(v.w*U/2)*2),H:Math.max(2,Math.round(v.h*U/2)*2)},y=v.op-v.ip,I=document.createElement("canvas");I.width=L.W,I.height=L.H;const G=async()=>{if(t){try{await En(D,K.v,L,Math.floor((performance.now()-x)/1e3*v.fr%y),I);const E=g.current?.getContext("2d");E&&t&&(E.clearRect(0,0,$,P),E.drawImage(I,($-L.W)/2,(P-L.H)/2),M(!0))}catch{}h=requestAnimationFrame(()=>void G())}};G()}})(),()=>{t=!1,cancelAnimationFrame(h),An(D),In(D),K.v&&URL.revokeObjectURL(K.v)}},[e.id,e.kind,o,r]),s.jsx("div",{className:"ad-preview-modal",onMouseDown:t=>{t.target===t.currentTarget&&C()},children:s.jsxs("div",{className:"ad-preview-box ps-detail",role:"dialog","aria-label":e.name[l],children:[s.jsxs("header",{children:[s.jsx("b",{children:e.name[l]}),s.jsx("button",{className:"ad-iconbtn","aria-label":a("Đóng"),onClick:C,children:"✕"})]}),e.kind==="sfxlib"?s.jsx(Wn,{item:e,locale:l}):e.kind==="sfx"?s.jsx(zn,{item:e,locale:l,owned:r,free:o}):s.jsxs("div",{className:"ps-stage",children:[s.jsx("canvas",{ref:g,width:640,height:360,style:{display:k?"block":"none"}}),!k&&(e.previewUrl&&/\.(mp4|webm)(\?|$)/.test(e.previewUrl)?s.jsx("video",{src:e.previewUrl,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):e.previewUrl||e.thumbnailUrl?s.jsx("img",{src:e.previewUrl||e.thumbnailUrl,alt:""}):s.jsx("span",{className:"ad-ph",children:"⧉"})),s.jsx("span",{className:"ps-stage-note",children:k?a("Xem thử trực tiếp trong sandbox"):o||r?A?a("Không tải được bản xem thử"):e.kind==="recipe"?a("Công thức chạy trên clip bạn chọn"):e.kind==="pack"?a("Gói {0} mục — cài rồi dùng từng mục trong tab Plug-in",[e.itemCount??0]):F(e)?a("Cài trong {0} trên máy bạn — không cài vào Timeline",[e.link.platform]):a("Đang tải bản xem thử…"):a("Mua để xem thử trực tiếp và dùng")})]}),e.kind==="pack"&&s.jsx(qn,{item:e,locale:l}),s.jsxs("div",{className:"ps-info",children:[e.featured&&s.jsxs("p",{className:"ps-featured-line",children:["★ ",a("Đối tác tiên phong của Clipoox")]}),e.private&&s.jsxs("p",{className:"ps-private-line",children:["🔒 ",a("Gói riêng: chỉ các tài khoản được Clipoox chọn mới thấy và cài được.")]}),s.jsxs("div",{className:"ps-row",children:[u,s.jsxs("span",{className:"ps-kind",children:[F(e)?e.link.platform:gn(J(e),l)," · v",e.version," · ",e.author.name,e.kit?` · ${mn(e.kit.bytes,l)}`:"",V(e)?` · ${a("GLB ≤ 20 MB, ≤ 300 000 tam giác")}`:""]})]}),s.jsx("p",{children:e.description[l]}),F(e)&&e.link.commands.length>0&&s.jsx(Hn,{commands:e.link.commands}),e.params.length>0&&s.jsxs("p",{className:"ps-params",children:[s.jsxs("b",{children:[a("Tham số chỉnh được"),":"]})," ",e.params.map(t=>t.label[l]).join(" · ")]}),j&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán… Hoàn tất trên trang clipoox.com vừa mở, rồi quay lại đây.")]}),c&&!r&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn mua này đã được hoàn tiền nên không cài mới được. Các clip đã dùng vẫn giữ nguyên.")}),b&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi — mở tab Plug-in để dùng.")]}),s.jsx("div",{className:"ad-actions",children:p}),V(e)&&!o&&!r&&s.jsxs("div",{className:"ps-lock",children:["🔒 ",a("Mô hình và texture chỉ tải về máy sau khi mua. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")]}),V(e)&&(o||r)&&s.jsx("small",{className:"muted",children:a("Tài nguyên 3D chỉ chép vào dự án khi bạn dùng một mục. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")}),!o&&!r&&e.kind!=="sfxlib"&&s.jsx("small",{className:"muted",children:a("Thanh toán một lần trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit.")})]})]})})}function Hn({commands:e}){const[l,r]=d.useState(!1),o=()=>{navigator.clipboard?.writeText(e.join(`
2
- `)).then(()=>{r(!0),window.setTimeout(()=>r(!1),2e3)},()=>{})};return s.jsxs("div",{className:"ps-cmds",children:[s.jsxs("div",{className:"ps-cmds-head",children:[s.jsx("b",{children:a("Lệnh cài")}),s.jsx("span",{className:"muted",children:a("chạy trong terminal trên máy bạn")}),s.jsx("button",{className:"ad-chip",onClick:o,children:l?`✓ ${a("Đã chép")}`:a("Chép lệnh")})]}),s.jsx("pre",{children:e.join(`
3
- `)})]})}function qn({item:e,locale:l}){const[r,o]=d.useState(null);if(d.useEffect(()=>{let c=!0;return Tn(e.id).then(p=>{c&&o(p.items)},()=>{c&&o([])}),()=>{c=!1}},[e.id]),!r?.length)return null;const j=c=>c.kind==="model"?a("Mô hình"):c.kind==="lut"?"Look":c.kind==="motion"&&c.engine==="3d"?"3D":c.kind==="recipe"?a("Combo"):c.kind==="lottie"?"Lottie":"2D";return s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"ps-items-head",children:[s.jsx("b",{children:a("{0} mục trong gói",[r.length])})," · ",s.jsx("span",{className:"muted",children:a("ảnh chụp từ lần chạy thử")})]}),s.jsx("div",{className:"ps-items",children:r.slice(0,24).map(c=>s.jsxs("figure",{children:[c.thumbnail?s.jsx("img",{src:`data:${c.thumbnail.type};base64,${c.thumbnail.data}`,alt:""}):s.jsx("span",{className:"ph",children:c.kind==="model"?"◈":"✦"}),s.jsxs("figcaption",{title:c.name[l],children:[j(c)," · ",c.name[l]]})]},c.id))})]})}function zn({item:e,locale:l,owned:r,free:o}){const[j,c]=d.useState(null),[p,u]=d.useState(!1),[b,C]=d.useState(!1),[g,k]=d.useState(null),M=d.useRef(null),A=d.useRef(0);d.useEffect(()=>{let t=!0;return $n(e.id).then(h=>{t&&(c(h.sounds),u(h.full))},()=>{t&&C(!0)}),()=>{t=!1,M.current?.pause(),window.clearTimeout(A.current)}},[e.id,r,o]);const S=t=>{if(M.current?.pause(),window.clearTimeout(A.current),g===t.id||!t.url){k(null);return}const h=new Audio(t.url);M.current=h,h.volume=.8,k(t.id),h.onended=()=>k(f=>f===t.id?null:f),t.preview&&(A.current=window.setTimeout(()=>{h.pause(),k(f=>f===t.id?null:f)},H.previewSeconds*1e3+300)),h.play().catch(()=>k(null))};return s.jsxs("div",{className:"ps-sounds","data-full":p?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Q,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["♪ ",a("{0} âm thanh",[e.soundCount??j?.length??0])," · ",hn(e.totalDuration)]}),s.jsx("small",{className:"muted",children:p?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.",[H.previewCount,H.previewSeconds])})]})]}),b&&s.jsx("p",{className:"ad-alert",role:"alert",children:a("Không tải được bản xem thử")}),j===null&&!b&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),j&&s.jsx("ul",{className:"ps-sound-list","aria-label":a("Âm thanh trong gói"),children:j.map(t=>{const h=t.name?.[l]||t.name?.vi||t.id;return s.jsxs("li",{className:`${g===t.id?"on":""}${t.url?"":" locked"}`,"data-store-sound":t.id,children:[s.jsx("button",{className:"tl-sfx-play",disabled:!t.url,"aria-label":t.url?`${a("Nghe thử")} ${h}`:a("Mua để nghe {0}",[h]),title:t.url?a("Nghe thử"):a("Mua để nghe"),onClick:()=>S(t),children:t.url?g===t.id?"■":"▶":"🔒"}),s.jsxs("span",{className:"ps-sound-name",children:[s.jsxs("span",{className:"ell",children:[h,t.loop?" ↻":""]}),s.jsxs("small",{className:"muted ell",children:[Pn(t.category,l),t.tags.length?` · ${t.tags.slice(0,3).join(", ")}`:""]})]}),s.jsxs("small",{className:"muted",children:[t.preview&&(t.previewSeconds??0)<t.duration-.05?`▶ ${(t.previewSeconds??0).toFixed(1)}s / `:"",t.duration.toFixed(1),"s"]})]},t.id)})})]})}function Wn({item:e,locale:l}){const r=d.useCallback(p=>Dn(e.id,p),[e.id]),[o,j]=d.useState(null),c=d.useCallback(async p=>{const u=await r(p);return j(u.access.full),u},[r]);return s.jsxs("div",{className:"ps-sounds","data-full":o?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Q,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["📚 ",a("{0} âm thanh",[(e.soundCount??0).toLocaleString(l==="en"?"en-US":"vi-VN")])," · ",un(e.totalDuration,l)]}),s.jsxs("div",{className:"ps-stats",children:[(e.folders?.length??0)>0&&s.jsxs("span",{children:[s.jsx("b",{children:e.folders.length})," ",a("thư mục")]}),s.jsxs("span",{children:[s.jsx("b",{children:"48 kHz"})," stereo"]}),s.jsxs("span",{children:["v",e.version]})]}),s.jsx("small",{className:"muted",children:o?a("Nghe đầy đủ — thêm âm từ mục SFX của Timeline."):a("Nghe thử mọi âm ({0} giây, chất lượng thấp). Mua để nghe đủ và dùng.",[H.previewSeconds])})]})]}),s.jsx(Un,{libId:e.id,fetchPage:c,variant:"store"})]})}function _n({item:e,owned:l,busy:r,installed:o,onInstall:j,onBuy:c}){const p=on(),u=(e.passVnd??0)>0||(e.passUsd??0)>0,b=e.priceVnd>0||e.priceUsd>0,C=s.jsx("button",{className:"ad-use ps-big",disabled:r,onClick:j,children:r?a("Đang cài…"):o?a("Cài lại"):a("Cài plug-in")});return l?.owned&&!l.expiresAt?C:l?.owned?s.jsxs("div",{className:"ps-lib-buy-wrap",children:[C,u&&s.jsx("button",{className:"ad-use ps-big ps-alt",onClick:()=>c("pass"),children:a("Gia hạn thêm 30 ngày · {0}",[q(e)])}),s.jsx("small",{className:"muted",children:a("Vé đến {0}. Gia hạn cộng nối từ ngày đó, không tự trừ tiền.",[X(l.expiresAt,p)])})]}):s.jsxs("div",{className:"ps-lib-buy-wrap",children:[l?.expiresAt&&s.jsx("div",{className:"ps-waiting",children:a("Vé 30 ngày đã hết hạn ngày {0}. Âm đã dùng trong dự án vẫn giữ nguyên.",[X(l.expiresAt,p)])}),s.jsxs("div",{className:"ps-lib-buy",children:[u&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("pass"),children:[a("Vé 30 ngày · {0}",[q(e)]),s.jsx("small",{children:a("Trả lại để gia hạn, không tự trừ tiền")})]}),b&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("lifetime"),children:[a("Mua trọn đời · {0}",[R(e)]),s.jsx("small",{children:a("Một lần, gồm các đợt âm mới")})]})]}),s.jsx("small",{className:"muted",children: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.")})]})}export{vs as default};
@@ -1,2 +0,0 @@
1
- import{j as f}from"./remote-DXG553d8.js";import{r as l}from"./api-C5pOWyBM.js";import{p as E}from"./main-BNZrzSIG.js";import{o as b}from"./rigTrack-CW9_kg5j.js";import{l as g,d as h}from"./titleArt-CAOxtyHl.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./spark.module-CMSPLU2n.js";import"./userFonts-txN4I-eo.js";import"./lottieLayer-BhLbZOpr.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.js";const j=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],x=e=>({text:e.sample,fontSize:e.defaults.fontSize,color:e.defaults.color,accentColor:e.defaults.accentColor,placement:"center",align:e.defaults.align,fontFamily:e.defaults.fontFamily,styleId:"classic",design:e.design,animation:e.animation}),L=e=>e.split(`
2
- `).map(a=>({word:Math.max(1,a.split(/\s+/).filter(Boolean).length),char:Math.max(1,a.replace(/\s/g,"").length)})),F=e=>{if(!e.animation)return 2;const a=b(e.animation,L(e.sample));return a+1.2+a/e.animation.outSpeed};function N(){const e=l.useRef(null),[a,y]=l.useState(null),[u,d]=l.useState("");return l.useEffect(()=>{const i=(t,r)=>t.source?.postMessage(r,{targetOrigin:t.origin}),p=async t=>{if(!j.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;let r;try{r=E(t.data.template)}catch(o){i(t,{type:"clipoox-template-error",id:"id"in t.data?t.data.id:null,error:o.message});return}if(t.data.type==="clipoox-template-play"){d(""),y(r);return}if(t.data.type==="clipoox-template-thumb"){const o=t.data.id,n=x(r),c=Object.assign(document.createElement("canvas"),{width:1280,height:720}),m=c.getContext("2d");if(!m)return;try{await g(n),h(m,n)}catch(w){i(t,{type:"clipoox-template-error",id:o,error:w.message});return}i(t,{type:"clipoox-template-thumb",id:o,png:c.toDataURL("image/png")})}},s=t=>void p(t);return window.addEventListener("message",s),window.parent?.postMessage({type:"clipoox-template-ready"},"*"),()=>window.removeEventListener("message",s)},[]),l.useEffect(()=>{if(!a)return;let i=0,p=!0;const s=x(a),t=F(a),r=performance.now();return g(s).then(()=>{const o=()=>{const n=e.current?.getContext("2d");if(!p||!n)return;const c=(performance.now()-r)/1e3%t;n.clearRect(0,0,1280,720);try{h(n,s,{time:c,duration:t})}catch(m){d(m.message);return}i=requestAnimationFrame(o)};o()},o=>d(o.message)),()=>{p=!1,cancelAnimationFrame(i)}},[a]),f.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:[f.jsx("canvas",{ref:e,width:1280,height:720,style:{width:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Template preview"}),u&&f.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:u})]})}export{N as default,F as loopLength,x as titleOf};
@@ -1 +0,0 @@
1
- .tl-plugins{display:flex;flex-direction:column;gap:10px;padding:2px 0 10px;min-width:0}.tl-plugins h4{margin:0;font-size:13px;color:#e6e8ec}.tl-plugins h5{margin:0 0 4px;font-size:12px;color:#e6e8ec;display:flex;gap:6px;align-items:baseline}.tl-plugins p{margin:0;font-size:11.5px;line-height:1.5;color:#aab3ac}.tl-plugins small{line-height:1.45}.tl-plugins-head{display:flex;flex-direction:column;gap:8px}.tl-plugins-head>div:first-child{display:flex;flex-direction:column;gap:2px}.tl-plugins-actions{display:flex;gap:6px;flex-wrap:wrap}.tl-plugins-empty{display:flex;flex-direction:column;align-items:center;gap:8px;padding:18px 12px;border:1px dashed #38423a;border-radius:12px;text-align:center;background:#0f130f}.tl-plugins-empty>b{font-size:28px;color:#c6f432;line-height:1}.tl-plugins-empty strong{font-size:13px;color:#e6e8ec}.tl-plugins-samples{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;align-items:center}.tl-plugins-samples a{text-decoration:none}.tl-plugin-grid{display:flex;flex-direction:column;gap:6px}.tl-plugin-tile{position:relative;border:1px solid #283129;border-radius:10px;background:#0f130f;min-width:0}.tl-plugin-tile:hover{border-color:#c6f43299}.tl-plugin-tile.off{opacity:.55}.tl-plugin-use{display:grid;grid-template-columns:96px minmax(0,1fr);gap:10px;align-items:center;width:100%;padding:6px 30px 6px 6px;border:0;background:none;color:#c8cec9;text-align:left;cursor:pointer;min-width:0;border-radius:10px}.tl-plugin-use:disabled{cursor:default}.tl-plugin-use:focus-visible{outline:2px solid #c6f432;outline-offset:-2px}.tl-plugin-thumb{position:relative;display:grid;place-items:center;aspect-ratio:16/9;border-radius:6px;overflow:hidden;background:#15181d}.tl-plugin-thumb img{width:100%;height:100%;object-fit:cover}.tl-plugin-thumb b{font-size:20px;color:#c6f432}.tl-plugin-thumb .spin{position:absolute;right:4px;bottom:4px}.tl-plugin-name{display:flex;flex-direction:column;gap:3px;min-width:0}.tl-plugin-name strong{font-size:12px;line-height:1.45;color:#e6e8ec;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.tl-plugin-name small{font-size:10.5px;color:#8f9a91}.tl-plugin-more{position:absolute;right:4px;top:6px;width:22px;height:22px;border:0;border-radius:6px;background:none;color:#8f9a91;cursor:pointer;font-size:14px;line-height:1}.tl-plugin-more:hover,.tl-plugin-more[aria-expanded=true]{background:#1c231c;color:#e6e8ec}.tl-plugin-menu{position:absolute;z-index:5;left:0;right:0;top:100%;margin-top:4px;display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid #38423a;border-radius:10px;background:#11161a;box-shadow:0 10px 24px #00000080}.tl-plugin-menu button{border:1px solid #2b3330;border-radius:7px;background:#161b1f;color:#e6e8ec;font-size:11.5px;padding:5px 8px;text-align:left;cursor:pointer}.tl-plugin-menu button:hover{border-color:#c6f43299}.tl-plugin-menu button.danger{color:#ff8f8f}.tl-plugin-review,.tl-plugin-recipe,.tl-plugin-inspector{display:flex;flex-direction:column;gap:8px;padding:10px;border:1px solid #c6f43255;border-radius:12px;background:#11160f}.tl-plugin-review.bad{border-color:#ff6b6b66;background:#1a1112}.tl-plugin-card{display:flex;flex-direction:column;gap:8px;min-width:0}.tl-plugin-card img{width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:8px;background:#15181d}.tl-plugin-card>div{display:flex;flex-direction:column;gap:3px;min-width:0}.tl-plugin-card strong{font-size:13px;color:#e6e8ec;line-height:1.45}.tl-plugin-card small{font-size:10.5px;color:#8f9a91}.tl-plugin-checks{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.tl-plugin-checks li{display:flex;gap:6px;font-size:11.5px;line-height:1.45;color:#c8cec9}.tl-plugin-checks li>span{flex:none;width:14px;text-align:center;font-weight:700}.tl-plugin-checks li.ok>span{color:#c6f432}.tl-plugin-checks li.warn>span{color:#ffc24b}.tl-plugin-checks li.bad{color:#ffb3b3}.tl-plugin-checks li.bad>span{color:#ff6b6b}.tl-plugin-checks small{color:#8f9a91}.tl-plugin-error{display:flex;flex-direction:column;gap:3px;margin:0;font-size:12px;line-height:1.5;color:#ffb3b3}.tl-plugin-error small{font:10.5px/1.4 ui-monospace,Menlo,monospace;color:#c99;word-break:break-word}.tl-plugin-note{font-size:12px;color:#ffd27a!important}.tl-plugin-step{display:flex;gap:8px;align-items:center;font-size:12px;color:#aab3ac;margin:0}.tl-plugin-review-actions{display:flex;gap:6px;flex-wrap:wrap}.tl-plugin-update{align-self:flex-start}.tl-plugin-params{display:flex;flex-direction:column;gap:7px}.tl-plugin-params .tl-motion-param{display:grid;grid-template-columns:minmax(0,42%) minmax(0,1fr);align-items:center;gap:8px;font-size:11.5px;color:#aab3ac;line-height:1.4}.tl-plugin-params .tl-motion-param.check{display:flex}.tl-plugin-params input[type=text],.tl-plugin-params textarea,.tl-plugin-params select,.tl-plugin-params input:not([type]){width:100%;min-width:0;box-sizing:border-box}.tl-plugin-image>span{display:flex;align-items:center;gap:6px;min-width:0}.tl-plugin-image img,.tl-plugin-image i{width:30px;height:30px;border-radius:6px;object-fit:cover;flex:none;background:#15181d;border:1px dashed #38423a}.tl-plugin-image button{font-size:11px}.tl-plugin-off summary{cursor:pointer;font-size:11.5px;color:#8f9a91;margin-bottom:6px}.tl-plugins-foot{font-size:10.5px;color:#8f9a91}.tl-warn{color:#ffc24b;font-size:11px}.tl-guide-backdrop{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;background:#050709b8;padding:16px}.tl-guide{display:flex;flex-direction:column;width:min(860px,100%);max-height:min(88vh,1000px);border:1px solid #2b3330;border-radius:14px;background:#0f1215;box-shadow:0 24px 60px #0009;overflow:hidden}.tl-guide-head{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:10px 12px;border-bottom:1px solid #222a26}.tl-guide-head strong{flex:1 1 auto;font-size:13px;color:#e6e8ec}.tl-guide-head a{text-decoration:none}.tl-guide-body{overflow:auto;padding:6px 22px 22px;color:#c8cec9;font-size:13px;line-height:1.65}.tl-guide-body h2{font-size:20px;color:#e6e8ec;margin:16px 0 6px;line-height:1.4}.tl-guide-body h3{font-size:16px;color:#c6f432;margin:20px 0 6px;line-height:1.45}.tl-guide-body h4,.tl-guide-body h5{font-size:13.5px;color:#e6e8ec;margin:14px 0 4px;line-height:1.5}.tl-guide-body p{margin:6px 0}.tl-guide-body ul,.tl-guide-body ol{margin:4px 0;padding-left:22px}.tl-guide-body li{margin:2px 0}.tl-guide-body code{font:12px/1.5 ui-monospace,Menlo,monospace;background:#1a1f1c;border-radius:4px;padding:1px 4px;color:#e6e8ec}.tl-guide-body pre{background:#0a0d0b;border:1px solid #222a26;border-radius:8px;padding:10px 12px;overflow:auto}.tl-guide-body pre code{background:none;padding:0;font-size:11.5px}.tl-guide-body blockquote{margin:8px 0;padding:6px 12px;border-left:3px solid #c6f432;background:#121811;color:#c8cec9}.tl-guide-body a{color:#c6f432}.tl-guide-table{overflow:auto}.tl-guide-body table{border-collapse:collapse;margin:8px 0;font-size:12px}.tl-guide-body th,.tl-guide-body td{border:1px solid #2b3330;padding:5px 8px;text-align:left;vertical-align:top}.tl-guide-body th{background:#151a17;color:#e6e8ec}.ps-drawer .ad-grid{grid-template-columns:repeat(auto-fill,minmax(200px,1fr))}.ps-open{display:block;width:calc(100% - 16px);padding:0;border:0;cursor:pointer;background:#15181d}.ps-price{position:absolute;right:8px;top:8px;z-index:2;padding:4px 8px;border-radius:7px;background:#070907db;border:1px solid var(--border-strong);font-size:11px;font-weight:800;color:#f2f4f0;line-height:1.3}.ps-price.free{color:#0b1106;background:var(--accent);border-color:var(--accent)}.ps-price.owned{color:var(--accent)}.ps-sub{text-transform:none}.ps-n{margin-left:6px;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--accent);color:#0b1106;font-size:10.5px;font-weight:800;display:inline-grid;place-items:center}.ps-waiting{display:flex;gap:7px;align-items:center;margin-top:8px;font-size:11.5px;line-height:1.45;color:#ffd27a}.ps-waiting.bad{color:#ff9b9b}.ps-drawer .ad-use.ps-wait,.ps-drawer .ad-use.ps-wait:hover:not(:disabled){background:#1d2416;color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent);opacity:1}.ad-use.ps-big{flex:0 1 auto;padding:0 22px;height:40px}.ps-detail{width:min(760px,100%);max-height:calc(100% - 20px);overflow:auto}.ps-stage{position:relative;aspect-ratio:16/9;border-radius:10px;overflow:hidden;background:repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/16px 16px;margin-bottom:12px}.ps-stage canvas,.ps-stage img,.ps-stage video{width:100%;height:100%;object-fit:contain;display:block}.ps-stage-note{position:absolute;left:10px;bottom:10px;padding:4px 8px;border-radius:7px;background:#070907d1;color:#c8cec9;font-size:11px}.ps-info{display:flex;flex-direction:column;gap:8px}.ps-info p{margin:0;font-size:13px;line-height:1.55;color:#c8cec9}.ps-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.ps-row .ps-price{position:static}.ps-kind{font-size:12px;color:var(--text-muted)}.ps-params{font-size:12px!important;color:#aab3ac!important}.tl-plugins .spin,.ps-drawer .spin,.tl-guide .spin{display:inline-block;flex:none;width:10px;height:10px;border:2px solid #c6f43244;border-top-color:#c6f432;border-radius:50%;animation:plg-spin .8s linear infinite;vertical-align:-1px}.ps-waiting .spin{border-color:#ffd27a44;border-top-color:#ffd27a}@keyframes plg-spin{to{transform:rotate(360deg)}}.ps-drawer .ad-name{font-size:15px;line-height:1.45}.ps-drawer .ps-sub{font-size:12.5px;margin-top:4px}.ps-drawer .ad-notice{font-size:13px;line-height:1.5}.ps-drawer .ad-tab,.ps-drawer .ad-chip{font-size:13.5px}.ps-drawer .ad-search{font-size:14px}.ps-drawer .ad-use{font-size:14px;height:38px}.ps-drawer .ad-badge{font-size:10.5px}.ps-drawer .ps-price{font-size:13px;padding:5px 9px}.ps-drawer .ps-waiting{font-size:13px}.ps-drawer .ad-empty{font-size:14px}.ps-detail header b{font-size:17px}.ps-info p{font-size:14.5px!important;line-height:1.6!important}.ps-info .ps-params{font-size:13.5px!important}.ps-info .ps-kind{font-size:13.5px}.ps-info small{font-size:12.5px;line-height:1.5}.ps-stage-note{font-size:12.5px}.ps-drawer .ps-sub{align-items:center;gap:8px}.ps-drawer .ps-sub .ps-price{position:static;flex:none}.ps-drawer .ps-by{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tl-sfx-item.tl-sfx-plug{grid-template-columns:26px minmax(0,1fr) auto 26px}.tl-sfx-plug .tl-sfx-name small{font-size:10px;color:#8f9a91;line-height:1.35}.tl-sfx-loop{font-style:normal;color:#c6f432}.tl-sfx-plugins h5{color:#e6e8ec}.tl-plugin-use.on{outline:1px solid #c6f432;outline-offset:-1px}.tl-plugin-pack{margin-top:10px;padding:8px;border:1px solid var(--border,#2a2f36);border-radius:8px;background:#ffffff05}.tl-plugin-pack h5{margin:0 0 6px;font-size:12.5px;line-height:1.5;display:flex;flex-wrap:wrap;gap:6px;align-items:baseline;color:#e6e8ec}.tl-plugin-pack h5 small{font-weight:400;font-size:10.5px}.tl-plugin-pack .tl-sfx-list,.tl-plugin-sfx-list{list-style:none;margin:0;padding:0;display:grid;gap:2px;max-height:260px;overflow:auto}.tl-plugin-sfx-review{display:flex;flex-direction:column;gap:10px}.tl-plugin-sfx-list .tl-sfx-item{grid-template-columns:26px minmax(0,1fr) auto}.tl-plugin-wave,.ps-wave{display:flex;align-items:center;justify-content:center;gap:3px;width:100%;aspect-ratio:16/9;border-radius:8px;background:#15181d;padding:0 10%;box-sizing:border-box}.tl-plugin-wave i,.ps-wave i{display:block;flex:1 1 0;max-width:6px;border-radius:3px;background:#c6f432;opacity:.9}.ps-sounds-meta{margin-top:4px;font-size:12px;color:#c6f432;font-weight:600}.ps-sounds{display:flex;flex-direction:column;gap:10px;margin-bottom:12px}.ps-sounds-head{display:grid;grid-template-columns:160px minmax(0,1fr);gap:12px;align-items:center}.ps-sounds-head img,.ps-sounds-head .ps-wave{width:160px;aspect-ratio:16/9;object-fit:cover;border-radius:8px}.ps-sounds-head b{display:block;font-size:14px;color:#e6e8ec;margin-bottom:4px}.ps-sounds-head small{font-size:12.5px;line-height:1.5}.ps-sound-list{list-style:none;margin:0;display:grid;gap:2px;max-height:300px;overflow:auto;border:1px solid var(--border,#2a2f36);border-radius:8px;padding:4px}.ps-sound-list li{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:8px;align-items:center;padding:4px 6px;border-radius:6px;font-size:13px;line-height:1.5}.ps-sound-list li.on,.ps-sound-list li:hover{background:#ffffff0f}.ps-sound-list li.locked{opacity:.55}.ps-sound-list .ps-sound-name{display:grid;min-width:0}.ps-sound-list .ps-sound-name small{font-size:11px}.ps-sound-list .tl-sfx-play{width:26px;height:26px;border-radius:50%;border:1px solid var(--border,#2a2f36);background:transparent;color:#e6e8ec;font-size:10px;cursor:pointer}.ps-sound-list .tl-sfx-play:disabled{cursor:not-allowed}@media(max-width:560px){.ps-sounds-head{grid-template-columns:1fr}.ps-sounds-head img,.ps-sounds-head .ps-wave{width:100%}}.timeline-workspace .tl-sfx .tl-sfx-plugins .tl-sfx-list{max-height:220px}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins{flex:none}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins .tl-sfx-list{flex:none;max-height:176px;min-height:0}.timeline-workspace .tl-plugin-sfx-review .tl-sfx-list{max-height:240px}.tl-plugin-items{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:6px}.tl-plugin-item{display:flex;flex-direction:column;gap:4px;padding:6px;border:1px solid #283129;border-radius:8px;background:#0f130f;color:inherit;text-align:left;cursor:pointer;min-width:0}.tl-plugin-item:hover:not(:disabled){border-color:#c6f43299}.tl-plugin-item:disabled{opacity:.6;cursor:default}.tl-plugin-item .tl-plugin-thumb{width:100%;aspect-ratio:16/9;height:auto}.tl-plugin-item .tl-plugin-name strong{font-size:12px}.ps-open{position:relative}.ps-featured{position:absolute;left:8px;bottom:8px;padding:2px 8px;border-radius:999px;background:#c6f432;color:#0b0d0f;font-size:10.5px;font-weight:700;letter-spacing:.02em}.ps-featured-line{margin:0 0 6px;color:#c6f432;font-weight:600;font-size:12.5px}.ps-private{position:absolute;right:8px;top:8px;padding:2px 8px;border-radius:999px;background:#0b0d0fd1;color:#f4f5f7;border:1px solid rgba(255,255,255,.18);font-size:10.5px;font-weight:700}.ps-private-line{margin:0 0 6px;color:#f4f5f7;opacity:.85;font-weight:600;font-size:12.5px}.sfxlib{display:flex;flex-direction:column;gap:6px;min-height:0}.sfxlib-tools{display:flex;gap:8px;align-items:center}.sfxlib-tools .ad-search{flex:1;min-width:0}.sfxlib-tools .sfxlib-folder{flex:none;width:190px}.sfxlib-chip span{opacity:.6}.sfxlib-chip.on{background:var(--accent-soft);color:var(--accent);border-color:#b4e36a73}select.sfxlib-chip{appearance:none;padding-right:9px}.sfxlib-count{margin:0;font-size:11.5px;color:var(--text-muted)}.sfxlib-more{width:100%;margin-top:4px;min-height:30px;border-radius:8px;border:1px dashed var(--border-strong);background:transparent;color:var(--text-muted);cursor:pointer;font-size:12px}.sfxlib-more:hover:not(:disabled){color:var(--text);border-color:#b4e36a73}.sfxlib-list.locked .tl-sfx-name,.sfxlib-list.locked small{opacity:.5}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins .tl-sfx-list.sfxlib-list{max-height:none;flex:none}.sfxlib-store .ps-sound-list{max-height:340px;overflow:auto}.ps-stats{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12.5px;color:var(--text-muted);margin-bottom:4px}.ps-sounds-head .ps-stats b{display:inline;font-size:12.5px;margin:0;color:#e6e8ec}.ps-lib-prices{color:#8f9a91!important;font-weight:500!important}.ps-lib-buy-wrap{display:flex;flex-direction:column;gap:8px}.ps-lib-buy{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:8px}.ps-drawer .ps-lib-buy .ad-use{height:auto;padding:9px 12px;line-height:1.3}.ps-lib-buy .ad-use small{display:block;font-size:11.5px;font-weight:500;opacity:.75}.ps-drawer .ad-use.ps-alt{background:transparent;color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}.tl-sfx-plugins select.sfxlib-source{appearance:none;-webkit-appearance:none;width:100%;margin:0 0 8px;padding:7px 30px 7px 10px;border-radius:9px;border:1px solid var(--border-strong);color:var(--text);font-size:12px;font-weight:600;cursor:pointer;background:var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A8F98' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center}.tl-sfx-plugins select.sfxlib-source:hover{border-color:#b4e36a73}.tl-sfx-plugins select.sfxlib-source:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.sfxlib-head{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;background:linear-gradient(135deg,#b4e36a1a,#b4e36a05 60%);border:1px solid rgba(180,227,106,.18)}.sfxlib-icon{flex:none;width:34px;height:34px;border-radius:9px;background:#11160d;border:1px solid rgba(180,227,106,.3);display:flex;align-items:center;justify-content:center;gap:2px}.sfxlib-icon i{display:block;width:2px;border-radius:1px;background:var(--accent)}.sfxlib-title{display:grid;min-width:0;flex:1;line-height:1.3}.sfxlib-title strong{font-size:12.5px;color:var(--text)}.sfxlib-title small{font-size:10.5px;color:var(--text-muted)}.sfxlib-badge{flex:none;font-size:10px;font-weight:700;padding:3px 7px;border-radius:999px;background:var(--accent-soft);color:var(--accent);white-space:nowrap}.sfxlib-badge.off{background:#e8b0631f;color:#f0c27e}.sfxlib-pass{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;background:#e8b06312;border:1px solid rgba(232,176,99,.28)}.sfxlib-pass-ic{flex:none;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;background:#e8b06329;font-size:13px}.sfxlib-pass-text{display:grid;gap:2px;min-width:0;flex:1}.sfxlib-pass-text b{font-size:11.5px;color:#f3d3a3;font-weight:700}.sfxlib-pass-text small{font-size:10.5px;line-height:1.4;color:#c9ad87}.sfxlib-renew{flex:none;border:0;border-radius:999px;padding:6px 12px;background:var(--accent);color:#0b1106;font-weight:700;font-size:11.5px;cursor:pointer}.sfxlib-renew:hover{filter:brightness(1.08)}.sfxlib-chips{display:flex;flex-wrap:nowrap;gap:5px;overflow-x:auto;scrollbar-width:none;padding-bottom:1px;mask-image:linear-gradient(90deg,#000 88%,transparent)}.sfxlib-chips::-webkit-scrollbar{display:none}.sfxlib-chip{flex:none;border:1px solid var(--border);background:var(--surface-2);color:var(--text-muted);border-radius:999px;padding:3px 10px;font-size:11px;cursor:pointer;white-space:nowrap}.sfxlib-chip:hover{color:var(--text);border-color:var(--border-strong)}.sfxlib-panel .sfxlib-count{padding:0 2px}.sfxlib-panel .sfxlib-more{border-style:solid;border-color:var(--border);background:var(--surface-2);border-radius:999px}.sfxlib-hint{display:block;margin:0 0 6px;font-size:11px}.tl-plugin-items.kit{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:7px}.tl-plugin-items.kit .tl-plugin-name strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}.tl-kit-badge{position:absolute;left:4px;top:4px;padding:1px 5px;border-radius:4px;background:#070907d1;font-size:9px;font-weight:800;letter-spacing:.04em;color:#c6f432;line-height:1.5}.tl-kit-badge.model{color:#7fe3ff}.tl-kit-badge.lut{color:#ffc24b}.tl-kit-controls{display:flex;flex-direction:column;gap:7px;padding:9px;margin:4px 0 8px;border:1px solid #2b3a2c;border-radius:10px;background:#0d120d}.tl-kit-controls h6{margin:0;font-size:11.5px;color:#e6e8ec;display:flex;justify-content:space-between;gap:8px;align-items:baseline;line-height:1.5}.tl-kit-controls h6 small{font-weight:500}.tl-kit-control{display:flex;flex-direction:column;gap:4px}.tl-kit-swatches{display:flex;gap:5px;flex-wrap:wrap;padding-left:calc(42% + 8px)}.tl-kit-swatches button{width:18px;height:18px;border-radius:5px;border:1px solid #38423a;padding:0;cursor:pointer}.tl-kit-swatches button.on{outline:2px solid #e6e8ec;outline-offset:1px}.tl-kit-controls>.pill-btn{align-self:flex-start}.tl-kit-chips{display:flex;flex-wrap:wrap;gap:5px;margin:0 0 7px}.tl-kit-chip{border:1px solid #38423a;background:transparent;color:#aab3ac;border-radius:999px;padding:2px 9px;font-size:11.5px;line-height:1.5;cursor:pointer}.tl-kit-chip span{opacity:.6}.tl-kit-chip.on{background:#c6f4321f;color:#c6f432;border-color:#c6f43273}.tl-plugin-subhead{margin:2px 0 0;font-size:11.5px;color:#c8cec9;font-weight:700}.tl-plugin-fact{min-width:0;overflow-wrap:anywhere}.tl-plugin-fact b{font-weight:600;color:#e6e8ec}.tl-plugin-linked{display:flex;flex-direction:column;gap:3px}.tl-plugin-link{align-self:flex-end;display:inline-flex;align-items:center;gap:3px;font-size:10px;line-height:1.5;color:#7fe3ff;border:1px solid #2a4a55;border-radius:999px;padding:0 6px;white-space:nowrap}.tl-plugin-asset select{min-width:0;flex:1}.tl-plugin-asset i{display:inline-grid;place-items:center;font-style:normal;color:#7fe3ff}.tl-plugin-assets{display:flex;flex-direction:column;gap:4px;border-top:1px solid #222a26;padding-top:8px}.tl-plugin-assets ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px;font-size:11px;color:#aab3ac}.tl-plugin-assets li{display:flex;justify-content:space-between;gap:6px}.tl-plugin-assets b{color:#c8cec9;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ps-drawer .ad-card{display:flex;flex-direction:column}.ps-drawer .ad-meta{flex:1;display:flex;flex-direction:column}.ps-drawer .ad-actions{margin-top:auto;padding-top:10px}.ps-kit-meta{font-size:12px;color:#c8cec9;line-height:1.5;margin-top:4px;min-height:3em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.ps-kit-meta b{color:#c6f432}.ps-items{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;margin:0 0 12px}.ps-items figure{margin:0;display:flex;flex-direction:column;gap:3px;min-width:0}.ps-items img,.ps-items .ph{width:100%;aspect-ratio:16/9;border-radius:6px;display:block;background:#15181d;object-fit:cover}.ps-items .ph{display:grid;place-items:center;color:#7fe3ff}.ps-items figcaption{font-size:10.5px;color:#aab3ac;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ps-lock{display:flex;gap:6px;align-items:center;font-size:12px;color:#aab3ac;padding:7px 10px;border:1px dashed #38423a;border-radius:8px}@media(max-width:720px){.ps-items{grid-template-columns:repeat(3,minmax(0,1fr))}}.ps-items-head{margin:0 0 6px;font-size:12px;color:#c8cec9}.tl-plugin-doc{display:flex;flex-direction:column;gap:6px}.tl-plugin-doc textarea{width:100%;min-height:180px;max-height:360px;box-sizing:border-box;resize:vertical;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:#dfe6e0;background:#0b0f0a;border:1px solid #2a3328;border-radius:8px;padding:8px}.tl-plugin-hooks{margin-top:10px;padding:8px 10px;border:1px solid #2a3328;border-radius:12px;background:#0f130e;display:flex;flex-direction:column;gap:8px}.tl-plugin-hooks>summary{cursor:pointer;font-size:12px;color:#dfe6e0;display:flex;flex-wrap:wrap;gap:6px;align-items:baseline}.tl-plugin-hooks[open]>summary{margin-bottom:8px}.tl-plugin-hooks>small{display:block;margin-top:6px;line-height:1.45}.tl-plugin-hook-list{list-style:none;margin:0 0 8px;padding:0;display:flex;flex-direction:column;gap:6px}.tl-plugin-hook-list>li{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:space-between;padding:6px 8px;border-radius:8px;background:#141a13}.tl-plugin-hook-url{display:flex;flex-direction:column;min-width:0;flex:1 1 180px}.tl-plugin-hook-url code{font-size:11.5px;color:#c6f432;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tl-plugin-hook-url small{font-size:11px}.tl-plugin-hook-actions{display:flex;gap:4px;flex-wrap:wrap}.tl-plugin-hook-secret{flex-basis:100%;margin:2px 0 0;font-size:11.5px;color:#ffd27a;display:flex;flex-wrap:wrap;gap:6px;align-items:center}.tl-plugin-hook-secret code{word-break:break-all;color:#fff;background:#0b0f0a;padding:2px 6px;border-radius:6px}.tl-plugin-hook-add{display:flex;flex-direction:column;gap:6px}.tl-plugin-hook-add input[type=url]{width:100%;box-sizing:border-box}.tl-plugin-hook-events{display:flex;flex-wrap:wrap;gap:10px;font-size:11.5px;color:#aab3ac}.tl-plugin-hook-events label{display:flex;gap:4px;align-items:center}.ps-cmds{border:1px solid rgba(198,244,50,.25);border-radius:12px;background:#0d100c;padding:10px 12px}.ps-cmds-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;font-size:12px}.ps-cmds-head .muted{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ps-cmds pre{margin:0;font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;color:#e6ffe0;white-space:pre-wrap;word-break:break-all;user-select:all}.ps-drawer .ad-actions{flex-wrap:wrap;align-items:center}.ad-use.ps-use,.ad-use.ps-use:hover:not(:disabled){background:#16210f;color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);opacity:1}.ad-use.ps-use:hover:not(:disabled){background:#1d2c12}.ps-reinstall{background:none;border:0;padding:4px 2px;color:var(--text-dim,#9aa39a);font-size:12.5px;text-decoration:underline;text-underline-offset:3px;cursor:pointer}.ps-reinstall:hover{color:var(--text,#e8ece8)}.ps-installed{margin-top:8px;padding:7px 10px;border-radius:10px;background:#16210f;color:var(--accent);font-size:13px;font-weight:600;animation:ps-pop .35s ease-out}@keyframes ps-pop{0%{transform:scale(.96);opacity:0}to{transform:none;opacity:1}}.tl-plugin-tile.flash{animation:tl-plugin-flash 1.6s ease-out 2}@keyframes tl-plugin-flash{0%{box-shadow:0 0 #c6f432aa}50%{box-shadow:0 0 0 6px #c6f43244}to{box-shadow:0 0 #c6f43200}}
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PluginStore-8TjQawtB.js","assets/remote-DXG553d8.js","assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-Dxq3MZF3.js","assets/rotoMaskStore-DrRawyH9.js","assets/rigTrack-CW9_kg5j.js","assets/main-BNZrzSIG.js","assets/spark.module-CMSPLU2n.js","assets/userFonts-txN4I-eo.js","assets/lottieLayer-BhLbZOpr.js","assets/desktop-BWhFnYwd.js","assets/timeline3d-DqXTKdEK.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-pFxeatJt.js","assets/captionLayout-BAdmqwdS.js","assets/timelineText-DEK2BRyU.js","assets/titleArt-CAOxtyHl.js","assets/rotoMatte-2EcyuvBX.js","assets/distortGL-5uNfls9s.js","assets/main-By_IEoB_.css","assets/pluginAutomation-DdZOnpoV.js"])))=>i.map(i=>d[i]);
2
- import{_ as Ln,au as Pi,f as Ti}from"./titleFrameBudget-BjW--v_T.js";import{j as n,cw as Mn,ao as gn,cN as $i,N as Li}from"./remote-DXG553d8.js";import{u as wn,r as N,t as e,bX as Ei}from"./api-C5pOWyBM.js";import{u as H}from"./store-Dxq3MZF3.js";import{G as Oi}from"./lottieLayer-BhLbZOpr.js";import{b as _,c as mn,s as Ai,e as Bi,S as Gi,f as Ii,l as Qn,g as qi,L as Ki,P as Fi,i as Ui,r as Di,h as yn,j as zi,k as Ri,m as Yn,n as Wi,o as bn,q as Hi,t as Xi,v as ni,w as ii,x as ei,y as ri,z as J,A as ci,B as En,C as On,D as ti,E as Ji,F as Vi,G as Zi,H as oi,I as Qi,J as An,K as Yi,M as di,N as ne,O as ie,Q as ee,R as te}from"./main-BNZrzSIG.js";import{l as se,a as le,t as ae,r as re,b as ce,p as oe,c as de}from"./pluginAutomation-DdZOnpoV.js";function he({review:t}){const l=wn(),o=t.manifest,h=o.sounds??[],[j,u]=N.useState(null),A=N.useRef(null),p=N.useRef(new Map);N.useEffect(()=>()=>{A.current?.pause();for(const k of p.current.values())URL.revokeObjectURL(k)},[]);const c=(k,x)=>{if(A.current?.pause(),j===k){u(null);return}let T=p.current.get(k);if(!T){const b=x.split(".").pop().toLowerCase();T=URL.createObjectURL(new Blob([t.read(x)],{type:Gi[b]})),p.current.set(k,T)}const r=new Audio(T);A.current=r,r.volume=.8,u(k),r.onended=()=>u(b=>b===k?null:b),r.play().catch(()=>u(null))},g=t.facts.reduce((k,x)=>k+x.duration,0);return n.jsxs("div",{className:"tl-plugin-sfx-review",children:[n.jsxs("div",{className:"tl-plugin-card",children:[t.thumbnail?n.jsx("img",{alt:"",src:`data:${t.thumbnail.type};base64,${t.thumbnail.data}`}):n.jsx("span",{className:"tl-plugin-wave","aria-hidden":!0,children:Array.from({length:18},(k,x)=>n.jsx("i",{style:{height:`${20+Math.round(70*Math.abs(Math.sin(x*1.7)))}%`}},x))}),n.jsxs("div",{children:[n.jsx("strong",{children:_(o,l)}),n.jsxs("small",{children:[e("Gói âm thanh")," · v",o.version," · ",o.author.name]}),n.jsx("p",{children:mn(o,l)}),n.jsx("small",{className:"muted",children:e("{0} âm thanh · tổng {1} giây",[h.length,g.toFixed(1)])})]})]}),n.jsxs("ul",{className:"tl-plugin-checks",children:[n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),e("Đọc được {0} file âm thanh ({1})",[h.length,[...new Set(t.facts.map(k=>k.format))].join(", ")])]}),n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),e("Độ dài trong giới hạn (≤ 30 giây, âm nền / lặp ≤ 120 giây)")]}),n.jsxs("li",{className:"warn",children:[n.jsx("span",{"aria-hidden":!0,children:"!"}),e("Khi cài, máy chủ kiểm tra lại từng file và cân bằng âm lượng như thư viện SFX của Clipoox.")]})]}),n.jsx("ul",{className:"tl-sfx-list tl-plugin-sfx-list","aria-label":e("Âm thanh trong gói"),children:h.map((k,x)=>{const T=t.facts[x],r=Ai(k,l);return n.jsxs("li",{className:`tl-sfx-item tl-sfx-plug${j===k.id?" on":""}`,children:[n.jsx("button",{className:"tl-sfx-play","aria-label":`${e("Nghe thử")} ${r}`,title:e("Nghe thử"),onClick:()=>c(k.id,k.file),children:j===k.id?"■":"▶"}),n.jsxs("span",{className:"tl-sfx-name",children:[n.jsxs("span",{className:"ell",title:k.tags.join(", "),children:[r,k.loop?n.jsx("i",{className:"tl-sfx-loop",title:e("Lặp được"),children:" ↻"}):null]}),n.jsxs("small",{className:"ell",children:[Bi(k.category,l)," · ",T?.format]})]}),n.jsxs("small",{children:[T?T.duration.toFixed(1):"–","s"]})]},k.id)})})]})}const Pn={bad_package:"File này không phải gói plug-in hợp lệ.",not_zip:"File này không phải gói .clipoox-plugin (phải là một file nén zip).",too_large:"Gói quá lớn (tối đa {0} MB).",path:"Gói chứa đường dẫn không an toàn: “{0}”. Hãy nén lại chỉ các file của plug-in.",extra_file:"Gói có file không được phép: “{0}”. Chỉ cần manifest.json, file chính (hoặc thư mục sounds/) và ảnh thumbnail.",too_many_files:"Gói có quá nhiều file (tối đa {0}).",no_manifest:"Gói thiếu file manifest.json.",manifest_json:"Không đọc được manifest.json (JSON chưa đúng).",manifest_field:"manifest.json: trường “{0}” {1}.",unknown_key:"manifest.json có trường lạ “{0}”.",forbidden_key:"Gói có khoá bị cấm “{0}”.",too_deep:"Dữ liệu trong {0} lồng quá sâu.",kind:"Loại plug-in “{0}” không được hỗ trợ (motion, lottie, recipe, analyzer, ai-template).",kind_later:"Loại plug-in “{0}” sẽ có ở bản sau.",min_app:"Plug-in này cần phiên bản Clipoox mới hơn (API {0}).",permissions:"Plug-in xin quyền “{0}” — loại plug-in này không được cấp quyền đó.",permission_needed:'Plug-in loại {0} phải khai báo quyền "permissions": [{1}] để khách thấy trước khi cài.',ai_template:"File mẫu AI (template.json) chưa đúng.",analyzer_result:"Plug-in phân tích trả về kết quả không hợp lệ.",analyzer_op:"Thao tác {0}: “{1}” — plug-in phân tích chỉ được đặt key / hiệu ứng / crop / rung cho chính clip đó.",use_ai_template:"“{0}” là mẫu AI: nó viết tài liệu, không đặt gì lên timeline — chạy ở tab Plug-in hoặc MCP run_ai_template.",not_ai_template:"“{0}” không phải plug-in mẫu AI.",store_paid_kind:"“{0}” là mẫu AI (tốn credit mỗi lần chạy) — Kho Plug-in chỉ nhận plug-in miễn phí khi chạy. Bỏ mục này khỏi gói rồi gửi lại; vẫn cài riêng từ file được.",no_transcript:"Clip này chưa có lời thoại — bấm Transcript cho clip trước.",max_credits:"Lần chạy này có thể tốn tới {0} credit — hãy xác nhận giá trước.",insufficient_credits:"Không đủ credit — nạp thêm để chạy mẫu AI.",ai_failed:"AI chưa viết được tài liệu — không trừ credit. Thử lại.",webhook_url:"Link webhook phải là link https:// đầy đủ.",webhook_https:"Chỉ nhận link https:// (cổng 443).",webhook_private:"Địa chỉ này là mạng nội bộ — dùng link webhook công khai mà Make, Zapier hoặc n8n đưa.",webhook_event:"Sự kiện webhook không hợp lệ.",webhook_limit:"Mỗi tài khoản tối đa 5 webhook.",webhook_missing:"Không tìm thấy webhook này (có thể đã xoá).",too_many_params:"Plug-in có tối đa {0} tham số.",param_type:"Tham số “{0}”: kiểu “{1}” chưa dùng được cho plug-in {2}.",param_value:"Giá trị của “{0}” không hợp lệ.",image_large:"Ảnh quá lớn (tối đa {0} MB).",no_entry:"Không thấy file “{0}” trong gói.",entry_large:"File “{0}” quá lớn.",encoding:"File trong gói phải là văn bản UTF-8.",code:"Code motion của plug-in không chạy được.",lottie:"File Lottie của plug-in không hợp lệ.",bind:"Tham số “{0}” không gắn được: không thấy “{1}” trong hoạt ảnh.",recipe_json:'recipe.json chưa đúng (cần dạng {"ops": [ … ]}).',recipe_ops:"Công thức có tối đa {0} bước.",recipe_op:"Bước {0}: thao tác “{1}” không dùng được trong plug-in.",paid_op:"Bước {0}: “{1}” là thao tác tốn credit — plug-in không được dùng.",recipe_field:"Bước {0}: trường “{1}” không được phép.",placeholder:"Bước {0}: {{{1}}} chưa được khai báo trong params.",needs_clip:"Chọn một clip trên timeline trước khi chạy.",needs_video:"Chọn một clip video trên timeline trước khi chạy plug-in phân tích.",thumbnail:"Ảnh thumbnail phải là PNG, WebP hoặc JPEG, tối đa 256 KB.",limit:"Tài khoản đã có đủ {0} plug-in. Gỡ bớt trước khi thêm.",rate:"Cài quá nhiều lần liên tiếp — thử lại sau vài phút.",not_found:"Không tìm thấy plug-in này (có thể đã gỡ).",nondeterministic:"Plug-in vẽ ra hai hình khác nhau cho cùng một thời điểm — video xuất sẽ không giống Monitor. Đừng lưu biến giữa các khung hình.",dryrun:"Chạy thử trên timeline mẫu: không bước nào áp dụng được.",not_owned:"Plug-in này cần mua trên clipoox.com trước khi cài.",refunded:"Đơn mua plug-in này đã hoàn tiền nên không cài mới được.",archived:"Plug-in này không còn trong kho.",sfx_package:"Gói âm thanh được cài từ file .clipoox-plugin, không phải dạng bundle.",not_sfx:"File này không phải gói âm thanh.",too_many_sounds:"Gói âm thanh có tối đa {0} âm thanh.",sound_format:"“{0}” không phải file âm thanh đúng định dạng (wav, mp3, ogg, flac, m4a — đuôi file phải khớp nội dung).",sound_header:"Không đọc được phần đầu file “{0}”.",sound_video:"“{0}” có hình (video) — gói âm thanh chỉ nhận file tiếng.",sound_long:"“{0}” dài quá: tối đa {1} giây.",sound_short:"“{0}” ngắn quá (dưới 0,05 giây).",sound_silent:"“{0}” im lặng hoàn toàn.",sound_rate:"“{0}”: tần số lấy mẫu không hợp lệ (8–192 kHz).",sound_channels:"“{0}”: quá nhiều kênh (tối đa 8).",sound_decode:"Không giải mã được “{0}”.",sound_large:"“{0}” quá lớn (tối đa {1} MB mỗi file).",sound_unlisted:"“{0}” nằm trong thư mục sounds/ nhưng chưa khai báo trong manifest.json.",not_zip_sfx:"Gói âm thanh phải là file nén zip.",sha256:"File tải lên bị lỗi giữa đường (mã kiểm tra không khớp) — thử lại.",busy:"Máy chủ đang xử lý gói âm thanh khác — thử lại sau một phút.",asset:"Tài nguyên “{0}”: {1}.",use_asset:"Mục “{0}” dùng tài nguyên “{1}” mà gói không có (hoặc sai loại).",use_missing:"Không tìm thấy “{0}” trong plug-in đã cài.",use_assets:"“{0}” cần tài nguyên 3D nhưng chỗ này chưa nạp được — dùng trong tab Plug-in.",pack_only:"Mục loại “{0}” chỉ có trong gói có thư mục assets/.",item_budget:"Mục “{0}”: tài nguyên tổng {1} MB — tối đa {2} MB mỗi mục.",item_pixels:"Mục “{0}”: ảnh giải mã ra {1} MB — tối đa {2} MB mỗi mục.",model_anim:"Mục “{0}”: GLB không có animation “{1}”.",param_link:"Mục “{0}”: tham số “{1}” gắn với điều khiển chung “{2}” không có hoặc khác kiểu.",item_category:"Mục “{0}”: nhóm “{1}” chưa khai báo trong categories."},ue={too_large:"quá lớn (tối đa {0} MB)",not_image:"không phải ảnh PNG / WebP / JPEG đọc được",magic:"đuôi file không khớp nội dung (thật ra là {0})",image_size:"ảnh {0} lớn quá (tối đa {1})",glb_header:"không phải file GLB hợp lệ",glb_version:"GLB phiên bản {0} — cần glTF 2.0",glb_length:"file GLB bị cắt dở",glb_json_large:"phần JSON của GLB quá lớn",glb_json:"không đọc được phần JSON của GLB",glb_uri:"trỏ ra file hoặc link ngoài “{0}” — hãy nhúng mọi thứ vào GLB",glb_compressed:"dùng nén {0} chưa hỗ trợ — hãy xuất GLB không nén",glb_extension:"cần extension {0} chưa hỗ trợ",glb_buffers:"cấu trúc buffer không hợp lệ (chỉ một buffer BIN nhúng)",glb_nodes:"cây node quá lớn hoặc quá sâu (tối đa {0})",glb_range:"dữ liệu “{0}” nằm ngoài file",glb_sparse:"dùng accessor sparse chưa hỗ trợ",glb_triangles:"{0} tam giác — quá {1}",glb_vertices:"{0} đỉnh — quá {1}",glb_images:"{0} ảnh nhúng — tối đa {1}",glb_image:"ảnh nhúng số {0} không phải PNG / JPEG / WebP hợp lệ",lut:"LUT .cube không đọc được {0}",lut_size:"LUT {0}³ lớn quá (tối đa {1}³)",seq_frames:"{0} khung — tối đa {1}",seq_size:"các khung không cùng kích thước",seq_format:"chuỗi ảnh hỏng"},ge={type:"sai kiểu dữ liệu",required:"đang thiếu",length:"dài quá hoặc rỗng",format:"sai định dạng",range:"ngoài khoảng cho phép",duplicate:"bị trùng"};function X(t){const l=t||{},o=l.code&&Pn[l.code]?l.code:null;if(!o)return{text:e("Không cài được plug-in: {0}",[String(l.message||"").slice(0,200)]),detail:""};const h=[...l.args||[]];if(o==="manifest_field"&&h[1]&&(h[1]=e(ge[h[1]]??h[1])),o==="asset"&&h[1]){const u=ue[h[1]];return{text:e(Pn.asset,[h[0],u?e(u,h.slice(2)):h[1]]),detail:l.message&&l.message!==o?String(l.message).slice(0,300):""}}const j=l.message&&l.message!==o&&!/^manifest\./.test(l.message)?String(l.message).slice(0,300):"";return{text:e(Pn[o],h),detail:j}}const me=t=>(t==="en"?Ln(()=>import("./plugin-guide.en-CGYh_9Su.js"),[]):Ln(()=>import("./plugin-guide.vi-DMphSELb.js"),[])).then(l=>l.default);function an(t,l){const o=[],h=/(`[^`]+`|\*\*[^*]+\*\*|\*[^*\s][^*]*\*|\[[^\]]+\]\((https:\/\/[^)\s]+|[a-z0-9./#-]+)\))/g;let j=0,u=0;for(const A of t.matchAll(h)){A.index>j&&o.push(t.slice(j,A.index));const p=A[0],c=`${l}-${u++}`;if(p.startsWith("`"))o.push(n.jsx("code",{children:p.slice(1,-1)},c));else if(p.startsWith("**"))o.push(n.jsx("strong",{children:p.slice(2,-2)},c));else if(p.startsWith("*"))o.push(n.jsx("em",{children:p.slice(1,-1)},c));else{const g=p.slice(1,p.indexOf("]")),k=A[2];o.push(k.startsWith("https://")?n.jsx("a",{href:k,target:"_blank",rel:"noopener noreferrer",children:g},c):n.jsx("span",{className:"tl-guide-ref",children:g},c))}j=A.index+p.length}return j<t.length&&o.push(t.slice(j)),o}function pe(t){const l=t.replace(/\r/g,"").split(`
3
- `),o=[];for(let h=0;h<l.length;){const j=l[h],u=`b${h}`;if(j.startsWith("```")){const c=[];for(h++;h<l.length&&!l[h].startsWith("```");)c.push(l[h++]);h++,o.push(n.jsx("pre",{children:n.jsx("code",{children:c.join(`
4
- `)})},u));continue}const A=/^(#{1,4})\s+(.*)$/.exec(j);if(A){const c=Math.min(4,A[1].length+1),g=`h${c}`;o.push(n.jsx(g,{children:an(A[2],u)},u)),h++;continue}if(/^\|.*\|\s*$/.test(j)){const c=[];for(;h<l.length&&/^\|.*\|\s*$/.test(l[h]);){const g=l[h].trim().slice(1,-1).split("|").map(k=>k.trim());g.every(k=>/^:?-{2,}:?$/.test(k))||c.push(g),h++}o.push(n.jsx("div",{className:"tl-guide-table",children:n.jsxs("table",{children:[n.jsx("thead",{children:n.jsx("tr",{children:c[0].map((g,k)=>n.jsx("th",{children:an(g,`${u}h${k}`)},k))})}),n.jsx("tbody",{children:c.slice(1).map((g,k)=>n.jsx("tr",{children:g.map((x,T)=>n.jsx("td",{children:an(x,`${u}r${k}c${T}`)},T))},k))})]})},u));continue}if(/^\s*([-*]|\d+\.)\s+/.test(j)){const c=/^(\s*)([-*]|\d+\.)\s+/,g=/^\s*\d+\./.test(j),k=c.exec(j)[1].length,x=[];for(;h<l.length;){const r=c.exec(l[h]);if(r){const b=l[h].slice(r[0].length);if(r[1].length>k&&x.length)x[x.length-1].sub.push(b);else{if(r[1].length<k)break;x.push({text:b,sub:[]})}h++;continue}if(/^\s{2,}\S/.test(l[h])&&x.length){const b=x[x.length-1],G=l[h++].trim();b.sub.length?b.sub[b.sub.length-1]+=" "+G:b.text+=" "+G;continue}break}const T=g?"ol":"ul";o.push(n.jsx(T,{children:x.map((r,b)=>n.jsxs("li",{children:[an(r.text,`${u}-${b}`),r.sub.length>0&&n.jsx("ul",{children:r.sub.map((G,C)=>n.jsx("li",{children:an(G,`${u}-${b}-${C}`)},C))})]},b))},u));continue}if(j.startsWith(">")){const c=[];for(;h<l.length&&l[h].startsWith(">");)c.push(l[h++].replace(/^>\s?/,""));o.push(n.jsx("blockquote",{children:an(c.join(" "),u)},u));continue}if(!j.trim()){h++;continue}const p=[];for(;h<l.length&&l[h].trim()&&!/^(#|```|\||>|\s*([-*]|\d+\.)\s)/.test(l[h]);)p.push(l[h++]);o.push(n.jsx("p",{children:an(p.join(" "),u)},u))}return o}function ke({onClose:t}){const l=wn(),[o,h]=N.useState(null),[j,u]=N.useState(!1);N.useEffect(()=>{let p=!0;return h(null),me(l).then(c=>{p&&h(c)},()=>{p&&u(!0)}),()=>{p=!1}},[l]),N.useEffect(()=>{const p=c=>{c.key==="Escape"&&(c.stopPropagation(),t())};return window.addEventListener("keydown",p,!0),()=>window.removeEventListener("keydown",p,!0)},[t]);const A=()=>{if(!o)return;const p=Object.assign(document.createElement("a"),{href:URL.createObjectURL(new Blob([o],{type:"text/markdown"})),download:`clipoox-plugin-guide.${l==="en"?"en":"vi"}.md`});p.click(),setTimeout(()=>URL.revokeObjectURL(p.href),1e3)};return n.jsx("div",{className:"tl-guide-backdrop",onMouseDown:p=>{p.target===p.currentTarget&&t()},children:n.jsxs("div",{className:"tl-guide",role:"dialog","aria-modal":"true","aria-label":e("Hướng dẫn làm plug-in"),children:[n.jsxs("div",{className:"tl-guide-head",children:[n.jsxs("strong",{children:["📘 ",e("Hướng dẫn làm plug-in")]}),n.jsx("button",{className:"pill-btn thin",disabled:!o,onClick:A,children:e("Tải hướng dẫn (.md)")}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/lower-third-clipoox.clipoox-plugin",download:!0,children:[e("Mẫu Motion")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/like-subscribe.clipoox-plugin",download:!0,children:[e("Mẫu Lottie")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/talking-head-quick.clipoox-plugin",download:!0,children:[e("Mẫu công thức")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/bds-starter.clipoox-plugin",download:!0,children:[e("Mẫu gói ngách BĐS")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin accent",href:"/plugin-dev-kit.md",download:"clipoox-plugin-dev-kit.md",title:e("Dán cho Claude / ChatGPT để AI viết plug-in theo đúng quy tắc của Clipoox"),children:[e("Plugin Dev Kit (cho AI)")," ⤓"]}),n.jsx("button",{className:"icon-btn","aria-label":e("Đóng"),onClick:t,children:"×"})]}),n.jsx("div",{className:"tl-guide-body",children:j?n.jsx("p",{className:"tl-plugin-error",children:e("Không tải được hướng dẫn.")}):o===null?n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải…")]}):n.jsx(N.Fragment,{children:pe(o)})})]})})}const Tn=[{id:"export.done",vi:"Xuất video xong"},{id:"ai.document.ready",vi:"Tài liệu AI xong"},{id:"plugin.analyzed",vi:"Plug-in phân tích xong"}];function xe({toast:t}){const[l,o]=N.useState(null),[h,j]=N.useState(""),[u,A]=N.useState(Tn.map(v=>v.id)),[p,c]=N.useState(null),[g,k]=N.useState(null),[x,T]=N.useState(""),r=()=>se().then(v=>o(v.endpoints)).catch(v=>T(X(v).text));N.useEffect(()=>{r()},[]);const b=v=>T(X(v).text),G=async()=>{c("add"),T("");try{const v=await le(h.trim(),u);k({id:v.id,value:v.secret}),j(""),await r(),t(e("Đã thêm webhook"),"ok")}catch(v){b(v)}finally{c(null)}},C=async v=>{c(v),T("");try{const O=await ae(v);t(O.status>=200&&O.status<300?e("Đã gửi thử — nơi nhận trả lời HTTP {0}",[O.status]):e("Gửi thử chưa tới nơi ({0}) — kiểm tra link và kịch bản Make đang chạy",[O.error||`HTTP ${O.status}`]),O.status>=200&&O.status<300?"ok":"error"),await r()}catch(O){b(O)}finally{c(null)}},rn=async v=>{c(v);try{const O=await re(v);k({id:v,value:O.secret})}catch(O){b(O)}finally{c(null)}},V=async v=>{c(v);try{await ce(v),g?.id===v&&k(null),await r()}catch(O){b(O)}finally{c(null)}},Z=v=>e(Tn.find(O=>O.id===v)?.vi??v);return n.jsxs("details",{className:"tl-plugin-hooks",children:[n.jsxs("summary",{children:[n.jsxs("b",{children:["⚡ ",e("Tự động hoá (Webhook)")]})," ",n.jsx("small",{className:"muted",children:e("Make, Zapier, n8n nhận tin khi video xuất xong hoặc tài liệu AI xong")})]}),l===null&&!x&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải…")]}),l&&l.length>0&&n.jsx("ul",{className:"tl-plugin-hook-list","aria-label":e("Webhook của tôi"),children:l.map(v=>n.jsxs("li",{children:[n.jsxs("div",{className:"tl-plugin-hook-url",children:[n.jsx("code",{title:v.url,children:v.url}),n.jsxs("small",{className:"muted",children:[v.events.map(Z).join(" · "),v.lastAt?` · ${e("lần gửi cuối")}: ${typeof v.lastStatus=="number"&&v.lastStatus>=200&&v.lastStatus<300?`✓ ${v.lastStatus}`:`⚠ ${v.lastStatus}`}`:""]})]}),n.jsxs("div",{className:"tl-plugin-hook-actions",children:[n.jsxs("button",{className:"pill-btn thin",disabled:!!p,onClick:()=>void C(v.id),children:[p===v.id?n.jsx("i",{className:"spin"}):null,e("Gửi thử")]}),n.jsx("button",{className:"pill-btn thin",disabled:!!p,onClick:()=>void rn(v.id),children:e("Đổi khoá")}),n.jsx("button",{className:"pill-btn thin danger",disabled:!!p,"aria-label":e("Xoá webhook {0}",[v.url]),onClick:()=>void V(v.id),children:"✕"})]}),g?.id===v.id&&n.jsxs("p",{className:"tl-plugin-hook-secret",role:"status",children:[e("Khoá ký (chỉ hiện một lần — dán vào Make để kiểm chữ ký):")," ",n.jsx("code",{children:g.value}),n.jsx("button",{className:"pill-btn thin",onClick:()=>{navigator.clipboard?.writeText(g.value),t(e("Đã chép khoá"),"ok")},children:e("Chép")})]})]},v.id))}),l&&l.length<5&&n.jsxs("div",{className:"tl-plugin-hook-add",children:[n.jsx("input",{type:"url",inputMode:"url",placeholder:"https://hook.eu2.make.com/…","aria-label":e("Link webhook (https)"),value:h,onChange:v=>j(v.target.value)}),n.jsx("div",{className:"tl-plugin-hook-events",role:"group","aria-label":e("Gửi khi"),children:Tn.map(v=>n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:u.includes(v.id),onChange:O=>A(cn=>O.target.checked?[...cn,v.id]:cn.filter(S=>S!==v.id))}),e(v.vi)]},v.id))}),n.jsxs("button",{className:"pill-btn accent",disabled:!!p||!/^https:\/\/\S+\.\S+/.test(h.trim())||!u.length,onClick:()=>void G(),children:[p==="add"?n.jsx("i",{className:"spin"}):null,e("Thêm webhook")]})]}),x&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",x]}),n.jsx("small",{className:"muted",children:e("Mỗi lần gửi có chữ ký X-Clipoox-Signature (HMAC-SHA256). Xem cách nối Make trong Hướng dẫn plug-in, mục 17.")})]})}const fe=N.lazy(()=>Ln(()=>import("./PluginStore-8TjQawtB.js"),__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]))),si=[{file:"lower-third-clipoox.clipoox-plugin",kind:"motion"},{file:"like-subscribe.clipoox-plugin",kind:"lottie"},{file:"talking-head-quick.clipoox-plugin",kind:"recipe"},{file:"sfx-starter.clipoox-plugin",kind:"sfx"},{file:"bds-starter.clipoox-plugin",kind:"pack"},{file:"hologram-studio.clipoox-plugin",kind:"kit"},{file:"auto-zoom-screen.clipoox-plugin",kind:"analyzer"},{file:"lesson-kit.clipoox-plugin",kind:"ai-template"},{file:"lecture-studio.clipoox-plugin",kind:"pack"}],be={motion:{vi:"Motion",en:"Motion"},lottie:{vi:"Lottie",en:"Lottie"},recipe:{vi:"Công thức",en:"Recipe"},sfx:{vi:"Âm thanh",en:"Sounds"},pack:{vi:"Gói ngách",en:"Niche pack"},model:{vi:"Mô hình 3D",en:"3D model"},lut:{vi:"Look màu",en:"Colour look"},kit:{vi:"Bộ 3D",en:"3D kit"},motion3d:{vi:"Motion 3D",en:"Motion 3D"},sfxlib:{vi:"Kho âm thanh",en:"Sound library"},analyzer:{vi:"Phân tích clip",en:"Clip analyzer"},"ai-template":{vi:"Mẫu AI",en:"AI template"}},je={footage:"đọc khung hình nhỏ (đen trắng) + lời thoại của clip bạn chọn, ngay trên máy — không gửi đi đâu",transcript:"đọc lời thoại của clip bạn chọn, AI của Clipoox viết tài liệu (tính credit, báo giá trước)"},Bn=(t,l)=>be[t][l==="en"?"en":"vi"],Nn=t=>t.kind==="pack"&&!!t.assets?.some(l=>l.kind==="model"),$n=(t,l)=>Bn(Nn(t)?"kit":t.kind==="motion"&&t.engine==="3d"?"motion3d":t.kind,l),ve={motion3d:["3D","3D"],model:["MÔ HÌNH","MODEL"],lut:["LOOK","LOOK"],motion:["2D","2D"],recipe:["COMBO","COMBO"],lottie:["LOTTIE","LOTTIE"]},ye=(t,l)=>{const o=t.kind==="motion"&&t.engine==="3d"?"motion3d":t.kind,h=ve[o];return h?h[l==="en"?1:0]:""},Gn=1024*1024;function Ne(t,l){const o=t.facts??{},h=u=>u.toLocaleString(l==="en"?"en-US":"vi-VN"),j=t.bytes!==void 0?t.bytes>=Gn?`${(t.bytes/Gn).toFixed(1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(t.bytes/1024))} KB`:"";return t.kind==="model"?[j,e("{0} tam giác",[h(o.triangles??0)]),...o.images?.length?[e("{0} ảnh nhúng",[o.images.length])]:[],...o.animations?.length?[e("animation: {0}",[o.animations.slice(0,3).join(", ")])]:[],e("không có link ngoài")].join(" · "):t.kind==="sequence"?[j,e("{0} khung {1} × {2}",[o.frames??0,o.width??0,o.height??0])].join(" · "):t.kind==="lut"?[j,e("LUT 3D {0}³",[o.size??0])].join(" · "):[j,`${o.width??0} × ${o.height??0}`,...t.sprite?[e("sprite {0} × {1} = {2} khung",[t.sprite.cols,t.sprite.rows,t.sprite.frames])]:[]].join(" · ")}const hi=t=>`clipoox:kit-controls:${t}`;function we(t){try{const l=JSON.parse(localStorage.getItem(hi(t))||"{}");return l&&typeof l=="object"&&!Array.isArray(l)?l:{}}catch{return{}}}function _e(t,l){try{localStorage.setItem(hi(t),JSON.stringify(l))}catch{}}const Se=["#3ee6ff","#c6f432","#ff5fa2","#ffb547","#9d7bff","#ffffff"],Ce={compile:["Chạy được trong sandbox (không mạng, không truy cập trang)","Không chạy được"],frames:["Đã vẽ thử {0} khung hình"],speed:["Tốc độ: {0} ms / khung","Hơi chậm: {0} ms / khung — xuất video sẽ lâu hơn"],same:["Vẽ lại cho cùng kết quả — video xuất giống Monitor","Hai lần vẽ cùng thời điểm cho kết quả khác nhau"],blank:["Có hình trong khung thử","Các khung thử đều trống — kiểm tra thời lượng và màu"],binds:["Gắn được {0} tham số vào hoạt ảnh"],dryrun:["Chạy thử trên timeline mẫu: {0} bước áp dụng, {1} bước bỏ qua (cần lời thoại / video)"],analyze:["Chạy thử trên video mẫu: {0} thao tác cho clip, {1} ms","Chạy thử trên video mẫu không ra thao tác nào"],template:["Mẫu AI hợp lệ: kết quả {0}, tối đa {1} token"],permission:["Quyền: {0}"]},li=t=>t.source?.store?` · ${e("Kho")}`:t.source?.dev?` · ${e("Bản thử – chưa duyệt")}`:"",Me=t=>t.recipe?{...t,recipe:{ops:t.recipe.ops.filter(l=>l.op!=="usePlugin")}}:t;async function ai(t){const l=j=>{const u=j;return u.op==="addMap"&&!u.geo||u.op==="updateMap"&&Array.isArray(u.places)};if(!t.some(l))return{ops:t,errors:[]};const o=[],h=[];for(const j of t){if(!l(j)){o.push(j);continue}const u=await Ei([j]);u.ops.length===1?o.push(u.ops[0]):h.push(...u.errors)}return{ops:o,errors:h}}const In=(t,l)=>Object.fromEntries(t.params.filter(o=>o.type!=="image").map(o=>[o.key,l[o.key]]));function Pe({selected:t,time:l,aspect:o,materials:h,locked:j,onCommit:u,onPatch:A,toast:p}){const c=wn(),[g,k]=N.useState(null),[x,T]=N.useState(null),[r,b]=N.useState(null),[G,C]=N.useState(null),[rn,V]=N.useState(null),[Z]=N.useState(()=>Ii()),[v,O]=N.useState(!1),[cn,S]=N.useState(!!Z),[M,K]=N.useState(null),[B,F]=N.useState(null),[pn,qn]=N.useState({}),[vn,Kn]=N.useState("all"),[P,on]=N.useState(null),_n=i=>{F({id:i.id}),Kn("all"),qn(s=>({...s,[i.id]:{...Object.fromEntries((i.manifest.controls??[]).map(a=>[a.key,a.default])),...we(i.id)}})),ni(i).then(s=>F(a=>a?.id===i.id?{id:i.id,index:s}:a),s=>F(a=>a?.id===i.id?{id:i.id,error:X(s).text}:a))},Fn=N.useRef(null),[ui,Un]=N.useState(""),gi=i=>{S(!1),Qn().then(s=>{k(s.plugins);const a=s.plugins.find(d=>d.id===i);a&&(a.kind==="pack"&&B?.id!==i&&_n(a),Un(i),window.setTimeout(()=>Un(d=>d===i?"":d),3400),requestAnimationFrame(()=>document.querySelector(`[data-plugin="${CSS.escape(i)}"]`)?.scrollIntoView({block:"center",behavior:"smooth"})))},()=>{})},Q=N.useCallback(()=>Qn().then(i=>{k(i.plugins),T(null)},i=>{k(s=>s??[]),T(X(i).text)}),[]);N.useEffect(()=>{Q()},[Q]),N.useEffect(()=>{Z&&qi()},[Z]);const en=i=>{const s=X(i);p(s.detail?`${s.text} (${s.detail})`:s.text,"error")},mi=async i=>{b({file:i.name,stage:"reading"});try{if(await Ui(i)){const y=await Di(i),w=g?.find(L=>L.id===y.manifest.id);b({file:i.name,stage:"review",sfx:y,...w?{exists:{installed:w.version,newer:yn(y.manifest.version,w.version)>0}}:{}});return}const{bytes:s,...a}=await zi(i);if(a.manifest.kind==="pack"){const y=a.items,w=[];let L=a.thumbnail;b({file:i.name,stage:"checking",bundle:a,pack:{bytes:s,checks:[],total:y.length}});const m=Ri(a,Math.random().toString(36).slice(2,8));try{for(const E of y){const z=await Yn(Me(E),o,{assets:m.refs,readAsset:a.readAsset}).catch(R=>({ok:!1,lines:[],thumbnail:null,error:R.message}));L??=z.thumbnail,w.push({id:E.manifest.id,name:_(E.manifest,c),kind:E.manifest.kind==="motion"&&E.manifest.engine==="3d"?"motion3d":E.manifest.kind,ok:z.ok,warn:z.lines.some(R=>R.warn),...z.error?{error:z.error}:{}}),b(R=>R&&{...R,pack:{bytes:s,checks:[...w],total:y.length}})}}finally{m.drop()}const $=w.find(E=>!E.ok),q=g?.find(E=>E.id===a.manifest.id);b({file:i.name,stage:"review",bundle:{...a,thumbnail:L},pack:{bytes:s,checks:w,total:y.length},...$?{error:{text:e("Mục “{0}” không chạy được",[$.name]),detail:$.error??""}}:{},...q?{exists:{installed:q.version,newer:yn(a.manifest.version,q.version)>0}}:{}});return}b({file:i.name,stage:"checking",bundle:a});const d=await Yn(a,o),f=g?.find(y=>y.id===a.manifest.id);b({file:i.name,stage:"review",bundle:a,check:d,...d.ok?{}:{error:X({code:d.error==="nondeterministic"||d.error==="dryrun"?d.error:"code",message:d.error})},...f?{exists:{installed:f.version,newer:yn(a.manifest.version,f.version)>0}}:{}})}catch(s){b({file:i.name,stage:"review",error:X(s)})}},pi=async()=>{const i=r;if(i?.sfx){const s=i.sfx;b({...i,stage:"saving",progress:{stage:"upload",pct:0}});try{const a=await Wi(s,!!i.exists,(d,f)=>b(y=>y&&{...y,progress:{stage:d,pct:f}}));b(null),await Q(),bn(),p(a.updated?e("Đã cập nhật “{0}” lên v{1}",[_(a.plugin.manifest,c),a.plugin.version]):e("Đã thêm gói âm thanh “{0}” ({1} âm thanh) — có trong mục SFX",[_(a.plugin.manifest,c),a.plugin.manifest.sounds?.length??0]),"ok")}catch(a){const d=a;if(d.code==="exists"){const f=d.data;b({...i,stage:"review",progress:void 0,exists:{installed:f.installed,newer:f.newer}});return}b({...i,stage:"review",progress:void 0,error:X(a)})}return}if(i?.pack&&i.bundle){const s=i.pack,a=i.bundle.manifest;b({...i,stage:"saving",progress:{stage:"upload",pct:0}});try{const d=await Hi(s.bytes,a,i.file,!!i.exists,f=>b(y=>y&&{...y,progress:{stage:"upload",pct:f}}));b(null),await Q(),bn(),_n(d.plugin),p(d.updated?e("Đã cập nhật “{0}” lên v{1}",[_(d.plugin.manifest,c),d.plugin.version]):Nn(d.plugin.manifest)?e("Đã thêm bộ 3D “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]):e("Đã thêm gói “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]),"ok")}catch(d){const f=d;if(f.code==="exists"){const y=f.data;b({...i,stage:"review",progress:void 0,exists:{installed:y.installed,newer:y.newer}});return}b({...i,stage:"review",progress:void 0,error:X(d)})}return}if(!(!i?.bundle||!i.check?.ok)){b({...i,stage:"saving"});try{const s=await Xi({...i.bundle,thumbnail:i.check.thumbnail??i.bundle.thumbnail},!!i.exists);b(null),await Q(),bn(),p(s.updated?e("Đã cập nhật “{0}” lên v{1}",[_(s.plugin.manifest,c),s.plugin.version]):e("Đã thêm plug-in “{0}”",[_(s.plugin.manifest,c)]),"ok")}catch(s){const a=s;if(a.code==="exists"){const d=a.data;b({...i,stage:"review",exists:{installed:d.installed,newer:d.newer}});return}b({...i,stage:"review",error:X(s)})}}},dn=i=>Pi(Math.max(0,Math.min(l,Ti-i))),ki=async i=>{if(!G){if(i.kind==="sfx"||i.kind==="sfxlib"){Hn(s=>s===i.id?null:i.id);return}if(i.kind==="pack"){B?.id===i.id?F(null):_n(i);return}C(i.id);try{const s=await oi(i,k),a=s.manifest,d=_(a,c),f=H.getState();if(a.kind==="recipe"){K({id:i.id,values:J(a,{}),bundle:s});return}if(a.kind==="analyzer"){Dn(i.id,void 0,a);return}if(a.kind==="ai-template"){on({id:i.id,values:J(a,{}),bundle:s});return}if(a.kind==="motion"){const U=di(a,s.entry,{}),Y=dn(a.duration),sn=gn(f.clips,[{op:"addMotion",code:U.code,params:U.params,motionPreset:U.preset,...U.kind?{motionKind:U.kind}:{},label:`Plug-in · ${d}`,start:Y,duration:a.duration}],[],f.timelineTracks);if(sn.errors.length)throw Error(sn.errors[0]);const I=sn.clips.find(W=>!f.clips.some(nn=>nn.id===W.id));u(sn.clips.map(W=>W.id===I?.id?{...W,plugin:{id:a.id,v:a.version,kind:"motion"}}:W),I?.id);return}const y=J(a,{}),w=await En(s.lottie,a,y),L=await On(a.id,w),m=ti(s),$=dn(m),q={id:L.gcsUri,kind:"lottie",url:L.url,gcsUri:L.gcsUri,label:d,lottie:s.lottie.meta},E=H.getState(),z=gn(E.clips,[{op:"addClip",materialId:q.id,start:$,duration:m}],[q],E.timelineTracks);if(z.errors.length)throw Error(z.errors[0]);const R=z.clips.find(U=>!E.clips.some(Y=>Y.id===U.id));u(z.clips.map(U=>U.id===R?.id?{...U,label:`Plug-in · ${d}`,lottie:{...U.lottie,loop:a.loop!==!1},plugin:{id:a.id,v:a.version,kind:"lottie",params:In(a,y)}}:U),R?.id)}catch(s){en(s)}finally{C(null)}}},xi=async(i,s)=>{if(!G){C(`${i.id}/${s}`);try{const a=(await ni(i)).items.find(I=>I.manifest.id===s)?.manifest;if(a&&(a.kind==="model"||a.kind==="lut"||a.kind==="motion"&&(a.uses?.length||a.params.some(I=>I.link||I.type==="asset")))){const I=H.getState(),W=pn[i.id]??{};if(a.kind==="lut"&&!t)throw ii("needs_clip");const nn=Object.fromEntries(a.params.filter(ln=>ln.link&&W[ln.link]!==void 0).map(ln=>[ln.key,W[ln.link]])),hn=await ei([{op:"usePlugin",pluginId:`${i.id}/${s}`,params:nn,...a.kind==="lut"?{clipId:t.id}:{start:dn(a.duration??5)}}],{items:g??[],clips:I.clips,playhead:l,locale:c}),D=H.getState(),un=Mn(D.clips,hn.ops,[...h,...hn.materials],D.timelineTracks,D.timelineCamera,{W:o.width,H:o.height,motion:D.timelineMotion,brand:D.timelineBrand});if(!un.result||!un.ops.length)throw Error(un.skipped[0]?.error??"—");const Zn=hn.tagPlugins(D.clips,un.result.clips),Ci=Zn.find(ln=>!D.clips.some(Mi=>Mi.id===ln.id));u(Zn,Ci?.id??t?.id??null),a.kind==="lut"&&p(e("Đã áp look “{0}” cho “{1}” (chỉnh độ mạnh ở tab Màu)",[_(a,c),t.label]),"ok");return}const d=await ri(i,s),f=d.manifest,y=_(f,c),w=H.getState(),L={id:i.id,item:s,v:i.version};if(f.kind==="recipe"){K({id:i.id,item:s,values:J(f,{}),bundle:d});return}if(f.kind==="analyzer"){Dn(i.id,s,f);return}if(f.kind==="ai-template"){on({id:i.id,item:s,values:J(f,{}),bundle:d});return}if(f.kind==="motion"){const I=ci(i.id,s,d,{}),W=dn(f.duration),nn=gn(w.clips,[{op:"addMotion",code:I.code,params:I.params,motionPreset:I.preset,...I.kind?{motionKind:I.kind}:{},label:`Plug-in · ${y}`,start:W,duration:f.duration}],[],w.timelineTracks);if(nn.errors.length)throw Error(nn.errors[0]);const hn=nn.clips.find(D=>!w.clips.some(un=>un.id===D.id));u(nn.clips.map(D=>D.id===hn?.id?{...D,plugin:{...L,kind:"motion"}}:D),hn?.id);return}const m=J(f,{}),$=await En(d.lottie,f,m),q=await On(i.id,$),E=ti(d),z=dn(E),R={id:q.gcsUri,kind:"lottie",url:q.url,gcsUri:q.gcsUri,label:y,lottie:d.lottie.meta},U=H.getState(),Y=gn(U.clips,[{op:"addClip",materialId:R.id,start:z,duration:E}],[R],U.timelineTracks);if(Y.errors.length)throw Error(Y.errors[0]);const sn=Y.clips.find(I=>!U.clips.some(W=>W.id===I.id));u(Y.clips.map(I=>I.id===sn?.id?{...I,label:`Plug-in · ${y}`,lottie:{...I.lottie,loop:f.loop!==!1},plugin:{...L,kind:"lottie",params:In(f,m)}}:I),sn?.id)}catch(a){en(a)}finally{C(null)}}},Dn=(i,s,a)=>{if(!t||t.kind!=="video")throw ii("needs_video");const d=H.getState(),f=g?.find(w=>w.id===i),y=gn(d.clips,[{op:"runAnalyzer",clipId:t.id,plugin:{id:i,...s?{item:s}:{},v:f?.version??a.version},values:J(a,{})}],[],d.timelineTracks);if(y.errors.length)throw Error(y.errors[0]);u(y.clips,t.id),p(e("“{0}” đang đọc clip “{1}” trên máy — xong sẽ tự áp (hoàn tác bằng ⌘Z)",[_(a,c),t.label]),"ok")},zn=()=>{if(!t)return"";const i=H.getState(),s=i.timelineMedia.find(w=>t.gcsUri&&w.gcsUri===t.gcsUri||w.url===t.url),a=t.playbackRate||1,d=t.inPoint||0,f=d+t.duration*a,y=w=>w.end>d&&w.start<f;return s?.words?.length?s.words.filter(y).map(w=>w.word).join(" "):(s?.transcript??[]).filter(y).map(w=>w.text).join(`
5
- `)},Rn=()=>({plugin:P.item?`${P.id}/${P.item}`:P.id,params:P.values,transcript:zn(),title:t?.label??"",duration:t?.duration??0,source:t?.id}),fi=async()=>{if(!(!P||G)){C(`ai:${P.id}`);try{const i=await oe(Rn());on(s=>s&&{...s,price:i.max_credits,doc:void 0})}catch(i){p(X(i).text,"error")}finally{C(null)}}},bi=async()=>{if(!(!P?.price||G)){C(`ai:${P.id}`);try{const i=await de(Rn(),P.price);on(s=>s&&{...s,doc:i}),p(e("Đã viết “{0}” — {1} credit",[i.title,i.credits]),"ok")}catch(i){p(X(i).text,"error")}finally{C(null)}}},ji=i=>{const s=i.format==="json"?"json":"md",a=i.format==="json"&&i.json!==void 0?JSON.stringify(i.json,null,2):i.text,d=Object.assign(document.createElement("a"),{href:URL.createObjectURL(new Blob([a],{type:i.format==="json"?"application/json":"text/markdown"})),download:`${i.title.replace(/[\\/:*?"<>|]+/g,"-").slice(0,80)||"clipoox"}.${s}`});d.click(),setTimeout(()=>URL.revokeObjectURL(d.href),2e3)},vi=async()=>{if(!(!M||G)){C(M.id);try{const i=H.getState(),s=t;if(M.item){const w=await ei([{op:"usePlugin",pluginId:`${M.id}/${M.item}`,params:M.values,...s?{clipId:s.id}:{}}],{items:g??[],clips:i.clips,playhead:l,locale:c}),L=await ai(w.ops),m=Mn(i.clips,L.ops,[...h,...w.materials],i.timelineTracks,i.timelineCamera,{W:o.width,H:o.height,motion:i.timelineMotion,brand:i.timelineBrand}),$=_(M.bundle.manifest,c),q=[...L.errors,...m.skipped.map(E=>E.error)];if(!m.result||!m.ops.length){p(e("“{0}” không áp dụng được bước nào: {1}",[$,q[0]??"—"]),"error");return}u(w.tagPlugins(i.clips,m.result.clips),null),p(q.length?e("Đã chạy “{0}”: {1} bước. Bỏ qua: {2}",[$,m.ops.length,q.join("; ")]):e("Đã chạy “{0}”: {1} bước (hoàn tác bằng ⌘Z)",[$,m.ops.length]),m.ops.length?"ok":"error");return}const a=await ai(Ji(M.bundle,M.values,{clip:s?.id??null,playhead:l,clipStart:s?.start??null,clipEnd:s?s.start+s.duration:null})),d=Mn(i.clips,a.ops,h,i.timelineTracks,i.timelineCamera,{W:o.width,H:o.height,motion:i.timelineMotion,brand:i.timelineBrand}),f=_(M.bundle.manifest,c),y=[...a.errors,...d.skipped.map(w=>w.error)];if(!d.result||!d.ops.length){p(e("“{0}” không áp dụng được bước nào: {1}",[f,y[0]??"—"]),"error");return}u(d.result.clips,null),p(y.length?e("Đã chạy “{0}”: {1} bước. Bỏ qua: {2}",[f,d.ops.length,y.join("; ")]):e("Đã chạy “{0}”: {1} bước (hoàn tác bằng ⌘Z)",[f,d.ops.length]),d.ops.length?"ok":"error")}catch(i){en(i)}finally{C(null)}}},Wn=(i,s)=>{qn(a=>({...a,[i]:s})),_e(i,s)},yi=i=>H.getState().clips.filter(s=>s.plugin?.id===i&&s.plugin?.kind==="motion"&&s.motion),Ni=(i,s)=>{const a=pn[i.id]??{},d=H.getState(),f=new Map(s.items.map(L=>[L.manifest.id,L.manifest]));let y=0;const w=d.clips.map(L=>{const m=L.plugin,$=m?.id===i.id&&m.item?f.get(m.item):void 0;if(!$||!L.motion)return L;const q=Object.fromEntries($.params.filter(E=>E.link&&a[E.link]!==void 0).map(E=>[E.key,a[E.link]]));return Object.keys(q).length?(y++,{...L,motion:{...L.motion,params:{...L.motion.params,...q}}}):L});if(!y){p(e("Chưa có lớp nào của bộ này trong dự án."),"error");return}u(w,null),p(e("Đã áp điều khiển chung cho {0} lớp (hoàn tác bằng ⌘Z)",[y]),"ok")},wi=async i=>{V(null);try{await ne(i.id,!i.enabled),await Q(),bn()}catch(s){en(s)}},[tn,Hn]=N.useState(null),[Sn,Xn]=N.useState(""),Jn=async i=>{const s=Vi(i);if(!(!s||Sn)){Xn(i);try{const a=await Zi(s.pack,s.sound),d=H.getState(),f=gn(d.clips,[{op:"addSfx",sfxId:i,at:dn(a.duration),volume:$i,sound:a}],[],d.timelineTracks);if(f.errors.length)throw Error(f.errors[0]);u(f.clips,f.clips.find(y=>!d.clips.some(w=>w.id===y.id))?.id??null)}catch(a){en(a)}finally{Xn("")}}},_i=async i=>{if(V(null),!!window.confirm(e("Gỡ plug-in “{0}”? Các lớp đã thêm vào video vẫn giữ nguyên.",[_(i.manifest,c)])))try{await ie(i.id),await Q(),bn(),tn===i.id&&Hn(null),p(e("Đã gỡ “{0}”",[_(i.manifest,c)]),"ok")}catch(s){en(s)}},kn=t,xn=kn?.plugin,Si=xn?g?.find(i=>i.id===xn.id):void 0,fn=(g??[]).filter(i=>i.enabled),Cn=(g??[]).filter(i=>!i.enabled),Vn=i=>n.jsxs("div",{className:`tl-plugin-tile${i.enabled?"":" off"}${ui===i.id?" flash":""}`,"data-plugin":i.id,children:[n.jsxs("button",{className:`tl-plugin-use${tn===i.id||B?.id===i.id?" on":""}`,disabled:!i.enabled||!!G,"aria-expanded":i.kind==="sfx"||i.kind==="sfxlib"?tn===i.id:i.kind==="pack"?B?.id===i.id:void 0,"aria-label":i.kind==="recipe"?e("Mở công thức {0}",[_(i.manifest,c)]):i.kind==="sfx"?e("Mở gói âm thanh {0}",[_(i.manifest,c)]):i.kind==="sfxlib"?e("Mở kho âm thanh {0}",[_(i.manifest,c)]):i.kind==="pack"?e("Mở gói {0}",[_(i.manifest,c)]):e("Thêm plug-in {0}",[_(i.manifest,c)]),onClick:()=>void ki(i),children:[n.jsxs("span",{className:"tl-plugin-thumb",children:[i.thumbnailUrl?n.jsx("img",{src:i.thumbnailUrl,alt:"",loading:"lazy",onError:s=>{s.currentTarget.style.visibility="hidden"}}):n.jsx("b",{children:i.kind==="analyzer"?"⌖":i.kind==="ai-template"?"✎":i.kind==="recipe"?"▶":i.kind==="sfx"?"♪":i.kind==="sfxlib"?"📚":Nn(i.manifest)?"◈":i.kind==="pack"?"⧉":"✦"}),G===i.id&&n.jsx("i",{className:"spin"})]}),n.jsxs("span",{className:"tl-plugin-name",children:[n.jsx("strong",{title:_(i.manifest,c),children:_(i.manifest,c)}),n.jsxs("small",{children:[$n(i.manifest,c),i.kind==="sfx"?` · ${e("{0} âm thanh",[i.manifest.sounds?.length??0])}`:""," · v",i.version,i.kind==="pack"?` · ${e("{0} mục",[i.manifest.items?.length??0])}`:"",li(i),i.enabled?"":` · ${e("Đã tắt")}`]})]})]}),n.jsx("button",{className:"tl-plugin-more","aria-label":e("Tuỳ chọn {0}",[_(i.manifest,c)]),"aria-expanded":rn===i.id,onClick:()=>V(s=>s===i.id?null:i.id),children:"⋯"}),rn===i.id&&n.jsxs("div",{className:"tl-plugin-menu",role:"menu",children:[n.jsx("p",{children:mn(i.manifest,c)||"—"}),n.jsxs("small",{className:"muted",children:[e("Tác giả"),": ",i.manifest.author.name,i.manifest.author.url?` · ${i.manifest.author.url}`:""]}),n.jsx("button",{role:"menuitem",onClick:()=>void wi(i),children:i.enabled?e("Tắt plug-in"):e("Bật plug-in")}),n.jsx("button",{role:"menuitem",className:"danger",onClick:()=>void _i(i),children:e("Gỡ plug-in")})]})]},i.id);return n.jsxs("section",{className:"tl-plugins","aria-label":e("Plug-in của tôi"),children:[n.jsxs("div",{className:"tl-plugins-head",children:[n.jsxs("div",{children:[n.jsx("h4",{children:e("Plug-in của tôi")}),n.jsx("small",{className:"muted",children:e("Hiệu ứng motion, hoạt ảnh Lottie, công thức chỉnh sửa và gói âm thanh do cộng đồng làm")})]}),n.jsxs("div",{className:"tl-plugins-actions",children:[n.jsxs("button",{className:"pill-btn accent",onClick:()=>S(!0),children:["🛍 ",e("Kho Plug-in")]}),n.jsxs("button",{className:"pill-btn",disabled:!!r&&r.stage!=="review",onClick:()=>Fn.current?.click(),children:["+ ",e("Thêm plug-in")]}),n.jsxs("button",{className:"pill-btn",onClick:()=>O(!0),children:["📘 ",e("Hướng dẫn plug-in")]})]}),n.jsx("input",{ref:Fn,type:"file",hidden:!0,"aria-label":e("Chọn file plug-in"),accept:".clipoox-plugin,.zip,application/zip",onChange:i=>{const s=i.target.files?.[0];i.target.value="",s&&mi(s)}})]}),r&&n.jsxs("div",{className:`tl-plugin-review${r.error?" bad":""}`,role:"dialog","aria-label":e("Kiểm tra plug-in"),children:[r.stage==="reading"&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang đọc {0}…",[r.file])]}),r.stage==="checking"&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang chạy thử trong sandbox…")]}),r.sfx&&n.jsx(he,{review:r.sfx}),r.progress&&n.jsxs("p",{className:"tl-plugin-step",role:"status",children:[n.jsx("i",{className:"spin"}),r.progress.stage==="upload"?e("Đang tải gói lên… {0}%",[r.progress.pct??0]):r.pack?e("Máy chủ đang kiểm tra từng mục…"):e("Máy chủ đang kiểm tra và cân bằng âm lượng từng âm thanh…")]}),r.bundle&&n.jsxs("div",{className:"tl-plugin-card",children:[(r.check?.thumbnail??r.bundle.thumbnail)&&n.jsx("img",{alt:"",src:`data:${(r.check?.thumbnail??r.bundle.thumbnail).type};base64,${(r.check?.thumbnail??r.bundle.thumbnail).data}`}),n.jsxs("div",{children:[n.jsx("strong",{children:_(r.bundle.manifest,c)}),n.jsxs("small",{children:[$n(r.bundle.manifest,c)," · v",r.bundle.manifest.version," · ",r.bundle.manifest.author.name]}),n.jsx("p",{children:mn(r.bundle.manifest,c)}),n.jsxs("small",{className:"muted",children:[r.bundle.manifest.kind==="pack"?e("{0} mục",[r.bundle.manifest.items?.length??0]):e("{0} tham số",[r.bundle.manifest.params.length]),r.bundle.lottie?.removed&&r.bundle.lottie.removed.expressions+r.bundle.lottie.removed.assets+r.bundle.lottie.removed.fonts>0?` · ${e("đã bỏ {0} phần không an toàn (biểu thức / link ngoài)",[r.bundle.lottie.removed.expressions+r.bundle.lottie.removed.assets+r.bundle.lottie.removed.fonts])}`:""]})]})]}),r.bundle?.assets&&r.bundle.assets.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("h6",{className:"tl-plugin-subhead",children:e("Tài nguyên ({0})",[r.bundle.assets.length])}),n.jsxs("ul",{className:"tl-plugin-checks","aria-label":e("Tài nguyên"),children:[n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),n.jsxs("div",{className:"tl-plugin-fact",children:[n.jsx("b",{children:e("Gói {0} MB",[((r.pack?.bytes.length??0)/Gn).toFixed(1).replace(".",c==="en"?".":",")])})," ",n.jsxs("small",{className:"muted",children:["— ",e("giới hạn 200 MB · GLB ≤ 20 MB, ≤ 300 000 tam giác")]})]})]}),r.bundle.assets.slice(0,12).map(i=>n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),n.jsxs("div",{className:"tl-plugin-fact",children:[n.jsx("b",{children:i.name})," ",n.jsxs("small",{className:"muted",children:["— ",Ne(i,c)]})]})]},i.name)),r.bundle.assets.length>12&&n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),e("+ {0} tài nguyên khác",[r.bundle.assets.length-12])]})]}),n.jsx("h6",{className:"tl-plugin-subhead",children:e("Chạy thử từng mục")})]}),r.pack&&n.jsxs("ul",{className:"tl-plugin-checks","aria-label":e("Chạy thử từng mục"),children:[r.stage==="checking"&&n.jsxs("li",{className:"ok",children:[n.jsx("i",{className:"spin"}),e("Đang chạy thử mục {0} / {1}…",[r.pack.checks.length+1,r.pack.total])]}),r.pack.checks.map(i=>n.jsxs("li",{className:i.ok?i.warn?"warn":"ok":"bad",children:[n.jsx("span",{"aria-hidden":!0,children:i.ok?i.warn?"!":"✓":"✕"}),i.name," ",n.jsx("small",{className:"muted",children:Bn(i.kind,c)}),i.error&&n.jsxs("small",{children:[" — ",i.error]})]},i.id))]}),r.check&&n.jsx("ul",{className:"tl-plugin-checks",children:r.check.lines.map((i,s)=>{const[a,d]=Ce[i.key],f=!i.ok||i.warn;return n.jsxs("li",{className:i.ok?i.warn?"warn":"ok":"bad",children:[n.jsx("span",{"aria-hidden":!0,children:i.ok?i.warn?"!":"✓":"✕"}),e(f&&d?d:a,i.key==="permission"?[e(je[String(i.args?.[0])]??String(i.args?.[0]))]:i.args??[]),i.detail&&n.jsxs("small",{children:[" — ",i.detail]})]},s)})}),r.error&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",r.error.text,r.error.detail&&n.jsx("small",{children:r.error.detail})]}),r.exists&&!r.error&&(()=>{const i=(r.bundle??r.sfx).manifest.version;return n.jsx("p",{className:"tl-plugin-note",children:r.exists.newer?e("Đã cài v{0}. Cập nhật lên v{1}?",[r.exists.installed,i]):e("Đã cài v{0} — cài lại bản v{1} này?",[r.exists.installed,i])})})(),n.jsxs("div",{className:"tl-plugin-review-actions",children:[r.stage==="review"&&(r.check?.ok||r.sfx||r.pack)&&!r.error&&n.jsx("button",{className:"pill-btn accent",onClick:()=>void pi(),children:r.exists?r.exists.newer?e("Cập nhật plug-in"):e("Cài lại plug-in"):e("Cài plug-in")}),r.stage==="saving"&&n.jsxs("button",{className:"pill-btn accent",disabled:!0,children:[n.jsx("i",{className:"spin"}),e("Đang lưu…")]}),n.jsx("button",{className:"pill-btn",disabled:r.stage==="saving",onClick:()=>b(null),children:r.error?e("Đóng"):e("Huỷ")})]})]}),xn&&kn&&n.jsx($e,{clip:kn,pref:xn,item:Si,materials:h,locked:j,onPatch:A,toast:p,fail:en},`${kn.id}:${kn.url}:${xn.v}`),M&&(()=>{const i=M.bundle.manifest,s=g?.find(d=>d.id===M.id),a=/\{\{\s*clip/.test(JSON.stringify(M.bundle.recipe?.ops??[]));return n.jsxs("div",{className:"tl-plugin-recipe",role:"group","aria-label":e("Công thức {0}",[_(i,c)]),children:[n.jsxs("h5",{children:["▶ ",_(i,c)," ",n.jsxs("small",{className:"muted",children:["v",i.version]})]}),n.jsx("p",{className:"muted",children:mn(i,c)}),i.params.length>0&&n.jsx("div",{className:"tl-plugin-params",children:i.params.map(d=>n.jsx(jn,{p:d,value:M.values[d.key],locale:c,disabled:!1,onBegin:()=>{},onChange:f=>K(y=>y&&{...y,values:{...y.values,[d.key]:f}})},d.key))}),a&&n.jsx("small",{className:t?"muted":"tl-warn",children:t?e("Áp dụng cho clip đang chọn: {0}",[t.label]):e("Chọn một clip trên timeline trước khi chạy.")}),n.jsxs("div",{className:"tl-plugin-review-actions",children:[n.jsx("button",{className:"pill-btn accent",disabled:!!G||a&&!t||!s?.enabled,onClick:()=>void vi(),children:G===M.id?e("Đang chạy…"):e("Chạy công thức")}),n.jsx("button",{className:"pill-btn",onClick:()=>K(null),children:e("Đóng")})]})]})})(),P&&(()=>{const i=P.bundle.manifest,s=g?.find(f=>f.id===P.id),a=zn().length,d=G===`ai:${P.id}`;return n.jsxs("div",{className:"tl-plugin-recipe tl-plugin-ai",role:"group","aria-label":e("Mẫu AI {0}",[_(i,c)]),children:[n.jsxs("h5",{children:["✎ ",_(i,c)," ",n.jsxs("small",{className:"muted",children:["v",i.version," · ",e("Mẫu AI")]})]}),n.jsx("p",{className:"muted",children:mn(i,c)}),i.params.length>0&&n.jsx("div",{className:"tl-plugin-params",children:i.params.map(f=>n.jsx(jn,{p:f,value:P.values[f.key],locale:c,disabled:d,onBegin:()=>{},onChange:y=>on(w=>w&&{...w,values:{...w.values,[f.key]:y},price:void 0})},f.key))}),n.jsx("small",{className:t&&a?"muted":"tl-warn",children:t?a?e("Đọc lời thoại của: {0}",[t.label]):e("Clip “{0}” chưa có lời thoại — bấm Transcript cho clip trước.",[t.label]):e("Chọn clip có lời thoại trên timeline.")}),P.price!==void 0&&!P.doc&&n.jsx("p",{className:"tl-plugin-note",role:"status",children:e("Tối đa {0} credit — tính theo lượng AI thật sự viết, thường ít hơn.",[P.price])}),n.jsxs("div",{className:"tl-plugin-review-actions",children:[P.price===void 0||P.doc?n.jsxs("button",{className:"pill-btn accent",disabled:!!G||!t||!a||!s?.enabled,onClick:()=>void fi(),children:[d?n.jsx("i",{className:"spin"}):null,e("Xem giá")]}):n.jsxs("button",{className:"pill-btn accent",disabled:!!G,onClick:()=>void bi(),children:[d?n.jsx("i",{className:"spin"}):null,e("Chạy (tối đa {0} credit)",[P.price])]}),n.jsx("button",{className:"pill-btn",onClick:()=>on(null),children:e("Đóng")})]}),P.doc&&n.jsxs("div",{className:"tl-plugin-doc",children:[n.jsx("textarea",{readOnly:!0,"aria-label":e("Tài liệu AI"),value:P.doc.format==="json"&&P.doc.json!==void 0?JSON.stringify(P.doc.json,null,2):P.doc.text}),n.jsxs("div",{className:"tl-plugin-review-actions",children:[n.jsx("button",{className:"pill-btn thin",onClick:()=>{navigator.clipboard?.writeText(P.doc.text),p(e("Đã chép tài liệu"),"ok")},children:e("Chép")}),n.jsx("button",{className:"pill-btn thin",onClick:()=>ji(P.doc),children:P.doc.format==="json"?e("Tải .json"):e("Tải .md")}),n.jsx("small",{className:"muted",children:e("{0} credit · đã gửi tới webhook (nếu có)",[P.doc.credits])})]})]})]})})(),x&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",e("Không tải được danh sách plug-in: {0}",[x])]}),g===null&&!x&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải plug-in…")]}),g&&!g.length&&!r&&n.jsxs("div",{className:"tl-plugins-empty",children:[n.jsx("b",{"aria-hidden":!0,children:"⧉"}),n.jsx("strong",{children:e("Chưa có plug-in nào")}),n.jsx("p",{children:e("Plug-in thêm hiệu ứng motion, hoạt ảnh Lottie, công thức chỉnh sửa nhanh hoặc gói âm thanh do cộng đồng làm. Chọn trong Kho Plug-in, hoặc thêm file .clipoox-plugin bạn có.")}),n.jsxs("button",{className:"pill-btn accent",onClick:()=>S(!0),children:["🛍 ",e("Mở Kho Plug-in")]}),n.jsxs("button",{className:"pill-btn",onClick:()=>O(!0),children:["📘 ",e("Đọc hướng dẫn làm plug-in")]}),n.jsxs("div",{className:"tl-plugins-samples",children:[n.jsx("small",{className:"muted",children:e("Thử {0} plug-in mẫu:",[si.length])}),si.map(i=>n.jsxs("a",{className:"pill-btn thin",href:`/plugin-samples/${i.file}`,download:!0,children:[Bn(i.kind,c)," ⤓"]},i.file))]})]}),fn.length>0&&n.jsx("div",{className:"tl-plugin-grid",children:fn.map(Vn)}),(()=>{const i=tn?fn.find(s=>s.id===tn&&s.kind==="sfxlib"):void 0;return i?n.jsxs("section",{className:"tl-plugin-pack","aria-label":e("Âm thanh trong {0}",[_(i.manifest,c)]),children:[n.jsx("small",{className:"muted sfxlib-hint",children:e("cũng có trong mục SFX (tab Âm thanh)")}),n.jsx(Ki,{item:i,busy:Sn,onAdd:s=>void Jn(s)})]}):null})(),(()=>{const i=tn?fn.find(s=>s.id===tn&&s.kind==="sfx"):void 0;return i?n.jsxs("section",{className:"tl-plugin-pack","aria-label":e("Âm thanh trong {0}",[_(i.manifest,c)]),children:[n.jsxs("h5",{children:["♪ ",_(i.manifest,c)," ",n.jsxs("small",{className:"muted",children:[e("{0} âm thanh",[i.manifest.sounds?.length??0])," · ",e("cũng có trong mục SFX (tab Âm thanh)")]})]}),n.jsx(Fi,{packs:[i],busy:Sn,showPack:!1,onAdd:s=>void Jn(s)})]}):null})(),(()=>{const i=B?fn.find(m=>m.id===B.id&&m.kind==="pack"):void 0;if(!i||!B)return null;const s=B.index,a=Nn(i.manifest),d=s?.manifest.controls??[],f=s?.manifest.categories??[],y=pn[i.id]??{},w=s?s.items.filter(m=>vn==="all"||m.manifest.category===vn):[],L=a&&d.length?yi(i.id).length:0;return n.jsxs("section",{className:`tl-plugin-pack${a?" kit":""}`,"aria-label":e("Các mục trong {0}",[_(i.manifest,c)]),children:[n.jsxs("h5",{children:[a?"◈":"⧉"," ",_(i.manifest,c)," ",n.jsxs("small",{className:"muted",children:[e("{0} mục",[i.manifest.items?.length??0]),li(i)," · ",a?e("bấm một mục để thêm vào playhead; look áp lên clip đang chọn"):e("bấm một mục để thêm vào playhead; công thức chạy trên clip đang chọn")]})]}),B.error&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",B.error]}),!s&&!B.error&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải gói…")]}),d.length>0&&n.jsxs("div",{className:"tl-kit-controls",role:"group","aria-label":e("Điều khiển chung của bộ"),children:[n.jsxs("h6",{children:[e("Điều khiển chung của bộ")," ",n.jsx("small",{className:"muted",children:e("áp cho mọi mục có 🔗")})]}),n.jsx("div",{className:"tl-plugin-params",children:d.map(m=>n.jsxs("div",{className:"tl-kit-control",children:[n.jsx(jn,{p:m,value:y[m.key],locale:c,disabled:!1,onBegin:()=>{},onChange:$=>Wn(i.id,{...y,[m.key]:$})}),m.type==="color"&&n.jsx("span",{className:"tl-kit-swatches",role:"group","aria-label":e("Màu gợi ý"),children:Se.map($=>n.jsx("button",{type:"button",className:String(y[m.key]).toLowerCase()===$?"on":"",style:{background:$},"aria-label":$,onClick:()=>Wn(i.id,{...y,[m.key]:$})},$))})]},m.key))}),n.jsx("button",{className:"pill-btn thin",disabled:j||!L||!s,onClick:()=>s&&Ni(i,s),children:e("Áp cho {0} lớp của bộ trong dự án",[L])})]}),f.length>0&&s&&n.jsx("div",{className:"tl-kit-chips",role:"group","aria-label":e("Nhóm"),children:[{id:"all",name:{vi:"Tất cả",en:"All"}},...f].map(m=>{const $=m.id==="all"?s.items.length:s.items.filter(q=>q.manifest.category===m.id).length;return $||m.id==="all"?n.jsxs("button",{type:"button",className:`tl-kit-chip${vn===m.id?" on":""}`,"aria-pressed":vn===m.id,onClick:()=>Kn(m.id),children:[m.name[c==="en"?"en":"vi"]," ",n.jsx("span",{children:$})]},m.id):null})}),s&&n.jsx("div",{className:`tl-plugin-items${a?" kit":""}`,children:w.map(({manifest:m,thumbnail:$})=>{const q=`${i.id}/${m.id}`,E=a?ye(m,c):"";return n.jsxs("button",{className:"tl-plugin-item","data-item":m.id,"data-kind":m.kind,disabled:!!G,title:mn(m,c),"aria-label":m.kind==="recipe"?e("Mở công thức {0}",[_(m,c)]):m.kind==="lut"?e("Áp look {0} cho clip đang chọn",[_(m,c)]):e("Thêm {0}",[_(m,c)]),onClick:()=>void xi(i,m.id),children:[n.jsxs("span",{className:"tl-plugin-thumb",children:[$?n.jsx("img",{src:`data:${$.type};base64,${$.data}`,alt:""}):n.jsx("b",{children:m.kind==="analyzer"?"⌖":m.kind==="ai-template"?"✎":m.kind==="recipe"?"▶":m.kind==="model"?"◈":m.kind==="lut"?"◐":"✦"}),E&&n.jsx("span",{className:`tl-kit-badge ${m.kind}`,children:E}),G===q&&n.jsx("i",{className:"spin"})]}),n.jsxs("span",{className:"tl-plugin-name",children:[n.jsx("strong",{children:_(m,c)}),n.jsxs("small",{children:[$n(m,c),m.duration?` · ${m.duration} s`:""]})]})]},m.id)})})]})})(),Cn.length>0&&n.jsxs("details",{className:"tl-plugin-off",children:[n.jsx("summary",{children:e("Đã tắt ({0})",[Cn.length])}),n.jsx("div",{className:"tl-plugin-grid",children:Cn.map(Vn)})]}),g&&g.length>0&&n.jsx("small",{className:"muted tl-plugins-foot",children:e("{0} / 50 plug-in · chỉ tài khoản của bạn thấy · bấm để thêm vào playhead",[g.length])}),g&&n.jsx(xe,{toast:p}),v&&n.jsx(ke,{onClose:()=>O(!1)}),cn&&n.jsx(N.Suspense,{fallback:null,children:n.jsx(fe,{installed:g??[],initialId:Z,onClose:()=>S(!1),onInstalled:()=>void Q(),onUse:gi,toast:p})})]})}function jn({p:t,value:l,locale:o,disabled:h,onBegin:j,onChange:u,onImage:A,media:p,linked:c}){const g=An(t,o),k=l??t.default;if(c&&t.type!=="asset"){const x=n.jsx(jn,{p:t,value:l,locale:o,disabled:h,onBegin:j,onChange:u,onImage:A});return n.jsxs("div",{className:"tl-plugin-linked",children:[x,n.jsxs("span",{className:"tl-plugin-link",title:e("Theo điều khiển chung của bộ"),children:["🔗 ",e("theo bộ")]})]})}if(t.type==="asset"){const x=t.accept==="model"?"model":"image",T=(p??[]).filter(b=>b.kind===x&&typeof b.gcsUri=="string"),r=T.find(b=>b.gcsUri===k);return n.jsxs("div",{className:"tl-motion-param tl-plugin-image tl-plugin-asset",children:[n.jsx("span",{children:g}),n.jsxs("span",{children:[r&&x==="image"&&r.url?n.jsx("img",{src:r.url,alt:""}):n.jsx("i",{title:x==="model"?e("Chưa chọn GLB"):e("Chưa chọn ảnh"),children:x==="model"?"◈":""}),n.jsxs("select",{"aria-label":g,value:typeof k=="string"?k:"",disabled:h,onFocus:j,onChange:b=>u(b.target.value),children:[n.jsx("option",{value:"",children:x==="model"?e("— Mẫu của bộ (không dùng GLB của bạn) —"):e("— Không dùng ảnh —")}),T.map(b=>n.jsx("option",{value:b.gcsUri,children:String(b.label||b.gcsUri.split("/").pop()).slice(0,40)},b.gcsUri))]})]}),!T.length&&n.jsx("small",{className:"muted",children:x==="model"?e("Thêm file .glb vào Media trước (kéo thả vào Media)."):e("Thêm ảnh PNG / JPEG / WebP vào Media trước.")})]})}return t.type==="boolean"?n.jsxs("label",{className:"tl-motion-param check",children:[n.jsx("input",{type:"checkbox","aria-label":g,checked:!!k,disabled:h,onChange:x=>{j(),u(x.target.checked)}}),g]}):t.type==="number"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsx(Li,{"aria-label":g,value:Number(k),min:t.min,max:t.max,precision:3,disabled:h,onCommit:x=>{j(),u(Yi(t,x))}})]}):t.type==="color"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsxs("span",{className:"tl-motion-color",children:[n.jsx("input",{type:"color","aria-label":g,value:String(k),disabled:h,onFocus:j,onChange:x=>u(x.target.value)}),n.jsx("code",{children:String(k)})]})]}):t.type==="select"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsx("select",{"aria-label":g,value:String(k),disabled:h,onFocus:j,onChange:x=>u(x.target.value),children:t.options.map(x=>n.jsx("option",{value:x.value,children:An({...t,label:x.label},o)},x.value))})]}):t.type==="image"?n.jsxs("div",{className:"tl-motion-param tl-plugin-image",children:[n.jsx("span",{children:g}),n.jsxs("span",{children:[typeof k=="string"&&k.startsWith("data:")?n.jsx("img",{src:k,alt:""}):n.jsx("i",{title:e("Ảnh mặc định")}),n.jsx(Te,{label:g,disabled:h,onPick:x=>A?.(x)})]})]}):n.jsxs("label",{className:"tl-motion-param tl-plugin-text",children:[g,t.multiline?n.jsx("textarea",{"aria-label":g,rows:2,value:String(k),maxLength:t.maxLength,disabled:h,onFocus:j,onKeyDown:x=>x.stopPropagation(),onChange:x=>u(x.target.value)}):n.jsx("input",{type:"text","aria-label":g,value:String(k),maxLength:t.maxLength,disabled:h,onFocus:j,onKeyDown:x=>x.stopPropagation(),onChange:x=>u(x.target.value)})]})}function Te({label:t,disabled:l,onPick:o}){const h=N.useRef(null);return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"pill-btn thin",disabled:l,onClick:()=>h.current?.click(),children:e("Chọn ảnh…")}),n.jsx("input",{ref:h,type:"file",hidden:!0,"aria-label":t,accept:"image/png,image/jpeg,image/webp",onChange:j=>{const u=j.target.files?.[0];j.target.value="",u&&o(u)}})]})}function $e({clip:t,pref:l,item:o,materials:h,locked:j,onPatch:u,toast:A,fail:p}){const c=wn(),[g,k]=N.useState(null),[x,T]=N.useState({}),[r,b]=N.useState(!1),G=l.kind==="motion"||l.kind==="lottie"||l.kind==="recipe";if(N.useEffect(()=>{let S=!0;return o&&G&&(l.item?ri(o,l.item):oi(o)).then(M=>{S&&k(M)},()=>{}),()=>{S=!1}},[o,l.item,G]),l.kind==="model")return n.jsxs("section",{className:"tl-plugin-inspector",children:[n.jsxs("h5",{children:["◈ ",t.label]}),n.jsx("small",{className:"muted",children:e("Lớp 3D từ bộ “{0}”. Xoay, keyframe, chuyển động 3D, animation của GLB và camera Timeline chỉnh ở tab 3D. Gỡ bộ thì lớp vẫn giữ.",[o?_(o.manifest,c):l.id])})]});const C=g?.manifest??(l.item?void 0:o?.manifest);if(!C&&l.item&&o)return n.jsxs("section",{className:"tl-plugin-inspector",children:[n.jsx("h5",{children:e("Lớp plug-in")}),n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải gói…")]})]});if(!C)return n.jsxs("section",{className:"tl-plugin-inspector",children:[n.jsx("h5",{children:e("Lớp plug-in")}),n.jsx("small",{className:"muted",children:e("Plug-in này đã gỡ khỏi tài khoản. Lớp vẫn chạy bình thường; tham số motion vẫn sửa được ở tab Edit.")})]});const rn=o&&yn(o.version,l.v)>0,V=l.kind==="motion"?{...J(C,{}),...t.motion?.params}:{...J(C,l.params??{}),...x},Z=(S,M)=>{if(!t.motion)return;const K=C.params.find(F=>F.key===S)?.type==="asset",B={...t.motion.assets??{}};K&&(delete B[`@${S}`],typeof M=="string"&&M&&(B[`@${S}`]=M)),u(t.id,{motion:{...t.motion,params:{...t.motion.params,[S]:M},...K?{assets:B}:{}}},!1)},v=Object.keys(x).length>0,O=async(S,M)=>{if(g?.lottie){b(!0);try{const K=S?g.lottie:{data:await Oi(t.url)},B=await On(l.id,await En(K,C,M)),F=S?o?.version??C.version:l.v;u(t.id,{url:B.url,gcsUri:B.gcsUri,...S?{lottie:{...g.lottie.meta,loop:t.lottie?.loop??C.loop!==!1}}:{},plugin:{id:l.id,...l.item?{item:l.item}:{},v:F,kind:"lottie",params:In(C,M)}},!0),T({}),A(e("Đã áp dụng tham số plug-in"),"ok")}catch(K){p(K)}finally{b(!1)}}},cn=async()=>{if(g){if(l.kind==="motion"&&t.motion){const S=Object.fromEntries(Object.entries(t.motion.params??{}).filter(([F])=>C.params.some(pn=>pn.key===F))),M=l.item?ci(l.id,l.item,g,S):di(C,g.entry,S),K=o?.version??C.version;let B={};try{C.uses?.length&&(B=ee(await te(l.id,C.uses)))}catch(F){p(F);return}for(const F of C.params)F.type==="asset"&&typeof S[F.key]=="string"&&S[F.key]&&(B[`@${F.key}`]=S[F.key]);u(t.id,{motion:{...M,...Object.keys(B).length?{assets:B}:{}},plugin:{id:l.id,...l.item?{item:l.item}:{},v:K,kind:"motion"}},!0),A(e("Đã cập nhật lớp lên v{0}",[K]),"ok");return}O(!0,V)}};return n.jsxs("section",{className:"tl-plugin-inspector","aria-label":e("Tham số plug-in"),children:[n.jsxs("h5",{children:["⧉ ",_(C,c)," ",n.jsxs("small",{className:"muted",children:["v",l.v]})]}),rn&&n.jsxs("button",{className:"pill-btn thin tl-plugin-update",disabled:j||r||!g,onClick:()=>void cn(),children:["↑ ",e("Cập nhật lớp lên v{0}",[o.version])]}),C.params.length?n.jsx("div",{className:"tl-plugin-params",children:C.params.map(S=>n.jsx(jn,{p:S,value:V[S.key],locale:c,disabled:j||r,media:h,linked:!!S.link,onBegin:()=>{l.kind==="motion"&&u(t.id,{},!0)},onChange:M=>{l.kind==="motion"?Z(S.key,M):T(K=>({...K,[S.key]:M}))},onImage:M=>void Qi(M).then(K=>T(B=>({...B,[S.key]:K})),p)},S.key))}):n.jsx("small",{className:"muted",children:e("Plug-in này không có tham số.")}),l.kind==="lottie"&&n.jsxs("div",{className:"tl-plugin-review-actions",children:[n.jsx("button",{className:"pill-btn accent",disabled:j||r||!v||!g,onClick:()=>void O(!1,V),children:r?e("Đang áp dụng…"):e("Áp dụng")}),n.jsx("button",{className:"pill-btn",disabled:j||r||!g,title:e("Về hoạt ảnh gốc của plug-in với giá trị mặc định"),onClick:()=>void O(!0,J(C,{})),children:e("Đặt lại")})]}),l.kind==="motion"&&n.jsx("small",{className:"muted",children:e("Thay đổi hiện ngay trên Monitor. Code của lớp ở tab Edit.")}),l.kind==="motion"&&t.motion?.assets&&n.jsxs("div",{className:"tl-plugin-assets",children:[n.jsx("small",{className:"muted",children:e("Tài nguyên của lớp (đã chép vào dự án — gỡ bộ vẫn giữ)")}),n.jsx("ul",{children:Object.keys(t.motion.assets).map(S=>n.jsxs("li",{children:[n.jsx("b",{children:S.startsWith("@")?e("của bạn: {0}",[An(C.params.find(M=>`@${M.key}`===S)??{key:S.slice(1),label:{vi:S.slice(1),en:S.slice(1)}},c)]):S}),n.jsx("span",{children:"✓"})]},S))})]})]})}const qe=Object.freeze(Object.defineProperty({__proto__:null,default:Pe},Symbol.toStringTag,{value:"Module"}));export{qe as T,X as p};