clipoox-render 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server-text/titleRaster.js +1394 -0
- package/package.json +5 -3
- package/scripts/render-local.mjs +1617 -1481
- package/shared/transitionStarterPack.json +261 -0
- package/web/assets/FxEmbed-D7k1ThAF.js +1 -0
- package/web/assets/{GLTFLoader-Dy6SrZg8.js → GLTFLoader-BHWu1lKg.js} +1 -1
- package/web/assets/MotionEmbed-DFni5IAh.js +1 -0
- package/web/assets/PluginStore-BrupM_8E.js +3 -0
- package/web/assets/{ShotComposer-AHScyNYv.js → ShotComposer-BLztjSKy.js} +4 -4
- package/web/assets/TemplateEmbed-BbAimhLj.js +2 -0
- package/web/assets/TimelinePlugins-BI1bE9pX.js +5 -0
- package/web/assets/TimelinePlugins-DYarX9RK.css +1 -0
- package/web/assets/TimelineShotFx-CQN3WIfN.js +2 -0
- package/web/assets/TransitionEmbed-CmoIrHVr.js +1 -0
- package/web/assets/{Whiteboard-C9Mwa3nF.js → Whiteboard-DMk0unYK.js} +3 -3
- package/web/assets/aerial-DT_gUtSh.js +2 -0
- package/web/assets/agentTools-qOww5RUs.js +2 -0
- package/web/assets/analyzerRun-B2FLUp4G.js +1 -0
- package/web/assets/{analyzerSandbox-DQGHjUCa.js → analyzerSandbox-CJVsEhrg.js} +2 -2
- package/web/assets/{api-C5pOWyBM.js → api-QBI5GJTZ.js} +148 -148
- package/web/assets/auraTrack-CEs_Q9EP.js +1 -0
- package/web/assets/breakthrough-DvkxvNK9.js +2 -0
- package/web/assets/{cameraPresets-CeStHDvF.js → cameraPresets-4pFeF2YG.js} +1 -1
- package/web/assets/{captionLayout-BAdmqwdS.js → captionLayout-C67EMVI1.js} +1 -1
- package/web/assets/clientExport-C4VgAJtO.js +1 -0
- package/web/assets/{depthEstimate-1OjTo_pb.js → depthEstimate-mnXDZMW-.js} +1 -1
- package/web/assets/directorTools-BOHZjcww.js +1 -0
- package/web/assets/{distortFrames-D39fkQ_H.js → distortFrames-Csuj2jHE.js} +2 -2
- package/web/assets/{distortGL-5uNfls9s.js → distortGL-BaXfN0IK.js} +2 -2
- package/web/assets/editTools-m0VGPmfF.js +1 -0
- package/web/assets/{exportEncode-pFxeatJt.js → exportEncode-D9OT7_5k.js} +1 -1
- package/web/assets/exportGlb-CLfTnbMG.js +2 -0
- package/web/assets/faceTracker-W0iZSiMe.js +1 -0
- package/web/assets/fightDirector-CECPf2iH.js +1 -0
- package/web/assets/fightDrama-CqNoa5XI.js +2 -0
- package/web/assets/{frameSink-CB1EghW0.js → frameSink-BGRj7wqY.js} +3 -3
- package/web/assets/{gpuCompose-EfzSAeMh.js → gpuCompose-CIEoLFem.js} +1 -1
- package/web/assets/gpuExport-uyOAyrhm.js +190 -0
- package/web/assets/handMatte-mHxZwLZD.js +1 -0
- package/web/assets/handTracker-dTVeSUzt.js +2 -0
- package/web/assets/{index-BGZJld3s.js → index-D7M5t2re.js} +1 -1
- package/web/assets/layer-worker-Cp0pjurp.js +5 -0
- package/web/assets/library-Dsz_MLyd.js +1 -0
- package/web/assets/{lottieLayer-BhLbZOpr.js → lottieLayer-CDCGeJyv.js} +5 -5
- package/web/assets/{lottie_light_canvas-D9fsNLID.js → lottie_light_canvas-BblLU4nU.js} +1 -1
- package/web/assets/main-BQ8IY0WV.css +1 -0
- package/web/assets/{main-BNZrzSIG.js → main-CVRIuDW2.js} +76 -76
- package/web/assets/{mapBake-BAG6i5fI.js → mapBake-CNMOKXA7.js} +1 -1
- package/web/assets/maskTrack-Dtv6Jr06.js +1 -0
- package/web/assets/matteFixRun-BLDH2AjH.js +1 -0
- package/web/assets/motionBlur-uAm030t9.js +1 -0
- package/web/assets/{objectLocate-Dhktxe5z.js → objectLocate-Cy3IFBSF.js} +1 -1
- package/web/assets/{objectTrack.worker-ENzKeSiV.js → objectTrack.worker-BlZkgpOX.js} +483 -352
- package/web/assets/pendingMatte-C2AWApuv.js +2 -0
- package/web/assets/personAi-DPUnoymj.js +2 -0
- package/web/assets/plateCamera-C96L5GKm.js +1 -0
- package/web/assets/plateCameraMatch-Chk-ZjDi.js +2 -0
- package/web/assets/plateFollow-B9_QTgvo.js +2 -0
- package/web/assets/plateMatte-BiqyI_8x.js +2 -0
- package/web/assets/{pluginAutomation-DdZOnpoV.js → pluginAutomation-5DYldFrb.js} +1 -1
- package/web/assets/poseTracker-PuI8vWpR.js +1 -0
- package/web/assets/productTools-B1h5cgyt.js +2 -0
- package/web/assets/remote-BJdzzFZg.js +1241 -0
- package/web/assets/rigTrack-CUt4O67J.js +1 -0
- package/web/assets/{rotoMaskStore-DrRawyH9.js → rotoMaskStore-DIi45swK.js} +1 -1
- package/web/assets/{rotoMatte-2EcyuvBX.js → rotoMatte-013RKqHu.js} +1 -1
- package/web/assets/rotoscope-d_TUxa-J.js +1 -0
- package/web/assets/{sceneTrack.worker-CEvCN5OB.js → sceneTrack.worker-CT4uoTKn.js} +475 -344
- package/web/assets/shot-worker-B1iZT6F5.js +1 -0
- package/web/assets/{shotFxAgent-CETPcjzU.js → shotFxAgent-BDfe73TP.js} +2 -2
- package/web/assets/{skin-BQG1Iz6Q.js → skin-GDY3QPkV.js} +1 -1
- package/web/assets/{spark.module-CMSPLU2n.js → spark.module-DdwuJ_hb.js} +10 -10
- package/web/assets/spellDuel-DjNN00bv.js +2 -0
- package/web/assets/{store-Dxq3MZF3.js → store-2zneEhhu.js} +1 -1
- package/web/assets/{surfaceLight-B_OSTxcx.js → surfaceLight-B_SYg_f8.js} +1 -1
- package/web/assets/surfacePin-zDPmq-hH.js +2 -0
- package/web/assets/textAnimators-Bdt5LWXk.js +1 -0
- package/web/assets/{thumb-xLFX6lDN.js → thumb-byAKvhQP.js} +1 -1
- package/web/assets/timeline3d-YIIk_Kn2.js +2 -0
- package/web/assets/timeline3dExport-CEH1RjNf.js +1 -0
- package/web/assets/timelineComp-B73i_8vD.js +1 -0
- package/web/assets/timelineProps-B2pnudeT.js +1 -0
- package/web/assets/timelineText-BcL4Pw3C.js +1 -0
- package/web/assets/{titleArt-CAOxtyHl.js → titleArt-hb_T45WJ.js} +5 -5
- package/web/assets/{titleFrameBudget-BjW--v_T.js → titleFrameBudget-Cml-MO53.js} +970 -839
- package/web/assets/titleFrames-Dw0PEBdV.js +1 -0
- package/web/assets/{tool-DEWWeyCz.js → tool-Bt9bclIf.js} +1 -1
- package/web/assets/tools-BXeJbgZJ.js +1 -0
- package/web/assets/toonTools-u7Y9fdEZ.js +2 -0
- package/web/assets/trackAnchor-9MnVHe4S.js +1 -0
- package/web/assets/userFonts-BHduCNtc.js +1 -0
- package/web/assets/{vfxAlpha-vbbI-03F.js → vfxAlpha-DpV4rbI-.js} +2 -2
- package/web/assets/vfxBackground-Ddviync5.js +2 -0
- package/web/assets/videoExport-z5WjM0hw.js +1 -0
- package/web/assets/views-CsrYzCSR.js +1 -0
- package/web/assets/weaponDuel-CLLgv5A4.js +1 -0
- package/web/assets/{windowFrames-DydW5Al5.js → windowFrames-BQEWQkEs.js} +1 -1
- package/web/layer-worker.html +3 -3
- package/web/assets/FxEmbed-B5TQxKxk.js +0 -1
- package/web/assets/MotionEmbed-Catb_GgA.js +0 -1
- package/web/assets/PluginStore-8TjQawtB.js +0 -3
- package/web/assets/TemplateEmbed-Cao8Z5fY.js +0 -2
- package/web/assets/TimelinePlugins-B5WmAawO.css +0 -1
- package/web/assets/TimelinePlugins-CkP5P9b_.js +0 -5
- package/web/assets/TimelineShotFx-DvmPZQXM.js +0 -2
- package/web/assets/TransitionEmbed-o4UxJ35e.js +0 -1
- package/web/assets/aerial-BPRLPci2.js +0 -2
- package/web/assets/agentTools-CSnN-LvS.js +0 -2
- package/web/assets/analyzerRun-5zJsmMS1.js +0 -1
- package/web/assets/auraTrack-pF-WhpH3.js +0 -1
- package/web/assets/breakthrough-DQN1i-Pw.js +0 -2
- package/web/assets/clientExport-Ca9a3Jiy.js +0 -1
- package/web/assets/desktop-BWhFnYwd.js +0 -1
- package/web/assets/directorTools-CvmghG_6.js +0 -1
- package/web/assets/editTools-CUoVvupD.js +0 -1
- package/web/assets/exportGlb-MK05aKqH.js +0 -2
- package/web/assets/faceTracker-_rQOgBvX.js +0 -1
- package/web/assets/fightDirector-Dt60kfbV.js +0 -1
- package/web/assets/fightDrama-py4jxSdn.js +0 -2
- package/web/assets/gpuExport-Cnv2NfEb.js +0 -189
- package/web/assets/handMatte-DZCsuqD2.js +0 -1
- package/web/assets/handTracker-Btr9L-Hu.js +0 -2
- package/web/assets/layer-worker-Rbo-YZv-.js +0 -5
- package/web/assets/library-CdukL2BW.js +0 -1
- package/web/assets/main-By_IEoB_.css +0 -1
- package/web/assets/maskTrack-AZwAVz1c.js +0 -1
- package/web/assets/matteFixRun-wTHGiGGf.js +0 -1
- package/web/assets/pendingMatte-iKz2-XBZ.js +0 -2
- package/web/assets/personAi-BEVyjCii.js +0 -2
- package/web/assets/plateCamera-D_J3-X06.js +0 -1
- package/web/assets/plateCameraMatch-C0peOvBn.js +0 -2
- package/web/assets/plateFollow-BbJMVxfg.js +0 -2
- package/web/assets/plateMatte-u5wKpsUN.js +0 -2
- package/web/assets/poseTracker--VJYw-hX.js +0 -1
- package/web/assets/productTools-DbhbyJxx.js +0 -2
- package/web/assets/remote-DXG553d8.js +0 -1220
- package/web/assets/rigTrack-CW9_kg5j.js +0 -1
- package/web/assets/rotoscope-_CYT-9ry.js +0 -1
- package/web/assets/shot-worker-BxIzQRZh.js +0 -1
- package/web/assets/spellDuel-eZvRwaxi.js +0 -2
- package/web/assets/surfacePin-CfLBhSrm.js +0 -2
- package/web/assets/timeline3d-DqXTKdEK.js +0 -2
- package/web/assets/timeline3dExport-MWomW4fF.js +0 -1
- package/web/assets/timelineProps-KL6XCR4Q.js +0 -1
- package/web/assets/timelineText-DEK2BRyU.js +0 -1
- package/web/assets/titleFrames-WfiLHzjf.js +0 -1
- package/web/assets/tools-CBfIZX8_.js +0 -1
- package/web/assets/toonTools-D7jucq3t.js +0 -2
- package/web/assets/trackAnchor-DFqKIb8a.js +0 -1
- package/web/assets/userFonts-txN4I-eo.js +0 -1
- package/web/assets/vfxBackground-C1dHlJN6.js +0 -2
- package/web/assets/vfxTrack-BmxWjlDi.js +0 -1
- package/web/assets/videoExport-DiNI9GY1.js +0 -1
- package/web/assets/views-sH39zgjD.js +0 -1
- package/web/assets/weaponDuel-CEvRDeuE.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as o}from"./store-2zneEhhu.js";import{t as l,c as w}from"./api-QBI5GJTZ.js";import{l as v,d as C}from"./titleArt-hb_T45WJ.js";import{i as h}from"./textAnimators-Bdt5LWXk.js";import"./titleFrameBudget-Cml-MO53.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-
|
|
2
|
-
import{_ as st,
|
|
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,
|
|
4
|
-
`);P.forEach((m,
|
|
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-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};
|