clipoox-render 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/package.json +1 -1
  2. package/scripts/render-local.mjs +1480 -1479
  3. package/web/assets/FxEmbed-BymBArNa.js +1 -0
  4. package/web/assets/MotionEmbed-PmXWSWe5.js +1 -0
  5. package/web/assets/PluginStore-BVsm6n6N.js +3 -0
  6. package/web/assets/{ShotComposer-AHScyNYv.js → ShotComposer-Dprx-Yi7.js} +4 -4
  7. package/web/assets/TemplateEmbed-CrZXoUk_.js +2 -0
  8. package/web/assets/{TimelinePlugins-CkP5P9b_.js → TimelinePlugins-B1KGtbmb.js} +3 -3
  9. package/web/assets/TimelineShotFx-DoLx312Y.js +2 -0
  10. package/web/assets/TransitionEmbed-C5SUosv2.js +1 -0
  11. package/web/assets/{Whiteboard-C9Mwa3nF.js → Whiteboard-DybaKCdo.js} +3 -3
  12. package/web/assets/aerial-DSt_mJNA.js +2 -0
  13. package/web/assets/agentTools-CxZqRLeR.js +2 -0
  14. package/web/assets/analyzerRun-DCJwb_-Z.js +1 -0
  15. package/web/assets/{analyzerSandbox-DQGHjUCa.js → analyzerSandbox-DO5ZTv5q.js} +2 -2
  16. package/web/assets/{api-C5pOWyBM.js → api-BsKbf3l3.js} +4 -4
  17. package/web/assets/auraTrack-QR0WqBHp.js +1 -0
  18. package/web/assets/breakthrough-Dv1bndQb.js +2 -0
  19. package/web/assets/{cameraPresets-CeStHDvF.js → cameraPresets-B234aNzE.js} +1 -1
  20. package/web/assets/{captionLayout-BAdmqwdS.js → captionLayout-CNgb471H.js} +1 -1
  21. package/web/assets/clientExport-NtJmxOYP.js +1 -0
  22. package/web/assets/{depthEstimate-1OjTo_pb.js → depthEstimate-wVYSJtW8.js} +1 -1
  23. package/web/assets/directorTools-BqFcShgT.js +1 -0
  24. package/web/assets/{distortFrames-D39fkQ_H.js → distortFrames-D3TQNcJA.js} +2 -2
  25. package/web/assets/{distortGL-5uNfls9s.js → distortGL-BklPDXPq.js} +1 -1
  26. package/web/assets/editTools-BQlG5WB_.js +1 -0
  27. package/web/assets/exportEncode-CaKEPgsy.js +1 -0
  28. package/web/assets/exportGlb-DstxwzH5.js +2 -0
  29. package/web/assets/faceTracker-DWxxieVC.js +1 -0
  30. package/web/assets/fightDirector-OMlPZgjv.js +1 -0
  31. package/web/assets/fightDrama-G7bXfpQu.js +2 -0
  32. package/web/assets/{frameSink-CB1EghW0.js → frameSink-Dj71jCRb.js} +3 -3
  33. package/web/assets/{gpuCompose-EfzSAeMh.js → gpuCompose-DIxBHlTa.js} +1 -1
  34. package/web/assets/gpuExport-CPSw_dmq.js +189 -0
  35. package/web/assets/handMatte-DHsHHz4m.js +1 -0
  36. package/web/assets/handTracker-D_O-C4Dw.js +2 -0
  37. package/web/assets/{index-BGZJld3s.js → index-CZn97Ygs.js} +1 -1
  38. package/web/assets/layer-worker-Bar7WgOA.js +5 -0
  39. package/web/assets/library-BtBrCaFk.js +1 -0
  40. package/web/assets/{lottieLayer-BhLbZOpr.js → lottieLayer-CfUPParC.js} +4 -4
  41. package/web/assets/{lottie_light_canvas-D9fsNLID.js → lottie_light_canvas-7iv3btPX.js} +1 -1
  42. package/web/assets/main-BPmr0TOL.css +1 -0
  43. package/web/assets/{main-BNZrzSIG.js → main-M1vRa-gd.js} +32 -32
  44. package/web/assets/{mapBake-BAG6i5fI.js → mapBake-lPNhNZgv.js} +1 -1
  45. package/web/assets/maskTrack-D2jUh7aw.js +1 -0
  46. package/web/assets/matteFixRun-B7tWV9Y1.js +1 -0
  47. package/web/assets/motionBlur-uAm030t9.js +1 -0
  48. package/web/assets/{objectLocate-Dhktxe5z.js → objectLocate-BDqfSo9J.js} +1 -1
  49. package/web/assets/pendingMatte-q35zVaiB.js +2 -0
  50. package/web/assets/personAi-ZjQVo-80.js +2 -0
  51. package/web/assets/plateCamera-A2E_WO_x.js +1 -0
  52. package/web/assets/plateCameraMatch-D41LQrsm.js +2 -0
  53. package/web/assets/plateFollow-CNfi4xuP.js +2 -0
  54. package/web/assets/plateMatte-BdIxGhw5.js +2 -0
  55. package/web/assets/{pluginAutomation-DdZOnpoV.js → pluginAutomation-BtQ_w2TB.js} +1 -1
  56. package/web/assets/poseTracker-DVX__OK7.js +1 -0
  57. package/web/assets/productTools-r2RgILaA.js +2 -0
  58. package/web/assets/{remote-DXG553d8.js → remote-sTZauTqM.js} +77 -77
  59. package/web/assets/rigTrack-Bx9QHlFv.js +1 -0
  60. package/web/assets/{rotoMaskStore-DrRawyH9.js → rotoMaskStore-pxpRt5Cj.js} +1 -1
  61. package/web/assets/{rotoMatte-2EcyuvBX.js → rotoMatte-DyXlW4jK.js} +1 -1
  62. package/web/assets/rotoscope-GORCSVBr.js +1 -0
  63. package/web/assets/shot-worker-B8JWkmBz.js +1 -0
  64. package/web/assets/{shotFxAgent-CETPcjzU.js → shotFxAgent-CzHfe75S.js} +2 -2
  65. package/web/assets/{skin-BQG1Iz6Q.js → skin-BkaT2QuX.js} +1 -1
  66. package/web/assets/{spark.module-CMSPLU2n.js → spark.module-BRT8yMS4.js} +10 -10
  67. package/web/assets/spellDuel-BUy289OT.js +2 -0
  68. package/web/assets/{store-Dxq3MZF3.js → store-BSSbvpzr.js} +1 -1
  69. package/web/assets/{surfaceLight-B_OSTxcx.js → surfaceLight-CMaBhZ_d.js} +1 -1
  70. package/web/assets/surfacePin-DM9b9ubh.js +2 -0
  71. package/web/assets/textAnimators-Cihw35O8.js +1 -0
  72. package/web/assets/{thumb-xLFX6lDN.js → thumb-Cs636sYt.js} +1 -1
  73. package/web/assets/{timeline3d-DqXTKdEK.js → timeline3d-BEuZZOxM.js} +2 -2
  74. package/web/assets/{timeline3dExport-MWomW4fF.js → timeline3dExport-CmSI_pjv.js} +1 -1
  75. package/web/assets/timelineComp-CRRzLazc.js +1 -0
  76. package/web/assets/timelineProps-tN2YsMYN.js +1 -0
  77. package/web/assets/timelineText-CkoUgWcY.js +1 -0
  78. package/web/assets/{titleArt-CAOxtyHl.js → titleArt-CcTdJuOC.js} +5 -5
  79. package/web/assets/{titleFrameBudget-BjW--v_T.js → titleFrameBudget-3MFHWIT6.js} +1 -1
  80. package/web/assets/titleFrames-w-iWje9N.js +1 -0
  81. package/web/assets/{tool-DEWWeyCz.js → tool-BhIsq238.js} +1 -1
  82. package/web/assets/tools-DMUnabc_.js +1 -0
  83. package/web/assets/toonTools-CICrV3QB.js +2 -0
  84. package/web/assets/trackAnchor-D2bB5mZE.js +1 -0
  85. package/web/assets/userFonts-BZ4QL-zq.js +1 -0
  86. package/web/assets/{vfxAlpha-vbbI-03F.js → vfxAlpha-D3Dk1tfF.js} +2 -2
  87. package/web/assets/vfxBackground-CHlCg8lb.js +2 -0
  88. package/web/assets/{vfxTrack-BmxWjlDi.js → vfxTrack-CqiQDEYm.js} +1 -1
  89. package/web/assets/videoExport-l5MGvMn_.js +1 -0
  90. package/web/assets/views-BdWnG2xK.js +1 -0
  91. package/web/assets/weaponDuel-B2wTffPC.js +1 -0
  92. package/web/assets/{windowFrames-DydW5Al5.js → windowFrames-CoIyWqxr.js} +1 -1
  93. package/web/layer-worker.html +3 -3
  94. package/web/assets/FxEmbed-B5TQxKxk.js +0 -1
  95. package/web/assets/MotionEmbed-Catb_GgA.js +0 -1
  96. package/web/assets/PluginStore-8TjQawtB.js +0 -3
  97. package/web/assets/TemplateEmbed-Cao8Z5fY.js +0 -2
  98. package/web/assets/TimelineShotFx-DvmPZQXM.js +0 -2
  99. package/web/assets/TransitionEmbed-o4UxJ35e.js +0 -1
  100. package/web/assets/aerial-BPRLPci2.js +0 -2
  101. package/web/assets/agentTools-CSnN-LvS.js +0 -2
  102. package/web/assets/analyzerRun-5zJsmMS1.js +0 -1
  103. package/web/assets/auraTrack-pF-WhpH3.js +0 -1
  104. package/web/assets/breakthrough-DQN1i-Pw.js +0 -2
  105. package/web/assets/clientExport-Ca9a3Jiy.js +0 -1
  106. package/web/assets/directorTools-CvmghG_6.js +0 -1
  107. package/web/assets/editTools-CUoVvupD.js +0 -1
  108. package/web/assets/exportEncode-pFxeatJt.js +0 -1
  109. package/web/assets/exportGlb-MK05aKqH.js +0 -2
  110. package/web/assets/faceTracker-_rQOgBvX.js +0 -1
  111. package/web/assets/fightDirector-Dt60kfbV.js +0 -1
  112. package/web/assets/fightDrama-py4jxSdn.js +0 -2
  113. package/web/assets/gpuExport-Cnv2NfEb.js +0 -189
  114. package/web/assets/handMatte-DZCsuqD2.js +0 -1
  115. package/web/assets/handTracker-Btr9L-Hu.js +0 -2
  116. package/web/assets/layer-worker-Rbo-YZv-.js +0 -5
  117. package/web/assets/library-CdukL2BW.js +0 -1
  118. package/web/assets/main-By_IEoB_.css +0 -1
  119. package/web/assets/maskTrack-AZwAVz1c.js +0 -1
  120. package/web/assets/matteFixRun-wTHGiGGf.js +0 -1
  121. package/web/assets/pendingMatte-iKz2-XBZ.js +0 -2
  122. package/web/assets/personAi-BEVyjCii.js +0 -2
  123. package/web/assets/plateCamera-D_J3-X06.js +0 -1
  124. package/web/assets/plateCameraMatch-C0peOvBn.js +0 -2
  125. package/web/assets/plateFollow-BbJMVxfg.js +0 -2
  126. package/web/assets/plateMatte-u5wKpsUN.js +0 -2
  127. package/web/assets/poseTracker--VJYw-hX.js +0 -1
  128. package/web/assets/productTools-DbhbyJxx.js +0 -2
  129. package/web/assets/rigTrack-CW9_kg5j.js +0 -1
  130. package/web/assets/rotoscope-_CYT-9ry.js +0 -1
  131. package/web/assets/shot-worker-BxIzQRZh.js +0 -1
  132. package/web/assets/spellDuel-eZvRwaxi.js +0 -2
  133. package/web/assets/surfacePin-CfLBhSrm.js +0 -2
  134. package/web/assets/timelineProps-KL6XCR4Q.js +0 -1
  135. package/web/assets/timelineText-DEK2BRyU.js +0 -1
  136. package/web/assets/titleFrames-WfiLHzjf.js +0 -1
  137. package/web/assets/tools-CBfIZX8_.js +0 -1
  138. package/web/assets/toonTools-D7jucq3t.js +0 -2
  139. package/web/assets/trackAnchor-DFqKIb8a.js +0 -1
  140. package/web/assets/userFonts-txN4I-eo.js +0 -1
  141. package/web/assets/vfxBackground-C1dHlJN6.js +0 -2
  142. package/web/assets/videoExport-DiNI9GY1.js +0 -1
  143. package/web/assets/views-sH39zgjD.js +0 -1
  144. package/web/assets/weaponDuel-CEvRDeuE.js +0 -1
@@ -0,0 +1 @@
1
+ import{f as R,au as b,ik as C,eO as nt,eP as ot,eQ as Mt,ji as bt,i7 as T,F as vt,fn as _t,gT as it,ec as L,g$ as at,h3 as St,gU as Pt,gW as $t,fs as tt,jh as rt,m as E,l as A,gS as st,fc as G,lE as ut,lF as z,iq as et,ea as q,d5 as dt,lG as lt,h as U,s as pt,h$ as Ot,i0 as Et}from"./titleFrameBudget-3MFHWIT6.js";const $=1/vt,w=1e-6,X=t=>typeof t=="number"&&Number.isFinite(t);function jt(t){if(t===null)return null;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(i=>i!=="in"&&i!=="out")||!X(t.in)||!X(t.out))throw Error("Invalid export range");const n=b(t.in),e=b(t.out);if(n<0||e>R||e-n<$-w)throw Error("Invalid export range");return{in:n,out:e}}function B(t,n){if(t==null&&n==null)return null;const e=jt({in:t??0,out:n??R});return e.in<=w&&e.out>=R-w?null:e}function Jt(t,n,e){const i=Math.max(0,Math.min(R,b(e))),o=t?.in??0,s=t?.out??R;try{return n==="in"?i>=R-$+w?void 0:B(i,i>=s-w?null:s):i<$-w?void 0:B(i<=o+w?null:o,i)}catch{return}}function Qt(t,n,e,i){if(!(i>=$))return t??null;const o=t?.in??0,s=t?.out??R;try{if(n==="in")return B(Math.max(0,Math.min(b(e),b(Math.min(s,i)-$))),s>=R-w?null:s);const f=Math.max(b(o+$),Math.min(b(e),i));return B(o,f>=i-w?null:f)}catch{return t??null}}function Zt(t,n){if(!t||!X(t.in)||!X(t.out)||!(n>0))return null;const e=Math.max(0,Math.min(n,t.in)),i=Math.max(0,Math.min(n,t.out));return i-e<$-w||e<=w&&i>=n-w?null:{in:e,out:i}}function Rt(t,n,e){if(!t||!Array.isArray(t.motionKeys)||!t.motionKeys.length)return t;let i={...t,motionKeys:[]};for(const o of St){const s=Pt(t,o);if(!s.length)continue;const f=s.some(a=>a.time<n-w),l=s.some(a=>a.time>e+w),p=[...s].reverse().find(a=>a.time<=n+w);i=$t(i,o,[...f?[{time:0,value:tt(t,o,n),...p?.ease!==void 0?{ease:p.ease}:{}}]:[],...s.filter(a=>(f?a.time>n+w:a.time>=n-w)&&(l?a.time<e-w:a.time<=e+w)).map(a=>({...a,time:Math.max(0,b(a.time-n))})),...l?[{time:b(e-n),value:tt(t,o,e)}]:[]])}return i}const At=t=>[...t.parentId?[t.parentId]:[],...Array.isArray(t.shape?.items)?t.shape.items.flatMap(n=>n?.pins&&typeof n.pins=="object"?Object.values(n.pins):[]):[]];function Ft(t,n,e,i,o,s){const f=n.find(I=>I.id===t.id)??t,l=t.start+t.duration<=e+w?t.duration:0,p=_t(f,l,o,s),a=p.sx??1,r=p.sy??1,v=it("image",t.track)?t.track:0;return{...at({id:t.id,track:v,start:0,duration:i,label:String(t.label||"Null").slice(0,160)}),posX:p.x,posY:p.y,scale:p.zoom,rotation:p.rot,anchorX:L(t,"ax",l),anchorY:L(t,"ay",l),...a!==1||r!==1?{motionKeys:[{time:0,sx:a,sy:r}]}:{}}}function J({clips:t,camera:n=null},e,{W:i=1280,H:o=720}={}){if(!e||!Array.isArray(t))return{clips:t,camera:n};const s=e.in,f=e.out,l=b(f-s),p=[];for(const m of t){if(m.start+m.duration<=s+w||m.start>=f-w)continue;let k=m;if(k.start<s-w){const x=b(s-k.start);if(k.duration-x<$-w)continue;if(x>=$-w){const _=C(k,s,`${m.id}~in`);_.length===2&&(k={..._[1],id:m.id})}}if(k.start+k.duration>f+w){const x=b(f-k.start);if(x<$-w)continue;k.duration-x>=$-w&&(k=C(k,f,`${m.id}~out`)[0])}p.push({...k,start:Math.max(0,b(k.start-s))})}const a=new Set(p.map(m=>m.id)),r=new Map(t.map(m=>[m.id,m])),v=[...new Set(p.flatMap(At))].filter(m=>!a.has(m)&&r.get(m)&&!r.get(m).disabled&&r.get(m).kind!=="audio");let I=[];if(v.length){const m=nt(ot(t.filter(k=>!k.disabled)));Mt(m),I=v.map(k=>Ft(r.get(k),m,s,l,i,o))}const y=new Set([...a,...I.map(m=>m.id)]);return{clips:[...p.map(m=>{const k=r.get(m.id),x=[];let _=m;if(m.parentId&&!y.has(m.parentId)&&x.push("parentId"),m.matte&&!a.has(m.matte.source)&&(x.push("matte"),m.matte.mode?.endsWith("-inverted")||(_={...m,opacity:0,motionKeys:bt(m,"opacity",[])})),m.transition&&k&&T(t,k)&&!T(p,m)&&x.push("transition"),m.join&&k&&T(t,k)&&!T(p,m)&&x.push("join"),!x.length)return _;_={..._};for(const F of x)delete _[F];return _}),...I],camera:Rt(n,s,f)}}const j=t=>!!t&&!!t.comp&&Array.isArray(t.comp.clips),D=">",Q=t=>j(t)?1+Math.max(0,...t.comp.clips.map(Q)):0,mt=t=>j(t)?t.comp.clips.reduce((n,e)=>n+1+mt(e),0):0,Tt=t=>j(t)?Math.max(0,...t.comp.clips.map(n=>n.start+n.duration)):0,ft=t=>{let n=1;for(;t.some(e=>e.label===`Comp ${n}`);)n++;return`Comp ${n}`},K=t=>String(t).padStart(3,"0"),V=["x","y","zoom","rot","ax","ay"],zt={x:0,y:0,zoom:1,rot:0,ax:0,ay:0};function Z(t){return t.parentId||V.some(n=>q(t,n).length||Math.abs(L(t,n,0)-zt[n])>1e-9)?!0:["enter","exit"].some(n=>t[n]&&t[n].type!=="fade")}const ct=t=>q(t,"opacity").length>0||["enter","exit"].some(n=>t[n]&&(t[n].type==="fade"||t[n].fade!==!1));function ht(t,n){const e=[];for(const o of t.motionKeys||[]){const s={time:o.time};for(const l of V)Number.isFinite(o[l])&&(s[l]=o[l]);if(Object.keys(s).length===1)continue;const f=o.ease&&Object.fromEntries(Object.entries(o.ease).filter(([l])=>V.includes(l)));f&&Object.keys(f).length&&(s.ease=f),e.push(s)}const i=Object.fromEntries(["posX","posY","scale","rotation","anchorX","anchorY","parentId","zIndex","enter","exit"].filter(o=>t[o]!==void 0).map(o=>[o,t[o]]));return{...at({id:n,track:t.track,start:t.start,duration:t.duration,label:t.label}),...i,motionKeys:e,_comp:t.id}}function Kt(t,n){if(Math.abs(n-1)<1e-9)return t;const e=q(t,"opacity"),i={...t,opacity:(t.opacity??1)*n};return e.length?{...i,...dt(i,"opacity",e.map(o=>({...o,value:o.value*n})))}:i}function Nt(t,n){const e=Math.max(1,Math.ceil(t.duration*60-1e-6)),i=[];for(let o=0;o<=e;o++){const s=Math.min(t.duration,o/60);i.push({time:+s.toFixed(6),value:Math.max(0,Math.min(1,L(t,"opacity",s)*n(s)))})}return{...t,...dt(t,"opacity",i)}}function W(t,n){const e={...t},i=o=>n(o);if(e.parentId!==void 0){const o=i(e.parentId);o?e.parentId=o:delete e.parentId}if(e.matte?.source!==void 0){const o=i(e.matte.source);o?e.matte={...e.matte,source:o}:delete e.matte}e._virtual!==void 0&&(e._virtual=i(e._virtual)??e._virtual),typeof e.space=="string"&&(e.space=i(e.space)??e.space);for(const o of["bend","vfx"])typeof e[o]?.source=="string"&&(e[o]={...e[o],source:i(e[o].source)??e[o].source});return Array.isArray(e.shape?.items)&&e.shape.items.some(o=>o?.pins)&&(e.shape={...e.shape,items:e.shape.items.map(o=>o?.pins&&typeof o.pins=="object"?{...o,pins:Object.fromEntries(Object.entries(o.pins).map(([s,f])=>[s,i(f)??f]))}:o)}),e}const Dt=t=>{if(t.transition===void 0&&t.join===void 0)return t;const{transition:n,join:e,...i}=t;return i};function H(t){const n=t.comp.tracks||{};return t.comp.clips.filter(e=>!e.disabled&&!(e.kind!=="audio"&&n[e.track]?.hidden)).map(e=>n[e.track]?.muted?{...e,volume:0}:e)}function kt(t,n,e,i){const o=t.inPoint||0,s=t.start-o;return J({clips:n},{in:o,out:o+t.duration},{W:e,H:i}).clips.map(l=>{const p={...l,start:b(t.start+l.start)};for(const a of["_txIn","_txOut"])p[a]&&(p[a]={...p[a],t0:p[a].t0+s});return p})}function Lt(t,n){const e=t.inPoint||0;if(U(t)&&!t.reverse)return e+pt(t,Math.max(0,Math.min(t.duration,n)));const i=t.playbackRate||1,o=Math.max(0,Math.min(t.duration,n));return e+(t.reverse?Math.max(0,t.duration-o-1/30):o)*i}function yt(t){const n=t.inPoint||0,e=U(t)&&!t.reverse?pt(t,t.duration):t.duration*(t.playbackRate||1);return{from:n,to:n+e}}function wt(t){const n=H(t),e=new Set(n.map(o=>o.id)),i=`${t.id}${D}`;return n.map(o=>({...W(o,s=>e.has(s)?i+s:null),id:i+o.id}))}function It(t,{W:n=1280,H:e=720}={}){const{from:i,to:o}=yt(t);return J({clips:wt(t)},{in:i,out:o},{W:n,H:e}).clips.map(s=>({...s,volume:0}))}function Ut(t,{W:n=1280,H:e=720}={}){const i=[],o=(s,f)=>{for(const l of s)if(l?._group&&j(l)&&f<z){const p=N(It(l,{W:n,H:e}),{W:n,H:e});i.push(p),o(p,f+1)}};return o(N(t||[],{W:n,H:e}),0),i}function Xt(t,n,e,i){if(t.reverse||U(t))return[];const o=t.playbackRate||1,s=t.inPoint||0,f=`${t.id}${D}`,l=N(H(t),{W:e,H:i,depth:n+1}).filter(a=>a.url&&(a.volume??1)>0&&(a.kind==="audio"||a.kind==="video"&&!a.freeze&&!a.reverse));return J({clips:l},{in:s,out:s+t.duration*o},{W:e,H:i}).clips.flatMap(a=>{const r=(a.playbackRate||1)*o;return r>8||U(a)&&o!==1?[]:[{...Object.fromEntries(["nodeId","url","gcsUri","label","inPoint","sourceDuration","audioFx","duck","muffle"].filter(I=>a[I]!==void 0).map(I=>[I,a[I]])),id:`${f}${a.id}~a`,kind:"audio",track:a.kind==="audio"?a.track:st[0],start:b(t.start+a.start/o),duration:Math.max(1/30,b(a.duration/o)),volume:(a.volume??1)*(t.volume??1),...r!==1?{playbackRate:r}:{},...a.speedRamp&&o===1?{speedRamp:a.speedRamp}:{},...a.audioFadeIn?{audioFadeIn:a.audioFadeIn/o}:{},...a.audioFadeOut?{audioFadeOut:a.audioFadeOut/o}:{},_comp:t.id,_slot:`§a${f}${a.id}`}]})}function gt(t,n,e){let i=n;return n.kind!=="audio"&&!n.nullLayer&&(i=e!==null?Kt(i,e):Nt(i,o=>G(t,i.start-t.start+o).opacity)),t.volume!==void 0&&t.volume!==1&&(n.kind==="video"||n.kind==="audio")&&(i={...i,volume:(i.volume??1)*t.volume}),t.lookBypass&&(i={...i,lookBypass:!0}),i}function Bt(t,n,e,i,o){if(n>=z)return[];t={...t,...rt(t)};let s=nt(ot(H(t))).map(Dt);s=N(s,{W:e,H:i,depth:n+1});const f=kt(t,s,e,i),l=new Set(f.map(y=>y.id)),p=`${t.id}${D}`,a=o?`${p}~comp`:null,r=ct(t)?null:G(t,0).opacity,v=[...new Set(f.filter(y=>y.kind!=="audio").map(y=>`${K((y.zIndex??0)+200)}:${K(E(y.track)+1)}`))].sort(),I=f.map(y=>{let g=W(y,m=>l.has(m)?p+m:null);return g={...gt(t,g,r),id:p+y.id,_comp:t.id,...g.parentId===void 0&&a&&y.kind!=="audio"?{parentId:a}:{}},y.kind!=="audio"?(g.track=t.track,g._slot=`§${K(v.indexOf(`${K((y.zIndex??0)+200)}:${K(E(y.track)+1)}`))}${y._slot??""}`,t.zIndex!==void 0?g.zIndex=t.zIndex:delete g.zIndex):g._slot=`§${y._slot??""}${y.id}`,g});return I.sort((y,g)=>y._slot<g._slot?-1:y._slot>g._slot?1:0),a?[ht(t,a),...I]:I}function N(t,{W:n=1280,H:e=720,depth:i=0}={}){if(!Array.isArray(t)||!t.some(r=>j(r)&&!r._group))return t;const o=new Set(t.filter(r=>r.transition).map(r=>T(t,r)?.id).filter(Boolean)),s=r=>lt(r)||o.has(r.id),f=new Set(t.filter(r=>r.parentId).map(r=>r.parentId)),l=new Set(t.filter(r=>j(r)&&!s(r)).map(r=>r.id)),p=new Map,a=[];for(const r of t){if(!j(r)||r._group){a.push(r);continue}if(r.disabled)continue;if(s(r)){i<z&&a.push({...r,_group:!0},...Xt(r,i,n,e));continue}const v=Z(r)||f.has(r.id);v&&p.set(r.id,`${r.id}${D}~comp`),a.push(...Bt(r,i,n,e,v))}return a.map(r=>{if(r.parentId&&p.has(r.parentId))return{...r,parentId:p.get(r.parentId)};if(r.matte&&l.has(r.matte.source)){const{matte:v,...I}=r;return I}return r})}function Yt(t,n,{id:e,label:i,tracks:o={},W:s=1280,H:f=720}={}){const l=new Set(n||[]),p=t.filter(u=>l.has(u.id));if(!p.length)throw Error("Precompose: select at least one layer");if(!p.some(u=>u.kind!=="audio"))throw Error("Precompose needs at least one picture layer");if(p.some(u=>o[u.track]?.locked))throw Error("Track đã khóa");if(1+Math.max(0,...p.map(Q))>z)throw Error(`Comps nest at most ${z} deep`);const a=t.filter(u=>!l.has(u.id)),r=[...p.filter(u=>u.matte&&!l.has(u.matte.source)),...a.filter(u=>u.matte&&l.has(u.matte.source))];if(r.length)throw Error(`Precompose: the track matte of "${r[0].label||r[0].id}" crosses the comp's edge — take the matte layer in too, or remove the matte`);const v=b(Math.min(...p.map(u=>u.start))),I=b(Math.max(...p.map(u=>u.start+u.duration))),y=Math.max(1/30,b(I-v)),g=u=>a.some(c=>c.track===u&&c.kind!=="audio"&&c.start<I-1e-6&&c.start+c.duration>v+1e-6)||o[u]?.locked,m=[...new Set(p.filter(u=>u.kind!=="audio").map(u=>u.track))].sort((u,c)=>E(c)-E(u));let k=m.find(u=>!g(u));for(let u=E(m[0])+1;k===void 0;u++)g(A(u))||(k=A(u));const x=u=>T(t,u),_=p.map(u=>{let c={...u};return c.parentId&&!l.has(c.parentId)&&(c={...c,...et(t,u,null,0,s,f)}),c.transition&&!l.has(x(u)?.id)&&delete c.transition,c.join&&!l.has(x(u)?.id)&&delete c.join,c.parentId===void 0&&delete c.parentId,{...c,start:b(u.start-v)}}),F=a.map(u=>{let c=u;return u.parentId&&l.has(u.parentId)&&(c={...c,...et(t,u,null,0,s,f)},c.parentId===void 0&&(c={...c},delete c.parentId)),(c.transition||c.join)&&l.has(x(u)?.id)&&(c={...c},delete c.transition,delete c.join),c}),O=[...new Set(p.map(u=>u.track))].filter(u=>o[u]?.hidden||o[u]?.muted),Y=Object.fromEntries(O.map(u=>[u,{...o[u].hidden?{hidden:!0}:{},...o[u].muted?{muted:!0}:{}}])),P={id:e||`comp-${Date.now().toString(36)}`,nodeId:"",kind:"image",url:"",label:i||ft(t),track:k,start:v,duration:y,inPoint:0,sourceDuration:y,motionV:2,comp:{clips:_,...O.length?{tracks:Y}:{}}};return{clips:[...F,P],id:P.id,track:k}}function Vt(t,n,{tracks:e={},W:i=1280,H:o=720,newId:s=()=>`null-${Math.random().toString(36).slice(2,9)}`}={}){const f=t.find(d=>d.id===n);if(!j(f))throw Error("Uncompose needs a comp layer");if(e[f.track]?.locked)throw Error("Track đã khóa");const l={...f,...rt(f)},p=t.filter(d=>d.id!==n),a=new Set(p.map(d=>d.id)),r=l.comp.tracks||{},v=l.comp.clips.map(d=>({...d,...r[d.track]?.hidden&&d.kind!=="audio"?{disabled:!0}:{},...r[d.track]?.muted?{volume:0}:{}})),I=kt(l,v,i,o),y=new Map;for(const d of I){let h=d.id,M=2;for(;a.has(h)||[...y.values()].includes(h);)h=`${d.id}-${M++}`;y.set(d.id,h)}const g=[...p],m=(d,h)=>!e[d]?.locked&&!g.some(M=>M.track===d&&h.some(S=>M.start<S.start+S.duration-1e-6&&M.start+M.duration>S.start+1e-6)),k=new Map,x=[...new Set(I.filter(d=>d.kind!=="audio").map(d=>d.track))].sort((d,h)=>E(d)-E(h)),_=d=>I.filter(h=>h.kind!=="audio"&&h.track===d),F=x.every(d=>m(d,_(d)));let O=F?E(x.at(-1)??l.track)+1:E(l.track);for(const d of x){const h=_(d);if(F){k.set(d,d),g.push(...h);continue}for(;!m(A(O),h);)O++;k.set(d,A(O)),g.push(...h.map(M=>({...M,track:A(O)}))),O++}for(const d of[...new Set(I.filter(h=>h.kind==="audio").map(h=>h.track))]){const h=I.filter(S=>S.kind==="audio"&&S.track===d),M=[d,...st.filter(S=>S!==d)].find(S=>m(S,h));if(M===void 0)throw Error("Uncompose: no free audio row for the comp's sounds");k.set(d,M),g.push(...h.map(S=>({...S,track:M})))}const Y=Z(l)||p.some(d=>d.parentId===n);let P=null;if(Y){let d=O;const h=[{start:l.start,duration:l.duration}];for(;!m(A(d),h);)d++;let M=s();for(;a.has(M);)M=s();const{_comp:S,...xt}=ht(l,M);P={...xt,track:A(d),label:l.label||"Null"}}const u=ct(l)?null:G(l,0).opacity,c=I.map(d=>{let h=W(d,M=>y.get(M)??null);if(h={...gt(l,h,u),id:y.get(d.id),track:k.get(d.track)??d.track},h.parentId===void 0&&P&&d.kind!=="audio"&&(h.parentId=P.id),!it(h.kind,h.track))throw Error("Uncompose: no free row");return h});return{clips:[...p.map(d=>d.parentId===n?P?{...d,parentId:P.id}:(({parentId:h,...M})=>M)(d):d),...P?[P]:[],...c],ids:c.map(d=>d.id),nullId:P?.id??null,dropped:ut(f)}}const Wt=Object.freeze(Object.defineProperty({__proto__:null,COMP_DEPTH:z,COMP_SEP:D,compBlockers:Ot,compClipCount:mt,compContentEnd:Tt,compDepth:Q,compGrouped:lt,compInner:wt,compLabel:ft,compMoves:Z,compPictureFields:ut,compRange:yt,compRenderLevel:It,compTime:Lt,expandComps:N,groupedLevels:Ut,isComp:j,precompose:Yt,stripComp:Et,uncompose:Vt},Symbol.toStringTag,{value:"Module"}));export{wt as a,Lt as b,Tt as c,Zt as d,N as e,ft as f,mt as g,Qt as h,j as i,Jt as j,B as m,Yt as p,J as s,Wt as t,Vt as u};
@@ -0,0 +1 @@
1
+ import{dx as P,ez as O,dy as M,i3 as R,fB as E,fD as j}from"./remote-sTZauTqM.js";import"./api-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const K=(t,e,i=.1)=>["X","Y","Z"].map((o,s)=>({id:t+s,label:`${e} ${o}`,step:i})),A=[...K("p","Vị trí"),...K("t","Nhìn tới"),{id:"lens",label:"Tiêu cự (mm)",step:1,min:14,max:200},{id:"roll",label:"Nghiêng (°)",step:1}],U=[...K("p","Vị trí"),...K("r","Xoay",1),{id:"s",label:"Kích thước",step:.05,min:.05}],_=K("o","Lệch"),X=[...K("p","Vị trí"),{id:"s",label:"Kích thước",step:.05,min:.05}],p=t=>t.shots.find(e=>e.id===t.activeShot)||t.shots[0];function J(t,e){if(e==="camera")return A;const i=t.items.find(o=>o.id===e);return i?i.kind==="fx"?i.fx?.attach?_:X:U:[]}function q(t,e){return e==="camera"?t.motion==="path"&&!!t.cameraKeys?.length:(t.objectKeys?.[e]?.length??0)>0}const y=t=>+t.slice(1);function G(t,e,i,o){const s=p(t);if(e==="camera"){const c=P(s,o);return i==="lens"?c.lens:i==="roll"?c.roll:(i[0]==="p"?c.position:c.target)[y(i)]}const r=t.items.find(c=>c.id===e);if(!r)return 0;if(i[0]==="o")return O(r,s,o).position[y(i)];const n=M(r,s,o);return i==="s"?n.scale[0]:(i[0]==="p"?n.position:n.rotation)[y(i)]}const C=t=>+t.toFixed(3);function H(t,e,i,o,s,r=()=>crypto.randomUUID()){const n=p(t);if(!n||!Number.isFinite(s))return t;const c=f=>({...t,shots:t.shots.map(l=>l.id===n.id?{...l,...f}:l)});if(e==="camera"){const f=P(n,o),l={position:[...f.position],target:[...f.target],roll:f.roll};return i==="roll"?l.roll=s:i!=="lens"&&((i[0]==="p"?l.position:l.target)[y(i)]=s),c(R(n,o,l,r,i==="lens"?s:void 0))}const a=t.items.find(f=>f.id===e);if(!a||a.locked)return t;if(i[0]==="o"){const f=O(a,n,o).position.slice();if(f[y(i)]=s,E(a,n))return j(t,e,o,{position:f});const l={...a.fx.attach,offset:f};return{...t,items:t.items.map(u=>u.id===e?{...u,fx:{...u.fx,attach:l}}:u)}}const d=M(a,n,o),m={position:[...d.position],rotation:[...d.rotation],scale:[...d.scale]};i==="s"?m.scale=d.scale[0]>1e-6?d.scale.map(f=>C(f*s/d.scale[0])):[s,s,s]:(i[0]==="p"?m.position:m.rotation)[y(i)]=s;const h=n.objectKeys?.[e]||[];if(h.length){const f=h.find(u=>Math.abs(u.time-o)<1e-6),l={...f,id:f?.id??r(),time:o,...m};return c({objectKeys:{...n.objectKeys,[e]:[...h.filter(u=>u.id!==l.id),l].sort((u,F)=>u.time-F.time)}})}return{...t,items:t.items.map(f=>f.id===e?{...f,...m}:f)}}const b=1e-6,S=(t,e)=>e==="camera"?t.motion==="path"?t.cameraKeys||[]:[]:t.objectKeys?.[e]||[];function x(t,e,i){const o=p(t),s=[...i].sort((r,n)=>r.time-n.time);if(e==="camera"){const r=s,n=r[0],c=r[r.length-1],a={cameraKeys:r,motion:r.length?"path":"static",...n&&c?{position:n.position,target:n.target,lens:n.lens,roll:n.roll,endPosition:c.position,endTarget:c.target,endLens:c.lens}:{}};return{...t,shots:t.shots.map(d=>d.id===o.id?{...d,...a}:d)}}return{...t,shots:t.shots.map(r=>r.id===o.id?{...r,objectKeys:{...r.objectKeys,[e]:s}}:r)}}const k=(t,e)=>e!=="camera"&&!!t.items.find(i=>i.id===e)?.locked;function D(t,e,i,o=()=>crypto.randomUUID()){const s=p(t);if(!s||k(t,e))return t;const r=S(s,e);if(r.some(a=>Math.abs(a.time-i)<b))return t;if(e==="camera"){const a=P(s,i);return x(t,e,[...r,{id:o(),time:i,position:a.position,target:a.target,lens:a.lens,roll:a.roll}])}const n=t.items.find(a=>a.id===e);if(!n)return t;if(n.kind==="fx"&&n.fx?.attach)return j(t,e,i,{id:o()});const c=M(n,s,i);return x(t,e,[...r,{id:o(),time:i,position:c.position,rotation:c.rotation,scale:c.scale}])}function I(t,e,i){return["camera",...t.items.filter(o=>!o.hidden).map(o=>o.id)].reduce((o,s)=>D(o,s,e,i),t)}function Q(t,e){const i=p(t);return e.flatMap(o=>{const s=S(i,o.row).find(r=>r.id===o.id);return s?[{row:o.row,key:structuredClone(s)}]:[]})}function W(t,e,i,o=()=>crypto.randomUUID()){if(!e.length)return{stage:t,pasted:[]};const s=Math.min(...e.map(c=>c.key.time)),r=[];let n=t;for(const c of new Set(e.map(a=>a.row))){if(k(n,c)||c!=="camera"&&!n.items.some(d=>d.id===c))continue;let a=[...S(p(n),c)];for(const d of e.filter(m=>m.row===c)){const m=Math.min(1,Math.max(0,d.key.time-s+i)),h={...structuredClone(d.key),id:o(),time:m};a=[...a.filter(f=>Math.abs(f.time-m)>=b),h],r.push({row:c,id:h.id})}n=x(n,c,a)}return{stage:n,pasted:r}}function v(t,e,i){let o=t;for(const s of new Set(e.map(r=>r.row))){if(k(o,s))continue;const r=new Set(e.filter(n=>n.row===s).map(n=>n.id));o=x(o,s,S(p(o),s).map(n=>r.has(n.id)?{...n,ease:i}:n))}return o}function g(t,e,i){let o=t,s=!1;for(const r of new Set(e.map(n=>n.row))){if(k(o,r))continue;const n=new Set(e.filter(m=>m.row===r).map(m=>m.id)),a=S(p(o),r).map(m=>n.has(m.id)?{...m,time:m.time+i}:m);a.every(m=>m.time>=-b&&m.time<=1+b)&&a.every((m,h)=>a.every((f,l)=>h>=l||Math.abs(m.time-f.time)>b))&&(s=!0,o=x(o,r,a.map(m=>({...m,time:Math.min(1,Math.max(0,m.time))}))))}return{stage:o,moved:s}}export{A as CAMERA_PROPS,X as FX_FREE_PROPS,_ as FX_OFFSET_PROPS,U as OBJECT_PROPS,D as addKeyAt,Q as copyKeys,v as easeKeys,I as keyAllAt,g as nudgeKeys,W as pasteKeys,G as readProp,q as rowKeyed,J as rowProps,H as writeProp};
@@ -0,0 +1 @@
1
+ import{u as o}from"./store-BSSbvpzr.js";import{t as l,c as w}from"./api-BsKbf3l3.js";import{l as v,d as C}from"./titleArt-CcTdJuOC.js";import{i as h}from"./textAnimators-Cihw35O8.js";import"./titleFrameBudget-3MFHWIT6.js";async function y(g){const e=[],m=o.getState().canvasId;for(const t of g){if(!t.title||t.url){e.push(t);continue}const n=document.createElement("canvas");n.width=1280,n.height=720;const a=n.getContext("2d");if(!a)throw Error("Canvas unavailable");const r=await v(t.title),f=r.filter(h),c=r.filter(i=>!h(i));c.length&&o.getState().toast(l("Font {0} chưa tải được (mạng chập chờn) — chữ tạm dùng font thay thế. Chọn lại font để thử lại.",[c.join(", ")]),"info"),f.length&&o.getState().toast(l("Font riêng của chữ này không còn trong tài khoản của bạn — chữ dùng font mặc định. Tải font lên lại (Chữ → Font) hoặc chọn font khác."),"info"),C(a,t.title);const p=await new Promise((i,d)=>n.toBlob(s=>s?i(s):d(Error("Cannot create title")),"image/png")),u=await w(new File([p],"timeline-title.png",{type:"image/png"}));if(o.getState().canvasId!==m)throw Error("Canvas changed while creating text");e.push({...t,...u})}return e}export{y as materializeTitles};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/userFonts-txN4I-eo.js","assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js","assets/store-Dxq3MZF3.js","assets/rigTrack-CW9_kg5j.js"])))=>i.map(i=>d[i]);
2
- import{_ as st,mB as rt}from"./titleFrameBudget-BjW--v_T.js";import{an as it,ao as lt,q as ht,ap as ft,aq as Ve,ar as qe,as as Ye,at as dt,l as Ne,au as pt,av as ut,a as gt}from"./rigTrack-CW9_kg5j.js";const Ee=(e,t)=>typeof document<"u"?Object.assign(document.createElement("canvas"),{width:e,height:t}):new OffscreenCanvas(e,t),ne=1280,se=720,ue=new Map,ct=8,Ue=()=>Ee(ne,se);function Oe(e,t,s){const r=s*Math.PI/180,n=Math.cos(r),f=Math.sin(r),p=(Math.abs(n)*ne+Math.abs(f)*se)/2;return Math.min(1,Math.max(0,((e-ne/2)*n+(t-se/2)*f+p)/(2*p)))}function wt(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function mt(e,t){const s=Ue(),r=s.getContext("2d"),{scale:n,size:f,fade:p,fadeAngle:g}=e;if(r.fillStyle=t,e.pattern==="grain"){const b=Math.max(1,Math.round(n/4)),M=Math.ceil(ne/b),v=Math.ceil(se/b),T=wt(1729);for(let w=0;w<v;w++)for(let P=0;P<M;P++){const d=P*b,k=w*b,z=f*(1-p*Oe(d,k,g));T()<z&&r.fillRect(d,k,b,b)}return s}const l=e.angle*Math.PI/180,h=Math.cos(l),i=Math.sin(l),u=Math.hypot(ne,se)/2+n;r.beginPath();for(let b=-u;b<=u;b+=n){if(e.pattern==="lines"){for(let M=-u;M<u;M+=n*2){const v=ne/2+(M+n)*h-b*i,T=se/2+(M+n)*i+b*h,w=n*f*(1-p*Oe(v,T,g))/2;if(w<.15)continue;const P=[[M,b-w],[M+n*2,b-w],[M+n*2,b+w],[M,b+w]].map(([d,k])=>[ne/2+d*h-k*i,se/2+d*i+k*h]);r.moveTo(P[0][0],P[0][1]);for(const[d,k]of P.slice(1))r.lineTo(d,k);r.closePath()}continue}for(let M=-u;M<=u;M+=n){const v=ne/2+M*h-b*i,T=se/2+M*i+b*h;if(v<-n||T<-n||v>ne+n||T>se+n)continue;const w=n*.6*f*(1-p*Oe(v,T,g));w<.3||(r.moveTo(v+w,T),r.arc(v,T,w,0,Math.PI*2))}}return r.fill(),s}function yt(e,t,s){const r=JSON.stringify([e.pattern,e.scale,e.size,e.angle,e.fade,e.fadeAngle,t,s]);let n=ue.get(r);if(n)return ue.delete(r),ue.set(r,n),n;if(n=mt(e,s?"#000000":t),s){const f=Ue(),p=f.getContext("2d");p.fillStyle="#000000",p.fillRect(0,0,ne,se),p.globalCompositeOperation="destination-out",p.drawImage(n,0,0),n=f}return ue.set(r,n),ue.size>ct&&ue.delete(ue.keys().next().value),n}function bt(e,t,s){e.save(),e.setTransform(1,0,0,1,0,0),e.filter="none",e.shadowBlur=0,e.globalAlpha=t.opacity,e.globalCompositeOperation=t.mode==="atop"?"source-atop":"destination-out",e.drawImage(yt(t,s,t.mode==="keep"),0,0),e.restore()}const x={width:1280,height:720};let Mt=null;const kt=()=>Mt??=Ee(x.width,x.height);function St(e,t){const s=[];for(const r of t.split(`
3
- `)){let n="";for(const f of Array.from(r))n&&e.measureText(n+f).width>1050&&(s.push(n),n=""),n+=f;s.push(n)}return s}function Ot(e,t,s){if(t.design){if(!t.design.layers.some(k=>k.type==="texture"))return De(e,t,t.design,s);const P=kt(),d=P.getContext("2d");d.setTransform(1,0,0,1,0,0),d.globalAlpha=1,d.globalCompositeOperation="source-over",d.clearRect(0,0,x.width,x.height),De(d,t,t.design,s),e.drawImage(P,0,0);return}const{text:r,fontSize:n,color:f,placement:p,fontFamily:g="Arial",align:l="center",styleId:h="classic",accentColor:i="#32d8cd"}=t,u=h!=="classic",b=u?800:600;e.font=`${b} ${n}px "${g}", sans-serif`,e.textAlign=l,e.textBaseline="middle";const M=St(e,r),v=n*(u?1.12:1.3);if(M.length*v>560)throw Error("Text is too long for the frame; reduce copy or font size");const T=M.length*v,w=p==="top"?80+T/2:p==="lower"?640-T/2:360;M.forEach((P,d)=>{const k=l==="left"?90:l==="right"?1190:640,z=w+(d-(M.length-1)/2)*v,E=e.measureText(P).width;if(e.save(),h==="accent-bar"){const I=l==="left"?k-18:l==="right"?k-E-18:k-E/2-18;e.fillStyle=i,e.beginPath(),e.roundRect(I,z-n*.56,E+36,n*1.12,10),e.fill()}if(h==="tape-label"){const I=n*.45,_=E+I*2,F=n*1.32,R=l==="left"?k+E/2:l==="right"?k-E/2:k,L=(d%2?1:-1)*.028,j=6;e.save(),e.translate(R,z),e.rotate(L),e.beginPath(),e.moveTo(-_/2,-F/2),e.lineTo(_/2,-F/2);for(let W=1;W<=j;W++)e.lineTo(_/2+(W%2?n*.07:0),-F/2+F*W/j);e.lineTo(-_/2,F/2);for(let W=j-1;W>=0;W--)e.lineTo(-_/2-(W%2?n*.07:0),-F/2+F*W/j);e.closePath(),e.shadowColor="rgba(0,0,0,0.22)",e.shadowBlur=n*.12,e.shadowOffsetY=n*.04,e.globalAlpha=.94,e.fillStyle=i,e.fill(),e.shadowColor="transparent",e.globalAlpha=.07,e.strokeStyle="#5a4a30",e.lineWidth=1;for(let W=1;W<5;W++){const ae=-F/2+F*W/5;e.beginPath(),e.moveTo(-_/2,ae),e.lineTo(_/2,ae+(W%2?1.5:-1.5)),e.stroke()}e.restore(),e.save(),e.translate(R,z),e.rotate(L),e.translate(-R,-z)}if(h==="echo-stack"&&(e.fillStyle=i,e.globalAlpha=.82,e.fillText(P,k+13,z+13),e.globalAlpha=1),h==="outline-punch"&&(e.lineWidth=Math.max(4,n*.11),e.lineJoin="round",e.strokeStyle=i,e.strokeText(P,k,z)),h==="neon-edge"&&(e.shadowColor=i,e.shadowBlur=25,e.strokeStyle=i,e.lineWidth=Math.max(3,n*.07),e.lineJoin="round",e.strokeText(P,k,z),e.shadowBlur=12),h==="classic"&&(e.shadowColor="#000000",e.shadowBlur=8),e.fillStyle=h==="duotone-stack"&&d%2?i:f,e.fillText(P,k,z),h==="tape-label"&&e.restore(),h==="duotone-stack"&&d===M.length-1){const I=l==="left"?k:l==="right"?k-E:k-E/2;e.fillStyle=i,e.fillRect(I,z+n*.55,Math.min(E,760),Math.max(4,n*.07))}e.restore()})}const We=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter("vi",{granularity:"grapheme"}):null,le=e=>We?Array.from(We.segment(e),t=>t.segment):Array.from(e);function be(e,t){if(t>=.999||!/^#[0-9a-f]{6}$/i.test(e))return e;const s=parseInt(e.slice(1),16),r=Math.max(0,t);return`rgb(${Math.round((s>>16&255)*r)},${Math.round((s>>8&255)*r)},${Math.round((s&255)*r)})`}function Be(e,t,s){if(!/^#[0-9a-f]{6}$/i.test(e))return e;const r=parseInt(e.slice(1),16);return"#"+[r>>16&255,r>>8&255,r&255].map(n=>Math.round(n+(t-n)*s).toString(16).padStart(2,"0")).join("")}const _e=e=>{if(!/^#[0-9a-f]{6}$/i.test(e))return[e,e];const t=gt(e.toLowerCase()).gradient;return[t[0],t.at(-1)]};function He(e,t,s,r,n,f,p){const g=s+n/2,l=r+f/2;let h;if(t.type==="radial")h=e.createRadialGradient(g,l,0,g,l,Math.max(n,f)/2);else{const i=(t.angle??90)*Math.PI/180,u=Math.cos(i)*n/2,b=Math.sin(i)*f/2;h=e.createLinearGradient(g-u,l-b,g+u,l+b)}return t.gradient.forEach((i,u)=>h.addColorStop(t.stops?.[u]??u/(t.gradient.length-1),p(i))),h}const Tt=e=>typeof e=="string"?e:e.type==="radial"?e.gradient[0]:e.gradient.at(-1),Se=(e,t)=>{if(!/^#[0-9a-f]{6}$/i.test(e))return`rgba(255,255,255,${t})`;const s=parseInt(e.slice(1),16);return`rgba(${s>>16&255},${s>>8&255},${s&255},${t})`};function Ke(e,t,s,r){const n=r?.stretch??e.stretch;return`${r?.italic?"italic ":""}${r?.weight??e.weight} ${n&&n!=="normal"?n+" ":""}${t}px "${r?.font??s}", sans-serif`}function Te(e,t,s,r,n){e.font=Ke(t,s,r,n),"letterSpacing"in e&&(e.letterSpacing=`${((n?.tracking??t.tracking??0)*s).toFixed(2)}px`)}const Xe=e=>{const t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)};function Qe(e,t,s,r){const{fontSize:n,placement:f,fontFamily:p="Arial",align:g="center"}=t,l=s.stack==="ink";e.textBaseline=l?"alphabetic":"middle",e.textAlign="left";const h=!!s.lines,i=s.maxWidth?s.maxWidth*x.width:1050,u=!!s.lines?.some(T=>T.side||T.x||T.y||T.align),b=T=>{const w=[],P=r.split(`
4
- `);P.forEach((m,q)=>{const H=Ne(s,q,P.length);let o=n*(H?.scale??1)*T;if(Te(e,s,o,p,H),h){const c=u?i*T:i,a=e.measureText(m||" ").width;a>c&&(o*=c/a,Te(e,s,o,p,H))}const A=[];let y="";if(h)A.push(m);else if(s.wrap==="word"){for(const c of m.split(/(\s+)/))if(y&&y.trim()&&e.measureText(y+c).width>i&&c.trim()&&(A.push(y.trimEnd()),y=""),!(!y&&!c.trim()))if(e.measureText(c).width>i)for(const a of le(c))y&&e.measureText(y+a).width>i&&(A.push(y),y=""),y+=a;else y+=c;A.push(y.trimEnd())}else{for(const c of le(m))y&&e.measureText(y+c).width>i&&(A.push(y),y=""),y+=c;A.push(y)}for(const c of A){const a=e.measureText(c||" ");w.push({text:c,paragraph:q,size:o,fill:H?.fill,style:H,width:a.width,left:0,center:0,ascent:l?a.actualBoundingBoxAscent:o*.56,descent:l?a.actualBoundingBoxDescent:o*.56})}});const d=w.map(m=>l?m.ascent+m.descent:m.size*s.lineHeight),k=w.map(m=>l?(s.gap??.08)*m.size:0),z=m=>!!m.style?.side,E=w.map((m,q)=>q).filter(m=>!z(w[m]));let I=0;E.forEach((m,q)=>{I+=d[m]+(q?k[m]:0)});const _=(f==="top"?80:f==="lower"?640-I:x.height/2-I/2)+(s.shiftY??0)*x.height,F=(g==="left"?90:g==="right"?1190:x.width/2)+(s.shiftX??0)*x.width,R=Math.max(0,...E.map(m=>w[m].width)),L=g==="left"?F:g==="right"?F-R:F-R/2;let j=_;if(E.forEach((m,q)=>{const H=w[m];q&&(j+=k[m]),H.center=j+d[m]/2,j+=d[m];const o=H.style?.align??g;H.left=o==="left"?L:o==="right"?L+R-H.width:L+(R-H.width)/2}),!u)return{rows:w,heights:d,gaps:k,total:I,box:{x:L,y:_,w:R,h:I},extras:u,ink:l};const W=n*T;for(const m of w)z(m)&&(m.center=_+I/2,m.left=m.style.side==="left"?L-.12*W-m.width:L+R+.12*W),m.left+=(m.style?.x??0)*W,m.center+=(m.style?.y??0)*W;const ae=Math.min(...w.map(m=>m.left)),re=Math.max(...w.map(m=>m.left+m.width)),he=Math.min(...w.map((m,q)=>m.center-d[q]/2)),Me=Math.max(...w.map((m,q)=>m.center+d[q]/2)),ge=g==="left"?F-ae:g==="right"?F-re:F-(ae+re)/2,ce=(f==="top"?80:f==="lower"?640-(Me-he):x.height/2-(Me-he)/2)+(s.shiftY??0)*x.height-he;for(const m of w)m.left+=ge,m.center+=ce;return{rows:w,heights:d,gaps:k,total:I,box:{x:ae+ge,y:he+ce,w:re-ae,h:Me-he},extras:u,ink:l}};let M=b(1),v=1;for(let T=0;T<4;T++){const w=M.extras?M.box.h:M.total,P=Math.max(w/560,M.extras?M.box.w/i:0);if(P<=1)break;v*=.98/P,M=b(v)}if((M.extras?M.box.h:M.total)>560)throw Error("Text is too long for the frame; reduce copy or font size");return M}const Ze=(e,t)=>(t.uppercase?e.text.toLocaleUpperCase("vi"):e.text).normalize("NFC");function Bt(e){const t=Ee(1,1).getContext("2d");if(!t)return[];if(!e.design){const s=e.text.split(`
5
- `).length,r=Math.min(560,s*e.fontSize*1.3);return[{paragraph:-1,x:115,y:e.placement==="top"?80:e.placement==="lower"?640-r:360-r/2,w:1050,h:r,rotate:0}]}try{const s=Qe(t,e,e.design,Ze(e,e.design));return s.rows.map((r,n)=>({paragraph:r.paragraph,x:r.left,y:r.center-s.heights[n]/2,w:r.width,h:s.heights[n],rotate:r.style?.rotate??0}))}catch{return[]}}function Pt(e,t,s,r,n,f){const p=[[t,s+f*.1],[t+r*.55,s+f*.2],[t+r,s-f*.26]],g=28,l=[],h=[];for(let i=0;i<=g;i++){const u=i/g,b=(1-u)*(1-u),M=2*(1-u)*u,v=u*u,T=b*p[0][0]+M*p[1][0]+v*p[2][0],w=b*p[0][1]+M*p[1][1]+v*p[2][1],P=2*(1-u)*(p[1][0]-p[0][0])+2*u*(p[2][0]-p[1][0]),d=2*(1-u)*(p[1][1]-p[0][1])+2*u*(p[2][1]-p[1][1]),k=Math.hypot(P,d)||1,z=n*Math.pow(Math.sin(Math.PI*u),.55)*(1.25-.55*u)/2;l.push([T-d/k*z,w+P/k*z]),h.push([T+d/k*z,w-P/k*z])}e.beginPath(),e.moveTo(l[0][0],l[0][1]);for(const i of l.slice(1))e.lineTo(i[0],i[1]);for(const i of h.reverse())e.lineTo(i[0],i[1]);e.closePath()}function Ge(e,t,s,r,n){if(e.globalAlpha*=Math.min(1,Math.max(0,t.opacity)),e.globalAlpha<.002)return!1;const f=n*.3;if(t.wipeX<1){const l=(s.w+2*f)*Math.max(0,t.wipeX);e.beginPath(),e.rect(r==="right"?s.x+s.w+f-l:s.x-f,s.y-n*2,l,s.h+n*4),e.clip()}if(t.wipeY<1){const l=(s.h+2*f)*Math.max(0,t.wipeY);e.beginPath(),e.rect(s.x-n*2,r==="bottom"?s.y+s.h+f-l:s.y-f,s.w+n*4,l),e.clip()}const p=r==="left"?s.x:r==="right"?s.x+s.w:s.x+s.w/2,g=r==="top"?s.y:r==="bottom"?s.y+s.h:s.y+s.h/2;return e.translate(p+t.x*n,g+t.y*n),e.rotate(t.rotate*Math.PI/180),e.scale(t.scale*t.scaleX,t.scale*t.scaleY),e.translate(-p,-g),!0}const Le=[];function je(e,t,s){let r=Le[e];return(!r||r.width!==t||r.height!==s)&&(r=typeof document<"u"?Object.assign(document.createElement("canvas"),{width:t,height:s}):new OffscreenCanvas(t,s),Le[e]=r),r.getContext("2d")}function Ct(e,t,s,r){const n=e.canvas.width,f=e.canvas.height,p=e.getTransform(),g=je(0,n,f),l=je(1,n,f),h=i=>{i.font=e.font,i.textAlign=e.textAlign,i.textBaseline=e.textBaseline;const u=i,b=e;for(const M of["letterSpacing","fontStretch","fontKerning"])M in b&&(u[M]=b[M])};g.setTransform(1,0,0,1,0,0),g.globalCompositeOperation="source-over",g.clearRect(0,0,n,f),g.fillStyle=s,g.fillRect(0,0,n,f),g.setTransform(p),h(g),g.globalCompositeOperation="destination-out",g.fillStyle="#000",t(g),l.setTransform(1,0,0,1,0,0),l.globalCompositeOperation="source-over",l.clearRect(0,0,n,f),l.filter=`blur(${Math.max(.5,r).toFixed(1)}px)`,l.drawImage(g.canvas,0,0),l.filter="none",l.setTransform(p),h(l),l.globalCompositeOperation="destination-in",l.fillStyle="#000",t(l),e.save(),e.setTransform(1,0,0,1,0,0),e.shadowColor="transparent",e.filter="none",e.drawImage(l.canvas,0,0),e.restore()}function At(e,t,s,r,n,f){const{fontSize:p,fontFamily:g="Arial"}=t,l=Ne(s,0,1),h=p*(l?.scale??1);Te(e,s,h,g,l);const i=le(r.replace(/\s*\n\s*/g," ")),u=i.map(d=>e.measureText(d).width),b=f?f.time:0,M=rt(s.path,u,b,x),v=i.length,T=f&&t.animation?Math.min(.8,Math.max(.1,f.duration*.4)):0,w=d=>{if(typeof d=="string")return n(d);const k=h*.5,z=(d.angle??90)*Math.PI/180,E=Math.cos(z)*k,I=Math.sin(z)*k,_=d.type==="radial"?e.createRadialGradient(0,0,0,0,0,h*.6):e.createLinearGradient(-E,-I,E,I);return d.gradient.forEach((F,R)=>_.addColorStop(d.stops?.[R]??R/Math.max(1,d.gradient.length-1),n(F))),_};e.textAlign="center",e.textBaseline="middle";const P=f&&t.animators?.length?qe(t.animators,Ve([i.join("")]),f.time):null;for(const d of s.layers){if(d.type!=="text")continue;e.save(),e.globalAlpha=d.opacity,d.shadow&&(e.shadowColor=n(d.shadow.color),e.shadowBlur=d.shadow.blur*h,e.shadowOffsetX=d.shadow.x*h,e.shadowOffsetY=d.shadow.y*h);const k=(d.offset?.x||0)*h,z=(d.offset?.y||0)*h;i.forEach((E,I)=>{const _=M[I];if(!_.visible||!E.trim())return;const F=T?Math.min(1,Math.max(0,(b-I/Math.max(1,v)*T)/.15)):1;if(F<=0)return;const R=P?.[I];if(R&&(R.opacity<=.002||R.scale<=1e-4))return;e.save(),e.globalAlpha*=F,e.translate(_.x+k,_.y+z),e.rotate(_.angle);const L=()=>{d.stroke&&(e.strokeStyle=n(d.stroke.color),e.lineWidth=Math.max(1.5,d.stroke.width*h),e.strokeText(E,0,0)),e.fillStyle=w(d.fill),e.fillText(E,0,0)};R?xe(e,R,0,0,L,j=>j==="fill"?e.fillText(E,0,0):e.strokeText(E,0,0)):L(),e.restore()}),e.restore()}}const Ce=new Map;function zt(e,t,s){const r=e.font+"|"+(e.letterSpacing??"")+"|"+t;let n=Ce.get(r);if(!n){let f="";n=[0];for(const p of s)f+=p,n.push(e.measureText(f).width);Ce.size>400&&Ce.clear(),Ce.set(r,n)}return n}function xe(e,t,s,r,n,f){e.globalAlpha*=t.opacity,e.translate(s+t.x,r+t.y),t.rotate&&e.rotate(t.rotate*Math.PI/180),t.skew&&e.transform(1,0,Math.tan(-t.skew*Math.PI/180),1,0,0),t.scale!==1&&e.scale(t.scale,t.scale),e.translate(-s,-r),t.blur>.05&&(e.filter=`blur(${t.blur.toFixed(1)}px)`),t.stroke>.05&&t.strokeColor&&(e.save(),e.lineWidth=t.stroke*2,e.lineJoin="round",e.strokeStyle=t.strokeColor,f("stroke"),e.restore()),n(),t.fill&&t.fillAmount>.002&&(e.save(),e.shadowColor="transparent",e.globalAlpha*=t.fillAmount,e.fillStyle=t.fill,f("fill"),e.restore())}function De(e,t,s,r){const{fontSize:n,color:f,fontFamily:p="Arial",align:g="center",accentColor:l="#dfff00"}=t,h=Ze(t,s),i=o=>o==="{color}"?f:o==="{accent}"?l:o==="{accent-hi}"?Be(l,255,.5):o==="{accent-lo}"?Be(l,0,.45):o==="{accent-bright}"?_e(l)[0]:o==="{accent-deep}"?_e(l)[1]:o==="{color-lo}"?Be(f,0,.45):o==="transparent"?"rgba(0,0,0,0)":o;if(e.lineJoin="round",s.path){At(e,t,s,h,i,r);return}const{rows:u,heights:b,total:M,box:v,extras:T,ink:w}=Qe(e,t,s,h),P=o=>w?o.center+(o.ascent-o.descent)/2:o.center,d=o=>w?b[o]:u[o].size*1.12,k=Math.max(...u.map(o=>o.paragraph))+1,z=r&&t.animation?t.animation:void 0,E=z?Array.from({length:k},(o,A)=>{const y=u.filter(c=>c.paragraph===A).map(c=>c.text).join(" ");return{word:Math.max(1,y.split(/\s+/).filter(Boolean).length),char:Math.max(1,le(y.replace(/\s/g,"")).length)}}):[],I=z&&r?lt(z,E,r.time,r.duration,ht(s,u.length)):r?r.time:1e6,_={...ft,masked:!1},F=(o,A,y,c)=>z?ut(z,o,A,y,c,I):_,R=(o,A,y,c,a,te)=>typeof o=="string"?be(i(o),te):He(e,o,A,y,c,a,K=>be(i(K),te));let L=0;const j=(o,A,y,c,a,te=A-4e3,K=8e3)=>{if(e.globalAlpha*=Math.min(1,Math.max(0,o.opacity)),o.flicker>0&&Xe(Math.floor(I*24)+A*.01)<o.flicker&&(e.globalAlpha=0),o.reveal<1||o.masked){const $=Math.max(0,c*o.reveal);e.beginPath(),e.rect(-4e3,y-$,8e3,$*2),e.clip()}o.wipeX<1&&(e.beginPath(),e.rect(te-a*.1,y-c*1.6,(K+a*.2)*Math.max(0,o.wipeX),c*3.2),e.clip()),o.wipeY<1&&(e.beginPath(),e.rect(-4e3,y-c*1.2,8e3,c*2.4*Math.max(0,o.wipeY)),e.clip());const D=o.glitch>0?o.glitch*a*.35*(Xe(Math.floor(I*18)+y*.01)*2-1):0;return L=Math.max(L,o.glitch),e.translate(A+o.x*a+D,y+o.y*a),e.rotate(o.rotate*Math.PI/180),e.scale(o.scale*o.scaleX,o.scale*o.scaleY),e.translate(-A,-y),o.blur>0&&(e.filter=`blur(${(o.blur*a).toFixed(1)}px)`),o.brightness},W=o=>{Te(e,s,o.size,p,o.style);const A=u.filter($=>$.paragraph===o.paragraph&&u.indexOf($)<u.indexOf(o));let y=le(A.map($=>$.text).join("").replace(/\s/g,"")).length,c=A.map($=>$.text).join(" ").split(/\s+/).filter(Boolean).length;const a=[];let te=c-1,K=!0,D="";for(const $ of le(o.text)){const ee=e.measureText(D).width;if(D+=$,/\s/.test($)){K=!0;continue}K&&(te++,K=!1),a.push({text:$,x:o.left+ee,w:e.measureText(D).width-ee,char:y++,word:te})}return a},ae=(o,A)=>!!z?.in.some(y=>y.unit===A&&(!y.lines||y.lines.includes(o))),re=o=>E[o]||{word:1,char:1},he=Array.from({length:k},(o,A)=>u.filter(y=>y.paragraph===A).map(y=>y.text).join(" ").split(/\s+/).filter(Boolean).length),Me=o=>he.slice(0,o).reduce((A,y)=>A+y,0),ge=o=>o.style?.align??g,ce=r&&t.animators?.length?t.animators:null,m=ce?Ve(u.map(o=>o.text)):null,q=ce&&m?qe(ce,m,r.time):null,H=[];if(m){let o=0;for(let A=0;A<u.length;A++)H.push(o),o+=le(u[A].text).length}for(const o of s.layers){if(o.type==="texture"){bt(e,o,i(o.color));continue}if(o.type==="shape"||o.type==="icon"){e.save(),vt(e,o,I,i),e.restore();continue}if(e.save(),e.globalAlpha=o.opacity,o.type==="box"&&o.per==="block"){const c=u[0],a=F("line",c.paragraph,c.paragraph,k),te=o.padX*n,K=o.padY*n,D=(T?v.x:Math.min(...u.map(G=>G.left)))-te,$=(T?v.y:u[0].center-d(0)/2)-K,ee=(T?v.w:Math.max(...u.map(G=>G.width)))+te*2,O=(T?v.h:M-(b[0]-d(0))/2-(b.at(-1)-d(u.length-1))/2)+K*2,N=j(a,D+ee/2,$+O/2,O/2,n);(!o.motion||Ge(e,Ye(o.motion,I),{x:D,y:$,w:ee,h:O},o.motion.origin,n))&&(o.skewX&&(e.translate(D+ee/2,$+O/2),e.transform(1,0,Math.tan(-o.skewX*Math.PI/180),1,0,0),e.translate(-D-ee/2,-$-O/2)),o.shadow&&(e.shadowColor=i(o.shadow.color),e.shadowBlur=o.shadow.blur*n,e.shadowOffsetX=o.shadow.x*n,e.shadowOffsetY=o.shadow.y*n),e.fillStyle=R(o.fill,D,$,ee,O,N),e.beginPath(),e.roundRect(D,$,ee,O,o.radius*n),e.fill(),o.stroke&&(e.strokeStyle=be(i(o.stroke.color),N),e.lineWidth=Math.max(1.5,o.stroke.width*n),e.stroke())),e.restore();continue}const A=u.map((c,a)=>o.lines?o.lines.includes(c.paragraph):o.type==="underline"?o.line==="all"||a===u.length-1:!0);let y=0;for(const[c,a]of u.entries()){if(!A[c])continue;const te=y++;e.save();const K=a.left+a.width/2;a.style?.rotate&&(e.translate(K,a.center),e.rotate(a.style.rotate*Math.PI/180),e.translate(-K,-a.center));const D=F("line",a.paragraph,a.paragraph,k);L=0;const $=j(D,K,a.center,b[c]/2+a.size*.1,a.size,a.left,a.width),ee=O=>!o.motion||Ge(e,Ye(o.motion,I-(o.motion.stagger??0)*te),O,o.motion.origin,a.size);if(o.type==="box"){const O=o.padX*a.size,N=o.padY*a.size,G=a.left-O,B=a.center-d(c)/2-N,J=a.width+O*2,fe=d(c)+N*2;ee({x:G,y:B,w:J,h:fe})&&(o.skewX&&(e.translate(G+J/2,B+fe/2),e.transform(1,0,Math.tan(-o.skewX*Math.PI/180),1,0,0),e.translate(-G-J/2,-B-fe/2)),o.shadow&&(e.shadowColor=i(o.shadow.color),e.shadowBlur=o.shadow.blur*a.size,e.shadowOffsetX=o.shadow.x*a.size,e.shadowOffsetY=o.shadow.y*a.size),e.fillStyle=R(o.fill,G,B,J,fe,$),e.beginPath(),e.roundRect(G,B,J,fe,o.radius*a.size),e.fill(),o.stroke&&(e.strokeStyle=be(i(o.stroke.color),$),e.lineWidth=Math.max(1.5,o.stroke.width*a.size),e.stroke()))}if(o.type==="underline"){const O=a.width*o.width,N=ge(a),G=N==="left"?a.left:N==="right"?a.left+a.width-O:a.left+(a.width-O)/2,B=a.center+o.offsetY*a.size,J=Math.max(3,o.height*a.size);ee({x:G,y:B-(o.style==="swash"?a.size*.3:0),w:O,h:J+(o.style==="swash"?a.size*.5:0)})&&(e.fillStyle=R(o.fill,G,B,O,J,$),o.style==="swash"?(Pt(e,G,B,O,J,a.size),e.fill()):e.fillRect(G,B,O,J))}if(o.type==="text"){Te(e,s,a.size,p,a.style);const O=D.count!==1?dt(a.text,D.count):a.text;let N=a.left,G=a.width;if(O!==a.text){G=e.measureText(O).width;const S=ge(a);N=S==="left"?a.left:S==="right"?a.left+a.width-G:a.left+(a.width-G)/2}const B=(o.offset?.x||0)*a.size,J=(o.offset?.y||0)*a.size;if(r&&o.flicker&&Xe(Math.floor(I*12)*1.37+5)<o.flicker&&(e.globalAlpha*=.18),!ee({x:N+B-a.size*.05,y:a.center-d(c)/2+J-a.size*.12,w:G+a.size*.1,h:d(c)+a.size*.24})){e.restore();continue}o.shadow&&(e.shadowColor=i(o.shadow.color),e.shadowBlur=o.shadow.blur*a.size,e.shadowOffsetX=o.shadow.x*a.size,e.shadowOffsetY=o.shadow.y*a.size);const fe=o.lineFills?o.lineFills[c%o.lineFills.length]:void 0;let we=null;if(r&&o.shine){const S=o.shine;let X=I-S.start;X>=0&&S.every>0&&(X%=S.every);const U=X/S.duration;if(X>=0&&U<1){const C=S.width*a.size,Y=N-C+(G+C*2)*U,Q=S.angle*Math.PI/180,Z=i(S.color);we=e.createLinearGradient(Y-C*Math.cos(Q),a.center-C*Math.sin(Q),Y+C*Math.cos(Q),a.center+C*Math.sin(Q)),we.addColorStop(0,Se(Z,0)),we.addColorStop(.5,Se(Z,1)),we.addColorStop(1,Se(Z,0))}}const et=fe??(a.fill&&o.fill==="{color}"?a.fill:o.fill),tt=a.center-d(c)/2+J,ot=(S,X)=>R(S,N+B,tt,G,d(c),X),at=o.reflection?P(a)+J+e.measureText(O).actualBoundingBoxDescent:0,ke=(S,X,U,C)=>{const Y=P(a)+J,Q=C??et;if(L>.02){const Z=e.globalAlpha,oe=L*a.size*.08;e.globalAlpha=Z*.85,e.fillStyle="#fd436a",e.fillText(S,X+B+oe,Y),e.fillStyle="#37eaff",e.fillText(S,X+B-oe,Y),e.globalAlpha=Z}if(o.stroke&&(e.strokeStyle=be(i(o.stroke.color),U),e.lineWidth=Math.max(2,o.stroke.width*a.size),e.strokeText(S,X+B,Y)),e.fillStyle=ot(Q,U),e.fillText(S,X+B,Y),o.innerGlow){const Z=e.getTransform();Ct(e,oe=>oe.fillText(S,X+B,Y),be(i(o.innerGlow.color),U),o.innerGlow.blur*a.size*Math.hypot(Z.a,Z.b))}if(we&&(e.save(),e.shadowColor="transparent",e.fillStyle=we,e.fillText(S,X+B,Y),e.restore()),o.reflection){const Z=o.reflection,oe=at+Z.gap*a.size,$e=d(c)*Z.fade,V=i(Tt(Q)),de=!/^#[0-9a-f]{6}$/i.test(V),pe=de&&o.stroke?i(o.stroke.color):V;e.save(),e.shadowColor="transparent",e.filter="none",e.translate(0,2*oe),e.scale(1,-1);const ye=e.createLinearGradient(0,oe,0,oe-$e);ye.addColorStop(0,Se(pe,Z.opacity)),ye.addColorStop(1,Se(pe,0)),de&&o.stroke?(e.strokeStyle=ye,e.lineWidth=Math.max(2,o.stroke.width*a.size),e.strokeText(S,X+B,Y)):(e.fillStyle=ye,e.fillText(S,X+B,Y)),e.restore()}},me=new Map;for(const S of o.highlights??[])for(const X of S.words)me.set(X,S.fill);const Ae=Me(a.paragraph),ze=ae(a.paragraph,"word"),ve=ae(a.paragraph,"char"),Ie=D.spread;if(q){const S=le(a.text),X=zt(e,a.text,S),U=H[c],C=W(a);let Y=0;for(let V=0;V<S.length;V++)Y+=q[U+V].tracking;const Q=ge(a);let oe=Q==="left"?0:Q==="right"?-Y:-Y/2,$e=0;for(let V=0;V<S.length;V++){const de=q[U+V],pe=a.left+X[V],ye=X[V+1]-X[V],Re=!/\S/u.test(S[V]),ie=Re?null:C[$e++],Pe=oe;if(oe+=de.tracking,Re||!ie||de.opacity<=.002||de.scale<=1e-4)continue;e.save();let Fe=$;ze&&(Fe*=j(F("word",a.paragraph,ie.word,re(a.paragraph).word),ie.x+ie.w/2,a.center,b[c]/2+a.size*.1,a.size)),ve&&(Fe*=j(F("char",a.paragraph,ie.char,re(a.paragraph).char),ie.x+ie.w/2,a.center,b[c]/2+a.size*.1,a.size)),e.globalAlpha>.002&&xe(e,de,pe+Pe+B+ye/2,a.center,()=>ke(S[V],pe+Pe,Fe,me.get(Ae+ie.word)),nt=>nt==="fill"?e.fillText(S[V],pe+Pe+B,P(a)+J):e.strokeText(S[V],pe+Pe+B,P(a)+J)),e.restore()}}else if(!ze&&!ve&&!Ie)if(!me.size||O!==a.text)ke(O,N,$);else{const S=new Map;for(const C of W(a)){const Y=Ae+C.word,Q=S.get(Y);S.set(Y,Q?{x0:Math.min(Q.x0,C.x),x1:Math.max(Q.x1,C.x+C.w)}:{x0:C.x,x1:C.x+C.w})}const X=[...S].filter(([C])=>me.has(C)),U=a.size*.04;e.save(),e.beginPath(),e.rect(-1e5,-1e5,2e5,2e5);for(const[,C]of X)e.rect(C.x0+B-U,-1e5,C.x1-C.x0+U*2,2e5);e.clip("evenodd"),ke(O,N,$),e.restore();for(const[C,Y]of X)e.save(),e.beginPath(),e.rect(Y.x0+B-U,-1e5,Y.x1-Y.x0+U*2,2e5),e.clip(),ke(O,N,$,me.get(C)),e.restore()}else{const S=W(a),X=(S.length-1)/2;for(const[U,C]of S.entries()){e.save(),Ie&&e.translate((U-X)*Ie*a.size,0);let Y=$;ze&&(Y*=j(F("word",a.paragraph,C.word,re(a.paragraph).word),C.x+C.w/2,a.center,b[c]/2+a.size*.1,a.size)),ve&&(Y*=j(F("char",a.paragraph,C.char,re(a.paragraph).char),C.x+C.w/2,a.center,b[c]/2+a.size*.1,a.size)),e.globalAlpha>.002&&ke(C.text,C.x,Y,me.get(Ae+C.word)),e.restore()}}}e.restore()}e.restore()}}function vt(e,t,s,r){const n=x.width,f=x.height,p=Ye(t.motion,s);if(e.globalAlpha=t.opacity*Math.min(1,Math.max(0,p.opacity)),e.globalAlpha<.002)return;let g,l,h,i;t.type==="shape"?(g=(t.box[0]+t.box[2]/2)*n,l=(t.box[1]+t.box[3]/2)*f,h=t.box[2]*n,i=t.box[3]*f):(h=i=t.size*f,g=t.center[0]*n,l=t.center[1]*f);const u=t.motion?.origin??"center",b=u==="left"?g-h/2:u==="right"?g+h/2:g,M=u==="top"?l-i/2:u==="bottom"?l+i/2:l;if(p.wipeX<1&&(e.beginPath(),e.rect(g-h/2-8,l-i/2-8,(h+16)*Math.max(0,p.wipeX),i+16),e.clip()),p.wipeY<1&&(e.beginPath(),e.rect(g-h/2-8,l-i/2-8,h+16,(i+16)*Math.max(0,p.wipeY)),e.clip()),e.translate(b+p.x*n,M+p.y*f),e.scale(p.scale*p.scaleX,p.scale*p.scaleY),e.translate(g-b,l-M),e.rotate(((t.rotate||0)+p.rotate)*Math.PI/180),t.type==="shape"){if(t.skewX&&e.transform(1,0,Math.tan(t.skewX*Math.PI/180),1,0,0),t.blur&&(e.filter=`blur(${(t.blur*f).toFixed(1)}px)`),t.shape==="glow"){const w=typeof t.fill=="string"?r(t.fill):r(t.stroke?.color??"{accent}"),P=Math.max(h,i)/2;e.scale(h/2/P,i/2/P);const d=e.createRadialGradient(0,0,0,0,0,P);d.addColorStop(0,w),d.addColorStop(1,"rgba(0,0,0,0)"),e.fillStyle=d,e.beginPath(),e.arc(0,0,P,0,Math.PI*2),e.fill();return}e.beginPath(),t.shape==="rect"?e.roundRect(-h/2,-i/2,h,i,Math.min(h,i)/2*Math.min(1,t.radius*2)):e.ellipse(0,0,h/2,i/2,0,0,Math.PI*2),t.fill&&(typeof t.fill=="string"?e.fillStyle=r(t.fill):e.fillStyle=He(e,t.fill,-h/2,-i/2,h,i,r),e.fill()),t.stroke&&(e.strokeStyle=r(t.stroke.color),e.lineWidth=t.stroke.width,e.setLineDash(t.stroke.dash??[]),e.stroke());return}if(t.glow&&(e.shadowColor=r(t.color),e.shadowBlur=t.glow*h*.5),t.badge!=="none"){e.save(),t.badge==="diamond"&&e.rotate(Math.PI/4);const w=t.badge==="diamond"?h*.72:h;e.beginPath(),t.badge==="circle"?e.arc(0,0,h/2,0,Math.PI*2):e.roundRect(-w/2,-w/2,w,w,t.badge==="square"?0:w*.22),t.badgeFill&&(e.fillStyle=r(t.badgeFill),e.fill()),t.badgeStroke&&(e.strokeStyle=r(t.badgeStroke),e.lineWidth=2,e.stroke()),e.restore()}e.shadowBlur=0;const v=h*.6,T=v/24;e.translate(-v/2,-v/2),e.scale(T,T),e.strokeStyle=r(t.color),e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round";for(const w of pt[t.name]??[])e.stroke(new Path2D(w))}function It(e){const t=[];for(const s of Array.from(document.styleSheets)){let r;try{r=s.cssRules}catch{continue}for(const n of Array.from(r))if(n instanceof CSSFontFaceRule&&n.style.getPropertyValue("font-family").replace(/['"]/g,"").trim()===e){const f=n.style.getPropertyValue("src");if(!f)continue;t.push(new FontFace(e,f,{weight:n.style.getPropertyValue("font-weight")||"normal",stretch:n.style.getPropertyValue("font-stretch")||"normal",style:n.style.getPropertyValue("font-style")||"normal"}))}}return t}const Je=async(e,t)=>{try{return await document.fonts.load(e,t),!0}catch{}await new Promise(r=>setTimeout(r,400));const s=e.match(/"([^"]+)"/)?.[1]??"";try{const r=It(s);return r.length?(await Promise.all(r.map(n=>n.load().then(()=>document.fonts.add(n)))),!0):!1}catch{return!1}};async function Xt(e){const t=it(e),s=[];if(t.length){const l=await st(()=>import("./userFonts-txN4I-eo.js"),__vite__mapDeps([0,1,2,3,4]));await l.userFontsReady();for(const h of t)l.isMissingCustomFont(h)&&s.push(h)}const r=e.design?.weight??(e.styleId&&e.styleId!=="classic"?800:600),n=e.design?.stretch&&e.design.stretch!=="normal"?e.design.stretch+" ":"",f=e.fontFamily||"Arial",p=[];await Je(`${r} ${n}${e.fontSize}px "${f}"`,e.text)||p.push(f);const g=e.design;if(g?.lines?.some(l=>l.font||l.weight||l.italic||l.stretch)){const l=[...new Set(g.lines.map(i=>Ke(g,e.fontSize,f,i).replace(/ sans-serif$/,"").replace(/,$/,"")))],h=await Promise.all(l.map(i=>Je(i,e.text)));l.forEach((i,u)=>{h[u]||p.push(i.replace(/^.*?"([^"]+)".*$/,"$1"))})}return[...new Set([...p.filter(l=>!s.includes(l)),...s])]}export{Ot as d,Xt as l,Bt as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/userFonts-BZ4QL-zq.js","assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js","assets/store-BSSbvpzr.js","assets/textAnimators-Cihw35O8.js"])))=>i.map(i=>d[i]);
2
+ import{_ as st,mA as rt}from"./titleFrameBudget-3MFHWIT6.js";import{u as it,v as lt,o as ht,R as ft,w as Ve,x as Ne,y as Re,z as dt,l as Ue,A as pt,C as ut,a as gt}from"./textAnimators-Cihw35O8.js";const Ye=(e,t)=>typeof document<"u"?Object.assign(document.createElement("canvas"),{width:e,height:t}):new OffscreenCanvas(e,t),ne=1280,se=720,ue=new Map,ct=8,qe=()=>Ye(ne,se);function Oe(e,t,s){const r=s*Math.PI/180,n=Math.cos(r),f=Math.sin(r),p=(Math.abs(n)*ne+Math.abs(f)*se)/2;return Math.min(1,Math.max(0,((e-ne/2)*n+(t-se/2)*f+p)/(2*p)))}function wt(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function mt(e,t){const s=qe(),r=s.getContext("2d"),{scale:n,size:f,fade:p,fadeAngle:g}=e;if(r.fillStyle=t,e.pattern==="grain"){const b=Math.max(1,Math.round(n/4)),M=Math.ceil(ne/b),v=Math.ceil(se/b),T=wt(1729);for(let w=0;w<v;w++)for(let P=0;P<M;P++){const d=P*b,k=w*b,z=f*(1-p*Oe(d,k,g));T()<z&&r.fillRect(d,k,b,b)}return s}const l=e.angle*Math.PI/180,h=Math.cos(l),i=Math.sin(l),u=Math.hypot(ne,se)/2+n;r.beginPath();for(let b=-u;b<=u;b+=n){if(e.pattern==="lines"){for(let M=-u;M<u;M+=n*2){const v=ne/2+(M+n)*h-b*i,T=se/2+(M+n)*i+b*h,w=n*f*(1-p*Oe(v,T,g))/2;if(w<.15)continue;const P=[[M,b-w],[M+n*2,b-w],[M+n*2,b+w],[M,b+w]].map(([d,k])=>[ne/2+d*h-k*i,se/2+d*i+k*h]);r.moveTo(P[0][0],P[0][1]);for(const[d,k]of P.slice(1))r.lineTo(d,k);r.closePath()}continue}for(let M=-u;M<=u;M+=n){const v=ne/2+M*h-b*i,T=se/2+M*i+b*h;if(v<-n||T<-n||v>ne+n||T>se+n)continue;const w=n*.6*f*(1-p*Oe(v,T,g));w<.3||(r.moveTo(v+w,T),r.arc(v,T,w,0,Math.PI*2))}}return r.fill(),s}function yt(e,t,s){const r=JSON.stringify([e.pattern,e.scale,e.size,e.angle,e.fade,e.fadeAngle,t,s]);let n=ue.get(r);if(n)return ue.delete(r),ue.set(r,n),n;if(n=mt(e,s?"#000000":t),s){const f=qe(),p=f.getContext("2d");p.fillStyle="#000000",p.fillRect(0,0,ne,se),p.globalCompositeOperation="destination-out",p.drawImage(n,0,0),n=f}return ue.set(r,n),ue.size>ct&&ue.delete(ue.keys().next().value),n}function bt(e,t,s){e.save(),e.setTransform(1,0,0,1,0,0),e.filter="none",e.shadowBlur=0,e.globalAlpha=t.opacity,e.globalCompositeOperation=t.mode==="atop"?"source-atop":"destination-out",e.drawImage(yt(t,s,t.mode==="keep"),0,0),e.restore()}const x={width:1280,height:720};let Mt=null;const kt=()=>Mt??=Ye(x.width,x.height);function St(e,t){const s=[];for(const r of t.split(`
3
+ `)){let n="";for(const f of Array.from(r))n&&e.measureText(n+f).width>1050&&(s.push(n),n=""),n+=f;s.push(n)}return s}function Ot(e,t,s){if(t.design){if(!t.design.layers.some(k=>k.type==="texture"))return De(e,t,t.design,s);const P=kt(),d=P.getContext("2d");d.setTransform(1,0,0,1,0,0),d.globalAlpha=1,d.globalCompositeOperation="source-over",d.clearRect(0,0,x.width,x.height),De(d,t,t.design,s),e.drawImage(P,0,0);return}const{text:r,fontSize:n,color:f,placement:p,fontFamily:g="Arial",align:l="center",styleId:h="classic",accentColor:i="#32d8cd"}=t,u=h!=="classic",b=u?800:600;e.font=`${b} ${n}px "${g}", sans-serif`,e.textAlign=l,e.textBaseline="middle";const M=St(e,r),v=n*(u?1.12:1.3);if(M.length*v>560)throw Error("Text is too long for the frame; reduce copy or font size");const T=M.length*v,w=p==="top"?80+T/2:p==="lower"?640-T/2:360;M.forEach((P,d)=>{const k=l==="left"?90:l==="right"?1190:640,z=w+(d-(M.length-1)/2)*v,Y=e.measureText(P).width;if(e.save(),h==="accent-bar"){const I=l==="left"?k-18:l==="right"?k-Y-18:k-Y/2-18;e.fillStyle=i,e.beginPath(),e.roundRect(I,z-n*.56,Y+36,n*1.12,10),e.fill()}if(h==="tape-label"){const I=n*.45,_=Y+I*2,F=n*1.32,E=l==="left"?k+Y/2:l==="right"?k-Y/2:k,L=(d%2?1:-1)*.028,j=6;e.save(),e.translate(E,z),e.rotate(L),e.beginPath(),e.moveTo(-_/2,-F/2),e.lineTo(_/2,-F/2);for(let W=1;W<=j;W++)e.lineTo(_/2+(W%2?n*.07:0),-F/2+F*W/j);e.lineTo(-_/2,F/2);for(let W=j-1;W>=0;W--)e.lineTo(-_/2-(W%2?n*.07:0),-F/2+F*W/j);e.closePath(),e.shadowColor="rgba(0,0,0,0.22)",e.shadowBlur=n*.12,e.shadowOffsetY=n*.04,e.globalAlpha=.94,e.fillStyle=i,e.fill(),e.shadowColor="transparent",e.globalAlpha=.07,e.strokeStyle="#5a4a30",e.lineWidth=1;for(let W=1;W<5;W++){const ae=-F/2+F*W/5;e.beginPath(),e.moveTo(-_/2,ae),e.lineTo(_/2,ae+(W%2?1.5:-1.5)),e.stroke()}e.restore(),e.save(),e.translate(E,z),e.rotate(L),e.translate(-E,-z)}if(h==="echo-stack"&&(e.fillStyle=i,e.globalAlpha=.82,e.fillText(P,k+13,z+13),e.globalAlpha=1),h==="outline-punch"&&(e.lineWidth=Math.max(4,n*.11),e.lineJoin="round",e.strokeStyle=i,e.strokeText(P,k,z)),h==="neon-edge"&&(e.shadowColor=i,e.shadowBlur=25,e.strokeStyle=i,e.lineWidth=Math.max(3,n*.07),e.lineJoin="round",e.strokeText(P,k,z),e.shadowBlur=12),h==="classic"&&(e.shadowColor="#000000",e.shadowBlur=8),e.fillStyle=h==="duotone-stack"&&d%2?i:f,e.fillText(P,k,z),h==="tape-label"&&e.restore(),h==="duotone-stack"&&d===M.length-1){const I=l==="left"?k:l==="right"?k-Y:k-Y/2;e.fillStyle=i,e.fillRect(I,z+n*.55,Math.min(Y,760),Math.max(4,n*.07))}e.restore()})}const We=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter("vi",{granularity:"grapheme"}):null,le=e=>We?Array.from(We.segment(e),t=>t.segment):Array.from(e);function be(e,t){if(t>=.999||!/^#[0-9a-f]{6}$/i.test(e))return e;const s=parseInt(e.slice(1),16),r=Math.max(0,t);return`rgb(${Math.round((s>>16&255)*r)},${Math.round((s>>8&255)*r)},${Math.round((s&255)*r)})`}function Be(e,t,s){if(!/^#[0-9a-f]{6}$/i.test(e))return e;const r=parseInt(e.slice(1),16);return"#"+[r>>16&255,r>>8&255,r&255].map(n=>Math.round(n+(t-n)*s).toString(16).padStart(2,"0")).join("")}const _e=e=>{if(!/^#[0-9a-f]{6}$/i.test(e))return[e,e];const t=gt(e.toLowerCase()).gradient;return[t[0],t.at(-1)]};function He(e,t,s,r,n,f,p){const g=s+n/2,l=r+f/2;let h;if(t.type==="radial")h=e.createRadialGradient(g,l,0,g,l,Math.max(n,f)/2);else{const i=(t.angle??90)*Math.PI/180,u=Math.cos(i)*n/2,b=Math.sin(i)*f/2;h=e.createLinearGradient(g-u,l-b,g+u,l+b)}return t.gradient.forEach((i,u)=>h.addColorStop(t.stops?.[u]??u/(t.gradient.length-1),p(i))),h}const Tt=e=>typeof e=="string"?e:e.type==="radial"?e.gradient[0]:e.gradient.at(-1),Se=(e,t)=>{if(!/^#[0-9a-f]{6}$/i.test(e))return`rgba(255,255,255,${t})`;const s=parseInt(e.slice(1),16);return`rgba(${s>>16&255},${s>>8&255},${s&255},${t})`};function Ke(e,t,s,r){const n=r?.stretch??e.stretch;return`${r?.italic?"italic ":""}${r?.weight??e.weight} ${n&&n!=="normal"?n+" ":""}${t}px "${r?.font??s}", sans-serif`}function Te(e,t,s,r,n){e.font=Ke(t,s,r,n),"letterSpacing"in e&&(e.letterSpacing=`${((n?.tracking??t.tracking??0)*s).toFixed(2)}px`)}const Xe=e=>{const t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)};function Qe(e,t,s,r){const{fontSize:n,placement:f,fontFamily:p="Arial",align:g="center"}=t,l=s.stack==="ink";e.textBaseline=l?"alphabetic":"middle",e.textAlign="left";const h=!!s.lines,i=s.maxWidth?s.maxWidth*x.width:1050,u=!!s.lines?.some(T=>T.side||T.x||T.y||T.align),b=T=>{const w=[],P=r.split(`
4
+ `);P.forEach((m,N)=>{const H=Ue(s,N,P.length);let o=n*(H?.scale??1)*T;if(Te(e,s,o,p,H),h){const c=u?i*T:i,a=e.measureText(m||" ").width;a>c&&(o*=c/a,Te(e,s,o,p,H))}const C=[];let y="";if(h)C.push(m);else if(s.wrap==="word"){for(const c of m.split(/(\s+)/))if(y&&y.trim()&&e.measureText(y+c).width>i&&c.trim()&&(C.push(y.trimEnd()),y=""),!(!y&&!c.trim()))if(e.measureText(c).width>i)for(const a of le(c))y&&e.measureText(y+a).width>i&&(C.push(y),y=""),y+=a;else y+=c;C.push(y.trimEnd())}else{for(const c of le(m))y&&e.measureText(y+c).width>i&&(C.push(y),y=""),y+=c;C.push(y)}for(const c of C){const a=e.measureText(c||" ");w.push({text:c,paragraph:N,size:o,fill:H?.fill,style:H,width:a.width,left:0,center:0,ascent:l?a.actualBoundingBoxAscent:o*.56,descent:l?a.actualBoundingBoxDescent:o*.56})}});const d=w.map(m=>l?m.ascent+m.descent:m.size*s.lineHeight),k=w.map(m=>l?(s.gap??.08)*m.size:0),z=m=>!!m.style?.side,Y=w.map((m,N)=>N).filter(m=>!z(w[m]));let I=0;Y.forEach((m,N)=>{I+=d[m]+(N?k[m]:0)});const _=(f==="top"?80:f==="lower"?640-I:x.height/2-I/2)+(s.shiftY??0)*x.height,F=(g==="left"?90:g==="right"?1190:x.width/2)+(s.shiftX??0)*x.width,E=Math.max(0,...Y.map(m=>w[m].width)),L=g==="left"?F:g==="right"?F-E:F-E/2;let j=_;if(Y.forEach((m,N)=>{const H=w[m];N&&(j+=k[m]),H.center=j+d[m]/2,j+=d[m];const o=H.style?.align??g;H.left=o==="left"?L:o==="right"?L+E-H.width:L+(E-H.width)/2}),!u)return{rows:w,heights:d,gaps:k,total:I,box:{x:L,y:_,w:E,h:I},extras:u,ink:l};const W=n*T;for(const m of w)z(m)&&(m.center=_+I/2,m.left=m.style.side==="left"?L-.12*W-m.width:L+E+.12*W),m.left+=(m.style?.x??0)*W,m.center+=(m.style?.y??0)*W;const ae=Math.min(...w.map(m=>m.left)),re=Math.max(...w.map(m=>m.left+m.width)),he=Math.min(...w.map((m,N)=>m.center-d[N]/2)),Me=Math.max(...w.map((m,N)=>m.center+d[N]/2)),ge=g==="left"?F-ae:g==="right"?F-re:F-(ae+re)/2,ce=(f==="top"?80:f==="lower"?640-(Me-he):x.height/2-(Me-he)/2)+(s.shiftY??0)*x.height-he;for(const m of w)m.left+=ge,m.center+=ce;return{rows:w,heights:d,gaps:k,total:I,box:{x:ae+ge,y:he+ce,w:re-ae,h:Me-he},extras:u,ink:l}};let M=b(1),v=1;for(let T=0;T<4;T++){const w=M.extras?M.box.h:M.total,P=Math.max(w/560,M.extras?M.box.w/i:0);if(P<=1)break;v*=.98/P,M=b(v)}if((M.extras?M.box.h:M.total)>560)throw Error("Text is too long for the frame; reduce copy or font size");return M}const Ze=(e,t)=>(t.uppercase?e.text.toLocaleUpperCase("vi"):e.text).normalize("NFC");function Bt(e){const t=Ye(1,1).getContext("2d");if(!t)return[];if(!e.design){const s=e.text.split(`
5
+ `).length,r=Math.min(560,s*e.fontSize*1.3);return[{paragraph:-1,x:115,y:e.placement==="top"?80:e.placement==="lower"?640-r:360-r/2,w:1050,h:r,rotate:0}]}try{const s=Qe(t,e,e.design,Ze(e,e.design));return s.rows.map((r,n)=>({paragraph:r.paragraph,x:r.left,y:r.center-s.heights[n]/2,w:r.width,h:s.heights[n],rotate:r.style?.rotate??0}))}catch{return[]}}function Pt(e,t,s,r,n,f){const p=[[t,s+f*.1],[t+r*.55,s+f*.2],[t+r,s-f*.26]],g=28,l=[],h=[];for(let i=0;i<=g;i++){const u=i/g,b=(1-u)*(1-u),M=2*(1-u)*u,v=u*u,T=b*p[0][0]+M*p[1][0]+v*p[2][0],w=b*p[0][1]+M*p[1][1]+v*p[2][1],P=2*(1-u)*(p[1][0]-p[0][0])+2*u*(p[2][0]-p[1][0]),d=2*(1-u)*(p[1][1]-p[0][1])+2*u*(p[2][1]-p[1][1]),k=Math.hypot(P,d)||1,z=n*Math.pow(Math.sin(Math.PI*u),.55)*(1.25-.55*u)/2;l.push([T-d/k*z,w+P/k*z]),h.push([T+d/k*z,w-P/k*z])}e.beginPath(),e.moveTo(l[0][0],l[0][1]);for(const i of l.slice(1))e.lineTo(i[0],i[1]);for(const i of h.reverse())e.lineTo(i[0],i[1]);e.closePath()}function Ge(e,t,s,r,n){if(e.globalAlpha*=Math.min(1,Math.max(0,t.opacity)),e.globalAlpha<.002)return!1;const f=n*.3;if(t.wipeX<1){const l=(s.w+2*f)*Math.max(0,t.wipeX);e.beginPath(),e.rect(r==="right"?s.x+s.w+f-l:s.x-f,s.y-n*2,l,s.h+n*4),e.clip()}if(t.wipeY<1){const l=(s.h+2*f)*Math.max(0,t.wipeY);e.beginPath(),e.rect(s.x-n*2,r==="bottom"?s.y+s.h+f-l:s.y-f,s.w+n*4,l),e.clip()}const p=r==="left"?s.x:r==="right"?s.x+s.w:s.x+s.w/2,g=r==="top"?s.y:r==="bottom"?s.y+s.h:s.y+s.h/2;return e.translate(p+t.x*n,g+t.y*n),e.rotate(t.rotate*Math.PI/180),e.scale(t.scale*t.scaleX,t.scale*t.scaleY),e.translate(-p,-g),!0}const Le=[];function je(e,t,s){let r=Le[e];return(!r||r.width!==t||r.height!==s)&&(r=typeof document<"u"?Object.assign(document.createElement("canvas"),{width:t,height:s}):new OffscreenCanvas(t,s),Le[e]=r),r.getContext("2d")}function At(e,t,s,r){const n=e.canvas.width,f=e.canvas.height,p=e.getTransform(),g=je(0,n,f),l=je(1,n,f),h=i=>{i.font=e.font,i.textAlign=e.textAlign,i.textBaseline=e.textBaseline;const u=i,b=e;for(const M of["letterSpacing","fontStretch","fontKerning"])M in b&&(u[M]=b[M])};g.setTransform(1,0,0,1,0,0),g.globalCompositeOperation="source-over",g.clearRect(0,0,n,f),g.fillStyle=s,g.fillRect(0,0,n,f),g.setTransform(p),h(g),g.globalCompositeOperation="destination-out",g.fillStyle="#000",t(g),l.setTransform(1,0,0,1,0,0),l.globalCompositeOperation="source-over",l.clearRect(0,0,n,f),l.filter=`blur(${Math.max(.5,r).toFixed(1)}px)`,l.drawImage(g.canvas,0,0),l.filter="none",l.setTransform(p),h(l),l.globalCompositeOperation="destination-in",l.fillStyle="#000",t(l),e.save(),e.setTransform(1,0,0,1,0,0),e.shadowColor="transparent",e.filter="none",e.drawImage(l.canvas,0,0),e.restore()}function Ct(e,t,s,r,n,f){const{fontSize:p,fontFamily:g="Arial"}=t,l=Ue(s,0,1),h=p*(l?.scale??1);Te(e,s,h,g,l);const i=le(r.replace(/\s*\n\s*/g," ")),u=i.map(d=>e.measureText(d).width),b=f?f.time:0,M=rt(s.path,u,b,x),v=i.length,T=f&&t.animation?Math.min(.8,Math.max(.1,f.duration*.4)):0,w=d=>{if(typeof d=="string")return n(d);const k=h*.5,z=(d.angle??90)*Math.PI/180,Y=Math.cos(z)*k,I=Math.sin(z)*k,_=d.type==="radial"?e.createRadialGradient(0,0,0,0,0,h*.6):e.createLinearGradient(-Y,-I,Y,I);return d.gradient.forEach((F,E)=>_.addColorStop(d.stops?.[E]??E/Math.max(1,d.gradient.length-1),n(F))),_};e.textAlign="center",e.textBaseline="middle";const P=f&&t.animators?.length?Ne(t.animators,Ve([i.join("")]),f.time):null;for(const d of s.layers){if(d.type!=="text")continue;e.save(),e.globalAlpha=d.opacity,d.shadow&&(e.shadowColor=n(d.shadow.color),e.shadowBlur=d.shadow.blur*h,e.shadowOffsetX=d.shadow.x*h,e.shadowOffsetY=d.shadow.y*h);const k=(d.offset?.x||0)*h,z=(d.offset?.y||0)*h;i.forEach((Y,I)=>{const _=M[I];if(!_.visible||!Y.trim())return;const F=T?Math.min(1,Math.max(0,(b-I/Math.max(1,v)*T)/.15)):1;if(F<=0)return;const E=P?.[I];if(E&&(E.opacity<=.002||E.scale<=1e-4))return;e.save(),e.globalAlpha*=F,e.translate(_.x+k,_.y+z),e.rotate(_.angle);const L=()=>{d.stroke&&(e.strokeStyle=n(d.stroke.color),e.lineWidth=Math.max(1.5,d.stroke.width*h),e.strokeText(Y,0,0)),e.fillStyle=w(d.fill),e.fillText(Y,0,0)};E?xe(e,E,0,0,L,j=>j==="fill"?e.fillText(Y,0,0):e.strokeText(Y,0,0)):L(),e.restore()}),e.restore()}}const Ae=new Map;function zt(e,t,s){const r=e.font+"|"+(e.letterSpacing??"")+"|"+t;let n=Ae.get(r);if(!n){let f="";n=[0];for(const p of s)f+=p,n.push(e.measureText(f).width);Ae.size>400&&Ae.clear(),Ae.set(r,n)}return n}function xe(e,t,s,r,n,f){e.globalAlpha*=t.opacity,e.translate(s+t.x,r+t.y),t.rotate&&e.rotate(t.rotate*Math.PI/180),t.skew&&e.transform(1,0,Math.tan(-t.skew*Math.PI/180),1,0,0),t.scale!==1&&e.scale(t.scale,t.scale),e.translate(-s,-r),t.blur>.05&&(e.filter=`blur(${t.blur.toFixed(1)}px)`),t.stroke>.05&&t.strokeColor&&(e.save(),e.lineWidth=t.stroke*2,e.lineJoin="round",e.strokeStyle=t.strokeColor,f("stroke"),e.restore()),n(),t.fill&&t.fillAmount>.002&&(e.save(),e.shadowColor="transparent",e.globalAlpha*=t.fillAmount,e.fillStyle=t.fill,f("fill"),e.restore())}function De(e,t,s,r){const{fontSize:n,color:f,fontFamily:p="Arial",align:g="center",accentColor:l="#dfff00"}=t,h=Ze(t,s),i=o=>o==="{color}"?f:o==="{accent}"?l:o==="{accent-hi}"?Be(l,255,.5):o==="{accent-lo}"?Be(l,0,.45):o==="{accent-bright}"?_e(l)[0]:o==="{accent-deep}"?_e(l)[1]:o==="{color-lo}"?Be(f,0,.45):o==="transparent"?"rgba(0,0,0,0)":o;if(e.lineJoin="round",s.path){Ct(e,t,s,h,i,r);return}const{rows:u,heights:b,total:M,box:v,extras:T,ink:w}=Qe(e,t,s,h),P=o=>w?o.center+(o.ascent-o.descent)/2:o.center,d=o=>w?b[o]:u[o].size*1.12,k=Math.max(...u.map(o=>o.paragraph))+1,z=r&&t.animation?t.animation:void 0,Y=z?Array.from({length:k},(o,C)=>{const y=u.filter(c=>c.paragraph===C).map(c=>c.text).join(" ");return{word:Math.max(1,y.split(/\s+/).filter(Boolean).length),char:Math.max(1,le(y.replace(/\s/g,"")).length)}}):[],I=z&&r?lt(z,Y,r.time,r.duration,ht(s,u.length)):r?r.time:1e6,_={...ft,masked:!1},F=(o,C,y,c)=>z?ut(z,o,C,y,c,I):_,E=(o,C,y,c,a,te)=>typeof o=="string"?be(i(o),te):He(e,o,C,y,c,a,K=>be(i(K),te));let L=0;const j=(o,C,y,c,a,te=C-4e3,K=8e3)=>{if(e.globalAlpha*=Math.min(1,Math.max(0,o.opacity)),o.flicker>0&&Xe(Math.floor(I*24)+C*.01)<o.flicker&&(e.globalAlpha=0),o.reveal<1||o.masked){const $=Math.max(0,c*o.reveal);e.beginPath(),e.rect(-4e3,y-$,8e3,$*2),e.clip()}o.wipeX<1&&(e.beginPath(),e.rect(te-a*.1,y-c*1.6,(K+a*.2)*Math.max(0,o.wipeX),c*3.2),e.clip()),o.wipeY<1&&(e.beginPath(),e.rect(-4e3,y-c*1.2,8e3,c*2.4*Math.max(0,o.wipeY)),e.clip());const D=o.glitch>0?o.glitch*a*.35*(Xe(Math.floor(I*18)+y*.01)*2-1):0;return L=Math.max(L,o.glitch),e.translate(C+o.x*a+D,y+o.y*a),e.rotate(o.rotate*Math.PI/180),e.scale(o.scale*o.scaleX,o.scale*o.scaleY),e.translate(-C,-y),o.blur>0&&(e.filter=`blur(${(o.blur*a).toFixed(1)}px)`),o.brightness},W=o=>{Te(e,s,o.size,p,o.style);const C=u.filter($=>$.paragraph===o.paragraph&&u.indexOf($)<u.indexOf(o));let y=le(C.map($=>$.text).join("").replace(/\s/g,"")).length,c=C.map($=>$.text).join(" ").split(/\s+/).filter(Boolean).length;const a=[];let te=c-1,K=!0,D="";for(const $ of le(o.text)){const ee=e.measureText(D).width;if(D+=$,/\s/.test($)){K=!0;continue}K&&(te++,K=!1),a.push({text:$,x:o.left+ee,w:e.measureText(D).width-ee,char:y++,word:te})}return a},ae=(o,C)=>!!z?.in.some(y=>y.unit===C&&(!y.lines||y.lines.includes(o))),re=o=>Y[o]||{word:1,char:1},he=Array.from({length:k},(o,C)=>u.filter(y=>y.paragraph===C).map(y=>y.text).join(" ").split(/\s+/).filter(Boolean).length),Me=o=>he.slice(0,o).reduce((C,y)=>C+y,0),ge=o=>o.style?.align??g,ce=r&&t.animators?.length?t.animators:null,m=ce?Ve(u.map(o=>o.text)):null,N=ce&&m?Ne(ce,m,r.time):null,H=[];if(m){let o=0;for(let C=0;C<u.length;C++)H.push(o),o+=le(u[C].text).length}for(const o of s.layers){if(o.type==="texture"){bt(e,o,i(o.color));continue}if(o.type==="shape"||o.type==="icon"){e.save(),vt(e,o,I,i),e.restore();continue}if(e.save(),e.globalAlpha=o.opacity,o.type==="box"&&o.per==="block"){const c=u[0],a=F("line",c.paragraph,c.paragraph,k),te=o.padX*n,K=o.padY*n,D=(T?v.x:Math.min(...u.map(G=>G.left)))-te,$=(T?v.y:u[0].center-d(0)/2)-K,ee=(T?v.w:Math.max(...u.map(G=>G.width)))+te*2,O=(T?v.h:M-(b[0]-d(0))/2-(b.at(-1)-d(u.length-1))/2)+K*2,U=j(a,D+ee/2,$+O/2,O/2,n);(!o.motion||Ge(e,Re(o.motion,I),{x:D,y:$,w:ee,h:O},o.motion.origin,n))&&(o.skewX&&(e.translate(D+ee/2,$+O/2),e.transform(1,0,Math.tan(-o.skewX*Math.PI/180),1,0,0),e.translate(-D-ee/2,-$-O/2)),o.shadow&&(e.shadowColor=i(o.shadow.color),e.shadowBlur=o.shadow.blur*n,e.shadowOffsetX=o.shadow.x*n,e.shadowOffsetY=o.shadow.y*n),e.fillStyle=E(o.fill,D,$,ee,O,U),e.beginPath(),e.roundRect(D,$,ee,O,o.radius*n),e.fill(),o.stroke&&(e.strokeStyle=be(i(o.stroke.color),U),e.lineWidth=Math.max(1.5,o.stroke.width*n),e.stroke())),e.restore();continue}const C=u.map((c,a)=>o.lines?o.lines.includes(c.paragraph):o.type==="underline"?o.line==="all"||a===u.length-1:!0);let y=0;for(const[c,a]of u.entries()){if(!C[c])continue;const te=y++;e.save();const K=a.left+a.width/2;a.style?.rotate&&(e.translate(K,a.center),e.rotate(a.style.rotate*Math.PI/180),e.translate(-K,-a.center));const D=F("line",a.paragraph,a.paragraph,k);L=0;const $=j(D,K,a.center,b[c]/2+a.size*.1,a.size,a.left,a.width),ee=O=>!o.motion||Ge(e,Re(o.motion,I-(o.motion.stagger??0)*te),O,o.motion.origin,a.size);if(o.type==="box"){const O=o.padX*a.size,U=o.padY*a.size,G=a.left-O,B=a.center-d(c)/2-U,J=a.width+O*2,fe=d(c)+U*2;ee({x:G,y:B,w:J,h:fe})&&(o.skewX&&(e.translate(G+J/2,B+fe/2),e.transform(1,0,Math.tan(-o.skewX*Math.PI/180),1,0,0),e.translate(-G-J/2,-B-fe/2)),o.shadow&&(e.shadowColor=i(o.shadow.color),e.shadowBlur=o.shadow.blur*a.size,e.shadowOffsetX=o.shadow.x*a.size,e.shadowOffsetY=o.shadow.y*a.size),e.fillStyle=E(o.fill,G,B,J,fe,$),e.beginPath(),e.roundRect(G,B,J,fe,o.radius*a.size),e.fill(),o.stroke&&(e.strokeStyle=be(i(o.stroke.color),$),e.lineWidth=Math.max(1.5,o.stroke.width*a.size),e.stroke()))}if(o.type==="underline"){const O=a.width*o.width,U=ge(a),G=U==="left"?a.left:U==="right"?a.left+a.width-O:a.left+(a.width-O)/2,B=a.center+o.offsetY*a.size,J=Math.max(3,o.height*a.size);ee({x:G,y:B-(o.style==="swash"?a.size*.3:0),w:O,h:J+(o.style==="swash"?a.size*.5:0)})&&(e.fillStyle=E(o.fill,G,B,O,J,$),o.style==="swash"?(Pt(e,G,B,O,J,a.size),e.fill()):e.fillRect(G,B,O,J))}if(o.type==="text"){Te(e,s,a.size,p,a.style);const O=D.count!==1?dt(a.text,D.count):a.text;let U=a.left,G=a.width;if(O!==a.text){G=e.measureText(O).width;const S=ge(a);U=S==="left"?a.left:S==="right"?a.left+a.width-G:a.left+(a.width-G)/2}const B=(o.offset?.x||0)*a.size,J=(o.offset?.y||0)*a.size;if(r&&o.flicker&&Xe(Math.floor(I*12)*1.37+5)<o.flicker&&(e.globalAlpha*=.18),!ee({x:U+B-a.size*.05,y:a.center-d(c)/2+J-a.size*.12,w:G+a.size*.1,h:d(c)+a.size*.24})){e.restore();continue}o.shadow&&(e.shadowColor=i(o.shadow.color),e.shadowBlur=o.shadow.blur*a.size,e.shadowOffsetX=o.shadow.x*a.size,e.shadowOffsetY=o.shadow.y*a.size);const fe=o.lineFills?o.lineFills[c%o.lineFills.length]:void 0;let we=null;if(r&&o.shine){const S=o.shine;let X=I-S.start;X>=0&&S.every>0&&(X%=S.every);const q=X/S.duration;if(X>=0&&q<1){const A=S.width*a.size,R=U-A+(G+A*2)*q,Q=S.angle*Math.PI/180,Z=i(S.color);we=e.createLinearGradient(R-A*Math.cos(Q),a.center-A*Math.sin(Q),R+A*Math.cos(Q),a.center+A*Math.sin(Q)),we.addColorStop(0,Se(Z,0)),we.addColorStop(.5,Se(Z,1)),we.addColorStop(1,Se(Z,0))}}const et=fe??(a.fill&&o.fill==="{color}"?a.fill:o.fill),tt=a.center-d(c)/2+J,ot=(S,X)=>E(S,U+B,tt,G,d(c),X),at=o.reflection?P(a)+J+e.measureText(O).actualBoundingBoxDescent:0,ke=(S,X,q,A)=>{const R=P(a)+J,Q=A??et;if(L>.02){const Z=e.globalAlpha,oe=L*a.size*.08;e.globalAlpha=Z*.85,e.fillStyle="#fd436a",e.fillText(S,X+B+oe,R),e.fillStyle="#37eaff",e.fillText(S,X+B-oe,R),e.globalAlpha=Z}if(o.stroke&&(e.strokeStyle=be(i(o.stroke.color),q),e.lineWidth=Math.max(2,o.stroke.width*a.size),e.strokeText(S,X+B,R)),e.fillStyle=ot(Q,q),e.fillText(S,X+B,R),o.innerGlow){const Z=e.getTransform();At(e,oe=>oe.fillText(S,X+B,R),be(i(o.innerGlow.color),q),o.innerGlow.blur*a.size*Math.hypot(Z.a,Z.b))}if(we&&(e.save(),e.shadowColor="transparent",e.fillStyle=we,e.fillText(S,X+B,R),e.restore()),o.reflection){const Z=o.reflection,oe=at+Z.gap*a.size,$e=d(c)*Z.fade,V=i(Tt(Q)),de=!/^#[0-9a-f]{6}$/i.test(V),pe=de&&o.stroke?i(o.stroke.color):V;e.save(),e.shadowColor="transparent",e.filter="none",e.translate(0,2*oe),e.scale(1,-1);const ye=e.createLinearGradient(0,oe,0,oe-$e);ye.addColorStop(0,Se(pe,Z.opacity)),ye.addColorStop(1,Se(pe,0)),de&&o.stroke?(e.strokeStyle=ye,e.lineWidth=Math.max(2,o.stroke.width*a.size),e.strokeText(S,X+B,R)):(e.fillStyle=ye,e.fillText(S,X+B,R)),e.restore()}},me=new Map;for(const S of o.highlights??[])for(const X of S.words)me.set(X,S.fill);const Ce=Me(a.paragraph),ze=ae(a.paragraph,"word"),ve=ae(a.paragraph,"char"),Ie=D.spread;if(N){const S=le(a.text),X=zt(e,a.text,S),q=H[c],A=W(a);let R=0;for(let V=0;V<S.length;V++)R+=N[q+V].tracking;const Q=ge(a);let oe=Q==="left"?0:Q==="right"?-R:-R/2,$e=0;for(let V=0;V<S.length;V++){const de=N[q+V],pe=a.left+X[V],ye=X[V+1]-X[V],Ee=!/\S/u.test(S[V]),ie=Ee?null:A[$e++],Pe=oe;if(oe+=de.tracking,Ee||!ie||de.opacity<=.002||de.scale<=1e-4)continue;e.save();let Fe=$;ze&&(Fe*=j(F("word",a.paragraph,ie.word,re(a.paragraph).word),ie.x+ie.w/2,a.center,b[c]/2+a.size*.1,a.size)),ve&&(Fe*=j(F("char",a.paragraph,ie.char,re(a.paragraph).char),ie.x+ie.w/2,a.center,b[c]/2+a.size*.1,a.size)),e.globalAlpha>.002&&xe(e,de,pe+Pe+B+ye/2,a.center,()=>ke(S[V],pe+Pe,Fe,me.get(Ce+ie.word)),nt=>nt==="fill"?e.fillText(S[V],pe+Pe+B,P(a)+J):e.strokeText(S[V],pe+Pe+B,P(a)+J)),e.restore()}}else if(!ze&&!ve&&!Ie)if(!me.size||O!==a.text)ke(O,U,$);else{const S=new Map;for(const A of W(a)){const R=Ce+A.word,Q=S.get(R);S.set(R,Q?{x0:Math.min(Q.x0,A.x),x1:Math.max(Q.x1,A.x+A.w)}:{x0:A.x,x1:A.x+A.w})}const X=[...S].filter(([A])=>me.has(A)),q=a.size*.04;e.save(),e.beginPath(),e.rect(-1e5,-1e5,2e5,2e5);for(const[,A]of X)e.rect(A.x0+B-q,-1e5,A.x1-A.x0+q*2,2e5);e.clip("evenodd"),ke(O,U,$),e.restore();for(const[A,R]of X)e.save(),e.beginPath(),e.rect(R.x0+B-q,-1e5,R.x1-R.x0+q*2,2e5),e.clip(),ke(O,U,$,me.get(A)),e.restore()}else{const S=W(a),X=(S.length-1)/2;for(const[q,A]of S.entries()){e.save(),Ie&&e.translate((q-X)*Ie*a.size,0);let R=$;ze&&(R*=j(F("word",a.paragraph,A.word,re(a.paragraph).word),A.x+A.w/2,a.center,b[c]/2+a.size*.1,a.size)),ve&&(R*=j(F("char",a.paragraph,A.char,re(a.paragraph).char),A.x+A.w/2,a.center,b[c]/2+a.size*.1,a.size)),e.globalAlpha>.002&&ke(A.text,A.x,R,me.get(Ce+A.word)),e.restore()}}}e.restore()}e.restore()}}function vt(e,t,s,r){const n=x.width,f=x.height,p=Re(t.motion,s);if(e.globalAlpha=t.opacity*Math.min(1,Math.max(0,p.opacity)),e.globalAlpha<.002)return;let g,l,h,i;t.type==="shape"?(g=(t.box[0]+t.box[2]/2)*n,l=(t.box[1]+t.box[3]/2)*f,h=t.box[2]*n,i=t.box[3]*f):(h=i=t.size*f,g=t.center[0]*n,l=t.center[1]*f);const u=t.motion?.origin??"center",b=u==="left"?g-h/2:u==="right"?g+h/2:g,M=u==="top"?l-i/2:u==="bottom"?l+i/2:l;if(p.wipeX<1&&(e.beginPath(),e.rect(g-h/2-8,l-i/2-8,(h+16)*Math.max(0,p.wipeX),i+16),e.clip()),p.wipeY<1&&(e.beginPath(),e.rect(g-h/2-8,l-i/2-8,h+16,(i+16)*Math.max(0,p.wipeY)),e.clip()),e.translate(b+p.x*n,M+p.y*f),e.scale(p.scale*p.scaleX,p.scale*p.scaleY),e.translate(g-b,l-M),e.rotate(((t.rotate||0)+p.rotate)*Math.PI/180),t.type==="shape"){if(t.skewX&&e.transform(1,0,Math.tan(t.skewX*Math.PI/180),1,0,0),t.blur&&(e.filter=`blur(${(t.blur*f).toFixed(1)}px)`),t.shape==="glow"){const w=typeof t.fill=="string"?r(t.fill):r(t.stroke?.color??"{accent}"),P=Math.max(h,i)/2;e.scale(h/2/P,i/2/P);const d=e.createRadialGradient(0,0,0,0,0,P);d.addColorStop(0,w),d.addColorStop(1,"rgba(0,0,0,0)"),e.fillStyle=d,e.beginPath(),e.arc(0,0,P,0,Math.PI*2),e.fill();return}e.beginPath(),t.shape==="rect"?e.roundRect(-h/2,-i/2,h,i,Math.min(h,i)/2*Math.min(1,t.radius*2)):e.ellipse(0,0,h/2,i/2,0,0,Math.PI*2),t.fill&&(typeof t.fill=="string"?e.fillStyle=r(t.fill):e.fillStyle=He(e,t.fill,-h/2,-i/2,h,i,r),e.fill()),t.stroke&&(e.strokeStyle=r(t.stroke.color),e.lineWidth=t.stroke.width,e.setLineDash(t.stroke.dash??[]),e.stroke());return}if(t.glow&&(e.shadowColor=r(t.color),e.shadowBlur=t.glow*h*.5),t.badge!=="none"){e.save(),t.badge==="diamond"&&e.rotate(Math.PI/4);const w=t.badge==="diamond"?h*.72:h;e.beginPath(),t.badge==="circle"?e.arc(0,0,h/2,0,Math.PI*2):e.roundRect(-w/2,-w/2,w,w,t.badge==="square"?0:w*.22),t.badgeFill&&(e.fillStyle=r(t.badgeFill),e.fill()),t.badgeStroke&&(e.strokeStyle=r(t.badgeStroke),e.lineWidth=2,e.stroke()),e.restore()}e.shadowBlur=0;const v=h*.6,T=v/24;e.translate(-v/2,-v/2),e.scale(T,T),e.strokeStyle=r(t.color),e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round";for(const w of pt[t.name]??[])e.stroke(new Path2D(w))}function It(e){const t=[];for(const s of Array.from(document.styleSheets)){let r;try{r=s.cssRules}catch{continue}for(const n of Array.from(r))if(n instanceof CSSFontFaceRule&&n.style.getPropertyValue("font-family").replace(/['"]/g,"").trim()===e){const f=n.style.getPropertyValue("src");if(!f)continue;t.push(new FontFace(e,f,{weight:n.style.getPropertyValue("font-weight")||"normal",stretch:n.style.getPropertyValue("font-stretch")||"normal",style:n.style.getPropertyValue("font-style")||"normal"}))}}return t}const Je=async(e,t)=>{try{return await document.fonts.load(e,t),!0}catch{}await new Promise(r=>setTimeout(r,400));const s=e.match(/"([^"]+)"/)?.[1]??"";try{const r=It(s);return r.length?(await Promise.all(r.map(n=>n.load().then(()=>document.fonts.add(n)))),!0):!1}catch{return!1}};async function Xt(e){const t=it(e),s=[];if(t.length){const l=await st(()=>import("./userFonts-BZ4QL-zq.js"),__vite__mapDeps([0,1,2,3,4]));await l.userFontsReady();for(const h of t)l.isMissingCustomFont(h)&&s.push(h)}const r=e.design?.weight??(e.styleId&&e.styleId!=="classic"?800:600),n=e.design?.stretch&&e.design.stretch!=="normal"?e.design.stretch+" ":"",f=e.fontFamily||"Arial",p=[];await Je(`${r} ${n}${e.fontSize}px "${f}"`,e.text)||p.push(f);const g=e.design;if(g?.lines?.some(l=>l.font||l.weight||l.italic||l.stretch)){const l=[...new Set(g.lines.map(i=>Ke(g,e.fontSize,f,i).replace(/ sans-serif$/,"").replace(/,$/,"")))],h=await Promise.all(l.map(i=>Je(i,e.text)));l.forEach((i,u)=>{h[u]||p.push(i.replace(/^.*?"([^"]+)".*$/,"$1"))})}return[...new Set([...p.filter(l=>!s.includes(l)),...s])]}export{Ot as d,Xt as l,Bt as t};
@@ -14445,4 +14445,4 @@ ${e}
14445
14445
  ctx.save()
14446
14446
  for(const [lag,al] of [[0,1],[.18,.55]]){const z=M.ease.inExpo(M.clamp(k-lag+.08)),s=M.lerp(.22,3.2,z),w=W*.5*s,hh=H*.5*s;if(s>3.1)continue;ctx.globalAlpha=al*Math.min(1,Math.sin(Math.PI*M.clamp(k-lag+.08))*1.6);ctx.strokeStyle=A;ctx.lineWidth=Math.max(1.5,u*.006*s);ctx.strokeRect(W/2-w/2,H/2-hh/2,w,hh);ctx.fillStyle=INK;const q=u*.012*s;[[-1,-1],[1,-1],[-1,1],[1,1]].forEach(c=>ctx.fillRect(W/2+c[0]*w/2-q/2,H/2+c[1]*hh/2-q/2,q,q));if(lag===0){CHV(W/2-w/2-u*.06*s,H/2,u*.05*s,0,2,A);CHV(W/2+w/2+u*.06*s,H/2,u*.05*s,Math.PI,2,A)}}
14447
14447
  if(full){ctx.globalAlpha=.3;ctx.fillStyle=M.mix(A,'#ffffff',.7);ctx.fillRect(-m,-m,W+2*m,H+2*m)}
14448
- ctx.restore()`,{k:1.2,min:.5})}),AP=t=>Object.hasOwn(ag,t)?ag[t]:null,ng=Object.freeze({accent:"#ff1f8e",lime:"#c6f432",paper:"#fbf7fa",ink:"#141418"}),mm="#c6f432",Ps=Object.freeze(["ur-photocopy-scribble","ur-magenta-flash","ur-neon-edge","ur-torn-paper","ur-cutout-blocks","ur-sticker-slap","ed-box-wipe","ed-arc-swoosh","ed-star-flythrough","ed-window-morph","ed-window-morph-v","ed-flicker-cut","ed-color-flash","ed-negative-blink","ed-silhouette-lead","ed-flash-invert","ed-invert-cut","tl-duotone-flash","tl-pixel-dissolve","tl-card-cascade","tl-chevron-push","tl-scramble","tl-blur-whip","tl-frame-zoom"]),CP=Object.freeze(Ll.filter(t=>Ps.includes(t.id))),Xf=.2,_f=1.2,RP=/^#[0-9a-fA-F]{6}$/,Po=t=>wo(t)&&!t.motion&&!t.lottie&&!t.geo&&!t.element&&!t.solid&&!t.adjust&&!t.nullLayer&&!t.freeze,Hl=t=>{const e=Rs(t?.style),c=Number.isFinite(t?.duration)?t.duration:e?.dur??.5;return 2*V(Math.max(Xf,Math.min(_f,c))/2)},Xh=(t,e)=>t.kind==="sequence"?e+1/15:1.5*e+1/15;function Mm(t,e,c,{duration:a,color:n}={}){const o=t.find(d=>d.id===e);if(!o)throw Error("Clip not found");if(c==="none"){if(!o.join)throw Error("No join style on this cut");return t.map(d=>{if(d.id!==e)return d;const{join:p,...b}=d;return b})}const i=Eo(t,o);if(!Po(o)||!Po(i))throw Error("Join styles need two touching filmed clips (video / photo) on the same track");const s=Rs(c??o.join?.style);if(!s||!Ps.includes(s.id))throw Error(`Unknown footage join style "${c}" — use ${Ps.join(", ")}`);const r={style:s.id},l=Number.isFinite(a)?a:o.join?.style===s.id?o.join.duration:void 0;if(l!==void 0){if(!(l>=Xf&&l<=_f))throw Error("Join duration must be 0.2–1.2 s");r.duration=V(l)}const x=n??o.join?.color;if(x!==void 0){if(!RP.test(x))throw Error("Join colour must be #RRGGBB");r.color=x}const h=Hl(r),f=Xh(s,h);if(o.duration<f-1e-6||i.duration<f-1e-6)throw Error(`Clips too short for this join (each needs ≥ ${f.toFixed(2)} s)`);return t.map(d=>{if(d.id===o.id){const{transition:p,visualFadeOut:b,fadeOutColor:g,...m}=d;return{...m,join:r}}if(d.id===i.id&&(d.visualFadeIn||d.fadeInColor)){const{visualFadeIn:p,fadeInColor:b,...g}=d;return g}return d})}function PP(t,e,c,{duration:a,newId:n=()=>`sil-${Math.random().toString(36).slice(2,9)}`}={}){const o=t.find(T=>T.id===c),i=o&&Eo(t,o);if(!o||!i||!Po(o)||!Po(i))throw Error("Silhouette reveal needs two touching filmed clips on one track");if(i.kind!=="image"||!i.url)throw Error("Silhouette reveal needs a photo after the cut (its subject is cut out in the browser)");const s=Mm(t,c,"ed-silhouette-lead",{duration:a}),r=Hl(s.find(T=>T.id===c).join),l=V(i.start-r/2),x=V(i.start+r/2),{track:h}=sl(s,e,l,x),{transition:f,join:d,visualFadeIn:p,visualFadeOut:b,fadeInColor:g,fadeOutColor:m,enter:y,exit:k,captions:w,captionWords:S,mask:u,...M}=i,A=mn({...M,id:n(),track:h,start:l,duration:V(x-l),volume:0,label:`${i.label??"Shot"} · silhouette`,silhouetteOf:i.id},"enter","slide-left",{duration:V(r/2),amount:1,fade:!1,ease:"expo-out"});return{clips:[...s,A],copyId:A.id}}function Vf(t){return t.filter(e=>e.join&&!e.disabled).flatMap(e=>{const c=Eo(t,e),a=Rs(e.join.style);if(!a||!Ps.includes(a.id)||e.transition||!Po(e)||!Po(c))return[];const n=Hl(e.join);return e.duration<Xh(a,n)-1e-6||c.duration<Xh(a,n)-1e-6?[]:[{a:e,b:c,style:a,w:n,cut:c.start}]})}const qx=t=>{const e=Je[t.ease],c=e==="hold"?[-1,0,0,0]:Array.isArray(e)?e:[0,0,1,1];return{e0:c[0],e1:c[1],e2:c[2],e3:c[3]}};function Yf({a:t,b:e,style:c,w:a,cut:n}){const o=c.pack==="urban",i=c.pack==="techlaunch",s=c.sticker?null:i?AP(c.deco):o?uP(c.deco):SP(c.deco);if(!s)return null;const r=t.join.color??(i?ng.accent:mm),l=V(Math.min(2*n,Za.maxDuration,Math.max(s.min,a*s.k+s.add))),x=xy({code:s.code,params:i?{...ng,accent:r,...qx(c)}:o?{accent:r,...gP,...qx(c)}:{accent:r,...vP,...qx(c),w:a,flash:t.join.color??"#ffffff"},preset:c.id});return{id:`${t.id}~jfx`,nodeId:"",kind:"image",url:"",label:`${i?"Tech Launch":o?"Urban":"Editorial"} · ${t.label} → ${e.label}`,volume:0,start:V(n-l/2),duration:l,track:t.track,motion:{...x,duration:l},motionKeys:[],_slot:"k",_virtual:t.id,...t.zIndex!==void 0||e.zIndex!==void 0?{zIndex:Math.max(t.zIndex??0,e.zIndex??0)}:{},...s.cam&&t.is3D&&e.is3D?{is3D:!0}:{}}}function zP(t){const e=new Set(t.map(c=>c.id));return Vf(t).map(Yf).filter(c=>c&&!e.has(c.id))}const BP=.1,og=(t,e)=>{const{captions:c,captionWords:a,audioFadeIn:n,audioFadeOut:o,visualFadeIn:i,visualFadeOut:s,enter:r,exit:l,transition:x,join:h,...f}=t;return{...f,volume:0,_slot:"j",_virtual:e}},ig=t=>{if(!t.revealType)return t;const{revealType:e,reveal:c,...a}=t;return{...a,...It(a,"reveal").length?{motionKeys:za(a,"reveal",[])}:{}}};function wm(t){if(!t.some(o=>o.join))return t;let e=t.slice();const c=[],a=[],n=o=>{e=e.map(i=>i.id===o.id?o:i)};for(const o of Vf(t).sort((i,s)=>i.cut-s.cut)){const i=e.find(b=>b.id===o.a.id),s=e.find(b=>b.id===o.b.id),{style:r,w:l,cut:x}=o,h=l/2,f=V(x-h),d=V(x+h);if(r.kind==="sequence"){const b=Z1(r,{out:[i],inn:[{...s,start:f,duration:V(s.duration+h)}],b0:f,b1:d});for(const g of[i,s]){const m=b.get(g.id);if(!m)continue;let{seam:y,...k}=m;r.sticker&&(k={...k,motionKeys:za(k,"rot",It(g,"rot"))}),n({...k,start:g.start,duration:g.duration,inPoint:g.inPoint,...g.seam?{seam:g.seam}:{}})}}else{const b=i.playbackRate||1,g=s.playbackRate||1,{tail:m,head:y}=Qg(i,s),k=Z1(r,{out:[i],inn:[{...s,inPoint:(s.inPoint||0)-h*g}],b0:f,b1:d}),w=k.get(i.id),S=k.get(s.id);if(!w||!S)continue;const u=({seam:P,...z})=>z,[M,A]=$1(u(w),x,`${i.id}~jna`),[T,v]=$1(u(S),x,s.id);if(!A||!v)continue;n({...ig(M),...i.seam?{seam:i.seam}:{}}),n({...ig({...v,inPoint:s.inPoint||0}),...s.seam?{seam:s.seam}:{}}),(m<h||y<h)&&c.push({clipId:i.id,tail:Math.min(m,h),head:Math.min(y,h),need:h});const C=i.kind==="video"&&m<h,R=s.kind==="video"&&y<h;a.push({...og(A,i.id),...C?{_still:!0,inPoint:Math.max(0,(i.inPoint||0)+i.duration*b-BP)}:{}}),a.push({...og({...T,id:`${s.id}~jnb`},s.id),...R?{_still:!0,inPoint:s.inPoint||0}:{inPoint:(s.inPoint||0)-h*g}})}const p=Yf({...o,a:{...o.a}});p&&!t.some(b=>b.id===p.id)&&a.push(p)}return Object.assign([...e,...a],{short:c})}const CH=Object.freeze(Object.defineProperty({__proto__:null,FOOTAGE_JOIN_ACCENT:mm,FOOTAGE_JOIN_IDS:Ps,FOOTAGE_JOIN_MAX:_f,FOOTAGE_JOIN_MIN:Xf,FOOTAGE_JOIN_STYLES:CP,cutJoins:Vf,expandJoins:wm,joinDeco:Yf,joinDecoLayers:zP,joinWindow:Hl,joinable:Po,setCutJoin:Mm,silhouetteReveal:PP},Symbol.toStringTag,{value:"Module"})),sg=21600,km=t=>t.kind==="image"&&(jy(t.title)||!!t.shape||!!t.motion||!!t.lottie||!!t.card||!!t.geo||t.warped===!0),RH=t=>Gw(wm((t||[]).filter(e=>e&&!e.disabled))).filter(e=>e._virtual&&km(e)),PH=(t,e)=>(t||[]).filter(c=>!c?.disabled&&km(c)).reduce((c,a)=>c+(KC(a)?1:Math.ceil(a.duration*e)),0),zH=(t,e=!0)=>e?`Video có quá nhiều lớp chữ động / Motion chồng nhau (${t} khung, tối đa ${sg}). Hãy xuất từng đoạn ngắn hơn hoặc xoá bớt các lớp chữ trùng nhau.`:`Too many overlapping animated text / Motion layers (${t} frames, max ${sg}). Export a shorter part at a time or remove duplicate text layers.`;export{Iv as $,dH as A,il as B,Fw as C,s5 as D,iH as E,Ve as F,ba as G,Ps as H,WE as I,Ll as J,F4 as K,RE as L,G1 as M,m8 as N,yE as O,Gb as P,v8 as Q,Fa as R,Z5 as S,ry as T,Pb as U,cE as V,Lb as W,mb as X,j9 as Y,L9 as Z,EP as _,Yh as a,Eg as a$,X9 as a0,$r as a1,c4 as a2,Q9 as a3,y4 as a4,i4 as a5,Ch as a6,I9 as a7,J9 as a8,Z9 as a9,v7 as aA,Je as aB,A7 as aC,C7 as aD,An as aE,zs as aF,me as aG,us as aH,G5 as aI,an as aJ,E7 as aK,Kn as aL,W7 as aM,R7 as aN,L7 as aO,GM as aP,_7 as aQ,Mi as aR,OM as aS,SM as aT,b0 as aU,$l as aV,oM as aW,sM as aX,RM as aY,UM as aZ,jM as a_,tE as aa,eE as ab,K2 as ac,Tb as ad,Bd as ae,Mf as af,Nv as ag,Ld as ah,pf as ai,Rh as aj,Ab as ak,Ml as al,h4 as am,M4 as an,p4 as ao,V7 as ap,uM as aq,Vs as ar,G7 as as,N7 as at,V as au,v5 as av,Gl as aw,Nl as ax,r0 as ay,T7 as az,$x as b,LP as b$,X7 as b0,Z7 as b1,Q7 as b2,_x as b3,I7 as b4,q7 as b5,bs as b6,g0 as b7,kM as b8,Ul as b9,vL as bA,TL as bB,SL as bC,$h as bD,DL as bE,Dz as bF,HP as bG,OP as bH,Dm as bI,ah as bJ,$z as bK,Xz as bL,Iz as bM,Vz as bN,_z as bO,jz as bP,Oz as bQ,qz as bR,IP as bS,NP as bT,Nz as bU,Gz as bV,Uz as bW,Kz as bX,bb as bY,Ss as bZ,Ls as b_,bM as ba,y0 as bb,m0 as bc,U7 as bd,v4 as be,g3 as bf,a7 as bg,uE as bh,Af as bi,B4 as bj,pE as bk,gE as bl,bE as bm,lm as bn,Kh as bo,I1 as bp,D1 as bq,vs as br,QT as bs,YT as bt,n8 as bu,PE as bv,c1 as bw,ve as bx,OL as by,hR as bz,i7 as c,kB as c$,uB as c0,UC as c1,jC as c2,ZW as c3,$y as c4,HC as c5,nL as c6,Qn as c7,DC as c8,IC as c9,BB as cA,jB as cB,Xa as cC,HB as cD,Kk as cE,EB as cF,Zk as cG,P2 as cH,Hk as cI,TB as cJ,nR as cK,vB as cL,xc as cM,Uk as cN,sS as cO,PB as cP,CB as cQ,RB as cR,iS as cS,LB as cT,SB as cU,MB as cV,Te as cW,jk as cX,V0 as cY,xl as cZ,lf as c_,aL as ca,Fn as cb,FC as cc,on as cd,JW as ce,cL as cf,ko as cg,Lz as ch,Wz as ci,Hz as cj,Qz as ck,tk as cl,G0 as cm,Bo as cn,uL as co,b7 as cp,Ef as cq,Ts as cr,ky as cs,Sy as ct,oA as cu,Pk as cv,pB as cw,A2 as cx,VB as cy,C2 as cz,n7 as d,ws as d$,wB as d0,Gk as d1,Dk as d2,q9 as d3,vv as d4,Zn as d5,md as d6,P9 as d7,Mv as d8,nv as d9,QE as dA,cA as dB,Lh as dC,wy as dD,$E as dE,Df as dF,Ih as dG,Z8 as dH,pW as dI,po as dJ,UE as dK,uW as dL,FE as dM,XE as dN,KE as dO,VE as dP,My as dQ,mW as dR,_E as dS,yW as dT,gW as dU,bW as dV,zx as dW,fW as dX,Py as dY,tC as dZ,WW as d_,Sv as da,wd as db,z9 as dc,ub as dd,lb as de,kd as df,hC as dg,jW as dh,KW as di,UW as dj,sl as dk,qh as dl,Ds as dm,So as dn,H9 as dp,yb as dq,pl as dr,A3 as ds,Is as dt,Z2 as du,S9 as dv,tb as dw,dv as dx,fv as dy,YE as dz,r5 as e,sW as e$,gB as e0,yl as e1,K9 as e2,wb as e3,ur as e4,U9 as e5,ok as e6,xB as e7,oC as e8,xL as e9,wz as eA,kz as eB,Sz as eC,pz as eD,Mz as eE,gz as eF,IB as eG,fS as eH,OB as eI,gS as eJ,qB as eK,DB as eL,GB as eM,LW as eN,Gw as eO,wm as eP,tx as eQ,rk as eR,jy as eS,nH as eT,oH as eU,fH as eV,wW as eW,ZE as eX,oP as eY,Y9 as eZ,tw as e_,It as ea,Mr as eb,et as ec,uo as ed,Zt as ee,T4 as ef,nE as eg,A4 as eh,Wb as ei,ls as ej,pL as ek,Az as el,Zg as em,Yg as en,mz as eo,sz as ep,lz as eq,Mo as er,ho as es,rz as et,dz as eu,bz as ev,yz as ew,uz as ex,vw as ey,vz as ez,xm as f,s9 as f$,lB as f0,Kv as f1,CC as f2,oL as f3,NB as f4,iz as f5,tL as f6,vl as f7,ye as f8,$s as f9,iE as fA,NA as fB,nW as fC,hB as fD,rL as fE,sL as fF,rB as fG,c9 as fH,Vh as fI,dg as fJ,XP as fK,a0 as fL,VP as fM,N2 as fN,GP as fO,jP as fP,Nm as fQ,$P as fR,YP as fS,Ra as fT,c5 as fU,a5 as fV,Gx as fW,t7 as fX,c7 as fY,e7 as fZ,dl as f_,Us as fa,Tl as fb,Jy as fc,u7 as fd,FW as fe,B7 as ff,k7 as fg,oB as fh,g7 as fi,HW as fj,DW as fk,Yr as fl,eB as fm,rf as fn,vk as fo,Yn as fp,vy as fq,i2 as fr,gi as fs,rW as ft,pc as fu,If as fv,Al as fw,Xs as fx,_s as fy,g5 as fz,MM as g,ML as g$,QS as g0,ai as g1,gm as g2,i9 as g3,US as g4,O2 as g5,kS as g6,fl as g7,YB as g8,QB as g9,h9 as gA,JB as gB,$B as gC,pw as gD,nw as gE,mo as gF,v0 as gG,xz as gH,cl as gI,cf as gJ,$g as gK,Hr as gL,yo as gM,ow as gN,_g as gO,fz as gP,R0 as gQ,li as gR,nk as gS,Ms as gT,Cl as gU,$e as gV,Of as gW,eW as gX,am as gY,jL as gZ,Qr as g_,ed as ga,sd as gb,x9 as gc,G2 as gd,l9 as ge,mL as gf,cz as gg,ez as gh,nz as gi,MH as gj,az as gk,YL as gl,ZL as gm,QL as gn,ld as go,d9 as gp,f9 as gq,n3 as gr,UB as gs,c3 as gt,_B as gu,FP as gv,FB as gw,XB as gx,KB as gy,UP as gz,zo as h,zR as h$,KL as h0,vR as h1,O7 as h2,xA as h3,MC as h4,_W as h5,Kf as h6,Vr as h7,XW as h8,kC as h9,rP as hA,Hl as hB,CP as hC,_f as hD,Xf as hE,R9 as hF,u9 as hG,p9 as hH,df as hI,Yy as hJ,Qy as hK,Zy as hL,Ob as hM,wH as hN,kH as hO,ti as hP,d0 as hQ,km as hR,Jz as hS,iW as hT,ih as hU,Zz as hV,sB as hW,cW as hX,sk as hY,K7 as hZ,aB as h_,qr as ha,aH as hb,Ur as hc,S4 as hd,Dv as he,_9 as hf,jr as hg,vf as hh,Ib as hi,vh as hj,Pv as hk,Mb as hl,di as hm,pi as hn,Bb as ho,V9 as hp,Uv as hq,Nd as hr,Eb as hs,Cb as ht,F9 as hu,Rs as hv,xy as hw,Za as hx,p5 as hy,E9 as hz,iM as i,j7 as i$,XL as i0,gL as i1,tB as i2,dW as i3,bA as i4,aW as i5,D9 as i6,Eo as i7,Qg as i8,Jx as i9,T9 as iA,B3 as iB,cb as iC,cB as iD,Rz as iE,wo as iF,NW as iG,AB as iH,dB as iI,zH as iJ,al as iK,Es as iL,RH as iM,za as iN,Ti as iO,BR as iP,E1 as iQ,FL as iR,P8 as iS,Nf as iT,xs as iU,C5 as iV,m7 as iW,w7 as iX,M7 as iY,R5 as iZ,y7 as i_,Bz as ia,zz as ib,Po as ic,pH as id,Ao as ie,To as ig,_L as ih,tH as ii,Pm as ij,$1 as ik,XC as il,PH as im,sg as io,kk as ip,fB as iq,VL as ir,JL as is,cH as it,eH as iu,q2 as iv,N9 as iw,Xn as ix,C9 as iy,eb as iz,Jh as j,a9 as j$,ii as j0,$7 as j1,dE as j2,E4 as j3,W4 as j4,L4 as j5,Rn as j6,AC as j7,WP as j8,bL as j9,TH as jA,Z1 as jB,AP as jC,uP as jD,SP as jE,ng as jF,gP as jG,vP as jH,LE as jI,wE as jJ,kE as jK,aT as jL,oT as jM,iT as jN,VC as jO,Cy as jP,s2 as jQ,ph as jR,_2 as jS,U2 as jT,C4 as jU,oW as jV,JP as jW,KP as jX,Fm as jY,Km as jZ,ds as j_,eR as ja,rr as jb,Qt as jc,lL as jd,yi as je,BA as jf,ZT as jg,f8 as jh,OA as ji,qA as jj,Ty as jk,h8 as jl,IE as jm,s1 as jn,Cx as jo,N8 as jp,l1 as jq,CM as jr,hS as js,Or as jt,Ac as ju,EE as jv,be as jw,AH as jx,vH as jy,SH as jz,Am as k,hz as k$,Ym as k0,Zf as k1,jm as k2,hf as k3,I2 as k4,QP as k5,_P as k6,zS as k7,ZP as k8,Vm as k9,Cc as kA,qP as kB,Lm as kC,Ye as kD,DP as kE,zm as kF,ck as kG,B9 as kH,v9 as kI,z3 as kJ,$W as kK,gH as kL,bH as kM,yH as kN,mH as kO,GW as kP,iC as kQ,rC as kR,qW as kS,IW as kT,OW as kU,UR as kV,hm as kW,Wr as kX,Ar as kY,ik as kZ,Qx as k_,n9 as ka,o9 as kb,Gm as kc,hg as kd,Jn as ke,Xk as kf,Qk as kg,Dh as kh,IL as ki,$C as kj,SW as kk,Ff as kl,PP as km,Mm as kn,UL as ko,ui as kp,nP as kq,hH as kr,xH as ks,fE as kt,mn as ku,s7 as kv,t5 as kw,ug as kx,gg as ky,e5 as kz,nf as l,SE as l$,Tz as l0,D7 as l1,pM as l2,SC as l3,vC as l4,lW as l5,iB as l6,d2 as l7,iL as l8,Pz as l9,m4 as lA,dL as lB,VM as lC,YM as lD,b9 as lE,y9 as lF,g9 as lG,eL as lH,WC as lI,$L as lJ,x7 as lK,h7 as lL,p7 as lM,f7 as lN,d7 as lO,l7 as lP,KC as lQ,r9 as lR,BE as lS,JE as lT,ME as lU,CE as lV,AE as lW,vE as lX,X4 as lY,mE as lZ,TE as l_,k9 as la,pv as lb,S3 as lc,uv as ld,A9 as le,ml as lf,oz as lg,oE as lh,hL as li,uH as lj,bo as lk,Cz as ll,EA as lm,J7 as ln,tz as lo,Y7 as lp,Ez as lq,Yz as lr,kg as ls,fL as lt,S7 as lu,m9 as lv,tW as lw,z7 as lx,P7 as ly,G9 as lz,Yo as m,yL as m$,fi as m0,pg as m1,e9 as m2,xg as m3,t9 as m4,ZB as m5,R4 as m6,sE as m7,lE as m8,xE as m9,qm as mA,QW as mB,$9 as mC,Gs as mD,KA as mE,U8 as mF,DE as mG,NE as mH,Y8 as mI,_8 as mJ,eA as mK,Rl as mL,PW as mM,kW as mN,TW as mO,AW as mP,BW as mQ,EW as mR,MW as mS,zW as mT,vW as mU,CW as mV,RW as mW,C3 as mX,H7 as mY,Uw as mZ,iP as m_,rE as ma,vc as mb,hE as mc,lH as md,rH as me,sH as mf,l8 as mg,NL as mh,CL as mi,GL as mj,wL as mk,RL as ml,HL as mm,AL as mn,WL as mo,LL as mp,zL as mq,PL as mr,zE as ms,kL as mt,BL as mu,EL as mv,qL as mw,_0 as mx,jR as my,YW as mz,o7 as n,nB as n0,F7 as n1,zB as n2,WB as n3,mB as n4,O9 as n5,W9 as n6,yB as n7,bB as n8,VW as n9,Fz as na,nh as nb,xW as nc,hW as nd,M9 as ne,pr as nf,w9 as ng,Bv as nh,qE as ni,GE as nj,jE as nk,OE as nl,HE as nm,aE as nn,CH as no,jx as o,kr as p,h5 as q,r7 as r,Pa as s,J as t,Qd as u,TM as v,Vd as w,Yd as x,N4 as y,Ir as z};
14448
+ ctx.restore()`,{k:1.2,min:.5})}),AP=t=>Object.hasOwn(ag,t)?ag[t]:null,ng=Object.freeze({accent:"#ff1f8e",lime:"#c6f432",paper:"#fbf7fa",ink:"#141418"}),mm="#c6f432",Ps=Object.freeze(["ur-photocopy-scribble","ur-magenta-flash","ur-neon-edge","ur-torn-paper","ur-cutout-blocks","ur-sticker-slap","ed-box-wipe","ed-arc-swoosh","ed-star-flythrough","ed-window-morph","ed-window-morph-v","ed-flicker-cut","ed-color-flash","ed-negative-blink","ed-silhouette-lead","ed-flash-invert","ed-invert-cut","tl-duotone-flash","tl-pixel-dissolve","tl-card-cascade","tl-chevron-push","tl-scramble","tl-blur-whip","tl-frame-zoom"]),CP=Object.freeze(Ll.filter(t=>Ps.includes(t.id))),Xf=.2,_f=1.2,RP=/^#[0-9a-fA-F]{6}$/,Po=t=>wo(t)&&!t.motion&&!t.lottie&&!t.geo&&!t.element&&!t.solid&&!t.adjust&&!t.nullLayer&&!t.freeze,Hl=t=>{const e=Rs(t?.style),c=Number.isFinite(t?.duration)?t.duration:e?.dur??.5;return 2*V(Math.max(Xf,Math.min(_f,c))/2)},Xh=(t,e)=>t.kind==="sequence"?e+1/15:1.5*e+1/15;function Mm(t,e,c,{duration:a,color:n}={}){const o=t.find(d=>d.id===e);if(!o)throw Error("Clip not found");if(c==="none"){if(!o.join)throw Error("No join style on this cut");return t.map(d=>{if(d.id!==e)return d;const{join:p,...b}=d;return b})}const i=Eo(t,o);if(!Po(o)||!Po(i))throw Error("Join styles need two touching filmed clips (video / photo) on the same track");const s=Rs(c??o.join?.style);if(!s||!Ps.includes(s.id))throw Error(`Unknown footage join style "${c}" — use ${Ps.join(", ")}`);const r={style:s.id},l=Number.isFinite(a)?a:o.join?.style===s.id?o.join.duration:void 0;if(l!==void 0){if(!(l>=Xf&&l<=_f))throw Error("Join duration must be 0.2–1.2 s");r.duration=V(l)}const x=n??o.join?.color;if(x!==void 0){if(!RP.test(x))throw Error("Join colour must be #RRGGBB");r.color=x}const h=Hl(r),f=Xh(s,h);if(o.duration<f-1e-6||i.duration<f-1e-6)throw Error(`Clips too short for this join (each needs ≥ ${f.toFixed(2)} s)`);return t.map(d=>{if(d.id===o.id){const{transition:p,visualFadeOut:b,fadeOutColor:g,...m}=d;return{...m,join:r}}if(d.id===i.id&&(d.visualFadeIn||d.fadeInColor)){const{visualFadeIn:p,fadeInColor:b,...g}=d;return g}return d})}function PP(t,e,c,{duration:a,newId:n=()=>`sil-${Math.random().toString(36).slice(2,9)}`}={}){const o=t.find(T=>T.id===c),i=o&&Eo(t,o);if(!o||!i||!Po(o)||!Po(i))throw Error("Silhouette reveal needs two touching filmed clips on one track");if(i.kind!=="image"||!i.url)throw Error("Silhouette reveal needs a photo after the cut (its subject is cut out in the browser)");const s=Mm(t,c,"ed-silhouette-lead",{duration:a}),r=Hl(s.find(T=>T.id===c).join),l=V(i.start-r/2),x=V(i.start+r/2),{track:h}=sl(s,e,l,x),{transition:f,join:d,visualFadeIn:p,visualFadeOut:b,fadeInColor:g,fadeOutColor:m,enter:y,exit:k,captions:w,captionWords:S,mask:u,...M}=i,A=mn({...M,id:n(),track:h,start:l,duration:V(x-l),volume:0,label:`${i.label??"Shot"} · silhouette`,silhouetteOf:i.id},"enter","slide-left",{duration:V(r/2),amount:1,fade:!1,ease:"expo-out"});return{clips:[...s,A],copyId:A.id}}function Vf(t){return t.filter(e=>e.join&&!e.disabled).flatMap(e=>{const c=Eo(t,e),a=Rs(e.join.style);if(!a||!Ps.includes(a.id)||e.transition||!Po(e)||!Po(c))return[];const n=Hl(e.join);return e.duration<Xh(a,n)-1e-6||c.duration<Xh(a,n)-1e-6?[]:[{a:e,b:c,style:a,w:n,cut:c.start}]})}const qx=t=>{const e=Je[t.ease],c=e==="hold"?[-1,0,0,0]:Array.isArray(e)?e:[0,0,1,1];return{e0:c[0],e1:c[1],e2:c[2],e3:c[3]}};function Yf({a:t,b:e,style:c,w:a,cut:n}){const o=c.pack==="urban",i=c.pack==="techlaunch",s=c.sticker?null:i?AP(c.deco):o?uP(c.deco):SP(c.deco);if(!s)return null;const r=t.join.color??(i?ng.accent:mm),l=V(Math.min(2*n,Za.maxDuration,Math.max(s.min,a*s.k+s.add))),x=xy({code:s.code,params:i?{...ng,accent:r,...qx(c)}:o?{accent:r,...gP,...qx(c)}:{accent:r,...vP,...qx(c),w:a,flash:t.join.color??"#ffffff"},preset:c.id});return{id:`${t.id}~jfx`,nodeId:"",kind:"image",url:"",label:`${i?"Tech Launch":o?"Urban":"Editorial"} · ${t.label} → ${e.label}`,volume:0,start:V(n-l/2),duration:l,track:t.track,motion:{...x,duration:l},motionKeys:[],_slot:"k",_virtual:t.id,...t.zIndex!==void 0||e.zIndex!==void 0?{zIndex:Math.max(t.zIndex??0,e.zIndex??0)}:{},...s.cam&&t.is3D&&e.is3D?{is3D:!0}:{}}}function zP(t){const e=new Set(t.map(c=>c.id));return Vf(t).map(Yf).filter(c=>c&&!e.has(c.id))}const BP=.1,og=(t,e)=>{const{captions:c,captionWords:a,audioFadeIn:n,audioFadeOut:o,visualFadeIn:i,visualFadeOut:s,enter:r,exit:l,transition:x,join:h,...f}=t;return{...f,volume:0,_slot:"j",_virtual:e}},ig=t=>{if(!t.revealType)return t;const{revealType:e,reveal:c,...a}=t;return{...a,...It(a,"reveal").length?{motionKeys:za(a,"reveal",[])}:{}}};function wm(t){if(!t.some(o=>o.join))return t;let e=t.slice();const c=[],a=[],n=o=>{e=e.map(i=>i.id===o.id?o:i)};for(const o of Vf(t).sort((i,s)=>i.cut-s.cut)){const i=e.find(b=>b.id===o.a.id),s=e.find(b=>b.id===o.b.id),{style:r,w:l,cut:x}=o,h=l/2,f=V(x-h),d=V(x+h);if(r.kind==="sequence"){const b=Z1(r,{out:[i],inn:[{...s,start:f,duration:V(s.duration+h)}],b0:f,b1:d});for(const g of[i,s]){const m=b.get(g.id);if(!m)continue;let{seam:y,...k}=m;r.sticker&&(k={...k,motionKeys:za(k,"rot",It(g,"rot"))}),n({...k,start:g.start,duration:g.duration,inPoint:g.inPoint,...g.seam?{seam:g.seam}:{}})}}else{const b=i.playbackRate||1,g=s.playbackRate||1,{tail:m,head:y}=Qg(i,s),k=Z1(r,{out:[i],inn:[{...s,inPoint:(s.inPoint||0)-h*g}],b0:f,b1:d}),w=k.get(i.id),S=k.get(s.id);if(!w||!S)continue;const u=({seam:P,...z})=>z,[M,A]=$1(u(w),x,`${i.id}~jna`),[T,v]=$1(u(S),x,s.id);if(!A||!v)continue;n({...ig(M),...i.seam?{seam:i.seam}:{}}),n({...ig({...v,inPoint:s.inPoint||0}),...s.seam?{seam:s.seam}:{}}),(m<h||y<h)&&c.push({clipId:i.id,tail:Math.min(m,h),head:Math.min(y,h),need:h});const C=i.kind==="video"&&m<h,R=s.kind==="video"&&y<h;a.push({...og(A,i.id),...C?{_still:!0,inPoint:Math.max(0,(i.inPoint||0)+i.duration*b-BP)}:{}}),a.push({...og({...T,id:`${s.id}~jnb`},s.id),...R?{_still:!0,inPoint:s.inPoint||0}:{inPoint:(s.inPoint||0)-h*g}})}const p=Yf({...o,a:{...o.a}});p&&!t.some(b=>b.id===p.id)&&a.push(p)}return Object.assign([...e,...a],{short:c})}const CH=Object.freeze(Object.defineProperty({__proto__:null,FOOTAGE_JOIN_ACCENT:mm,FOOTAGE_JOIN_IDS:Ps,FOOTAGE_JOIN_MAX:_f,FOOTAGE_JOIN_MIN:Xf,FOOTAGE_JOIN_STYLES:CP,cutJoins:Vf,expandJoins:wm,joinDeco:Yf,joinDecoLayers:zP,joinWindow:Hl,joinable:Po,setCutJoin:Mm,silhouetteReveal:PP},Symbol.toStringTag,{value:"Module"})),sg=21600,km=t=>t.kind==="image"&&(jy(t.title)||!!t.shape||!!t.motion||!!t.lottie||!!t.card||!!t.geo||t.warped===!0),RH=t=>Gw(wm((t||[]).filter(e=>e&&!e.disabled))).filter(e=>e._virtual&&km(e)),PH=(t,e)=>(t||[]).filter(c=>!c?.disabled&&km(c)).reduce((c,a)=>c+(KC(a)?1:Math.ceil(a.duration*e)),0),zH=(t,e=!0)=>e?`Video có quá nhiều lớp chữ động / Motion chồng nhau (${t} khung, tối đa ${sg}). Hãy xuất từng đoạn ngắn hơn hoặc xoá bớt các lớp chữ trùng nhau.`:`Too many overlapping animated text / Motion layers (${t} frames, max ${sg}). Export a shorter part at a time or remove duplicate text layers.`;export{Iv as $,dH as A,il as B,Fw as C,s5 as D,iH as E,Ve as F,ba as G,Ps as H,WE as I,Ll as J,F4 as K,RE as L,G1 as M,m8 as N,yE as O,Gb as P,v8 as Q,Fa as R,Z5 as S,ry as T,Pb as U,cE as V,Lb as W,mb as X,j9 as Y,L9 as Z,EP as _,Yh as a,Eg as a$,X9 as a0,$r as a1,c4 as a2,Q9 as a3,y4 as a4,i4 as a5,Ch as a6,I9 as a7,J9 as a8,Z9 as a9,v7 as aA,Je as aB,A7 as aC,C7 as aD,An as aE,zs as aF,me as aG,us as aH,G5 as aI,an as aJ,E7 as aK,Kn as aL,W7 as aM,R7 as aN,L7 as aO,GM as aP,_7 as aQ,Mi as aR,OM as aS,SM as aT,b0 as aU,$l as aV,oM as aW,sM as aX,RM as aY,UM as aZ,jM as a_,tE as aa,eE as ab,K2 as ac,Tb as ad,Bd as ae,Mf as af,Nv as ag,Ld as ah,pf as ai,Rh as aj,Ab as ak,Ml as al,h4 as am,M4 as an,p4 as ao,V7 as ap,uM as aq,Vs as ar,G7 as as,N7 as at,V as au,v5 as av,Gl as aw,Nl as ax,r0 as ay,T7 as az,$x as b,LP as b$,X7 as b0,Z7 as b1,Q7 as b2,_x as b3,I7 as b4,q7 as b5,bs as b6,g0 as b7,kM as b8,Ul as b9,vL as bA,TL as bB,SL as bC,$h as bD,DL as bE,Dz as bF,HP as bG,OP as bH,Dm as bI,ah as bJ,$z as bK,Xz as bL,Iz as bM,Vz as bN,_z as bO,jz as bP,Oz as bQ,qz as bR,IP as bS,NP as bT,Nz as bU,Gz as bV,Uz as bW,Kz as bX,bb as bY,Ss as bZ,Ls as b_,bM as ba,y0 as bb,m0 as bc,U7 as bd,v4 as be,g3 as bf,a7 as bg,uE as bh,Af as bi,B4 as bj,pE as bk,gE as bl,bE as bm,lm as bn,Kh as bo,I1 as bp,D1 as bq,vs as br,QT as bs,YT as bt,n8 as bu,PE as bv,c1 as bw,ve as bx,OL as by,hR as bz,i7 as c,kB as c$,uB as c0,UC as c1,jC as c2,ZW as c3,$y as c4,HC as c5,nL as c6,Qn as c7,DC as c8,IC as c9,BB as cA,jB as cB,Xa as cC,HB as cD,Kk as cE,EB as cF,Zk as cG,P2 as cH,Hk as cI,TB as cJ,nR as cK,vB as cL,xc as cM,Uk as cN,sS as cO,PB as cP,CB as cQ,RB as cR,iS as cS,LB as cT,SB as cU,MB as cV,Te as cW,jk as cX,V0 as cY,xl as cZ,lf as c_,aL as ca,Fn as cb,FC as cc,on as cd,JW as ce,cL as cf,ko as cg,Lz as ch,Wz as ci,Hz as cj,Qz as ck,tk as cl,G0 as cm,Bo as cn,uL as co,b7 as cp,Ef as cq,Ts as cr,ky as cs,Sy as ct,oA as cu,Pk as cv,pB as cw,A2 as cx,VB as cy,C2 as cz,n7 as d,ws as d$,wB as d0,Gk as d1,Dk as d2,q9 as d3,vv as d4,Zn as d5,md as d6,P9 as d7,Mv as d8,nv as d9,QE as dA,cA as dB,Lh as dC,wy as dD,$E as dE,Df as dF,Ih as dG,Z8 as dH,pW as dI,po as dJ,UE as dK,uW as dL,FE as dM,XE as dN,KE as dO,VE as dP,My as dQ,mW as dR,_E as dS,yW as dT,gW as dU,bW as dV,zx as dW,fW as dX,Py as dY,tC as dZ,WW as d_,Sv as da,wd as db,z9 as dc,ub as dd,lb as de,kd as df,hC as dg,jW as dh,KW as di,UW as dj,sl as dk,qh as dl,Ds as dm,So as dn,H9 as dp,yb as dq,pl as dr,A3 as ds,Is as dt,Z2 as du,S9 as dv,tb as dw,dv as dx,fv as dy,YE as dz,r5 as e,sW as e$,gB as e0,yl as e1,K9 as e2,wb as e3,ur as e4,U9 as e5,ok as e6,xB as e7,oC as e8,xL as e9,wz as eA,kz as eB,Sz as eC,pz as eD,Mz as eE,gz as eF,IB as eG,fS as eH,OB as eI,gS as eJ,qB as eK,DB as eL,GB as eM,LW as eN,Gw as eO,wm as eP,tx as eQ,rk as eR,jy as eS,nH as eT,oH as eU,fH as eV,wW as eW,ZE as eX,oP as eY,Y9 as eZ,tw as e_,It as ea,Mr as eb,et as ec,uo as ed,Zt as ee,T4 as ef,nE as eg,A4 as eh,Wb as ei,ls as ej,pL as ek,Az as el,Zg as em,Yg as en,mz as eo,sz as ep,lz as eq,Mo as er,ho as es,rz as et,dz as eu,bz as ev,yz as ew,uz as ex,vw as ey,vz as ez,xm as f,s9 as f$,lB as f0,Kv as f1,CC as f2,oL as f3,NB as f4,iz as f5,tL as f6,vl as f7,ye as f8,$s as f9,iE as fA,NA as fB,nW as fC,hB as fD,rL as fE,sL as fF,rB as fG,c9 as fH,Vh as fI,dg as fJ,XP as fK,a0 as fL,VP as fM,N2 as fN,GP as fO,jP as fP,Nm as fQ,$P as fR,YP as fS,Ra as fT,c5 as fU,a5 as fV,Gx as fW,t7 as fX,c7 as fY,e7 as fZ,dl as f_,Us as fa,Tl as fb,Jy as fc,u7 as fd,FW as fe,B7 as ff,k7 as fg,oB as fh,g7 as fi,HW as fj,DW as fk,Yr as fl,eB as fm,rf as fn,vk as fo,Yn as fp,vy as fq,i2 as fr,gi as fs,rW as ft,pc as fu,If as fv,Al as fw,Xs as fx,_s as fy,g5 as fz,MM as g,ML as g$,QS as g0,ai as g1,gm as g2,i9 as g3,US as g4,O2 as g5,kS as g6,fl as g7,YB as g8,QB as g9,h9 as gA,JB as gB,$B as gC,pw as gD,nw as gE,mo as gF,v0 as gG,xz as gH,cl as gI,cf as gJ,$g as gK,Hr as gL,yo as gM,ow as gN,_g as gO,fz as gP,R0 as gQ,li as gR,nk as gS,Ms as gT,Cl as gU,$e as gV,Of as gW,eW as gX,am as gY,jL as gZ,Qr as g_,ed as ga,sd as gb,x9 as gc,G2 as gd,l9 as ge,mL as gf,cz as gg,ez as gh,nz as gi,MH as gj,az as gk,YL as gl,ZL as gm,QL as gn,ld as go,d9 as gp,f9 as gq,n3 as gr,UB as gs,c3 as gt,_B as gu,FP as gv,FB as gw,XB as gx,KB as gy,UP as gz,zo as h,zR as h$,KL as h0,vR as h1,O7 as h2,xA as h3,MC as h4,_W as h5,Kf as h6,Vr as h7,XW as h8,kC as h9,rP as hA,Hl as hB,CP as hC,_f as hD,Xf as hE,R9 as hF,u9 as hG,p9 as hH,df as hI,Yy as hJ,Qy as hK,Zy as hL,Ob as hM,wH as hN,kH as hO,ti as hP,d0 as hQ,km as hR,Jz as hS,iW as hT,ih as hU,Zz as hV,sB as hW,cW as hX,sk as hY,K7 as hZ,aB as h_,qr as ha,aH as hb,Ur as hc,S4 as hd,Dv as he,_9 as hf,jr as hg,vf as hh,Ib as hi,vh as hj,Pv as hk,Mb as hl,di as hm,pi as hn,Bb as ho,V9 as hp,Uv as hq,Nd as hr,Eb as hs,Cb as ht,F9 as hu,Rs as hv,xy as hw,Za as hx,p5 as hy,E9 as hz,iM as i,W4 as i$,XL as i0,gL as i1,tB as i2,dW as i3,bA as i4,aW as i5,D9 as i6,Eo as i7,Qg as i8,Jx as i9,T9 as iA,B3 as iB,cb as iC,cB as iD,Rz as iE,wo as iF,NW as iG,AB as iH,dB as iI,zH as iJ,al as iK,Es as iL,RH as iM,P8 as iN,Nf as iO,xs as iP,C5 as iQ,m7 as iR,w7 as iS,M7 as iT,R5 as iU,y7 as iV,j7 as iW,ii as iX,$7 as iY,dE as iZ,E4 as i_,Bz as ia,zz as ib,Po as ic,pH as id,Ao as ie,To as ig,_L as ih,tH as ii,Pm as ij,$1 as ik,XC as il,PH as im,sg as io,kk as ip,fB as iq,VL as ir,JL as is,cH as it,eH as iu,q2 as iv,N9 as iw,Xn as ix,C9 as iy,eb as iz,Jh as j,jm as j$,L4 as j0,Rn as j1,AC as j2,WP as j3,bL as j4,eR as j5,rr as j6,Qt as j7,lL as j8,yi as j9,uP as jA,SP as jB,ng as jC,gP as jD,vP as jE,LE as jF,wE as jG,kE as jH,aT as jI,oT as jJ,iT as jK,VC as jL,Cy as jM,s2 as jN,ph as jO,_2 as jP,U2 as jQ,C4 as jR,oW as jS,JP as jT,KP as jU,Fm as jV,Km as jW,ds as jX,a9 as jY,Ym as jZ,Zf as j_,BA as ja,ZT as jb,f8 as jc,OA as jd,qA as je,Ty as jf,h8 as jg,Ti as jh,za as ji,IE as jj,s1 as jk,Cx as jl,N8 as jm,l1 as jn,CM as jo,hS as jp,Or as jq,Ac as jr,EE as js,be as jt,AH as ju,vH as jv,SH as jw,TH as jx,Z1 as jy,AP as jz,Am as k,pM as k$,hf as k0,I2 as k1,QP as k2,_P as k3,zS as k4,ZP as k5,Vm as k6,n9 as k7,o9 as k8,Gm as k9,Ye as kA,DP as kB,zm as kC,ck as kD,B9 as kE,v9 as kF,z3 as kG,$W as kH,gH as kI,bH as kJ,yH as kK,mH as kL,GW as kM,iC as kN,rC as kO,qW as kP,IW as kQ,OW as kR,UR as kS,hm as kT,Wr as kU,Ar as kV,ik as kW,Qx as kX,hz as kY,Tz as kZ,D7 as k_,hg as ka,Jn as kb,Xk as kc,Qk as kd,Dh as ke,IL as kf,$C as kg,SW as kh,Ff as ki,PP as kj,Mm as kk,UL as kl,ui as km,nP as kn,hH as ko,xH as kp,fE as kq,mn as kr,s7 as ks,t5 as kt,ug as ku,gg as kv,e5 as kw,Cc as kx,qP as ky,Lm as kz,nf as l,SE as l$,SC as l0,vC as l1,lW as l2,iB as l3,d2 as l4,iL as l5,Pz as l6,k9 as l7,pv as l8,S3 as l9,YM as lA,b9 as lB,y9 as lC,g9 as lD,BR as lE,E1 as lF,FL as lG,eL as lH,WC as lI,$L as lJ,x7 as lK,h7 as lL,p7 as lM,f7 as lN,d7 as lO,l7 as lP,KC as lQ,r9 as lR,BE as lS,JE as lT,ME as lU,CE as lV,AE as lW,vE as lX,X4 as lY,mE as lZ,TE as l_,uv as la,A9 as lb,ml as lc,oz as ld,oE as le,hL as lf,uH as lg,bo as lh,Cz as li,EA as lj,J7 as lk,tz as ll,Y7 as lm,Ez as ln,Yz as lo,kg as lp,fL as lq,S7 as lr,m9 as ls,tW as lt,z7 as lu,P7 as lv,G9 as lw,m4 as lx,dL as ly,VM as lz,Yo as m,yL as m$,fi as m0,pg as m1,e9 as m2,xg as m3,t9 as m4,ZB as m5,R4 as m6,sE as m7,lE as m8,xE as m9,QW as mA,YW as mB,$9 as mC,Gs as mD,KA as mE,U8 as mF,DE as mG,NE as mH,Y8 as mI,_8 as mJ,eA as mK,Rl as mL,PW as mM,kW as mN,TW as mO,AW as mP,BW as mQ,EW as mR,MW as mS,zW as mT,vW as mU,CW as mV,RW as mW,C3 as mX,H7 as mY,Uw as mZ,iP as m_,rE as ma,vc as mb,hE as mc,lH as md,rH as me,sH as mf,l8 as mg,NL as mh,CL as mi,GL as mj,wL as mk,RL as ml,HL as mm,AL as mn,WL as mo,LL as mp,zL as mq,PL as mr,zE as ms,kL as mt,BL as mu,EL as mv,qL as mw,_0 as mx,jR as my,qm as mz,o7 as n,nB as n0,F7 as n1,zB as n2,WB as n3,mB as n4,O9 as n5,W9 as n6,yB as n7,bB as n8,VW as n9,Fz as na,nh as nb,xW as nc,hW as nd,M9 as ne,pr as nf,w9 as ng,Bv as nh,qE as ni,GE as nj,jE as nk,OE as nl,HE as nm,aE as nn,CH as no,jx as o,kr as p,h5 as q,r7 as r,Pa as s,J as t,Qd as u,TM as v,Vd as w,Yd as x,N4 as y,Ir as z};
@@ -0,0 +1 @@
1
+ import{b$ as P,eO as et,eP as at,lQ as ot,eT as B,lR as rt,ea as nt,eU as it,eQ as H,ec as V,eS as st,eX as U,eW as Y,eY as X,eV as q}from"./titleFrameBudget-3MFHWIT6.js";import{l as lt,d as ht}from"./titleArt-CcTdJuOC.js";import{i as R,j as dt,s as j,d as T,l as ct,k,f as mt,e as G,a as ft,p as ut,t as pt,m as z}from"./lottieLayer-CfUPParC.js";import{wantsFrame as J,SKIPPED_FRAME as wt}from"./frameSink-Dj71jCRb.js";import{t as N}from"./api-BsKbf3l3.js";import"./textAnimators-Cihw35O8.js";import"./rigTrack-Bx9QHlFv.js";const gt=a=>st(a.title)||!!a.shape||!!a.motion||!!a.lottie||!!a.card||!!a.geo,D=4,Q=192*1024*1024,g=new Map;let A=0;function xt(a,s){if(a.geo||a.shape&&R(a.shape)||a.pin?.scene||a.space)return null;const{start:i,track:h,...n}=a;return JSON.stringify([s,n])}function Et(a,s){const i=s.reduce((h,n)=>h+n.length,0);if(!(i>Q/4)){g.delete(a),g.set(a,{frames:s,bytes:i}),A+=i;for(const[h,n]of g){if(A<=Q)break;g.delete(h),A-=n.bytes}}}function At(){g.clear(),A=0}const Mt=a=>new Promise((s,i)=>a.toBlob(h=>{if(!h)return i(Error("Cannot encode title frame"));const n=new FileReader;n.onload=()=>s(String(n.result).slice(String(n.result).indexOf(",")+1)),n.onerror=()=>i(n.error),n.readAsDataURL(h)},"image/webp",.9));async function Pt(a,s,i,h,n){const{fps:o,width:m,height:S}=P(s),f=P({...s,resolution:"720p"}),y=a.some(t=>t.shape&&R(t.shape))?et(at(a)):null,$=!!i.wants;for(const t of a.filter(u=>gt(u)&&!u.warped)){if(!J(i,"titleFrames",t.id))continue;const u=e=>J(i,"titleFrames",t.id,e),d=xt(t,s),r=d?g.get(d):void 0;if(r){g.delete(d),g.set(d,r);for(const e of r.frames){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");await i.push("titleFrames",t.id,e)}continue}const x=[],E=t.title,M=ot(t)?1:Math.ceil(t.duration*o);if(M>1&&Math.ceil(t.duration*o)>3600)throw Error("Mỗi tiêu đề động / Motion tối đa 2 phút khi xuất MP4.");E&&!t.shape&&!t.motion&&!t.lottie&&!t.card&&!t.geo&&await lt(E);const b=t.card?await dt(t.card).catch(e=>{throw Error(N("Thẻ HTML “{0}”: {1}",[t.label,e.message]))}):null,[p,w]=b?[b.width,b.height]:t.geo?[f.width,f.height]:t.lottie?[B(t.lottie).W,B(t.lottie).H]:t.motion?[f.width,f.height]:t.shape?[j(t.shape).W,j(t.shape).H]:[1280,720],C=Object.assign(document.createElement("canvas"),{width:p,height:w}),F=C.getContext("2d");if(!F)throw Error("Canvas unavailable");let I="",O=null;const L=(e,l)=>z({layer:`export:${e.id}`,motion:e.motion,t:q(e,l/o),width:p,height:w,duration:X(e),fps:o,surface:e.pin?.scene?Y(e,a,e.start+l/o,p,w):null,space:e.space?(H(a),U(e,a,e.start+l/o,p,w,n)):null}),c=[],W="\0same",_="\0skip",K=t.shape&&!t.motion&&!t.card&&!t.lottie&&!t.geo&&!R(t.shape)?rt(t.shape):null,Z=K==null?1/0:Math.max(K,...["trimStart","trimEnd"].flatMap(e=>nt(t,e).map(l=>l.time))),v=async()=>{const e=await c.shift();if(e===_){await i.push("titleFrames",t.id,wt);return}if(e===W||e===I){x.push("="),await i.push("titleFrames",t.id,"=");return}I=e,x.push(e),await i.push("titleFrames",t.id,e)};try{for(let e=0;e<M;e++){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");if(!u(e)){c.push(Promise.resolve(_)),c.length>=D&&await v();continue}if(!$&&e>0&&(e-1)/o>Z+1e-6){c.push(Promise.resolve(W)),c.length>=D&&await v();continue}if(F.clearRect(0,0,p,w),t.motion){let l;try{l=await(O??L(t,e)),O=e+1<M&&u(e+1)?L(t,e+1):null}catch(tt){throw O?.catch(()=>{}),T(`export:${t.id}`),Error(`Motion “${t.label}”: ${tt.message}`)}F.drawImage(l,0,0),l.close()}else if(t.lottie)try{await ct(`export:${t.id}`,t.url,{W:p,H:w},it(t,e/o),C)}catch(l){throw k(`export:${t.id}`),Error(`Lottie “${t.label}”: ${l.message}`)}else if(t.geo)try{await mt(`export:${t.id}`,t.geo,{W:p,H:w},e/o,C,{wait:2e4,duration:t.duration})}catch(l){throw G(`export:${t.id}`),Error(N("Bản đồ “{0}”: {1}",[t.label,l.message]))}else b?F.drawImage(b,0,0):t.shape?(y&&H(y),ft(F,ut(t,a,e/o,m,S),{start:V(t,"trimStart",e/o),end:V(t,"trimEnd",e/o),offset:pt(t.shape)},p,w,e/o)):ht(F,E,{time:e/o,duration:t.duration});c.push(Mt(C)),c.length>=D&&await v()}for(;c.length;)await v();d&&!$&&Et(d,x)}finally{for(const e of c)e.catch(()=>{})}t.motion&&T(`export:${t.id}`),t.lottie&&k(`export:${t.id}`),t.geo&&G(`export:${t.id}`)}}function Tt(a,s,i,h){const{fps:n}=P(i),{width:o,height:m}=P({...i,resolution:"720p"}),S=Math.ceil(a.duration*n)-1,f=Object.assign(document.createElement("canvas"),{width:o,height:m}),y=f.getContext("2d");if(!y)throw Error("Canvas unavailable");const $=r=>z({layer:`export:${a.id}`,motion:a.motion,t:q(a,r/n),width:o,height:m,duration:X(a),fps:n,surface:a.pin?.scene?Y(a,s,a.start+r/n,o,m):null,space:a.space?(H(s),U(a,s,a.start+r/n,o,m,h)):null});let t=null,u=-1;const d=r=>{r?.p.then(x=>x.close(),()=>{})};return{W:o,H:m,async frame(r){if(r=Math.max(0,Math.min(S,r)),r===u)return f;for(;t&&t.i<r;){const M=t;t=null,await M.p.then(b=>b.close(),()=>{})}const x=t&&t.i===r?t.p:$(r);t&&t.i!==r&&d(t),t=null;let E;try{E=await x}catch(M){throw T(`export:${a.id}`),Error(`Motion “${a.label}”: ${M.message}`)}return t=r<S?{i:r+1,p:$(r+1)}:null,y.clearRect(0,0,o,m),y.drawImage(E,0,0),E.close(),u=r,f},close(){d(t),t=null,T(`export:${a.id}`)}}}export{At as clearFrameCache,xt as frameCacheKey,Tt as liveMotion,Pt as renderTitleFrames};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GLTFExporter-BuGYM-Ik.js","assets/three.module-Bx43vjkH.js"])))=>i.map(i=>d[i]);
2
- import{dZ as P}from"./remote-DXG553d8.js";import{_ as R}from"./titleFrameBudget-BjW--v_T.js";import{Vector3 as S,WebGLRenderer as O,NeutralToneMapping as D,SRGBColorSpace as B,Scene as F,Color as k,HemisphereLight as G,DirectionalLight as C,PerspectiveCamera as $,Mesh as q,Group as _,BufferGeometry as U,BufferAttribute as x,InstancedMesh as W,Matrix4 as Z,MeshPhysicalMaterial as V,DoubleSide as Y,FrontSide as X}from"./three.module-Bx43vjkH.js";const f=Object.freeze({code:24e3,triangles:3e5,instanceTriangles:3e6,meshes:64,instances:2e4,params:12,timeoutMs:8e3,size:500}),J=String.raw`
2
+ import{dL as P}from"./remote-sTZauTqM.js";import{_ as R}from"./titleFrameBudget-3MFHWIT6.js";import{Vector3 as S,WebGLRenderer as O,NeutralToneMapping as D,SRGBColorSpace as B,Scene as F,Color as k,HemisphereLight as G,DirectionalLight as C,PerspectiveCamera as $,Mesh as q,Group as _,BufferGeometry as U,BufferAttribute as x,InstancedMesh as W,Matrix4 as Z,MeshPhysicalMaterial as V,DoubleSide as Y,FrontSide as X}from"./three.module-Bx43vjkH.js";const f=Object.freeze({code:24e3,triangles:3e5,instanceTriangles:3e6,meshes:64,instances:2e4,params:12,timeoutMs:8e3,size:500}),J=String.raw`
3
3
  const __codeModel = (() => {
4
4
  const LIM = ${JSON.stringify(f)}
5
5
  let seed = 1, noiseSeed = 1
@@ -0,0 +1 @@
1
+ import{b as N,c as D,a as _,d as E}from"./shotFxAgent-CzHfe75S.js";import{j9 as P,ja as B,gD as h,eC as C,eh as A,dA as L,dy as U}from"./remote-sTZauTqM.js";import"./api-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const j=(s,n)=>{const o=h(s);return{anchor:n?(c,d,x)=>n.partPointAt(o,x,c.id,d):void 0,items:s.items,shot:o,at:(c,d)=>{const x=s.items.find(b=>b.id===c.id),k=U(x,o,o.duration?Math.max(0,Math.min(1,d/o.duration)):0);return{position:k.position,rotation:k.rotation}},uid:()=>crypto.randomUUID(),restPose:{...L.Đứng}}},w=(s,n,o)=>({...s,shots:s.shots.map(c=>c.id===s.activeShot?{...c,fxTiming:{...c.fxTiming,[n]:o}}:c)}),v=(s,n)=>{const o=A(s,h(n));return{name:s.name,id:s.id,effect:s.fx.cat??s.fx.preset,preset:s.fx.preset,start_s:o.start,end_s:+(o.start+o.duration).toFixed(2),...s.fx.attach?{attach:s.fx.attach}:{},...s.fx.path?{path:s.fx.path}:{}}};function Y(s,n,o){const c=o.engine();c&&c.sync(o.getStage(),null);const d=o.getStage();if(s==="add_effect"){const t=N(n,j(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;if(e.fx&&e.fx.preset in P&&o.userText!=null&&!B(o.userText))return{ok:!1,error:"blood effects are only used when the user asks for blood (máu / blood) in their message — leave it out"};o.setStage(i=>w({...i,items:[...i.items,e]},e.id,t.timing));const f=h(o.getStage());return{ok:!0,...v(e,o.getStage()),...t.timing.start+t.timing.duration>f.duration+.01?{note:"the effect runs past the end of the shot; shorten it or extend the shot with set_duration"}:{},hint:"render_preview / preview_motion at the effect time to check it is readable"}}if(s==="add_destruction"){const t=D(n,j(d,c));if(!t.ok)return{ok:!1,error:t.error};const e=t.item;o.setStage(i=>{const a=w({...i,items:[...i.items,e]},e.id,t.timing);return{...a,shots:a.shots.map(p=>p.id===a.activeShot?{...p,objectKeys:{...p.objectKeys,[e.id]:t.keys}}:p)}});const f=d.items.filter(i=>i.fx?.preset===e.fx.preset&&i.fx?.target?.to===e.fx?.target?.to&&i.id!==e.id).map(i=>i.name);return{ok:!0,...v(e,o.getStage()),target:d.items.find(i=>i.id===e.fx?.target?.to)?.name,recipe:e.fx.params.recipe,...t.keys.length?{sphere_path:t.keys.map(i=>({at_s:+(i.time*h(d).duration).toFixed(2),position:i.position}))}:{mode:e.fx.params.mode},...f.length?{combines_with:f}:{},hint:"render_preview after the sweep / collapse time to see the destruction; remove_effect removes it"}}if(s==="edit_destruction"){const t=_(d.items.filter(m=>m.kind==="fx"&&m.fx?.preset===C),String(n.name));if(!t?.fx)return{ok:!1,error:`no Mix FX named '${String(n.name)}' (add_destruction makes one; scene_summary lists effects)`};const e=h(d),f=e.duration||1,i=[];let a=d;const p=m=>m.map((r,u)=>({id:`${t.id}-k${u}-${Math.round(r.time*1e6)}`,time:r.time,position:r.position,rotation:[...t.rotation],scale:[...t.scale]})),T=m=>{a={...a,shots:a.shots.map(r=>r.id===a.activeShot?{...r,objectKeys:{...r.objectKeys,[t.id]:m}}:r)}};if(n.target!=null){const m=d.items.find(r=>r.name.toLowerCase()===String(n.target).toLowerCase()&&r.kind!=="fx");if(!m)return{ok:!1,error:`no object '${String(n.target)}' to break`};a={...a,items:a.items.map(r=>r.id===t.id?{...r,fx:{...r.fx,target:{to:m.id,part:"center"}}}:r)},i.push(`target ${m.name}`)}if(Array.isArray(n.points)){if(n.points.length<2||n.points.length>24)return{ok:!1,error:"points: 2 to 24 path points"};const m=[];for(const r of n.points){const u=Number(r.time_s),l=r.position;if(!Number.isFinite(u)||u<0||u>f+1e-6)return{ok:!1,error:`time_s ${String(r.time_s)} is outside the shot (0–${f} s)`};if(!Array.isArray(l)||l.length!==3||!l.every(y=>Number.isFinite(Number(y))))return{ok:!1,error:"each point needs position [x, y, z]"};m.push({time:Math.min(1,u/f),position:l.map(Number)})}T(p(m.sort((r,u)=>r.time-u.time))),i.push(`path of ${m.length} points`)}else if(n.sweep===!0){const m=a.items.find(M=>M.id===t.id).fx,r=m.target?.to?c?.objectBounds()[m.target.to]:null;if(!r)return{ok:!1,error:"sweep measures the target: it needs the 3D view (a scene open in the composer or the render machine) and a target"};const u=m.params,l=Number(u.radius)*t.scale[0]+Number(u.falloff)+.3,y=(r.min[1]+r.max[1])/2,K=(r.min[2]+r.max[2])/2,S=A(t,e),O=Math.min(1,S.start/f),F=Math.min(1,(S.start+S.duration)/f);T(p([{time:O,position:[r.min[0]-l,y,K]},{time:F,position:[r.max[0]+l,y,K]}])),i.push("sweep through the target")}if(!i.length)return{ok:!1,error:"give points, sweep or target"};const $=a;return o.setStage(()=>$),{ok:!0,name:t.name,changed:i,path_s:(h($).objectKeys?.[t.id]||[]).map(m=>+(m.time*f).toFixed(3))}}if(s==="update_effect"){const t=_(d.items.filter(a=>a.kind==="fx"),String(n.name));if(!t?.fx)return{ok:!1,error:`no effect named '${String(n.name)}'; use remove_effect / update_effect with the name returned by add_effect (see scene_summary effects)`};const e=h(d),f=A(t,e),i=E(t,n,{...j(d,c),timing:f});return i.ok?(o.setStage(a=>w({...a,items:a.items.map(p=>p.id===t.id?{...p,...i.itemPatch,fx:i.fx}:p)},t.id,{start:i.timing.start,duration:i.timing.duration,...i.timing.loop?{loop:!0}:{}})),{ok:!0,...v(o.getStage().items.find(a=>a.id===t.id),o.getStage())}):{ok:!1,error:i.error}}const x=Array.isArray(n.names)?n.names.map(String):n.name!=null?[String(n.name)]:[],k=[],b=[],g=new Set;for(const t of x){const e=_(d.items.filter(f=>f.kind==="fx"),t);e?(g.add(e.id),k.push(e.name)):b.push(t)}for(const t of d.items)t.trackAnchor&&g.has(t.trackAnchor.effect)&&g.add(t.id);return o.setStage(t=>({...t,items:t.items.filter(e=>!g.has(e.id)),shots:t.shots.map(e=>({...e,...e.fxTiming?{fxTiming:Object.fromEntries(Object.entries(e.fxTiming).filter(([f])=>!g.has(f)))}:{},...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([f])=>!g.has(f)))}:{}}))})),{ok:!b.length,removed:k,missing:b}}export{Y as runFxTool};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMaskStore-pxpRt5Cj.js","assets/titleFrameBudget-3MFHWIT6.js","assets/api-BsKbf3l3.js"])))=>i.map(i=>d[i]);
2
+ import{_ as L}from"./titleFrameBudget-3MFHWIT6.js";import{gD as O,iR as D,fh as C,fU as P,dL as T,jb as U,jc as E,jd as B,fL as $,fS as j,fT as I}from"./remote-sTZauTqM.js";import"./api-BsKbf3l3.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const F=["twos","snap","anticipation","exaggerate","squash","smear"],A=t=>Array.isArray(t)&&t.length===3&&t.every(p=>Number.isFinite(Number(p)))?t.map(Number):null,K=t=>t==="left"?"L":t==="both"?"both":"R",w=t=>Math.round(t*1e3)/1e3;function Z(t,p){const c=p.getStage(),d=O(c),a=t.on!==!1&&t.on!=="false",s={on:a};if(t.amount!=null){const r=Number(t.amount);if(!Number.isFinite(r))return{ok:!1,error:"amount must be a number 0–1"};s.amount=Math.max(0,Math.min(1,r))}for(const r of F)typeof t[r]=="boolean"&&(s[r]=t[r]);if(t.shot_default){const r=j({...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=>D(c,r))}catch(r){return{ok:!1,error:r.message}}const k=l.filter(r=>!["person","prop","box","sphere","cylinder","model"].includes(r.kind));if(k.length)return{ok:!1,error:`the cartoon style works on people, props and simple objects, not on ${k.map(r=>`'${r.name}' (${r.kind})`).join(", ")}`};const u={};return p.setStage(r=>({...r,items:r.items.map(m=>{if(!l.some(h=>h.id===m.id))return m;const f=j({...j(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=D(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=T(c,{kind:"prop",name:String(t.name||"Bóng rổ"),prop:{kind:"ball"},color:"#d8641c",position:u?[u[0],Math.max(r,u[1]),u[2]]:e})}t.toon!==!1&&!l.toon&&(l={...l,toon:{on:!0,amount:Math.max(0,Math.min(1,Number(t.amount??.6)))}}),t.bounciness!=null&&(l={...l,ball:{restitution:Math.max(.3,Math.min(.95,Number(t.bounciness)||P.restitution))}});const m=K(t.hand),f=(d.ball?.[l.id]||[]).filter(e=>e.t<s-1e-6),h=[],y=A(t.velocity);let N=A(t.target),b=null;if(a==="throw"&&!y&&!N&&t.target_person==null){if(b=U((await E(p,c)).colliders,o?.position??l.position),!b&&t.target==="hoop")return{ok:!1,error:"no hoop in the scene: build_set a court with parts named rim / vành rổ and backboard / bảng rổ, or give target [x,y,z]"};b&&(N=[...b.rim])}let v;if(t.target_person!=null)try{v=D(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"?B(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 L(()=>import("./rotoMaskStore-pxpRt5Cj.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=>D(c,i))}catch(i){return{ok:!1,error:i.message}}const e=s.map(i=>[i,a.dropUnavailable(i)]).filter(([,i])=>i);if(e.length)return{ok:!1,error:`cannot drop ${e.map(([i])=>`'${i.name}' (${i.kind}${i.locked?", locked":i.hold?", held":""})`).join(", ")}: physics_drop moves objects and props, not people, effects, sets or the floor`}}if(s=s.filter(n=>!(n.kind==="prop"&&n.prop?.kind==="ball"&&d.ball?.[n.id]?.length)),!s.length)return{ok:!1,error:"nothing to drop (a ball with add_ball motion keeps its own motion)"};if(s.length>a.MAX_PHYSICS_BODIES)return{ok:!1,error:`at most ${a.MAX_PHYSICS_BODIES} objects per drop`};const o=Math.max(0,Math.min(d.duration,Number(t.time??0)||0)),l=d.duration-o;if(l<a.DROP_SECONDS.min)return{ok:!1,error:`time ${w(o)} s is too close to the end of the shot (${d.duration} s)`};const k=Math.min(l,Math.max(1,Math.min(a.DROP_SECONDS.max,Number(t.duration)||a.DROP_SECONDS.default))),u=o/d.duration,r=a.DROP_MODES.includes(t.mode)?t.mode:"above",m=t.bounciness,f=typeof m=="number"||m==="bouncy"||m==="heavy"?m:"normal",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};
@@ -0,0 +1 @@
1
+ import{b as w,gD as k,j7 as v,dy as S}from"./remote-sTZauTqM.js";import{a as $}from"./shotFxAgent-CzHfe75S.js";import{a as F,V as y,b as N}from"./vfxTrack-CqiQDEYm.js";import{Vector3 as _}from"./three.module-Bx43vjkH.js";import"./api-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const A=4,C=1.25;function M(t,c,s){return t.updateMatrixWorld(),new _(c*2-1,1-s*2,.5).unproject(t).sub(t.position).normalize()}function T(t,c,s){const i=k(t),n=Math.max(1e-6,i.duration),f=t.items.find(r=>r.kind==="person"&&!r.hidden);return c.points.map(([r,u,h])=>{const m=Math.max(0,Math.min(1,r/n)),d=v(i,m),a=M(d,u,h);let p=s??NaN;if(!Number.isFinite(p)&&f){const l=S(f,i,m);p=new _(l.position[0],l.position[1]+C*Math.max(.3,l.scale[1]),l.position[2]).sub(d.position).dot(a)}(!Number.isFinite(p)||p<.3)&&(p=A);const b=d.position.clone().addScaledVector(a,p);return{t:m,d:p,position:[b.x,b.y,b.z].map(l=>Math.round(l*1e4)/1e4)}})}function K(t,c,s){const i=k(c).duration;try{if(t.track!=null)return F(t.track,i);const n=String(t.source??"");if(!y.includes(n))return`give track {fps, points} or source ${y.join(" / ")}`;const f=c.plate?.timelineClipId,r=f?s.timelineClip?.(f):void 0;return r?N(r,n,{side:t.side==="left"?"left":"right",point:typeof t.point=="string"?t.point:"palm",...typeof t.object=="string"?{object:t.object}:{},to:i}):"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(n){return n.message}}function L(t,c){const s=c.getStage();if(!s.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 i=$(s.items.filter(o=>o.kind==="fx"),String(t.name??""));if(!i?.fx)return{ok:!1,error:`no effect named '${String(t.name)}' (scene_summary lists the effects)`};const n=s.items.find(o=>o.trackAnchor?.effect===i.id);if(t.stop===!0)return n?(c.setStage(o=>({...o,items:o.items.filter(e=>e.id!==n.id).map(e=>e.id===i.id?{...e,fx:{...e.fx,...e.fx.attach?.to===n.id?{attach:void 0}:{},...e.fx.target?.to===n.id?{target:void 0}:{}}}:e),shots:o.shots.map(e=>({...e,...e.objectKeys?{objectKeys:Object.fromEntries(Object.entries(e.objectKeys).filter(([j])=>j!==n.id))}:{}}))})),{ok:!0,name:i.name,stopped:!0}):{ok:!1,error:`${i.name} follows no track`};const f=K(t,s,c);if(typeof f=="string")return{ok:!1,error:f};const r=t.depth_m==null?void 0:Number(t.depth_m);if(r!==void 0&&!(r>=.3&&r<=200))return{ok:!1,error:"depth_m must be 0.3–200 (metres from the camera)"};const u=t.offset==null?void 0:Array.isArray(t.offset)&&t.offset.length===3&&t.offset.every(o=>Number.isFinite(Number(o))&&Math.abs(Number(o))<=20)?t.offset.map(Number):null;if(u===null)return{ok:!1,error:"offset must be [x, y, z] metres (±20)"};const h=t.role==="target"?"target":"attach",m=T(s,f,r),d=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=n?{...n,trackAnchor:{effect:i.id,source:d}}:{...w("sphere",s.items.length),name:`${i.name} · điểm bám`.slice(0,60),color:"#ffffff",trackAnchor:{effect:i.id,source:d}};a.position=m[0].position,a.rotation=[0,0,0],a.scale=[1,1,1];const p=m.map((o,e)=>({id:`${a.id}-t${e}`,time:o.t,position:o.position,rotation:[0,0,0],scale:[1,1,1]})),b={...i.fx,...h==="attach"?{attach:{to:a.id,follow:"position",...u?{offset:u}:{}}}:{target:{to:a.id,part:"center"}}};c.setStage(o=>({...o,items:[...o.items.filter(e=>e.id!==a.id).map(e=>e.id===i.id?{...e,fx:b}:e),a],shots:o.shots.map(e=>e.id===o.activeShot?{...e,objectKeys:{...e.objectKeys,[a.id]:p}}:e)}));const l=m.map(o=>o.d).sort((o,e)=>o-e),x=k(s).duration;return{ok:!0,name:i.name,anchor:a.name,source:d,role:h,samples:m.length,from_s:+f.points[0][0].toFixed(2),to_s:+f.points.at(-1)[0].toFixed(2),depth_m:+l[l.length>>1].toFixed(2),note:`${i.name} now ${h==="attach"?"rides on":"aims at"} the tracked point (${m.length} keys over ${x.toFixed(1)} s, ${r?`${r} 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,T as trackWorldPoints};
@@ -0,0 +1 @@
1
+ import{t as f,bY as p,bZ as b,c as S,b_ as _,r as U}from"./api-BsKbf3l3.js";import{u as C}from"./store-BSSbvpzr.js";import{i as w}from"./textAnimators-Cihw35O8.js";import"./titleFrameBudget-3MFHWIT6.js";let e={fonts:[],loaded:!1,error:null};const l=new Set,c=t=>{e={...e,...t},l.forEach(o=>o())},E=t=>(l.add(t),()=>{l.delete(t)}),N=()=>U.useSyncExternalStore(E,()=>e),O=()=>e,x={ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2"},$=".ttf,.otf,.woff,.woff2,font/ttf,font/otf,font/woff,font/woff2",d=10,u=new Map;function h(t){if(!t.url||u.has(t.family)||typeof FontFace>"u")return;const o=new FontFace(t.family,`url(${JSON.stringify(t.url)})`,{weight:t.wght?`${t.wght[0]} ${t.wght[1]}`:"1 1000",style:"normal",display:"block"});document.fonts.add(o),u.set(t.family,o)}function m(t){const o=u.get(t);o&&(document.fonts.delete(o),u.delete(t))}let a=null,g=!1;function y(t=!1){return g||(g=!0,C.subscribe((o,r)=>{const n=o.user?.uid??null,i=r.user?.uid??null;if(n!==i)if(n)y(!0);else{for(const s of e.fonts)m(s.family);a=Promise.resolve(),c({fonts:[],loaded:!0,error:null})}})),a&&!t||(a=p().then(o=>{const r=(Array.isArray(o?.fonts)?o.fonts:[]).filter(n=>n&&w(n.family)&&typeof n.name=="string");for(const n of e.fonts)r.some(i=>i.family===n.family)||m(n.family);for(const n of r)try{h(n)}catch{}c({fonts:r,loaded:!0,error:null})}).catch(o=>{c({loaded:!0,error:o?.message||"fonts"})})),a}const v=()=>y();function B(t){return t?w(t)?e.fonts.find(o=>o.family===t)?.name??f("Font đã xoá"):t:"Arial"}const P=t=>!!t&&w(t)&&e.loaded&&!e.error&&!e.fonts.some(o=>o.family===t);function z(t){const o=t?.code;return o==="bad_font"?f("File này không phải font dùng được (.ttf, .otf, .woff, .woff2 · không nhận bộ .ttc · tối đa {0} MB).",[String(d)]):o==="font_limit"?f("Tối đa 50 font — xoá bớt font không dùng rồi tải lên lại."):o==="font_rights"?f("Cần xác nhận bạn có quyền dùng font trước khi tải lên."):o==="font_not_found"?f("Không tìm thấy font."):t?.message||String(t)}async function L(t,o){const r=(t.name.match(/\.([a-z0-9]+)$/i)?.[1]||"").toLowerCase(),n=x[r];if(!n)throw new Error(f("Chỉ nhận file font .ttf, .otf, .woff hoặc .woff2"));if(t.size>d*1024*1024)throw new Error(f("Font tối đa {0} MB",[String(d)]));const i=await S(new File([t],t.name,{type:n}),o,"font"),s=await _({gcsUri:i.gcsUri,rightsConfirmed:!0});return h(s.font),c({fonts:[s.font,...e.fonts.filter(F=>F.family!==s.font.family)]}),s}async function Y(t){await b(t.id),m(t.family),c({fonts:e.fonts.filter(o=>o.id!==t.id)})}export{$ as FONT_ACCEPT,d as FONT_MAX_MB,x as FONT_TYPES,z as fontError,B as fontLabel,P as isMissingCustomFont,y as loadUserFonts,Y as removeUserFont,L as uploadUserFont,N as useUserFonts,v as userFontsReady,O as userFontsState};
@@ -1,4 +1,4 @@
1
- import{ii as D}from"./remote-DXG553d8.js";import{FramebufferTexture as F,ShaderMaterial as S,Color as w,WebGLRenderTarget as k,NoColorSpace as O,HalfFloatType as A,UnsignedByteType as I}from"./three.module-Bx43vjkH.js";import"./api-C5pOWyBM.js";import"./titleFrameBudget-BjW--v_T.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const U=new S({uniforms:{tC:{value:null},tB:{value:null},tW:{value:null},uOcc:{value:0}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:`uniform sampler2D tC, tB, tW; uniform float uOcc; varying vec2 vUv;
1
+ import{i2 as D}from"./remote-sTZauTqM.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-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const U=new S({uniforms:{tC:{value:null},tB:{value:null},tW:{value:null},uOcc:{value:0}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }",fragmentShader:`uniform sampler2D tC, tB, tW; uniform float uOcc; varying vec2 vUv;
2
2
  void main() {
3
3
  vec3 b = texture2D(tB, vUv).rgb, w = texture2D(tW, vUv).rgb;
4
4
  float occ = clamp(1.0 - max(max(w.r - b.r, w.g - b.g), w.b - b.b), 0.0, 1.0);
@@ -6,4 +6,4 @@ import{ii as D}from"./remote-DXG553d8.js";import{FramebufferTexture as F,ShaderM
6
6
  vec3 c = texture2D(tC, vUv).rgb;
7
7
  float a = max(occ, max(max(c.r, c.g), c.b));
8
8
  gl_FragColor = vec4(a > 0.002 ? clamp(c / a, 0.0, 1.0) : vec3(0.0), a);
9
- }`,depthTest:!1,depthWrite:!1}),n=(t,l,e)=>new k(t,l,{type:e?A:I,depthBuffer:e,samples:e?4:0,colorSpace:O});function Q(t,l,e){const v=n(l,e,!0),i=n(l,e,!0),f=n(l,e,!1),g=new F(l,e),y=new D(U),T=new Uint8Array(l*e*4),B=new w(0,0,0),M=new w(1,1,1),C=(o,u,s,r)=>{const a=o.background,c=t.getRenderTarget();try{o.background=B,t.setRenderTarget(s),t.clear(),t.render(o,u),o.background=M,t.setRenderTarget(r),t.clear(),t.render(o,u)}finally{o.background=a,t.setRenderTarget(c)}},R=(o,u,s,r)=>{const a=U.uniforms;a.tB.value=u.texture,a.tW.value=s.texture,a.tC.value=g,a.uOcc.value=o?1:0,t.setRenderTarget(r),y.render(t),t.setRenderTarget(null)};return{frame(o,u,s){t.setRenderTarget(null),t.copyFramebufferToTexture(g),C(o,u,v,i),R(!1,v,i,f),t.readRenderTargetPixels(f,0,0,l,e,T);const r=s.createImageData(l,e),a=l*4;for(let c=0;c<e;c++)r.data.set(T.subarray((e-1-c)*a,(e-c)*a),c*a);s.putImageData(r,0,0)},occlusion(o,u,s=8){const r=Math.max(16,Math.round(l/s)),a=Math.max(16,Math.round(e/s)),c=n(r,a,!0),b=n(r,a,!0),x=n(r,a,!1),d=new Uint8Array(r*a*4);try{C(o,u,c,b),R(!0,c,b,x),t.readRenderTargetPixels(x,0,0,r,a,d);const m=[];for(let p=0;p<d.length;p+=4)m.push(d[p]);return m.sort((p,W)=>p-W),m[Math.floor(m.length*.98)]/255}finally{c.dispose(),b.dispose(),x.dispose()}},dispose(){v.dispose(),i.dispose(),f.dispose(),g.dispose(),y.dispose()}}}export{Q as createVfxAlpha};
9
+ }`,depthTest:!1,depthWrite:!1}),n=(t,l,e)=>new k(t,l,{type:e?A:I,depthBuffer:e,samples:e?4:0,colorSpace:O});function j(t,l,e){const v=n(l,e,!0),i=n(l,e,!0),f=n(l,e,!1),g=new F(l,e),y=new D(U),T=new Uint8Array(l*e*4),B=new w(0,0,0),M=new w(1,1,1),C=(o,u,s,r)=>{const a=o.background,c=t.getRenderTarget();try{o.background=B,t.setRenderTarget(s),t.clear(),t.render(o,u),o.background=M,t.setRenderTarget(r),t.clear(),t.render(o,u)}finally{o.background=a,t.setRenderTarget(c)}},R=(o,u,s,r)=>{const a=U.uniforms;a.tB.value=u.texture,a.tW.value=s.texture,a.tC.value=g,a.uOcc.value=o?1:0,t.setRenderTarget(r),y.render(t),t.setRenderTarget(null)};return{frame(o,u,s){t.setRenderTarget(null),t.copyFramebufferToTexture(g),C(o,u,v,i),R(!1,v,i,f),t.readRenderTargetPixels(f,0,0,l,e,T);const r=s.createImageData(l,e),a=l*4;for(let c=0;c<e;c++)r.data.set(T.subarray((e-1-c)*a,(e-c)*a),c*a);s.putImageData(r,0,0)},occlusion(o,u,s=8){const r=Math.max(16,Math.round(l/s)),a=Math.max(16,Math.round(e/s)),c=n(r,a,!0),b=n(r,a,!0),x=n(r,a,!1),d=new Uint8Array(r*a*4);try{C(o,u,c,b),R(!0,c,b,x),t.readRenderTargetPixels(x,0,0,r,a,d);const m=[];for(let p=0;p<d.length;p+=4)m.push(d[p]);return m.sort((p,W)=>p-W),m[Math.floor(m.length*.98)]/255}finally{c.dispose(),b.dispose(),x.dispose()}},dispose(){v.dispose(),i.dispose(),f.dispose(),g.dispose(),y.dispose()}}}export{j as createVfxAlpha};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShotComposer-Dprx-Yi7.js","assets/titleFrameBudget-3MFHWIT6.js","assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/tool-BhIsq238.js","assets/timelineProps-tN2YsMYN.js","assets/thumb-Cs636sYt.js","assets/shotFxAgent-CzHfe75S.js","assets/cameraPresets-B234aNzE.js","assets/weaponDuel-B2wTffPC.js","assets/skin-BkaT2QuX.js","assets/views-BdWnG2xK.js","assets/motionBlur-uAm030t9.js","assets/library-BtBrCaFk.js","assets/ShotComposer-VixLbeMe.css"])))=>i.map(i=>d[i]);
2
+ import{_ as l}from"./titleFrameBudget-3MFHWIT6.js";import{R as h}from"./api-BsKbf3l3.js";import{di as w}from"./remote-sTZauTqM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.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-Dprx-Yi7.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{iI as E,iJ as A,iK as j,be as y,iL as S,b3 as M}from"./remote-DXG553d8.js";import{dB as T,hl as N,dE as F,dD as _,e1 as x}from"./titleFrameBudget-BjW--v_T.js";const w=Object.freeze(["hand","roto","planar","face","object"]),v=15,b=900,D=t=>t?.crop??{left:0,right:0,top:0,bottom:0},O=(t,n,a)=>{const o=D(t);return[o.left+n*(1-o.left-o.right),o.top+a*(1-o.top-o.bottom)]},m=t=>Math.round(t*1e4)/1e4;function $(t){if(!t||t.kind!=="video")return[];const n=[];t.hands?.data&&n.push({source:"hand",label:"Tay (tracking tay)",points:E,sides:["right","left"]}),t.roto?.points?.length&&n.push({source:"roto",label:"Điểm Roto"}),t.planar?.frames?.length&&!T(t.planar)&&n.push({source:"planar",label:"Mặt phẳng (planar)"}),t.face?.f?.length&&n.push({source:"face",label:"Khuôn mặt"});for(const a of t.objectTracks??[])a?.frames?.length&&n.push({source:"object",object:a.id,label:`Vật thể 3D ${a.name||a.id}`});return n}function C(t,n,{side:a="right",point:o="palm",object:i,from:l=0,to:c,fps:f=v}={}){if(!t||t.kind!=="video")throw Error("VFX tracks come from a filmed video clip");if(!w.includes(n))throw Error(`source must be ${w.join(" / ")}`);const p=Math.min(t.duration,c??t.duration),k=1/Math.max(1,Math.min(30,f)),d=[];let h;if(n==="hand"){if(!t.hands?.data)throw Error("this clip has no hand track yet (Timeline: Track hands, or edit_timeline handAttach once)");const e=A(t.hands),r=a==="left"?1:0,s=E.includes(o)?o:"palm";h=u=>{const g=j(e,y(t,u),r);return g?S(g,s):null}}else if(n==="roto"){if(!t.roto?.points?.length)throw Error("this clip has no Roto point track");h=e=>N(t,e)}else if(n==="planar"){if(!t.planar?.frames?.length)throw Error(T(t.planar)?"this planar track is stored apart from the clip: open the Timeline in the editor and run it there":"this clip has no planar track");h=e=>{if(!F(t.planar,e))return null;const r=_(t.planar,e);return O(t,r.reduce((s,u)=>s+u[0],0)/r.length,r.reduce((s,u)=>s+u[1],0)/r.length)}}else if(n==="face"){if(!t.face?.f?.length)throw Error("this clip has no face track");h=e=>{const r=x(t,e);return r&&r.score>0?[r.cx,r.cy]:null}}else{const e=(t.objectTracks??[]).find(r=>r?.id===i)??(i==null?t.objectTracks?.[0]:null);if(!e?.frames?.length)throw Error(i==null?"this clip has no 3D-tracked object (edit_timeline trackObject3D)":`no 3D-tracked object ${i} on this clip`);h=r=>{if(r<e.frames[0][0]-1e-6||r>e.frames.at(-1)[0]+1e-6)return null;const s=M(e,[0,0,0],r);return s?[s[0]/e.w,s[1]/e.h]:null}}for(let e=Math.max(0,l);e<=p+1e-6&&d.length<b;e+=k){const r=h(Math.min(e,p));r&&Number.isFinite(r[0])&&Number.isFinite(r[1])&&r[0]>-.5&&r[0]<1.5&&r[1]>-.5&&r[1]<1.5&&d.push([m(Math.min(e,p)),m(r[0]),m(r[1])])}if(d.length<2)throw Error(`the ${n} track does not see its target in this clip (fewer than 2 samples)`);return{fps:Math.round(1/k),points:d}}function K(t,n=600){if(!t||typeof t!="object"||!Array.isArray(t.points))throw Error("track must be {fps, points: [[t, u, v], …]}");if(t.points.length<2||t.points.length>b)throw Error(`track: 2 to ${b} points`);let a=-1/0;const o=t.points.map(i=>{if(!Array.isArray(i)||i.length<3||!i.slice(0,3).every(p=>Number.isFinite(Number(p))))throw Error("each track point is [t, u, v]");const[l,c,f]=i.map(Number);if(l<0||l>n+.001||l<=a)throw Error(`track times must rise within the shot (0–${n} s)`);if(c<-.5||c>1.5||f<-.5||f>1.5)throw Error("track u / v are fractions of the picture (−0.5..1.5)");return a=l,[l,c,f]});return{fps:Number.isFinite(Number(t.fps))?Number(t.fps):v,points:o}}export{w as V,K as a,C as b,$ as v};
1
+ import{it as E,iu as A,iv as j,bc as y,iw as S,b1 as M}from"./remote-sTZauTqM.js";import{dB as v,hl as N,dE as F,dD as _,e1 as x}from"./titleFrameBudget-3MFHWIT6.js";const w=Object.freeze(["hand","roto","planar","face","object"]),T=15,b=900,D=t=>t?.crop??{left:0,right:0,top:0,bottom:0},O=(t,n,a)=>{const o=D(t);return[o.left+n*(1-o.left-o.right),o.top+a*(1-o.top-o.bottom)]},m=t=>Math.round(t*1e4)/1e4;function $(t){if(!t||t.kind!=="video")return[];const n=[];t.hands?.data&&n.push({source:"hand",label:"Tay (tracking tay)",points:E,sides:["right","left"]}),t.roto?.points?.length&&n.push({source:"roto",label:"Điểm Roto"}),t.planar?.frames?.length&&!v(t.planar)&&n.push({source:"planar",label:"Mặt phẳng (planar)"}),t.face?.f?.length&&n.push({source:"face",label:"Khuôn mặt"});for(const a of t.objectTracks??[])a?.frames?.length&&n.push({source:"object",object:a.id,label:`Vật thể 3D ${a.name||a.id}`});return n}function C(t,n,{side:a="right",point:o="palm",object:i,from:l=0,to:c,fps:f=T}={}){if(!t||t.kind!=="video")throw Error("VFX tracks come from a filmed video clip");if(!w.includes(n))throw Error(`source must be ${w.join(" / ")}`);const p=Math.min(t.duration,c??t.duration),k=1/Math.max(1,Math.min(30,f)),d=[];let h;if(n==="hand"){if(!t.hands?.data)throw Error("this clip has no hand track yet (Timeline: Track hands, or edit_timeline handAttach once)");const e=A(t.hands),r=a==="left"?1:0,s=E.includes(o)?o:"palm";h=u=>{const g=j(e,y(t,u),r);return g?S(g,s):null}}else if(n==="roto"){if(!t.roto?.points?.length)throw Error("this clip has no Roto point track");h=e=>N(t,e)}else if(n==="planar"){if(!t.planar?.frames?.length)throw Error(v(t.planar)?"this planar track is stored apart from the clip: open the Timeline in the editor and run it there":"this clip has no planar track");h=e=>{if(!F(t.planar,e))return null;const r=_(t.planar,e);return O(t,r.reduce((s,u)=>s+u[0],0)/r.length,r.reduce((s,u)=>s+u[1],0)/r.length)}}else if(n==="face"){if(!t.face?.f?.length)throw Error("this clip has no face track");h=e=>{const r=x(t,e);return r&&r.score>0?[r.cx,r.cy]:null}}else{const e=(t.objectTracks??[]).find(r=>r?.id===i)??(i==null?t.objectTracks?.[0]:null);if(!e?.frames?.length)throw Error(i==null?"this clip has no 3D-tracked object (edit_timeline trackObject3D)":`no 3D-tracked object ${i} on this clip`);h=r=>{if(r<e.frames[0][0]-1e-6||r>e.frames.at(-1)[0]+1e-6)return null;const s=M(e,[0,0,0],r);return s?[s[0]/e.w,s[1]/e.h]:null}}for(let e=Math.max(0,l);e<=p+1e-6&&d.length<b;e+=k){const r=h(Math.min(e,p));r&&Number.isFinite(r[0])&&Number.isFinite(r[1])&&r[0]>-.5&&r[0]<1.5&&r[1]>-.5&&r[1]<1.5&&d.push([m(Math.min(e,p)),m(r[0]),m(r[1])])}if(d.length<2)throw Error(`the ${n} track does not see its target in this clip (fewer than 2 samples)`);return{fps:Math.round(1/k),points:d}}function X(t,n=600){if(!t||typeof t!="object"||!Array.isArray(t.points))throw Error("track must be {fps, points: [[t, u, v], …]}");if(t.points.length<2||t.points.length>b)throw Error(`track: 2 to ${b} points`);let a=-1/0;const o=t.points.map(i=>{if(!Array.isArray(i)||i.length<3||!i.slice(0,3).every(p=>Number.isFinite(Number(p))))throw Error("each track point is [t, u, v]");const[l,c,f]=i.map(Number);if(l<0||l>n+.001||l<=a)throw Error(`track times must rise within the shot (0–${n} s)`);if(c<-.5||c>1.5||f<-.5||f>1.5)throw Error("track u / v are fractions of the picture (−0.5..1.5)");return a=l,[l,c,f]});return{fps:Number.isFinite(Number(t.fps))?Number(t.fps):T,points:o}}export{w as V,X as a,C as b,$ as v};
@@ -0,0 +1 @@
1
+ import{gB as S}from"./remote-sTZauTqM.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 B,W as H,a as P,C as I}from"./output-BwZzMbp-.js";import"./api-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.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 B({format:o?new H:new P({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};
@@ -0,0 +1 @@
1
+ import{Bone as k,SkinnedMesh as g,Vector3 as a,Scene as L,Color as M,MeshLambertMaterial as b,HemisphereLight as S,DirectionalLight as h,WebGLRenderer as z,OrthographicCamera as C}from"./three.module-Bx43vjkH.js";import{c as D}from"./GLTFLoader-Dy6SrZg8.js";import{f as E}from"./skin-BkaT2QuX.js";import"./remote-sTZauTqM.js";import"./api-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const B=640;function U(y,c=B){const t=D(y);t.position.set(0,0,0),t.quaternion.identity(),t.scale.set(1,1,1);const p=[];t.traverse(e=>{e.userData.rigOverlay&&p.push(e),e instanceof k&&e.quaternion.identity()}),p.forEach(e=>e.parent?.remove(e)),t.traverse(e=>{e instanceof g&&e.skeleton.pose()});const d=E(t),n=d.getCenter(new a),f=d.getSize(new a),r=Math.max(f.x,f.y,f.z)/2*1.08,o=new L;o.background=new M("#ffffff");const m=new b({color:"#8d949b"});o.overrideMaterial=m,o.add(new S("#ffffff","#5a6066",2.2));const l=new h("#ffffff",1.4);l.position.set(.4,1,1),o.add(l);const u=new h("#ffffff",.6);u.position.set(1,.5,.3),o.add(u),o.add(t);const i=new z({antialias:!0,preserveDrawingBuffer:!0});i.setSize(c,c,!1);const s=new C(-r,r,r,-r,.01,100),w=e=>(s.position.copy(n).add(e),s.up.set(0,1,0),s.lookAt(n),s.updateProjectionMatrix(),i.render(o,s),i.domElement.toDataURL("image/jpeg",.88));try{const e=r*4,x=w(new a(0,0,e)),v=w(new a(e,0,0));return{front:x,side:v,frame:{cx:n.x,cy:n.y,cz:n.z,half:r}}}finally{m.dispose(),i.dispose(),i.forceContextLoss(),t.traverse(e=>{e instanceof g&&e.skeleton.dispose()})}}export{B as VIEW_SIZE,U as renderRigViews};
@@ -0,0 +1 @@
1
+ import{ir as pt,is as Y,ff as ut,fe as mt,fh as Z,fj as B,hy as kt,b as gt,fk as bt,fu as tt,fv as et,hu as Mt,fL as yt,hx as wt}from"./remote-sTZauTqM.js";import{F as vt}from"./rigTrack-Bx9QHlFv.js";const z=t=>pt(t)??(Y(t)?{clip:Y(t),pack:{id:"fist"}}:null),st=Object.freeze({spear:{"spear-thrust":"thrust","spear-overhead":"high","spear-sweep":"low","spear-spin":"side","spear-dive-thrust":"thrust"},katana:{"katana-overhead":"high","katana-diagonal":"high","katana-horizontal":"side","katana-rising":"side","katana-thrust":"thrust","katana-spin-cut":"side"},staff:{"staff-jab":"thrust","staff-overhead":"high","staff-sweep":"low","staff-rising":"side","staff-spin":"side"},fist:{"fist-lunge-punch":"thrust","fist-rising-uppercut":"side","fist-flying-kick":"side","fist-ground-slam":"high","fist-low-lunge":"thrust"}}),it={high:"block-high",side:"block-side",thrust:"block-side",low:null},jt=Object.freeze({spear:1.42,katana:.98,staff:1.1,fist:0}),Ot={body:.05,blocked:.22,miss:.18},Ft=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(z(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=z(t).clip.keys.filter(a=>a.strike).at(-1);return e?e.t:0}const At=t=>z(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}=z(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 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)],C=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[C]&&(y="miss");const $=`${j}-${y==="blocked"?it[C]:y==="miss"?"dodge-back":"hit"}`,D=ht(g),O=z($).clip.contact??0,b=Math.max(Ft,$t(g)+Ot[y]+ot(g,D)+ot($,O));o.push({attacker:f,attack:g,defence:$,result:y,strike:D,contact:O,gap:Math.round(b*1e3)/1e3})}return o}const x=[.18,.42],nt=t=>(t.kind==="model"?(t.model?.height??2)/1.8:Mt(t))*(t.scale[1]||1),L=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 zt(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),C=m+.5+l.reduce((s,c)=>s+Math.max(B(c.attack).duration,c.strike-c.contact+B(c.defence).duration)+1.4+x[1],0);let i=C>g.duration?rt(t,Math.min(300,C)):t;const M=T(i,h,m),y=l[0].gap*(u[0]+u[1])/2,$=[Math.sin(L(M.yaw)),0,Math.cos(L(M.yaw))],D=[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,D,M.yaw+180]])i=ct(i,s.id,(d,k)=>[...d.filter(p=>p.time*k.duration<m-1e-6),{id:a(),time:m/k.duration,position:c.map(p=>+p.toFixed(3)),rotation:[0,+n.toFixed(1),0],scale:s.scale}]);const O=(s,c,n)=>{const d=v(i),k=B(c),p=wt(i,r[s].id,k,{start:n/d.duration,newId:a,loop:!1});if(!p.ok)throw new Error(`${r[s].name}: ${p.error}`);return i=p.stage,n+k.duration};let b=m+.35,S=m;const E=[];let q=(e.seed*9301+49297)%233280;const lt=()=>(q=(q*9301+49297)%233280,q/233280);try{l.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const F=T(i,r[0],b).position,K=T(i,r[1],b).position;return Math.hypot(K[0]-F[0],K[2]-F[2])};for(let F=0;F<3;F++){const K=p()-s.gap*k;if(Math.abs(K)<.3*k)break;K>0?b=O(n,`${e.packs[n]}-advance`,b):b=O(d,`${e.packs[d]}-retreat`,b)}const N=Math.max(0,s.contact-s.strike),w=b+N,_=w+s.strike-s.contact,P=p()-s.gap*k,G=O(n,s.attack,w),ft=O(d,s.defence,_),H=r[n],U=T(i,H,w).yaw,W=[Math.sin(L(U)),Math.cos(L(U))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,P));i=ct(i,H.id,(F,K)=>F.map(A=>{const I=A.time*K.duration;if(I<w-1e-6||I>G+1e-6)return A;const R=Math.min(1,(I-w)/Math.max(.001,s.strike)),Q=R*R*(3-2*R),X={...A,position:[+(A.position[0]+W[0]*V*Q).toFixed(3),A.position[1],+(A.position[2]+W[1]*V*Q).toFixed(3)]};return A.strike&&Math.abs(I-J)<.06?{...X,hit:s.result}:X})),E.push({...s,time:+J.toFixed(2),attackerName:H.name}),S=Math.max(G,ft),b=S+x[0]+(x[1]-x[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)}`,P=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:P?"#ffd27a":"#9fdcff",fx:{preset:"vong_xung_kich",cat:"vong-xung-kich",intensity:P?.9:.75,seed:500+k,start:d.time,duration:.6,loop:!1,auto:"hit",params:{size:(P?1.05:.85)*w,height:+(1.35*w).toFixed(2),hits:1,gap:.3}}}),n[_]={start:d.time,duration:.6}}),c.length&&(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,zt as s};
@@ -1 +1 @@
1
- import{mC as P,a7 as b,U as W,$ as y,Z as E,a0 as F,lz as x}from"./titleFrameBudget-BjW--v_T.js";import"./rotoMatte-2EcyuvBX.js";import"./api-C5pOWyBM.js";import"./store-Dxq3MZF3.js";const N=e=>P(e).length>0,O=new Map;function D(e){const r=e.face??e.colorPerson??e.person??e.roto??e.mask;if(r?.mw&&r?.mh)return Promise.resolve(r.mh/r.mw);let o=O.get(e.url);return o||(o=new Promise(n=>{if(e.kind==="image"){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a.naturalHeight/Math.max(1,a.naturalWidth)),a.onerror=()=>n(9/16),a.src=e.url;return}const t=document.createElement("video");t.preload="metadata",t.muted=!0,t.crossOrigin="anonymous",t.onloadedmetadata=()=>{n(t.videoHeight/Math.max(1,t.videoWidth)),t.removeAttribute("src"),t.load()},t.onerror=()=>n(9/16),t.src=e.url}),O.set(e.url,o)),o}function I(e,r,o,n,t,a,g){const i=W(e.grade)[r],h=e.colorPerson?E(e.colorPerson):null,f=F(i,e,o,a,h),c=g??document.createElement("canvas");(c.width!==n||c.height!==t)&&Object.assign(c,{width:n,height:t});const l=c.getContext("2d"),d=l.createImageData(n,t);for(let w=0;w<t;w++)for(let u=0;u<n;u++){const m=(w*n+u)*4,s=Math.round(f((u+.5)/n,(w+.5)/t,0,0,0)*255);d.data[m]=d.data[m+1]=d.data[m+2]=s,d.data[m+3]=255}return l.putImageData(d,0,0),c}async function U(e,r,o,n){const t=document.createElement("canvas");for(const{key:a,k:g,clip:i}of P(e)){if(o.wants&&!o.wants("windowFrames",a))continue;i.colorPerson&&await b(i.colorPerson);const h=await D(i),f=x,c=Math.max(2,Math.min(x*2,Math.round(f*h))),l=W(i.grade)[g],d=Math.ceil(i.duration*r),w=!!l.motion;let u="",m="";for(let s=0;s<d;s++){if(n?.aborted)throw new DOMException("Export cancelled","AbortError");if(o.wants&&!o.wants("windowFrames",a,s)){await o.push("windowFrames",a,""),m="";continue}if(w){const p=JSON.stringify(y(l,i,s/r));if(s&&p===m){await o.push("windowFrames",a,"=");continue}m=p}I(i,g,s/r,f,c,h,t);const M=t.toDataURL("image/webp",.9),v=M.slice(M.indexOf(",")+1);if(v===u){await o.push("windowFrames",a,"=");continue}u=v,await o.push("windowFrames",a,v),s%5===0&&await new Promise(p=>setTimeout(p,0))}}}export{N as hasMovingWindows,D as pictureAspect,U as renderWindowFrames,I as windowMatteImage};
1
+ import{mC as P,a7 as b,U as W,$ as y,Z as E,a0 as F,lw as x}from"./titleFrameBudget-3MFHWIT6.js";import"./rotoMatte-DyXlW4jK.js";import"./api-BsKbf3l3.js";import"./store-BSSbvpzr.js";const N=e=>P(e).length>0,O=new Map;function D(e){const r=e.face??e.colorPerson??e.person??e.roto??e.mask;if(r?.mw&&r?.mh)return Promise.resolve(r.mh/r.mw);let o=O.get(e.url);return o||(o=new Promise(n=>{if(e.kind==="image"){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>n(a.naturalHeight/Math.max(1,a.naturalWidth)),a.onerror=()=>n(9/16),a.src=e.url;return}const t=document.createElement("video");t.preload="metadata",t.muted=!0,t.crossOrigin="anonymous",t.onloadedmetadata=()=>{n(t.videoHeight/Math.max(1,t.videoWidth)),t.removeAttribute("src"),t.load()},t.onerror=()=>n(9/16),t.src=e.url}),O.set(e.url,o)),o}function I(e,r,o,n,t,a,g){const i=W(e.grade)[r],h=e.colorPerson?E(e.colorPerson):null,f=F(i,e,o,a,h),c=g??document.createElement("canvas");(c.width!==n||c.height!==t)&&Object.assign(c,{width:n,height:t});const l=c.getContext("2d"),d=l.createImageData(n,t);for(let u=0;u<t;u++)for(let w=0;w<n;w++){const m=(u*n+w)*4,s=Math.round(f((w+.5)/n,(u+.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),u=!!l.motion;let w="",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(u){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===w){await o.push("windowFrames",a,"=");continue}w=v,await o.push("windowFrames",a,v),s%5===0&&await new Promise(p=>setTimeout(p,0))}}}export{N as hasMovingWindows,D as pictureAspect,U as renderWindowFrames,I as windowMatteImage};
@@ -4,9 +4,9 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="robots" content="noindex" />
6
6
  <title>Timeline layer worker</title>
7
- <script type="module" crossorigin src="/assets/layer-worker-Rbo-YZv-.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-BjW--v_T.js">
9
- <link rel="modulepreload" crossorigin href="/assets/frameSink-CB1EghW0.js">
7
+ <script type="module" crossorigin src="/assets/layer-worker-Bar7WgOA.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/titleFrameBudget-3MFHWIT6.js">
9
+ <link rel="modulepreload" crossorigin href="/assets/frameSink-Dj71jCRb.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
@@ -1 +0,0 @@
1
- import{j as d,dD as y,dE as w}from"./remote-DXG553d8.js";import{r as p}from"./api-C5pOWyBM.js";import{t as b,a as E,d as u}from"./thumb-xLFX6lDN.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const j=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],x=960,h=540;function F(i){const r=i&&typeof i=="object"?i:{},m=y({...r,name:String(r.name||"preview").slice(0,60),category:r.category||"tu-tien"});let o=5381;for(const l of JSON.stringify(m))o=(o<<5)+o+l.charCodeAt(0)|0;return w({id:(o>>>0).toString(16).padStart(32,"0"),...m})}function N(){const i=p.useRef(null),[r,m]=p.useState(null),[o,l]=p.useState("");return p.useEffect(()=>{const s=(t,a)=>t.source?.postMessage(a,{targetOrigin:t.origin}),c=t=>{if(!j.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const a="id"in t.data?t.data.id:null;let n;try{n=F(t.data.fx)}catch(e){t.data.type==="clipoox-fx-play"&&l(e.message),s(t,{type:"clipoox-fx-error",id:a,error:e.message});return}if(t.data.type==="clipoox-fx-play"){l(""),m(n);return}if(t.data.type==="clipoox-fx-thumb")try{const e=Object.assign(document.createElement("canvas"),{width:480,height:270}),f=e.getContext("2d");if(!f)throw Error("canvas");const g=Number.isFinite(t.data.t)?Math.max(0,Number(t.data.t)):E(n);u(f,n,g,480,270),s(t,{type:"clipoox-fx-thumb",id:a,webp:e.toDataURL("image/webp",.85)})}catch(e){s(t,{type:"clipoox-fx-error",id:a,error:e.message})}};return window.addEventListener("message",c),window.parent?.postMessage({type:"clipoox-fx-ready"},"*"),()=>window.removeEventListener("message",c)},[]),p.useEffect(()=>{const s=i.current,c=s?.getContext("2d");if(!r||!s||!c)return;let t=0;const a=performance.now(),n=b(r),e=()=>{u(c,r,(performance.now()-a)/1e3%n,x,h),t=requestAnimationFrame(e)};return t=requestAnimationFrame(e),()=>cancelAnimationFrame(t)},[r]),d.jsxs("div",{style:{margin:0,background:"#0a0e14",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[d.jsx("canvas",{ref:i,width:x,height:h,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"FX preview"}),o&&d.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,right:8,color:"#ff8080",font:"12px sans-serif"},children:o})]})}export{N as default,F as previewEntry};
@@ -1 +0,0 @@
1
- import{j as w,dC as F}from"./remote-DXG553d8.js";import{r as l}from"./api-C5pOWyBM.js";import{d as M,m as E}from"./lottieLayer-BhLbZOpr.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const I=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],j={"16:9":[1280,720],"9:16":[720,1280],"1:1":[960,960],"4:5":[768,960]},L=f=>j[f.aspect??"16:9"]??j["16:9"];function P(){const f=l.useRef(null),[o,R]=l.useState(null),[y,x]=l.useState(""),b=l.useRef(Promise.resolve());return l.useEffect(()=>{const a=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),h=async t=>{if(!I.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;const i="id"in t.data?t.data.id:null;let e;try{e=F(t.data.motion)}catch(n){a(t,{type:"clipoox-motion-error",id:i,error:n.message});return}if(t.data.type==="clipoox-motion-play"){x(""),R(e);return}if(t.data.type==="clipoox-motion-thumb"){const[n,u]=L(e),m=480/Math.max(n,u),s=Math.round(n*m),d=Math.round(u*m);try{const p=await E({layer:"embed:thumb",motion:{v:1,code:e.code,params:e.params},t:Number.isFinite(t.data.t)?Math.max(0,Math.min(e.duration,Number(t.data.t))):e.duration*.55,width:s,height:d,duration:e.duration}),c=Object.assign(document.createElement("canvas"),{width:s,height:d}),g=c.getContext("2d");if(!g)throw Error("canvas");g.fillStyle="#16181c",g.fillRect(0,0,s,d),g.drawImage(p,0,0),p.close(),a(t,{type:"clipoox-motion-thumb",id:i,webp:c.toDataURL("image/webp",.85)})}catch(p){a(t,{type:"clipoox-motion-error",id:i,error:p.message})}finally{M("embed:thumb")}}},r=t=>{b.current=b.current.then(()=>h(t)).catch(()=>{})};return window.addEventListener("message",r),window.parent?.postMessage({type:"clipoox-motion-ready"},"*"),()=>window.removeEventListener("message",r)},[]),l.useEffect(()=>{const a=f.current,h=a?.getContext("2d");if(!o||!a||!h)return;let r=!0,t=0;const i=performance.now(),[e,n]=L(o),u=Math.min(1,960/Math.max(e,n)),m=Math.round(e*u),s=Math.round(n*u);a.width=m,a.height=s;const d=async()=>{if(!r)return;const p=(performance.now()-i)/1e3%(o.duration+.8);try{const c=await E({layer:"embed:play",motion:{v:1,code:o.code,params:o.params},t:Math.min(p,o.duration),width:m,height:s,duration:o.duration});r&&(h.clearRect(0,0,m,s),h.drawImage(c,0,0)),c.close()}catch(c){if(r){x(c.message);return}}r&&(t=requestAnimationFrame(()=>void d()))};return d(),()=>{r=!1,cancelAnimationFrame(t),M("embed:play")}},[o]),w.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[w.jsx("canvas",{ref:f,width:1280,height:720,style:{maxWidth:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Motion preview"}),y&&w.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:y})]})}export{P as default};