clipoox-render 0.3.0 → 0.4.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 (111) hide show
  1. package/dist/server-text/titleRaster.js +23 -4
  2. package/package.json +1 -1
  3. package/scripts/render-local.mjs +229 -229
  4. package/shared/transitionStarterPack.json +355 -0
  5. package/web/assets/{FxEmbed-D7k1ThAF.js → FxEmbed-CGqGi2Lw.js} +1 -1
  6. package/web/assets/{MotionEmbed-DFni5IAh.js → MotionEmbed-C3CZ3_y_.js} +1 -1
  7. package/web/assets/{PluginStore-BrupM_8E.js → PluginStore-DKXZ-jBj.js} +1 -1
  8. package/web/assets/{ShotComposer-BLztjSKy.js → ShotComposer-DFfaYLoV.js} +4 -4
  9. package/web/assets/{TemplateEmbed-BbAimhLj.js → TemplateEmbed-C8pXcPsc.js} +1 -1
  10. package/web/assets/{TimelinePlugins-BI1bE9pX.js → TimelinePlugins-DnkV3i4G.js} +3 -3
  11. package/web/assets/{TimelineShotFx-CQN3WIfN.js → TimelineShotFx-foiuuogg.js} +2 -2
  12. package/web/assets/{TransitionEmbed-CmoIrHVr.js → TransitionEmbed-BueDilY0.js} +1 -1
  13. package/web/assets/{Whiteboard-DMk0unYK.js → Whiteboard-zBsNHh5h.js} +1 -1
  14. package/web/assets/aerial-z34Nww_T.js +2 -0
  15. package/web/assets/{agentTools-qOww5RUs.js → agentTools-ALxghYpf.js} +2 -2
  16. package/web/assets/{analyzerRun-B2FLUp4G.js → analyzerRun-DNwryAlU.js} +1 -1
  17. package/web/assets/{analyzerSandbox-CJVsEhrg.js → analyzerSandbox-A1oFsCrO.js} +1 -1
  18. package/web/assets/{api-QBI5GJTZ.js → api-DUp403BK.js} +57 -57
  19. package/web/assets/auraTrack-BKVZCwNt.js +1 -0
  20. package/web/assets/breakthrough-Cwt8gEwK.js +2 -0
  21. package/web/assets/{cameraPresets-4pFeF2YG.js → cameraPresets-DSOPj4oy.js} +1 -1
  22. package/web/assets/{captionLayout-C67EMVI1.js → captionLayout-EuB59pN_.js} +1 -1
  23. package/web/assets/clientExport-BL1XMTF0.js +1 -0
  24. package/web/assets/{depthEstimate-mnXDZMW-.js → depthEstimate-DOvsY8mn.js} +1 -1
  25. package/web/assets/{directorTools-BOHZjcww.js → directorTools-BkbNYbSq.js} +1 -1
  26. package/web/assets/{distortFrames-Csuj2jHE.js → distortFrames-Drch0LhT.js} +2 -2
  27. package/web/assets/{distortGL-BaXfN0IK.js → distortGL-BlmBZKRU.js} +2 -2
  28. package/web/assets/{editTools-m0VGPmfF.js → editTools-BcGinqHC.js} +1 -1
  29. package/web/assets/exportEncode-MUwVTI52.js +1 -0
  30. package/web/assets/{exportGlb-CLfTnbMG.js → exportGlb-SIXFRRJM.js} +1 -1
  31. package/web/assets/{faceTracker-W0iZSiMe.js → faceTracker-DCbZbLMc.js} +1 -1
  32. package/web/assets/fightDirector-hlF1JS_z.js +1 -0
  33. package/web/assets/fightDrama-fHN5EXk3.js +2 -0
  34. package/web/assets/{frameSink-BGRj7wqY.js → frameSink-BvOXjLuw.js} +3 -3
  35. package/web/assets/{gpuCompose-CIEoLFem.js → gpuCompose-CNkLwpbZ.js} +1 -1
  36. package/web/assets/gpuExport-DQB6x4eh.js +194 -0
  37. package/web/assets/{handMatte-mHxZwLZD.js → handMatte-BD7OE3Zc.js} +1 -1
  38. package/web/assets/{handTracker-dTVeSUzt.js → handTracker-BumGtRCW.js} +2 -2
  39. package/web/assets/{index-D7M5t2re.js → index-CuaB7Y0L.js} +1 -1
  40. package/web/assets/{layer-worker-Cp0pjurp.js → layer-worker-DxPMMKIZ.js} +3 -3
  41. package/web/assets/library-CyjJ8nGG.js +1 -0
  42. package/web/assets/{lottieLayer-CDCGeJyv.js → lottieLayer-1ET89OUr.js} +5 -5
  43. package/web/assets/{lottie_light_canvas-BblLU4nU.js → lottie_light_canvas-DD9pkFL8.js} +1 -1
  44. package/web/assets/{main-CVRIuDW2.js → main-BKjBWQik.js} +91 -91
  45. package/web/assets/{main-BQ8IY0WV.css → main-Ca_CVxMz.css} +1 -1
  46. package/web/assets/mapBake-DLoBt_k5.js +1 -0
  47. package/web/assets/{maskTrack-Dtv6Jr06.js → maskTrack-C2SJbDGO.js} +1 -1
  48. package/web/assets/{matteFixRun-BLDH2AjH.js → matteFixRun-BdHKC3m5.js} +1 -1
  49. package/web/assets/{objectLocate-Cy3IFBSF.js → objectLocate-bZtc5AJo.js} +1 -1
  50. package/web/assets/{pendingMatte-C2AWApuv.js → pendingMatte-mlyLLZCT.js} +2 -2
  51. package/web/assets/{personAi-DPUnoymj.js → personAi-CUNQeseG.js} +2 -2
  52. package/web/assets/plateCamera-_jP1xXnj.js +1 -0
  53. package/web/assets/{plateCameraMatch-Chk-ZjDi.js → plateCameraMatch-rr0oUwQ2.js} +2 -2
  54. package/web/assets/{plateFollow-B9_QTgvo.js → plateFollow-BjvtcT8q.js} +2 -2
  55. package/web/assets/{plateMatte-BiqyI_8x.js → plateMatte-BqyL8cQZ.js} +2 -2
  56. package/web/assets/{pluginAutomation-5DYldFrb.js → pluginAutomation-Dp188qm7.js} +1 -1
  57. package/web/assets/{poseTracker-PuI8vWpR.js → poseTracker-DDGDhhMF.js} +1 -1
  58. package/web/assets/{productTools-B1h5cgyt.js → productTools-CRgI88-O.js} +2 -2
  59. package/web/assets/remote-Dva2qg58.js +1241 -0
  60. package/web/assets/{rigTrack-CUt4O67J.js → rigTrack-UYZU4P-e.js} +1 -1
  61. package/web/assets/{rotoMaskStore-DIi45swK.js → rotoMaskStore-BxyxB2bD.js} +1 -1
  62. package/web/assets/{rotoMatte-013RKqHu.js → rotoMatte-BdYa8FSB.js} +1 -1
  63. package/web/assets/{rotoscope-d_TUxa-J.js → rotoscope-DDixNQCt.js} +1 -1
  64. package/web/assets/{shot-worker-B1iZT6F5.js → shot-worker-D9sZS6bn.js} +1 -1
  65. package/web/assets/{shotFxAgent-BDfe73TP.js → shotFxAgent-7RQNtEe4.js} +2 -2
  66. package/web/assets/{skin-GDY3QPkV.js → skin-CVwmK130.js} +1 -1
  67. package/web/assets/{spark.module-DdwuJ_hb.js → spark.module-B34aiScb.js} +1 -1
  68. package/web/assets/{spellDuel-DjNN00bv.js → spellDuel-BkweL6pI.js} +2 -2
  69. package/web/assets/{store-2zneEhhu.js → store-75tQUvPT.js} +1 -1
  70. package/web/assets/surfaceLight-DhU-zgNL.js +1 -0
  71. package/web/assets/{surfacePin-zDPmq-hH.js → surfacePin-ObK6QgDm.js} +2 -2
  72. package/web/assets/textAnimators-nVSz_sZo.js +1 -0
  73. package/web/assets/{thumb-byAKvhQP.js → thumb-r6dlZprA.js} +1 -1
  74. package/web/assets/{timeline3d-YIIk_Kn2.js → timeline3d-246tBEJl.js} +2 -2
  75. package/web/assets/timeline3dExport-T57qnWi9.js +1 -0
  76. package/web/assets/{timelineComp-B73i_8vD.js → timelineComp-BcewYGR2.js} +1 -1
  77. package/web/assets/{timelineProps-B2pnudeT.js → timelineProps-CJzzAWWO.js} +1 -1
  78. package/web/assets/{timelineText-BcL4Pw3C.js → timelineText-BzUhNWPB.js} +1 -1
  79. package/web/assets/titleArt-B8DVR58F.js +5 -0
  80. package/web/assets/{titleFrameBudget-Cml-MO53.js → titleFrameBudget-BYRZAQPs.js} +260 -260
  81. package/web/assets/titleFrames-BVgm601q.js +1 -0
  82. package/web/assets/{tool-Bt9bclIf.js → tool-CAGU3dUa.js} +1 -1
  83. package/web/assets/{tools-BXeJbgZJ.js → tools-DVaOkokV.js} +1 -1
  84. package/web/assets/{toonTools-u7Y9fdEZ.js → toonTools-CfGTR_H1.js} +2 -2
  85. package/web/assets/{trackAnchor-9MnVHe4S.js → trackAnchor-DzUt1r5Q.js} +1 -1
  86. package/web/assets/{userFonts-BHduCNtc.js → userFonts-DzY0A4bD.js} +1 -1
  87. package/web/assets/{vfxAlpha-DpV4rbI-.js → vfxAlpha-DQJOaZ9v.js} +2 -2
  88. package/web/assets/{vfxBackground-Ddviync5.js → vfxBackground-DiktQFOD.js} +2 -2
  89. package/web/assets/{videoExport-z5WjM0hw.js → videoExport-Ce0ElSQR.js} +1 -1
  90. package/web/assets/{views-CsrYzCSR.js → views-V3si1lOz.js} +1 -1
  91. package/web/assets/weaponDuel-D6sLVGmG.js +1 -0
  92. package/web/assets/{windowFrames-BQEWQkEs.js → windowFrames-D_2QJCJJ.js} +1 -1
  93. package/web/layer-worker.html +3 -3
  94. package/web/assets/aerial-DT_gUtSh.js +0 -2
  95. package/web/assets/auraTrack-CEs_Q9EP.js +0 -1
  96. package/web/assets/breakthrough-DvkxvNK9.js +0 -2
  97. package/web/assets/clientExport-C4VgAJtO.js +0 -1
  98. package/web/assets/exportEncode-D9OT7_5k.js +0 -1
  99. package/web/assets/fightDirector-CECPf2iH.js +0 -1
  100. package/web/assets/fightDrama-CqNoa5XI.js +0 -2
  101. package/web/assets/gpuExport-uyOAyrhm.js +0 -190
  102. package/web/assets/library-Dsz_MLyd.js +0 -1
  103. package/web/assets/mapBake-CNMOKXA7.js +0 -1
  104. package/web/assets/plateCamera-C96L5GKm.js +0 -1
  105. package/web/assets/remote-BJdzzFZg.js +0 -1241
  106. package/web/assets/surfaceLight-B_SYg_f8.js +0 -1
  107. package/web/assets/textAnimators-Bdt5LWXk.js +0 -1
  108. package/web/assets/timeline3dExport-CEH1RjNf.js +0 -1
  109. package/web/assets/titleArt-hb_T45WJ.js +0 -5
  110. package/web/assets/titleFrames-Dw0PEBdV.js +0 -1
  111. package/web/assets/weaponDuel-CLLgv5A4.js +0 -1
@@ -1 +0,0 @@
1
- import{bf as A,dD as C,nj as D,nk as I}from"./titleFrameBudget-Cml-MO53.js";const e=160;async function H(p,g,x,y){const u=g.frames;if(!u.length)return null;const t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=x;try{await new Promise((a,d)=>{t.onloadeddata=()=>a(),t.onerror=()=>d(Error("video"))});const r=Math.max(2,Math.round(e*t.videoHeight/t.videoWidth)),E=Object.assign(document.createElement("canvas"),{width:e,height:r}),w=E.getContext("2d",{willReadFrequently:!0}),o=p.crop||{left:0,right:0,top:0,bottom:0},S=1-o.left-o.right,T=1-o.top-o.bottom,s=u[0][0],M=u.at(-1)[0],m=Math.max(1/6,(M-s)/80),k=Math.max(1,Math.floor((M-s)/m+1e-6)+1),b=[];for(let a=0;a<k;a++){if(y?.aborted)throw new DOMException("cancelled","AbortError");const d=s+a*m,v=Math.min(t.duration-1/60,A(p,d));Math.abs(t.currentTime-v)>1e-4&&await new Promise((n,c)=>{const i=window.setTimeout(()=>c(Error("seek")),8e3);t.onseeked=()=>{window.clearTimeout(i),n()},t.currentTime=v}),w.drawImage(t,0,0,e,r);const l=w.getImageData(0,0,e,r).data,O=(n,c)=>{const i=Math.round(n),h=Math.round(c);if(i<0||h<0||i>=e||h>=r)return null;const f=(h*e+i)*4;return[l[f]/255,l[f+1]/255,l[f+2]/255]},j=C(g,d).map(([n,c])=>[(o.left+n*S)*e,(o.top+c*T)*r]);b.push(D(O,j))}return I(b,s,m)}finally{t.removeAttribute("src"),t.load()}}export{H as measureSurfaceLight};
@@ -1 +0,0 @@
1
- import{mI as se}from"./titleFrameBudget-Cml-MO53.js";const oe=[{family:"Inter",category:"Sans serif"},{family:"Be Vietnam Pro",category:"Sans serif"},{family:"Roboto",category:"Sans serif"},{family:"Open Sans",category:"Sans serif"},{family:"Montserrat",category:"Sans serif"},{family:"Manrope",category:"Sans serif"},{family:"Lexend",category:"Sans serif"},{family:"Archivo",category:"Sans serif"},{family:"Barlow",category:"Sans serif"},{family:"Noto Sans",category:"Sans serif"},{family:"Noto Serif",category:"Serif"},{family:"Playfair Display",category:"Serif"},{family:"Oswald",category:"Display"},{family:"Anton",category:"Display"},{family:"Bungee",category:"Display"},{family:"Dancing Script",category:"Handwriting"},{family:"Arial",category:"System"},{family:"Georgia",category:"System"},{family:"Courier New",category:"System"}],ce=oe.map(e=>e.family),ae=e=>ce.includes(e),fe=/^u:[A-Za-z0-9_-]{8,40}$/,ne=e=>typeof e=="string"&&fe.test(e),de=e=>ae(e)||ne(e);function ve(e){const n=new Set,i=new WeakSet,t=r=>{if(typeof r=="string"){ne(r)&&n.add(r);return}if(!(!r||typeof r!="object"||i.has(r))){i.add(r);for(const s of Array.isArray(r)?r:Object.values(r))t(s)}};return t(e),[...n]}const T=["linear","easeOutCubic","easeOutQuart","easeOutExpo","easeInOutCubic","easeOutBack","easeOutElastic","easeOutBounce"],R=["line","word","char"],Z=6,Y=["forward","reverse","center","random"],A={opacity:1,x:0,y:0,scale:1,scaleX:1,scaleY:1,reveal:1,wipeX:1,wipeY:1,brightness:1,blur:0,rotate:0,spread:0,glitch:0,flicker:0,count:1},le=["x","y","rotate","blur","spread","glitch","flicker"],F={opacity:[0,1],x:[-4,4],y:[-4,4],scale:[0,4],scaleX:[0,4],scaleY:[0,4],reveal:[0,1],wipeX:[0,1],wipeY:[0,1],brightness:[0,1],blur:[0,1],rotate:[-180,180],spread:[-.2,1.5],glitch:[0,1],flicker:[0,1],count:[0,20]},te={linear:e=>e,easeOutCubic:e=>1-(1-e)**3,easeOutQuart:e=>1-(1-e)**4,easeOutExpo:e=>e>=1?1:1-2**(-10*e),easeInOutCubic:e=>e<.5?4*e**3:1-(-2*e+2)**3/2,easeOutBack:e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,easeOutElastic:e=>e<=0?0:e>=1?1:2**(-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1,easeOutBounce:e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375};function ge(e,n){m(e,n),g(e,["lines","unit","start","duration","stagger","order","easing","from","mask","at"],n),e.mask!==void 0&&typeof e.mask!="boolean"&&a(n+".mask","true/false"),R.includes(e.unit??"line")||a(n+".unit",R.join("/")),e.order!==void 0&&!Y.includes(e.order)&&a(n+".order",Y.join("/")),e.easing!==void 0&&!T.includes(e.easing)&&a(n+".easing",T.join("/"));let i=null;e.lines!==void 0&&e.lines!==null&&((!Array.isArray(e.lines)||!e.lines.length||e.lines.length>8||e.lines.some(o=>!Number.isInteger(o)||o<0||o>7))&&a(n+".lines","mảng chỉ số dòng 0–7"),i=[...new Set(e.lines)]);let t=null;e.at!==void 0&&((!Array.isArray(e.at)||!e.at.length||e.at.length>60)&&a(n+".at","cần 1–60 mốc giây"),t=e.at.map((o,f)=>c(o,0,10,`${n}.at[${f}]`)));const r=m(e.from??{},n+".from");g(r,Object.keys(A),n+".from"),Object.keys(r).length||a(n+".from","cần ít nhất 1 thuộc tính");const s={};for(const[o,f]of Object.entries(r))s[o]=c(f,F[o][0],F[o][1],`${n}.from.${o}`);return{lines:i,unit:e.unit??"line",start:c(e.start,0,10,n+".start",0),duration:c(e.duration,.02,5,n+".duration",.4),stagger:c(e.stagger,0,2,n+".stagger",0),order:e.order??"forward",easing:e.easing??"easeOutCubic",from:s,mask:e.mask===!0,...t?{at:t}:{}}}function en(e,n="animation"){return m(e,n),g(e,["version","in","out","outSpeed"],n),e.version!==void 0&&e.version!==1&&a(n+".version","chỉ hỗ trợ version 1"),(!Array.isArray(e.in)||!e.in.length||e.in.length>Z)&&a(n+".in",`cần 1–${Z} track`),e.out!==void 0&&!["reverse","none"].includes(e.out)&&a(n+".out","reverse hoặc none"),{version:1,in:e.in.map((i,t)=>ge(i,`${n}.in[${t}]`)),out:e.out??"reverse",outSpeed:c(e.outSpeed,.25,4,n+".outSpeed",1.5)}}function me(e,n){const i=[...Array(e).keys()];let t=n||1;for(let r=e-1;r>0;r--){t=t*16807%2147483647;const s=t%(r+1);[i[r],i[s]]=[i[s],i[r]]}return i}function _(e,n,i){return i==="reverse"?n-1-e:i==="center"?Math.abs(e-(n-1)/2)*2|0:i==="random"?me(n,n*7919).indexOf(e):e}function ue(e,n){let i=0;for(const t of e.in)for(const[r,s]of n.entries()){if(t.lines&&!t.lines.includes(r))continue;const o=t.unit==="line"?1:s[t.unit];for(let f=0;f<o;f++)i=Math.max(i,re(t,f,o)+t.duration)}return i}function re(e,n,i){if(e.at){const t=_(n,i,e.order),r=Math.min(t,e.at.length-1);return e.at[r]+e.stagger*(t-r)}return e.start+e.stagger*_(n,i,e.order)}function ye(e,n,i,t){const r=re(e,n,i);return te[e.easing](Math.min(1,Math.max(0,(t-r)/e.duration)))}function nn(e,n,i,t,r=0){const s=Math.max(r,ue(e,n)),o=s/e.outSpeed;return e.out==="reverse"&&Number.isFinite(t)&&i>Math.max(s,t-o)?(t-i)*e.outSpeed:i}function tn(e,n,i,t,r,s){const o={...A,masked:!1};for(const f of e.in){if(f.unit!==n||f.lines&&!f.lines.includes(i))continue;const l=ye(f,t,r,s);f.mask&&l<1&&(o.masked=!0);for(const[d,b]of Object.entries(f.from)){const k=b+(A[d]-b)*l;le.includes(d)?o[d]+=k:o[d]*=k}}return o}const rn=Object.freeze({...A});function H(e,n){m(e,n),g(e,["start","duration","easing","from","spin","origin","stagger"],n),e.easing!==void 0&&!T.includes(e.easing)&&a(n+".easing",T.join("/")),e.origin!==void 0&&!["center","left","right","top","bottom"].includes(e.origin)&&a(n+".origin","center/left/right/top/bottom");const i=m(e.from??{},n+".from");g(i,["opacity","x","y","scale","scaleX","scaleY","rotate","wipeX","wipeY"],n+".from");const t={};for(const[r,s]of Object.entries(i))t[r]=c(s,F[r][0],F[r][1],`${n}.from.${r}`);return{start:c(e.start,0,10,n+".start",0),duration:c(e.duration,.02,5,n+".duration",.6),easing:e.easing??"easeOutCubic",from:t,spin:c(e.spin,-720,720,n+".spin",0),origin:e.origin??"center",...e.stagger?{stagger:c(e.stagger,0,2,n+".stagger")}:{}}}function sn(e,n=1){let i=0;for(const t of e?.layers||[])t.motion&&(i=Math.max(i,t.motion.start+t.motion.duration+(t.motion.stagger||0)*Math.max(0,n-1)));return i}function on(e,n){const i={...A};if(!e)return i;const t=te[e.easing](Math.min(1,Math.max(0,(n-e.start)/e.duration)));for(const[r,s]of Object.entries(e.from))i[r]=s+(A[r]-s)*t;return i.rotate+=e.spin*Math.max(0,n-e.start),i}function cn(e,n){return n===1?e:e.replace(/\d[\d.,]*\d|\d/,i=>{const t=/^\d{1,3}([.,]\d{3})+$/.test(i)?i.match(/[.,]/)[0]:"";if(!t&&/[.,]/.test(i)){const s=i.split(/[.,]/)[1].length;return Math.max(0,Number(i.replace(",","."))*n).toFixed(s).replace(".",i.includes(",")?",":".")}const r=String(Math.max(0,Math.round(Number(i.replace(/[.,]/g,""))*n)));return t?r.replace(/\B(?=(\d{3})+(?!\d))/g,t):r})}const he=Object.freeze({sparkle:["m12 2 2.4 6.6L21 11l-6.6 2.4L12 20l-2.4-6.6L3 11l6.6-2.4L12 2Z","m19 17 1 3 3 1-3 1-1 3-1-3-3-1 3-1 1-3Z"],pen:["M5 16 16 5l3 3L8 19H5v-3Z","m14 7 3 3M4 20h16"],target:["M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0Z","M9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0Z","M12 1v4m0 14v4M1 12h4m14 0h4"],play:["M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2Z","m10 9 5 3-5 3V9Z"],bolt:["m13 2-8 11h6l-1 9 9-12h-6l0-8Z"],navigate:["M4 17 10 3l3 9 7-3-6 12-3-7-7 3Z"],chip:["M6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2Z","M9 9h6v6h-6Z","M8 1v3m8-3v3M8 20v3m8-3v3M1 8h3m-3 8h3m16-8h3m-3 8h3"],data:["M4 6h16M4 12h10M4 18h16","m17 10 4 2-4 2"],building:["M3 21V8l9-5 9 5v13H3Z","M9 21v-7h6v7M8 9h1m6 0h1"],signal:["M4 16a8 8 0 0 1 16 0M7 16a5 5 0 0 1 10 0M10 16a2 2 0 0 1 4 0M12 20h.01"],office:["M3 21V4h11v17M14 9h7v12H3M7 8h3m-3 4h3m-3 4h3m10-3h-2m2 4h-2"],cloud:["M4 15a4 4 0 0 1 1-8 7 7 0 0 1 13 1 4 4 0 0 1 1 8H4Z","m9 19 3 3 3-3M12 13v9"],skyline:["M3 21V9l5-3v15M8 21V4l6-2v19m0-11 7-3v14M3 21h18"],network:["M2 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0Z","M18 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0Z","M18 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0Z","m6 11 12-4M6 13l12 4"],video:["M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2Z","m10 9 5 3-5 3V9Z","M7 22h10"],home:["m3 11 9-8 9 8v10H3V11Z","M9 21v-7h6v7M8 10h.01m8 0h.01"],compass:["M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0Z","m12 4 3 8-3 8-3-8 3-8ZM4 12h16"],grid:["M3 3h18v18H3V3ZM3 9h18M9 3v18M15 9v12"],chart:["M3 20h18M5 17l5-6 4 3 5-8","m16 6 3 0 0 3"],pin:["M20 10c0 6-8 12-8 12S4 16 4 10a8 8 0 1 1 16 0Z","M9.5 10a2.5 2.5 0 1 0 5.0 0a2.5 2.5 0 1 0 -5.0 0Z"]}),we=Object.keys(he),be=/^#[0-9a-f]{6}$/i,ke=e=>[1,3,5].map(n=>parseInt(e.slice(n,n+2),16)/255),pe=e=>"#"+e.map(n=>Math.round(Math.max(0,Math.min(1,n))*255).toString(16).padStart(2,"0")).join("");function Me(e){const[n,i,t]=ke(e),r=Math.max(n,i,t),s=Math.min(n,i,t),o=(r+s)/2,f=r-s;if(!f)return[0,0,o];const l=f/(1-Math.abs(2*o-1));return[(r===n?((i-t)/f+6)%6:r===i?(t-n)/f+2:(n-i)/f+4)*60,l,o]}function P(e,n,i){const t=(1-Math.abs(2*i-1))*n,r=t*(1-Math.abs(e/60%2-1)),s=i-t/2,[o,f,l]=e<60?[t,r,0]:e<120?[r,t,0]:e<180?[0,t,r]:e<240?[0,r,t]:e<300?[r,0,t]:[t,0,r];return pe([o+s,f+s,l+s])}const p={yellow:55,cyan:185,magenta:315};function xe(e,n){if(n==="yellow")return p.yellow;if(n==="cyan")return p.cyan;if(n==="pink")return p.magenta;const i=(t,r)=>Math.abs((t-r+540)%360-180);for(const t of Object.values(p))if(i(e,t)<=15)return t;return e>=345||e<135?p.yellow:e<255?p.cyan:p.magenta}function Ae(e,{white:n=!1,toward:i="auto"}={}){if(!be.test(e))throw new Error("màu gốc phải là #rrggbb");const[t,r,s]=Me(e);if(r<.15)return s<.35?{type:"radial",gradient:["#5c5c5c","#0d0d0d"]}:{type:"radial",gradient:["#ffffff",n?"#d6d6d6":"#8a8a8a"],stops:[.25,1]};const o=P(t,Math.max(.75,r),Math.min(.5,Math.max(.32,s))),f=P(xe(t,i),1,.58);return n?{gradient:["#ffffff",f,o],stops:[0,.38,1],angle:90}:{gradient:[f,o],angle:90}}const Se=/^auto(\+white)?(?:-(yellow|cyan|pink))?:(#[0-9a-f]{6})$/i;function Oe(e){const n=typeof e=="string"?Se.exec(e):null;return n?Ae(n[3].toLowerCase(),{white:!!n[1],toward:(n[2]||"auto").toLowerCase()}):null}const G=8,I=["condensed","semi-condensed","normal","semi-expanded","expanded"],z=["halftone","lines","grain"],B=["atop","cut","keep"],$e=/^#[0-9a-f]{6}$/i,a=(e,n)=>{throw new Error(`${e}: ${n}`)},m=(e,n)=>((!e||typeof e!="object"||Array.isArray(e))&&a(n,"phải là object"),e),c=(e,n,i,t,r)=>e===void 0?r:((typeof e!="number"||!Number.isFinite(e)||e<n||e>i)&&a(t,`phải là số từ ${n} đến ${i}`),e),D=(e,n,i,{required:t=!1,fallback:r=""}={})=>e===void 0&&!t?r:((typeof e!="string"||t&&!e.trim()||e.length>n)&&a(i,`cần chuỗi tối đa ${n} ký tự`),e.trim()),Ee=["{color}","{accent}","{accent-hi}","{accent-lo}","{accent-bright}","{accent-deep}","{color-lo}","transparent"],u=(e,n)=>{if(Ee.includes(e)||typeof e=="string"&&$e.test(e))return e;a(n,"màu phải là #rrggbb, {color}, {accent}, {accent-hi}, {accent-lo}, {accent-bright}, {accent-deep}, {color-lo} hoặc transparent")},g=(e,n,i)=>{for(const t of Object.keys(e))n.includes(t)||a(i,`trường lạ "${t}"`)};function je(e,n){(!Array.isArray(e)||e.length!==4)&&a(n,"[x, y, w, h] theo tỉ lệ khung");const[i,t,r,s]=e.map((o,f)=>c(o,f<2?-.5:0,f<2?1.5:2,`${n}[${f}]`));return[i,t,r,s]}function x(e,n){if(typeof e=="string")return Oe(e)??u(e,n);m(e,n),g(e,["gradient","angle","type","stops"],n),(!Array.isArray(e.gradient)||e.gradient.length<2||e.gradient.length>4)&&a(n+".gradient","cần 2–4 màu"),e.type!==void 0&&!["linear","radial"].includes(e.type)&&a(n+".type","linear hoặc radial");const i={gradient:e.gradient.map((t,r)=>u(t,`${n}.gradient[${r}]`))};return e.type==="radial"?i.type="radial":i.angle=c(e.angle,0,360,n+".angle",90),e.stops!==void 0&&((!Array.isArray(e.stops)||e.stops.length!==i.gradient.length)&&a(n+".stops","mỗi màu một vị trí 0–1"),i.stops=e.stops.map((t,r)=>c(t,0,1,`${n}.stops[${r}]`)),i.stops.some((t,r)=>r&&t<i.stops[r-1])&&a(n+".stops","vị trí phải tăng dần")),i}function Te(e,n){if(e!==void 0)return(!Array.isArray(e)||!e.length||e.length>8||e.some(i=>!Number.isInteger(i)||i<0||i>7))&&a(n,"mảng chỉ số dòng 0–7"),[...new Set(e)]}function q(e,n){const i=m(e,n);return g(i,["color","blur","x","y"],n),{color:u(i.color??"#000000",n+".color"),blur:c(i.blur,0,1,n+".blur",.15),x:c(i.x,-.5,.5,n+".x",0),y:c(i.y,-.5,.5,n+".y",0)}}function X(e,n){const i=Te(e.lines,n+".lines");return{...i?{lines:i}:{},...e.motion!==void 0?{motion:H(e.motion,n+".motion")}:{}}}function Fe(e,n){m(e,n);const i={opacity:c(e.opacity,0,1,n+".opacity",1)};switch(e.type){case"box":{g(e,["type","fill","radius","padX","padY","opacity","per","stroke","shadow","skewX","lines","motion"],n),e.per!==void 0&&!["line","block"].includes(e.per)&&a(n+".per","line hoặc block");const t={type:"box",fill:x(e.fill??"{accent}",n+".fill"),radius:c(e.radius,0,1,n+".radius",.15),padX:c(e.padX,0,1.5,n+".padX",.3),padY:c(e.padY,0,1,n+".padY",.12),per:e.per||"line",...i};if(e.stroke!==void 0){const r=m(e.stroke,n+".stroke");g(r,["color","width"],n+".stroke"),t.stroke={color:u(r.color??"{accent}",n+".stroke.color"),width:c(r.width,.01,.3,n+".stroke.width",.05)}}return e.shadow!==void 0&&(t.shadow=q(e.shadow,n+".shadow")),e.skewX!==void 0&&(t.skewX=c(e.skewX,-30,30,n+".skewX")),{...t,...X(e,n)}}case"text":{g(e,["type","fill","lineFills","stroke","shadow","offset","opacity","shine","flicker","lines","motion","reflection","innerGlow","highlights"],n);const t={type:"text",fill:x(e.fill??"{color}",n+".fill"),...i,...X(e,n)};if(e.shine!==void 0){const r=m(e.shine,n+".shine");g(r,["color","width","angle","start","duration","every"],n+".shine"),t.shine={color:u(r.color??"#ffffff",n+".shine.color"),width:c(r.width,.1,4,n+".shine.width",.8),angle:c(r.angle,-60,60,n+".shine.angle",20),start:c(r.start,0,10,n+".shine.start",.6),duration:c(r.duration,.1,5,n+".shine.duration",.8),every:c(r.every,0,10,n+".shine.every",0)}}if(e.flicker!==void 0&&(t.flicker=c(e.flicker,0,1,n+".flicker")),e.lineFills!==void 0&&((!Array.isArray(e.lineFills)||!e.lineFills.length||e.lineFills.length>4)&&a(n+".lineFills","cần 1–4 màu"),t.lineFills=e.lineFills.map((r,s)=>u(r,`${n}.lineFills[${s}]`))),e.stroke!==void 0){const r=m(e.stroke,n+".stroke");g(r,["color","width"],n+".stroke"),t.stroke={color:u(r.color??"{accent}",n+".stroke.color"),width:c(r.width,.01,.3,n+".stroke.width",.08)}}if(e.shadow!==void 0&&(t.shadow=q(e.shadow,n+".shadow")),e.offset!==void 0){const r=m(e.offset,n+".offset");g(r,["x","y"],n+".offset"),t.offset={x:c(r.x,-.5,.5,n+".offset.x",0),y:c(r.y,-.5,.5,n+".offset.y",0)}}if(e.reflection!==void 0){const r=m(e.reflection,n+".reflection");g(r,["opacity","gap","fade"],n+".reflection"),t.reflection={opacity:c(r.opacity,.05,1,n+".reflection.opacity",.35),gap:c(r.gap,-.3,.6,n+".reflection.gap",.04),fade:c(r.fade,.15,1,n+".reflection.fade",.7)}}if(e.innerGlow!==void 0){const r=m(e.innerGlow,n+".innerGlow");g(r,["color","blur"],n+".innerGlow"),t.innerGlow={color:u(r.color??"#ffffff",n+".innerGlow.color"),blur:c(r.blur,.02,.5,n+".innerGlow.blur",.12)}}return e.highlights!==void 0&&((!Array.isArray(e.highlights)||!e.highlights.length||e.highlights.length>4)&&a(n+".highlights","cần 1–4 nhóm từ"),t.highlights=e.highlights.map((r,s)=>{const o=`${n}.highlights[${s}]`;return m(r,o),g(r,["words","fill"],o),(!Array.isArray(r.words)||!r.words.length||r.words.length>40||r.words.some(f=>!Number.isInteger(f)||f<0||f>199))&&a(o+".words","số thứ tự từ 0–199"),{words:[...new Set(r.words)],fill:x(r.fill??"{accent}",o+".fill")}})),t}case"underline":return g(e,["type","fill","height","width","offsetY","opacity","line","style","lines","motion"],n),e.line!==void 0&&!["last","all"].includes(e.line)&&a(n+".line","last hoặc all"),e.style!==void 0&&!["bar","swash"].includes(e.style)&&a(n+".style","bar hoặc swash"),{type:"underline",fill:x(e.fill??"{accent}",n+".fill"),height:c(e.height,.02,.4,n+".height",.07),width:c(e.width,.1,1.4,n+".width",1),offsetY:c(e.offsetY,-1.2,1.2,n+".offsetY",.55),line:e.line||"last",...e.style==="swash"?{style:"swash"}:{},...i,...X(e,n)};case"shape":{g(e,["type","shape","box","fill","stroke","radius","skewX","rotate","blur","opacity","motion"],n),["rect","ellipse","glow"].includes(e.shape)||a(n+".shape","rect/ellipse/glow");const t={type:"shape",shape:e.shape,box:je(e.box,n+".box"),radius:c(e.radius,0,.5,n+".radius",0),skewX:c(e.skewX,-45,45,n+".skewX",0),rotate:c(e.rotate,-180,180,n+".rotate",0),blur:c(e.blur,0,.2,n+".blur",0),...i};if(e.fill!==void 0&&(t.fill=x(e.fill,n+".fill")),e.stroke!==void 0){const r=m(e.stroke,n+".stroke");g(r,["color","width","dash"],n+".stroke"),t.stroke={color:u(r.color??"{accent}",n+".stroke.color"),width:c(r.width,.5,12,n+".stroke.width",1.5)},r.dash!==void 0&&((!Array.isArray(r.dash)||r.dash.length!==2)&&a(n+".stroke.dash","[nét, khoảng]"),t.stroke.dash=r.dash.map((s,o)=>c(s,1,60,`${n}.stroke.dash[${o}]`)))}return!t.fill&&!t.stroke&&a(n,"shape cần fill hoặc stroke"),e.motion!==void 0&&(t.motion=H(e.motion,n+".motion")),t}case"icon":{g(e,["type","name","center","size","color","width","badge","badgeFill","badgeStroke","glow","rotate","opacity","motion"],n),we.includes(e.name)||a(n+".name","icon không có trong bộ dựng sẵn"),(!Array.isArray(e.center)||e.center.length!==2)&&a(n+".center","[x, y]"),e.badge!==void 0&&!["none","circle","square","rounded","diamond"].includes(e.badge)&&a(n+".badge","none/circle/square/rounded/diamond");const t={type:"icon",name:e.name,center:e.center.map((r,s)=>c(r,-.2,1.2,`${n}.center[${s}]`)),size:c(e.size,.02,.4,n+".size",.12),color:u(e.color??"{accent}",n+".color"),width:c(e.width,.5,4,n+".width",2),badge:e.badge??"none",rotate:c(e.rotate,-180,180,n+".rotate",0),glow:c(e.glow,0,1,n+".glow",0),...i};return e.badgeFill!==void 0&&(t.badgeFill=u(e.badgeFill,n+".badgeFill")),e.badgeStroke!==void 0&&(t.badgeStroke=u(e.badgeStroke,n+".badgeStroke")),e.motion!==void 0&&(t.motion=H(e.motion,n+".motion")),t}case"texture":return g(e,["type","pattern","mode","color","scale","size","angle","fade","fadeAngle","opacity"],n),z.includes(e.pattern)||a(n+".pattern",z.join("/")),e.mode!==void 0&&!B.includes(e.mode)&&a(n+".mode",B.join("/")),{type:"texture",pattern:e.pattern,mode:e.mode??"atop",color:u(e.color??"#000000",n+".color"),scale:c(e.scale,2,60,n+".scale",8),size:c(e.size,.05,1,n+".size",.5),angle:c(e.angle,-90,90,n+".angle",45),fade:c(e.fade,0,1,n+".fade",0),fadeAngle:c(e.fadeAngle,-180,180,n+".fadeAngle",90),...i};default:a(n+".type","chỉ hỗ trợ box, text, underline, shape, icon, texture")}}const ie=[400,500,600,700,800,900],Ie=["left","center","right"];function Ne(e,n){return m(e,n),g(e,["scale","fill","font","italic","weight","tracking","stretch","x","y","rotate","align","side","label","labelEn"],n),e.align!==void 0&&!Ie.includes(e.align)&&a(n+".align","left/center/right"),e.side!==void 0&&!["left","right"].includes(e.side)&&a(n+".side","left/right"),e.font!==void 0&&!de(e.font)&&a(n+".font","font không có trong danh sách Timeline hay font của bạn"),e.italic!==void 0&&typeof e.italic!="boolean"&&a(n+".italic","true/false"),e.weight!==void 0&&!ie.includes(e.weight)&&a(n+".weight","400–900"),e.stretch!==void 0&&!I.includes(e.stretch)&&a(n+".stretch",I.join("/")),{scale:c(e.scale,.2,3,n+".scale",1),...e.fill!==void 0?{fill:x(e.fill,n+".fill")}:{},...e.font!==void 0?{font:e.font}:{},...e.italic?{italic:!0}:{},...e.weight!==void 0?{weight:e.weight}:{},...e.tracking!==void 0?{tracking:c(e.tracking,-.15,.6,n+".tracking")}:{},...e.stretch!==void 0?{stretch:e.stretch}:{},...e.x!==void 0?{x:c(e.x,-4,4,n+".x")}:{},...e.y!==void 0?{y:c(e.y,-4,4,n+".y")}:{},...e.rotate!==void 0?{rotate:c(e.rotate,-30,30,n+".rotate")}:{},...e.align!==void 0?{align:e.align}:{},...e.side!==void 0?{side:e.side}:{},...e.label!==void 0?{label:D(e.label,24,n+".label",{required:!0})}:{},...e.labelEn!==void 0?{labelEn:D(e.labelEn,24,n+".labelEn",{required:!0})}:{}}}function an(e,n="design"){m(e,n),g(e,["weight","lineHeight","uppercase","layers","lines","stack","gap","stretch","tracking","shiftY","shiftX","maxWidth","wrap","linesFrom","path"],n),e.wrap!==void 0&&!["char","word"].includes(e.wrap)&&a(n+".wrap","char hoặc word"),e.linesFrom!==void 0&&!["start","end"].includes(e.linesFrom)&&a(n+".linesFrom","start hoặc end"),e.stack!==void 0&&!["center","ink"].includes(e.stack)&&a(n+".stack","center hoặc ink"),e.stretch!==void 0&&!I.includes(e.stretch)&&a(n+".stretch",I.join("/"));let i;return e.lines!==void 0&&((!Array.isArray(e.lines)||!e.lines.length||e.lines.length>8)&&a(n+".lines","cần 1–8 dòng"),i=e.lines.map((t,r)=>Ne(t,`${n}.lines[${r}]`))),(!Array.isArray(e.layers)||!e.layers.length||e.layers.length>G)&&a(n+".layers",`cần 1–${G} lớp`),e.layers.some(t=>t?.type==="text")||a(n+".layers","cần ít nhất 1 lớp text"),e.weight!==void 0&&!ie.includes(e.weight)&&a(n+".weight","400–900"),e.uppercase!==void 0&&typeof e.uppercase!="boolean"&&a(n+".uppercase","true/false"),{weight:e.weight??700,lineHeight:c(e.lineHeight,1.25,2,n+".lineHeight",1.32),uppercase:e.uppercase??!1,layers:e.layers.map((t,r)=>Fe(t,`${n}.layers[${r}]`)),...i?{lines:i}:{},...e.stack?{stack:e.stack}:{},...e.gap!==void 0?{gap:c(e.gap,0,.5,n+".gap")}:{},...e.stretch?{stretch:e.stretch}:{},...e.tracking!==void 0?{tracking:c(e.tracking,-.15,.6,n+".tracking")}:{},...e.shiftY!==void 0?{shiftY:c(e.shiftY,-.3,.3,n+".shiftY")}:{},...e.shiftX!==void 0?{shiftX:c(e.shiftX,-.3,.3,n+".shiftX")}:{},...e.maxWidth!==void 0?{maxWidth:c(e.maxWidth,.15,.9,n+".maxWidth")}:{},...e.wrap==="word"?{wrap:"word"}:{},...e.linesFrom==="end"?{linesFrom:"end"}:{},...e.path!=null?{path:se(e.path,n+".path")}:{}}}function fn(e,n,i){const t=e?.lines;if(t)return t[e.linesFrom==="end"?t.length-(i-n):n]}const U=["chars","charsNoSpace","words","lines"],W=["square","rampUp","rampDown","triangle","round","smooth"],V=["add","subtract","intersect"],K=["linear","easeIn","easeOut","easeInOut","hold"],Q=8,Xe=["start","end","offset","amount"],He=/^#[0-9a-f]{6}$/i,$={x:[-2e3,2e3],y:[-2e3,2e3],scale:[0,1e3],rotate:[-3600,3600],opacity:[0,100],tracking:[-200,500],fill:null,stroke:[0,50],strokeColor:null,blur:[0,200],skew:[-85,85]},Ce=(e,n,i,t)=>((!Array.isArray(e)||e.length>60)&&a(n,"cần mảng ≤ 60 key"),e.map((s,o)=>(m(s,`${n}[${o}]`),g(s,["time","value","ease"],`${n}[${o}]`),s.ease!==void 0&&!K.includes(s.ease)&&a(`${n}[${o}].ease`,K.join("/")),{time:c(s.time,0,600,`${n}[${o}].time`),value:c(s.value,i,t,`${n}[${o}].value`),...s.ease&&s.ease!=="linear"?{ease:s.ease}:{}})).sort((s,o)=>s.time-o.time));function Le(e,n){m(e,n);const i=e.type??"range";["range","wiggly"].includes(i)||a(n+".type","range/wiggly"),e.basedOn!==void 0&&!U.includes(e.basedOn)&&a(n+".basedOn",U.join("/")),e.mode!==void 0&&!V.includes(e.mode)&&a(n+".mode",V.join("/"));const t={type:i,basedOn:e.basedOn??"chars",mode:e.mode??(i==="wiggly"?"intersect":"add"),seed:c(e.seed,0,1e6,n+".seed",1)};if(Number.isInteger(t.seed)||a(n+".seed","số nguyên"),i==="wiggly")return g(e,["type","basedOn","mode","seed","maxAmount","minAmount","wiggles","correlation"],n),{...t,maxAmount:c(e.maxAmount,-100,100,n+".maxAmount",100),minAmount:c(e.minAmount,-100,100,n+".minAmount",-100),wiggles:c(e.wiggles,0,30,n+".wiggles",2),correlation:c(e.correlation,0,100,n+".correlation",50)};g(e,["type","basedOn","mode","seed","start","end","offset","amount","shape","easeHigh","easeLow","smoothness","random","keys","loop"],n),e.shape!==void 0&&!W.includes(e.shape)&&a(n+".shape",W.join("/")),e.random!==void 0&&typeof e.random!="boolean"&&a(n+".random","true/false"),e.loop!==void 0&&typeof e.loop!="boolean"&&a(n+".loop","true/false");const r={...t,start:c(e.start,0,100,n+".start",0),end:c(e.end,0,100,n+".end",100),offset:c(e.offset,-200,200,n+".offset",0),amount:c(e.amount,-100,100,n+".amount",100),shape:e.shape??"square",easeHigh:c(e.easeHigh,-100,100,n+".easeHigh",0),easeLow:c(e.easeLow,-100,100,n+".easeLow",0),smoothness:c(e.smoothness,0,100,n+".smoothness",100),random:e.random===!0,...e.loop===!0?{loop:!0}:{}};if(e.keys!==void 0&&e.keys!==null){m(e.keys,n+".keys"),g(e.keys,Xe,n+".keys");const s={};for(const[o,f]of Object.entries(e.keys)){const l=o==="offset"?[-200,200]:o==="amount"?[-100,100]:[0,100],d=Ce(f,`${n}.keys.${o}`,l[0],l[1]);d.length&&(s[o]=d)}Object.keys(s).length&&(r.keys=s)}return r}function Re(e,n="animator"){m(e,n),g(e,["name","properties","selectors"],n),e.name!==void 0&&(typeof e.name!="string"||e.name.length>40)&&a(n+".name","chuỗi ≤ 40 ký tự");const i=m(e.properties??{},n+".properties");g(i,Object.keys($),n+".properties");const t={};for(const[s,o]of Object.entries(i))o!=null&&($[s]?t[s]=c(o,$[s][0],$[s][1],`${n}.properties.${s}`):((typeof o!="string"||!He.test(o))&&a(`${n}.properties.${s}`,"#RRGGBB"),t[s]=o.toLowerCase()));Object.keys(t).some(s=>s!=="strokeColor")||a(n+".properties","cần ít nhất 1 thuộc tính");const r=e.selectors??[{}];return(!Array.isArray(r)||!r.length||r.length>4)&&a(n+".selectors","cần 1–4 selector"),{...e.name?{name:e.name}:{},properties:t,selectors:r.map((s,o)=>Le(s,`${n}.selectors[${o}]`))}}function Ze(e,n="animators"){return e==null?[]:((!Array.isArray(e)||e.length>Q)&&a(n,`cần mảng ≤ ${Q} animator`),e.map((i,t)=>Re(i,`${n}[${t}]`)))}const J=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter("vi",{granularity:"grapheme"}):null;function Ye(e){const n=String(e??"").normalize("NFC");if(J)return Array.from(J.segment(n),t=>t.segment);const i=[];for(const t of Array.from(n))i.length&&/\p{M}/u.test(t)?i[i.length-1]+=t:i.push(t);return i}function dn(e){const n=[];let i=0,t=-1,r=-1;return e.forEach((s,o)=>{let f=!1;for(const l of Ye(s)){const d=!/\S/u.test(l);d?f=!1:(t++,f||(r++,f=!0)),n.push({row:o,text:l,space:d,chars:i++,charsNoSpace:Math.max(0,t),words:Math.max(0,r),lines:o})}}),{units:n,counts:{chars:i,charsNoSpace:t+1,words:r+1,lines:e.length}}}const _e={linear:e=>e,easeIn:e=>e*e*e,easeOut:e=>1-(1-e)**3,easeInOut:e=>e<.5?4*e**3:1-(-2*e+2)**3/2};function E(e,n,i,t=!1){if(!e?.length)return i;if(t&&e.length>1){const r=e[0].time,s=e.at(-1).time-r;s>1e-6&&n>r&&(n=r+(n-r)%s)}if(n<=e[0].time)return e[0].value;for(let r=1;r<e.length;r++){const s=e[r-1],o=e[r];if(n<=o.time){if(s.ease==="hold")return s.value;const f=(n-s.time)/Math.max(1e-9,o.time-s.time);return s.value+(o.value-s.value)*_e[s.ease??"linear"](f)}}return e.at(-1).value}const Pe=e=>()=>{e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296},j=new Map;function Ge(e,n){const i=e+":"+n;let t=j.get(i);if(t)return t;const r=Pe(n*7919+17);t=[...Array(e).keys()];for(let s=e-1;s>0;s--){const o=Math.floor(r()*(s+1));[t[s],t[o]]=[t[o],t[s]]}return j.size>200&&j.clear(),j.set(i,t),t}const M=e=>Math.min(1,Math.max(0,e));function ze(e,n,i){const t=n/100,r=i/100;return e=t>=0?e**(1+2*t):1-(1-e)**(1-2*t),r>=0?1-(1-e)**(1+2*r):e**(1-2*r)}function Be(e,n,i,t){if(i<=0)return 0;const r=e.random?Ge(i,e.seed)[n]:n,s=e.keys||{},o=!!e.loop,f=E(s.start,t,e.start,o)/100,l=E(s.end,t,e.end,o)/100,d=E(s.offset,t,e.offset,o)/100,b=E(s.amount,t,e.amount,o)/100,k=Math.min(f,l)+d,L=Math.max(f,l)+d;let h;if(e.shape==="square"){const S=r/i,O=(r+1)/i,y=M((Math.min(O,L)-Math.max(S,k))*i),N=e.smoothness/100;h=N>=1?y:N<=0?y>.5+1e-9?1:y<.5-1e-9?0:.5:M((y-.5)/N+.5)}else{const S=(r+.5)/i,O=L-k,y=O>1e-9?(S-k)/O:S<k?-1:2;e.shape==="rampUp"?h=M(y):e.shape==="rampDown"?h=1-M(y):y<0||y>1?h=0:e.shape==="triangle"?h=1-Math.abs(2*y-1):e.shape==="round"?h=Math.sqrt(Math.max(0,1-(2*y-1)**2)):h=(1-Math.cos(2*Math.PI*y))/2}return(e.easeHigh||e.easeLow)&&(h=ze(M(h),e.easeLow,e.easeHigh)),h*b}const v=(e,n)=>{const i=Math.sin(e*127.1+n*311.7)*43758.5453;return(i-Math.floor(i))*2-1},ee=(e,n)=>{const i=Math.floor(e),t=e-i,r=t*t*(3-2*t);return v(i,n)*(1-r)+v(i+1,n)*r};function De(e,n,i,t){const r=t*e.wiggles,s=e.correlation/100,o=s*ee(r,e.seed)+(1-s)*ee(r+n*3.17,e.seed+1+n*13.7);return(e.minAmount+(o+1)/2*(e.maxAmount-e.minAmount))/100}function qe(e,n,i,t){let r=0;return e.selectors.forEach((s,o)=>{const f=i[s.basedOn],l=n[s.basedOn],d=s.type==="wiggly"?De(s,l,f,t):Be(s,l,f,t);r=o===0?d:s.mode==="intersect"?r*d:s.mode==="subtract"?r-d:r+d}),Math.max(-1,Math.min(1,r))}const Ue=Object.freeze({x:0,y:0,scale:1,rotate:0,opacity:1,tracking:0,blur:0,skew:0,stroke:0,strokeColor:null,fill:null,fillAmount:0}),We=(e,n,i)=>{const t=parseInt(e.slice(1),16),r=parseInt(n.slice(1),16);return"#"+[16,8,0].map(s=>Math.round((t>>s&255)+((r>>s&255)-(t>>s&255))*i).toString(16).padStart(2,"0")).join("")};function ln(e,n,i){const{units:t,counts:r}=n;return t.map(s=>{const o={...Ue};for(const f of e){const l=qe(f,s,r,i);if(Math.abs(l)<1e-6)continue;const d=f.properties;if(d.x&&(o.x+=d.x*l),d.y&&(o.y+=d.y*l),d.rotate&&(o.rotate+=d.rotate*l),d.tracking&&(o.tracking+=d.tracking*l),d.blur&&(o.blur+=d.blur*l),d.skew&&(o.skew+=d.skew*l),d.stroke&&(o.stroke+=d.stroke*l,o.strokeColor=d.strokeColor??o.strokeColor??"#000000"),d.scale!==void 0&&(o.scale*=Math.max(0,1+(d.scale/100-1)*l)),d.opacity!==void 0&&(o.opacity*=M(1+(d.opacity/100-1)*l)),d.fill){const b=M(Math.abs(l));o.fill=o.fill?We(o.fill,d.fill,b):d.fill,o.fillAmount=o.fillAmount+(1-o.fillAmount)*b}}return o.blur=Math.max(0,o.blur),o.stroke=Math.max(0,o.stroke),o})}const Ve=e=>Math.round(e*1e3)/1e3,Ke=e=>Ve(Math.max(.3,Math.min(1.6,(e||2)*.5))),w=(e,n,i,t)=>[{time:0,value:e,...t?{ease:t}:{}},{time:i,value:n}],C={"type-on":e=>[{name:"Type on",properties:{opacity:0},selectors:[{basedOn:"chars",shape:"square",smoothness:0,start:0,end:100,keys:{start:w(0,100,e)}}]}],"fade-up-chars":e=>[{name:"Fade up",properties:{opacity:0,y:18},selectors:[{basedOn:"charsNoSpace",shape:"rampUp",start:0,end:25,keys:{offset:w(-25,100,e,"easeOut")}}]}],"cascade-bottom":e=>[{name:"Cascade",properties:{y:160,opacity:0,rotate:12},selectors:[{basedOn:"charsNoSpace",shape:"rampUp",start:0,end:35,easeHigh:60,keys:{offset:w(-35,100,e,"easeOut")}}]}],"scale-pop-words":e=>[{name:"Pop in",properties:{scale:0,opacity:0},selectors:[{basedOn:"words",shape:"rampUp",start:0,end:20,keys:{offset:w(-20,100,e)}}]},{name:"Overshoot",properties:{scale:135},selectors:[{basedOn:"words",shape:"triangle",start:0,end:30,keys:{offset:w(-45,100,e)}}]}],"blur-in":e=>[{name:"Blur in",properties:{blur:22,opacity:0,scale:125},selectors:[{basedOn:"charsNoSpace",shape:"rampUp",start:0,end:40,keys:{offset:w(-40,100,e,"easeOut")}}]}],"tracking-in":e=>[{name:"Tracking in",properties:{tracking:48,opacity:0},selectors:[{basedOn:"chars",shape:"square",start:0,end:100,keys:{amount:w(100,0,e,"easeOut")}}]}],"random-fade":e=>[{name:"Random fade",properties:{opacity:0},selectors:[{basedOn:"charsNoSpace",shape:"square",random:!0,seed:7,start:0,end:100,keys:{start:w(0,100,e)}}]}],wave:e=>[{name:"Wave",properties:{y:-28},selectors:[{basedOn:"chars",shape:"smooth",start:0,end:34,loop:!0,keys:{offset:w(-34,100,Math.max(1.2,Math.min(2.4,e*2)))}}]}]},Qe=Object.freeze(Object.keys(C));function gn(e,n=2){return Object.hasOwn(C,e)||a("preset",Qe.join("/")),Ze(C[e](Ke(n)),`preset.${e}`)}export{he as A,U as B,tn as C,$e as H,Q as M,$ as P,rn as R,W as S,oe as T,Ae as a,Qe as b,V as c,m as d,g as e,a as f,ae as g,en as h,ne as i,an as j,E as k,fn as l,ue as m,c as n,sn as o,gn as p,de as q,Re as r,D as s,Ze as t,ve as u,nn as v,dn as w,ln as x,on as y,cn as z};
@@ -1 +0,0 @@
1
- import{b$ as E,eO as M,eP as D,lN as F,eQ as v}from"./titleFrameBudget-Cml-MO53.js";import{T as P}from"./timeline3d-YIIk_Kn2.js";import{wantsFrame as u,SKIPPED_FRAME as C}from"./frameSink-BGRj7wqY.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./api-QBI5GJTZ.js";import"./RoomEnvironment-Dmv_G5ka.js";const d=6;async function B(p,w,a,g,f){const{width:s,height:m,fps:r}=E(w),b=M(D(p));for(const e of p.filter(l=>l.kind==="model")){if(!u(a,"modelFrames",e.id))continue;if(!e.gcsUri&&!e.device)throw Error("Clip 3D chưa có GLB");const l=Math.ceil(e.duration*r);if(l>3600)throw Error("Mỗi clip 3D tối đa 2 phút khi xuất MP4. Hãy chia clip dài thành nhiều đoạn.");const o=new P(s,m),h=e.modelLook?F(e.modelLook).blur:e.motionBlur?.5:0,c=h>0?Object.assign(document.createElement("canvas"),{width:s,height:m}):null,t=c?.getContext("2d");try{e.device?await o.loadDevice(e):await o.load(e.gcsUri);for(let i=0;i<l;i++){if(g?.aborted)throw new DOMException("Export cancelled","AbortError");if(!u(a,"modelFrames",e.id,i)){await a.push("modelFrames",e.id,C);continue}if(v(b),await o.prepare(i/r),c&&t){t.globalCompositeOperation="copy",t.clearRect(0,0,s,m),t.globalCompositeOperation="lighter",t.globalAlpha=1/d;for(let n=0;n<d;n++){const x=Math.max(0,Math.min(e.duration,i/r+(n/(d-1)-.5)*h/r));o.render(e,x,!1,f),t.drawImage(o.canvas,0,0)}t.globalAlpha=1,t.globalCompositeOperation="source-over",await a.push("modelFrames",e.id,await o.frame(c))}else o.render(e,i/r,!1,f),await a.push("modelFrames",e.id,await o.frame());i%8===0&&await new Promise(n=>setTimeout(n,0))}}finally{o.dispose()}}}export{B as render3DFrames};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/userFonts-BHduCNtc.js","assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js","assets/store-2zneEhhu.js","assets/textAnimators-Bdt5LWXk.js"])))=>i.map(i=>d[i]);
2
- import{_ as st,mH as rt}from"./titleFrameBudget-Cml-MO53.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 He,A as pt,C as ut,a as gt}from"./textAnimators-Bdt5LWXk.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,Ue=()=>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=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??=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 qe(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 q=He(s,N,P.length);let o=n*(q?.scale??1)*T;if(Te(e,s,o,p,q),h){const c=u?i*T:i,a=e.measureText(m||" ").width;a>c&&(o*=c/a,Te(e,s,o,p,q))}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:N,size:o,fill:q?.fill,style:q,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 q=w[m];N&&(j+=k[m]),q.center=j+d[m]/2,j+=d[m];const o=q.style?.align??g;q.left=o==="left"?L:o==="right"?L+E-q.width:L+(E-q.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 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=He(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 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,Y=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,Y,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):_,E=(o,A,y,c,a,te)=>typeof o=="string"?be(i(o),te):qe(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=>Y[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,N=ce&&m?Ne(ce,m,r.time):null,q=[];if(m){let o=0;for(let A=0;A<u.length;A++)q.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,H=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,H),e.beginPath(),e.roundRect(D,$,ee,O,o.radius*n),e.fill(),o.stroke&&(e.strokeStyle=be(i(o.stroke.color),H),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,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,H=o.padY*a.size,G=a.left-O,B=a.center-d(c)/2-H,J=a.width+O*2,fe=d(c)+H*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,H=ge(a),G=H==="left"?a.left:H==="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 H=a.left,G=a.width;if(O!==a.text){G=e.measureText(O).width;const S=ge(a);H=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:H+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,R=H-C+(G+C*2)*U,Q=S.angle*Math.PI/180,Z=i(S.color);we=e.createLinearGradient(R-C*Math.cos(Q),a.center-C*Math.sin(Q),R+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)=>E(S,H+B,tt,G,d(c),X),at=o.reflection?P(a)+J+e.measureText(O).actualBoundingBoxDescent:0,ke=(S,X,U,C)=>{const R=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,R),e.fillStyle="#37eaff",e.fillText(S,X+B-oe,R),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,R)),e.fillStyle=ot(Q,U),e.fillText(S,X+B,R),o.innerGlow){const Z=e.getTransform();Ct(e,oe=>oe.fillText(S,X+B,R),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,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 Ae=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),U=q[c],C=W(a);let R=0;for(let V=0;V<S.length;V++)R+=N[U+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[U+V],pe=a.left+X[V],ye=X[V+1]-X[V],Ee=!/\S/u.test(S[V]),ie=Ee?null:C[$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(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,H,$);else{const S=new Map;for(const C of W(a)){const R=Ae+C.word,Q=S.get(R);S.set(R,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,H,$),e.restore();for(const[C,R]of X)e.save(),e.beginPath(),e.rect(R.x0+B-U,-1e5,R.x1-R.x0+U*2,2e5),e.clip(),ke(O,H,$,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 R=$;ze&&(R*=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&&(R*=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,R,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=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=qe(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-BHduCNtc.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 +0,0 @@
1
- import{b$ as T,eO as ot,eP as rt,lX as nt,eT as B,lY as it,ea as st,eU as lt,eQ as H,ec as V,eS as X,eX as Q,eW as q,eY as z,eV as Z}from"./titleFrameBudget-Cml-MO53.js";import{l as ht,d as dt}from"./titleArt-hb_T45WJ.js";import{i as R,j as ct,s as k,d as P,l as mt,k as Y,f as ft,e as j,a as ut,p as pt,t as wt,m as tt}from"./lottieLayer-CDCGeJyv.js";import{wantsFrame as G,SKIPPED_FRAME as gt}from"./frameSink-BGRj7wqY.js";import{t as J}from"./api-QBI5GJTZ.js";import"./textAnimators-Bdt5LWXk.js";import"./rigTrack-CUt4O67J.js";const xt=e=>X(e.title)||!!e.shape||!!e.motion||!!e.lottie||!!e.card||!!e.geo,N=e=>e.kind==="image"&&!!e.title?.text&&!e.url&&!X(e.title),D=4,U=192*1024*1024,g=new Map;let A=0;function Et(e,s){if(e.geo||e.shape&&R(e.shape)||e.pin?.scene||e.space)return null;const{start:i,track:h,...n}=e;return JSON.stringify([s,n])}function Mt(e,s){const i=s.reduce((h,n)=>h+n.length,0);if(!(i>U/4)){g.delete(e),g.set(e,{frames:s,bytes:i}),A+=i;for(const[h,n]of g){if(A<=U)break;g.delete(h),A-=n.bytes}}}function Tt(){g.clear(),A=0}const bt=e=>new Promise((s,i)=>e.toBlob(h=>{if(!h)return i(Error("Cannot encode title frame"));const n=new FileReader;n.onload=()=>s(String(n.result).slice(String(n.result).indexOf(",")+1)),n.onerror=()=>i(n.error),n.readAsDataURL(h)},"image/webp",.9));async function Pt(e,s,i,h,n){const{fps:o,width:f,height:S}=T(s),u=T({...s,resolution:"720p"}),y=e.some(t=>t.shape&&R(t.shape))?ot(rt(e)):null,$=!!i.wants;for(const t of e.filter(d=>(xt(d)||N(d))&&!d.warped)){if(!G(i,"titleFrames",t.id))continue;const d=a=>G(i,"titleFrames",t.id,a),c=Et(t,s),r=c?g.get(c):void 0;if(r){g.delete(c),g.set(c,r);for(const a of r.frames){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");await i.push("titleFrames",t.id,a)}continue}const x=[],E=t.title,M=nt(t)||N(t)?1:Math.ceil(t.duration*o);if(M>1&&Math.ceil(t.duration*o)>3600)throw Error("Mỗi tiêu đề động / Motion tối đa 2 phút khi xuất MP4.");E&&!t.shape&&!t.motion&&!t.lottie&&!t.card&&!t.geo&&await ht(E);const b=t.card?await ct(t.card).catch(a=>{throw Error(J("Thẻ HTML “{0}”: {1}",[t.label,a.message]))}):null,[p,w]=b?[b.width,b.height]:t.geo?[u.width,u.height]:t.lottie?[B(t.lottie).W,B(t.lottie).H]:t.motion?[u.width,u.height]:t.shape?[k(t.shape).W,k(t.shape).H]:[1280,720],C=Object.assign(document.createElement("canvas"),{width:p,height:w}),F=C.getContext("2d");if(!F)throw Error("Canvas unavailable");let I="",O=null;const L=(a,l)=>tt({layer:`export:${a.id}`,motion:a.motion,t:Z(a,l/o),width:p,height:w,duration:z(a),fps:o,surface:a.pin?.scene?q(a,e,a.start+l/o,p,w):null,space:a.space?(H(e),Q(a,e,a.start+l/o,p,w,n)):null}),m=[],W="\0same",_="\0skip",K=t.shape&&!t.motion&&!t.card&&!t.lottie&&!t.geo&&!R(t.shape)?it(t.shape):null,et=K==null?1/0:Math.max(K,...["trimStart","trimEnd"].flatMap(a=>st(t,a).map(l=>l.time))),v=async()=>{const a=await m.shift();if(a===_){await i.push("titleFrames",t.id,gt);return}if(a===W||a===I){x.push("="),await i.push("titleFrames",t.id,"=");return}I=a,x.push(a),await i.push("titleFrames",t.id,a)};try{for(let a=0;a<M;a++){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");if(!d(a)){m.push(Promise.resolve(_)),m.length>=D&&await v();continue}if(!$&&a>0&&(a-1)/o>et+1e-6){m.push(Promise.resolve(W)),m.length>=D&&await v();continue}if(F.clearRect(0,0,p,w),t.motion){let l;try{l=await(O??L(t,a)),O=a+1<M&&d(a+1)?L(t,a+1):null}catch(at){throw O?.catch(()=>{}),P(`export:${t.id}`),Error(`Motion “${t.label}”: ${at.message}`)}F.drawImage(l,0,0),l.close()}else if(t.lottie)try{await mt(`export:${t.id}`,t.url,{W:p,H:w},lt(t,a/o),C)}catch(l){throw Y(`export:${t.id}`),Error(`Lottie “${t.label}”: ${l.message}`)}else if(t.geo)try{await ft(`export:${t.id}`,t.geo,{W:p,H:w},a/o,C,{wait:2e4,duration:t.duration})}catch(l){throw j(`export:${t.id}`),Error(J("Bản đồ “{0}”: {1}",[t.label,l.message]))}else b?F.drawImage(b,0,0):t.shape?(y&&H(y),ut(F,pt(t,e,a/o,f,S),{start:V(t,"trimStart",a/o),end:V(t,"trimEnd",a/o),offset:wt(t.shape)},p,w,a/o)):dt(F,E,{time:a/o,duration:t.duration});m.push(bt(C)),m.length>=D&&await v()}for(;m.length;)await v();c&&!$&&Mt(c,x)}finally{for(const a of m)a.catch(()=>{})}t.motion&&P(`export:${t.id}`),t.lottie&&Y(`export:${t.id}`),t.geo&&j(`export:${t.id}`)}}function Ot(e,s,i,h){const{fps:n}=T(i),{width:o,height:f}=T({...i,resolution:"720p"}),S=Math.ceil(e.duration*n)-1,u=Object.assign(document.createElement("canvas"),{width:o,height:f}),y=u.getContext("2d");if(!y)throw Error("Canvas unavailable");const $=r=>tt({layer:`export:${e.id}`,motion:e.motion,t:Z(e,r/n),width:o,height:f,duration:z(e),fps:n,surface:e.pin?.scene?q(e,s,e.start+r/n,o,f):null,space:e.space?(H(s),Q(e,s,e.start+r/n,o,f,h)):null});let t=null,d=-1;const c=r=>{r?.p.then(x=>x.close(),()=>{})};return{W:o,H:f,async frame(r){if(r=Math.max(0,Math.min(S,r)),r===d)return u;for(;t&&t.i<r;){const M=t;t=null,await M.p.then(b=>b.close(),()=>{})}const x=t&&t.i===r?t.p:$(r);t&&t.i!==r&&c(t),t=null;let E;try{E=await x}catch(M){throw P(`export:${e.id}`),Error(`Motion “${e.label}”: ${M.message}`)}return t=r<S?{i:r+1,p:$(r+1)}:null,y.clearRect(0,0,o,f),y.drawImage(E,0,0),E.close(),d=r,u},close(){c(t),t=null,P(`export:${e.id}`)}}}export{Tt as clearFrameCache,Et as frameCacheKey,Ot as liveMotion,Pt as renderTitleFrames};
@@ -1 +0,0 @@
1
- import{iu as pt,iv as Y,fg as ut,ff as mt,fi as Z,fk as B,hz as kt,b as gt,fl as bt,fv as tt,fw as et,hv as Mt,fM as yt,hy as wt}from"./remote-BJdzzFZg.js";import{F as vt}from"./rigTrack-CUt4O67J.js";const P=t=>pt(t)??(Y(t)?{clip:Y(t),pack:{id:"fist"}}:null),st=Object.freeze({spear:{"spear-thrust":"thrust","spear-overhead":"high","spear-sweep":"low","spear-spin":"side","spear-dive-thrust":"thrust"},katana:{"katana-overhead":"high","katana-diagonal":"high","katana-horizontal":"side","katana-rising":"side","katana-thrust":"thrust","katana-spin-cut":"side"},staff:{"staff-jab":"thrust","staff-overhead":"high","staff-sweep":"low","staff-rising":"side","staff-spin":"side"},fist:{"fist-lunge-punch":"thrust","fist-rising-uppercut":"side","fist-flying-kick":"side","fist-ground-slam":"high","fist-low-lunge":"thrust"}}),it={high:"block-high",side:"block-side",thrust:"block-side",low:null},jt=Object.freeze({spear:1.42,katana:.98,staff:1.1,fist:0}),Ot={body:.05,blocked:.22,miss:.18},Ft=1.05,at=new Map,dt=t=>{let e=at.get(t);return e||(e=mt(P(t).clip),at.set(t,e)),e},Kt=(t,e)=>t[Math.max(0,Math.min(t.length-1,Math.round(e*30)))];function lt(t){const e=P(t).clip.keys.filter(a=>a.strike).at(-1);return e?e.t:0}const At=t=>P(t).clip.keys.filter(e=>e.strike).at(-1)?.limb??"handR",ot=(t,e)=>Kt(dt(t),e).dz??0;function $t(t){const{pack:e}=P(t),a=dt(t),l=lt(t),o=At(t);let f=0;for(const h of a){if(Math.abs(h.t-l)>.1)continue;if(e.id==="fist"){const j=vt(h.pose),m=j[o.replace("foot","toe")];f=Math.max(f,m[2]-j.pelvis[2]);continue}const r=ut(h.pose),u=r.front[2]+r.dir[2]*jt[e.id];f=Math.max(f,u)}return f}function St(t){let e=t>>>0||1;return()=>{e=e+1831565813>>>0;let a=Math.imul(e^e>>>15,1|e);return a=a+Math.imul(a^a>>>7,61|a)^a,((a^a>>>14)>>>0)/4294967296}}function Tt(t,e=4,a=1){const l=St(a),o=[];let f=0,h=["",""];for(let r=0;r<e;r++){r>0&&l()<.62&&(f=1-f);const u=t[f],j=t[1-f],m=Object.keys(st[u]).filter(S=>S!==h[f]),g=m[Math.floor(l()*m.length)],z=st[u][g];h[f]=g;const i=l();let y=r===e-1?"body":i<.5?"blocked":i<.78?"miss":"body";y==="blocked"&&!it[z]&&(y="miss");const $=`${j}-${y==="blocked"?it[z]:y==="miss"?"dodge-back":"hit"}`,D=lt(g),O=P($).clip.contact??0,b=Math.max(Ft,$t(g)+Ot[y]+ot(g,D)+ot($,O));o.push({attacker:f,attack:g,defence:$,result:y,strike:D,contact:O,gap:Math.round(b*1e3)/1e3})}return o}const q=[.18,.42],nt=t=>(t.kind==="model"?(t.model?.height??2)/1.8:Mt(t))*(t.scale[1]||1),x=t=>t*Math.PI/180,v=t=>t.shots.find(e=>e.id===t.activeShot);function rt(t,e){const a=v(t),l=a.duration/e,o=h=>h?.map(r=>({...r,time:Math.min(1,r.time*l)})),f={...a,duration:e,cameraKeys:o(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([h,r])=>[h,o(r)||[]])),...a.impacts?{impacts:o(a.impacts)}:{},...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([h,r])=>[h,o(r)||[]]))}:{}};return{...t,shots:t.shots.map(h=>h.id===a.id?f:h)}}const ct=(t,e,a)=>{const l=v(t);return{...t,shots:t.shots.map(o=>o.id===l.id?{...o,objectKeys:{...o.objectKeys,[e]:a(o.objectKeys?.[e]||[],o)}}:o)}},T=(t,e,a)=>{const l=v(t),o=yt(t.items.find(f=>f.id===e.id),l,Math.min(1,a/l.duration));return{position:o.position,yaw:o.rotation[1]}};function Pt(t,e,a){const l=t.items.find(s=>s.id===e.a),o=t.items.find(s=>s.id===e.b);if(!l||!o||!Z(l)||!Z(o))return{ok:!1,error:"two people are needed"};if(l.id===o.id)return{ok:!1,error:"two different people are needed"};const f=Math.max(1,Math.min(10,Math.round(e.exchanges))),h=Tt(e.packs,f,e.seed),r=[l,o],u=[nt(l),nt(o)],j=[],m=Math.max(0,e.start),g=v(t),z=m+.5+h.reduce((s,c)=>s+Math.max(B(c.attack).duration,c.strike-c.contact+B(c.defence).duration)+1.4+q[1],0);let i=z>g.duration?rt(t,Math.min(300,z)):t;const M=T(i,l,m),y=h[0].gap*(u[0]+u[1])/2,$=[Math.sin(x(M.yaw)),0,Math.cos(x(M.yaw))],D=[M.position[0]+$[0]*y,M.position[1],M.position[2]+$[2]*y];for(const[s,c,n]of[[l,M.position,M.yaw],[o,D,M.yaw+180]])i=ct(i,s.id,(d,k)=>[...d.filter(p=>p.time*k.duration<m-1e-6),{id:a(),time:m/k.duration,position:c.map(p=>+p.toFixed(3)),rotation:[0,+n.toFixed(1),0],scale:s.scale}]);const O=(s,c,n)=>{const d=v(i),k=B(c),p=wt(i,r[s].id,k,{start:n/d.duration,newId:a,loop:!1});if(!p.ok)throw new Error(`${r[s].name}: ${p.error}`);return i=p.stage,n+k.duration};let b=m+.35,S=m;const C=[];let H=(e.seed*9301+49297)%233280;const ht=()=>(H=(H*9301+49297)%233280,H/233280);try{h.forEach((s,c)=>{const n=s.attacker,d=1-n,k=(u[0]+u[1])/2,p=()=>{const F=T(i,r[0],b).position,K=T(i,r[1],b).position;return Math.hypot(K[0]-F[0],K[2]-F[2])};for(let F=0;F<3;F++){const K=p()-s.gap*k;if(Math.abs(K)<.3*k)break;K>0?b=O(n,`${e.packs[n]}-advance`,b):b=O(d,`${e.packs[d]}-retreat`,b)}const N=Math.max(0,s.contact-s.strike),w=b+N,_=w+s.strike-s.contact,E=p()-s.gap*k,G=O(n,s.attack,w),ft=O(d,s.defence,_),L=r[n],U=T(i,L,w).yaw,W=[Math.sin(x(U)),Math.cos(x(U))],J=w+s.strike,V=Math.max(-.3,Math.min(.3,E));i=ct(i,L.id,(F,K)=>F.map(A=>{const I=A.time*K.duration;if(I<w-1e-6||I>G+1e-6)return A;const R=Math.min(1,(I-w)/Math.max(.001,s.strike)),Q=R*R*(3-2*R),X={...A,position:[+(A.position[0]+W[0]*V*Q).toFixed(3),A.position[1],+(A.position[2]+W[1]*V*Q).toFixed(3)]};return A.strike&&Math.abs(I-J)<.06?{...X,hit:s.result}:X})),C.push({...s,time:+J.toFixed(2),attackerName:L.name}),S=Math.max(G,ft),b=S+q[0]+(q[1]-q[0])*ht(),c===h.length-1&&j.push(`${r[d].name} dính đòn kết`)})}catch(s){return{ok:!1,error:s.message}}if(v(i).duration>g.duration&&(i=rt(i,Math.max(g.duration,Math.min(300,Math.ceil((S+.6)*10)/10)))),i=kt(i).stage,e.packs.includes("fist")){const s=v(i),c=[],n={};C.forEach((d,k)=>{if(d.result==="miss"||e.packs[d.attacker]!=="fist")return;const p=T(i,r[0],d.time).position,N=T(i,r[1],d.time).position,w=(u[0]+u[1])/2,_=`duelfx-${r[d.attacker].id}-${Math.round(d.time*1e3)}`,E=d.result==="body";c.push({...gt("fx",i.items.length+c.length),id:_,name:`Vòng xung kích ${c.length+1}`,position:[+((p[0]+N[0])/2).toFixed(2),0,+((p[2]+N[2])/2).toFixed(2)],color:E?"#ffd27a":"#9fdcff",fx:{preset:"vong_xung_kich",cat:"vong-xung-kich",intensity:E?.9:.75,seed:500+k,start:d.time,duration:.6,loop:!1,auto:"hit",params:{size:(E?1.05:.85)*w,height:+(1.35*w).toFixed(2),hits:1,gap:.3}}}),n[_]={start:d.time,duration:.6}}),c.length&&(i={...i,items:[...i.items,...c],shots:i.shots.map(d=>d.id===s.id?{...d,fxTiming:{...d.fxTiming,...n}}:d)})}if(e.hitStops!==!1){const s=v(i);let c=bt(s.timing,s.duration);c=tt(c,C.filter(n=>n.result==="blocked").map(n=>n.time),et.light,s.duration),c=tt(c,C.filter(n=>n.result==="body").map(n=>n.time),et.heavy,s.duration),i={...i,shots:i.shots.map(n=>n.id===s.id&&c?{...n,timing:c}:n)}}return{ok:!0,stage:i,plan:C,end:+S.toFixed(2),notes:j}}export{st as D,Pt as s};