clipoox-render 0.4.2 → 0.4.3

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 (105) hide show
  1. package/package.json +1 -1
  2. package/scripts/render-local.mjs +1322 -1320
  3. package/web/assets/{FxEmbed-CGqGi2Lw.js → FxEmbed-BCmj9Q5C.js} +1 -1
  4. package/web/assets/{MotionEmbed-C3CZ3_y_.js → MotionEmbed-CEmbcq8Z.js} +1 -1
  5. package/web/assets/PluginStore-C5hyahvG.js +3 -0
  6. package/web/assets/{ShotComposer-DFfaYLoV.js → ShotComposer-0DUtMTVI.js} +4 -4
  7. package/web/assets/{TemplateEmbed-C8pXcPsc.js → TemplateEmbed-ANxSs7H5.js} +1 -1
  8. package/web/assets/{TimelinePlugins-DnkV3i4G.js → TimelinePlugins-BYZ9y4m3.js} +4 -4
  9. package/web/assets/{TimelinePlugins-DYarX9RK.css → TimelinePlugins-D841ngau.css} +1 -1
  10. package/web/assets/{TimelineShotFx-foiuuogg.js → TimelineShotFx-q5PQwq-V.js} +2 -2
  11. package/web/assets/{TransitionEmbed-BueDilY0.js → TransitionEmbed-O6LInGWq.js} +1 -1
  12. package/web/assets/{Whiteboard-zBsNHh5h.js → Whiteboard-BP_DvIAV.js} +1 -1
  13. package/web/assets/{aerial-z34Nww_T.js → aerial-CGLDKKtP.js} +2 -2
  14. package/web/assets/{agentTools-ALxghYpf.js → agentTools-2Ghb80VH.js} +2 -2
  15. package/web/assets/{analyzerRun-DNwryAlU.js → analyzerRun-DRgxrcJA.js} +1 -1
  16. package/web/assets/{analyzerSandbox-A1oFsCrO.js → analyzerSandbox-DuIVFnsk.js} +1 -1
  17. package/web/assets/{api-DUp403BK.js → api-CJ8PdbfZ.js} +5 -5
  18. package/web/assets/{auraTrack-BKVZCwNt.js → auraTrack-DQw9sVU6.js} +1 -1
  19. package/web/assets/{breakthrough-Cwt8gEwK.js → breakthrough-BNj_iTDr.js} +2 -2
  20. package/web/assets/{cameraPresets-DSOPj4oy.js → cameraPresets-CYw0OdM3.js} +1 -1
  21. package/web/assets/{captionLayout-EuB59pN_.js → captionLayout-DvDPTwO9.js} +1 -1
  22. package/web/assets/{clientExport-BL1XMTF0.js → clientExport-xhoXY6Dh.js} +1 -1
  23. package/web/assets/conversion-4rhF3xRJ.js +17 -0
  24. package/web/assets/{depthEstimate-DOvsY8mn.js → depthEstimate-DEpeCojm.js} +1 -1
  25. package/web/assets/{directorTools-BkbNYbSq.js → directorTools-C5CpTmci.js} +1 -1
  26. package/web/assets/{distortFrames-Drch0LhT.js → distortFrames-Dia8O1NM.js} +2 -2
  27. package/web/assets/{distortGL-BlmBZKRU.js → distortGL-QalhICvi.js} +1 -1
  28. package/web/assets/{editTools-BcGinqHC.js → editTools-CY_JrQfw.js} +1 -1
  29. package/web/assets/engine-BedcnK45.js +1 -0
  30. package/web/assets/{exportEncode-MUwVTI52.js → exportEncode-QYsT9JBO.js} +1 -1
  31. package/web/assets/{exportGlb-SIXFRRJM.js → exportGlb-TSj09XoV.js} +1 -1
  32. package/web/assets/{faceTracker-DCbZbLMc.js → faceTracker-CnCWOwnJ.js} +1 -1
  33. package/web/assets/{fightDirector-hlF1JS_z.js → fightDirector-DCI_FWTh.js} +1 -1
  34. package/web/assets/{fightDrama-fHN5EXk3.js → fightDrama-Bg7uP_2Q.js} +2 -2
  35. package/web/assets/{frameSink-BvOXjLuw.js → frameSink-DeM8xC8_.js} +3 -3
  36. package/web/assets/{gpuCompose-CNkLwpbZ.js → gpuCompose-CA3UmOl4.js} +1 -1
  37. package/web/assets/{gpuExport-DQB6x4eh.js → gpuExport-D31azOQA.js} +13 -9
  38. package/web/assets/{handMatte-BD7OE3Zc.js → handMatte-Dl-xVXFR.js} +1 -1
  39. package/web/assets/{handTracker-BumGtRCW.js → handTracker-CplBsAFg.js} +2 -2
  40. package/web/assets/{id3-BCR9Bqgo.js → id3-arvEpAg7.js} +1 -1
  41. package/web/assets/{index-CuaB7Y0L.js → index-D5oyVCRl.js} +1 -1
  42. package/web/assets/index-_tSTJnL9.js +8 -0
  43. package/web/assets/layer-worker-DFuo32bk.js +5 -0
  44. package/web/assets/library-BufgA-Pl.js +1 -0
  45. package/web/assets/{lottieLayer-1ET89OUr.js → lottieLayer-DzbA3bHV.js} +4 -4
  46. package/web/assets/{lottie_light_canvas-DD9pkFL8.js → lottie_light_canvas-B-d7-ATe.js} +1 -1
  47. package/web/assets/main-VVYiW8XD.js +309 -0
  48. package/web/assets/{mapBake-DLoBt_k5.js → mapBake-BKOcEd0w.js} +1 -1
  49. package/web/assets/maskTrack-CHGXtBRy.js +1 -0
  50. package/web/assets/{matteFixRun-BdHKC3m5.js → matteFixRun-vgYrINet.js} +1 -1
  51. package/web/assets/{objectLocate-bZtc5AJo.js → objectLocate-BJltm8Ob.js} +1 -1
  52. package/web/assets/{output-BwZzMbp-.js → output-p-Q7qous.js} +1 -1
  53. package/web/assets/{pendingMatte-mlyLLZCT.js → pendingMatte-BPyzzx4y.js} +2 -2
  54. package/web/assets/{personAi-CUNQeseG.js → personAi-gJu03SjU.js} +2 -2
  55. package/web/assets/{plateCamera-_jP1xXnj.js → plateCamera-B2JvhjJw.js} +1 -1
  56. package/web/assets/{plateCameraMatch-rr0oUwQ2.js → plateCameraMatch-ByB9nVQT.js} +2 -2
  57. package/web/assets/{plateFollow-BjvtcT8q.js → plateFollow-C9S-l7RH.js} +2 -2
  58. package/web/assets/{plateMatte-BqyL8cQZ.js → plateMatte-J4qlNHnY.js} +2 -2
  59. package/web/assets/{pluginAutomation-Dp188qm7.js → pluginAutomation-CkP3tA9r.js} +1 -1
  60. package/web/assets/{poseTracker-DDGDhhMF.js → poseTracker-DGLbouqt.js} +1 -1
  61. package/web/assets/{productTools-CRgI88-O.js → productTools-CkaWF1bM.js} +2 -2
  62. package/web/assets/remote-C7J0Tqhb.js +1433 -0
  63. package/web/assets/{rigTrack-UYZU4P-e.js → rigTrack-urT3nDK0.js} +1 -1
  64. package/web/assets/{rotoMaskStore-BxyxB2bD.js → rotoMaskStore-DPziPKAN.js} +1 -1
  65. package/web/assets/{rotoMatte-BdYa8FSB.js → rotoMatte-C-2o3vv0.js} +1 -1
  66. package/web/assets/{rotoscope-DDixNQCt.js → rotoscope-GvPFRUBg.js} +1 -1
  67. package/web/assets/{shot-worker-D9sZS6bn.js → shot-worker-6dYkHPoL.js} +1 -1
  68. package/web/assets/{shotFxAgent-7RQNtEe4.js → shotFxAgent-BFLkqs8v.js} +1 -1
  69. package/web/assets/{skin-CVwmK130.js → skin-DY4QLaBI.js} +1 -1
  70. package/web/assets/{spark.module-B34aiScb.js → spark.module-DzziUgOj.js} +1 -1
  71. package/web/assets/{spellDuel-BkweL6pI.js → spellDuel-BD3m2ebA.js} +2 -2
  72. package/web/assets/store-Cug4GGcP.js +1 -0
  73. package/web/assets/{store-75tQUvPT.js → store-DW4E9xnW.js} +1 -1
  74. package/web/assets/{surfaceLight-DhU-zgNL.js → surfaceLight-aDSYU8Jg.js} +1 -1
  75. package/web/assets/surfacePin-m83hCgGP.js +2 -0
  76. package/web/assets/{textAnimators-nVSz_sZo.js → textAnimators-DUZjhVGO.js} +1 -1
  77. package/web/assets/{thumb-r6dlZprA.js → thumb-CS0ZuiGS.js} +1 -1
  78. package/web/assets/{timeline3d-246tBEJl.js → timeline3d-DOw-CpZI.js} +2 -2
  79. package/web/assets/{timeline3dExport-T57qnWi9.js → timeline3dExport-BtYLU1pw.js} +1 -1
  80. package/web/assets/{timelineComp-BcewYGR2.js → timelineComp-B4GtoH2f.js} +1 -1
  81. package/web/assets/{timelineProps-CJzzAWWO.js → timelineProps-D7MVutxu.js} +1 -1
  82. package/web/assets/{timelineText-BzUhNWPB.js → timelineText-BH09jfSM.js} +1 -1
  83. package/web/assets/{titleArt-B8DVR58F.js → titleArt-Drsrtfiv.js} +3 -3
  84. package/web/assets/{titleFrameBudget-BYRZAQPs.js → titleFrameBudget-CLZWaFHO.js} +1 -1
  85. package/web/assets/{titleFrames-BVgm601q.js → titleFrames-BI1DnLBn.js} +1 -1
  86. package/web/assets/{tool-CAGU3dUa.js → tool-DktQYmS6.js} +1 -1
  87. package/web/assets/{tools-DVaOkokV.js → tools-Co9aRDiT.js} +1 -1
  88. package/web/assets/{toonTools-CfGTR_H1.js → toonTools-CD9clJvN.js} +2 -2
  89. package/web/assets/{trackAnchor-DzUt1r5Q.js → trackAnchor-sOjTtd3I.js} +1 -1
  90. package/web/assets/{userFonts-DzY0A4bD.js → userFonts-CwlKh9NR.js} +1 -1
  91. package/web/assets/{vfxAlpha-DQJOaZ9v.js → vfxAlpha-71tSN86T.js} +2 -2
  92. package/web/assets/{vfxBackground-DiktQFOD.js → vfxBackground-Bq7lJvmZ.js} +2 -2
  93. package/web/assets/{videoExport-Ce0ElSQR.js → videoExport-D4KbireJ.js} +1 -1
  94. package/web/assets/{views-V3si1lOz.js → views-ozVF4ABO.js} +1 -1
  95. package/web/assets/{weaponDuel-D6sLVGmG.js → weaponDuel-ZhX-tjGZ.js} +1 -1
  96. package/web/assets/{windowFrames-D_2QJCJJ.js → windowFrames-CpqX3kOM.js} +1 -1
  97. package/web/layer-worker.html +3 -3
  98. package/web/assets/PluginStore-DKXZ-jBj.js +0 -3
  99. package/web/assets/index-DYa7fEK0.js +0 -24
  100. package/web/assets/layer-worker-DxPMMKIZ.js +0 -5
  101. package/web/assets/library-CyjJ8nGG.js +0 -1
  102. package/web/assets/main-BKjBWQik.js +0 -309
  103. package/web/assets/maskTrack-C2SJbDGO.js +0 -1
  104. package/web/assets/remote-Dva2qg58.js +0 -1241
  105. package/web/assets/surfacePin-ObK6QgDm.js +0 -2
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-BxyxB2bD.js","assets/titleFrameBudget-BYRZAQPs.js","assets/api-DUp403BK.js"])))=>i.map(i=>d[i]);
2
- import{_ as U}from"./titleFrameBudget-BYRZAQPs.js";import{gM as O,iY as j,fq as C,g1 as P,dU as L,jl as B,jm as E,jn as F,fU as $,f$ as D,g0 as I}from"./remote-Dva2qg58.js";import"./api-DUp403BK.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";const T=["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,q=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 T)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(!C(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=L(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=q(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=B((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,M=l;p.setStage(e=>({...e,items:k?[...e.items,M]:e.items.map(i=>i.id===_?M:i),shots:e.shots.map(i=>i.id===d.id?{...i,ball:{...i.ball,[_]:x}}:i)}));const S=h.find(e=>e.kind==="launch"&&Array.isArray(e.vel)),n=S&&S.kind==="launch"?F(S.from??M.position,S.vel,S.t,d.duration,{radius:r,restitution:M.ball?.restitution}).impacts.slice(0,8).map(e=>w(e.time)):void 0;return{ok:!0,name:M.name,created:k,...b?{hoop:"aimed through the rim centre, drops through the net"}:{},events: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 U(()=>import("./rotoMaskStore-BxyxB2bD.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}),M=Object.fromEntries(s.map(n=>[n.id,$(n,d,u).scale]));p.setStage(n=>a.applyDropKeys(n,d.id,_.tracks,{scale:M,lifted:r==="above"}));const S={};for(const n of s){const e=_.tracks[n.id];e&&(S[n.name]={keys:e.keys.length,rest:e.rest,settled_at:e.settledAt==null?null:w(o+e.settledAt)})}return{ok:!0,mode:r,from:w(o),until:w(o+k),objects:S,settled:_.settled,note:"baked into ordinary keys (no physics at playback); their keys after `from` were replaced. Run again with another seed for a different tumble."}}export{tt as addBall,et as physicsDrop,Z as setToon};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-DPziPKAN.js","assets/titleFrameBudget-CLZWaFHO.js","assets/api-CJ8PdbfZ.js"])))=>i.map(i=>d[i]);
2
+ import{_ as U}from"./titleFrameBudget-CLZWaFHO.js";import{gM as O,iY as j,fq as C,g1 as P,dU as L,jl as B,jm as E,jn as F,fU as $,f$ as D,g0 as I}from"./remote-C7J0Tqhb.js";import"./api-CJ8PdbfZ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";const T=["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,q=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 T)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(!C(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=L(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=q(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=B((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,M=l;p.setStage(e=>({...e,items:k?[...e.items,M]:e.items.map(i=>i.id===_?M:i),shots:e.shots.map(i=>i.id===d.id?{...i,ball:{...i.ball,[_]:x}}:i)}));const S=h.find(e=>e.kind==="launch"&&Array.isArray(e.vel)),n=S&&S.kind==="launch"?F(S.from??M.position,S.vel,S.t,d.duration,{radius:r,restitution:M.ball?.restitution}).impacts.slice(0,8).map(e=>w(e.time)):void 0;return{ok:!0,name:M.name,created:k,...b?{hoop:"aimed through the rim centre, drops through the net"}:{},events: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 U(()=>import("./rotoMaskStore-DPziPKAN.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}),M=Object.fromEntries(s.map(n=>[n.id,$(n,d,u).scale]));p.setStage(n=>a.applyDropKeys(n,d.id,_.tracks,{scale:M,lifted:r==="above"}));const S={};for(const n of s){const e=_.tracks[n.id];e&&(S[n.name]={keys:e.keys.length,rest:e.rest,settled_at:e.settledAt==null?null:w(o+e.settledAt)})}return{ok:!0,mode:r,from:w(o),until:w(o+k),objects:S,settled:_.settled,note:"baked into ordinary keys (no physics at playback); their keys after `from` were replaced. Run again with another seed for a different tumble."}}export{tt as addBall,et as physicsDrop,Z as setToon};
@@ -1 +1 @@
1
- import{b as v,gM as b,je as j,dH as $,jg as F,jh as y,ji as N}from"./remote-Dva2qg58.js";import{a as A}from"./shotFxAgent-7RQNtEe4.js";import{Vector3 as _}from"./three.module-Bx43vjkH.js";import"./api-DUp403BK.js";import"./titleFrameBudget-BYRZAQPs.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.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 M(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 B(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 M(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(([S])=>S!==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=M(r,f,n),p=t.track!=null?"given":t.source==="hand"?`hand:${t.side==="left"?"left":"right"}:${typeof t.point=="string"?t.point:"palm"}`:t.source==="object"&&typeof t.object=="string"?`object:${t.object}`:String(t.source),a=s?{...s,trackAnchor:{effect:o.id,source:p}}:{...v("sphere",r.items.length),name:`${o.name} · điểm bám`.slice(0,60),color:"#ffffff",trackAnchor:{effect:o.id,source:p}};a.position=m[0].position,a.rotation=[0,0,0],a.scale=[1,1,1];const u=m.map((i,e)=>({id:`${a.id}-t${e}`,time:i.t,position:i.position,rotation:[0,0,0],scale:[1,1,1]})),k={...o.fx,...l==="attach"?{attach:{to:a.id,follow:"position",...d?{offset:d}:{}}}:{target:{to:a.id,part:"center"}}};c.setStage(i=>({...i,items:[...i.items.filter(e=>e.id!==a.id).map(e=>e.id===o.id?{...e,fx:k}:e),a],shots:i.shots.map(e=>e.id===i.activeShot?{...e,objectKeys:{...e.objectKeys,[a.id]:u}}:e)}));const h=m.map(i=>i.d).sort((i,e)=>i-e),x=b(r).duration;return{ok:!0,name:o.name,anchor:a.name,source:p,role:l,samples:m.length,from_s:+f.points[0][0].toFixed(2),to_s:+f.points.at(-1)[0].toFixed(2),depth_m:+h[h.length>>1].toFixed(2),note:`${o.name} now ${l==="attach"?"rides on":"aims at"} the tracked point (${m.length} keys over ${x.toFixed(1)} s, ${n?`${n} m from the camera`:"at the filmed person's distance (the stand-in; run follow_plate first for a person who walks toward / away from the camera)"}). Re-run after the track changes; stop:true detaches. Export again (export_video vfx) to update the Timeline passes.`}}export{L as followTrack,B as scenePoint,M as trackWorldPoints};
1
+ import{b as v,gM as b,je as j,dH as $,jg as F,jh as y,ji as N}from"./remote-C7J0Tqhb.js";import{a as A}from"./shotFxAgent-BFLkqs8v.js";import{Vector3 as _}from"./three.module-Bx43vjkH.js";import"./api-CJ8PdbfZ.js";import"./titleFrameBudget-CLZWaFHO.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";const 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 M(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 B(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 M(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(([S])=>S!==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=M(r,f,n),p=t.track!=null?"given":t.source==="hand"?`hand:${t.side==="left"?"left":"right"}:${typeof t.point=="string"?t.point:"palm"}`:t.source==="object"&&typeof t.object=="string"?`object:${t.object}`:String(t.source),a=s?{...s,trackAnchor:{effect:o.id,source:p}}:{...v("sphere",r.items.length),name:`${o.name} · điểm bám`.slice(0,60),color:"#ffffff",trackAnchor:{effect:o.id,source:p}};a.position=m[0].position,a.rotation=[0,0,0],a.scale=[1,1,1];const u=m.map((i,e)=>({id:`${a.id}-t${e}`,time:i.t,position:i.position,rotation:[0,0,0],scale:[1,1,1]})),k={...o.fx,...l==="attach"?{attach:{to:a.id,follow:"position",...d?{offset:d}:{}}}:{target:{to:a.id,part:"center"}}};c.setStage(i=>({...i,items:[...i.items.filter(e=>e.id!==a.id).map(e=>e.id===o.id?{...e,fx:k}:e),a],shots:i.shots.map(e=>e.id===i.activeShot?{...e,objectKeys:{...e.objectKeys,[a.id]:u}}:e)}));const h=m.map(i=>i.d).sort((i,e)=>i-e),x=b(r).duration;return{ok:!0,name:o.name,anchor:a.name,source:p,role:l,samples:m.length,from_s:+f.points[0][0].toFixed(2),to_s:+f.points.at(-1)[0].toFixed(2),depth_m:+h[h.length>>1].toFixed(2),note:`${o.name} now ${l==="attach"?"rides on":"aims at"} the tracked point (${m.length} keys over ${x.toFixed(1)} s, ${n?`${n} m from the camera`:"at the filmed person's distance (the stand-in; run follow_plate first for a person who walks toward / away from the camera)"}). Re-run after the track changes; stop:true detaches. Export again (export_video vfx) to update the Timeline passes.`}}export{L as followTrack,B as scenePoint,M as trackWorldPoints};
@@ -1 +1 @@
1
- import{t as f,bZ as p,b_ as b,c as S,b$ as _,r as U}from"./api-DUp403BK.js";import{u as C}from"./store-75tQUvPT.js";import{i as w}from"./textAnimators-nVSz_sZo.js";import"./titleFrameBudget-BYRZAQPs.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)}),$=()=>U.useSyncExternalStore(E,()=>e),N=()=>e,x={ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2"},O=".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 q(t){await b(t.id),m(t.family),c({fonts:e.fonts.filter(o=>o.id!==t.id)})}export{O as FONT_ACCEPT,d as FONT_MAX_MB,x as FONT_TYPES,z as fontError,B as fontLabel,P as isMissingCustomFont,y as loadUserFonts,q as removeUserFont,L as uploadUserFont,$ as useUserFonts,v as userFontsReady,N as userFontsState};
1
+ import{t as f,bZ as p,b_ as b,c as S,b$ as _,r as U}from"./api-CJ8PdbfZ.js";import{u as C}from"./store-DW4E9xnW.js";import{i as w}from"./textAnimators-DUZjhVGO.js";import"./titleFrameBudget-CLZWaFHO.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)}),$=()=>U.useSyncExternalStore(E,()=>e),N=()=>e,x={ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2"},O=".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 q(t){await b(t.id),m(t.family),c({fonts:e.fonts.filter(o=>o.id!==t.id)})}export{O as FONT_ACCEPT,d as FONT_MAX_MB,x as FONT_TYPES,z as fontError,B as fontLabel,P as isMissingCustomFont,y as loadUserFonts,q as removeUserFont,L as uploadUserFont,$ as useUserFonts,v as userFontsReady,N as userFontsState};
@@ -1,4 +1,4 @@
1
- import{ic as D}from"./remote-Dva2qg58.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-DUp403BK.js";import"./titleFrameBudget-BYRZAQPs.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.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{i9 as D}from"./remote-C7J0Tqhb.js";import{FramebufferTexture as F,ShaderMaterial as S,Color as w,WebGLRenderTarget as k,NoColorSpace as O,HalfFloatType as A,UnsignedByteType as I}from"./three.module-Bx43vjkH.js";import"./api-CJ8PdbfZ.js";import"./titleFrameBudget-CLZWaFHO.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";const U=new S({uniforms:{tC:{value:null},tB:{value:null},tW:{value:null},uOcc:{value:0}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:`uniform sampler2D tC, tB, tW; uniform float uOcc; varying vec2 vUv;
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{ic as D}from"./remote-Dva2qg58.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,c,e)=>new k(t,c,{type:e?A:I,depthBuffer:e,samples:e?4:0,colorSpace:O});function j(t,c,e){const v=n(c,e,!0),i=n(c,e,!0),f=n(c,e,!1),g=new F(c,e),y=new D(U),T=new Uint8Array(c*e*4),B=new w(0,0,0),M=new w(1,1,1),C=(o,u,s,r)=>{const a=o.background,l=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(l)}},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,c,e,T);const r=s.createImageData(c,e),a=c*4;for(let l=0;l<e;l++)r.data.set(T.subarray((e-1-l)*a,(e-l)*a),l*a);s.putImageData(r,0,0)},occlusion(o,u,s=8){const r=Math.max(16,Math.round(c/s)),a=Math.max(16,Math.round(e/s)),l=n(r,a,!0),b=n(r,a,!0),x=n(r,a,!1),d=new Uint8Array(r*a*4);try{C(o,u,l,b),R(!0,l,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{l.dispose(),b.dispose(),x.dispose()}},dispose(){v.dispose(),i.dispose(),f.dispose(),g.dispose(),y.dispose()}}}export{j as createVfxAlpha};
9
+ }`,depthTest:!1,depthWrite:!1}),n=(t,l,e)=>new k(t,l,{type:e?A:I,depthBuffer:e,samples:e?4:0,colorSpace:O});function 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};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShotComposer-DFfaYLoV.js","assets/titleFrameBudget-BYRZAQPs.js","assets/remote-Dva2qg58.js","assets/api-DUp403BK.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-75tQUvPT.js","assets/rotoMaskStore-BxyxB2bD.js","assets/textAnimators-nVSz_sZo.js","assets/timelineComp-BcewYGR2.js","assets/rigTrack-UYZU4P-e.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/tool-CAGU3dUa.js","assets/timelineProps-CJzzAWWO.js","assets/thumb-r6dlZprA.js","assets/shotFxAgent-7RQNtEe4.js","assets/cameraPresets-DSOPj4oy.js","assets/weaponDuel-D6sLVGmG.js","assets/skin-CVwmK130.js","assets/views-V3si1lOz.js","assets/motionBlur-uAm030t9.js","assets/library-CyjJ8nGG.js","assets/ShotComposer-VixLbeMe.css"])))=>i.map(i=>d[i]);
2
- import{_ as l}from"./titleFrameBudget-BYRZAQPs.js";import{R as h}from"./api-DUp403BK.js";import{ds as w}from"./remote-Dva2qg58.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.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-DFfaYLoV.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};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShotComposer-0DUtMTVI.js","assets/titleFrameBudget-CLZWaFHO.js","assets/remote-C7J0Tqhb.js","assets/api-CJ8PdbfZ.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-DW4E9xnW.js","assets/rotoMaskStore-DPziPKAN.js","assets/textAnimators-DUZjhVGO.js","assets/timelineComp-B4GtoH2f.js","assets/rigTrack-urT3nDK0.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/tool-DktQYmS6.js","assets/timelineProps-D7MVutxu.js","assets/thumb-CS0ZuiGS.js","assets/shotFxAgent-BFLkqs8v.js","assets/cameraPresets-CYw0OdM3.js","assets/weaponDuel-ZhX-tjGZ.js","assets/skin-DY4QLaBI.js","assets/views-ozVF4ABO.js","assets/motionBlur-uAm030t9.js","assets/library-BufgA-Pl.js","assets/ShotComposer-VixLbeMe.css"])))=>i.map(i=>d[i]);
2
+ import{_ as l}from"./titleFrameBudget-CLZWaFHO.js";import{R as h}from"./api-CJ8PdbfZ.js";import{ds as w}from"./remote-C7J0Tqhb.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";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-0DUtMTVI.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};
@@ -1 +1 @@
1
- import{gK as S}from"./remote-Dva2qg58.js";import{s as U}from"./motionBlur-uAm030t9.js";import{M as Y}from"./motionBlur-uAm030t9.js";import{bD as C,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-DUp403BK.js";import"./titleFrameBudget-BYRZAQPs.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.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)||!S.includes(a))throw new Error("Khoảng thời gian hoặc FPS không hợp lệ");const g=new C({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,E=Math.min(1/a,r-b);await T(d+(n>1?e/(n-1):0)*r),await u.add(b,E,{keyFrame:e%a===0}),e%6===0&&(p(Math.round((e+1)/n*95)),await new Promise(F=>setTimeout(F,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};
1
+ import{gK as S}from"./remote-C7J0Tqhb.js";import{s as U}from"./motionBlur-uAm030t9.js";import{M as Y}from"./motionBlur-uAm030t9.js";import{bF as C,c as M}from"./id3-arvEpAg7.js";import{S as O,B as D,O as H,W as P,a as B,C as I}from"./output-p-Q7qous.js";import"./api-CJ8PdbfZ.js";import"./titleFrameBudget-CLZWaFHO.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.js";async function G(s,T,h){const{start:d,end:F,fps:a,signal:w,progress:p}=h,r=F-d,n=Math.ceil(r*a);if(!(r>0)||!Number.isFinite(r)||!S.includes(a))throw new Error("Khoảng thời gian hoặc FPS không hợp lệ");const g=new C({bitrate:h.height>=1080?6e6:3e6}),o=h.alpha===!0,f=o?"vp9":"avc",k=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()}.${k}`;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,x=Math.min(1/a,r-b);await T(d+(n>1?e/(n-1):0)*r),await u.add(b,x,{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 v=c?await c.getFile():new Blob([i.buffer],{type:o?"video/webm":"video/mp4"});return p(100),{blob:v,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};
@@ -1 +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-CVwmK130.js";import"./remote-Dva2qg58.js";import"./api-DUp403BK.js";import"./titleFrameBudget-BYRZAQPs.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.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};
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-DY4QLaBI.js";import"./remote-C7J0Tqhb.js";import"./api-CJ8PdbfZ.js";import"./titleFrameBudget-CLZWaFHO.js";import"./store-DW4E9xnW.js";import"./rotoMaskStore-DPziPKAN.js";import"./textAnimators-DUZjhVGO.js";import"./timelineComp-B4GtoH2f.js";import"./rigTrack-urT3nDK0.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};
@@ -1 +1 @@
1
- import{iC as pt,iD as Y,fo as ut,fn as mt,fq as Z,fs as R,hH as kt,b as gt,ft as bt,fD as tt,fE as et,hD as Mt,fU as yt,hG as wt}from"./remote-Dva2qg58.js";import{F as vt}from"./rigTrack-UYZU4P-e.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 ht(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),h=ht(t),o=At(t);let f=0;for(const l of a){if(Math.abs(l.t-h)>.1)continue;if(e.id==="fist"){const j=vt(l.pose),m=j[o.replace("foot","toe")];f=Math.max(f,m[2]-j.pelvis[2]);continue}const r=ut(l.pose),u=r.front[2]+r.dir[2]*jt[e.id];f=Math.max(f,u)}return f}function Dt(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 St(t,e=4,a=1){const h=Dt(a),o=[];let f=0,l=["",""];for(let r=0;r<e;r++){r>0&&h()<.62&&(f=1-f);const u=t[f],j=t[1-f],m=Object.keys(st[u]).filter(D=>D!==l[f]),g=m[Math.floor(h()*m.length)],T=st[u][g];l[f]=g;const i=h();let y=r===e-1?"body":i<.5?"blocked":i<.78?"miss":"body";y==="blocked"&&!it[T]&&(y="miss");const $=`${j}-${y==="blocked"?it[T]:y==="miss"?"dodge-back":"hit"}`,z=ht(g),O=P($).clip.contact??0,b=Math.max(Ft,$t(g)+Ot[y]+ot(g,z)+ot($,O));o.push({attacker:f,attack:g,defence:$,result:y,strike:z,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),H=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const a=v(t),h=a.duration/e,o=l=>l?.map(r=>({...r,time:Math.min(1,r.time*h)})),f={...a,duration:e,cameraKeys:o(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([l,r])=>[l,o(r)||[]])),...a.impacts?{impacts:o(a.impacts)}:{},...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([l,r])=>[l,o(r)||[]]))}:{}};return{...t,shots:t.shots.map(l=>l.id===a.id?f:l)}}const ct=(t,e,a)=>{const h=v(t);return{...t,shots:t.shots.map(o=>o.id===h.id?{...o,objectKeys:{...o.objectKeys,[e]:a(o.objectKeys?.[e]||[],o)}}:o)}},S=(t,e,a)=>{const h=v(t),o=yt(t.items.find(f=>f.id===e.id),h,Math.min(1,a/h.duration));return{position:o.position,yaw:o.rotation[1]}};function Pt(t,e,a){const h=t.items.find(s=>s.id===e.a),o=t.items.find(s=>s.id===e.b);if(!h||!o||!Z(h)||!Z(o))return{ok:!1,error:"two people are needed"};if(h.id===o.id)return{ok:!1,error:"two different people are needed"};const f=Math.max(1,Math.min(10,Math.round(e.exchanges))),l=St(e.packs,f,e.seed),r=[h,o],u=[nt(h),nt(o)],j=[],m=Math.max(0,e.start),g=v(t),T=m+.5+l.reduce((s,c)=>s+Math.max(R(c.attack).duration,c.strike-c.contact+R(c.defence).duration)+1.4+q[1],0);let i=T>g.duration?rt(t,Math.min(300,T)):t;const M=S(i,h,m),y=l[0].gap*(u[0]+u[1])/2,$=[Math.sin(H(M.yaw)),0,Math.cos(H(M.yaw))],z=[M.position[0]+$[0]*y,M.position[1],M.position[2]+$[2]*y];for(const[s,c,n]of[[h,M.position,M.yaw],[o,z,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=R(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,D=m;const C=[];let x=(e.seed*9301+49297)%233280;const lt=()=>(x=(x*9301+49297)%233280,x/233280);try{l.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const F=S(i,r[0],b).position,K=S(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,U=O(n,s.attack,w),ft=O(d,s.defence,_),G=r[n],B=S(i,G,w).yaw,W=[Math.sin(H(B)),Math.cos(H(B))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,E));i=ct(i,G.id,(F,K)=>F.map(A=>{const I=A.time*K.duration;if(I<w-1e-6||I>U+1e-6)return A;const L=Math.min(1,(I-w)/Math.max(.001,s.strike)),Q=L*L*(3-2*L),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:G.name}),D=Math.max(U,ft),b=D+q[0]+(q[1]-q[0])*lt(),c===l.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((D+.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=S(i,r[0],d.time).position,N=S(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:+D.toFixed(2),notes:j}}export{st as D,Pt as s};
1
+ import{iz as pt,iA as Y,fo as ut,fn as mt,fq as Z,fs as R,hH as kt,b as gt,ft as bt,fD as tt,fE as et,hD as Mt,fU as yt,hG as wt}from"./remote-C7J0Tqhb.js";import{F as vt}from"./rigTrack-urT3nDK0.js";const C=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},At=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(C(t).clip),at.set(t,e)),e},Ft=(t,e)=>t[Math.max(0,Math.min(t.length-1,Math.round(e*30)))];function ht(t){const e=C(t).clip.keys.filter(a=>a.strike).at(-1);return e?e.t:0}const Kt=t=>C(t).clip.keys.filter(e=>e.strike).at(-1)?.limb??"handR",ot=(t,e)=>Ft(dt(t),e).dz??0;function $t(t){const{pack:e}=C(t),a=dt(t),h=ht(t),o=Kt(t);let f=0;for(const l of a){if(Math.abs(l.t-h)>.1)continue;if(e.id==="fist"){const j=vt(l.pose),m=j[o.replace("foot","toe")];f=Math.max(f,m[2]-j.pelvis[2]);continue}const r=ut(l.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 h=St(a),o=[];let f=0,l=["",""];for(let r=0;r<e;r++){r>0&&h()<.62&&(f=1-f);const u=t[f],j=t[1-f],m=Object.keys(st[u]).filter(S=>S!==l[f]),g=m[Math.floor(h()*m.length)],D=st[u][g];l[f]=g;const i=h();let y=r===e-1?"body":i<.5?"blocked":i<.78?"miss":"body";y==="blocked"&&!it[D]&&(y="miss");const $=`${j}-${y==="blocked"?it[D]:y==="miss"?"dodge-back":"hit"}`,P=ht(g),O=C($).clip.contact??0,b=Math.max(At,$t(g)+Ot[y]+ot(g,P)+ot($,O));o.push({attacker:f,attack:g,defence:$,result:y,strike:P,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),H=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const a=v(t),h=a.duration/e,o=l=>l?.map(r=>({...r,time:Math.min(1,r.time*h)})),f={...a,duration:e,cameraKeys:o(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([l,r])=>[l,o(r)||[]])),...a.impacts?{impacts:o(a.impacts)}:{},...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([l,r])=>[l,o(r)||[]]))}:{}};return{...t,shots:t.shots.map(l=>l.id===a.id?f:l)}}const ct=(t,e,a)=>{const h=v(t);return{...t,shots:t.shots.map(o=>o.id===h.id?{...o,objectKeys:{...o.objectKeys,[e]:a(o.objectKeys?.[e]||[],o)}}:o)}},T=(t,e,a)=>{const h=v(t),o=yt(t.items.find(f=>f.id===e.id),h,Math.min(1,a/h.duration));return{position:o.position,yaw:o.rotation[1]}};function Ct(t,e,a){const h=t.items.find(s=>s.id===e.a),o=t.items.find(s=>s.id===e.b);if(!h||!o||!Z(h)||!Z(o))return{ok:!1,error:"two people are needed"};if(h.id===o.id)return{ok:!1,error:"two different people are needed"};const f=Math.max(1,Math.min(10,Math.round(e.exchanges))),l=Tt(e.packs,f,e.seed),r=[h,o],u=[nt(h),nt(o)],j=[],m=Math.max(0,e.start),g=v(t),D=m+.5+l.reduce((s,c)=>s+Math.max(R(c.attack).duration,c.strike-c.contact+R(c.defence).duration)+1.4+q[1],0);let i=D>g.duration?rt(t,Math.min(300,D)):t;const M=T(i,h,m),y=l[0].gap*(u[0]+u[1])/2,$=[Math.sin(H(M.yaw)),0,Math.cos(H(M.yaw))],P=[M.position[0]+$[0]*y,M.position[1],M.position[2]+$[2]*y];for(const[s,c,n]of[[h,M.position,M.yaw],[o,P,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=R(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 E=[];let x=(e.seed*9301+49297)%233280;const lt=()=>(x=(x*9301+49297)%233280,x/233280);try{l.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const A=T(i,r[0],b).position,F=T(i,r[1],b).position;return Math.hypot(F[0]-A[0],F[2]-A[2])};for(let A=0;A<3;A++){const F=p()-s.gap*k;if(Math.abs(F)<.3*k)break;F>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,z=p()-s.gap*k,U=O(n,s.attack,w),ft=O(d,s.defence,_),G=r[n],B=T(i,G,w).yaw,W=[Math.sin(H(B)),Math.cos(H(B))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,z));i=ct(i,G.id,(A,F)=>A.map(K=>{const I=K.time*F.duration;if(I<w-1e-6||I>U+1e-6)return K;const L=Math.min(1,(I-w)/Math.max(.001,s.strike)),Q=L*L*(3-2*L),X={...K,position:[+(K.position[0]+W[0]*V*Q).toFixed(3),K.position[1],+(K.position[2]+W[1]*V*Q).toFixed(3)]};return K.strike&&Math.abs(I-J)<.06?{...X,hit:s.result}:X})),E.push({...s,time:+J.toFixed(2),attackerName:G.name}),S=Math.max(U,ft),b=S+q[0]+(q[1]-q[0])*lt(),c===l.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={};E.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)}`,z=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:z?"#ffd27a":"#9fdcff",fx:{preset:"vong_xung_kich",cat:"vong-xung-kich",intensity:z?.9:.75,seed:500+k,start:d.time,duration:.6,loop:!1,auto:"hit",params:{size:(z?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,E.filter(n=>n.result==="blocked").map(n=>n.time),et.light,s.duration),c=tt(c,E.filter(n=>n.result==="body").map(n=>n.time),et.heavy,s.duration),i={...i,shots:i.shots.map(n=>n.id===s.id&&c?{...n,timing:c}:n)}}return{ok:!0,stage:i,plan:E,end:+S.toFixed(2),notes:j}}export{st as D,Ct as s};
@@ -1 +1 @@
1
- import{mR as P,a7 as b,U as W,$ as y,Z as E,a0 as F,lG as x}from"./titleFrameBudget-BYRZAQPs.js";import"./rotoMatte-BdYa8FSB.js";import"./api-DUp403BK.js";import"./store-75tQUvPT.js";const R=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{R as hasMovingWindows,D as pictureAspect,U as renderWindowFrames,I as windowMatteImage};
1
+ import{mR as P,a7 as b,U as W,$ as y,Z as E,a0 as F,lG as x}from"./titleFrameBudget-CLZWaFHO.js";import"./rotoMatte-C-2o3vv0.js";import"./api-CJ8PdbfZ.js";import"./store-DW4E9xnW.js";const R=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{R as hasMovingWindows,D as pictureAspect,U as renderWindowFrames,I as windowMatteImage};
@@ -4,9 +4,9 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="robots" content="noindex" />
6
6
  <title>Timeline layer worker</title>
7
- <script type="module" crossorigin src="/assets/layer-worker-DxPMMKIZ.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-BYRZAQPs.js">
9
- <link rel="modulepreload" crossorigin href="/assets/frameSink-BvOXjLuw.js">
7
+ <script type="module" crossorigin src="/assets/layer-worker-DFuo32bk.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-CLZWaFHO.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/frameSink-DeM8xC8_.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
@@ -1,3 +0,0 @@
1
- import{r as bn,j as s}from"./remote-Dva2qg58.js";import{u as hn,r as d,t as a}from"./api-DUp403BK.js";import{at as kn,au as Nn,av as un,aw as pn,ax as W,ay as R,R as H,az as wn,N as yn,aA as Cn,z as Sn,M as Ln,aB as Mn,o as Dn,aC as Un,aD as q,aE as $n,aF as Pn,e as Tn,aG as An}from"./main-BKjBWQik.js";import{d as Vn,k as Kn,m as En,l as In}from"./lottieLayer-1ET89OUr.js";import{p as Fn}from"./TimelinePlugins-DnkV3i4G.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./titleFrameBudget-BYRZAQPs.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";import"./spark.module-B34aiScb.js";import"./userFonts-DzY0A4bD.js";import"./timeline3d-246tBEJl.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-MUwVTI52.js";import"./captionLayout-EuB59pN_.js";import"./timelineText-BzUhNWPB.js";import"./titleArt-B8DVR58F.js";import"./rotoMatte-BdYa8FSB.js";import"./distortGL-BlmBZKRU.js";import"./motionBlur-uAm030t9.js";import"./pluginAutomation-Dp188qm7.js";const mn=[{id:"all",vi:"Tất cả",en:"All"},{id:"motion",vi:"Motion",en:"Motion"},{id:"lottie",vi:"Lottie",en:"Lottie"},{id:"recipe",vi:"Công thức",en:"Recipe"},{id:"sfx",vi:"Âm thanh",en:"Sounds"},{id:"pack",vi:"Gói ngách",en:"Niche pack"},{id:"kit",vi:"Bộ 3D",en:"3D kit"},{id:"sfxlib",vi:"Kho âm thanh",en:"Sound library"},{id:"link",vi:"Cho AI agent",en:"AI agents"}],I=e=>e.kind==="pack"&&!!e.kit?.modelAssets,Q=e=>I(e)?"kit":e.kind,F=e=>e.kind==="link"&&!!e.link,Bn=e=>{e.link&&window.open(e.link.url,"_blank","noopener,noreferrer")},gn=(e,l)=>e>=1024*1024?`${(e/1024/1024).toFixed(e>=10*1024*1024?0:1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,Y=({n:e=28})=>s.jsx("span",{className:"ps-wave","aria-hidden":!0,children:Array.from({length:e},(l,r)=>s.jsx("i",{style:{height:`${18+Math.round(72*Math.abs(Math.sin(r*1.37)*Math.cos(r*.41)))}%`}},r))}),xn=(e,l)=>mn.find(r=>r.id===e)?.[l==="en"?"en":"vi"]??e,On=5e3,Rn=600*1e3,on=e=>e.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/gi,"d").toLowerCase(),z=e=>(e.passVnd??0)>0||(e.passUsd??0)>0,Gn=e=>{const l=(r,o)=>r>0&&o>0?Math.min(r,o):r>0?r:o;return R({priceVnd:l(e.priceVnd,e.passVnd??0),priceUsd:l(e.priceUsd,e.passUsd??0)})};function Ns({installed:e,initialId:l=null,onClose:r,onInstalled:o,onUse:j,toast:c}){const m=hn(),u=m==="en"?"en":"vi",[f,L]=d.useState(null),[p,N]=d.useState([]),[M,A]=d.useState(""),[C,t]=d.useState("all"),[h,v]=d.useState("all"),[D,K]=d.useState(""),[x,w]=d.useState(null),[$,P]=d.useState(""),[T,b]=d.useState({}),[U,S]=d.useState(""),y=d.useCallback(()=>kn().then(n=>(N(n.owned),n.owned)).catch(()=>[]),[]),[V,G]=d.useState(!1);d.useEffect(()=>{Nn().then(n=>L(n.items),n=>{L([]),A(n.message)}),y().finally(()=>G(!0))},[y]);const E=d.useRef(!1);d.useEffect(()=>{if(!l||E.current||f===null||!V)return;E.current=!0;const n=f.find(i=>i.id===l)??p.find(i=>i.storeId===l&&i.item)?.item;n?w(n):c(a("Không tìm thấy plug-in này trong kho."),"error")},[l,f,p,V,c]),d.useEffect(()=>{const n=i=>{i.key==="Escape"&&(i.stopPropagation(),x?w(null):r())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[x,r]);const Z=Object.keys(T).join(",");d.useEffect(()=>{if(!Z)return;const n=window.setInterval(()=>{y().then(i=>{b(g=>{const k={...g};for(const O of Object.keys(k))(tn(i,O)||Date.now()-k[O]>Rn)&&delete k[O];return k})})},On);return()=>window.clearInterval(n)},[Z,y]);const B=n=>p.some(i=>i.storeId===n&&i.owned),_=n=>p.find(i=>i.storeId===n),nn=n=>p.some(i=>i.storeId===n&&i.status==="refunded"),sn=n=>e.some(i=>i.id===n&&i.source?.store===n),X=async n=>{P(n.id);try{await Mn(n.id),o(),Dn(),S(n.id),c(a("Đã cài “{0}” vào Plug-in của tôi",[n.name[u]]),"ok")}catch(i){const g=Fn(i);c(g.text,"error")}finally{P("")}},en=d.useRef({}),an=n=>n?.owned?n.expiresAt?String(n.expiresAt):"life":"none",tn=(n,i)=>{const g=n.find(k=>k.storeId===i);return!!g?.owned&&an(g)!==(en.current[i]??"none")},ln=(n,i)=>{en.current[n.id]=an(_(n.id)),Ln(n.id,i),b(g=>({...g,[n.id]:Date.now()}))},jn=async n=>{const i=await y();tn(i,n)?(b(g=>{const k={...g};return delete k[n],k}),c(a("Thanh toán xong — plug-in đã thuộc về bạn"),"ok")):c(a("Chưa thấy thanh toán. Nếu bạn vừa chuyển khoản, đợi một chút rồi kiểm tra lại."),"error")},fn=p.filter(n=>n.item).map(n=>n.item),J=(C==="owned"?fn:(f??[]).filter(n=>C==="all"||(C==="free"?n.free:!n.free))).filter(n=>(h==="all"||Q(n)===h)&&(!D.trim()||on(D).split(/\s+/).every(i=>on(`${n.name.vi} ${n.name.en} ${n.description.vi} ${n.description.en} ${n.author.name} ${n.tags.join(" ")}`).includes(i)))),vn=[{id:"all",label:a("Plug-in")},{id:"free",label:a("Miễn phí")},{id:"paid",label:a("Trả phí")},{id:"owned",label:a("Đã sở hữu")}],rn=(n,i)=>$===n.id?s.jsxs("button",{className:i,disabled:!0,children:[s.jsx("i",{className:"spin"})," ",a("Đang cài…")]}):sn(n.id)||U===n.id?s.jsxs(s.Fragment,{children:[j?s.jsxs("button",{className:`${i} ps-use`,onClick:()=>j(n.id),children:["✓ ",a("Đã cài · Dùng ngay")]}):s.jsxs("span",{className:`${i} ps-use`,role:"status",children:["✓ ",a("Đã cài")]}),s.jsx("button",{className:"ps-reinstall",title:a("Cài lại plug-in"),onClick:()=>void X(n),children:a("Cài lại")})]}):s.jsx("button",{className:i,onClick:()=>void X(n),children:a("Cài plug-in")}),cn=(n,i=!1)=>{const g=`ad-use${i?" ps-big":""}`;if(F(n))return s.jsxs("button",{className:g,onClick:()=>Bn(n),children:[n.link.label?.[u]||a("Hướng dẫn cài")," ↗"]});if(n.free)return rn(n,g);if(T[n.id])return s.jsx("button",{className:`${g} ps-wait`,onClick:()=>void jn(n.id),children:a("Đã thanh toán? Kiểm tra lại")});if(n.kind==="sfxlib"||z(n)){const k=_(n.id);if(!i&&!k?.owned)return s.jsx("button",{className:g,onClick:()=>w(n),children:k?.expiresAt?a("Gia hạn"):a("Xem & mua")});if(i)return s.jsx(Xn,{item:n,owned:k,busy:$===n.id,installed:sn(n.id),onInstall:()=>void X(n),onBuy:O=>ln(n,O)})}return B(n.id)?rn(n,g):s.jsx("button",{className:g,onClick:()=>ln(n),children:a("Mua · {0}",[R(n)])})},dn=n=>{if(n.free)return s.jsx("span",{className:"ps-price free",children:a("Miễn phí")});const i=_(n.id);return i?.owned?s.jsxs("span",{className:"ps-price owned",children:["✓ ",i.expiresAt?a("Vé đến {0}",[H(i.expiresAt,m)]):a("Đã sở hữu")]}):s.jsx("span",{className:"ps-price",children:n.kind==="sfxlib"||z(n)?(n.passVnd||n.passUsd)&&!(n.priceVnd||n.priceUsd)?a("{0} / 30 ngày",[W(n)]):a("từ {0}",[Gn(n)]):R(n)})};return bn.createPortal(s.jsx("div",{className:"ad-backdrop",role:"dialog","aria-modal":"true","aria-label":a("Kho Plug-in"),onMouseDown:n=>{n.target===n.currentTarget&&r()},children:s.jsxs("section",{className:"ad-drawer ps-drawer",onMouseDown:n=>n.stopPropagation(),children:[s.jsxs("header",{className:"ad-head",children:[s.jsxs("div",{className:"ad-title",children:["🛍 ",a("Kho Plug-in")]}),s.jsxs("span",{className:"ad-count",children:[J.length," ",a("mục")]}),s.jsx("div",{className:"grow"}),s.jsx("button",{className:"ad-iconbtn",title:a("Đóng"),"aria-label":a("Đóng"),onClick:r,children:"✕"})]}),s.jsx("nav",{className:"ad-sources",children:vn.map(n=>s.jsxs("button",{className:`ad-tab${C===n.id?" on":""}`,"aria-pressed":C===n.id,onClick:()=>t(n.id),children:[n.id==="all"&&s.jsx("span",{className:"ad-pin",children:"⧉"}),n.label,n.id==="owned"&&p.filter(i=>i.owned).length>0&&s.jsx("span",{className:"ps-n",children:p.filter(i=>i.owned).length})]},n.id))}),s.jsxs("div",{className:"ad-tools",children:[s.jsx("input",{className:"ad-search","aria-label":a("Tìm plug-in"),placeholder:a("Tìm plug-in, tác giả, thẻ…"),value:D,onChange:n=>K(n.target.value),onKeyDown:n=>n.stopPropagation()}),s.jsx("div",{className:"ad-chips",role:"group","aria-label":a("Loại plug-in"),children:mn.map(n=>s.jsx("button",{className:`ad-chip${h===n.id?" on":""}`,"aria-pressed":h===n.id,onClick:()=>v(n.id),children:n[u]},n.id))})]}),s.jsxs("div",{className:"ad-notice",children:[s.jsxs("b",{children:["⧉ ",a("Plug-in không tốn credit.")]})," ",h==="sfxlib"?a("Kho âm thanh: mua một lần hoặc vé 30 ngày trên clipoox.com, tính là 1 plug-in; âm chỉ chép vào dự án khi bạn dùng."):a("Bản miễn phí cài ngay; bản trả phí mua một lần hoặc vé 30 ngày trên clipoox.com (chuyển khoản / thẻ), không tự trừ tiền.")]}),s.jsxs("div",{className:"ad-content",children:[M&&s.jsx("p",{role:"alert",className:"ad-alert",children:M}),f===null&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),f!==null&&!J.length&&s.jsx("div",{className:"ad-empty",children:C==="owned"?a("Bạn chưa mua plug-in nào."):D?a("Không có plug-in khớp tìm kiếm."):a("Kho chưa có plug-in nào trong nhóm này.")}),s.jsx("div",{className:"ad-grid",children:J.map(n=>s.jsxs("article",{className:"ad-card ps-card","data-store":n.id,children:[s.jsxs("button",{className:"ad-prev ps-open","aria-label":a("Xem {0}",[n.name[u]]),onClick:()=>w(n),children:[n.thumbnailUrl?s.jsx("img",{src:n.thumbnailUrl,alt:"",loading:"lazy"}):n.kind==="sfx"||n.kind==="sfxlib"?s.jsx(Y,{}):s.jsx("span",{className:"ad-ph",children:"⧉"}),s.jsx("span",{className:"ad-badge",children:(F(n)?n.link.platform:xn(Q(n),m)).toUpperCase()}),n.featured&&s.jsxs("span",{className:"ps-featured",title:a("Đối tác tiên phong của Clipoox"),children:["★ ",a("Đối tác tiên phong")]}),n.private&&s.jsxs("span",{className:"ps-private",title:a("Chỉ các tài khoản được Clipoox chọn mới thấy gói này"),children:["🔒 ",a("Gói riêng")]})]}),s.jsxs("div",{className:"ad-meta",children:[s.jsx("div",{className:"ad-name",title:n.name[u],children:n.name[u]}),s.jsxs("div",{className:"ad-sub ps-sub",children:[s.jsxs("span",{className:"ps-by",children:[n.author.name," · v",n.version]}),dn(n)]}),n.kind==="pack"&&!I(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["⧉ ",a("{0} mục trong gói",[n.itemCount??0])]}),I(n)&&s.jsxs("div",{className:"ps-kit-meta",children:["◈ ",s.jsx("b",{children:n.kit.items})," ",a("mục")," · ",s.jsx("b",{children:n.kit.models})," ",a("mô hình 3D")," · ",s.jsx("b",{children:n.kit.looks})," ",a("look")," · ",gn(n.kit.bytes,u)]}),F(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["↗ ",a("Cài trong {0} trên máy bạn",[n.link.platform])]}),n.kind==="sfx"&&s.jsxs("div",{className:"ps-sounds-meta",children:["♪ ",a("{0} âm thanh",[n.soundCount??0])," · ",un(n.totalDuration)]}),n.kind==="sfxlib"&&s.jsxs("div",{className:"ps-sounds-meta",children:["📚 ",a("{0} âm thanh",[(n.soundCount??0).toLocaleString(u==="en"?"en-US":"vi-VN")])," · ",pn(n.totalDuration,u)]}),(n.kind==="sfxlib"||z(n))&&!n.free&&!B(n.id)&&s.jsx("div",{className:"ps-sounds-meta ps-lib-prices",children:[n.passVnd||n.passUsd?a("{0} / 30 ngày",[W(n)]):"",n.priceVnd||n.priceUsd?a("{0} trọn đời",[R(n)]):""].filter(Boolean).join(" · ")}),U===n.id&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi")]}),T[n.id]&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán…")]}),nn(n.id)&&!B(n.id)&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn đã hoàn tiền")}),s.jsx("div",{className:"ad-actions",children:cn(n)})]})]},n.id))})]}),x&&s.jsx(Hn,{item:x,locale:u,owned:B(x.id),free:x.free,waiting:!!T[x.id],refunded:nn(x.id),action:cn(x,!0),price:dn(x),installed:U===x.id,onClose:()=>w(null)},`${x.id}:${B(x.id)}`)]})}),document.body)}function Hn({item:e,locale:l,owned:r,free:o,waiting:j,refunded:c,action:m,price:u,installed:f,onClose:L}){const p=d.useRef(null),[N,M]=d.useState(!1),[A,C]=d.useState(!1);return d.useEffect(()=>{if(!(o||r)||e.kind==="recipe"||e.kind==="sfx"||e.kind==="pack"||e.kind==="sfxlib"||e.kind==="link")return;let t=!0,h=0,v=null;const D=`store-preview:${e.id}`,K={v:""},x=performance.now();return(async()=>{try{v=await wn(e.id)}catch{t&&C(!0);return}if(!t||!v)return;const w=v.manifest,$=640,P=360;if(w.kind==="motion"){const T=yn(w,v.entry,{}),b=w.duration,U=async()=>{if(t){try{const S=await En({layer:D,motion:T,t:(performance.now()-x)/1e3%b,width:$,height:P,duration:b}),y=p.current?.getContext("2d");y&&t&&(y.clearRect(0,0,$,P),y.drawImage(S,0,0),M(!0)),S.close()}catch{}h=requestAnimationFrame(()=>void U())}};U()}else{const T=await Cn(v.lottie,w,Sn(w,{}));K.v=URL.createObjectURL(new Blob([JSON.stringify(T)],{type:"application/json"}));const b=v.lottie.meta,U=Math.min($/b.w,P/b.h),S={W:Math.max(2,Math.round(b.w*U/2)*2),H:Math.max(2,Math.round(b.h*U/2)*2)},y=b.op-b.ip,V=document.createElement("canvas");V.width=S.W,V.height=S.H;const G=async()=>{if(t){try{await In(D,K.v,S,Math.floor((performance.now()-x)/1e3*b.fr%y),V);const E=p.current?.getContext("2d");E&&t&&(E.clearRect(0,0,$,P),E.drawImage(V,($-S.W)/2,(P-S.H)/2),M(!0))}catch{}h=requestAnimationFrame(()=>void G())}};G()}})(),()=>{t=!1,cancelAnimationFrame(h),Vn(D),Kn(D),K.v&&URL.revokeObjectURL(K.v)}},[e.id,e.kind,o,r]),s.jsx("div",{className:"ad-preview-modal",onMouseDown:t=>{t.target===t.currentTarget&&L()},children:s.jsxs("div",{className:"ad-preview-box ps-detail",role:"dialog","aria-label":e.name[l],children:[s.jsxs("header",{children:[s.jsx("b",{children:e.name[l]}),s.jsx("button",{className:"ad-iconbtn","aria-label":a("Đóng"),onClick:L,children:"✕"})]}),e.kind==="sfxlib"?s.jsx(_n,{item:e,locale:l}):e.kind==="sfx"?s.jsx(Wn,{item:e,locale:l,owned:r,free:o}):s.jsxs("div",{className:"ps-stage",children:[s.jsx("canvas",{ref:p,width:640,height:360,style:{display:N?"block":"none"}}),!N&&(e.previewUrl&&/\.(mp4|webm)(\?|$)/.test(e.previewUrl)?s.jsx("video",{src:e.previewUrl,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):e.previewUrl||e.thumbnailUrl?s.jsx("img",{src:e.previewUrl||e.thumbnailUrl,alt:""}):s.jsx("span",{className:"ad-ph",children:"⧉"})),s.jsx("span",{className:"ps-stage-note",children:N?a("Xem thử trực tiếp trong sandbox"):o||r?A?a("Không tải được bản xem thử"):e.kind==="recipe"?a("Công thức chạy trên clip bạn chọn"):e.kind==="pack"?a("Gói {0} mục — cài rồi dùng từng mục trong tab Plug-in",[e.itemCount??0]):F(e)?a("Cài trong {0} trên máy bạn — không cài vào Timeline",[e.link.platform]):a("Đang tải bản xem thử…"):a("Mua để xem thử trực tiếp và dùng")})]}),e.kind==="pack"&&s.jsx(zn,{item:e,locale:l}),s.jsxs("div",{className:"ps-info",children:[e.featured&&s.jsxs("p",{className:"ps-featured-line",children:["★ ",a("Đối tác tiên phong của Clipoox")]}),e.private&&s.jsxs("p",{className:"ps-private-line",children:["🔒 ",a("Gói riêng: chỉ các tài khoản được Clipoox chọn mới thấy và cài được.")]}),s.jsxs("div",{className:"ps-row",children:[u,s.jsxs("span",{className:"ps-kind",children:[F(e)?e.link.platform:xn(Q(e),l)," · v",e.version," · ",e.author.name,e.kit?` · ${gn(e.kit.bytes,l)}`:"",I(e)?` · ${a("GLB ≤ 20 MB, ≤ 300 000 tam giác")}`:""]})]}),s.jsx("p",{children:e.description[l]}),F(e)&&e.link.commands.length>0&&s.jsx(qn,{commands:e.link.commands}),e.params.length>0&&s.jsxs("p",{className:"ps-params",children:[s.jsxs("b",{children:[a("Tham số chỉnh được"),":"]})," ",e.params.map(t=>t.label[l]).join(" · ")]}),j&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán… Hoàn tất trên trang clipoox.com vừa mở, rồi quay lại đây.")]}),c&&!r&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn mua này đã được hoàn tiền nên không cài mới được. Các clip đã dùng vẫn giữ nguyên.")}),f&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi — mở tab Plug-in để dùng.")]}),s.jsx("div",{className:"ad-actions",children:m}),I(e)&&!o&&!r&&s.jsxs("div",{className:"ps-lock",children:["🔒 ",a("Mô hình và texture chỉ tải về máy sau khi mua. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")]}),I(e)&&(o||r)&&s.jsx("small",{className:"muted",children:a("Tài nguyên 3D chỉ chép vào dự án khi bạn dùng một mục. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")}),!o&&!r&&e.kind!=="sfxlib"&&!z(e)&&s.jsx("small",{className:"muted",children:a("Thanh toán một lần trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit.")})]})]})})}function qn({commands:e}){const[l,r]=d.useState(!1),o=()=>{navigator.clipboard?.writeText(e.join(`
2
- `)).then(()=>{r(!0),window.setTimeout(()=>r(!1),2e3)},()=>{})};return s.jsxs("div",{className:"ps-cmds",children:[s.jsxs("div",{className:"ps-cmds-head",children:[s.jsx("b",{children:a("Lệnh cài")}),s.jsx("span",{className:"muted",children:a("chạy trong terminal trên máy bạn")}),s.jsx("button",{className:"ad-chip",onClick:o,children:l?`✓ ${a("Đã chép")}`:a("Chép lệnh")})]}),s.jsx("pre",{children:e.join(`
3
- `)})]})}function zn({item:e,locale:l}){const[r,o]=d.useState(null);if(d.useEffect(()=>{let c=!0;return An(e.id).then(m=>{c&&o(m.items)},()=>{c&&o([])}),()=>{c=!1}},[e.id]),!r?.length)return null;const j=c=>c.kind==="model"?a("Mô hình"):c.kind==="lut"?"Look":c.kind==="motion"&&c.engine==="3d"?"3D":c.kind==="recipe"?a("Combo"):c.kind==="lottie"?"Lottie":"2D";return s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"ps-items-head",children:[s.jsx("b",{children:a("{0} mục trong gói",[r.length])})," · ",s.jsx("span",{className:"muted",children:a("ảnh chụp từ lần chạy thử")})]}),s.jsx("div",{className:"ps-items",children:r.slice(0,24).map(c=>s.jsxs("figure",{children:[c.thumbnail?s.jsx("img",{src:`data:${c.thumbnail.type};base64,${c.thumbnail.data}`,alt:""}):s.jsx("span",{className:"ph",children:c.kind==="model"?"◈":"✦"}),s.jsxs("figcaption",{title:c.name[l],children:[j(c)," · ",c.name[l]]})]},c.id))})]})}function Wn({item:e,locale:l,owned:r,free:o}){const[j,c]=d.useState(null),[m,u]=d.useState(!1),[f,L]=d.useState(!1),[p,N]=d.useState(null),M=d.useRef(null),A=d.useRef(0);d.useEffect(()=>{let t=!0;return Pn(e.id).then(h=>{t&&(c(h.sounds),u(h.full))},()=>{t&&L(!0)}),()=>{t=!1,M.current?.pause(),window.clearTimeout(A.current)}},[e.id,r,o]);const C=t=>{if(M.current?.pause(),window.clearTimeout(A.current),p===t.id||!t.url){N(null);return}const h=new Audio(t.url);M.current=h,h.volume=.8,N(t.id),h.onended=()=>N(v=>v===t.id?null:v),t.preview&&(A.current=window.setTimeout(()=>{h.pause(),N(v=>v===t.id?null:v)},q.previewSeconds*1e3+300)),h.play().catch(()=>N(null))};return s.jsxs("div",{className:"ps-sounds","data-full":m?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Y,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["♪ ",a("{0} âm thanh",[e.soundCount??j?.length??0])," · ",un(e.totalDuration)]}),s.jsx("small",{className:"muted",children:m?a("Nghe đầy đủ — bấm ▶"):a("Nghe thử {0} âm thanh đầu, mỗi âm tối đa {1} giây. Mua để nghe đủ và dùng.",[q.previewCount,q.previewSeconds])})]})]}),f&&s.jsx("p",{className:"ad-alert",role:"alert",children:a("Không tải được bản xem thử")}),j===null&&!f&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),j&&s.jsx("ul",{className:"ps-sound-list","aria-label":a("Âm thanh trong gói"),children:j.map(t=>{const h=t.name?.[l]||t.name?.vi||t.id;return s.jsxs("li",{className:`${p===t.id?"on":""}${t.url?"":" locked"}`,"data-store-sound":t.id,children:[s.jsx("button",{className:"tl-sfx-play",disabled:!t.url,"aria-label":t.url?`${a("Nghe thử")} ${h}`:a("Mua để nghe {0}",[h]),title:t.url?a("Nghe thử"):a("Mua để nghe"),onClick:()=>C(t),children:t.url?p===t.id?"■":"▶":"🔒"}),s.jsxs("span",{className:"ps-sound-name",children:[s.jsxs("span",{className:"ell",children:[h,t.loop?" ↻":""]}),s.jsxs("small",{className:"muted ell",children:[Tn(t.category,l),t.tags.length?` · ${t.tags.slice(0,3).join(", ")}`:""]})]}),s.jsxs("small",{className:"muted",children:[t.preview&&(t.previewSeconds??0)<t.duration-.05?`▶ ${(t.previewSeconds??0).toFixed(1)}s / `:"",t.duration.toFixed(1),"s"]})]},t.id)})})]})}function _n({item:e,locale:l}){const r=d.useCallback(m=>Un(e.id,m),[e.id]),[o,j]=d.useState(null),c=d.useCallback(async m=>{const u=await r(m);return j(u.access.full),u},[r]);return s.jsxs("div",{className:"ps-sounds","data-full":o?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Y,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["📚 ",a("{0} âm thanh",[(e.soundCount??0).toLocaleString(l==="en"?"en-US":"vi-VN")])," · ",pn(e.totalDuration,l)]}),s.jsxs("div",{className:"ps-stats",children:[(e.folders?.length??0)>0&&s.jsxs("span",{children:[s.jsx("b",{children:e.folders.length})," ",a("thư mục")]}),s.jsxs("span",{children:[s.jsx("b",{children:"48 kHz"})," stereo"]}),s.jsxs("span",{children:["v",e.version]})]}),s.jsx("small",{className:"muted",children:o?a("Nghe đầy đủ — thêm âm từ mục SFX của Timeline."):a("Nghe thử mọi âm ({0} giây, chất lượng thấp). Mua để nghe đủ và dùng.",[q.previewSeconds])})]})]}),s.jsx($n,{libId:e.id,fetchPage:c,variant:"store"})]})}function Xn({item:e,owned:l,busy:r,installed:o,onInstall:j,onBuy:c}){const m=hn(),u=e.kind==="sfxlib",f=(e.passVnd??0)>0||(e.passUsd??0)>0,L=e.priceVnd>0||e.priceUsd>0,p=s.jsx("button",{className:"ad-use ps-big",disabled:r,onClick:j,children:r?a("Đang cài…"):o?a("Cài lại"):a("Cài plug-in")});return l?.owned&&!l.expiresAt?p:l?.owned?s.jsxs("div",{className:"ps-lib-buy-wrap",children:[p,f&&s.jsx("button",{className:"ad-use ps-big ps-alt",onClick:()=>c("pass"),children:a("Gia hạn thêm 30 ngày · {0}",[W(e)])}),s.jsx("small",{className:"muted",children:a("Vé đến {0}. Gia hạn cộng nối từ ngày đó, không tự trừ tiền.",[H(l.expiresAt,m)])})]}):s.jsxs("div",{className:"ps-lib-buy-wrap",children:[l?.expiresAt&&s.jsx("div",{className:"ps-waiting",children:u?a("Vé 30 ngày đã hết hạn ngày {0}. Âm đã dùng trong dự án vẫn giữ nguyên.",[H(l.expiresAt,m)]):a("Vé 30 ngày đã hết hạn ngày {0}. Lớp đã thêm vào video vẫn giữ nguyên.",[H(l.expiresAt,m)])}),s.jsxs("div",{className:"ps-lib-buy",children:[f&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("pass"),children:[a("Vé 30 ngày · {0}",[W(e)]),s.jsx("small",{children:a("Trả lại để gia hạn, không tự trừ tiền")})]}),L&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("lifetime"),children:[a("Mua trọn đời · {0}",[R(e)]),s.jsx("small",{children:u?a("Một lần, gồm các đợt âm mới"):a("Một lần, dùng mãi mãi")})]})]}),s.jsx("small",{className:"muted",children:u?a("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Âm đã dùng trong dự án vẫn giữ khi vé hết hạn."):a("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Hết vé thì không thêm mới được; lớp đã thêm vào video vẫn giữ nguyên.")})]})}export{Ns as default};
@@ -1,24 +0,0 @@
1
- import{I as pe,bx as Z,s as me,g as C,aY as Q,S as Y,ai as O,bA as fe,bB as j,bC as ee,b7 as te,bD as q,bE as we,V as se,by as re,bF as ae,bv as $,b as be,bG as ge,aZ as ye,bk as Te,b0 as ie,bH as _e,b1 as oe}from"./id3-BCR9Bqgo.js";import{bI as Ie,A as De,bJ as xe,al as Ve,bK as Le,bL as Ne,bM as We,bN as je,bO as qe,bP as ze,bQ as Ue,bR as He,bS as Ge,bT as Be,bU as Qe,bV as Ye,bW as Ke,bc as $e,O as Xe,bX as Je,bY as Ze,bZ as Oe,b_ as et,b$ as tt,c0 as st,c1 as rt,c2 as at,c3 as it,c4 as ot,c5 as nt,c6 as dt,c7 as ct,c8 as ut,c9 as ht,ca as lt,cb as pt,cc as mt,cd as ft,ce as wt,cf as bt,cg as gt,ch as yt,P as Tt,ci as _t,cj as vt,ck as St,cl as Et,cm as At,cn as Ct,co as kt,cp as Mt,cq as Pt,cr as Rt,R as Ft,b2 as It,cs as Dt,ct as xt,cu as Vt,cv as Lt,U as Nt,cw as Wt,a$ as jt,cx as qt,cy as zt,cz as Ut,cA as Ht,cB as Gt,cC as Bt,cD as Qt,cE as Yt,cF as Kt,cG as $t,cH as Xt,a as Jt,cI as Zt,c as Ot,cJ as es,cK as ts,cL as ss,cM as rs,cN as as,cO as is,cP as os,cQ as ns,cR as ds,cS as cs,cT as us,cU as hs,cV as ls}from"./id3-BCR9Bqgo.js";import{O as ne,E as ve,N as Se,a as Ee,V as de,b as Ae,c as Ce,d as z}from"./output-BwZzMbp-.js";import{e as ms,f as fs,g as ws,A as bs,h as gs,B as ys,C as Ts,i as _s,F as vs,j as Ss,H as Es,I as As,k as Cs,l as ks,m as Ms,n as Ps,M as Rs,o as Fs,p as Is,q as Ds,r as xs,s as Vs,t as Ls,u as Ns,v as Ws,P as js,R as qs,S as zs,w as Us,T as Hs,x as Gs,y as Bs,z as Qs,W as Ys}from"./output-BwZzMbp-.js";/*!
2
- * Copyright (c) 2026-present, Vanilagy and contributors
3
- *
4
- * This Source Code Form is subject to the terms of the Mozilla Public
5
- * License, v. 2.0. If a copy of the MPL was not distributed with this
6
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
- */var U=function(s,e,t){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var r,a;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=e[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=e[Symbol.dispose],t&&(a=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");a&&(r=function(){try{a.call(this)}catch(d){return Promise.reject(d)}}),s.stack.push({value:e,dispose:r,async:t})}else t&&s.stack.push({async:!0});return e},H=(function(s){return function(e){function t(c){e.error=e.hasError?new s(c,e.error,"An error was suppressed during disposal."):c,e.hasError=!0}var r,a=0;function d(){for(;r=e.stack.pop();)try{if(!r.async&&a===1)return a=0,e.stack.push(r),Promise.resolve().then(d);if(r.dispose){var c=r.dispose.call(r.value);if(r.async)return a|=2,Promise.resolve(c).then(d,function(u){return t(u),d()})}else a|=1}catch(u){t(u)}if(a===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return d()}})(typeof SuppressedError=="function"?SuppressedError:function(s,e,t){var r=new Error(t);return r.name="SuppressedError",r.error=s,r.suppressed=e,r});const G=s=>{if(!s||typeof s!="object")throw new TypeError("options.video, when provided, must be an object.");if(s?.discard!==void 0&&typeof s.discard!="boolean")throw new TypeError("options.video.discard, when provided, must be a boolean.");if(s?.forceTranscode!==void 0&&typeof s.forceTranscode!="boolean")throw new TypeError("options.video.forceTranscode, when provided, must be a boolean.");if(s?.codec!==void 0&&!ie.includes(s.codec))throw new TypeError(`options.video.codec, when provided, must be one of: ${ie.join(", ")}.`);const e=s?.bitrate;if(s?.quality!==void 0&&!(s.quality instanceof q))throw new TypeError("options.video.quality, when provided, must be a Quality.");if(s?.quality!==void 0&&e!==void 0)throw new TypeError("options.video.quality and options.video.bitrate cannot both be provided.");if(e!==void 0&&!(e instanceof q)&&(!Number.isInteger(e)||e<=0))throw new TypeError("options.video.bitrate, when provided, must be a positive integer or a quality.");if(s?.width!==void 0&&(!Number.isInteger(s.width)||s.width<=0))throw new TypeError("options.video.width, when provided, must be a positive integer.");if(s?.height!==void 0&&(!Number.isInteger(s.height)||s.height<=0))throw new TypeError("options.video.height, when provided, must be a positive integer.");if(s?.fit!==void 0&&!["fill","contain","cover"].includes(s.fit))throw new TypeError("options.video.fit, when provided, must be one of 'fill', 'contain', or 'cover'.");if(s?.width!==void 0&&s.height!==void 0&&s.fit===void 0)throw new TypeError("When both options.video.width and options.video.height are provided, options.video.fit must also be provided.");if(s?.rotate!==void 0&&![0,90,180,270].includes(s.rotate))throw new TypeError("options.video.rotate, when provided, must be 0, 90, 180 or 270.");if(s?.allowRotationMetadata!==void 0&&typeof s.allowRotationMetadata!="boolean")throw new TypeError("options.video.allowRotationMetadata, when provided, must be a boolean.");if(s?.crop!==void 0&&_e(s.crop,"options.video."),s?.frameRate!==void 0&&(!Number.isFinite(s.frameRate)||s.frameRate<=0))throw new TypeError("options.video.frameRate, when provided, must be a finite positive number.");if(s?.alpha!==void 0&&!["discard","keep"].includes(s.alpha))throw new TypeError("options.video.alpha, when provided, must be either 'discard' or 'keep'.");if(s?.keyFrameInterval!==void 0&&(!Number.isFinite(s.keyFrameInterval)||s.keyFrameInterval<0))throw new TypeError("options.video.keyFrameInterval, when provided, must be a non-negative number.");if(s?.process!==void 0&&typeof s.process!="function")throw new TypeError("options.video.process, when provided, must be a function.");if(s?.processedWidth!==void 0&&(!Number.isInteger(s.processedWidth)||s.processedWidth<=0))throw new TypeError("options.video.processedWidth, when provided, must be a positive integer.");if(s?.processedHeight!==void 0&&(!Number.isInteger(s.processedHeight)||s.processedHeight<=0))throw new TypeError("options.video.processedHeight, when provided, must be a positive integer.");if(s?.hardwareAcceleration!==void 0&&!["no-preference","prefer-hardware","prefer-software"].includes(s.hardwareAcceleration))throw new TypeError("options.video.hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");if(s?.group!==void 0&&!(s.group instanceof z||Array.isArray(s.group)&&s.group.every(t=>t instanceof z)))throw new TypeError("options.video.group, when provided, must be an OutputTrackGroup or an array of OutputTrackGroups.")},B=s=>{if(!s||typeof s!="object")throw new TypeError("options.audio, when provided, must be an object.");if(s?.discard!==void 0&&typeof s.discard!="boolean")throw new TypeError("options.audio.discard, when provided, must be a boolean.");if(s?.forceTranscode!==void 0&&typeof s.forceTranscode!="boolean")throw new TypeError("options.audio.forceTranscode, when provided, must be a boolean.");if(s?.codec!==void 0&&!oe.includes(s.codec))throw new TypeError(`options.audio.codec, when provided, must be one of: ${oe.join(", ")}.`);const e=s?.bitrate;if(s?.quality!==void 0&&!(s.quality instanceof q))throw new TypeError("options.audio.quality, when provided, must be a Quality.");if(s?.quality!==void 0&&e!==void 0)throw new TypeError("options.audio.quality and options.audio.bitrate cannot both be provided.");if(e!==void 0&&!(e instanceof q)&&(!Number.isInteger(e)||e<=0))throw new TypeError("options.audio.bitrate, when provided, must be a positive integer or a quality.");if(s?.numberOfChannels!==void 0&&(!Number.isInteger(s.numberOfChannels)||s.numberOfChannels<=0))throw new TypeError("options.audio.numberOfChannels, when provided, must be a positive integer.");if(s?.sampleRate!==void 0&&(!Number.isInteger(s.sampleRate)||s.sampleRate<=0))throw new TypeError("options.audio.sampleRate, when provided, must be a positive integer.");if(s?.sampleFormat!==void 0&&!["u8","s16","s32","f32"].includes(s.sampleFormat))throw new TypeError("options.audio.sampleFormat, when provided, must be one of: u8, s16, s32, f32.");if(s?.process!==void 0&&typeof s.process!="function")throw new TypeError("options.audio.process, when provided, must be a function.");if(s?.processedNumberOfChannels!==void 0&&(!Number.isInteger(s.processedNumberOfChannels)||s.processedNumberOfChannels<=0))throw new TypeError("options.audio.processedNumberOfChannels, when provided, must be a positive integer.");if(s?.processedSampleRate!==void 0&&(!Number.isInteger(s.processedSampleRate)||s.processedSampleRate<=0))throw new TypeError("options.audio.processedSampleRate, when provided, must be a positive integer.");if(s?.group!==void 0&&!(s.group instanceof z||Array.isArray(s.group)&&s.group.every(t=>t instanceof z)))throw new TypeError("options.audio.group, when provided, must be an OutputTrackGroup or an array of OutputTrackGroups.")},X=2,J=48e3;class he{static async init(e){const t=new he(e);return await t._init(),t}constructor(e){if(this.state="idle",this._nextOutputTrackId=0,this._outputTrackIds=[],this._outputOwnTrackGroups=[],this._trackPumps=[],this._composable=!1,this._executed=!1,this._executionUntil=1/0,this._pauseRequested=!1,this._synchronizer=new ke(this),this._totalDuration=null,this._maxTimestamps=new Map,this.onProgress=void 0,this._computeProgress=!1,this._lastProgress=0,this.isValid=!1,this.utilizedTracks=[],this.discardedTracks=[],!e||typeof e!="object")throw new TypeError("options must be an object.");if(!(e.input instanceof pe))throw new TypeError("options.input must be an Input.");if(!(e.output instanceof ne))throw new TypeError("options.output must be an Output.");if(e.tracks!==void 0&&e.tracks!=="all"&&e.tracks!=="primary")throw new TypeError("options.tracks, when provided, must be either 'all' or 'primary'.");if(e.composable!==void 0&&typeof e.composable!="boolean")throw new TypeError("options.composable, when provided, must be a boolean.");const t=e.composable??!1;if(t){if(e.tags!==void 0)throw new TypeError("options.tags cannot be set by a composable conversion; set metadata directly on the output instead.");if(e.output.state!=="pending")throw new TypeError("options.output must not have been started yet.")}else if(e.output.tracks.length>0||Object.keys(e.output._metadataTags).length>0||e.output.state!=="pending")throw new TypeError("options.output must be fresh: no tracks or metadata tags added and not started.");if(e.video!==void 0&&typeof e.video!="function")if(Array.isArray(e.video))for(const r of e.video)G(r);else G(e.video);if(e.audio!==void 0&&typeof e.audio!="function")if(Array.isArray(e.audio))for(const r of e.audio)B(r);else B(e.audio);if(e.trim!==void 0&&(!e.trim||typeof e.trim!="object"))throw new TypeError("options.trim, when provided, must be an object.");if(e.trim?.start!==void 0&&!Number.isFinite(e.trim.start))throw new TypeError("options.trim.start, when provided, must be a finite number.");if(e.trim?.end!==void 0&&!Number.isFinite(e.trim.end))throw new TypeError("options.trim.end, when provided, must be a finite number.");if(e.trim?.start!==void 0&&e.trim.end!==void 0&&e.trim.start>=e.trim.end)throw new TypeError("options.trim.start must be less than options.trim.end.");if(e.tags!==void 0&&(typeof e.tags!="object"||!e.tags)&&typeof e.tags!="function")throw new TypeError("options.tags, when provided, must be an object or a function.");if(typeof e.tags=="object"&&Z(e.tags),e.showWarnings!==void 0&&typeof e.showWarnings!="boolean")throw new TypeError("options.showWarnings, when provided, must be a boolean.");this._options=e,this._composable=t,this.input=e.input,this.output=e.output}async _init(){const e=await this.input.getFormat();let t,r=this._options.tracks;if(r===void 0&&(r=e.name.includes("(HLS)")?"primary":"all"),r==="all")t=await this.input.getTracks();else if(r==="primary"){const o=await this.input.getPrimaryVideoTrack(),i=await this.input.getPrimaryAudioTrack();t=[o,i].filter(m=>m!==null)}else me(r),C(!1);const a=this.output.format.getSupportedTrackCounts();let d=1,c=1;const u=[],R=[];for(const o of t){let i;if(o.isVideoTrack())if(this._options.video)if(typeof this._options.video=="function"){const n=await this._options.video(o,d)??{};if(Array.isArray(n))for(const h of n)G(h);else G(n);i=Array.isArray(n)?n:[n],d++}else i=Array.isArray(this._options.video)?this._options.video:[this._options.video];else i=[{}];else if(o.isAudioTrack())if(this._options.audio)if(typeof this._options.audio=="function"){const n=await this._options.audio(o,c)??{};if(Array.isArray(n))for(const h of n)B(h);else B(n);i=Array.isArray(n)?n:[n],c++}else i=Array.isArray(this._options.audio)?this._options.audio:[this._options.audio];else i=[{}];else C(!1);const m=i.filter(n=>n.discard);for(const n of m)this.discardedTracks.push({track:o,reason:"discarded_by_user",trackOptions:n});if(i.length===m.length){i.length===0&&this.discardedTracks.push({track:o,reason:"discarded_by_user",trackOptions:{}});continue}const w=i.filter(n=>!n.discard);u.push(o),R.push(w)}this._options.trim?.start!==void 0?this._startTimestamp=this._options.trim.start:this._startTimestamp=Math.max(await this.input.getFirstTimestamp(u),0),this._endTimestamp=Math.max(this._options.trim?.end??1/0,this._startTimestamp);for(let o=0;o<u.length;o++){const i=u[o],m=R[o];for(const w of m){if(this.output.tracks.length===a.total.max){this.discardedTracks.push({track:i,reason:"max_track_count_reached",trackOptions:w});continue}if(this.output.tracks.reduce((D,k)=>D+(k.type===i.type?1:0),0)===a[i.type].max){this.discardedTracks.push({track:i,reason:"max_track_count_of_type_reached",trackOptions:w});continue}const h=this._nextOutputTrackId++;i.isVideoTrack()?await this._processVideoTrack(i,w,h):i.isAudioTrack()?await this._processAudioTrack(i,w,h):C(!1)}}for(let o=0;o<this.utilizedTracks.length-1;o++)for(let i=o+1;i<this.utilizedTracks.length;i++){const m=this.utilizedTracks[o],w=this.utilizedTracks[i],n=this._outputOwnTrackGroups[o],h=this._outputOwnTrackGroups[i];C(n!==void 0),C(h!==void 0),n&&h&&m.canBePairedWith(w)&&n.pairWith(h)}if(!this._composable){const o=await this.input.getMetadataTags();let i;if(this._options.tags){const n=typeof this._options.tags=="function"?await this._options.tags(o):this._options.tags;Z(n),i=n}else i=o;const m=e.mimeType===this.output.format.mimeType,w=o.raw===i.raw;o.raw&&w&&!m&&delete i.raw,this.output.setMetadataTags(i)}if(this._composable?this.isValid=!0:this.isValid=this.output.hasEnoughTracks()&&this.output.tracks.length>0,this._options.showWarnings??!0){const o=[],i=this.discardedTracks.filter(m=>m.reason!=="discarded_by_user");i.length>0&&o.push("Some tracks had to be discarded from the conversion:",i),this.isValid||(o.length>0&&o.push(`
8
-
9
- `),o.push(this._getInvalidityExplanation().join(""))),o.length>0&&Q._warn(...o)}}_getInvalidityExplanation(){const e=[];if(this.discardedTracks.length===0)e.push("Due to missing tracks, this conversion cannot be executed.");else{const t=this.discardedTracks.every(r=>r.reason==="discarded_by_user"||r.reason==="no_encodable_target_codec")&&this.discardedTracks.some(r=>r.reason==="no_encodable_target_codec");if(e.push("Due to discarded tracks, this conversion cannot be executed."),t){const r=this.discardedTracks.flatMap(d=>{if(d.reason==="discarded_by_user")return[];let c;return d.track.type==="video"?c=this.output.format.getSupportedVideoCodecs():d.track.type==="audio"?c=this.output.format.getSupportedAudioCodecs():c=this.output.format.getSupportedSubtitleCodecs(),c.filter(u=>!d.trackOptions.codec||u===d.trackOptions.codec)}),a=[...new Set(r)];a.length===1?e.push(`
10
- Tracks were discarded because your environment is not able to encode '${a[0]}' with the provided parameters.`):e.push(`
11
- Tracks were discarded because your environment is not able to encode any of the codecs ${a.map(d=>`'${d}'`).join(", ")} with the provided parameters.`),a.includes("mp3")&&e.push(`
12
- The @mediabunny/mp3-encoder extension package provides support for encoding MP3.`),a.includes("aac")&&e.push(`
13
- The @mediabunny/aac-encoder extension package provides support for encoding AAC.`),(a.includes("ac3")||a.includes("eac3"))&&e.push(`
14
- The @mediabunny/ac3 extension package provides support for encoding and decoding AC-3/E-AC-3.`),a.includes("flac")&&e.push(`
15
- The @mediabunny/flac-encoder extension package provides support for encoding FLAC.`)}else e.push(`
16
- Check the discardedTracks field for more info.`)}return e}async execute(e={}){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(e.until!==void 0&&(typeof e.until!="number"||Number.isNaN(e.until)))throw new TypeError("options.until, when provided, must be a number.");if(e.pauseSignal!==void 0&&!(e.pauseSignal instanceof AbortSignal))throw new TypeError("options.pauseSignal, when provided, must be an AbortSignal.");if(!this.isValid)throw new Error(`Cannot execute this conversion because its output configuration is invalid. Make sure to always check the isValid field before executing a conversion.
17
- `+this._getInvalidityExplanation().join(""));if(this.state==="executing")throw new Error("Cannot call execute() while a previous call to execute() is still running.");if(this.state==="canceled")throw new ce;if(this.state==="done")return;if(this._composable&&this.output.state==="pending")throw new Error("A composable conversion requires the output to be started. Call start() on the output before executing the conversion.");this.state="executing",this._executionUntil=e.until??1/0,this._pauseRequested=e.pauseSignal?.aborted??!1;const t=()=>{this.state==="executing"&&(this._pauseRequested=!0,this._synchronizer.resolveAll())};e.pauseSignal?.addEventListener("abort",t);for(const a of this._trackPumps)a.done||(a.resolvers=Y());if(this._executed)for(const a of this._trackPumps)a.wake?.();else{this._executed=!0;for(const a of this._outputTrackIds)this._synchronizer.declareTrack(a);if(this.onProgress){const d=[...new Set(this.utilizedTracks)].map(async u=>await u.isLive()?1/0:await u.getDurationFromMetadata()??await u.computeDuration()),c=Math.max(0,...await Promise.all(d));this._computeProgress=!0,this._totalDuration=Math.min(c-this._startTimestamp,this._endTimestamp-this._startTimestamp);for(const u of this._outputTrackIds)this._maxTimestamps.set(u,0);this.onProgress?.(0,0)}this._composable||await this.output.start();for(const a of this._trackPumps)a.start()}try{await Promise.all(this._trackPumps.map(a=>a.resolvers.promise))}catch(a){throw this.state!=="canceled"&&this.cancel(),a}finally{e.pauseSignal?.removeEventListener("abort",t)}if(this.state==="canceled")throw new ce;const r=this._trackPumps.every(a=>a.done);if(this.state=r?"done":"idle",r&&(this._composable||await this.output.finalize(),this._computeProgress)){const a=Math.min(...this._maxTimestamps.values());this.onProgress?.(1,a)}}async cancel(){if(this.state!=="done"){if(this.state==="canceled"){Q._warn("Conversion already canceled.");return}this.state="canceled";for(const e of this._trackPumps)e.wake?.();this._synchronizer.resolveAll(),this._composable||await this.output.cancel()}}async _processVideoTrack(e,t,r){const a=await e.getCodec();if(!a){this.discardedTracks.push({track:e,reason:"unknown_source_codec",trackOptions:t});return}let d;const c=await e.getRotation(),u=O(c+(t.rotate??0));let R=u;const o=this.output.format.supportsVideoRotationMetadata&&(t.allowRotationMetadata??!0),i=await e.getSquarePixelWidth(),m=await e.getSquarePixelHeight(),[w,n]=u%180===0?[i,m]:[m,i];let h=t.crop;h&&(h=fe(h,w,n));const[D,k]=h?[h.width,h.height]:[w,n];let b=D,g=k;const L=b/g;t.width!==void 0&&t.height===void 0?(b=j(t.width),g=j(Math.round(b/L))):t.width===void 0&&t.height!==void 0?(g=j(t.height),b=j(Math.round(g*L))):t.width!==void 0&&t.height!==void 0&&(b=j(t.width),g=j(t.height));const M=await e.getFirstTimestamp();let E=this.output.format.getSupportedVideoCodecs();const T=!!t.forceTranscode||M<this._startTimestamp||!!t.frameRate||t.keyFrameInterval!==void 0||t.process!==void 0||t.quality!==void 0||t.bitrate!==void 0||!E.includes(a)||t.codec&&t.codec!==a||b!==D||g!==k||u!==0&&!o||!!h,y=t.alpha??"discard";if(T){if(!await e.canDecode()){this.discardedTracks.push({track:e,reason:"undecodable_source_codec",trackOptions:t});return}t.codec&&(E=E.filter(v=>v===t.codec));const l=te(t.quality,t.bitrate)??new q("high"),V=await we(E,{width:t.process&&t.processedWidth?t.processedWidth:b,height:t.process&&t.processedHeight?t.processedHeight:g,quality:l});if(!V){this.discardedTracks.push({track:e,reason:"no_encodable_target_codec",trackOptions:t});return}const f={codec:V,quality:l,keyFrameInterval:t.keyFrameInterval,sizeChangeBehavior:t.fit??"passThrough",alpha:y,hardwareAcceleration:t.hardwareAcceleration,transform:{}};C(f.transform);let F=b!==D||g!==k||u!==0&&(!o||t.process!==void 0)||!!h||i!==await e.getCodedWidth()||m!==await e.getCodedHeight();if(!F){const v={stack:[],error:void 0,hasError:!1};try{const A=new ne({format:new Ee,target:new Se}),W=new de(f);A.addVideoTrack(W),await A.start();const I=new se(e),S=U(v,await I.getSample(M),!1);if(S)try{await W.add(S),S.close(),await A.finalize()}catch(K){Q._warn("An error occurred when probing encoder support. Falling back to rerender path.",K),A.cancel(),F=!0,f.transform.force=!0}else await A.cancel()}catch(A){v.error=A,v.hasError=!0}finally{H(v)}}t.frameRate&&(f.transform.frameRate=t.frameRate),t.process&&(f.transform.process=t.process),F&&(R=0,f.transform.width=b,f.transform.height=g,f.transform.fit=t.fit??"fill",f.transform.rotate=O(u-c),f.transform.crop=h,f.transform.alpha=y);let _=null;f.onEncodedSample=v=>{_=v.timestamp};const p=new de(f);d=p,this._registerTrackPump(async v=>{const A=new se(e);for await(const W of A.samples(this._startTimestamp,this._endTimestamp)){const I={stack:[],error:void 0,hasError:!1};try{const S=U(I,W,!1);if(this.state==="canceled")break;const K=Math.max(S.timestamp-this._startTimestamp,0);S.setTimestamp(K),this._reportProgress(r,S.timestamp+S.duration),await p.add(S),S.close(),_!==null&&(this._synchronizer.shouldWait(r,_)&&await this._synchronizer.wait(_),await this._checkpoint(v,_))}catch(S){I.error=S,I.hasError=!0}finally{H(I)}}p.close(),this._synchronizer.closeTrack(r)})}else{const P=new ve(a);d=P,this._registerTrackPump(async l=>{const V=new ee(e),F={decoderConfig:await e.getDecoderConfig()??void 0};for await(const _ of V.packets(void 0,void 0,{verifyKeyPackets:!0})){if(this.state==="canceled"||_.timestamp>=this._endTimestamp)break;const p=_.clone({timestamp:_.timestamp-this._startTimestamp,sideData:y==="discard"?{}:_.sideData});C(p.timestamp>=0),this._reportProgress(r,p.timestamp+p.duration),await P.add(p,F),this._synchronizer.shouldWait(r,p.timestamp)&&await this._synchronizer.wait(p.timestamp),await this._checkpoint(l,p.timestamp)}P.close(),this._synchronizer.closeTrack(r)})}let x=null;!t.group&&!this._composable&&(x=new z);const N=await e.getLanguageCode();this.output.addVideoTrack(d,{frameRate:t.frameRate,languageCode:re(N)?N:void 0,name:await e.getName()??void 0,disposition:await e.getDisposition(),rotation:R,group:x??t.group}),this.utilizedTracks.push(e),this._outputTrackIds.push(r),this._outputOwnTrackGroups.push(x)}async _processAudioTrack(e,t,r){const a=await e.getCodec();if(!a){this.discardedTracks.push({track:e,reason:"unknown_source_codec",trackOptions:t});return}let d;const c=await e.getNumberOfChannels(),u=await e.getSampleRate(),R=await e.getFirstTimestamp();let o=t.numberOfChannels??c,i=t.sampleRate??u;const m=R<this._startTimestamp;let w=R>this._startTimestamp&&!this.output.format.supportsTimestampedMediaData,n=this.output.format.getSupportedAudioCodecs();if(!t.forceTranscode&&!t.quality&&!t.bitrate&&o===c&&i===u&&!m&&!w&&n.includes(a)&&(!t.codec||t.codec===a)&&!t.process&&t.sampleFormat===void 0){const k=new Ae(a);d=k,this._registerTrackPump(async b=>{const g=new ee(e),M={decoderConfig:await e.getDecoderConfig()??void 0};for await(const E of g.packets()){if(this.state==="canceled"||E.timestamp>=this._endTimestamp)break;const T=E.clone({timestamp:E.timestamp-this._startTimestamp});C(T.timestamp>=0),this._reportProgress(r,T.timestamp+T.duration),await k.add(T,M),this._synchronizer.shouldWait(r,T.timestamp)&&await this._synchronizer.wait(T.timestamp),await this._checkpoint(b,T.timestamp)}k.close(),this._synchronizer.closeTrack(r)})}else{if(!await e.canDecode()){this.discardedTracks.push({track:e,reason:"undecodable_source_codec",trackOptions:t});return}let b=null;t.codec&&(n=n.filter(y=>y===t.codec));const g=te(t.quality,t.bitrate)??new q("high"),L=await ae(n,{numberOfChannels:t.process&&t.processedNumberOfChannels?t.processedNumberOfChannels:o,sampleRate:t.process&&t.processedSampleRate?t.processedSampleRate:i,quality:g});if(!L.some(y=>$.includes(y))&&n.some(y=>$.includes(y))&&(o!==X||i!==J)){const x=(await ae(n,{numberOfChannels:X,sampleRate:J,quality:g})).find(N=>$.includes(N));x&&(b=x,o=X,i=J)}else b=L[0]??null;if(b===null){this.discardedTracks.push({track:e,reason:"no_encodable_target_codec",trackOptions:t});return}const M={codec:b,quality:g,transform:{sampleFormat:t.sampleFormat,process:t.process}};C(M.transform),o!==c&&(M.transform.numberOfChannels=o),i!==u&&(M.transform.sampleRate=i);let E=null;M.onEncodedSample=y=>{E=y.timestamp};const T=new Ce(M);d=T,this._registerTrackPump(async y=>{const x=new be(e);for await(const N of x.samples(this._startTimestamp,this._endTimestamp)){const P={stack:[],error:void 0,hasError:!1};try{const l=U(P,N,!1);if(this.state==="canceled")break;if(w){const p={stack:[],error:void 0,hasError:!1};try{const v=R-this._startTimestamp,A=Math.round(v*u),W=ge(l.format),I=new Uint8Array(W*A*c);(l.format==="u8"||l.format==="u8-planar")&&I.fill(2**7);const S=U(p,new ye({data:I,format:l.format,numberOfChannels:c,sampleRate:u,timestamp:0}),!1);await this._registerAudioSample(y,S,T,r,()=>E),w=!1}catch(v){p.error=v,p.hasError=!0}finally{H(p)}}let V=0,f=l.numberOfFrames;l.timestamp<this._startTimestamp&&(V=Math.round((this._startTimestamp-l.timestamp)*l.sampleRate)),l.timestamp+l.duration>this._endTimestamp&&(f=Math.round((this._endTimestamp-l.timestamp)*l.sampleRate));let F;if(V>0||f<l.numberOfFrames){const p=l.trim(V,f);if(l.close(),F=p,p.numberOfFrames===0){p.close();continue}}else F=l;const _=U(P,F,!1);_.setTimestamp(_.timestamp-this._startTimestamp),await this._registerAudioSample(y,_,T,r,()=>E)}catch(l){P.error=l,P.hasError=!0}finally{H(P)}}T.close(),this._synchronizer.closeTrack(r)})}let h=null;!t.group&&!this._composable&&(h=new z);const D=await e.getLanguageCode();this.output.addAudioTrack(d,{languageCode:re(D)?D:void 0,name:await e.getName()??void 0,disposition:await e.getDisposition(),group:h??t.group}),this.utilizedTracks.push(e),this._outputTrackIds.push(r),this._outputOwnTrackGroups.push(h)}async _registerAudioSample(e,t,r,a,d){this._reportProgress(a,t.timestamp+t.duration),await r.add(t),t.close();const c=d();c!==null&&(this._synchronizer.shouldWait(a,c)&&await this._synchronizer.wait(c),await this._checkpoint(e,c))}_registerTrackPump(e){const t={done:!1,resolvers:Y(),wake:null,start:()=>{e(t).then(()=>{t.done=!0,t.resolvers.resolve()},r=>{t.resolvers.reject(r)})}};this._trackPumps.push(t)}async _checkpoint(e,t){for(;this.state!=="canceled"&&(t>=this._executionUntil||this._pauseRequested);){e.resolvers.resolve();const{promise:r,resolve:a}=Y();e.wake=a,await r}}_reportProgress(e,t){if(!this._computeProgress)return;C(this._totalDuration!==null),this._maxTimestamps.set(e,Math.max(t,this._maxTimestamps.get(e)));const r=Math.min(...this._maxTimestamps.values()),a=Te(r/this._totalDuration,0,1);a!==this._lastProgress&&(this._lastProgress=a,this.onProgress?.(a,r))}}class ce extends Error{constructor(e="Conversion has been canceled."){super(e),this.name="ConversionCanceledError"}}const ue=1;class ke{constructor(e){this.maxTimestamps=new Map,this.resolvers=[],this.conversion=e}declareTrack(e){this.maxTimestamps.set(e,0)}shouldWait(e,t){const r=this.maxTimestamps.get(e);C(r!==void 0),this.maxTimestamps.set(e,Math.max(t,r));const a=this.computeMinAndMaybeResolve();return this.conversion.state==="canceled"||this.conversion._pauseRequested||t>=this.conversion._executionUntil?!1:t-a>ue}wait(e){const{promise:t,resolve:r}=Y();return this.resolvers.push({timestamp:e,resolve:r}),t}closeTrack(e){this.maxTimestamps.delete(e),this.computeMinAndMaybeResolve()}resolveAll(){for(const e of this.resolvers)e.resolve();this.resolvers.length=0}computeMinAndMaybeResolve(){let e=1/0;for(const[,t]of this.maxTimestamps)e=Math.min(e,t);for(let t=0;t<this.resolvers.length;t++){const r=this.resolvers[t];r.timestamp-e<ue&&(r.resolve(),this.resolvers.splice(t,1),t--)}return e}}/*!
18
- * Copyright (c) 2026-present, Vanilagy and contributors
19
- *
20
- * This Source Code Form is subject to the terms of the Mozilla Public
21
- * License, v. 2.0. If a copy of the MPL was not distributed with this
22
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
23
- */const le=Symbol.for("mediabunny loaded");globalThis[le]&&Q._error(`[WARNING]
24
- Mediabunny was loaded twice. This will likely cause Mediabunny not to work correctly. Check if multiple dependencies are importing different versions of Mediabunny, or if something is being bundled incorrectly.`);globalThis[le]=!0;export{Ie as ADTS,De as ALL_FORMATS,ms as ALL_TRACK_TYPES,oe as AUDIO_CODECS,xe as AdtsInputFormat,fs as AdtsOutputFormat,ws as AppendOnlyStreamTarget,Ve as AttachedFile,Le as AudioBufferSink,bs as AudioBufferSource,ye as AudioSample,Ne as AudioSampleResource,be as AudioSampleSink,Ce as AudioSampleSource,gs as AudioSource,We as BaseMediaSampleSink,je as BlobSource,qe as BufferSource,ys as BufferTarget,ze as CanvasSink,Ts as CanvasSource,_s as CmafOutputFormat,Ue as ConcurrentRunner,he as Conversion,ce as ConversionCanceledError,He as CustomAudioDecoder,Ge as CustomAudioEncoder,Be as CustomPathedSource,Qe as CustomSource,Ye as CustomVideoDecoder,Ke as CustomVideoEncoder,Ae as EncodedAudioPacketSource,$e as EncodedPacket,ee as EncodedPacketSink,ve as EncodedVideoPacketSource,Xe as EventEmitter,Je as FLAC,Ze as FilePathSource,vs as FilePathTarget,Oe as FlacInputFormat,Ss as FlacOutputFormat,et as HLS,tt as HLS_FORMATS,st as HlsInputFormat,Es as HlsOutputFormat,pe as Input,rt as InputAudioTrack,at as InputDisposedError,it as InputFormat,ot as InputTrack,nt as InputVideoTrack,dt as IsobmffInputFormat,As as IsobmffOutputFormat,ct as LogLevel,Q as Logging,ut as MATROSKA,ht as MP3,lt as MP4,pt as MPEG_TS,mt as MatroskaInputFormat,Cs as MediaSource,ks as MediaStreamAudioTrackSource,Ms as MediaStreamVideoTrackSource,Ps as MkvOutputFormat,Rs as MovOutputFormat,ft as Mp3InputFormat,Fs as Mp3OutputFormat,wt as Mp4InputFormat,Ee as Mp4OutputFormat,bt as MpegTsInputFormat,Is as MpegTsOutputFormat,$ as NON_PCM_AUDIO_CODECS,Se as NullTarget,gt as OGG,yt as OggInputFormat,Ds as OggOutputFormat,ne as Output,xs as OutputAudioTrack,Vs as OutputFormat,Ls as OutputSubtitleTrack,Ns as OutputTrack,z as OutputTrackGroup,Ws as OutputVideoTrack,Tt as PCM_AUDIO_CODECS,_t as PathedSource,js as PathedTarget,vt as QTFF,St as QUALITY_HIGH,Et as QUALITY_LOW,At as QUALITY_MEDIUM,Ct as QUALITY_VERY_HIGH,kt as QUALITY_VERY_LOW,q as Quality,Mt as QuickTimeInputFormat,Pt as RangedSource,qs as RangedTarget,Rt as ReadableStreamSource,Ft as RichImageData,It as SUBTITLE_CODECS,Dt as Source,xt as SourceRef,Vt as StreamSource,zs as StreamTarget,Us as SubtitleSource,Hs as Target,Gs as TextSubtitleSource,Lt as UnsupportedInputFormatError,Nt as UrlSource,ie as VIDEO_CODECS,Wt as VIDEO_SAMPLE_PIXEL_FORMATS,jt as VideoSample,qt as VideoSampleColorSpace,zt as VideoSampleResource,se as VideoSampleSink,de as VideoSampleSource,Bs as VideoSource,Ut as WAVE,Ht as WEBM,Qs as WavOutputFormat,Gt as WaveInputFormat,Bt as WebMInputFormat,Ys as WebMOutputFormat,Qt as asc,Yt as canDecode,Kt as canDecodeAudio,$t as canDecodeVideo,Xt as canEncode,Jt as canEncodeAudio,Zt as canEncodeSubtitles,Ot as canEncodeVideo,es as desc,ts as getDecodableAudioCodecs,ss as getDecodableCodecs,rs as getDecodableVideoCodecs,ae as getEncodableAudioCodecs,as as getEncodableCodecs,is as getEncodableSubtitleCodecs,os as getEncodableVideoCodecs,ns as getFirstEncodableAudioCodec,ds as getFirstEncodableSubtitleCodec,we as getFirstEncodableVideoCodec,cs as prefer,us as registerDecoder,hs as registerEncoder,ls as registerVideoSampleTransformer};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-BxyxB2bD.js","assets/titleFrameBudget-BYRZAQPs.js","assets/api-DUp403BK.js","assets/timeline3dExport-T57qnWi9.js","assets/timeline3d-246tBEJl.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/frameSink-BvOXjLuw.js","assets/titleFrames-BVgm601q.js","assets/titleArt-B8DVR58F.js","assets/textAnimators-nVSz_sZo.js","assets/lottieLayer-1ET89OUr.js","assets/rigTrack-UYZU4P-e.js","assets/rotoMatte-BdYa8FSB.js","assets/store-75tQUvPT.js","assets/windowFrames-D_2QJCJJ.js","assets/gpuExport-DQB6x4eh.js","assets/timelineComp-BcewYGR2.js","assets/gpuCompose-CNkLwpbZ.js","assets/motionBlur-uAm030t9.js","assets/exportEncode-MUwVTI52.js","assets/distortGL-BlmBZKRU.js","assets/id3-BCR9Bqgo.js","assets/output-BwZzMbp-.js","assets/clientExport-BL1XMTF0.js"])))=>i.map(i=>d[i]);
2
- import{_ as l,c1 as v,iQ as $}from"./titleFrameBudget-BYRZAQPs.js";import{FrameSink as P,SKIPPED_FRAME as b}from"./frameSink-BvOXjLuw.js";class x extends P{want;next=new Map;last=new Map;out={};constructor(o){super({put:async()=>{throw Error("a pick sink keeps its frames")}}),this.want=new Map;for(const[c,s]of Object.entries(o))for(const[r,n]of Object.entries(s||{}))this.want.set(`${c}
3
- ${r}`,new Set(n));this.wants=(c,s,r)=>{const n=this.want.get(`${c}
4
- ${s}`);return!!n&&(r===void 0||n.has(r))}}async push(o,c,s){const r=`${o}
5
- ${c}`,n=this.next.get(r)??0;if(this.next.set(r,n+1),s===b)return;const a=s==="="?this.last.get(r):s;a!==void 0&&(this.last.set(r,a),this.want.get(r)?.has(n)&&(((this.out[o]??={})[c]??={})[n]=a))}picked(){return this.out}}const F=(i,o)=>Object.keys(i[o]||{}).length>0,O={async frames({clips:i,format:o,camera:c=null,want:s}){const{unpackMasks:r}=await l(async()=>{const{unpackMasks:e}=await import("./rotoMaskStore-BxyxB2bD.js").then(w=>w.X);return{unpackMasks:e}},__vite__mapDeps([0,1,2])),n=await r(i);i=n.clips;const a=new x(s),g={},p=v(o).fps,d=a.wants,h=async(e,w,_)=>{for(const f of w){a.wants=(u,k,y)=>u===e&&k===f&&d(u,k,y);try{await _()}catch(u){g[f]=String(u?.message||u).slice(0,200)}finally{a.wants=d}}},E=e=>Object.keys(s[e]||{});if(F(s,"modelFrames")){const{render3DFrames:e}=await l(async()=>{const{render3DFrames:w}=await import("./timeline3dExport-T57qnWi9.js");return{render3DFrames:w}},__vite__mapDeps([3,1,4,5,6,2,7,8]));await h("modelFrames",E("modelFrames"),()=>e(i,o,a,void 0,c))}if(F(s,"titleFrames")){const{renderTitleFrames:e}=await l(async()=>{const{renderTitleFrames:_}=await import("./titleFrames-BVgm601q.js");return{renderTitleFrames:_}},__vite__mapDeps([9,1,10,11,12,13,2,8])),w=[...i,...$(i)];await h("titleFrames",E("titleFrames"),()=>e(w,o,a,void 0,c))}if(F(s,"matteFrames")){const e=await l(()=>import("./rotoMatte-BdYa8FSB.js").then(_=>_.r),__vite__mapDeps([14,1,2,15])),w=[...i,...e.maskedCopies(i)];await h("matteFrames",E("matteFrames"),()=>e.renderMatteFrames(w,p,a))}if(F(s,"windowFrames")){const e=await l(()=>import("./windowFrames-D_2QJCJJ.js"),__vite__mapDeps([16,1,14,2,15]));await h("windowFrames",E("windowFrames"),()=>e.renderWindowFrames(i,p,a))}return{frames:a.picked(),failed:g,missingMasks:n.missing}},async gpuExport({clips:i,format:o,tracks:c={},camera:s=null,encode:r=null,range:n,only:a,name:g="film.mp4",softwareEncoder:p=!1}){const d=await l(()=>import("./gpuExport-DQB6x4eh.js"),__vite__mapDeps([17,1,18,19,20,21,2,22,23,24]));if(p){if(a!=="video"||!await d.canEncodeH264(o))throw Object.assign(new Error("no H.264 encoder in this browser"),{name:"NoEncoder"})}else if(!await d.gpuExportSupported(o,r))throw Object.assign(new Error("no hardware video encoder in this browser"),{name:"NoEncoder"});const{softwareRetry:h}=await l(async()=>{const{softwareRetry:t}=await import("./clientExport-BL1XMTF0.js");return{softwareRetry:t}},__vite__mapDeps([25,1,18])),E=t=>{try{window.__clipooxProgress?.(t)}catch{}};let e=p;const w=`/__clipoox/out/${encodeURIComponent(g)}`,_=()=>new WritableStream({async write(t){const m=await fetch(`${w}?at=${t.position}`,{method:"PATCH",body:t.data});if(!m.ok)throw new Error(`the film could not be handed over (${m.status})`)}}),f=t=>d.exportOnGpu(i,{format:o,encode:r,tracks:c,camera:s,onProgress:E,software:t,liveMotion:!0,range:n,only:a,sink:_()}),u=t=>{const m=t instanceof Error?`${t.name}: ${t.message}`:String(t);return new Error(`${d.gpuExportStage()||"start"}${n?` (frames ${n.from}–${n.to})`:""}: ${m}`)},k=await f(p).catch(t=>{if(!h(t,d.gpuExportStage(),r))throw u(t);return e=!0,f(!0).catch(m=>{throw u(m)})});let y="";try{const t=document.createElement("canvas").getContext("webgl2"),m=t?.getExtension("WEBGL_debug_renderer_info");y=String(m&&t?t.getParameter(m.UNMASKED_RENDERER_WEBGL):"").slice(0,120)}catch{}return{ms:k.ms,software:e,gpu:y}}};window.__layerWorker=O;
@@ -1 +0,0 @@
1
- import{gE as f}from"./remote-Dva2qg58.js";import{ie as E,hy as G,ig as L,ih as P}from"./remote-Dva2qg58.js";import{e as l}from"./skin-CVwmK130.js";import"./api-DUp403BK.js";import"./titleFrameBudget-BYRZAQPs.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-75tQUvPT.js";import"./rotoMaskStore-BxyxB2bD.js";import"./textAnimators-nVSz_sZo.js";import"./timelineComp-BcewYGR2.js";import"./rigTrack-UYZU4P-e.js";async function M(o,s,a,m=2e4){let e;for(const t=Date.now()+m;!e&&Date.now()<t;){const i=o.getStage().items.find(r=>r.id===s);if(!i||i.rig!==a)return!1;e=o.engine()?.objects?.children.find(r=>r.userData.id===s)?.children[0],e||await new Promise(r=>setTimeout(r,150))}if(!e)return!1;const p=f(a,{positions:l(e).positions});let n=!1;return o.setStage(t=>({...t,items:t.items.map(i=>i.id===s&&i.rig===a?(n=!0,{...i,rig:p}):i)})),n}export{M as fitLibraryFingers,E as libraryModelFields,G as libraryModelItem,L as libraryRig,P as wantsFingers};