asciify-engine 4.23.0 → 4.24.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 (87) hide show
  1. package/README.md +7 -0
  2. package/dist/core.cjs +1 -1
  3. package/dist/core.js +1 -1
  4. package/dist/field.cjs +1 -1
  5. package/dist/field.js +1 -1
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/kit/chunk-2CF4PX6U.js +1 -0
  9. package/dist/kit/chunk-2NVKPXPL.js +1 -0
  10. package/dist/kit/chunk-3473NPIN.js +1 -0
  11. package/dist/kit/chunk-3A5LID2G.js +1 -0
  12. package/dist/kit/chunk-3PCKMO6I.js +1 -0
  13. package/dist/kit/chunk-4HWMQCAM.js +1 -0
  14. package/dist/kit/chunk-4OT66HSZ.js +1 -0
  15. package/dist/kit/chunk-4QHFEMFS.js +1 -0
  16. package/dist/kit/chunk-4ZQFDFEH.js +1 -0
  17. package/dist/kit/chunk-5BEBNKYM.js +1 -0
  18. package/dist/kit/chunk-5I4IZTL5.js +1 -0
  19. package/dist/kit/chunk-5QE6UMXN.js +1 -0
  20. package/dist/kit/chunk-5Z2EJAUV.js +1 -0
  21. package/dist/kit/chunk-73M2OESE.js +1 -0
  22. package/dist/kit/chunk-7ABNWOW4.js +1 -0
  23. package/dist/kit/chunk-AIM3J2US.js +1 -0
  24. package/dist/kit/chunk-BN7HL52Z.js +1 -0
  25. package/dist/kit/chunk-BNVRKD3V.js +1 -0
  26. package/dist/kit/chunk-BQZCLGCY.js +1 -0
  27. package/dist/kit/chunk-BR6ZNJZW.js +1 -0
  28. package/dist/kit/chunk-BTD6EFAW.js +1 -0
  29. package/dist/kit/chunk-C3C7AYKL.js +1 -0
  30. package/dist/kit/chunk-C4KZYCPF.js +1 -0
  31. package/dist/kit/chunk-DFOWXOZR.js +1 -0
  32. package/dist/kit/chunk-DZ5XGHTJ.js +1 -0
  33. package/dist/kit/chunk-E3TUOX2A.js +1 -0
  34. package/dist/kit/chunk-ENTDGT2V.js +1 -0
  35. package/dist/kit/chunk-FR3ZJNOY.js +1 -0
  36. package/dist/kit/chunk-FUI5AVIF.js +1 -0
  37. package/dist/kit/chunk-G57QACJG.js +1 -0
  38. package/dist/kit/chunk-H2UZBVKE.js +1 -0
  39. package/dist/kit/chunk-HTUGMGVA.js +1 -0
  40. package/dist/kit/chunk-I4QVLLRQ.js +1 -0
  41. package/dist/kit/chunk-IPVN22ZM.js +1 -0
  42. package/dist/kit/chunk-IQTGJRDX.js +1 -0
  43. package/dist/kit/chunk-IUKSHYED.js +1 -0
  44. package/dist/kit/chunk-J2YZBT3N.js +1 -0
  45. package/dist/kit/chunk-K563CCOL.js +1 -0
  46. package/dist/kit/chunk-KWTF6Q5W.js +1 -0
  47. package/dist/kit/chunk-MGVPLQ3Z.js +1 -0
  48. package/dist/kit/chunk-MIZ2DUHU.js +1 -0
  49. package/dist/kit/chunk-MQJQIDO5.js +1 -0
  50. package/dist/kit/chunk-NURPDP3Y.js +1 -0
  51. package/dist/kit/chunk-O7SGY4YJ.js +1 -0
  52. package/dist/kit/chunk-OWEZV7TQ.js +1 -0
  53. package/dist/kit/chunk-PCIAA2LL.js +1 -0
  54. package/dist/kit/chunk-PFKYKAIP.js +1 -0
  55. package/dist/kit/chunk-PIU2BMFU.js +1 -0
  56. package/dist/kit/chunk-QALCXKU6.js +1 -0
  57. package/dist/kit/chunk-QRCXXS5Z.js +1 -0
  58. package/dist/kit/chunk-RFLIFKZ4.js +1 -0
  59. package/dist/kit/chunk-ROR6MG3K.js +1 -0
  60. package/dist/kit/chunk-S62H7ZIU.js +1 -0
  61. package/dist/kit/chunk-S7RZP2MT.js +1 -0
  62. package/dist/kit/chunk-SARCZMLN.js +1 -0
  63. package/dist/kit/chunk-SNCXU7KF.js +1 -0
  64. package/dist/kit/chunk-T3GWGPST.js +1 -0
  65. package/dist/kit/chunk-TTGMK4EA.js +1 -0
  66. package/dist/kit/chunk-UML6XQAR.js +1 -0
  67. package/dist/kit/chunk-UO7RB7RC.js +1 -0
  68. package/dist/kit/chunk-VC2ZQG63.js +1 -0
  69. package/dist/kit/chunk-VVW7LZT2.js +1 -0
  70. package/dist/kit/chunk-W2STAN6V.js +1 -0
  71. package/dist/kit/chunk-WJLZM3DR.js +1 -0
  72. package/dist/kit/chunk-XANKANGR.js +1 -0
  73. package/dist/kit/chunk-XB4DKPGL.js +1 -0
  74. package/dist/kit/chunk-XDKKCIIL.js +1 -0
  75. package/dist/kit/chunk-XM56OTYT.js +1 -0
  76. package/dist/kit/chunk-XPXMCXYI.js +1 -0
  77. package/dist/kit/chunk-YBRP6BFW.js +1 -0
  78. package/dist/kit/chunk-YCWMOTYH.js +1 -0
  79. package/dist/kit/chunk-ZCHGV2CV.js +1 -0
  80. package/dist/kit/chunk-ZRJVOUWH.js +1 -0
  81. package/dist/kit.cjs +1 -1
  82. package/dist/kit.js +1 -1
  83. package/dist/studio.cjs +1 -1
  84. package/dist/studio.js +1 -1
  85. package/package.json +2 -2
  86. package/skills/asciify-engine/SKILL.md +3 -3
  87. package/skills/asciify-engine/references/performance.md +30 -0
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var t={standard:{label:"Classic ASCII",chars:" .:-=+*#%@"},asciify:{label:"Asciify",chars:" .:-=+YCIFSA#@"},minimal:{label:"Minimal",chars:" .:+"},detailed:{label:"Detailed",chars:" .,:;-~=+*xX#%@"},letters:{label:"Letters",chars:" .liLTYCFSAWM"},technical:{label:"Technical",chars:" ._:;+/>=][{}*$#@"},blocks:{label:"Tonal blocks",chars:" ░▒▓█"},braille:{label:"Braille",chars:" ⠁⠃⠇⡇⣇⣧⣷⣿"}},e={dracula:{name:"Dracula",accent:"#bd93f9",bg:"#282a36",fg:"#f8f8f2"},monokai:{name:"Monokai",accent:"#a6e22e",bg:"#272822",fg:"#f8f8f2"},nord:{name:"Nord",accent:"#88c0d0",bg:"#2e3440",fg:"#eceff4"},catppuccin:{name:"Catppuccin",accent:"#cba6f7",bg:"#1e1e2e",fg:"#cdd6f4"},solarized:{name:"Solarized",accent:"#268bd2",bg:"#002b36",fg:"#839496"},gruvbox:{name:"Gruvbox",accent:"#b8bb26",bg:"#282828",fg:"#ebdbb2"}},n={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:t.standard.chars,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",fineDither:!1,customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},o={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},a={caustics:"sheen",grain:"shimmer",trace:"relight",tidal:"current",weave:"current",breeze:"current",reform:"develop",print:"develop",unfold:"develop"},r=[{value:"none",mode:"none",group:"Still",label:"Off",description:"Keep the image still. Hover stays available."},{value:"relight",mode:"relight",group:"Light",label:"Relight",description:"A key light circles the subject and models its own relief, like moving a lamp around a sculpture."},{value:"sheen",mode:"sheen",group:"Light",label:"Specular sweep",description:"One slow pass of light glances across the highlights and follows their form, then rests."},{value:"glow",mode:"glow",group:"Light",label:"Highlight bloom",description:"The brightest areas breathe a soft halo into their surroundings. Shadows stay deep."},{value:"shimmer",mode:"shimmer",group:"Light",label:"Glints",description:"Sparse glints on bright fine detail, like light on water, metal or an eye. Everything else holds still."},{value:"parallax",mode:"parallax",group:"Depth",label:"Parallax",description:"A slow camera drift: the subject moves against its background, read from the photo’s own depth cues."},{value:"push",mode:"push",group:"Depth",label:"Slow push",description:"A gentle push toward the subject and back, with nearer areas moving slightly more."},{value:"focus",mode:"focus",group:"Depth",label:"Focus pull",description:"Focus racks from the subject to the background and back; the characters soften out of focus."},{value:"mist",mode:"mist",group:"Atmosphere",label:"Mist",description:"Soft mist drifts through the distance and plain areas, leaving the subject clear."},{value:"current",mode:"current",group:"Atmosphere",label:"Drift",description:"Water swells and glints, falls stream down, sky and clouds drift slowly, like a cinemagraph. Subjects and buildings hold still."},{value:"develop",mode:"develop",group:"Reveal",label:"Develop",description:"The image holds, fades, then develops back in from its highlights to its shadows, like a print in the tray."}];var i=t=>Math.max(0,Math.min(1,t)),s=(t,e,n)=>{const o=i((n-t)/(e-t));return o*o*(3-2*o)},h=(t,e)=>{const n=(.06711056*t+.00583715*e)%1*52.9829189;return n-Math.floor(n)};function l(t){const e=Math.floor(t),n=Math.max(0,Math.min(1,(t-e-.2)/.6));return e+n*n*(3-2*n)}function c(t,e,n,o,a){if(!(a<1))for(let r=0;r<2;r++){for(let r=0;r<o;r++){let o=0;const i=r*n;for(let e=-a;e<=a;e++)o+=t[i+Math.max(0,Math.min(n-1,e))];for(let r=0;r<n;r++)e[i+r]=o/(2*a+1),o+=t[i+Math.min(n-1,r+a+1)]-t[i+Math.max(0,r-a)]}for(let r=0;r<n;r++){let i=0;for(let t=-a;t<=a;t++)i+=e[Math.max(0,Math.min(o-1,t))*n+r];for(let s=0;s<o;s++)t[s*n+r]=i/(2*a+1),i+=e[Math.min(o-1,s+a+1)*n+r]-e[Math.max(0,s-a)*n+r]}}}var f=new Float32Array(0);var m=t=>Math.max(0,Math.min(1,t)),d=(t,e,n)=>{const o=m((n-t)/(e-t));return o*o*(3-2*o)};function u(t,e,n=256){let o=0;for(let e=0;e<t.length;e++)t[e]>o&&(o=t[e]);if(o<=0)return 0;const a=new Uint32Array(n);for(let e=0;e<t.length;e++)a[Math.min(n-1,Math.floor(Math.max(0,t[e])/o*n))]++;let r=0;const i=t.length*e;for(let t=0;t<n;t++)if(r+=a[t],r>=i)return(t+1)/n*o;return o}var M=class{constructor(t){this.n=t,this.arrays=[],this.next=0}take(t){this.next===this.arrays.length&&this.arrays.push(new Float32Array(this.n));const e=this.arrays[this.next++];return t?e.set(t):e.fill(0),e}reset(){this.next=0}},g=null;function p(t,e,n,o,a){const r=2*a+1;for(let i=0;i<o;i++){const o=i*n;let s=0;for(let e=-a;e<=a;e++)s+=t[o+Math.max(0,Math.min(n-1,e))];for(let i=0;i<n;i++)e[o+i]=s/r,s+=t[o+Math.min(n-1,i+a+1)]-t[o+Math.max(0,i-a)]}for(let i=0;i<n;i++){let s=0;for(let t=-a;t<=a;t++)s+=e[Math.max(0,Math.min(o-1,t))*n+i];for(let h=0;h<o;h++)t[h*n+i]=s/r,s+=e[Math.min(o-1,h+a+1)*n+i]-e[Math.max(0,h-a)*n+i]}}function x(t,e,n,o,a,r,i){const s=n*o,h=i.take(),l=i.take(e),c=i.take(t),f=i.take(),m=i.take();for(let n=0;n<s;n++)f[n]=e[n]*e[n],m[n]=e[n]*t[n];p(l,h,n,o,a),p(c,h,n,o,a),p(f,h,n,o,a),p(m,h,n,o,a);for(let t=0;t<s;t++){const e=(m[t]-l[t]*c[t])/(f[t]-l[t]*l[t]+r);f[t]=e,m[t]=c[t]-e*l[t]}p(f,h,n,o,a),p(m,h,n,o,a);for(let n=0;n<s;n++)t[n]=f[n]*e[n]+m[n]}function v(t,e,n,o,a,r=2){for(let i=0;i<r;i++){for(let r=0;r<o;r++)for(let o=0;o<n;o++){const i=r*n+o;let s=t[i];o>0&&(s=Math.max(s,Math.min(e[i],t[i-1]*a))),r>0&&(s=Math.max(s,Math.min(e[i],t[i-n]*a),o>0?Math.min(e[i],t[i-n-1]*a):0,o<n-1?Math.min(e[i],t[i-n+1]*a):0)),t[i]=s}for(let r=o-1;r>=0;r--)for(let i=n-1;i>=0;i--){const s=r*n+i;let h=t[s];i<n-1&&(h=Math.max(h,Math.min(e[s],t[s+1]*a))),r<o-1&&(h=Math.max(h,Math.min(e[s],t[s+n]*a),i>0?Math.min(e[s],t[s+n-1]*a):0,i<n-1?Math.min(e[s],t[s+n+1]*a):0)),t[s]=h}}}function w(t,e,n,o,a){for(let r=0;r<o;r++)for(let o=0;o<n;o++){let i=1;for(let e=Math.max(0,o-a);e<=Math.min(n-1,o+a);e++)i=Math.min(i,t[r*n+e]);e[r*n+o]=i}for(let r=0;r<o;r++)for(let i=0;i<n;i++){let s=1;for(let t=Math.max(0,r-a);t<=Math.min(o-1,r+a);t++)s=Math.min(s,e[t*n+i]);t[r*n+i]=s}}function y(t,e,n,o,a){const r=n*o,i=Math.min(n,o),s=a.take(),h=a.take(),l=a.take(),M=a.take(),g=a.take();for(let n=0;n<r;n++){const o=t[4*n+3]/255;g[n]=o,s[n]=e[4*n]/255*o,h[n]=e[4*n+1]/255*o,l[n]=e[4*n+2]/255*o,M[n]=(.299*t[4*n]+.587*t[4*n+1]+.114*t[4*n+2])/255*o}const y=a.take(),b=(t,e)=>{const r=a.take(t);return c(r,y,n,o,e),r},S=Math.max(2,Math.round(.04*i)),E=Math.max(S+2,Math.round(.12*i)),k=Math.max(2,Math.round(.05*i)),A=b(M,1),C=b(M,S),T=b(M,E),F=a.take(),L=a.take(),I=a.take(),R=a.take(),H=a.take();for(let t=0;t<o;t++)for(let e=0;e<n;e++){const a=t*n+e;F[a]=Math.abs(M[a]-A[a]),L[a]=Math.abs(A[a]-C[a]),I[a]=Math.abs(C[a]-T[a]),R[a]=Math.abs(M[t*n+Math.min(n-1,e+1)]-M[t*n+Math.max(0,e-1)]),H[a]=Math.abs(M[Math.min(o-1,t+1)*n+e]-M[Math.max(0,t-1)*n+e])}c(F,y,n,o,k),c(L,y,n,o,k),c(I,y,n,o,k),c(R,y,n,o,2),c(H,y,n,o,2);const W=Math.max(.01,u(F,.9)+u(L,.9)),j=b(s,1),$=b(h,1),P=b(l,1),z=a.take(),O=a.take(),q=a.take();let D=0;for(let t=0;t<r;t++){const e=j[t],n=$[t],o=P[t],a=Math.max(e,n,o),r=a-Math.min(e,n,o);q[t]=a,O[t]=a>.001?r/a:0,D+=r;let i=0;r>1e-4&&(i=a===e?((n-o)/r+6)%6:a===n?(o-e)/r+2:(e-n)/r+4),z[t]=60*i}const U=d(.02,.07,D/r),B=Math.max(2,Math.round(.06*o)),V=new Float32Array(o);for(let t=0;t<o;t++){let e=0;for(let o=0;o<n;o++)e+=F[t*n+o]+L[t*n+o];V[t]=e/n}let K=.5,N=0;for(let t=Math.max(B,Math.round(.12*o));t<=Math.min(o-B,Math.round(.88*o));t++){let e=0,a=0,r=0,i=0;for(let o=0;o<n;o++){let r=0,i=0,s=0,h=0,l=0,c=0;for(let e=1;e<=B;e++){const a=(t-e)*n+o,f=(t+e-1)*n+o;r+=j[a],i+=$[a],s+=P[a],h+=j[f],l+=$[f],c+=P[f]}const f=(Math.abs(r-h)+Math.abs(i-l)+Math.abs(s-c))/B;e+=f,a+=f>.12?1:0}const s=Math.max(2,Math.round(.15*o)),h=Math.max(0,t-s),l=Math.min(o,t+s);for(let e=h;e<t;e++)r+=V[e];for(let e=t;e<l;e++)i+=V[e];r/=t-h,i/=l-t;const c=d(-.05,.3,(i-r)/(i+r+1e-4)),f=d(.08,.35,e/n)*(a/n)*c;f>N&&(N=f,K=t/o)}const Y=d(.15,.45,N),X=a.take(),G=a.take(),_=a.take();for(let t=0;t<r;t++)X[t]=Math.min(s[t],h[t],l[t]);w(X,y,n,o,1),c(X,y,n,o,S);for(let t=0;t<r;t++)G[t]=L[t]+I[t];let J=0,Q=0,Z=0;for(let t=0;t<r;t++)J+=j[t],Q+=$[t],Z+=P[t];J/=r,Q/=r,Z/=r;const tt=b(j,S),et=b($,S),nt=b(P,S),ot=b(j,E),at=b($,E),rt=b(P,E);for(let t=0;t<r;t++){const e=Math.hypot(tt[t]-J,et[t]-Q,nt[t]-Z),n=Math.hypot(tt[t]-ot[t],et[t]-at[t],nt[t]-rt[t]);_[t]=(e+1.5*n)*(.4+.6*O[t]*U+.4*(1-U))}const it=a.take(),st=a.take(),ht=a.take(),lt=a.take(),ct=a.take(),ft=a.take(),mt=a.take(),dt=a.take(),ut=a.take(),Mt=a.take();for(let t=0;t<o;t++)for(let e=0;e<n;e++)Mt[t*n+e]=Math.abs(M[Math.min(o-1,t+1)*n+e]-M[Math.max(0,t-1)*n+e]);c(Mt,y,n,o,1);for(let t=0;t<o;t++)for(let e=0;e<n;e++){const a=t*n+e,r=(t+.5)/o,i=z[a],s=O[a]*U,h=q[a],l=F[a]+L[a],c=d(175,200,i)*(1-d(250,275,i))*d(.08,.25,s),f=(1-d(45,65,i)+d(290,330,i))*d(.2,.45,s)*d(.3,.55,h),m=(1-d(.15,.35,s))*d(.45,.7,h)*Y,u=(1-d(.08,.2,h))*Y,M=Y>.3?1-d(K,K+.1,r):1-d(.4,.8,r),g=1-d(.02,.06,l),p=1-d(.03,.09,l);st[a]=Math.max(c*g,.7*u*(1-d(.008,.025,l)),f*p*.9)*M,ht[a]=Math.max(st[a],m*g*M),it[a]=0===t?st[a]:0,lt[a]=d(150,172,i)*(1-d(232,250,i))*d(.25,.45,s),mt[a]=d(1.3,2.2,(R[a]+.004)/(H[a]+.004))*d(.35,.55,A[a])*(1-d(.1,.18,O[a]*U))*d(.025,.07,l)*d(.025,.045,Mt[a]);const x=1-d(.18,.4,s),v=d(.55,.8,h)*d(.05,.12,l);ct[a]=Math.max(lt[a],.85*x,.8*v)}v(it,st,n,o,.995,1),v(it,ht,n,o,.8,1);let gt=0;for(let t=0;t<r;t++)gt+=it[t];const pt=gt>.04*r&&Y>.3;if(pt)for(let t=0;t<o;t++)for(let e=0;e<n;e++)lt[t*n+e]*=d(K,K+.05,(t+.5)/o);if(pt){const t=a.take(),e=a.take(),i=a.take();for(let e=0;e<r;e++)t[e]=.299*tt[e]+.587*et[e]+.114*nt[e];for(let t=0;t<o;t++)for(let a=0;a<n;a++)e[t*n+a]=A[Math.min(o-1,t+1)*n+a]-A[Math.max(0,t-1)*n+a];const s=new Uint8Array(r);for(let t=1;t<o-1;t++)for(let a=0;a<n;a++){const r=Math.abs(e[t*n+a]);let i=r>.03;for(let s=-3;s<=3&&i;s++)s&&t+s>=0&&t+s<o&&Math.abs(e[(t+s)*n+a])>r&&(i=!1);s[t*n+a]=i?1:0}const h=(e,n,o,a=!0)=>{const r=tt[n]+et[n]+nt[n]+.05,i=tt[o]+et[o]+nt[o]+.05,s=Math.abs(tt[n]/r-tt[o]/i)+Math.abs(et[n]/r-et[o]/i)+Math.abs(nt[n]/r-nt[o]/i),h=Math.min(Math.abs(z[n]-z[o]),360-Math.abs(z[n]-z[o])),l=Math.max(1-d(.1,.25,s),(1-d(15,35,h))*d(.15,.3,Math.min(O[n],O[o]))),c=Math.max(d(2,3,(H[n]+.004)/(R[n]+.004))*d(.015,.04,F[n]+L[n])*d(.4,.55,F[n]/(F[n]+L[n]+1e-4)),1-d(.12,.25,t[n]));return l*(a?c:1)*(1-d(.82*t[o]+.02,1.02*t[o]+.05,t[n]))};let l=0,f=0;for(let t=Math.max(3,Math.round(o*Math.max(.25,K)));t<Math.round(.88*o);t++){let e=0;for(let o=0;o<n;o++)(s[(t-1)*n+o]||s[t*n+o]||s[(t+1)*n+o])&&e++;if(e<.5*n)continue;let a=0;for(let e=t+1;e<Math.min(o,2*t);e++)for(let o=0;o<n;o++)a+=h(t,e*n+o,(2*t-e)*n+o);a>f&&(f=a,l=t)}const m=d(.05,.1,f/r);if(m>0)for(let t=l+1;t<Math.min(o,2*l);t++)for(let e=0;e<n;e++){const o=t*n+e;dt[o]=h(l,o,(2*l-t)*n+e)*m,ut[o]=h(l,o,(2*l-t)*n+e,!1)*m,i[o]=dt[o]}c(i,y,n,o,1);for(let t=0;t<r;t++)dt[t]=Math.max(dt[t],i[t]),lt[t]=Math.max(lt[t],dt[t])}const xt=b(lt,E);for(let t=0;t<r;t++)lt[t]*=d(.15,.35,xt[t]);const vt=b(lt,S);for(let t=0;t<r;t++){lt[t]*=1-.8*st[t];const e=Math.min(Math.abs(z[t]-200),360-Math.abs(z[t]-200));ft[t]=d(.28,.45,O[t]*U)*d(55,80,e)*(1-d(.3,.6,ut[t]))}const wt=b(ft,S);for(let t=0;t<r;t++)ft[t]=Math.max(ft[t]*(1-(1-d(.15,.3,wt[t]))*d(.55,.7,q[t])*d(.5,.65,O[t])),1-g[t]),ct[t]=Math.min(Math.max(ct[t],.9*ut[t]),Math.max(lt[t],d(.25,.6,vt[t])))*(1-it[t])*(1-ft[t]);v(lt,ct,n,o,.97);const yt=a.take(mt),bt=Math.max(2,Math.round(.12*o));for(let t=0;t<n;t++){let e=0;for(let a=-bt;a<=bt;a++)e+=mt[Math.max(0,Math.min(o-1,a))*n+t];for(let a=0;a<o;a++)yt[a*n+t]=e/(2*bt+1),e+=mt[Math.min(o-1,a+bt+1)*n+t]-mt[Math.max(0,a-bt)*n+t]}c(yt,y,n,o,1);for(let t=0;t<r;t++)mt[t]=d(.2,.45,yt[t])*d(.2,.5,mt[t]+.5*yt[t])*(1-it[t]);x(it,M,n,o,Math.max(2,Math.round(.04*i)),.002,a),x(lt,M,n,o,Math.max(2,Math.round(.04*i)),.002,a),x(mt,M,n,o,Math.max(2,Math.round(.03*i)),.002,a),c(ft,y,n,o,1);for(let t=0;t<r;t++)it[t]=d(.3,.7,it[t])*g[t],mt[t]=d(.3,.7,mt[t])*g[t]*(1-it[t]),lt[t]=d(.3,.7,lt[t])*(1-it[t])*(1-mt[t])*(1-d(.15,.4,ft[t]));w(it,y,n,o,2),w(lt,y,n,o,2),w(mt,y,n,o,1),c(it,y,n,o,1),c(lt,y,n,o,1),c(mt,y,n,o,1);const St=1/Math.max(.02,u(_,.97)),Et=1/Math.max(.01,u(G,.9)),kt=u(X,.97),At=u(X,.1),Ct=d(.06,.25,kt-At),Tt=a.take();for(let t=0;t<o;t++)for(let e=0;e<n;e++){const a=t*n+e,r=(e+.5)/n,i=(t+.5)/o,s=Math.max(it[a],lt[a]),h=F[a]+L[a]+I[a],l=.6*m(((F[a]+.6*L[a])/(h+.004)-.25)/.55)+.4*m((F[a]+L[a])/W),c=d(.04,.35,h/W)*(1-s),f=.55*m((X[a]-At)/Math.max(.05,kt-At))+.25*(1-m(G[a]*Et))+.2*m(2*(P[a]-j[a])+.3)*U,u=Ct*d(.12,.35,C[a])*(.4+.6*Y),M=Y*(i<K?.45:.45+.55*d(0,1,(i-K)/Math.max(.15,1-K)))+(1-Y)*(.5+.4*(i-.5)),g=F[a]/(F[a]+L[a]+1e-4),p=d(.2,.7,(F[a]+L[a])/W)*(.35+.65*Y)*(1-s),x=1-m(1.5*Math.hypot(1.2*(r-.5),i-.52)),v=m(_[a]*St)*(.55+.45*x),w=.3*c,y=.25*u,b=.12+.45*Y,S=.12*p,E=.35*(1-.4*Y)*(1-s);Tt[a]=(w*l+y*(1-f)+b*M+S*m(1.6-1.6*g)+E*v+.04)/(w+y+b+S+E+.08)*(1-.85*it[a])*(1-.45*lt[a]*(1-Y))}const Ft=function(t,e,n){const o=e*n,a={width:e,height:n,subject:new Float32Array(o),depth:new Float32Array(o),key:"none"},{subject:r,depth:i}=a;let s=0;for(let e=0;e<o;e++)t[4*e+3]<250&&s++;const h=e=>(.2126*t[4*e]+.7152*t[4*e+1]+.0722*t[4*e+2])/255;let l="none",m=0;if(s>.01*o)l="alpha";else{let t=0,o=0,a=0;const r=Math.max(1,Math.round(.03*Math.min(e,n)));for(let i=0;i<n;i++)for(let s=0;s<e;s++){if(s>=r&&i>=r&&s<e-r&&i<n-r)continue;const l=h(i*e+s);t+=l,o+=l*l,a++}m=t/Math.max(1,a),Math.sqrt(Math.max(0,o/Math.max(1,a)-m*m))<.07&&(l="ground")}for(let e=0;e<o;e++){const n=t[4*e+3]/255,o=h(e);let a=1;if("alpha"===l)a=n;else if("ground"===l){const t=Math.max(0,Math.min(1,(Math.abs(o-m)-.035)/.12));a=t*t*(3-2*t)}r[e]=1*a,i[e]=o*n}a.key=l,f.length<o&&(f=new Float32Array(o));const d=f;return c(r,d,e,n,Math.max(1,Math.round(.02*Math.min(e,n)))),c(i,d,e,n,Math.max(1,Math.round(.035*Math.min(e,n)))),a}(t,n,o);if("none"!==Ft.key)for(let t=0;t<r;t++)Tt[t]=.7*Ft.subject[t]+.3*Tt[t];return c(Tt,y,n,o,Math.max(1,Math.round(.03*i))),function(t,e,n,o,a,r,i,s,h){const l=a*r,c=h.take(),f=t=>(p(t,c,a,r,i),t),m=(t,e)=>{const n=h.take();for(let o=0;o<l;o++)n[o]=t[o]*e[o];return f(n)},d=f(h.take(e)),u=f(h.take(n)),M=f(h.take(o)),g=f(h.take(t)),x=m(e,e),v=m(e,n),w=m(e,o),y=m(n,n),b=m(n,o),S=m(o,o),E=m(e,t),k=m(n,t),A=m(o,t),C=h.take(),T=h.take(),F=h.take(),L=h.take();for(let t=0;t<l;t++){const e=E[t]-d[t]*g[t],n=k[t]-u[t]*g[t],o=A[t]-M[t]*g[t],a=x[t]-d[t]*d[t]+s,r=v[t]-d[t]*u[t],i=w[t]-d[t]*M[t],h=y[t]-u[t]*u[t]+s,l=b[t]-u[t]*M[t],c=S[t]-M[t]*M[t]+s,f=h*c-l*l,m=i*l-r*c,p=r*l-i*h,I=a*c-i*i,R=r*i-a*l,H=a*h-r*r,W=a*f+r*m+i*p,j=Math.abs(W)>1e-12?1/W:0;C[t]=(f*e+m*n+p*o)*j,T[t]=(m*e+I*n+R*o)*j,F[t]=(p*e+R*n+H*o)*j,L[t]=g[t]-C[t]*d[t]-T[t]*u[t]-F[t]*M[t]}f(C),f(T),f(F),f(L);for(let a=0;a<l;a++)t[a]=C[a]*e[a]+T[a]*n[a]+F[a]*o[a]+L[a]}(Tt,j,$,P,n,o,Math.max(2,Math.round(.07*i)),.004,a),{depth:Tt,water:lt,sky:it,falls:mt}}function b(t,e,n,o,a,r,i){if(e===r&&n===i)return t[a*r+o];const s=Math.max(0,Math.min(e-1,(o+.5)*e/r-.5)),h=Math.max(0,Math.min(n-1,(a+.5)*n/i-.5)),l=Math.min(e-2,Math.floor(s)),c=Math.min(n-2,Math.floor(h)),f=s-l,m=h-c;if(l<0||c<0)return t[Math.round(h)*e+Math.round(s)];const d=c*e+l,u=d+e;return(t[d]*(1-f)+t[d+1]*f)*(1-m)+(t[u]*(1-f)+t[u+1]*f)*m}var S=new WeakMap;function E(t){const e=S.get(t);if(e)return e;const n=t.length,o=t[0]?.length??0,a=new Uint8ClampedArray(o*n*4);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=t[e][n],i=4*(e*o+n);a[i]=r.r,a[i+1]=r.g,a[i+2]=r.b,a[i+3]=r.a}const r=function(t,e,n,o,a=t){const r=e*n,i=o?.length===11*r?o:new Float32Array(11*r);if(!r)return i;const s=Math.min(e,n),h=new Float32Array(r),l=new Float32Array(r),f=new Float32Array(r),d=new Float32Array(r),p=new Float32Array(r),x=new Float32Array(r);for(let e=0;e<r;e++){const n=t[4*e+3]/255;h[e]=(.299*t[4*e]+.587*t[4*e+1]+.114*t[4*e+2])/255*n}l.set(h),c(l,x,e,n,Math.max(1,Math.round(.012*s))),f.set(h),c(f,x,e,n,Math.max(1,Math.round(.03*s)));for(let t=0;t<r;t++){d[t]=Math.abs(h[t]-l[t]);const e=Math.max(0,h[t]-.55)/.45;p[t]=e*e}c(d,x,e,n,Math.max(1,Math.round(.02*s)));const v=1/Math.max(.02,u(d,.95));c(p,x,e,n,Math.max(1,Math.round(.05*s)));const w=1/Math.max(.03,u(p,.98)),S=Math.max(1,Math.ceil(Math.sqrt(r/12e3))),E=Math.max(1,Math.floor(e/S)),k=Math.max(1,Math.floor(n/S)),A=E*k;let C=t,T=a;if(S>1){const n=new Uint8ClampedArray(4*A),o=a===t?n:new Uint8ClampedArray(4*A);for(let r=0;r<k;r++)for(let i=0;i<E;i++){const s=[0,0,0,0,0,0,0];for(let h=r*S;h<(r+1)*S;h++)for(let r=i*S;r<(i+1)*S;r++){const i=4*(h*e+r);for(let e=0;e<4;e++)s[e]+=t[i+e];if(o!==n)for(let t=0;t<3;t++)s[4+t]+=a[i+t]}const h=4*(r*E+i),l=S*S;for(let t=0;t<4;t++)n[h+t]=s[t]/l;if(o!==n){for(let t=0;t<3;t++)o[h+t]=s[4+t]/l;o[h+3]=n[h+3]}}C=n,T=o}g?.n!==A&&(g=new M(A)),g.reset();const{depth:F,water:L,sky:I,falls:R}=y(C,T,E,k,g),H=u(F,.03),W=u(F,.97),j=Math.max(.05,W-H);let $=0,P=0,z=0;const O=new Float32Array(r);for(let t=0;t<n;t++)for(let o=0;o<e;o++){const a=t*e+o,r=11*a,s=m((b(F,E,k,o,t,e,n)-H)/j);i[r+1]=s,i[r+8]=m(b(L,E,k,o,t,e,n)),i[r+9]=m(b(I,E,k,o,t,e,n)),i[r+10]=m(b(R,E,k,o,t,e,n));const l=s*s*s*(.25+h[a]);$+=(o+.5)/e*l,P+=(t+.5)/n*l,z+=l,O[a]=Math.hypot(f[t*e+Math.min(e-1,o+1)]-f[t*e+Math.max(0,o-1)],f[Math.min(n-1,t+1)*e+o]-f[Math.max(0,t-1)*e+o])}$=z>0?Math.max(.3,Math.min(.7,$/z)):.5,P=z>0?Math.max(.3,Math.min(.7,P/z)):.5;const q=1/Math.max(.004,u(O,.97));for(let t=0;t<n;t++)for(let o=0;o<e;o++){const a=t*e+o,r=11*a,s=(f[t*e+Math.min(e-1,o+1)]-f[t*e+Math.max(0,o-1)])*q,h=(f[Math.min(n-1,t+1)*e+o]-f[Math.max(0,t-1)*e+o])*q;i[r]=f[a],i[r+2]=Math.min(1,p[a]*w),i[r+3]=Math.min(1,d[a]*v),i[r+4]=Math.max(-1,Math.min(1,-s)),i[r+5]=Math.max(-1,Math.min(1,-h)),i[r+6]=$,i[r+7]=P}return i}(a,o,n);return S.set(t,r),r}function k(t,e){const n=document.createElement("canvas");n.width=t,n.height=e;const o=n.getContext("2d",{willReadFrequently:!0});return{canvas:n,ctx:o}}function A(t,e,n){let o=t+255*e;return o=259*(255*n+255)/(255*(259-255*n))*(o-128)+128,Math.max(0,Math.min(255,o))}function C(t,e,n,o,a,r){if((r?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(o*a+n)%i.length]}var T=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function F(t,e,n,o){if(o<=0)return t;const a=(T[n%4][e%4]/16-.5)*o*128;return Math.max(0,Math.min(255,t+a))}var L=new Array(256),I=new Array(256);for(let t=0;t<256;t++)L[t]=`rgb(${t},${t},${t})`,I[t]=`rgb(0,${t},0)`;function R(t,e,n,o,a,r=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return I[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${n},${o},${a})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return L[e]}}}var H=[0,0,0];function W(t,e,n,o,a,r=!1){switch(e){case"fullcolor":H[0]=t.r,H[1]=t.g,H[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;H[0]=0,H[1]=e,H[2]=0;break}case"accent":H[0]=n,H[1]=o,H[2]=a;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;H[0]=e,H[1]=e,H[2]=e;break}}return H}function j(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function $(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=j(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function P(t){if(t){const e=$(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=$(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function z(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");n.fillStyle=t,n.fillRect(0,0,1,1);const o=n.getImageData(0,0,1,1).data;return{r:o[0],g:o[1],b:o[2]}}function O(t){return t*t*(3-2*t)}var q={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function D(t,e,n,o,a,r,i,s,h="spotlight",l=.5,c="circle",f=[],m=1){const d=(t-n)*Math.max(1,m),u=(e-o)*Math.max(1,1/m),M=.08+.35*l+.04*r;let g,p;if("box"===c){const t=Math.abs(d),e=Math.abs(u);g=Math.max(t,e),p=M}else g=Math.sqrt(d*d+u*u),p=M;if(g>=p&&("trail"!==h||0===f.length))return q.scale=1,q.offsetX=0,q.offsetY=0,q.glow=0,q.colorBlend=0,q.proximity=0,q;const x=O(Math.max(0,1-g/p))*a;let v=1,w=0,y=0,b=0,S=0;switch(h){case"spotlight":{v=1+x*r*1.8;const t=Math.atan2(u,d),e=x*x*r*.6;w=Math.cos(t)*e*i,y=Math.sin(t)*e*s,b=x*r*.4,S=x*x*r*.25;break}case"magnify":v=1+x*r*.85,b=x*r*.15;break;case"repel":{v=1;const t=Math.atan2(u,d),e=x*x*r*1.8;w=Math.cos(t)*e*i,y=Math.sin(t)*e*s;break}case"glow":b=x*r*.8,S=x*r*.4;break;case"colorShift":v=1,b=x*r*.12,S=x*r;break;case"attract":{const t=Math.atan2(u,d),e=x*x*r*1;w=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,y=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,b=x*r*.3;break}case"shatter":{const t=Math.atan2(u,d),e=.5*Math.sin(43.7*d+29.3*u),n=x*r*1.4*(.7+.3*e);w=Math.cos(t+e)*n*i,y=Math.sin(t+e)*n*s,v=Math.max(.1,1-x*r*.6),b=x*r*.25;break}case"trail":{let n=x,o=-u*x,a=d*x;for(const r of f){const i=(t-r.x)*Math.max(1,m),s=(e-r.y)*Math.max(1,1/m),h=Math.hypot(i,s)/M;if(h>=1)continue;const l=O(1-h)*r.intensity;n=Math.max(n,l),o+=(.35*r.vx-2*s)*l*.35,a+=(.35*r.vy+2*i)*l*.35}w=Math.tanh(2*o)*r*i*3,y=Math.tanh(2*a)*r*s*3,S=n*r*.65,b=n*r*.35,v=1+n*r*.08,q.proximity=n;break}case"glitchText":v=1,b=x*r*.5,S=x*r*.6}return q.scale=v,q.offsetX=w,q.offsetY=y,q.glow=b,q.colorBlend=S,"trail"!==h&&(q.proximity=x),q}function U(t,e,{continuous:n=!1,interactive:o=!1}={}){const a=t.parentElement??t;let r=null,i=0,s=!1,h=!0,l=!0,c=-1/0;const f=window.matchMedia("(prefers-reduced-motion: reduce)"),m=()=>{l=!0,s||!h||document.hidden||i||(i=requestAnimationFrame(d))},d=t=>{if(i=0,s||!h||document.hidden)return;const o=!f.matches&&(n||t-c<1500);(l||o)&&(e(t,f.matches?null:r),l=!1),o&&(i=requestAnimationFrame(d))},u=e=>{if("touch"===e.pointerType)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const o=(e.clientX-n.left)/n.width,a=(e.clientY-n.top)/n.height;r=o>=0&&o<=1&&a>=0&&a<=1?{x:o,y:a}:null,c=performance.now(),m()},M=()=>{r=null,c=performance.now(),m()},g=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):m()},p="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{h=t.isIntersecting,h?m():i&&(cancelAnimationFrame(i),i=0)});return p?.observe(t),o&&(a.addEventListener("pointermove",u),a.addEventListener("pointerleave",M)),document.addEventListener("visibilitychange",g),f.addEventListener("change",m),m(),{wake:m,stop:()=>{s=!0,cancelAnimationFrame(i),p?.disconnect(),a.removeEventListener("pointermove",u),a.removeEventListener("pointerleave",M),document.removeEventListener("visibilitychange",g),f.removeEventListener("change",m)}}}var B=null,V=null;function K(t,e){if(!B||!V){const n=k(t,e);B=n.canvas,V=n.ctx}return B.width!==t&&(B.width=t),B.height!==e&&(B.height=e),V}var N=new Map,Y=new Map,X=new WeakMap;function G(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function _(t){let e=N.get(t);return e||(e=G(t),N.set(t,e)),e}function J(t){return G(t)}function Q(t,e,n){const o=n?1-t/255:t/255,a=Math.floor(o*(e.length-1));return e[Math.max(0,Math.min(e.length-1,a))]??" "}function Z(t,e,n,o){const a=`${t}\0${e?1:0}\0${n}\0${o}`;let r=Y.get(a);if(!r){const i=_(t);r=new Array(256);for(let t=0;t<256;t++)r[t]=Q(A(t,n,o),i,e);Y.set(a,r)}return r}function tt(){N.clear(),Y.clear(),dt=new WeakMap,Mt=new WeakMap,ut=new WeakMap,B=null,V=null}function et(t,e){return"auto"!==t?t:!P(e)}function nt(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const n=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return n?[n[1],n[2],n[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function ot(t){const e=t||"auto";if("auto"!==e)return nt(e)??"ffffff";if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const n=nt(t.getPropertyValue(e).trim());if(n)return n}const e=nt(getComputedStyle(document.body).accentColor??"");if(e)return e}return P("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function at(t,e,n){return Math.max(e,Math.min(n,t))}function rt(t,e,n){if(!t)return{x:0,y:0,width:e,height:n};const o=t.unit??"percent",a=!1!==t.preserveAspect,r=t=>void 0===t?void 0:"percent"===o?t*e:t,i=t=>void 0===t?void 0:"percent"===o?t*n:t,s=at(r(t.left)??0,0,e-1),h=at(r(t.right)??0,0,e-s-1),l=at(i(t.top)??0,0,n-1),c=at(i(t.bottom)??0,0,n-l-1),f=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,m=Math.max(1,e-s-h),d=Math.max(1,n-l-c),u=f?m:r(t.width),M=f?d:i(t.height);let g=u??e,p=M??n;if(a&&!f){const t=g/e,o=p/n,a=Math.min(t,o),r=void 0===u?o:void 0===M?t:a;g=e*r,p=n*r}g=at(g,1,f?m:e),p=at(p,1,f?d:n);const x=t.anchor??"center",v=r(t.x),w=i(t.y),y=f?s:0,b=f?l:0,S=f?m:e,E=f?d:n,k=x.endsWith("left")||"left"===x?0:x.endsWith("right")||"right"===x?S-g:(S-g)/2,A=x.startsWith("top")||"top"===x?0:x.startsWith("bottom")||"bottom"===x?E-p:(E-p)/2;return{x:at(v??y+k,0,Math.max(0,e-g)),y:at(w??b+A,0,Math.max(0,n-p)),width:g,height:p}}function it(t,e,n,o){const a=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===a||0===r)return{frame:[],cols:0,rows:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,l=n||a,c=o||r,f=Math.floor(l/s),m=Math.floor(c/h);if(f<=0||m<=0)return{frame:[],cols:0,rows:0};const d=rt(e.sourceCrop,a,r),u=Math.max(1,Math.min(Math.floor(2048/f),Math.floor(d.width/f))),M=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(d.height/m))),g=f*u,p=m*M,x=K(g,p),v=x.globalCompositeOperation;x.globalCompositeOperation="copy";try{x.drawImage(t,d.x,d.y,d.width,d.height,0,0,g,p)}finally{x.globalCompositeOperation=v}const w=x.getImageData(0,0,g,p).data,y=e.chromaKey,b=null!=y&&!1!==y,S=!0===y,E="blue-screen"===y;let k=null,T=0;!b||S||E||(k=z(y),T=(e.chromaKeyTolerance??60)**2);let L=0,I=255;if(e.normalize){let t=255,e=0;for(let n=0;n<w.length;n+=4){if(b){const t=w[n],e=w[n+1],o=w[n+2];let a=!1;if(S)a=e>1.4*t&&e>1.4*o&&e>80;else if(E)a=o>1.4*t&&o>1.4*e&&o>80;else if(null!==k){const n=t-k.r,r=e-k.g,i=o-k.b;a=n*n+r*r+i*i<=T}if(a)continue}const o=.299*w[n]+.587*w[n+1]+.114*w[n+2];o<t&&(t=o),o>e&&(e=o)}L=t,I=e>t?e-t:255}const R=[],H=et(e.invert),W=b&&e.charset.replace(/ /g,"")||e.charset,j=_(W),$=e.customText?null:Z(W,H,e.brightness,e.contrast),P=u*M;for(let t=0;t<m;t++){const n=[];for(let o=0;o<f;o++){let a=0,r=0,i=0,s=0,h=0;for(let e=0;e<M;e++){const n=(t*M+e)*g;for(let t=0;t<u;t++){const e=4*(n+o*u+t),l=w[e],c=w[e+1],f=w[e+2],m=w[e+3];if(b){let t=!1;if(S)t=c>1.4*l&&c>1.4*f&&c>80;else if(E)t=f>1.4*l&&f>1.4*c&&f>80;else if(null!==k){const e=l-k.r,n=c-k.g,o=f-k.b;t=e*e+n*n+o*o<=T}if(t){h++;continue}}a+=l,r+=c,i+=f,s+=m}}if(b&&h>P/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const l=P-h,c=l>0?a/l:0,m=l>0?r/l:0,d=l>0?i/l:0,p=l>0?s/l:0,x=.299*c+.587*m+.114*d,v=e.normalize?(x-L)/I*255:x,y=A(v,e.brightness,e.contrast),R=e.ditherStrength>0?F(y,o,t,e.ditherStrength):y,W=e.customText?C(R,e.customText,o,t,f,H):e.ditherStrength>0?Q(R,j,H):$[Math.max(0,Math.min(255,0|v))];n.push({char:W,r:c,g:m,b:d,a:p,lum:R})}R.push(n)}return{frame:R,cols:f,rows:m}}function st(t,e,n,o){const a=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===a||0===r)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,l=n||a,c=o||r,f=Math.floor(l/s),m=Math.floor(c/h);if(f<=0||m<=0)return{rows:[],cols:0,rowCount:0};const d=f,u=m,M=K(d,u),g=rt(e.sourceCrop,a,r),p=M.globalCompositeOperation;M.globalCompositeOperation="copy";try{M.drawImage(t,g.x,g.y,g.width,g.height,0,0,d,u)}finally{M.globalCompositeOperation=p}const x=M.getImageData(0,0,d,u).data,v=e.chromaKey,w=null!=v&&!1!==v,y=!0===v,b="blue-screen"===v;let S=null,E=0;!w||y||b||(S=z(v),E=(e.chromaKeyTolerance??60)**2);let k=0,C=255;if(e.normalize){let t=255,e=0;for(let n=0;n<x.length;n+=4){if(w){const t=x[n],e=x[n+1],o=x[n+2];let a=!1;if(y)a=e>1.4*t&&e>1.4*o&&e>80;else if(b)a=o>1.4*t&&o>1.4*e&&o>80;else if(null!==S){const n=t-S.r,r=e-S.g,i=o-S.b;a=n*n+r*r+i*i<=E}if(a)continue}const o=.299*x[n]+.587*x[n+1]+.114*x[n+2];o<t&&(t=o),o>e&&(e=o)}k=t,C=e>t?e-t:255}const T=et(e.invert),L=w&&e.charset.replace(/ /g,"")||e.charset,I=_(L),R=e.customText?null:Z(L,T,e.brightness,e.contrast),H=e.customText?_(e.customText):null,W="fullcolor"===e.colorMode?new Uint8ClampedArray(f*m*4):void 0,j=[];for(let t=0;t<m;t++){let n="";for(let o=0;o<f;o++){const a=4*(t*d+o),r=a,i=x[a],s=x[a+1],h=x[a+2],l=x[a+3];if(w){let t=!1;if(y)t=s>1.4*i&&s>1.4*h&&s>80;else if(b)t=h>1.4*i&&h>1.4*s&&h>80;else if(null!==S){const e=i-S.r,n=s-S.g,o=h-S.b;t=e*e+n*n+o*o<=E}if(t){n+=" ",W&&(W[r]=0,W[r+1]=0,W[r+2]=0,W[r+3]=0);continue}}W&&(W[r]=i,W[r+1]=s,W[r+2]=h,W[r+3]=l);const c=.299*i+.587*s+.114*h,m=e.normalize?(c-k)/C*255:c,u=e.ditherStrength>0||H?A(m,e.brightness,e.contrast):m,M=e.ditherStrength>0?F(u,o,t,e.ditherStrength):u;if(H){n+=(T?1-M/255:M/255)<.12?" ":H[(t*f+o)%H.length]}else e.ditherStrength<=0?n+=R[Math.max(0,Math.min(255,0|m))]:n+=Q(M,I,T)}j.push(n)}return{rows:j,cols:f,rowCount:m,colors:W}}function ht(t,e,n,o,a){if(0===e.rows.length)return;const r=t.canvas,i=Boolean(n.chromaKey)||e.rows.some(t=>t.includes(" "));i||(X.delete(t),t.clearRect(0,0,o,a),t.fillStyle=P(r)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,a));const s=ot(n.accentColor),h=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),c=parseInt(s.substring(4,6),16),f=o/e.cols,m=a/e.rowCount,d=.9*Math.min(f/.55,m),u=e.colors;if("fullcolor"===n.colorMode&&u){X.delete(t),t.clearRect(0,0,o,a),t.font=`${d}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let n="";for(let o=0;o<e.rows.length;o++){const a=J(e.rows[o]);let r=0;for(;r<e.cols;){for(;r<e.cols&&" "===a[r];)r++;if(r>=e.cols)break;const i=r,s=4*(o*e.cols+r),h=240&u[s],l=240&u[s+1],c=240&u[s+2];for(r++;r<e.cols&&" "!==a[r];){const t=4*(o*e.cols+r);if((240&u[t])!==h||(240&u[t+1])!==l||(240&u[t+2])!==c)break;r++}const d=`rgb(${h},${l},${c})`;d!==n&&(t.fillStyle=d,n=d),t.fillText(a.slice(i,r).join(""),i*f+.5*f,o*m+.5*m)}}return void(t.globalAlpha=1)}t.font=`${d}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const M="matrix"===n.colorMode?"rgb(0,255,0)":"grayscale"===n.colorMode?P(r)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${h},${l},${c})`;t.fillStyle=M,t.globalAlpha=1;const g=X.get(t),p=i&&g&&g.cols===e.cols&&g.rowCount===e.rowCount&&g.canvasWidth===o&&g.canvasHeight===a&&g.fillStyle===M;p||t.clearRect(0,0,o,a);for(let n=0;n<e.rows.length;n++){const a=e.rows[n];p&&g.rows[n]===a||(p&&t.clearRect(0,n*m,o,m+1),0!==a.trim().length&&t.fillText(a,.5*f,n*m+.5*m))}X.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:o,canvasHeight:a,fillStyle:M}),t.globalAlpha=1}async function lt(t,e,n,o,a=12,r=10,i,s=0){const h=Math.min(t.duration-s,r),l=Math.ceil(h*a),c=[];let f=0,m=0;for(let r=0;r<l;r++){const d=s+r/a;if(d>s+h)break;t.currentTime=d,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=it(t,e,n,o);c.push(u.frame),f=u.cols,m=u.rows,i?.((r+1)/l)}return{frames:c,cols:f,rows:m,fps:a}}async function ct(t,e,n,o,a=12,r=10,i,s=0){const h=Math.min(t.duration-s,r),l=Math.ceil(h*a),c=[];let f=0,m=0;for(let r=0;r<l;r++){const d=s+r/a;if(d>s+h)break;t.currentTime=d,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=st(t,e,n,o);c.push(u),f=u.cols,m=u.rowCount,i?.((r+1)/l)}return{frames:c,cols:f,rows:m,fps:a}}async function ft(t,e,n,o,a){const{parseGIF:r,decompressFrames:i}=await import("gifuct-js"),s=r(t),h=i(s,!0);if(0===h.length)return{frames:[],cols:0,rows:0,fps:10};const l=h[0].dims.width,c=h[0].dims.height,f=s.lsd?.width||l,m=s.lsd?.height||c,d=document.createElement("canvas");d.width=f,d.height=m;const u=d.getContext("2d"),M=document.createElement("canvas");M.width=f,M.height=m;const g=M.getContext("2d"),p=document.createElement("canvas"),x=p.getContext("2d"),v=[];let w=0,y=0,b=0;for(const t of h)b+=t.delay||100;const S=b/h.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),k=Math.min(h.length,300);for(let t=0;t<k;t++){const r=h[t],{dims:i,patch:s,disposalType:l}=r;3===l&&(g.clearRect(0,0,f,m),g.drawImage(d,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const c=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);x.putImageData(c,0,0),u.drawImage(p,i.left||0,i.top||0);const b=it(d,e,n,o);v.push(b.frame),w=b.cols,y=b.rows,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,m),u.drawImage(M,0,0)),a?.((t+1)/k)}return{frames:v,cols:w,rows:y,fps:E}}async function mt(t,e,n,o,a){const{parseGIF:r,decompressFrames:i}=await import("gifuct-js"),s=r(t),h=i(s,!0);if(0===h.length)return{frames:[],cols:0,rows:0,fps:10};const l=h[0].dims.width,c=h[0].dims.height,f=s.lsd?.width||l,m=s.lsd?.height||c,d=document.createElement("canvas");d.width=f,d.height=m;const u=d.getContext("2d"),M=document.createElement("canvas");M.width=f,M.height=m;const g=M.getContext("2d"),p=document.createElement("canvas"),x=p.getContext("2d"),v=[];let w=0,y=0,b=0;for(const t of h)b+=t.delay||100;const S=b/h.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),k=Math.min(h.length,300);for(let t=0;t<k;t++){const r=h[t],{dims:i,patch:s,disposalType:l}=r;3===l&&(g.clearRect(0,0,f,m),g.drawImage(d,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const c=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);x.putImageData(c,0,0),u.drawImage(p,i.left||0,i.top||0);const b=st(d,e,n,o);v.push(b),w=b.cols,y=b.rowCount,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,m),u.drawImage(M,0,0)),a?.((t+1)/k)}return{frames:v,cols:w,rows:y,fps:E}}var dt=new WeakMap,ut=new WeakMap,Mt=new WeakMap;function gt(t,e,n,o,a,r=0,i){if(!e.length||!e[0].length||o<=0||a<=0)return;let s=null;if(n.hoverStrength>0){let e=dt.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},dt.set(t,e)),s=function(t,e,n){const o=t.time<0?1/60:Math.max(0,Math.min(.1,(n-t.time)/1e3));t.time=n;const a=t.intensity<.003,r=t.x,i=t.y;if(e){a&&(t.x=e.x,t.y=e.y);const n=1-Math.exp(-o/.055);t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n}t.intensity+=((e?.intensity??(e?1:0))-t.intensity)*(1-Math.exp(-o/(e?.09:.18)));const s=Math.exp(-o/.22);for(const e of t.points)e.intensity*=s;for(;t.points.length&&t.points[0].intensity<.01;)t.points.shift();return e&&!a&&n-t.emittedAt>=24&&Math.hypot(t.x-r,t.y-i)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-r)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(t.y-i)/Math.max(o,.001)))}),t.points.length>12&&t.points.shift(),t.emittedAt=n),!e&&t.intensity<.003&&!t.points.length?(t.intensity=0,null):{x:t.x,y:t.y,intensity:t.intensity,trail:t.points}}(e,i??null,performance.now())}else dt.delete(t);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return Mt.delete(t),void pt(t,e,n,o,a,r,s);const h=ut.get(t);if(h?.frame!==e)return ut.set(t,{frame:e,since:performance.now()}),Mt.delete(t),void pt(t,e,n,o,a,r,s);if(performance.now()-h.since<100)return void pt(t,e,n,o,a,r,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void pt(t,e,n,o,a,r,s);if(!s||(s.intensity??0)<.003)return void pt(t,e,n,o,a,r,null);const c=P(t.canvas),f={...n,accentColor:"#"+ot(n.accentColor)},m=JSON.stringify([f,o,a,l.a,l.d,c,void 0!==document.fonts?document.fonts.status:"loaded"]);let d=Mt.get(t);if(!d||d.frame!==e||d.key!==m){const n=d?.canvas??document.createElement("canvas");n.width=Math.ceil(o*l.a),n.height=Math.ceil(a*l.d);const r=n.getContext("2d");r.setTransform(l.a,0,0,l.d,0,0),pt(r,e,f,o,a,0,null,void 0,c),d={frame:e,key:m,canvas:n},Mt.set(t,d)}if(t.clearRect(0,0,o,a),t.drawImage(d.canvas,0,0,o,a),!s||(s.intensity??0)<.003)return;const u=e.length,M=e[0].length,g=.08+.35*n.hoverRadius+.04*n.hoverStrength,p="trail"===n.hoverEffect?[s,...s.trail??[]]:[s];let x=1,v=1,w=0,y=0;for(const t of p)x=Math.min(x,t.x-g),w=Math.max(w,t.x+g),v=Math.min(v,t.y-g),y=Math.max(y,t.y+g);if("glitchText"===n.hoverEffect){const t=n.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));x=Math.min(x,s.x-e/M),w=Math.max(w,s.x+e/M)}const b=Math.ceil(5+4*n.hoverStrength),S={x:Math.max(0,Math.floor(x*M)-b),y:Math.max(0,Math.floor(v*u)-b),right:Math.min(M,Math.ceil(w*M)+b),bottom:Math.min(u,Math.ceil(y*u)+b)};t.save(),t.beginPath(),t.rect(S.x*o/M,S.y*a/u,(S.right-S.x)*o/M,(S.bottom-S.y)*a/u),t.clip(),pt(t,e,f,o,a,r,s,S,c),t.restore()}function pt(t,e,n,o,c,f=0,m,d,u){const M=e.length;if(0===M)return;const g=e[0].length;t.clearRect(0,0,o,c);let p=!1;const x=Math.max(1,M>>2),v=Math.max(1,g>>2);t:for(let t=0;t<M;t+=x){const n=e[t];for(let t=0;t<g;t+=v)if(n[t].a<200){p=!0;break t}}const w=t.canvas,y=u??P(w);p||(t.fillStyle=y?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,c));const b=o/g,S=c/M,k=m?.intensity??1,A=!!(m&&n.hoverStrength>0&&k>.005),C="#"+(nt(n.hoverColor||"#ffffff")??"ffffff"),T=parseInt(C.slice(1,3),16),F=parseInt(C.slice(3,5),16),L=parseInt(C.slice(5,7),16),I=ot(n.accentColor),H=parseInt(I.substring(0,2),16),j=parseInt(I.substring(2,4),16),$=parseInt(I.substring(4,6),16),z=n.hoverRadius;let O=0,q=g,U=0,B=M,V=0,K=0;if(A&&m){V=m.x,K=m.y;const t=.08+.35*z+.04*n.hoverStrength;O=Math.max(0,Math.floor((V-t)*g)-1),q=Math.min(g,Math.ceil((V+t)*g)+1),U=Math.max(0,Math.floor((K-t)*M)-1),B=Math.min(M,Math.ceil((K+t)*M)+1)}if(A&&"trail"===n.hoverEffect)for(const t of m?.trail??[]){const e=.08+.35*z+.04*n.hoverStrength;O=Math.min(O,Math.max(0,Math.floor((t.x-e)*g)-1)),q=Math.max(q,Math.min(g,Math.ceil((t.x+e)*g)+1)),U=Math.min(U,Math.max(0,Math.floor((t.y-e)*M)-1)),B=Math.max(B,Math.min(M,Math.ceil((t.y+e)*M)+1))}const N=n.animationStyle,Y=n.animationSpeed,X=function(t){const e=t&&Object.prototype.hasOwnProperty.call(a,t)?a[t]:t;return r.find(t=>t.value===e||t.mode===e)?.mode??"none"}(N),G="none"===X,J=[0,0,0,1],Z=G?void 0:E(e),tt=[0,0],at="relight"===(it=X)||"sheen"===it||"glow"===it||"shimmer"===it||"mist"===it,rt={char:" ",r:0,g:0,b:0,a:0};var it;const st=(t,n,o,a)=>{!function(t,e,n,o,a,r=.5,l,c=0){if(a[0]=a[1]=a[2]=0,a[3]=1,"none"===t)return a;r=i(r);const f=l?l[c]:r,m=l?l[c+1]:.5+.5*i(1-2*Math.hypot(e-.5,n-.55)),d=l?l[c+2]:s(.55,1,r)**2,u=l?l[c+3]:.5,M=l?l[c+4]:0,g=l?l[c+5]:0,p=o*Math.PI/6,x=(o%12+12)%12,v=s(0,.12,Math.min(e,1-e,n,1-n));if("relight"===t){const t=p+.6,o=Math.cos(t),i=Math.sin(t),h=Math.max(-1,Math.min(1,M*o+g*i))+.35*(o*(e-.5)+i*(n-.5));a[2]=.2*h*(.3+.7*s(.04,.3,f)*(1-.6*s(.82,1,r)))}else if("sheen"===t){const t=1.9*s(0,8,x)-.35,o=(.75*e+.45*n)/1.2+.05*(.75*M+.45*g),i=Math.exp(-(((o-t)/.12)**2));a[2]=i*s(.3,.8,f)*(1-.5*s(.9,1,r))*.45}else if("glow"===t){const t=.5-.5*Math.cos(p),e=1-.8*t;a[2]=.2*s(e-.3,e+.02,d)*Math.sqrt(d)*(1-.65*r)+.05*t*s(.6,.95,r)}else if("shimmer"===t){const t=h(Math.floor(160*e),Math.floor(100*n))*Math.PI*2,o=Math.pow(.5+.5*Math.cos(2*p+t),28);a[2]=o*s(.5,.88,r)*(.35+.65*s(.1,.55,u))*.42}else if("parallax"===t){const t=m-.45;a[0]=16*t*Math.sin(p)*v,a[1]=7*t*Math.sin(2*p)*v}else if("push"===t){const t=.045*(.5-.5*Math.cos(p))*(.7+.6*m)*960,o=l?l[c+6]:.5,r=l?l[c+7]:.5;a[0]=(e-o)*t,a[1]=(n-r)*t}else if("focus"===t){const t=Math.sin(p),e=t*t*s(.35,.85,t>=0?1-m:m);a[2]=(f-r)*e*.75}else if("mist"===t){const t=Math.pow(1-m,1.5)*(1-.6*u),o=.5*Math.sin(4.1*e-p+.9*Math.sin(3.3*n+p))+.3*Math.sin(7.3*e+2.1*n-2*p+1.1*Math.sin(2.7*e-5.1*n+p))+.2*Math.sin(5.7*n-1.9*e+p);a[2]=s(-.3,.9,o)*t*.16*(1-.55*r)}else if("current"===t){const t=l?.[c+8]??0,o=l?.[c+9]??0,i=l?.[c+10]??0,f=s(0,.06,Math.min(e,1-e,n,1-n)),d=l?0:(1-.4*u)*(1-.8*m)*v,M=t=>14*n-t+1.5*Math.sin(3*e+t),g=t=>16*n+2*e-t,x=t=>29*n-3*e-2*t,w=t=>1.7*e+2.3*n-t,y=t=>26*n+1.5*Math.sin(40*e)-2*t;a[0]=7*(Math.sin(M(p))-Math.sin(M(0))+.43*(Math.sin(5*e-3*n+p)-Math.sin(5*e-3*n)))*d+(3.5*(Math.sin(g(p))-Math.sin(g(0)))+1.5*(Math.sin(x(p))-Math.sin(x(0))))*t*f+5*(Math.sin(w(p))-Math.sin(w(0)))*o*f,a[1]=2*(Math.sin(11*e+p)-Math.sin(11*e))*d+.8*(Math.cos(g(p))-Math.cos(g(0)))*t*f+12*(Math.sin(y(p))-Math.sin(y(0)))*i*f;const b=Math.pow(.5+.5*Math.cos(2*p+9*e-4*n+6.2831853*h(Math.floor(160*e),Math.floor(100*n))),24)-Math.pow(.5+.5*Math.cos(9*e-4*n+6.2831853*h(Math.floor(160*e),Math.floor(100*n))),24);a[2]=.03*(Math.cos(M(p))-Math.cos(M(0)))*d+(b*s(.5,.85,r)*.3+.025*(Math.cos(g(p))-Math.cos(g(0))))*t*f+.08*(Math.cos(y(p))-Math.cos(y(0)))*i*f}else if("develop"===t){const t=s(7,8.5,x),o=i((x-8.5)/3.5),l=x<8.5?1-t:s(0,1,(1.45*o-(1-r)+.06*(h(Math.floor(160*e),Math.floor(100*n))-.5))/.3);a[2]=.3*-(1-l),a[3]=1-.9*(1-l)}}(X,t/g,n/M,f*Y,J,(.299*o.r+.587*o.g+.114*o.b)/255,Z,11*(n*g+t));let r=o;(J[0]||J[1])&&(!function(t,e,n,o,a,r){r[0]=l(Math.max(0,Math.min(o-1,e-t[0]/960*o))),r[1]=l(Math.max(0,Math.min(a-1,n-t[1]/960*a)))}(J,t,n,g,M,tt),r=e[Math.round(tt[1])][Math.round(tt[0])]);const c=255*J[2];return Math.abs(c)<.5&&1===J[3]?r:(rt.r=Math.max(0,Math.min(255,r.r+c)),rt.g=Math.max(0,Math.min(255,r.g+c)),rt.b=Math.max(0,Math.min(255,r.b+c)),rt.a=r.a*J[3],rt.char=r.char,rt.lum=r.lum,null!=r.lum&&(rt.lum=Math.max(0,Math.min(255,r.lum+c*(at?.45:1))),a&&Math.abs(c)>2&&(rt.char=Q(rt.lum,a,mt))),rt)},ht=n.hoverStrength,lt=n.hoverEffect,ct=z,ft=n.hoverShape||"circle",mt=et(n.invert,w),dt=n.colorMode,ut=2*Math.PI,Mt=1/g,gt=1/M;let pt="",xt=-1;if("dots"===n.renderMode){const a=.5*Math.min(b,S)*n.dotSizeRatio;for(let n=d?.y??0;n<(d?.bottom??M);n++){const r=e[n];for(let e=d?.x??0;e<(d?.right??g);e++){const i=G?r[e]:st(e,n,r[e]);if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=mt?1-s:s;if(h<.02)continue;let l=1,f=0,d=0,u=0,M=0;if(A&&e>=O&&e<=q&&n>=U&&n<=B){const t=D(e*Mt,n*gt,V,K,k,ht,b,S,lt,ct,ft,m?.trail,o/c);l=t.scale,f=t.offsetX,d=t.offsetY,u=t.glow,M=t.colorBlend}const g=a*h*l;if(g<.3)continue;const p=e*b+.5*b+f,x=n*S+.5*S+d;let v;if(M>0){const t=W(i,dt,H,j,$,mt);v=`rgb(${Math.min(255,t[0]+(T-t[0])*M|0)},${Math.min(255,t[1]+(F-t[1])*M|0)},${Math.min(255,t[2]+(L-t[2])*M|0)})`}else v=R(i,dt,H,j,$,mt);const w=Math.min(1,.00392156863*i.a*(1+u));if(w!==xt&&(t.globalAlpha=w,xt=w),v!==pt&&(t.fillStyle=v,pt=v),g<=3){const e=2*g;t.fillRect(p-g,x-g,e,e)}else t.beginPath(),t.arc(p,x,g,0,ut),t.fill()}}}else{const a=.55,r=.9*Math.min(b/a,S);{const e=/\p{Extended_Pictographic}/u.test(n.customText||n.charset);t.font=e?`${r}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${r}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const i=n.charsetFrames,s=!!i?.length,h=s?i[Math.floor(Math.max(0,f)*(n.charsetFps??2))%i.length]:n.charset,l=t.getTransform();if(!A&&G&&!s&&"accent"===dt&&!d&&n.hoverStrength<=0&&!/\p{Extended_Pictographic}/u.test(n.customText||n.charset)&&"letterSpacing"in t&&/^[\x20-\x7e]*$/.test(n.customText||n.charset)&&e.every(t=>t.every(t=>t.a<10||255===t.a&&1===t.char.length&&/^[\x20-\x7e]$/.test(t.char)))){const n=t.letterSpacing;t.letterSpacing="0px";const o=t.measureText("M").width;t.letterSpacing=b-o+"px",t.fillStyle=`rgb(${H},${j},${$})`,t.globalAlpha=1,t.textAlign="left";for(let n=0;n<M;n++){const a=e[n];let r="";for(let t=0;t<g;t++){const e=a[t];r+=e.a<10?" ":e.char}0!==r.trim().length&&t.fillText(r,.5*(b-o),n*S+.5*S)}return t.letterSpacing=n,t.textAlign="center",void(t.globalAlpha=1)}const u="glitchText"===lt&&A,p="!@#$%^&*<>{}[]|/\\~`0123456789",x=p.length;let v="",w=0,y=0,E=0,C=0,I=0,P=0;if(u){const t=n.hoverText??"ASCIIFY";if(y=Math.round(V*g),E=Math.round(K*M),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");v=e[((7*Math.floor(y/Math.max(1,Math.ceil(g/5)))+13*Math.floor(E/Math.max(1,Math.ceil(M/3))))%e.length+e.length)%e.length]}else v=t||"ASCIIFY";w=v.length,C=Math.max(3,Math.min(12,Math.round(M*z*.6)));const e=Math.floor(C/2);I=Math.max(0,E-e),I+C>M&&(I=Math.max(0,M-C)),P=y-Math.floor(w/2)}for(let a=d?.y??0;a<(d?.bottom??M);a++){const r=e[a];for(let i=d?.x??0;i<(d?.right??g);i++){const d=G?r[i]:st(i,a,r[i],n.customText?void 0:_(h));if(d.a<10)continue;let z=s&&null!=d.lum?Q(d.lum,_(h),mt):d.char;if(" "===z)continue;let N=1,Y=0,X=0,J=0,Z=0;if(A&&!u&&i>=O&&i<=q&&a>=U&&a<=B){const t=D(i*Mt,a*gt,V,K,k,ht,b,S,lt,ct,ft,m?.trail,o/c);if(N=t.scale,Y=t.offsetX,X=t.offsetY,J=t.glow,Z=t.colorBlend,"trail"===lt&&t.proximity>0){const n=Math.max(0,Math.min(g-1,Math.round(i-t.offsetX/b))),o=Math.max(0,Math.min(M-1,Math.round(a-t.offsetY/S))),r=e[o][n],s=r.lum??.299*r.r+.587*r.g+.114*r.b;z=Q(Math.min(255,s+t.proximity*ht*65),_(h),mt)}}if(u&&a>=I&&a<I+C){const t=i-P;if(t>=0&&t<w){const e=v[t],n=Math.abs(a-E)/Math.max(1,.5*C),o=Math.abs(i-y)/Math.max(1,w),r=Math.max(n,o),s=Math.max(0,Math.min(1,1-.9*r)),h=43758.5453*Math.sin(127.1*i+311.7*a+43758.5453*Math.floor(12*f));z=Math.abs(h-Math.floor(h))<s?e:p[Math.abs(Math.floor(97*h))%x],J=.3+.7*s,Z=.3+.65*s}}const tt=i*b+.5*b+Y,et=a*S+.5*S+X;let nt;if(Z>0){const t=W(d,dt,H,j,$,mt);nt=`rgb(${Math.min(255,t[0]+(T-t[0])*Z|0)},${Math.min(255,t[1]+(F-t[1])*Z|0)},${Math.min(255,t[2]+(L-t[2])*Z|0)})`}else nt=R(d,dt,H,j,$,mt);const ot=Math.min(1,.00392156863*d.a*(1+J));ot!==xt&&(t.globalAlpha=ot,xt=ot),nt!==pt&&(t.fillStyle=nt,pt=nt),1!==N?(t.translate(tt,et),t.scale(N,N),t.fillText(z,0,0),t.setTransform(l)):t.fillText(z,tt,et)}}}t.globalAlpha=1}function xt(t="classic"){if("classic"!==t)throw new RangeError(`Art preset "${String(t)}" was removed in 4.1. Use a StudioStyle with asciify-engine/studio, or supply options.charset directly.`);return{artStyle:"classic"}}function vt(t){return Math.max(0,Math.min(1,t))}function wt(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function yt(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function bt(t,e={}){const n=vt(t),o=vt(n*(void 0===e.speed?1:Math.max(.001,e.speed)));return vt(e.ease?e.ease(o):o)}function St(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const o=n.from??0,a=n.to??t.duration,r=Math.max(o,Math.min(a,t.duration)),i=bt(e,n),s=o+(r-o)*i;t.currentTime=Math.min(Math.max(o,s),Math.max(o,r-.04)),n.onUpdate?.(i,t)}function Et(t,e){return Math.abs(t.currentTime-e)<1/240?kt(t):new Promise(n=>{const o=()=>{t.removeEventListener("seeked",o),n()};t.addEventListener("seeked",o,{once:!0});const a=t.fastSeek;a?a.call(t,e):t.currentTime=e})}function kt(t){const e=t.requestVideoFrameCallback;return new Promise(e?n=>{let o=!1;const a=()=>{o||(o=!0,n())};e.call(t,a),window.setTimeout(a,32)}:t=>requestAnimationFrame(()=>t()))}function At(t,e={}){const n=wt(e.trigger)??t;t.pause();const o=e.gsap,a=e.ScrollTrigger??o?.ScrollTrigger;if(o&&a?.create){o.registerPlugin?.(a);const r=a.create({trigger:n,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:n=>St(t,n.progress,e)});return()=>r.kill?.()}return function(t,e,n){let o=0;const a=()=>{o=0;const a=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,i=a.height+r,s=i>0?vt((r-a.top)/i):0;St(t,s,n)},r=()=>{o||(o=requestAnimationFrame(a))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),o&&cancelAnimationFrame(o)}}(t,n,e)}function Ct(t,e,n){const o=e.gsap,a=e.ScrollTrigger??o?.ScrollTrigger;if(o&&a?.create){o.registerPlugin?.(a);const r=a.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>n(t.progress)});return()=>r.kill?.()}return function(t,e){let n=0;const o=()=>{n=0;const o=t.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,r=o.height+a,i=r>0?vt((a-o.top)/r):0;e(i)},a=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),n&&cancelAnimationFrame(n)}}(t,n)}function Tt(t,e,n){if(!t||!e||!n.sourceCrop)return{w:t,h:e};const o=rt(n.sourceCrop,t,e);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function Ft(t,e,n,o){const a=o.chromaKey;if(null==a||!1===a)return!1;if(!0===a)return e>1.4*t&&e>1.4*n&&e>80;if("blue-screen"===a)return n>1.4*t&&n>1.4*e&&n>80;const r=z(a),i=(o.chromaKeyTolerance??60)**2,s=t-r.r,h=e-r.g,l=n-r.b;return s*s+h*h+l*l<=i}function Lt(t,e,n){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const o=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!o||!a)return e;const r=rt(e.sourceCrop,o,a),i=Math.min(360,Math.max(1,Math.round(r.width))),s=Math.max(1,Math.round(i*(r.height/r.width))),{ctx:h}=k(i,s);h.drawImage(t,r.x,r.y,r.width,r.height,0,0,i,s);const l=h.getImageData(0,0,i,s).data,c=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let f=i,m=s,d=-1,u=-1;for(let t=0;t<s;t++)for(let n=0;n<i;n++){const o=4*(t*i+n),a=l[o+3],r=l[o],s=l[o+1],h=l[o+2];a<=8||.2126*r+.7152*s+.0722*h<=c||Ft(r,s,h,e)||(n<f&&(f=n),t<m&&(m=t),n>d&&(d=n),t>u&&(u=t))}if(d<f||u<m)return e;const M=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),g=Math.round(i*M),p=Math.round(s*M);f=Math.max(0,f-g),m=Math.max(0,m-p),d=Math.min(i-1,d+g),u=Math.min(s-1,u+p);const x=function(t,e,n,o,a){const r=a&&Number.isFinite(a)&&a>0?a:null;if(!r)return t;const i=e.x,s=e.y,h=e.x+e.width,l=e.y+e.height,c=Math.max(i,t.left),f=Math.max(s,t.top),m=Math.min(h,n-t.right),d=Math.min(l,o-t.bottom),u=Math.max(1,m-c),M=Math.max(1,d-f),g=c+u/2,p=f+M/2;let x=u,v=M;x/v<r?x=v*r:v=x/r;x>e.width&&(x=e.width,v=Math.max(M,Math.min(e.height,x/r)));v>e.height&&(v=e.height,x=Math.max(u,Math.min(e.width,v*r)));let w=g-x/2,y=p-v/2;return w=Math.max(i,Math.min(h-x,w)),y=Math.max(s,Math.min(l-v,y)),{left:w,top:y,right:n-(w+x),bottom:o-(y+v)}}({left:r.x+f/i*r.width,top:r.y+m/s*r.height,right:o-(r.x+(d+1)/i*r.width),bottom:a-(r.y+(u+1)/s*r.height)},{x:r.x,y:r.y,width:r.width,height:r.height},o,a,n);return{...e,sourceCrop:{unit:"pixel",...x,preserveAspect:!1}}}function It(t){const e=t.sourceCrop;return e&&"pixel"===e.unit?void 0===e.left||void 0===e.top||void 0===e.right||void 0===e.bottom?null:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}:null}async function Rt(t,e,n,o,a){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const r=t.currentTime,i=function(t,e,n,o){const a=!0===o?{}:o||{},r=Math.max(0,a.from??e),i=a.to??n??(Number.isFinite(t.duration)?t.duration:r),s=Math.max(r,i-.04),h=Math.max(0,s-r),l=h>.1?[r,r+.25*h,r+.5*h,r+.75*h,s]:[r];return Array.from(new Set(l.map(t=>Math.max(0,Number(t.toFixed(3))))))}(t,n,o,a);let s=null;for(const n of i){await Et(t,n),await kt(t);const o=It(Lt(t,e));o&&(s=s?{left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.min(s.right,o.right),bottom:Math.min(s.bottom,o.bottom)}:o)}return await Et(t,r),await kt(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function Ht(t,e,n=2048){return Wt({sourceWidth:t,sourceHeight:e,maxRenderDimension:n})}function Wt({sourceWidth:t,sourceHeight:e,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:a=2048}){const r=Math.max(1,t),i=Math.max(1,e),s=r/i,h=Math.max(1,a),l=Math.min(1,h/Math.max(r,i)),c=Math.max(r,i)*l,f=Math.max(0,n,o),m=Math.min(h,Math.max(c,f));return s>=1?{renderW:Math.round(m),renderH:Math.round(m/s)}:{renderW:Math.round(m*s),renderH:Math.round(m)}}function jt(t,e,n,o){if(void 0===t)return;if("number"==typeof t)return t;const a=t.trim();if(a.endsWith("%")){const t=Number.parseFloat(a)/100;return Number.isFinite(t)?e*t:void 0}if(a.endsWith("px")){const t=Number.parseFloat(a);return Number.isFinite(t)?t:void 0}if(a.endsWith("vw")){const t=Number.parseFloat(a)/100;return Number.isFinite(t)?n*t:void 0}if(a.endsWith("vh")){const t=Number.parseFloat(a)/100;return Number.isFinite(t)?o*t:void 0}}function $t(t,e,n,o,a,r=2048,i={}){const{width:s,height:h}=e.getBoundingClientRect();if(!s||!h)return{renderW:0,renderH:0,dpr:1};const l="undefined"!=typeof window?window.innerWidth:s,c="undefined"!=typeof window?window.innerHeight:h,f=jt(i.width,s,l,c)??s,m=jt(i.height,h,l,c)??h,d=function(t,e,n,o,a){const r=t=>{const n=jt(t,e,o,a);return n&&n>0?n:0},i=t=>{const e=jt(t,n,o,a);return e&&e>0?e:0};return void 0===t?{x:0,y:0}:"number"==typeof t||"string"==typeof t?{x:r(t),y:i(t)}:{x:r(t.x),y:i(t.y)}}(i.bleed,s,h,l,c),u=f+2*d.x,M=m+2*d.y,{cssW:g,cssH:p}=function(t,e,n,o="contain"){if("fill"===o)return{cssW:t,cssH:e};let a=t,r=a/n;const i="cover"===o,s=r>e;return(i&&!s||!i&&s)&&(r=e,a=r*n),"scale-down"===o&&(a=Math.min(a,t),r=Math.min(r,e)),{cssW:Math.round(a),cssH:Math.round(r)}}(u,M,n,i.objectFit??"contain"),x="undefined"!=typeof window&&window.devicePixelRatio||1;let v,w;o&&a?({renderW:v,renderH:w}=Wt({sourceWidth:o,sourceHeight:a,cssWidth:g,cssHeight:p,maxRenderDimension:r})):(v=g,w=p);const y=8e6,b=v*x*w*x>y?Math.sqrt(y/(v*w)):x;return t.width=Math.round(v*b),t.height=Math.round(w*b),t.style.width=`${g}px`,t.style.height=`${p}px`,{renderW:v,renderH:w,dpr:b}}async function Pt(t,e,{fontSize:o,artStyle:a="classic",options:r={}}={}){let i;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((n,o)=>{e.onload=()=>n(),e.onerror=()=>o(new Error(`Failed to load image: ${t}`)),e.src=t}),i=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=()=>n(new Error("Image failed to load"))}),i=t):i=t;const s=xt(a),h=o??r.fontSize??10,l={...n,...s,artStyle:a,...r,fontSize:h},c=e.getContext("2d");if(!c)throw new Error("Could not get 2d context from canvas");const{w:f,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(i),{renderW:d,renderH:u}=Ht(f,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,g=8e6,p=d*M*u*M>g?Math.sqrt(g/(d*u)):M;e.width===Math.round(d*p)&&e.height===Math.round(u*p)||(e.width=Math.round(d*p),e.height=Math.round(u*p));const{frame:x}=it(i,l,d,u),v=(t,e)=>{c.save(),c.setTransform(p,0,0,p,0,0),gt(c,x,l,d,u,t/1e3,e),c.restore()};v(0,null);return U(e,v,{continuous:"none"!==l.animationStyle||!!l.charsetFrames?.length,interactive:l.hoverStrength>0}).stop}async function zt(t,e,{fontSize:o,artStyle:a="classic",options:r={}}={}){const i="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??r.fontSize??10;let h={...n,...xt(a),artStyle:a,...r,fontSize:s};const l=e.getContext("2d");if(!l)throw new Error("Could not get 2d context from canvas");const{frames:c,fps:f}=await ft(i,h,e.width,e.height);if(!c.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const m=performance.now();let d=-1;return U(e,(t,n)=>{const o=Math.floor((t-m)*f/1e3)%c.length;o===d&&!n&&h.hoverStrength<=0&&"none"===h.animationStyle&&!h.charsetFrames?.length||(gt(l,c[o],h,e.width,e.height,(t-m)/1e3,n),d=o)},{continuous:!0,interactive:h.hoverStrength>0}).stop}async function Ot(t,e,{fontSize:o,artStyle:a="classic",options:r={},fitTo:i,objectFit:s,objectPosition:h,scale:l,width:c,height:f,bleed:m,preExtract:d=!1,fps:u,maxRenderDimension:M=2048,trim:g,scroll:p,maxCachedFrames:x=90,onReady:v,onFrame:w}={}){const y=g?.start??0,b=g?.end,S=o??r.fontSize??10;let E={...n,...xt(a),artStyle:a,...r,fontSize:S};const k=e.getContext("2d");if(!k)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof i?document.querySelector(i):i instanceof HTMLElement?i:null,C={objectFit:s,objectPosition:h,scale:l,width:c,height:f,bleed:m},T=function(t,e){var n;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height||void 0!==t.bleed}(e))return()=>{};const o={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0===e.scale&&void 0===e.bleed||(t.style.maxWidth="none",t.style.maxHeight="none"),void 0!==e.scale){const o=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(o)),(n=t.style).transformOrigin||(n.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=o.width,t.style.height=o.height,t.style.objectFit=o.objectFit,t.style.objectPosition=o.objectPosition,t.style.maxWidth=o.maxWidth,t.style.maxHeight=o.maxHeight,t.style.transformOrigin=o.transformOrigin,o.scale?t.style.setProperty("scale",o.scale):t.style.removeProperty("scale")}}(e,C),F=t=>()=>{t(),T()};if(d){let n;"string"==typeof t?(n=document.createElement("video"),n.crossOrigin="anonymous",n.src=t,n.readyState<2&&await new Promise((e,o)=>{n.onloadeddata=()=>e(),n.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))})):n=t,E=await Rt(n,E,y,b,p);const o=Tt(n.videoWidth,n.videoHeight,E);A&&$t(e,A,o.w/o.h,o.w,o.h,M,C);const{renderW:a,renderH:r}=Ht(o.w,o.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,h=a*i*r*i>s?Math.sqrt(s/(a*r)):i;e.width===Math.round(a*h)&&e.height===Math.round(r*h)||(e.width=Math.round(a*h),e.height=Math.round(r*h));const l=void 0!==b?b-y:10,c=u??(p?18:void 0);if(yt(E)){const{frames:t,fps:o}=await ct(n,E,a,r,c,l,void 0,y),i=e=>{const n=t[e];n&&(k.save(),k.setTransform(h,0,0,h,0,0),ht(k,n,E,a,r),k.restore(),w?.())};if(p){let o=!1,a=-1;const r=!0===p?{}:p,s=Ct(wt(r.trigger)??A??e,r,e=>{const s=bt(e,r),h=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));h!==a&&(a=h,i(h),o||(o=!0,v?.(n)),r.onUpdate?.(s,n))});return i(0),o=!0,v?.(n),F(s)}let s,f=!1,m=0,d=performance.now(),u=!0;const M=1e3/o,g=e=>{f||(e-d>=M&&(i(m),m=(m+1)%t.length,d=e,u&&(u=!1,v?.(n))),s=requestAnimationFrame(g))};return s=requestAnimationFrame(g),F(()=>{f=!0,cancelAnimationFrame(s)})}const{frames:f,fps:m}=await lt(n,E,a,r,c,l,void 0,y);if(!f.length)throw new Error("asciifyVideo: no frames were decoded.");let d=0;const g=performance.now(),x=U(e,(t,e)=>{p||(d=Math.floor((t-g)*m/1e3)%f.length),k.save(),k.setTransform(h,0,0,h,0,0),gt(k,f[d],E,a,r,(t-g)/1e3,e),k.restore(),w?.()},{continuous:!p||"none"!==E.animationStyle||!!E.charsetFrames?.length,interactive:E.hoverStrength>0});let S;if(p){const t=!0===p?{}:p;S=Ct(wt(t.trigger)??A??e,t,e=>{d=Math.max(0,Math.min(f.length-1,Math.round(bt(e,t)*(f.length-1)))),x.wake(),t.onUpdate?.(e,n)})}return v?.(n),F(()=>{x.stop(),S?.()})}let L,I=!1;"string"==typeof t?(L=document.createElement("video"),L.crossOrigin="anonymous",L.src=t,L.muted=!0,L.loop=!0,L.playsInline=!0,L.setAttribute("playsinline",""),Object.assign(L.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(L),I=!0,await new Promise((e,n)=>{L.onloadedmetadata=()=>e(),L.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))}),await L.play().catch(()=>{})):(L=t,L.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{L.removeEventListener("loadedmetadata",o),L.removeEventListener("error",a)},o=()=>{n(),t()},a=()=>{n(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};L.addEventListener("loadedmetadata",o),L.addEventListener("error",a),L.load()}),L.paused&&await L.play().catch(()=>{})),y>0&&(L.currentTime=y,await new Promise(t=>{const e=()=>{L.removeEventListener("seeked",e),t()};L.addEventListener("seeked",e)}),await kt(L));let R=null;(y>0||void 0!==b)&&(R=()=>{(void 0!==b&&L.currentTime>=b||y>0&&L.currentTime<y)&&(L.currentTime=y)},L.addEventListener("timeupdate",R)),E=await Rt(L,E,y,b,p);let H=null;const W=Tt(L.videoWidth,L.videoHeight,E);let{renderW:j,renderH:$}=Ht(W.w,W.h,M);const P=t=>"frame"===E.chromaKeyTrimMode?Lt(t,E,j/$):E;if(A){const t=W.w/W.h,n=W.w,o=W.h,a=$t(e,A,t,n,o,M,C);j=a.renderW,$=a.renderH;const r=e.getContext("2d");r&&r.setTransform(a.dpr,0,0,a.dpr,0,0),H=new ResizeObserver(()=>{const a=$t(e,A,t,n,o,M,C);j=a.renderW,$=a.renderH;const r=e.getContext("2d");r&&r.setTransform(a.dpr,0,0,a.dpr,0,0)}),H.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,n=8e6,o=j*t*$*t>n?Math.sqrt(n/(j*$)):t;e.width===Math.round(j*o)&&e.height===Math.round($*o)||(e.width=Math.round(j*o),e.height=Math.round($*o)),k.setTransform(o,0,0,o,0,0)}let z=!0,O=null;const q=p&&!d,D=u&&u>0?1e3/u:0;let B=0;const V=!q&&yt(E);if(q&&"ascii"===E.renderMode&&"none"===E.animationStyle&&E.hoverStrength<=0&&!E.charsetFrames?.length){const t=!0===p?{}:p,n=wt(t.trigger)??A??e,o=t.from??y,a=t.to??b??L.duration,r=Math.max(o,Math.min(a,L.duration)),i=Math.max(.001,r-o),s=Math.min(60,Math.max(12,u??30)),h=Math.max(2,Math.ceil(i*s)+1),l=new Array(h),c=[],f=Math.max(2,Math.min(h,Math.floor(x))),m=()=>{for(;c.length>f;){const t=c.findIndex(t=>t!==M&&Math.abs(t-M)>2),e=t>=0?t:0,n=c.splice(e,1)[0];void 0!==n&&(l[n]=void 0)}},d=t=>{const e=c.indexOf(t);e>=0&&c.splice(e,1),c.push(t),m()};let M=0,g=0,S=-1,C=0,T=!1,W=!1,z=!1;const q=new Set,U=document.createElement("video");U.muted=!0,U.playsInline=!0,U.preload="auto",U.crossOrigin=L.crossOrigin||"anonymous",U.src=L.currentSrc||L.src,Object.assign(U.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(U),U.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{U.removeEventListener("loadedmetadata",o),U.removeEventListener("error",a)},o=()=>{n(),t()},a=()=>{n(),e(new Error("asciifyVideo: cache video failed to load metadata."))};U.addEventListener("loadedmetadata",o),U.addEventListener("error",a),U.load()}),U.pause(),L.paused&&await L.play().catch(()=>{});const V=t=>o+i*t/Math.max(1,h-1),K=t=>Math.max(0,Math.min(h-1,Math.round(t*(h-1)))),N=P(L),Y=st(L,N,j,$);Y.rows.length>0&&(l[0]=Y,d(0),ht(k,Y,N,j,$),z=!0,v?.(L),w?.());const X=t=>{if(l[t])return t;for(let e=1;e<h;e++){const n=t-e,o=t+e;if(n>=0&&l[n])return n;if(o<h&&l[o])return o}return-1},G=()=>{if(!l[M])return M;for(const t of q)if(!l[t])return t;for(let t=1;t<h;t++){const e=M-t,n=M+t;if(e>=0&&!l[e])return e;if(n<h&&!l[n])return n}return-1},_=t=>{t<0||t>=h||l[t]||(q.add(t),J())},J=async()=>{if(T||W)return;const t=G();if(!(t<0)){q.delete(t),W=!0;try{if(await Et(U,V(t)),!T){const e=P(U),n=st(U,e,j,$);n.rows.length>0&&(l[t]=n,d(t))}}finally{W=!1,T||requestAnimationFrame(()=>{J()})}}},Q=()=>{if(T)return;const t=X(M);if(t>=0&&t!==S){const e=l[t];e&&(ht(k,e,E,j,$),S=t,z||(z=!0,v?.(L)),w?.())}else if(t<0||S<0){const t=performance.now();if(D<=0||t-B>=D){const e=P(L),n=st(L,e,j,$);n.rows.length>0&&(ht(k,n,e,j,$),B=t,z||(z=!0,v?.(L)),w?.())}}_(M),C=requestAnimationFrame(Q)};return O=Ct(n,t,e=>{const n=function(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const o=n.from??0,a=n.to??t.duration,r=Math.max(o,Math.min(a,t.duration)),i=bt(e,n),s=o+(r-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,r-.04))}}(L,e,{...t,from:o,to:r});g=n?.progress??vt(e),M=K(g),_(M),_(M-1),_(M+1),_(M-2),_(M+2),_(M-3),_(M+3),t.onUpdate?.(g,L)}),_(0),_(1),C=requestAnimationFrame(Q),F(()=>{T=!0,cancelAnimationFrame(C),O?.(),H?.disconnect(),q.clear(),c.length=0,l.fill(void 0),U.pause(),U.src="",U.removeAttribute("src"),U.load(),U.isConnected&&U.remove(),R&&L.removeEventListener("timeupdate",R),I&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}if(q){const t=!0===p?{}:p;O=At(L,{...t,trigger:t.trigger??A??e,from:t.from??y,to:t.to??b})}let K=-1,N=0,Y=-1,X=0;const G="function"==typeof L.requestVideoFrameCallback,_=()=>{X=L.requestVideoFrameCallback(()=>{N++,_()})};G&&_();let J=0,Q=0,Z=null;const tt=U(e,(t,n)=>{if(L.readyState<2||0===e.width||0===e.height)return;if(D>0&&t-B<D&&!n)return;if(y>0&&L.currentTime<y)return;if(void 0!==b&&L.currentTime>=b)return;const o=(G?N!==Y:L.currentTime!==K)||J!==j||Q!==$;if(o||!(E.hoverStrength<=0)||"none"!==E.animationStyle||E.charsetFrames?.length){if(V){const t=P(L),e=st(L,t,j,$);ht(k,e,t,j,$)}else!o&&Z||(Z=it(L,P(L),j,$).frame),gt(k,Z,E,j,$,t/1e3,n);K=L.currentTime,Y=N,J=j,Q=$,B=t,z&&(z=!1,v?.(L)),w?.()}},{continuous:!0,interactive:E.hoverStrength>0});return F(()=>{tt.stop(),X&&L.cancelVideoFrameCallback(X),O?.(),H?.disconnect(),R&&L.removeEventListener("timeupdate",R),I&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}function qt(t,e,n){return Ot(t,e,n)}function Dt(t,e={},o,a){const r={...n,...e},{frame:i,cols:s}=it(t,r,o,a);if(!i.length||0===s)return"";const h=[];for(const t of i)h.push(t.map(t=>t.char).join(""));return h.join("\n")}function Ut(t,e={},o,a){const r={...n,...e},{frame:i,cols:s}=it(t,r,o,a);if(!i.length||0===s)return"";const h=[];for(const t of i){let e="";for(const n of t)" "===n.char||n.a<10?e+=" ":e+=`[38;2;${n.r};${n.g};${n.b}m${n.char}`;h.push(e)}return h.join("\n")}function Bt(t,e,n,o="#505050",a=100){if(!t||e<=0||n<=0)return[];const r=function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return n?{r:+n[1],g:+n[2],b:+n[3]}:null}(o)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:n},(t,n)=>Array.from({length:e},(t,o)=>({char:i[(n*e+o)%s],r:r.r,g:r.g,b:r.b,a:a})))}var Vt=new WeakMap;function Kt(t,e,o,a,r={},i){const{fontSize:s=10,lineHeight:h=1.6,color:l="#505050",opacity:c=100,hoverEffect:f="spotlight",hoverStrength:m=.85,hoverRadius:d=.18,hoverColor:u="#d4ff00"}=r,M=Math.max(1,Math.floor(e/s)),g=Math.max(1,Math.floor(o/(s*h))),p=JSON.stringify([a,M,g,l,c]);let x=Vt.get(t);x&&x.key===p||(x={key:p,frame:Bt(a,M,g,l,c)},Vt.set(t,x));gt(t,x.frame,{...n,fontSize:s,hoverEffect:f,hoverStrength:m,hoverRadius:d,hoverColor:u},e,o,0,i??null)}function Nt(t,{format:e="png",quality:n=.92,scale:o=1}={}){return new Promise((a,r)=>{let i=t;if(1!==o){const e=document.createElement("canvas");e.width=Math.round(t.width*o),e.height=Math.round(t.height*o);const n=e.getContext("2d");if(!n)return void r(new Error("captureSnapshot: could not get 2d context"));n.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?a(t):r(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,n)})}async function Yt(t,e={}){const{filename:n="asciify-snapshot",format:o="png",...a}=e,r=await Nt(t,{format:o,...a}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(r),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)}async function Xt(t,{fontSize:e=10,style:o="classic",options:a={},liveOptions:r,mirror:i=!0,constraints:s={facingMode:"user"},dpr:h}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const l=xt(o),c=await navigator.mediaDevices.getUserMedia({video:s}),f=document.createElement("video");f.srcObject=c,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const m={...n,...l,...a,fontSize:e},d=t.getContext("2d");if(!d)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=h??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&d.scale(u,u);let M=null;const g=e=>{const n=t.getBoundingClientRect();M={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},p=()=>{M=null};m.hoverStrength>0&&(t.addEventListener("mousemove",g),t.addEventListener("mouseleave",p));let x,v=!1;const w=performance.now(),y=e=>{if(!v){if(f.readyState>=f.HAVE_CURRENT_DATA){const n=t.width/u,o=t.height/u,a=(e-w)/1e3,s=r?{...m,...r()}:m;s.hoverStrength>0?(t.addEventListener("mousemove",g),t.addEventListener("mouseleave",p)):(t.removeEventListener("mousemove",g),t.removeEventListener("mouseleave",p));const{frame:h}=it(f,s,n,o),l=M&&i?{x:1-M.x,y:M.y}:M;i?(d.save(),d.scale(-1,1),d.translate(-n,0),gt(d,h,s,n,o,a,l),d.restore()):gt(d,h,s,n,o,a,l)}x=requestAnimationFrame(y)}};return x=requestAnimationFrame(y),()=>{v=!0,cancelAnimationFrame(x),t.removeEventListener("mousemove",g),t.removeEventListener("mouseleave",p),c.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var Gt={A:[28,54,99,127,99,99,99],B:[126,99,99,126,99,99,126],C:[62,99,96,96,96,99,62],D:[124,102,99,99,99,102,124],E:[127,96,96,124,96,96,127],F:[127,96,96,124,96,96,96],G:[62,99,96,111,99,99,62],H:[99,99,99,127,99,99,99],I:[127,8,8,8,8,8,127],J:[63,6,6,6,102,102,60],K:[99,102,108,120,108,102,99],L:[96,96,96,96,96,96,127],M:[99,119,107,107,99,99,99],N:[99,115,107,103,99,99,99],O:[62,99,99,99,99,99,62],P:[126,99,99,126,96,96,96],Q:[62,99,99,99,107,102,61],R:[126,99,99,126,108,102,99],S:[62,99,96,62,3,99,62],T:[127,8,8,8,8,8,8],U:[99,99,99,99,99,99,62],V:[99,99,99,99,54,28,8],W:[99,99,99,107,107,54,20],X:[99,54,28,8,28,54,99],Y:[99,99,54,28,8,8,8],Z:[127,3,6,12,24,48,127],a:[0,0,60,3,62,99,61],b:[96,96,124,99,99,99,124],c:[0,0,62,96,96,96,62],d:[3,3,31,99,99,99,31],e:[0,0,62,99,127,96,62],f:[30,48,48,126,48,48,48],g:[0,0,63,99,63,3,62],h:[96,96,124,99,99,99,99],i:[8,0,24,8,8,8,28],j:[4,0,12,4,4,36,24],k:[96,96,102,108,120,108,102],l:[24,8,8,8,8,8,28],m:[0,0,92,107,107,99,99],n:[0,0,94,99,99,99,99],o:[0,0,62,99,99,99,62],p:[0,0,126,99,126,96,96],q:[0,0,63,99,63,3,3],r:[0,0,94,99,96,96,96],s:[0,0,62,96,62,3,124],t:[48,48,126,48,48,48,30],u:[0,0,99,99,99,103,59],v:[0,0,99,99,54,28,8],w:[0,0,99,99,107,54,20],x:[0,0,99,54,28,54,99],y:[0,0,99,99,63,3,62],z:[0,0,127,6,12,24,127],0:[62,99,103,107,115,99,62],1:[8,24,56,8,8,8,62],2:[62,99,3,6,24,48,127],3:[62,99,3,30,3,99,62],4:[6,14,22,38,127,6,6],5:[127,96,126,3,3,99,62],6:[62,99,96,126,99,99,62],7:[127,3,6,12,24,24,24],8:[62,99,99,62,99,99,62],9:[62,99,99,63,3,99,62]," ":[0,0,0,0,0,0,0],"!":[24,24,24,24,24,0,24],"?":[62,99,3,14,8,0,8],".":[0,0,0,0,0,24,24],",":[0,0,0,0,0,24,48],";":[0,24,24,0,24,24,48],":":[0,24,24,0,24,24,0],"-":[0,0,0,62,0,0,0],_:[0,0,0,0,0,0,127],"'":[24,24,32,0,0,0,0],'"':[54,54,36,0,0,0,0],"`":[24,8,0,0,0,0,0],")":[24,12,6,6,6,12,24],"(":[12,24,48,48,48,24,12],"[":[60,48,48,48,48,48,60],"]":[30,6,6,6,6,6,30],"{":[14,24,24,48,24,24,14],"}":[56,12,12,6,12,12,56],"/":[3,6,12,24,48,96,0],"\\":[96,48,24,12,6,3,0],"|":[8,8,8,8,8,8,8],"+":[0,8,8,62,8,8,0],"=":[0,0,62,0,62,0,0],"*":[0,42,28,127,28,42,0],"#":[36,36,127,36,127,36,36],"@":[62,99,111,107,111,96,62],"&":[24,36,24,60,74,68,58],"%":[99,38,4,8,16,50,99],$:[8,62,72,62,9,62,8],"^":[8,20,34,0,0,0,0],"~":[0,0,50,76,0,0,0],"<":[6,12,24,48,24,12,6],">":[48,24,12,6,12,24,48]},_t=[127,65,65,65,65,65,127];function Jt(t){return Gt[t]??Gt[t.toUpperCase()]??_t}function Qt(t,e={}){if(!t)return"";const{char:n="█",scale:o=1}=e,a=[...n][0]??"█",r=Math.max(1,Math.floor(o)),i=7*r,s=r,h=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const n=Jt(t[e]);for(let t=0;t<7;t++){const e=n[t];let o="";for(let t=6;t>=0;t--)o+=(e>>t&1?a:" ").repeat(r);for(let e=0;e<r;e++)h[t*r+e]+=o}if(e<t.length-1)for(let t=0;t<i;t++)h[t]+=" ".repeat(s)}return h.join("\n")}function Zt(t,e,n={}){const{color:o="#d4ff00",bgColor:a,fontSize:r=10}=n,i=Qt(e,n);if(!i)return;const s=i.split("\n"),h=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(h*r*.6),t.height=Math.ceil(s.length*r);const l=t.getContext("2d");a&&"transparent"!==a?(l.fillStyle=a,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=o,l.font=`${r}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*r))}var te=["ascii","blocks","braille","dots","lines","cross","diagonal","diamond","mixed","pixel","mosaic","lego","voxel","disco","dither","hex","led","cmyk","stipple","engraving","crosshatch","woodblock","risograph","pointillism"];export{t as CHARACTER_SETS,n as DEFAULT_OPTIONS,o as HOVER_PRESETS,e as PALETTE_THEMES,te as STUDIO_STYLES,Dt as asciiText,Ut as asciiTextAnsi,Pt as asciify,zt as asciifyGif,qt as asciifyLiveVideo,Qt as asciifyText,Ot as asciifyVideo,Xt as asciifyWebcam,Bt as buildTextFrame,Nt as captureSnapshot,tt as clearAsciifyCaches,Wt as computeCanvasRenderSize,At as createVideoScrollScrub,ft as gifToAsciiFrames,mt as gifToAsciiTextFrames,it as imageToAsciiFrame,st as imageToAsciiTextFrame,gt as renderFrameToCanvas,Kt as renderTextBackground,ht as renderTextFrameToCanvas,Zt as renderTextToCanvas,Yt as snapshotAndDownload,lt as videoToAsciiFrames,ct as videoToAsciiTextFrames};//# sourceMappingURL=index.js.map
1
+ var t={standard:{label:"Classic ASCII",chars:" .:-=+*#%@"},asciify:{label:"Asciify",chars:" .:-=+YCIFSA#@"},minimal:{label:"Minimal",chars:" .:+"},detailed:{label:"Detailed",chars:" .,:;-~=+*xX#%@"},letters:{label:"Letters",chars:" .liLTYCFSAWM"},technical:{label:"Technical",chars:" ._:;+/>=][{}*$#@"},blocks:{label:"Tonal blocks",chars:" ░▒▓█"},braille:{label:"Braille",chars:" ⠁⠃⠇⡇⣇⣧⣷⣿"}},e={dracula:{name:"Dracula",accent:"#bd93f9",bg:"#282a36",fg:"#f8f8f2"},monokai:{name:"Monokai",accent:"#a6e22e",bg:"#272822",fg:"#f8f8f2"},nord:{name:"Nord",accent:"#88c0d0",bg:"#2e3440",fg:"#eceff4"},catppuccin:{name:"Catppuccin",accent:"#cba6f7",bg:"#1e1e2e",fg:"#cdd6f4"},solarized:{name:"Solarized",accent:"#268bd2",bg:"#002b36",fg:"#839496"},gruvbox:{name:"Gruvbox",accent:"#b8bb26",bg:"#282828",fg:"#ebdbb2"}},n={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:t.standard.chars,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",fineDither:!1,customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},o={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},a={caustics:"sheen",grain:"shimmer",trace:"relight",tidal:"current",weave:"current",breeze:"current",reform:"develop",print:"develop",unfold:"develop"},r=[{value:"none",mode:"none",group:"Still",label:"Off",description:"Keep the image still. Hover stays available."},{value:"relight",mode:"relight",group:"Light",label:"Relight",description:"A key light circles the subject and models its own relief, like moving a lamp around a sculpture."},{value:"sheen",mode:"sheen",group:"Light",label:"Specular sweep",description:"One slow pass of light glances across the highlights and follows their form, then rests."},{value:"glow",mode:"glow",group:"Light",label:"Highlight bloom",description:"The brightest areas breathe a soft halo into their surroundings. Shadows stay deep."},{value:"shimmer",mode:"shimmer",group:"Light",label:"Glints",description:"Sparse glints on bright fine detail, like light on water, metal or an eye. Everything else holds still."},{value:"parallax",mode:"parallax",group:"Depth",label:"Parallax",description:"A slow camera drift: the subject moves against its background, read from the photo’s own depth cues."},{value:"push",mode:"push",group:"Depth",label:"Slow push",description:"A gentle push toward the subject and back, with nearer areas moving slightly more."},{value:"focus",mode:"focus",group:"Depth",label:"Focus pull",description:"Focus racks from the subject to the background and back; the characters soften out of focus."},{value:"mist",mode:"mist",group:"Atmosphere",label:"Mist",description:"Soft mist drifts through the distance and plain areas, leaving the subject clear."},{value:"current",mode:"current",group:"Atmosphere",label:"Drift",description:"Water swells and glints, falls stream down, sky and clouds drift slowly, like a cinemagraph. Subjects and buildings hold still."},{value:"develop",mode:"develop",group:"Reveal",label:"Develop",description:"The image holds, fades, then develops back in from its highlights to its shadows, like a print in the tray."}];var i=t=>Math.max(0,Math.min(1,t)),s=(t,e,n)=>{const o=i((n-t)/(e-t));return o*o*(3-2*o)},h=(t,e)=>{const n=(.06711056*t+.00583715*e)%1*52.9829189;return n-Math.floor(n)};function l(t){const e=Math.floor(t),n=Math.max(0,Math.min(1,(t-e-.2)/.6));return e+n*n*(3-2*n)}function c(t,e,n,o,a){if(!(a<1))for(let r=0;r<2;r++){for(let r=0;r<o;r++){let o=0;const i=r*n;for(let e=-a;e<=a;e++)o+=t[i+Math.max(0,Math.min(n-1,e))];for(let r=0;r<n;r++)e[i+r]=o/(2*a+1),o+=t[i+Math.min(n-1,r+a+1)]-t[i+Math.max(0,r-a)]}for(let r=0;r<n;r++){let i=0;for(let t=-a;t<=a;t++)i+=e[Math.max(0,Math.min(o-1,t))*n+r];for(let s=0;s<o;s++)t[s*n+r]=i/(2*a+1),i+=e[Math.min(o-1,s+a+1)*n+r]-e[Math.max(0,s-a)*n+r]}}}var f=new Float32Array(0);var m=t=>Math.max(0,Math.min(1,t)),d=(t,e,n)=>{const o=m((n-t)/(e-t));return o*o*(3-2*o)};function u(t,e,n=256){let o=0;for(let e=0;e<t.length;e++)t[e]>o&&(o=t[e]);if(o<=0)return 0;const a=new Uint32Array(n);for(let e=0;e<t.length;e++)a[Math.min(n-1,Math.floor(Math.max(0,t[e])/o*n))]++;let r=0;const i=t.length*e;for(let t=0;t<n;t++)if(r+=a[t],r>=i)return(t+1)/n*o;return o}var M=class{constructor(t){this.n=t,this.arrays=[],this.next=0}take(t){this.next===this.arrays.length&&this.arrays.push(new Float32Array(this.n));const e=this.arrays[this.next++];return t?e.set(t):e.fill(0),e}reset(){this.next=0}},g=null;function p(t,e,n,o,a){const r=2*a+1;for(let i=0;i<o;i++){const o=i*n;let s=0;for(let e=-a;e<=a;e++)s+=t[o+Math.max(0,Math.min(n-1,e))];for(let i=0;i<n;i++)e[o+i]=s/r,s+=t[o+Math.min(n-1,i+a+1)]-t[o+Math.max(0,i-a)]}for(let i=0;i<n;i++){let s=0;for(let t=-a;t<=a;t++)s+=e[Math.max(0,Math.min(o-1,t))*n+i];for(let h=0;h<o;h++)t[h*n+i]=s/r,s+=e[Math.min(o-1,h+a+1)*n+i]-e[Math.max(0,h-a)*n+i]}}function v(t,e,n,o,a,r,i){const s=n*o,h=i.take(),l=i.take(e),c=i.take(t),f=i.take(),m=i.take();for(let n=0;n<s;n++)f[n]=e[n]*e[n],m[n]=e[n]*t[n];p(l,h,n,o,a),p(c,h,n,o,a),p(f,h,n,o,a),p(m,h,n,o,a);for(let t=0;t<s;t++){const e=(m[t]-l[t]*c[t])/(f[t]-l[t]*l[t]+r);f[t]=e,m[t]=c[t]-e*l[t]}p(f,h,n,o,a),p(m,h,n,o,a);for(let n=0;n<s;n++)t[n]=f[n]*e[n]+m[n]}function x(t,e,n,o,a,r=2){for(let i=0;i<r;i++){for(let r=0;r<o;r++)for(let o=0;o<n;o++){const i=r*n+o;let s=t[i];o>0&&(s=Math.max(s,Math.min(e[i],t[i-1]*a))),r>0&&(s=Math.max(s,Math.min(e[i],t[i-n]*a),o>0?Math.min(e[i],t[i-n-1]*a):0,o<n-1?Math.min(e[i],t[i-n+1]*a):0)),t[i]=s}for(let r=o-1;r>=0;r--)for(let i=n-1;i>=0;i--){const s=r*n+i;let h=t[s];i<n-1&&(h=Math.max(h,Math.min(e[s],t[s+1]*a))),r<o-1&&(h=Math.max(h,Math.min(e[s],t[s+n]*a),i>0?Math.min(e[s],t[s+n-1]*a):0,i<n-1?Math.min(e[s],t[s+n+1]*a):0)),t[s]=h}}}function w(t,e,n,o,a){for(let r=0;r<o;r++)for(let o=0;o<n;o++){let i=1;for(let e=Math.max(0,o-a);e<=Math.min(n-1,o+a);e++)i=Math.min(i,t[r*n+e]);e[r*n+o]=i}for(let r=0;r<o;r++)for(let i=0;i<n;i++){let s=1;for(let t=Math.max(0,r-a);t<=Math.min(o-1,r+a);t++)s=Math.min(s,e[t*n+i]);t[r*n+i]=s}}function y(t,e,n,o,a){const r=n*o,i=Math.min(n,o),s=a.take(),h=a.take(),l=a.take(),M=a.take(),g=a.take();for(let n=0;n<r;n++){const o=t[4*n+3]/255;g[n]=o,s[n]=e[4*n]/255*o,h[n]=e[4*n+1]/255*o,l[n]=e[4*n+2]/255*o,M[n]=(.299*t[4*n]+.587*t[4*n+1]+.114*t[4*n+2])/255*o}const y=a.take(),b=(t,e)=>{const r=a.take(t);return c(r,y,n,o,e),r},S=Math.max(2,Math.round(.04*i)),E=Math.max(S+2,Math.round(.12*i)),k=Math.max(2,Math.round(.05*i)),A=b(M,1),C=b(M,S),T=b(M,E),F=a.take(),I=a.take(),L=a.take(),R=a.take(),H=a.take();for(let t=0;t<o;t++)for(let e=0;e<n;e++){const a=t*n+e;F[a]=Math.abs(M[a]-A[a]),I[a]=Math.abs(A[a]-C[a]),L[a]=Math.abs(C[a]-T[a]),R[a]=Math.abs(M[t*n+Math.min(n-1,e+1)]-M[t*n+Math.max(0,e-1)]),H[a]=Math.abs(M[Math.min(o-1,t+1)*n+e]-M[Math.max(0,t-1)*n+e])}c(F,y,n,o,k),c(I,y,n,o,k),c(L,y,n,o,k),c(R,y,n,o,2),c(H,y,n,o,2);const W=Math.max(.01,u(F,.9)+u(I,.9)),j=b(s,1),$=b(h,1),P=b(l,1),O=a.take(),z=a.take(),q=a.take();let D=0;for(let t=0;t<r;t++){const e=j[t],n=$[t],o=P[t],a=Math.max(e,n,o),r=a-Math.min(e,n,o);q[t]=a,z[t]=a>.001?r/a:0,D+=r;let i=0;r>1e-4&&(i=a===e?((n-o)/r+6)%6:a===n?(o-e)/r+2:(e-n)/r+4),O[t]=60*i}const U=d(.02,.07,D/r),B=Math.max(2,Math.round(.06*o)),V=new Float32Array(o);for(let t=0;t<o;t++){let e=0;for(let o=0;o<n;o++)e+=F[t*n+o]+I[t*n+o];V[t]=e/n}let K=.5,N=0;for(let t=Math.max(B,Math.round(.12*o));t<=Math.min(o-B,Math.round(.88*o));t++){let e=0,a=0,r=0,i=0;for(let o=0;o<n;o++){let r=0,i=0,s=0,h=0,l=0,c=0;for(let e=1;e<=B;e++){const a=(t-e)*n+o,f=(t+e-1)*n+o;r+=j[a],i+=$[a],s+=P[a],h+=j[f],l+=$[f],c+=P[f]}const f=(Math.abs(r-h)+Math.abs(i-l)+Math.abs(s-c))/B;e+=f,a+=f>.12?1:0}const s=Math.max(2,Math.round(.15*o)),h=Math.max(0,t-s),l=Math.min(o,t+s);for(let e=h;e<t;e++)r+=V[e];for(let e=t;e<l;e++)i+=V[e];r/=t-h,i/=l-t;const c=d(-.05,.3,(i-r)/(i+r+1e-4)),f=d(.08,.35,e/n)*(a/n)*c;f>N&&(N=f,K=t/o)}const Y=d(.15,.45,N),X=a.take(),G=a.take(),_=a.take();for(let t=0;t<r;t++)X[t]=Math.min(s[t],h[t],l[t]);w(X,y,n,o,1),c(X,y,n,o,S);for(let t=0;t<r;t++)G[t]=I[t]+L[t];let J=0,Q=0,Z=0;for(let t=0;t<r;t++)J+=j[t],Q+=$[t],Z+=P[t];J/=r,Q/=r,Z/=r;const tt=b(j,S),et=b($,S),nt=b(P,S),ot=b(j,E),at=b($,E),rt=b(P,E);for(let t=0;t<r;t++){const e=Math.hypot(tt[t]-J,et[t]-Q,nt[t]-Z),n=Math.hypot(tt[t]-ot[t],et[t]-at[t],nt[t]-rt[t]);_[t]=(e+1.5*n)*(.4+.6*z[t]*U+.4*(1-U))}const it=a.take(),st=a.take(),ht=a.take(),lt=a.take(),ct=a.take(),ft=a.take(),mt=a.take(),dt=a.take(),ut=a.take(),Mt=a.take();for(let t=0;t<o;t++)for(let e=0;e<n;e++)Mt[t*n+e]=Math.abs(M[Math.min(o-1,t+1)*n+e]-M[Math.max(0,t-1)*n+e]);c(Mt,y,n,o,1);for(let t=0;t<o;t++)for(let e=0;e<n;e++){const a=t*n+e,r=(t+.5)/o,i=O[a],s=z[a]*U,h=q[a],l=F[a]+I[a],c=d(175,200,i)*(1-d(250,275,i))*d(.08,.25,s),f=(1-d(45,65,i)+d(290,330,i))*d(.2,.45,s)*d(.3,.55,h),m=(1-d(.15,.35,s))*d(.45,.7,h)*Y,u=(1-d(.08,.2,h))*Y,M=Y>.3?1-d(K,K+.1,r):1-d(.4,.8,r),g=1-d(.02,.06,l),p=1-d(.03,.09,l);st[a]=Math.max(c*g,.7*u*(1-d(.008,.025,l)),f*p*.9)*M,ht[a]=Math.max(st[a],m*g*M),it[a]=0===t?st[a]:0,lt[a]=d(150,172,i)*(1-d(232,250,i))*d(.25,.45,s),mt[a]=d(1.3,2.2,(R[a]+.004)/(H[a]+.004))*d(.35,.55,A[a])*(1-d(.1,.18,z[a]*U))*d(.025,.07,l)*d(.025,.045,Mt[a]);const v=1-d(.18,.4,s),x=d(.55,.8,h)*d(.05,.12,l);ct[a]=Math.max(lt[a],.85*v,.8*x)}x(it,st,n,o,.995,1),x(it,ht,n,o,.8,1);let gt=0;for(let t=0;t<r;t++)gt+=it[t];const pt=gt>.04*r&&Y>.3;if(pt)for(let t=0;t<o;t++)for(let e=0;e<n;e++)lt[t*n+e]*=d(K,K+.05,(t+.5)/o);if(pt){const t=a.take(),e=a.take(),i=a.take();for(let e=0;e<r;e++)t[e]=.299*tt[e]+.587*et[e]+.114*nt[e];for(let t=0;t<o;t++)for(let a=0;a<n;a++)e[t*n+a]=A[Math.min(o-1,t+1)*n+a]-A[Math.max(0,t-1)*n+a];const s=new Uint8Array(r);for(let t=1;t<o-1;t++)for(let a=0;a<n;a++){const r=Math.abs(e[t*n+a]);let i=r>.03;for(let s=-3;s<=3&&i;s++)s&&t+s>=0&&t+s<o&&Math.abs(e[(t+s)*n+a])>r&&(i=!1);s[t*n+a]=i?1:0}const h=(e,n,o,a=!0)=>{const r=tt[n]+et[n]+nt[n]+.05,i=tt[o]+et[o]+nt[o]+.05,s=Math.abs(tt[n]/r-tt[o]/i)+Math.abs(et[n]/r-et[o]/i)+Math.abs(nt[n]/r-nt[o]/i),h=Math.min(Math.abs(O[n]-O[o]),360-Math.abs(O[n]-O[o])),l=Math.max(1-d(.1,.25,s),(1-d(15,35,h))*d(.15,.3,Math.min(z[n],z[o]))),c=Math.max(d(2,3,(H[n]+.004)/(R[n]+.004))*d(.015,.04,F[n]+I[n])*d(.4,.55,F[n]/(F[n]+I[n]+1e-4)),1-d(.12,.25,t[n]));return l*(a?c:1)*(1-d(.82*t[o]+.02,1.02*t[o]+.05,t[n]))};let l=0,f=0;for(let t=Math.max(3,Math.round(o*Math.max(.25,K)));t<Math.round(.88*o);t++){let e=0;for(let o=0;o<n;o++)(s[(t-1)*n+o]||s[t*n+o]||s[(t+1)*n+o])&&e++;if(e<.5*n)continue;let a=0;for(let e=t+1;e<Math.min(o,2*t);e++)for(let o=0;o<n;o++)a+=h(t,e*n+o,(2*t-e)*n+o);a>f&&(f=a,l=t)}const m=d(.05,.1,f/r);if(m>0)for(let t=l+1;t<Math.min(o,2*l);t++)for(let e=0;e<n;e++){const o=t*n+e;dt[o]=h(l,o,(2*l-t)*n+e)*m,ut[o]=h(l,o,(2*l-t)*n+e,!1)*m,i[o]=dt[o]}c(i,y,n,o,1);for(let t=0;t<r;t++)dt[t]=Math.max(dt[t],i[t]),lt[t]=Math.max(lt[t],dt[t])}const vt=b(lt,E);for(let t=0;t<r;t++)lt[t]*=d(.15,.35,vt[t]);const xt=b(lt,S);for(let t=0;t<r;t++){lt[t]*=1-.8*st[t];const e=Math.min(Math.abs(O[t]-200),360-Math.abs(O[t]-200));ft[t]=d(.28,.45,z[t]*U)*d(55,80,e)*(1-d(.3,.6,ut[t]))}const wt=b(ft,S);for(let t=0;t<r;t++)ft[t]=Math.max(ft[t]*(1-(1-d(.15,.3,wt[t]))*d(.55,.7,q[t])*d(.5,.65,z[t])),1-g[t]),ct[t]=Math.min(Math.max(ct[t],.9*ut[t]),Math.max(lt[t],d(.25,.6,xt[t])))*(1-it[t])*(1-ft[t]);x(lt,ct,n,o,.97);const yt=a.take(mt),bt=Math.max(2,Math.round(.12*o));for(let t=0;t<n;t++){let e=0;for(let a=-bt;a<=bt;a++)e+=mt[Math.max(0,Math.min(o-1,a))*n+t];for(let a=0;a<o;a++)yt[a*n+t]=e/(2*bt+1),e+=mt[Math.min(o-1,a+bt+1)*n+t]-mt[Math.max(0,a-bt)*n+t]}c(yt,y,n,o,1);for(let t=0;t<r;t++)mt[t]=d(.2,.45,yt[t])*d(.2,.5,mt[t]+.5*yt[t])*(1-it[t]);v(it,M,n,o,Math.max(2,Math.round(.04*i)),.002,a),v(lt,M,n,o,Math.max(2,Math.round(.04*i)),.002,a),v(mt,M,n,o,Math.max(2,Math.round(.03*i)),.002,a),c(ft,y,n,o,1);for(let t=0;t<r;t++)it[t]=d(.3,.7,it[t])*g[t],mt[t]=d(.3,.7,mt[t])*g[t]*(1-it[t]),lt[t]=d(.3,.7,lt[t])*(1-it[t])*(1-mt[t])*(1-d(.15,.4,ft[t]));w(it,y,n,o,2),w(lt,y,n,o,2),w(mt,y,n,o,1),c(it,y,n,o,1),c(lt,y,n,o,1),c(mt,y,n,o,1);const St=1/Math.max(.02,u(_,.97)),Et=1/Math.max(.01,u(G,.9)),kt=u(X,.97),At=u(X,.1),Ct=d(.06,.25,kt-At),Tt=a.take();for(let t=0;t<o;t++)for(let e=0;e<n;e++){const a=t*n+e,r=(e+.5)/n,i=(t+.5)/o,s=Math.max(it[a],lt[a]),h=F[a]+I[a]+L[a],l=.6*m(((F[a]+.6*I[a])/(h+.004)-.25)/.55)+.4*m((F[a]+I[a])/W),c=d(.04,.35,h/W)*(1-s),f=.55*m((X[a]-At)/Math.max(.05,kt-At))+.25*(1-m(G[a]*Et))+.2*m(2*(P[a]-j[a])+.3)*U,u=Ct*d(.12,.35,C[a])*(.4+.6*Y),M=Y*(i<K?.45:.45+.55*d(0,1,(i-K)/Math.max(.15,1-K)))+(1-Y)*(.5+.4*(i-.5)),g=F[a]/(F[a]+I[a]+1e-4),p=d(.2,.7,(F[a]+I[a])/W)*(.35+.65*Y)*(1-s),v=1-m(1.5*Math.hypot(1.2*(r-.5),i-.52)),x=m(_[a]*St)*(.55+.45*v),w=.3*c,y=.25*u,b=.12+.45*Y,S=.12*p,E=.35*(1-.4*Y)*(1-s);Tt[a]=(w*l+y*(1-f)+b*M+S*m(1.6-1.6*g)+E*x+.04)/(w+y+b+S+E+.08)*(1-.85*it[a])*(1-.45*lt[a]*(1-Y))}const Ft=function(t,e,n){const o=e*n,a={width:e,height:n,subject:new Float32Array(o),depth:new Float32Array(o),key:"none"},{subject:r,depth:i}=a;let s=0;for(let e=0;e<o;e++)t[4*e+3]<250&&s++;const h=e=>(.2126*t[4*e]+.7152*t[4*e+1]+.0722*t[4*e+2])/255;let l="none",m=0;if(s>.01*o)l="alpha";else{let t=0,o=0,a=0;const r=Math.max(1,Math.round(.03*Math.min(e,n)));for(let i=0;i<n;i++)for(let s=0;s<e;s++){if(s>=r&&i>=r&&s<e-r&&i<n-r)continue;const l=h(i*e+s);t+=l,o+=l*l,a++}m=t/Math.max(1,a),Math.sqrt(Math.max(0,o/Math.max(1,a)-m*m))<.07&&(l="ground")}for(let e=0;e<o;e++){const n=t[4*e+3]/255,o=h(e);let a=1;if("alpha"===l)a=n;else if("ground"===l){const t=Math.max(0,Math.min(1,(Math.abs(o-m)-.035)/.12));a=t*t*(3-2*t)}r[e]=1*a,i[e]=o*n}a.key=l,f.length<o&&(f=new Float32Array(o));const d=f;return c(r,d,e,n,Math.max(1,Math.round(.02*Math.min(e,n)))),c(i,d,e,n,Math.max(1,Math.round(.035*Math.min(e,n)))),a}(t,n,o);if("none"!==Ft.key)for(let t=0;t<r;t++)Tt[t]=.7*Ft.subject[t]+.3*Tt[t];return c(Tt,y,n,o,Math.max(1,Math.round(.03*i))),function(t,e,n,o,a,r,i,s,h){const l=a*r,c=h.take(),f=t=>(p(t,c,a,r,i),t),m=(t,e)=>{const n=h.take();for(let o=0;o<l;o++)n[o]=t[o]*e[o];return f(n)},d=f(h.take(e)),u=f(h.take(n)),M=f(h.take(o)),g=f(h.take(t)),v=m(e,e),x=m(e,n),w=m(e,o),y=m(n,n),b=m(n,o),S=m(o,o),E=m(e,t),k=m(n,t),A=m(o,t),C=h.take(),T=h.take(),F=h.take(),I=h.take();for(let t=0;t<l;t++){const e=E[t]-d[t]*g[t],n=k[t]-u[t]*g[t],o=A[t]-M[t]*g[t],a=v[t]-d[t]*d[t]+s,r=x[t]-d[t]*u[t],i=w[t]-d[t]*M[t],h=y[t]-u[t]*u[t]+s,l=b[t]-u[t]*M[t],c=S[t]-M[t]*M[t]+s,f=h*c-l*l,m=i*l-r*c,p=r*l-i*h,L=a*c-i*i,R=r*i-a*l,H=a*h-r*r,W=a*f+r*m+i*p,j=Math.abs(W)>1e-12?1/W:0;C[t]=(f*e+m*n+p*o)*j,T[t]=(m*e+L*n+R*o)*j,F[t]=(p*e+R*n+H*o)*j,I[t]=g[t]-C[t]*d[t]-T[t]*u[t]-F[t]*M[t]}f(C),f(T),f(F),f(I);for(let a=0;a<l;a++)t[a]=C[a]*e[a]+T[a]*n[a]+F[a]*o[a]+I[a]}(Tt,j,$,P,n,o,Math.max(2,Math.round(.07*i)),.004,a),{depth:Tt,water:lt,sky:it,falls:mt}}function b(t,e,n,o,a,r,i){if(e===r&&n===i)return t[a*r+o];const s=Math.max(0,Math.min(e-1,(o+.5)*e/r-.5)),h=Math.max(0,Math.min(n-1,(a+.5)*n/i-.5)),l=Math.min(e-2,Math.floor(s)),c=Math.min(n-2,Math.floor(h)),f=s-l,m=h-c;if(l<0||c<0)return t[Math.round(h)*e+Math.round(s)];const d=c*e+l,u=d+e;return(t[d]*(1-f)+t[d+1]*f)*(1-m)+(t[u]*(1-f)+t[u+1]*f)*m}var S=new WeakMap;function E(t){const e=S.get(t);if(e)return e;const n=t.length,o=t[0]?.length??0,a=new Uint8ClampedArray(o*n*4);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const r=t[e][n],i=4*(e*o+n);a[i]=r.r,a[i+1]=r.g,a[i+2]=r.b,a[i+3]=r.a}const r=function(t,e,n,o,a=t){const r=e*n,i=o?.length===11*r?o:new Float32Array(11*r);if(!r)return i;const s=Math.min(e,n),h=new Float32Array(r),l=new Float32Array(r),f=new Float32Array(r),d=new Float32Array(r),p=new Float32Array(r),v=new Float32Array(r);for(let e=0;e<r;e++){const n=t[4*e+3]/255;h[e]=(.299*t[4*e]+.587*t[4*e+1]+.114*t[4*e+2])/255*n}l.set(h),c(l,v,e,n,Math.max(1,Math.round(.012*s))),f.set(h),c(f,v,e,n,Math.max(1,Math.round(.03*s)));for(let t=0;t<r;t++){d[t]=Math.abs(h[t]-l[t]);const e=Math.max(0,h[t]-.55)/.45;p[t]=e*e}c(d,v,e,n,Math.max(1,Math.round(.02*s)));const x=1/Math.max(.02,u(d,.95));c(p,v,e,n,Math.max(1,Math.round(.05*s)));const w=1/Math.max(.03,u(p,.98)),S=Math.max(1,Math.ceil(Math.sqrt(r/12e3))),E=Math.max(1,Math.floor(e/S)),k=Math.max(1,Math.floor(n/S)),A=E*k;let C=t,T=a;if(S>1){const n=new Uint8ClampedArray(4*A),o=a===t?n:new Uint8ClampedArray(4*A);for(let r=0;r<k;r++)for(let i=0;i<E;i++){const s=[0,0,0,0,0,0,0];for(let h=r*S;h<(r+1)*S;h++)for(let r=i*S;r<(i+1)*S;r++){const i=4*(h*e+r);for(let e=0;e<4;e++)s[e]+=t[i+e];if(o!==n)for(let t=0;t<3;t++)s[4+t]+=a[i+t]}const h=4*(r*E+i),l=S*S;for(let t=0;t<4;t++)n[h+t]=s[t]/l;if(o!==n){for(let t=0;t<3;t++)o[h+t]=s[4+t]/l;o[h+3]=n[h+3]}}C=n,T=o}g?.n!==A&&(g=new M(A)),g.reset();const{depth:F,water:I,sky:L,falls:R}=y(C,T,E,k,g),H=u(F,.03),W=u(F,.97),j=Math.max(.05,W-H);let $=0,P=0,O=0;const z=new Float32Array(r);for(let t=0;t<n;t++)for(let o=0;o<e;o++){const a=t*e+o,r=11*a,s=m((b(F,E,k,o,t,e,n)-H)/j);i[r+1]=s,i[r+8]=m(b(I,E,k,o,t,e,n)),i[r+9]=m(b(L,E,k,o,t,e,n)),i[r+10]=m(b(R,E,k,o,t,e,n));const l=s*s*s*(.25+h[a]);$+=(o+.5)/e*l,P+=(t+.5)/n*l,O+=l,z[a]=Math.hypot(f[t*e+Math.min(e-1,o+1)]-f[t*e+Math.max(0,o-1)],f[Math.min(n-1,t+1)*e+o]-f[Math.max(0,t-1)*e+o])}$=O>0?Math.max(.3,Math.min(.7,$/O)):.5,P=O>0?Math.max(.3,Math.min(.7,P/O)):.5;const q=1/Math.max(.004,u(z,.97));for(let t=0;t<n;t++)for(let o=0;o<e;o++){const a=t*e+o,r=11*a,s=(f[t*e+Math.min(e-1,o+1)]-f[t*e+Math.max(0,o-1)])*q,h=(f[Math.min(n-1,t+1)*e+o]-f[Math.max(0,t-1)*e+o])*q;i[r]=f[a],i[r+2]=Math.min(1,p[a]*w),i[r+3]=Math.min(1,d[a]*x),i[r+4]=Math.max(-1,Math.min(1,-s)),i[r+5]=Math.max(-1,Math.min(1,-h)),i[r+6]=$,i[r+7]=P}return i}(a,o,n);return S.set(t,r),r}function k(t,e){const n=document.createElement("canvas");n.width=t,n.height=e;const o=n.getContext("2d",{willReadFrequently:!0});return{canvas:n,ctx:o}}function A(t,e,n){let o=t+255*e;return o=259*(255*n+255)/(255*(259-255*n))*(o-128)+128,Math.max(0,Math.min(255,o))}function C(t,e,n,o,a,r){if((r?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(o*a+n)%i.length]}var T=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function F(t,e,n,o){if(o<=0)return t;const a=(T[n%4][e%4]/16-.5)*o*128;return Math.max(0,Math.min(255,t+a))}var I=new Array(256),L=new Array(256);for(let t=0;t<256;t++)I[t]=`rgb(${t},${t},${t})`,L[t]=`rgb(0,${t},0)`;function R(t,e,n,o,a,r=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return L[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${n},${o},${a})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return I[e]}}}var H=[0,0,0];function W(t,e,n,o,a,r=!1){switch(e){case"fullcolor":H[0]=t.r,H[1]=t.g,H[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;H[0]=0,H[1]=e,H[2]=0;break}case"accent":H[0]=n,H[1]=o,H[2]=a;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;H[0]=e,H[1]=e,H[2]=e;break}}return H}function j(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function $(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=j(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function P(t){if(t){const e=$(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=$(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function O(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");n.fillStyle=t,n.fillRect(0,0,1,1);const o=n.getImageData(0,0,1,1).data;return{r:o[0],g:o[1],b:o[2]}}function z(t){return t*t*(3-2*t)}var q={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function D(t,e,n,o,a,r,i,s,h="spotlight",l=.5,c="circle",f=[],m=1){const d=(t-n)*Math.max(1,m),u=(e-o)*Math.max(1,1/m),M=.08+.35*l+.04*r;let g,p;if("box"===c){const t=Math.abs(d),e=Math.abs(u);g=Math.max(t,e),p=M}else g=Math.sqrt(d*d+u*u),p=M;if(g>=p&&("trail"!==h||0===f.length))return q.scale=1,q.offsetX=0,q.offsetY=0,q.glow=0,q.colorBlend=0,q.proximity=0,q;const v=z(Math.max(0,1-g/p))*a;let x=1,w=0,y=0,b=0,S=0;switch(h){case"spotlight":{x=1+v*r*1.8;const t=Math.atan2(u,d),e=v*v*r*.6;w=Math.cos(t)*e*i,y=Math.sin(t)*e*s,b=v*r*.4,S=v*v*r*.25;break}case"magnify":x=1+v*r*.85,b=v*r*.15;break;case"repel":{x=1;const t=Math.atan2(u,d),e=v*v*r*1.8;w=Math.cos(t)*e*i,y=Math.sin(t)*e*s;break}case"glow":b=v*r*.8,S=v*r*.4;break;case"colorShift":x=1,b=v*r*.12,S=v*r;break;case"attract":{const t=Math.atan2(u,d),e=v*v*r*1;w=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,y=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,b=v*r*.3;break}case"shatter":{const t=Math.atan2(u,d),e=.5*Math.sin(43.7*d+29.3*u),n=v*r*1.4*(.7+.3*e);w=Math.cos(t+e)*n*i,y=Math.sin(t+e)*n*s,x=Math.max(.1,1-v*r*.6),b=v*r*.25;break}case"trail":{let n=v,o=-u*v,a=d*v;for(const r of f){const i=(t-r.x)*Math.max(1,m),s=(e-r.y)*Math.max(1,1/m),h=Math.hypot(i,s)/M;if(h>=1)continue;const l=z(1-h)*r.intensity;n=Math.max(n,l),o+=(.35*r.vx-2*s)*l*.35,a+=(.35*r.vy+2*i)*l*.35}w=Math.tanh(2*o)*r*i*3,y=Math.tanh(2*a)*r*s*3,S=n*r*.65,b=n*r*.35,x=1+n*r*.08,q.proximity=n;break}case"glitchText":x=1,b=v*r*.5,S=v*r*.6}return q.scale=x,q.offsetX=w,q.offsetY=y,q.glow=b,q.colorBlend=S,"trail"!==h&&(q.proximity=v),q}function U(t,e,{continuous:n=!1,interactive:o=!1}={}){const a=t.parentElement??t;let r=null,i=0,s=!1,h=!0,l=!0,c=-1/0;const f=window.matchMedia("(prefers-reduced-motion: reduce)"),m=()=>{l=!0,s||!h||document.hidden||i||(i=requestAnimationFrame(d))},d=t=>{if(i=0,s||!h||document.hidden)return;const o=!f.matches&&(n||t-c<1500);(l||o)&&(e(t,f.matches?null:r),l=!1),o&&(i=requestAnimationFrame(d))},u=e=>{if("touch"===e.pointerType)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const o=(e.clientX-n.left)/n.width,a=(e.clientY-n.top)/n.height;r=o>=0&&o<=1&&a>=0&&a<=1?{x:o,y:a}:null,c=performance.now(),m()},M=()=>{r=null,c=performance.now(),m()},g=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):m()},p="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{h=t.isIntersecting,h?m():i&&(cancelAnimationFrame(i),i=0)});return p?.observe(t),o&&(a.addEventListener("pointermove",u),a.addEventListener("pointerleave",M)),document.addEventListener("visibilitychange",g),f.addEventListener("change",m),m(),{wake:m,stop:()=>{s=!0,cancelAnimationFrame(i),p?.disconnect(),a.removeEventListener("pointermove",u),a.removeEventListener("pointerleave",M),document.removeEventListener("visibilitychange",g),f.removeEventListener("change",m)}}}var B=null,V=null;function K(t,e){if(!B||!V){const n=k(t,e);B=n.canvas,V=n.ctx}return B.width!==t&&(B.width=t),B.height!==e&&(B.height=e),V}var N=new Map,Y=new Map,X=new WeakMap;function G(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function _(t){let e=N.get(t);return e||(e=G(t),N.set(t,e)),e}function J(t){return G(t)}function Q(t,e,n){const o=n?1-t/255:t/255,a=Math.floor(o*(e.length-1));return e[Math.max(0,Math.min(e.length-1,a))]??" "}function Z(t,e,n,o){const a=`${t}\0${e?1:0}\0${n}\0${o}`;let r=Y.get(a);if(!r){const i=_(t);r=new Array(256);for(let t=0;t<256;t++)r[t]=Q(A(t,n,o),i,e);Y.set(a,r)}return r}function tt(){N.clear(),Y.clear(),dt=new WeakMap,Mt=new WeakMap,ut=new WeakMap,B=null,V=null}function et(t,e){return"auto"!==t?t:!P(e)}function nt(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const n=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return n?[n[1],n[2],n[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function ot(t){const e=t||"auto";if("auto"!==e)return nt(e)??"ffffff";if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const n=nt(t.getPropertyValue(e).trim());if(n)return n}const e=nt(getComputedStyle(document.body).accentColor??"");if(e)return e}return P("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function at(t,e,n){return Math.max(e,Math.min(n,t))}function rt(t,e,n){if(!t)return{x:0,y:0,width:e,height:n};const o=t.unit??"percent",a=!1!==t.preserveAspect,r=t=>void 0===t?void 0:"percent"===o?t*e:t,i=t=>void 0===t?void 0:"percent"===o?t*n:t,s=at(r(t.left)??0,0,e-1),h=at(r(t.right)??0,0,e-s-1),l=at(i(t.top)??0,0,n-1),c=at(i(t.bottom)??0,0,n-l-1),f=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,m=Math.max(1,e-s-h),d=Math.max(1,n-l-c),u=f?m:r(t.width),M=f?d:i(t.height);let g=u??e,p=M??n;if(a&&!f){const t=g/e,o=p/n,a=Math.min(t,o),r=void 0===u?o:void 0===M?t:a;g=e*r,p=n*r}g=at(g,1,f?m:e),p=at(p,1,f?d:n);const v=t.anchor??"center",x=r(t.x),w=i(t.y),y=f?s:0,b=f?l:0,S=f?m:e,E=f?d:n,k=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-g:(S-g)/2,A=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?E-p:(E-p)/2;return{x:at(x??y+k,0,Math.max(0,e-g)),y:at(w??b+A,0,Math.max(0,n-p)),width:g,height:p}}function it(t,e,n,o){const a=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===a||0===r)return{frame:[],cols:0,rows:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,l=n||a,c=o||r,f=Math.floor(l/s),m=Math.floor(c/h);if(f<=0||m<=0)return{frame:[],cols:0,rows:0};const d=rt(e.sourceCrop,a,r),u=Math.max(1,Math.min(Math.floor(2048/f),Math.floor(d.width/f))),M=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(d.height/m))),g=f*u,p=m*M,v=K(g,p),x=v.globalCompositeOperation;v.globalCompositeOperation="copy";try{v.drawImage(t,d.x,d.y,d.width,d.height,0,0,g,p)}finally{v.globalCompositeOperation=x}const w=v.getImageData(0,0,g,p).data,y=e.chromaKey,b=null!=y&&!1!==y,S=!0===y,E="blue-screen"===y;let k=null,T=0;!b||S||E||(k=O(y),T=(e.chromaKeyTolerance??60)**2);let I=0,L=255;if(e.normalize){let t=255,e=0;for(let n=0;n<w.length;n+=4){if(b){const t=w[n],e=w[n+1],o=w[n+2];let a=!1;if(S)a=e>1.4*t&&e>1.4*o&&e>80;else if(E)a=o>1.4*t&&o>1.4*e&&o>80;else if(null!==k){const n=t-k.r,r=e-k.g,i=o-k.b;a=n*n+r*r+i*i<=T}if(a)continue}const o=.299*w[n]+.587*w[n+1]+.114*w[n+2];o<t&&(t=o),o>e&&(e=o)}I=t,L=e>t?e-t:255}const R=[],H=et(e.invert),W=b&&e.charset.replace(/ /g,"")||e.charset,j=_(W),$=e.customText?null:Z(W,H,e.brightness,e.contrast),P=u*M;for(let t=0;t<m;t++){const n=[];for(let o=0;o<f;o++){let a=0,r=0,i=0,s=0,h=0;for(let e=0;e<M;e++){const n=(t*M+e)*g;for(let t=0;t<u;t++){const e=4*(n+o*u+t),l=w[e],c=w[e+1],f=w[e+2],m=w[e+3];if(b){let t=!1;if(S)t=c>1.4*l&&c>1.4*f&&c>80;else if(E)t=f>1.4*l&&f>1.4*c&&f>80;else if(null!==k){const e=l-k.r,n=c-k.g,o=f-k.b;t=e*e+n*n+o*o<=T}if(t){h++;continue}}a+=l,r+=c,i+=f,s+=m}}if(b&&h>P/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const l=P-h,c=l>0?a/l:0,m=l>0?r/l:0,d=l>0?i/l:0,p=l>0?s/l:0,v=.299*c+.587*m+.114*d,x=e.normalize?(v-I)/L*255:v,y=A(x,e.brightness,e.contrast),R=e.ditherStrength>0?F(y,o,t,e.ditherStrength):y,W=e.customText?C(R,e.customText,o,t,f,H):e.ditherStrength>0?Q(R,j,H):$[Math.max(0,Math.min(255,0|x))];n.push({char:W,r:c,g:m,b:d,a:p,lum:R})}R.push(n)}return{frame:R,cols:f,rows:m}}function st(t,e,n,o){const a=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===a||0===r)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,l=n||a,c=o||r,f=Math.floor(l/s),m=Math.floor(c/h);if(f<=0||m<=0)return{rows:[],cols:0,rowCount:0};const d=f,u=m,M=K(d,u),g=rt(e.sourceCrop,a,r),p=M.globalCompositeOperation;M.globalCompositeOperation="copy";try{M.drawImage(t,g.x,g.y,g.width,g.height,0,0,d,u)}finally{M.globalCompositeOperation=p}const v=M.getImageData(0,0,d,u).data,x=e.chromaKey,w=null!=x&&!1!==x,y=!0===x,b="blue-screen"===x;let S=null,E=0;!w||y||b||(S=O(x),E=(e.chromaKeyTolerance??60)**2);let k=0,C=255;if(e.normalize){let t=255,e=0;for(let n=0;n<v.length;n+=4){if(w){const t=v[n],e=v[n+1],o=v[n+2];let a=!1;if(y)a=e>1.4*t&&e>1.4*o&&e>80;else if(b)a=o>1.4*t&&o>1.4*e&&o>80;else if(null!==S){const n=t-S.r,r=e-S.g,i=o-S.b;a=n*n+r*r+i*i<=E}if(a)continue}const o=.299*v[n]+.587*v[n+1]+.114*v[n+2];o<t&&(t=o),o>e&&(e=o)}k=t,C=e>t?e-t:255}const T=et(e.invert),I=w&&e.charset.replace(/ /g,"")||e.charset,L=_(I),R=e.customText?null:Z(I,T,e.brightness,e.contrast),H=e.customText?_(e.customText):null,W="fullcolor"===e.colorMode?new Uint8ClampedArray(f*m*4):void 0,j=[];for(let t=0;t<m;t++){let n="";for(let o=0;o<f;o++){const a=4*(t*d+o),r=a,i=v[a],s=v[a+1],h=v[a+2],l=v[a+3];if(w){let t=!1;if(y)t=s>1.4*i&&s>1.4*h&&s>80;else if(b)t=h>1.4*i&&h>1.4*s&&h>80;else if(null!==S){const e=i-S.r,n=s-S.g,o=h-S.b;t=e*e+n*n+o*o<=E}if(t){n+=" ",W&&(W[r]=0,W[r+1]=0,W[r+2]=0,W[r+3]=0);continue}}W&&(W[r]=i,W[r+1]=s,W[r+2]=h,W[r+3]=l);const c=.299*i+.587*s+.114*h,m=e.normalize?(c-k)/C*255:c,u=e.ditherStrength>0||H?A(m,e.brightness,e.contrast):m,M=e.ditherStrength>0?F(u,o,t,e.ditherStrength):u;if(H){n+=(T?1-M/255:M/255)<.12?" ":H[(t*f+o)%H.length]}else e.ditherStrength<=0?n+=R[Math.max(0,Math.min(255,0|m))]:n+=Q(M,L,T)}j.push(n)}return{rows:j,cols:f,rowCount:m,colors:W}}function ht(t,e,n,o,a){if(0===e.rows.length)return;const r=t.canvas,i=Boolean(n.chromaKey)||e.rows.some(t=>t.includes(" "));i||(X.delete(t),t.clearRect(0,0,o,a),t.fillStyle=P(r)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,a));const s=ot(n.accentColor),h=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),c=parseInt(s.substring(4,6),16),f=o/e.cols,m=a/e.rowCount,d=.9*Math.min(f/.55,m),u=e.colors;if("fullcolor"===n.colorMode&&u){X.delete(t),t.clearRect(0,0,o,a),t.font=`${d}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let n="";for(let o=0;o<e.rows.length;o++){const a=J(e.rows[o]);let r=0;for(;r<e.cols;){for(;r<e.cols&&" "===a[r];)r++;if(r>=e.cols)break;const i=r,s=4*(o*e.cols+r),h=240&u[s],l=240&u[s+1],c=240&u[s+2];for(r++;r<e.cols&&" "!==a[r];){const t=4*(o*e.cols+r);if((240&u[t])!==h||(240&u[t+1])!==l||(240&u[t+2])!==c)break;r++}const d=`rgb(${h},${l},${c})`;d!==n&&(t.fillStyle=d,n=d),t.fillText(a.slice(i,r).join(""),i*f+.5*f,o*m+.5*m)}}return void(t.globalAlpha=1)}t.font=`${d}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const M="matrix"===n.colorMode?"rgb(0,255,0)":"grayscale"===n.colorMode?P(r)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${h},${l},${c})`;t.fillStyle=M,t.globalAlpha=1;const g=X.get(t),p=i&&g&&g.cols===e.cols&&g.rowCount===e.rowCount&&g.canvasWidth===o&&g.canvasHeight===a&&g.fillStyle===M;p||t.clearRect(0,0,o,a);for(let n=0;n<e.rows.length;n++){const a=e.rows[n];p&&g.rows[n]===a||(p&&t.clearRect(0,n*m,o,m+1),0!==a.trim().length&&t.fillText(a,.5*f,n*m+.5*m))}X.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:o,canvasHeight:a,fillStyle:M}),t.globalAlpha=1}async function lt(t,e,n,o,a=12,r=10,i,s=0){const h=Math.min(t.duration-s,r),l=Math.ceil(h*a),c=[];let f=0,m=0;for(let r=0;r<l;r++){const d=s+r/a;if(d>s+h)break;t.currentTime=d,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=it(t,e,n,o);c.push(u.frame),f=u.cols,m=u.rows,i?.((r+1)/l)}return{frames:c,cols:f,rows:m,fps:a}}async function ct(t,e,n,o,a=12,r=10,i,s=0){const h=Math.min(t.duration-s,r),l=Math.ceil(h*a),c=[];let f=0,m=0;for(let r=0;r<l;r++){const d=s+r/a;if(d>s+h)break;t.currentTime=d,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=st(t,e,n,o);c.push(u),f=u.cols,m=u.rowCount,i?.((r+1)/l)}return{frames:c,cols:f,rows:m,fps:a}}async function ft(t,e,n,o,a){const{parseGIF:r,decompressFrames:i}=await import("gifuct-js"),s=r(t),h=i(s,!0);if(0===h.length)return{frames:[],cols:0,rows:0,fps:10};const l=h[0].dims.width,c=h[0].dims.height,f=s.lsd?.width||l,m=s.lsd?.height||c,d=document.createElement("canvas");d.width=f,d.height=m;const u=d.getContext("2d"),M=document.createElement("canvas");M.width=f,M.height=m;const g=M.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),x=[];let w=0,y=0,b=0;for(const t of h)b+=t.delay||100;const S=b/h.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),k=Math.min(h.length,300);for(let t=0;t<k;t++){const r=h[t],{dims:i,patch:s,disposalType:l}=r;3===l&&(g.clearRect(0,0,f,m),g.drawImage(d,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const c=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(c,0,0),u.drawImage(p,i.left||0,i.top||0);const b=it(d,e,n,o);x.push(b.frame),w=b.cols,y=b.rows,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,m),u.drawImage(M,0,0)),a?.((t+1)/k)}return{frames:x,cols:w,rows:y,fps:E}}async function mt(t,e,n,o,a){const{parseGIF:r,decompressFrames:i}=await import("gifuct-js"),s=r(t),h=i(s,!0);if(0===h.length)return{frames:[],cols:0,rows:0,fps:10};const l=h[0].dims.width,c=h[0].dims.height,f=s.lsd?.width||l,m=s.lsd?.height||c,d=document.createElement("canvas");d.width=f,d.height=m;const u=d.getContext("2d"),M=document.createElement("canvas");M.width=f,M.height=m;const g=M.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),x=[];let w=0,y=0,b=0;for(const t of h)b+=t.delay||100;const S=b/h.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),k=Math.min(h.length,300);for(let t=0;t<k;t++){const r=h[t],{dims:i,patch:s,disposalType:l}=r;3===l&&(g.clearRect(0,0,f,m),g.drawImage(d,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const c=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(c,0,0),u.drawImage(p,i.left||0,i.top||0);const b=st(d,e,n,o);x.push(b),w=b.cols,y=b.rowCount,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,m),u.drawImage(M,0,0)),a?.((t+1)/k)}return{frames:x,cols:w,rows:y,fps:E}}var dt=new WeakMap,ut=new WeakMap,Mt=new WeakMap;function gt(t,e,n,o,a,r=0,i){if(!e.length||!e[0].length||o<=0||a<=0)return;let s=null;if(n.hoverStrength>0){let e=dt.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},dt.set(t,e)),s=function(t,e,n){const o=t.time<0?1/60:Math.max(0,Math.min(.1,(n-t.time)/1e3));t.time=n;const a=t.intensity<.003,r=t.x,i=t.y;if(e){a&&(t.x=e.x,t.y=e.y);const n=1-Math.exp(-o/.055);t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n}t.intensity+=((e?.intensity??(e?1:0))-t.intensity)*(1-Math.exp(-o/(e?.09:.18)));const s=Math.exp(-o/.22);for(const e of t.points)e.intensity*=s;for(;t.points.length&&t.points[0].intensity<.01;)t.points.shift();return e&&!a&&n-t.emittedAt>=24&&Math.hypot(t.x-r,t.y-i)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-r)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(t.y-i)/Math.max(o,.001)))}),t.points.length>12&&t.points.shift(),t.emittedAt=n),!e&&t.intensity<.003&&!t.points.length?(t.intensity=0,null):{x:t.x,y:t.y,intensity:t.intensity,trail:t.points}}(e,i??null,performance.now())}else dt.delete(t);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return Mt.delete(t),void pt(t,e,n,o,a,r,s);const h=ut.get(t);if(h?.frame!==e)return ut.set(t,{frame:e,since:performance.now()}),Mt.delete(t),void pt(t,e,n,o,a,r,s);if(performance.now()-h.since<100)return void pt(t,e,n,o,a,r,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void pt(t,e,n,o,a,r,s);if(!s||(s.intensity??0)<.003)return void pt(t,e,n,o,a,r,null);const c=P(t.canvas),f={...n,accentColor:"#"+ot(n.accentColor)},m=JSON.stringify([f,o,a,l.a,l.d,c,void 0!==document.fonts?document.fonts.status:"loaded"]);let d=Mt.get(t);if(!d||d.frame!==e||d.key!==m){const n=d?.canvas??document.createElement("canvas");n.width=Math.ceil(o*l.a),n.height=Math.ceil(a*l.d);const r=n.getContext("2d");r.setTransform(l.a,0,0,l.d,0,0),pt(r,e,f,o,a,0,null,void 0,c),d={frame:e,key:m,canvas:n},Mt.set(t,d)}if(t.clearRect(0,0,o,a),t.drawImage(d.canvas,0,0,o,a),!s||(s.intensity??0)<.003)return;const u=e.length,M=e[0].length,g=.08+.35*n.hoverRadius+.04*n.hoverStrength,p="trail"===n.hoverEffect?[s,...s.trail??[]]:[s];let v=1,x=1,w=0,y=0;for(const t of p)v=Math.min(v,t.x-g),w=Math.max(w,t.x+g),x=Math.min(x,t.y-g),y=Math.max(y,t.y+g);if("glitchText"===n.hoverEffect){const t=n.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));v=Math.min(v,s.x-e/M),w=Math.max(w,s.x+e/M)}const b=Math.ceil(5+4*n.hoverStrength),S={x:Math.max(0,Math.floor(v*M)-b),y:Math.max(0,Math.floor(x*u)-b),right:Math.min(M,Math.ceil(w*M)+b),bottom:Math.min(u,Math.ceil(y*u)+b)};t.save(),t.beginPath(),t.rect(S.x*o/M,S.y*a/u,(S.right-S.x)*o/M,(S.bottom-S.y)*a/u),t.clip(),pt(t,e,f,o,a,r,s,S,c),t.restore()}function pt(t,e,n,o,c,f=0,m,d,u){const M=e.length;if(0===M)return;const g=e[0].length;t.clearRect(0,0,o,c);let p=!1;const v=Math.max(1,M>>2),x=Math.max(1,g>>2);t:for(let t=0;t<M;t+=v){const n=e[t];for(let t=0;t<g;t+=x)if(n[t].a<200){p=!0;break t}}const w=t.canvas,y=u??P(w);p||(t.fillStyle=y?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,c));const b=o/g,S=c/M,k=m?.intensity??1,A=!!(m&&n.hoverStrength>0&&k>.005),C="#"+(nt(n.hoverColor||"#ffffff")??"ffffff"),T=parseInt(C.slice(1,3),16),F=parseInt(C.slice(3,5),16),I=parseInt(C.slice(5,7),16),L=ot(n.accentColor),H=parseInt(L.substring(0,2),16),j=parseInt(L.substring(2,4),16),$=parseInt(L.substring(4,6),16),O=n.hoverRadius;let z=0,q=g,U=0,B=M,V=0,K=0;if(A&&m){V=m.x,K=m.y;const t=.08+.35*O+.04*n.hoverStrength;z=Math.max(0,Math.floor((V-t)*g)-1),q=Math.min(g,Math.ceil((V+t)*g)+1),U=Math.max(0,Math.floor((K-t)*M)-1),B=Math.min(M,Math.ceil((K+t)*M)+1)}if(A&&"trail"===n.hoverEffect)for(const t of m?.trail??[]){const e=.08+.35*O+.04*n.hoverStrength;z=Math.min(z,Math.max(0,Math.floor((t.x-e)*g)-1)),q=Math.max(q,Math.min(g,Math.ceil((t.x+e)*g)+1)),U=Math.min(U,Math.max(0,Math.floor((t.y-e)*M)-1)),B=Math.max(B,Math.min(M,Math.ceil((t.y+e)*M)+1))}const N=n.animationStyle,Y=n.animationSpeed,X=function(t){const e=t&&Object.prototype.hasOwnProperty.call(a,t)?a[t]:t;return r.find(t=>t.value===e||t.mode===e)?.mode??"none"}(N),G="none"===X,J=[0,0,0,1],Z=G?void 0:E(e),tt=[0,0],at="relight"===(it=X)||"sheen"===it||"glow"===it||"shimmer"===it||"mist"===it,rt={char:" ",r:0,g:0,b:0,a:0};var it;const st=(t,n,o,a)=>{!function(t,e,n,o,a,r=.5,l,c=0){if(a[0]=a[1]=a[2]=0,a[3]=1,"none"===t)return a;r=i(r);const f=l?l[c]:r,m=l?l[c+1]:.5+.5*i(1-2*Math.hypot(e-.5,n-.55)),d=l?l[c+2]:s(.55,1,r)**2,u=l?l[c+3]:.5,M=l?l[c+4]:0,g=l?l[c+5]:0,p=o*Math.PI/6,v=(o%12+12)%12,x=s(0,.12,Math.min(e,1-e,n,1-n));if("relight"===t){const t=p+.6,o=Math.cos(t),i=Math.sin(t),h=Math.max(-1,Math.min(1,M*o+g*i))+.35*(o*(e-.5)+i*(n-.5));a[2]=.2*h*(.3+.7*s(.04,.3,f)*(1-.6*s(.82,1,r)))}else if("sheen"===t){const t=1.9*s(0,8,v)-.35,o=(.75*e+.45*n)/1.2+.05*(.75*M+.45*g),i=Math.exp(-(((o-t)/.12)**2));a[2]=i*s(.3,.8,f)*(1-.5*s(.9,1,r))*.45}else if("glow"===t){const t=.5-.5*Math.cos(p),e=1-.8*t;a[2]=.2*s(e-.3,e+.02,d)*Math.sqrt(d)*(1-.65*r)+.05*t*s(.6,.95,r)}else if("shimmer"===t){const t=h(Math.floor(160*e),Math.floor(100*n))*Math.PI*2,o=Math.pow(.5+.5*Math.cos(2*p+t),28);a[2]=o*s(.5,.88,r)*(.35+.65*s(.1,.55,u))*.42}else if("parallax"===t){const t=m-.45;a[0]=16*t*Math.sin(p)*x,a[1]=7*t*Math.sin(2*p)*x}else if("push"===t){const t=.045*(.5-.5*Math.cos(p))*(.7+.6*m)*960,o=l?l[c+6]:.5,r=l?l[c+7]:.5;a[0]=(e-o)*t,a[1]=(n-r)*t}else if("focus"===t){const t=Math.sin(p),e=t*t*s(.35,.85,t>=0?1-m:m);a[2]=(f-r)*e*.75}else if("mist"===t){const t=Math.pow(1-m,1.5)*(1-.6*u),o=.5*Math.sin(4.1*e-p+.9*Math.sin(3.3*n+p))+.3*Math.sin(7.3*e+2.1*n-2*p+1.1*Math.sin(2.7*e-5.1*n+p))+.2*Math.sin(5.7*n-1.9*e+p);a[2]=s(-.3,.9,o)*t*.16*(1-.55*r)}else if("current"===t){const t=l?.[c+8]??0,o=l?.[c+9]??0,i=l?.[c+10]??0,f=s(0,.06,Math.min(e,1-e,n,1-n)),d=l?0:(1-.4*u)*(1-.8*m)*x,M=t=>14*n-t+1.5*Math.sin(3*e+t),g=t=>16*n+2*e-t,v=t=>29*n-3*e-2*t,w=t=>1.7*e+2.3*n-t,y=t=>26*n+1.5*Math.sin(40*e)-2*t;a[0]=7*(Math.sin(M(p))-Math.sin(M(0))+.43*(Math.sin(5*e-3*n+p)-Math.sin(5*e-3*n)))*d+(3.5*(Math.sin(g(p))-Math.sin(g(0)))+1.5*(Math.sin(v(p))-Math.sin(v(0))))*t*f+5*(Math.sin(w(p))-Math.sin(w(0)))*o*f,a[1]=2*(Math.sin(11*e+p)-Math.sin(11*e))*d+.8*(Math.cos(g(p))-Math.cos(g(0)))*t*f+12*(Math.sin(y(p))-Math.sin(y(0)))*i*f;const b=Math.pow(.5+.5*Math.cos(2*p+9*e-4*n+6.2831853*h(Math.floor(160*e),Math.floor(100*n))),24)-Math.pow(.5+.5*Math.cos(9*e-4*n+6.2831853*h(Math.floor(160*e),Math.floor(100*n))),24);a[2]=.03*(Math.cos(M(p))-Math.cos(M(0)))*d+(b*s(.5,.85,r)*.3+.025*(Math.cos(g(p))-Math.cos(g(0))))*t*f+.08*(Math.cos(y(p))-Math.cos(y(0)))*i*f}else if("develop"===t){const t=s(7,8.5,v),o=i((v-8.5)/3.5),l=v<8.5?1-t:s(0,1,(1.45*o-(1-r)+.06*(h(Math.floor(160*e),Math.floor(100*n))-.5))/.3);a[2]=.3*-(1-l),a[3]=1-.9*(1-l)}}(X,t/g,n/M,f*Y,J,(.299*o.r+.587*o.g+.114*o.b)/255,Z,11*(n*g+t));let r=o;(J[0]||J[1])&&(!function(t,e,n,o,a,r){r[0]=l(Math.max(0,Math.min(o-1,e-t[0]/960*o))),r[1]=l(Math.max(0,Math.min(a-1,n-t[1]/960*a)))}(J,t,n,g,M,tt),r=e[Math.round(tt[1])][Math.round(tt[0])]);const c=255*J[2];return Math.abs(c)<.5&&1===J[3]?r:(rt.r=Math.max(0,Math.min(255,r.r+c)),rt.g=Math.max(0,Math.min(255,r.g+c)),rt.b=Math.max(0,Math.min(255,r.b+c)),rt.a=r.a*J[3],rt.char=r.char,rt.lum=r.lum,null!=r.lum&&(rt.lum=Math.max(0,Math.min(255,r.lum+c*(at?.45:1))),a&&Math.abs(c)>2&&(rt.char=Q(rt.lum,a,mt))),rt)},ht=n.hoverStrength,lt=n.hoverEffect,ct=O,ft=n.hoverShape||"circle",mt=et(n.invert,w),dt=n.colorMode,ut=2*Math.PI,Mt=1/g,gt=1/M;let pt="",vt=-1;if("dots"===n.renderMode){const a=.5*Math.min(b,S)*n.dotSizeRatio;for(let n=d?.y??0;n<(d?.bottom??M);n++){const r=e[n];for(let e=d?.x??0;e<(d?.right??g);e++){const i=G?r[e]:st(e,n,r[e]);if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=mt?1-s:s;if(h<.02)continue;let l=1,f=0,d=0,u=0,M=0;if(A&&e>=z&&e<=q&&n>=U&&n<=B){const t=D(e*Mt,n*gt,V,K,k,ht,b,S,lt,ct,ft,m?.trail,o/c);l=t.scale,f=t.offsetX,d=t.offsetY,u=t.glow,M=t.colorBlend}const g=a*h*l;if(g<.3)continue;const p=e*b+.5*b+f,v=n*S+.5*S+d;let x;if(M>0){const t=W(i,dt,H,j,$,mt);x=`rgb(${Math.min(255,t[0]+(T-t[0])*M|0)},${Math.min(255,t[1]+(F-t[1])*M|0)},${Math.min(255,t[2]+(I-t[2])*M|0)})`}else x=R(i,dt,H,j,$,mt);const w=Math.min(1,.00392156863*i.a*(1+u));if(w!==vt&&(t.globalAlpha=w,vt=w),x!==pt&&(t.fillStyle=x,pt=x),g<=3){const e=2*g;t.fillRect(p-g,v-g,e,e)}else t.beginPath(),t.arc(p,v,g,0,ut),t.fill()}}}else{const a=.55,r=.9*Math.min(b/a,S);{const e=/\p{Extended_Pictographic}/u.test(n.customText||n.charset);t.font=e?`${r}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${r}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const i=n.charsetFrames,s=!!i?.length,h=s?i[Math.floor(Math.max(0,f)*(n.charsetFps??2))%i.length]:n.charset,l=t.getTransform();if(!A&&G&&!s&&"accent"===dt&&!d&&n.hoverStrength<=0&&!/\p{Extended_Pictographic}/u.test(n.customText||n.charset)&&"letterSpacing"in t&&/^[\x20-\x7e]*$/.test(n.customText||n.charset)&&e.every(t=>t.every(t=>t.a<10||255===t.a&&1===t.char.length&&/^[\x20-\x7e]$/.test(t.char)))){const n=t.letterSpacing;t.letterSpacing="0px";const o=t.measureText("M").width;t.letterSpacing=b-o+"px",t.fillStyle=`rgb(${H},${j},${$})`,t.globalAlpha=1,t.textAlign="left";for(let n=0;n<M;n++){const a=e[n];let r="";for(let t=0;t<g;t++){const e=a[t];r+=e.a<10?" ":e.char}0!==r.trim().length&&t.fillText(r,.5*(b-o),n*S+.5*S)}return t.letterSpacing=n,t.textAlign="center",void(t.globalAlpha=1)}const u="glitchText"===lt&&A,p="!@#$%^&*<>{}[]|/\\~`0123456789",v=p.length;let x="",w=0,y=0,E=0,C=0,L=0,P=0;if(u){const t=n.hoverText??"ASCIIFY";if(y=Math.round(V*g),E=Math.round(K*M),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");x=e[((7*Math.floor(y/Math.max(1,Math.ceil(g/5)))+13*Math.floor(E/Math.max(1,Math.ceil(M/3))))%e.length+e.length)%e.length]}else x=t||"ASCIIFY";w=x.length,C=Math.max(3,Math.min(12,Math.round(M*O*.6)));const e=Math.floor(C/2);L=Math.max(0,E-e),L+C>M&&(L=Math.max(0,M-C)),P=y-Math.floor(w/2)}for(let a=d?.y??0;a<(d?.bottom??M);a++){const r=e[a];for(let i=d?.x??0;i<(d?.right??g);i++){const d=G?r[i]:st(i,a,r[i],n.customText?void 0:_(h));if(d.a<10)continue;let O=s&&null!=d.lum?Q(d.lum,_(h),mt):d.char;if(" "===O)continue;let N=1,Y=0,X=0,J=0,Z=0;if(A&&!u&&i>=z&&i<=q&&a>=U&&a<=B){const t=D(i*Mt,a*gt,V,K,k,ht,b,S,lt,ct,ft,m?.trail,o/c);if(N=t.scale,Y=t.offsetX,X=t.offsetY,J=t.glow,Z=t.colorBlend,"trail"===lt&&t.proximity>0){const n=Math.max(0,Math.min(g-1,Math.round(i-t.offsetX/b))),o=Math.max(0,Math.min(M-1,Math.round(a-t.offsetY/S))),r=e[o][n],s=r.lum??.299*r.r+.587*r.g+.114*r.b;O=Q(Math.min(255,s+t.proximity*ht*65),_(h),mt)}}if(u&&a>=L&&a<L+C){const t=i-P;if(t>=0&&t<w){const e=x[t],n=Math.abs(a-E)/Math.max(1,.5*C),o=Math.abs(i-y)/Math.max(1,w),r=Math.max(n,o),s=Math.max(0,Math.min(1,1-.9*r)),h=43758.5453*Math.sin(127.1*i+311.7*a+43758.5453*Math.floor(12*f));O=Math.abs(h-Math.floor(h))<s?e:p[Math.abs(Math.floor(97*h))%v],J=.3+.7*s,Z=.3+.65*s}}const tt=i*b+.5*b+Y,et=a*S+.5*S+X;let nt;if(Z>0){const t=W(d,dt,H,j,$,mt);nt=`rgb(${Math.min(255,t[0]+(T-t[0])*Z|0)},${Math.min(255,t[1]+(F-t[1])*Z|0)},${Math.min(255,t[2]+(I-t[2])*Z|0)})`}else nt=R(d,dt,H,j,$,mt);const ot=Math.min(1,.00392156863*d.a*(1+J));ot!==vt&&(t.globalAlpha=ot,vt=ot),nt!==pt&&(t.fillStyle=nt,pt=nt),1!==N?(t.translate(tt,et),t.scale(N,N),t.fillText(O,0,0),t.setTransform(l)):t.fillText(O,tt,et)}}}t.globalAlpha=1}function vt(t="classic"){if("classic"!==t)throw new RangeError(`Art preset "${String(t)}" was removed in 4.1. Use a StudioStyle with asciify-engine/studio, or supply options.charset directly.`);return{artStyle:"classic"}}function xt(t){return Math.max(0,Math.min(1,t))}function wt(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function yt(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function bt(t,e={}){const n=xt(t),o=xt(n*(void 0===e.speed?1:Math.max(.001,e.speed)));return xt(e.ease?e.ease(o):o)}function St(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const o=n.from??0,a=n.to??t.duration,r=Math.max(o,Math.min(a,t.duration)),i=bt(e,n),s=o+(r-o)*i;t.currentTime=Math.min(Math.max(o,s),Math.max(o,r-.04)),n.onUpdate?.(i,t)}function Et(t,e){return Math.abs(t.currentTime-e)<1/240?kt(t):new Promise(n=>{const o=()=>{t.removeEventListener("seeked",o),n()};t.addEventListener("seeked",o,{once:!0});const a=t.fastSeek;a?a.call(t,e):t.currentTime=e})}function kt(t){const e=t.requestVideoFrameCallback;return new Promise(e?n=>{let o=!1;const a=()=>{o||(o=!0,n())};e.call(t,a),window.setTimeout(a,32)}:t=>requestAnimationFrame(()=>t()))}function At(t,e={}){const n=wt(e.trigger)??t;t.pause();const o=e.gsap,a=e.ScrollTrigger??o?.ScrollTrigger;if(o&&a?.create){o.registerPlugin?.(a);const r=a.create({trigger:n,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:n=>St(t,n.progress,e)});return()=>r.kill?.()}return function(t,e,n){let o=0;const a=()=>{o=0;const a=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,i=a.height+r,s=i>0?xt((r-a.top)/i):0;St(t,s,n)},r=()=>{o||(o=requestAnimationFrame(a))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),o&&cancelAnimationFrame(o)}}(t,n,e)}function Ct(t,e,n){const o=e.gsap,a=e.ScrollTrigger??o?.ScrollTrigger;if(o&&a?.create){o.registerPlugin?.(a);const r=a.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>n(t.progress)});return()=>r.kill?.()}return function(t,e){let n=0;const o=()=>{n=0;const o=t.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,r=o.height+a,i=r>0?xt((a-o.top)/r):0;e(i)},a=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),n&&cancelAnimationFrame(n)}}(t,n)}function Tt(t,e,n){if(!t||!e||!n.sourceCrop)return{w:t,h:e};const o=rt(n.sourceCrop,t,e);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function Ft(t,e,n,o){const a=o.chromaKey;if(null==a||!1===a)return!1;if(!0===a)return e>1.4*t&&e>1.4*n&&e>80;if("blue-screen"===a)return n>1.4*t&&n>1.4*e&&n>80;const r=O(a),i=(o.chromaKeyTolerance??60)**2,s=t-r.r,h=e-r.g,l=n-r.b;return s*s+h*h+l*l<=i}function It(t,e,n){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const o=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!o||!a)return e;const r=rt(e.sourceCrop,o,a),i=Math.min(360,Math.max(1,Math.round(r.width))),s=Math.max(1,Math.round(i*(r.height/r.width))),{ctx:h}=k(i,s);h.drawImage(t,r.x,r.y,r.width,r.height,0,0,i,s);const l=h.getImageData(0,0,i,s).data,c=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let f=i,m=s,d=-1,u=-1;for(let t=0;t<s;t++)for(let n=0;n<i;n++){const o=4*(t*i+n),a=l[o+3],r=l[o],s=l[o+1],h=l[o+2];a<=8||.2126*r+.7152*s+.0722*h<=c||Ft(r,s,h,e)||(n<f&&(f=n),t<m&&(m=t),n>d&&(d=n),t>u&&(u=t))}if(d<f||u<m)return e;const M=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),g=Math.round(i*M),p=Math.round(s*M);f=Math.max(0,f-g),m=Math.max(0,m-p),d=Math.min(i-1,d+g),u=Math.min(s-1,u+p);const v=function(t,e,n,o,a){const r=a&&Number.isFinite(a)&&a>0?a:null;if(!r)return t;const i=e.x,s=e.y,h=e.x+e.width,l=e.y+e.height,c=Math.max(i,t.left),f=Math.max(s,t.top),m=Math.min(h,n-t.right),d=Math.min(l,o-t.bottom),u=Math.max(1,m-c),M=Math.max(1,d-f),g=c+u/2,p=f+M/2;let v=u,x=M;v/x<r?v=x*r:x=v/r;v>e.width&&(v=e.width,x=Math.max(M,Math.min(e.height,v/r)));x>e.height&&(x=e.height,v=Math.max(u,Math.min(e.width,x*r)));let w=g-v/2,y=p-x/2;return w=Math.max(i,Math.min(h-v,w)),y=Math.max(s,Math.min(l-x,y)),{left:w,top:y,right:n-(w+v),bottom:o-(y+x)}}({left:r.x+f/i*r.width,top:r.y+m/s*r.height,right:o-(r.x+(d+1)/i*r.width),bottom:a-(r.y+(u+1)/s*r.height)},{x:r.x,y:r.y,width:r.width,height:r.height},o,a,n);return{...e,sourceCrop:{unit:"pixel",...v,preserveAspect:!1}}}function Lt(t){const e=t.sourceCrop;return e&&"pixel"===e.unit?void 0===e.left||void 0===e.top||void 0===e.right||void 0===e.bottom?null:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}:null}async function Rt(t,e,n,o,a){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const r=t.currentTime,i=function(t,e,n,o){const a=!0===o?{}:o||{},r=Math.max(0,a.from??e),i=a.to??n??(Number.isFinite(t.duration)?t.duration:r),s=Math.max(r,i-.04),h=Math.max(0,s-r),l=h>.1?[r,r+.25*h,r+.5*h,r+.75*h,s]:[r];return Array.from(new Set(l.map(t=>Math.max(0,Number(t.toFixed(3))))))}(t,n,o,a);let s=null;for(const n of i){await Et(t,n),await kt(t);const o=Lt(It(t,e));o&&(s=s?{left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.min(s.right,o.right),bottom:Math.min(s.bottom,o.bottom)}:o)}return await Et(t,r),await kt(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function Ht(t,e,n=2048){return Wt({sourceWidth:t,sourceHeight:e,maxRenderDimension:n})}function Wt({sourceWidth:t,sourceHeight:e,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:a=2048}){const r=Math.max(1,t),i=Math.max(1,e),s=r/i,h=Math.max(1,a),l=Math.min(1,h/Math.max(r,i)),c=Math.max(r,i)*l,f=Math.max(0,n,o),m=Math.min(h,Math.max(c,f));return s>=1?{renderW:Math.round(m),renderH:Math.round(m/s)}:{renderW:Math.round(m*s),renderH:Math.round(m)}}function jt(t,e,n,o){if(void 0===t)return;if("number"==typeof t)return t;const a=t.trim();if(a.endsWith("%")){const t=Number.parseFloat(a)/100;return Number.isFinite(t)?e*t:void 0}if(a.endsWith("px")){const t=Number.parseFloat(a);return Number.isFinite(t)?t:void 0}if(a.endsWith("vw")){const t=Number.parseFloat(a)/100;return Number.isFinite(t)?n*t:void 0}if(a.endsWith("vh")){const t=Number.parseFloat(a)/100;return Number.isFinite(t)?o*t:void 0}}function $t(t,e,n,o,a,r=2048,i={}){const{width:s,height:h}=e.getBoundingClientRect();if(!s||!h)return{renderW:0,renderH:0,dpr:1};const l="undefined"!=typeof window?window.innerWidth:s,c="undefined"!=typeof window?window.innerHeight:h,f=jt(i.width,s,l,c)??s,m=jt(i.height,h,l,c)??h,d=function(t,e,n,o,a){const r=t=>{const n=jt(t,e,o,a);return n&&n>0?n:0},i=t=>{const e=jt(t,n,o,a);return e&&e>0?e:0};return void 0===t?{x:0,y:0}:"number"==typeof t||"string"==typeof t?{x:r(t),y:i(t)}:{x:r(t.x),y:i(t.y)}}(i.bleed,s,h,l,c),u=f+2*d.x,M=m+2*d.y,{cssW:g,cssH:p}=function(t,e,n,o="contain"){if("fill"===o)return{cssW:t,cssH:e};let a=t,r=a/n;const i="cover"===o,s=r>e;return(i&&!s||!i&&s)&&(r=e,a=r*n),"scale-down"===o&&(a=Math.min(a,t),r=Math.min(r,e)),{cssW:Math.round(a),cssH:Math.round(r)}}(u,M,n,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let x,w;o&&a?({renderW:x,renderH:w}=Wt({sourceWidth:o,sourceHeight:a,cssWidth:g,cssHeight:p,maxRenderDimension:r})):(x=g,w=p);const y=8e6,b=x*v*w*v>y?Math.sqrt(y/(x*w)):v;return t.width=Math.round(x*b),t.height=Math.round(w*b),t.style.width=`${g}px`,t.style.height=`${p}px`,{renderW:x,renderH:w,dpr:b}}async function Pt(t,e,{fontSize:o,artStyle:a="classic",options:r={}}={}){let i;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((n,o)=>{e.onload=()=>n(),e.onerror=()=>o(new Error(`Failed to load image: ${t}`)),e.src=t}),i=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=()=>n(new Error("Image failed to load"))}),i=t):i=t;const s=vt(a),h=o??r.fontSize??10,l={...n,...s,artStyle:a,...r,fontSize:h},c=e.getContext("2d");if(!c)throw new Error("Could not get 2d context from canvas");const{w:f,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(i),{renderW:d,renderH:u}=Ht(f,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,g=8e6,p=d*M*u*M>g?Math.sqrt(g/(d*u)):M;e.width===Math.round(d*p)&&e.height===Math.round(u*p)||(e.width=Math.round(d*p),e.height=Math.round(u*p));const{frame:v}=it(i,l,d,u),x=(t,e)=>{c.save(),c.setTransform(p,0,0,p,0,0),gt(c,v,l,d,u,t/1e3,e),c.restore()};x(0,null);return U(e,x,{continuous:"none"!==l.animationStyle||!!l.charsetFrames?.length,interactive:l.hoverStrength>0}).stop}async function Ot(t,e,{fontSize:o,artStyle:a="classic",options:r={}}={}){const i="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??r.fontSize??10;let h={...n,...vt(a),artStyle:a,...r,fontSize:s};const l=e.getContext("2d");if(!l)throw new Error("Could not get 2d context from canvas");const{frames:c,fps:f}=await ft(i,h,e.width,e.height);if(!c.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const m=performance.now();let d=-1;return U(e,(t,n)=>{const o=Math.floor((t-m)*f/1e3)%c.length;o===d&&!n&&h.hoverStrength<=0&&"none"===h.animationStyle&&!h.charsetFrames?.length||(gt(l,c[o],h,e.width,e.height,(t-m)/1e3,n),d=o)},{continuous:!0,interactive:h.hoverStrength>0}).stop}async function zt(t,e,{fontSize:o,artStyle:a="classic",options:r={},fitTo:i,objectFit:s,objectPosition:h,scale:l,width:c,height:f,bleed:m,preExtract:d=!1,fps:u,maxRenderDimension:M=2048,trim:g,scroll:p,maxCachedFrames:v=90,onReady:x,onFrame:w}={}){const y=g?.start??0,b=g?.end,S=o??r.fontSize??10;let E={...n,...vt(a),artStyle:a,...r,fontSize:S};const k=e.getContext("2d");if(!k)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof i?document.querySelector(i):i instanceof HTMLElement?i:null,C={objectFit:s,objectPosition:h,scale:l,width:c,height:f,bleed:m},T=function(t,e){var n;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height||void 0!==t.bleed}(e))return()=>{};const o={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0===e.scale&&void 0===e.bleed||(t.style.maxWidth="none",t.style.maxHeight="none"),void 0!==e.scale){const o=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(o)),(n=t.style).transformOrigin||(n.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=o.width,t.style.height=o.height,t.style.objectFit=o.objectFit,t.style.objectPosition=o.objectPosition,t.style.maxWidth=o.maxWidth,t.style.maxHeight=o.maxHeight,t.style.transformOrigin=o.transformOrigin,o.scale?t.style.setProperty("scale",o.scale):t.style.removeProperty("scale")}}(e,C),F=t=>()=>{t(),T()};if(d){let n;"string"==typeof t?(n=document.createElement("video"),n.crossOrigin="anonymous",n.src=t,n.readyState<2&&await new Promise((e,o)=>{n.onloadeddata=()=>e(),n.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))})):n=t,E=await Rt(n,E,y,b,p);const o=Tt(n.videoWidth,n.videoHeight,E);A&&$t(e,A,o.w/o.h,o.w,o.h,M,C);const{renderW:a,renderH:r}=Ht(o.w,o.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,h=a*i*r*i>s?Math.sqrt(s/(a*r)):i;e.width===Math.round(a*h)&&e.height===Math.round(r*h)||(e.width=Math.round(a*h),e.height=Math.round(r*h));const l=void 0!==b?b-y:10,c=u??(p?18:void 0);if(yt(E)){const{frames:t,fps:o}=await ct(n,E,a,r,c,l,void 0,y),i=e=>{const n=t[e];n&&(k.save(),k.setTransform(h,0,0,h,0,0),ht(k,n,E,a,r),k.restore(),w?.())};if(p){let o=!1,a=-1;const r=!0===p?{}:p,s=Ct(wt(r.trigger)??A??e,r,e=>{const s=bt(e,r),h=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));h!==a&&(a=h,i(h),o||(o=!0,x?.(n)),r.onUpdate?.(s,n))});return i(0),o=!0,x?.(n),F(s)}let s=!1,f=0,m=0,d=performance.now(),u=!0,M=!0;const g=1e3/o,v=e=>{f=0,s||!u&&!M||(e-d>=g&&(i(m),m=(m+1)%t.length,d=e,M&&(M=!1,x?.(n))),f=requestAnimationFrame(v))},b="function"==typeof IntersectionObserver?new IntersectionObserver(([t])=>{u=t.isIntersecting,!u||f||s||(f=requestAnimationFrame(v))}):null;return b?.observe(e),f=requestAnimationFrame(v),F(()=>{s=!0,cancelAnimationFrame(f),b?.disconnect()})}const{frames:f,fps:m}=await lt(n,E,a,r,c,l,void 0,y);if(!f.length)throw new Error("asciifyVideo: no frames were decoded.");let d=0;const g=performance.now(),v=U(e,(t,e)=>{p||(d=Math.floor((t-g)*m/1e3)%f.length),k.save(),k.setTransform(h,0,0,h,0,0),gt(k,f[d],E,a,r,(t-g)/1e3,e),k.restore(),w?.()},{continuous:!p||"none"!==E.animationStyle||!!E.charsetFrames?.length,interactive:E.hoverStrength>0});let S;if(p){const t=!0===p?{}:p;S=Ct(wt(t.trigger)??A??e,t,e=>{d=Math.max(0,Math.min(f.length-1,Math.round(bt(e,t)*(f.length-1)))),v.wake(),t.onUpdate?.(e,n)})}return x?.(n),F(()=>{v.stop(),S?.()})}let I,L=!1;"string"==typeof t?(I=document.createElement("video"),I.crossOrigin="anonymous",I.src=t,I.muted=!0,I.loop=!0,I.playsInline=!0,I.setAttribute("playsinline",""),Object.assign(I.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(I),L=!0,await new Promise((e,n)=>{I.onloadedmetadata=()=>e(),I.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))}),await I.play().catch(()=>{})):(I=t,I.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{I.removeEventListener("loadedmetadata",o),I.removeEventListener("error",a)},o=()=>{n(),t()},a=()=>{n(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};I.addEventListener("loadedmetadata",o),I.addEventListener("error",a),I.load()}),I.paused&&await I.play().catch(()=>{})),y>0&&(I.currentTime=y,await new Promise(t=>{const e=()=>{I.removeEventListener("seeked",e),t()};I.addEventListener("seeked",e)}),await kt(I));let R=null;(y>0||void 0!==b)&&(R=()=>{(void 0!==b&&I.currentTime>=b||y>0&&I.currentTime<y)&&(I.currentTime=y)},I.addEventListener("timeupdate",R)),E=await Rt(I,E,y,b,p);let H=null;const W=Tt(I.videoWidth,I.videoHeight,E);let{renderW:j,renderH:$}=Ht(W.w,W.h,M);const P=t=>"frame"===E.chromaKeyTrimMode?It(t,E,j/$):E;if(A){const t=W.w/W.h,n=W.w,o=W.h,a=$t(e,A,t,n,o,M,C);j=a.renderW,$=a.renderH;const r=e.getContext("2d");r&&r.setTransform(a.dpr,0,0,a.dpr,0,0),H=new ResizeObserver(()=>{const a=$t(e,A,t,n,o,M,C);j=a.renderW,$=a.renderH;const r=e.getContext("2d");r&&r.setTransform(a.dpr,0,0,a.dpr,0,0)}),H.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,n=8e6,o=j*t*$*t>n?Math.sqrt(n/(j*$)):t;e.width===Math.round(j*o)&&e.height===Math.round($*o)||(e.width=Math.round(j*o),e.height=Math.round($*o)),k.setTransform(o,0,0,o,0,0)}let O=!0,z=null;const q=p&&!d,D=u&&u>0?1e3/u:0;let B=0;const V=!q&&yt(E);if(q&&"ascii"===E.renderMode&&"none"===E.animationStyle&&E.hoverStrength<=0&&!E.charsetFrames?.length){const t=!0===p?{}:p,n=wt(t.trigger)??A??e,o=t.from??y,a=t.to??b??I.duration,r=Math.max(o,Math.min(a,I.duration)),i=Math.max(.001,r-o),s=Math.min(60,Math.max(12,u??30)),h=Math.max(2,Math.ceil(i*s)+1),l=new Array(h),c=[],f=Math.max(2,Math.min(h,Math.floor(v))),m=()=>{for(;c.length>f;){const t=c.findIndex(t=>t!==M&&Math.abs(t-M)>2),e=t>=0?t:0,n=c.splice(e,1)[0];void 0!==n&&(l[n]=void 0)}},d=t=>{const e=c.indexOf(t);e>=0&&c.splice(e,1),c.push(t),m()};let M=0,g=0,S=-1,C=0,T=!0,W=!1,O=!1,q=!1;const U=new Set,V=document.createElement("video");V.muted=!0,V.playsInline=!0,V.preload="auto",V.crossOrigin=I.crossOrigin||"anonymous",V.src=I.currentSrc||I.src,Object.assign(V.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(V),V.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{V.removeEventListener("loadedmetadata",o),V.removeEventListener("error",a)},o=()=>{n(),t()},a=()=>{n(),e(new Error("asciifyVideo: cache video failed to load metadata."))};V.addEventListener("loadedmetadata",o),V.addEventListener("error",a),V.load()}),V.pause(),I.paused&&await I.play().catch(()=>{});const K=t=>o+i*t/Math.max(1,h-1),N=t=>Math.max(0,Math.min(h-1,Math.round(t*(h-1)))),Y=P(I),X=st(I,Y,j,$);X.rows.length>0&&(l[0]=X,d(0),ht(k,X,Y,j,$),q=!0,x?.(I),w?.());const G=t=>{if(l[t])return t;for(let e=1;e<h;e++){const n=t-e,o=t+e;if(n>=0&&l[n])return n;if(o<h&&l[o])return o}return-1},_=()=>{if(!l[M])return M;for(const t of U)if(!l[t])return t;for(let t=1;t<h;t++){const e=M-t,n=M+t;if(e>=0&&!l[e])return e;if(n<h&&!l[n])return n}return-1},J=t=>{t<0||t>=h||l[t]||(U.add(t),Q())},Q=async()=>{if(W||O)return;const t=_();if(!(t<0)){U.delete(t),O=!0;try{if(await Et(V,K(t)),!W){const e=P(V),n=st(V,e,j,$);n.rows.length>0&&(l[t]=n,d(t))}}finally{O=!1,W||requestAnimationFrame(()=>{Q()})}}},Z=()=>{if(C=0,W||!T&&q)return;const t=G(M);if(t>=0&&t!==S){const e=l[t];e&&(ht(k,e,E,j,$),S=t,q||(q=!0,x?.(I)),w?.())}else if(t<0||S<0){const t=performance.now();if(D<=0||t-B>=D){const e=P(I),n=st(I,e,j,$);n.rows.length>0&&(ht(k,n,e,j,$),B=t,q||(q=!0,x?.(I)),w?.())}}J(M),C=requestAnimationFrame(Z)};z=Ct(n,t,e=>{const n=function(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const o=n.from??0,a=n.to??t.duration,r=Math.max(o,Math.min(a,t.duration)),i=bt(e,n),s=o+(r-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,r-.04))}}(I,e,{...t,from:o,to:r});g=n?.progress??xt(e),M=N(g),J(M),J(M-1),J(M+1),J(M-2),J(M+2),J(M-3),J(M+3),t.onUpdate?.(g,I)}),J(0),J(1);const tt="function"==typeof IntersectionObserver?new IntersectionObserver(([t])=>{T=t.isIntersecting,!T||C||W||(C=requestAnimationFrame(Z))}):null;return tt?.observe(e),C=requestAnimationFrame(Z),F(()=>{W=!0,cancelAnimationFrame(C),tt?.disconnect(),z?.(),H?.disconnect(),U.clear(),c.length=0,l.fill(void 0),V.pause(),V.src="",V.removeAttribute("src"),V.load(),V.isConnected&&V.remove(),R&&I.removeEventListener("timeupdate",R),L&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}if(q){const t=!0===p?{}:p;z=At(I,{...t,trigger:t.trigger??A??e,from:t.from??y,to:t.to??b})}let K=-1,N=0,Y=-1,X=0;const G="function"==typeof I.requestVideoFrameCallback,_=()=>{X=I.requestVideoFrameCallback(()=>{N++,_()})};G&&_();let J=0,Q=0,Z=null;const tt=U(e,(t,n)=>{if(I.readyState<2||0===e.width||0===e.height)return;if(D>0&&t-B<D&&!n)return;if(y>0&&I.currentTime<y)return;if(void 0!==b&&I.currentTime>=b)return;const o=(G?N!==Y:I.currentTime!==K)||J!==j||Q!==$;if(o||!(E.hoverStrength<=0)||"none"!==E.animationStyle||E.charsetFrames?.length){if(V){const t=P(I),e=st(I,t,j,$);ht(k,e,t,j,$)}else!o&&Z||(Z=it(I,P(I),j,$).frame),gt(k,Z,E,j,$,t/1e3,n);K=I.currentTime,Y=N,J=j,Q=$,B=t,O&&(O=!1,x?.(I)),w?.()}},{continuous:!0,interactive:E.hoverStrength>0});return F(()=>{tt.stop(),X&&I.cancelVideoFrameCallback(X),z?.(),H?.disconnect(),R&&I.removeEventListener("timeupdate",R),L&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}function qt(t,e,n){return zt(t,e,n)}function Dt(t,e={},o,a){const r={...n,...e},{frame:i,cols:s}=it(t,r,o,a);if(!i.length||0===s)return"";const h=[];for(const t of i)h.push(t.map(t=>t.char).join(""));return h.join("\n")}function Ut(t,e={},o,a){const r={...n,...e},{frame:i,cols:s}=it(t,r,o,a);if(!i.length||0===s)return"";const h=[];for(const t of i){let e="";for(const n of t)" "===n.char||n.a<10?e+=" ":e+=`[38;2;${n.r};${n.g};${n.b}m${n.char}`;h.push(e)}return h.join("\n")}function Bt(t,e,n,o="#505050",a=100){if(!t||e<=0||n<=0)return[];const r=function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return n?{r:+n[1],g:+n[2],b:+n[3]}:null}(o)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:n},(t,n)=>Array.from({length:e},(t,o)=>({char:i[(n*e+o)%s],r:r.r,g:r.g,b:r.b,a:a})))}var Vt=new WeakMap;function Kt(t,e,o,a,r={},i){const{fontSize:s=10,lineHeight:h=1.6,color:l="#505050",opacity:c=100,hoverEffect:f="spotlight",hoverStrength:m=.85,hoverRadius:d=.18,hoverColor:u="#d4ff00"}=r,M=Math.max(1,Math.floor(e/s)),g=Math.max(1,Math.floor(o/(s*h))),p=JSON.stringify([a,M,g,l,c]);let v=Vt.get(t);v&&v.key===p||(v={key:p,frame:Bt(a,M,g,l,c)},Vt.set(t,v));gt(t,v.frame,{...n,fontSize:s,hoverEffect:f,hoverStrength:m,hoverRadius:d,hoverColor:u},e,o,0,i??null)}function Nt(t,{format:e="png",quality:n=.92,scale:o=1}={}){return new Promise((a,r)=>{let i=t;if(1!==o){const e=document.createElement("canvas");e.width=Math.round(t.width*o),e.height=Math.round(t.height*o);const n=e.getContext("2d");if(!n)return void r(new Error("captureSnapshot: could not get 2d context"));n.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?a(t):r(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,n)})}async function Yt(t,e={}){const{filename:n="asciify-snapshot",format:o="png",...a}=e,r=await Nt(t,{format:o,...a}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(r),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)}async function Xt(t,{fontSize:e=10,style:o="classic",options:a={},liveOptions:r,mirror:i=!0,constraints:s={facingMode:"user"},dpr:h}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const l=vt(o),c=await navigator.mediaDevices.getUserMedia({video:s}),f=document.createElement("video");f.srcObject=c,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const m={...n,...l,...a,fontSize:e},d=t.getContext("2d");if(!d)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=h??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&d.scale(u,u);let M=null;const g=e=>{const n=t.getBoundingClientRect();M={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},p=()=>{M=null};m.hoverStrength>0&&(t.addEventListener("mousemove",g),t.addEventListener("mouseleave",p));let v,x=!1;const w=performance.now(),y=e=>{if(!x){if(f.readyState>=f.HAVE_CURRENT_DATA){const n=t.width/u,o=t.height/u,a=(e-w)/1e3,s=r?{...m,...r()}:m;s.hoverStrength>0?(t.addEventListener("mousemove",g),t.addEventListener("mouseleave",p)):(t.removeEventListener("mousemove",g),t.removeEventListener("mouseleave",p));const{frame:h}=it(f,s,n,o),l=M&&i?{x:1-M.x,y:M.y}:M;i?(d.save(),d.scale(-1,1),d.translate(-n,0),gt(d,h,s,n,o,a,l),d.restore()):gt(d,h,s,n,o,a,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{x=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",g),t.removeEventListener("mouseleave",p),c.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var Gt={A:[28,54,99,127,99,99,99],B:[126,99,99,126,99,99,126],C:[62,99,96,96,96,99,62],D:[124,102,99,99,99,102,124],E:[127,96,96,124,96,96,127],F:[127,96,96,124,96,96,96],G:[62,99,96,111,99,99,62],H:[99,99,99,127,99,99,99],I:[127,8,8,8,8,8,127],J:[63,6,6,6,102,102,60],K:[99,102,108,120,108,102,99],L:[96,96,96,96,96,96,127],M:[99,119,107,107,99,99,99],N:[99,115,107,103,99,99,99],O:[62,99,99,99,99,99,62],P:[126,99,99,126,96,96,96],Q:[62,99,99,99,107,102,61],R:[126,99,99,126,108,102,99],S:[62,99,96,62,3,99,62],T:[127,8,8,8,8,8,8],U:[99,99,99,99,99,99,62],V:[99,99,99,99,54,28,8],W:[99,99,99,107,107,54,20],X:[99,54,28,8,28,54,99],Y:[99,99,54,28,8,8,8],Z:[127,3,6,12,24,48,127],a:[0,0,60,3,62,99,61],b:[96,96,124,99,99,99,124],c:[0,0,62,96,96,96,62],d:[3,3,31,99,99,99,31],e:[0,0,62,99,127,96,62],f:[30,48,48,126,48,48,48],g:[0,0,63,99,63,3,62],h:[96,96,124,99,99,99,99],i:[8,0,24,8,8,8,28],j:[4,0,12,4,4,36,24],k:[96,96,102,108,120,108,102],l:[24,8,8,8,8,8,28],m:[0,0,92,107,107,99,99],n:[0,0,94,99,99,99,99],o:[0,0,62,99,99,99,62],p:[0,0,126,99,126,96,96],q:[0,0,63,99,63,3,3],r:[0,0,94,99,96,96,96],s:[0,0,62,96,62,3,124],t:[48,48,126,48,48,48,30],u:[0,0,99,99,99,103,59],v:[0,0,99,99,54,28,8],w:[0,0,99,99,107,54,20],x:[0,0,99,54,28,54,99],y:[0,0,99,99,63,3,62],z:[0,0,127,6,12,24,127],0:[62,99,103,107,115,99,62],1:[8,24,56,8,8,8,62],2:[62,99,3,6,24,48,127],3:[62,99,3,30,3,99,62],4:[6,14,22,38,127,6,6],5:[127,96,126,3,3,99,62],6:[62,99,96,126,99,99,62],7:[127,3,6,12,24,24,24],8:[62,99,99,62,99,99,62],9:[62,99,99,63,3,99,62]," ":[0,0,0,0,0,0,0],"!":[24,24,24,24,24,0,24],"?":[62,99,3,14,8,0,8],".":[0,0,0,0,0,24,24],",":[0,0,0,0,0,24,48],";":[0,24,24,0,24,24,48],":":[0,24,24,0,24,24,0],"-":[0,0,0,62,0,0,0],_:[0,0,0,0,0,0,127],"'":[24,24,32,0,0,0,0],'"':[54,54,36,0,0,0,0],"`":[24,8,0,0,0,0,0],")":[24,12,6,6,6,12,24],"(":[12,24,48,48,48,24,12],"[":[60,48,48,48,48,48,60],"]":[30,6,6,6,6,6,30],"{":[14,24,24,48,24,24,14],"}":[56,12,12,6,12,12,56],"/":[3,6,12,24,48,96,0],"\\":[96,48,24,12,6,3,0],"|":[8,8,8,8,8,8,8],"+":[0,8,8,62,8,8,0],"=":[0,0,62,0,62,0,0],"*":[0,42,28,127,28,42,0],"#":[36,36,127,36,127,36,36],"@":[62,99,111,107,111,96,62],"&":[24,36,24,60,74,68,58],"%":[99,38,4,8,16,50,99],$:[8,62,72,62,9,62,8],"^":[8,20,34,0,0,0,0],"~":[0,0,50,76,0,0,0],"<":[6,12,24,48,24,12,6],">":[48,24,12,6,12,24,48]},_t=[127,65,65,65,65,65,127];function Jt(t){return Gt[t]??Gt[t.toUpperCase()]??_t}function Qt(t,e={}){if(!t)return"";const{char:n="█",scale:o=1}=e,a=[...n][0]??"█",r=Math.max(1,Math.floor(o)),i=7*r,s=r,h=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const n=Jt(t[e]);for(let t=0;t<7;t++){const e=n[t];let o="";for(let t=6;t>=0;t--)o+=(e>>t&1?a:" ").repeat(r);for(let e=0;e<r;e++)h[t*r+e]+=o}if(e<t.length-1)for(let t=0;t<i;t++)h[t]+=" ".repeat(s)}return h.join("\n")}function Zt(t,e,n={}){const{color:o="#d4ff00",bgColor:a,fontSize:r=10}=n,i=Qt(e,n);if(!i)return;const s=i.split("\n"),h=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(h*r*.6),t.height=Math.ceil(s.length*r);const l=t.getContext("2d");a&&"transparent"!==a?(l.fillStyle=a,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=o,l.font=`${r}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*r))}var te=["ascii","blocks","braille","dots","lines","cross","diagonal","diamond","mixed","pixel","mosaic","lego","voxel","disco","dither","hex","led","cmyk","stipple","engraving","crosshatch","woodblock","risograph","pointillism"];export{t as CHARACTER_SETS,n as DEFAULT_OPTIONS,o as HOVER_PRESETS,e as PALETTE_THEMES,te as STUDIO_STYLES,Dt as asciiText,Ut as asciiTextAnsi,Pt as asciify,Ot as asciifyGif,qt as asciifyLiveVideo,Qt as asciifyText,zt as asciifyVideo,Xt as asciifyWebcam,Bt as buildTextFrame,Nt as captureSnapshot,tt as clearAsciifyCaches,Wt as computeCanvasRenderSize,At as createVideoScrollScrub,ft as gifToAsciiFrames,mt as gifToAsciiTextFrames,it as imageToAsciiFrame,st as imageToAsciiTextFrame,gt as renderFrameToCanvas,Kt as renderTextBackground,ht as renderTextFrameToCanvas,Zt as renderTextToCanvas,Yt as snapshotAndDownload,lt as videoToAsciiFrames,ct as videoToAsciiTextFrames};//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ import{scenePreset as e}from"./chunk-C3C7AYKL.js";var r=e({id:"halo",name:"Halo",description:"A corona breathes slowly round the middle, its rays turning; the centre stays empty for a headline.",cellSize:11,scene:"halo",charset:" .·:-=+*",hover:"lantern",middle:!1,feather:.12});export{r as halo};//# sourceMappingURL=chunk-2CF4PX6U.js.map
@@ -0,0 +1 @@
1
+ import{styleKeeper as t,mountSurface as e,clamp as r,handle as n,resolveColor as o,mixHex as a,prefersReduced as i}from"./chunk-S7RZP2MT.js";var s={thumb:'[role="slider"]',label:"[data-label]",threshold:.9,resetAfter:0},l=720,c=(t,e,r)=>t+(e-t)*r,d=t=>1-(1-t)**3,u=(t,e,r)=>({x:t,v:0,to:t,k:e,z:r});function m(t,e,r=.4){const n=2*Math.sqrt(t.k)*t.z,o=Math.max(1,Math.ceil(240*e)),a=e/o;for(let e=0;e<o;e++)t.v+=(-t.k*(t.x-t.to)-n*t.v)*a,t.x+=t.v*a;return!(Math.abs(t.x-t.to)<r&&Math.abs(t.v)<12*r)||(t.x=t.to,t.v=0,!1)}var f=t=>{t.x=t.to,t.v=0};function h(t,e){const r=t.filter(([,t])=>e-t<80);if(r.length<2)return 0;const[n,o]=r[0],[a,i]=r[r.length-1];return i>o?(a-n)/(i-o)*1e3:0}function p(p,v={}){const x={current:{...s,...v}},b=t(),g=p.querySelector(x.current.thumb)??p.firstElementChild,k=()=>p.querySelector(x.current.label),y=()=>!!(x.current.reducedMotion??i());let A=u(0,520,.8),w=u(0,150,1),M=!1,E=0,L=!1,S=0,C=0,I=[],T=0,P=0,R=0,q="",z=-1,D=null;const W=()=>{if(!g)return null;const t=Math.max(0,(p.clientHeight-g.offsetHeight)/2);return{pad:t,size:g.offsetHeight,max:Math.max(1,p.clientWidth-g.offsetWidth-2*t)}},$=()=>p.getBoundingClientRect().width/(p.clientWidth||1)||1,F=t=>o(x.current.ink??"--ascii-ink-strong",p)??o(getComputedStyle(p).color,p)??(t?"#d8d6cf":"#1d1d1b");D=e({host:p,layer:"under",look:()=>({mark:"glyph",charset:" .:-=+*#%@",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:4,cellAspect:.62,glyphScale:.94,...x.current.look}),ink:F,kit:x,reducedMotion:()=>x.current.reducedMotion,onFail:()=>{D=null},onTheme:()=>{q=""},paint:({pen:t,w:e,h:n,now:i,still:s,dark:u,box:m})=>{const f=W();if(!f)return!1;const h=L?s?1:r((i-S)/l):0,v=d(r(h/.5)),b=d(r((h-.36)/.3)),g=d(r((h-.46)/.4)),k=r((h-.5)/.5),y=1+.07*Math.sin(Math.PI*k)*(1-k),M=C?1-r((i-C)/260):1,E=x.current.mark?m(x.current.mark):{x:e/2-18,y:n/2-18,w:36,h:36},I=E.x+E.w/2,T=E.y+E.h/2,P=Math.min(E.w/2,n/2-2)*y,R=L?a(F(u),(t=>o(x.current.color??"--ascii-success",p,t?"#3ccf7e":"#17844a"))(u),d(r(s?1:(i-S)/360))):F(u);R!==q&&(q=R,D?.field.update({ink:R})),t.save(),t.globalAlpha=M,t.beginPath(),e>4&&n>4&&t.roundRect(2,2,e-4,n-4,(n-4)/2),t.clip(),t.fillStyle=`rgba(255,255,255,${.1*(1-v)})`,t.fillRect(0,0,e,n);const z=f.pad+A.x+f.size/2,$=L?1:w.x,H=c(0,I-P,v),G=c(z,I+P,v),X=c(0,T-P,v),j=c(n,T+P,v);if(G-H>1&&$>.004){const e=t.createLinearGradient(H,0,G,0);e.addColorStop(0,`rgba(255,255,255,${c(.14,1,v)*$})`),e.addColorStop(.62,`rgba(255,255,255,${c(.48,1,v)*$})`),e.addColorStop(1,`rgba(255,255,255,${$})`),t.fillStyle=e,t.globalAlpha=M*(1-.28*b),t.beginPath(),t.roundRect(H,X,G-H,j-X,c(0,P,v)),t.fill()}return b>0&&(t.globalAlpha=1,t.fillStyle="#000",t.beginPath(),t.arc(I,T,Math.max(0,P-5)*b,0,2*Math.PI),t.fill()),t.restore(),g>0&&function(t,e,r,n,o,a,i){if(o<=0||a<=0)return;const s=[[-.82,.02],[-.26,.56],[.86,-.6]].map(([t,o])=>[e+t*n,r+o*n]),l=Math.hypot(s[1][0]-s[0][0],s[1][1]-s[0][1])+Math.hypot(s[2][0]-s[1][0],s[2][1]-s[1][1]);t.save(),t.globalAlpha=a,t.strokeStyle="#fff",t.lineWidth=i,t.lineCap="round",t.lineJoin="round",t.setLineDash([l*o,l]),t.beginPath(),t.moveTo(s[0][0],s[0][1]),t.lineTo(s[1][0],s[1][1]),t.lineTo(s[2][0],s[2][1]),t.stroke(),t.restore()}(t,I+.02*P,T+.07*P,.55*P,g,M,4.5),!1}});const H=()=>{const t=W();if(!t||!g)return;const e=A.x/t.max;b.set(g,"translate",`${A.x}px 0`),g.setAttribute("aria-valuenow",String(Math.round(100*r(e))));const n=k();n&&b.set(n,"opacity",String(L?0:1-r(1.7*e)))},G=t=>{T=0;const e=Math.min(1/30,Math.max(0,(t-P)/1e3));P=t;let r=!M&&m(A,e,.3);r=m(w,e,.003)||r,C&&(t-C>=260||y())&&(C=0,L=!1,A=u(0,520,.8),w=u(0,150,1),p.dataset.state="idle",delete p.dataset.confirmed,g&&(b.set(g,"opacity","1"),b.set(g,"scale","1"),g.tabIndex=0)),L&&t-S>302.4&&(p.dataset.confirmed=""),H(),D?.kick(),(r||M||L&&t-S<760||C>0)&&(T=requestAnimationFrame(G))},X=()=>{T||(P=performance.now(),T=requestAnimationFrame(G))},j=()=>{const t=W();if(!t||L)return;const e=t.max-A.x;M=!1,L=!0,A.to=t.max,w.to=1,S=performance.now()+(e>4?200:90),y()&&(f(A),f(w),S=-1e6,p.dataset.confirmed=""),p.dataset.state="confirmed",g&&(g.setAttribute("aria-valuetext","Confirmed"),g.tabIndex=-1,b.set(g,"transition","opacity 200ms 160ms, scale 240ms 160ms"),b.set(g,"opacity","0"),b.set(g,"scale",".6")),R&&clearTimeout(R),x.current.resetAfter>0&&(R=setTimeout(B,x.current.resetAfter)),H(),X(),x.current.onConfirm?.()};function B(){if(R&&clearTimeout(R),R=0,!L)return A.to=0,w.to=0,void X();C=performance.now(),p.dataset.state="resetting",g?.removeAttribute("aria-valuetext"),X()}const J=t=>{const e=W();if(!M||!e||void 0!==t&&void 0!==t.pointerId&&t.pointerId!==z)return;M=!1;const n=h(I,performance.now());A.x>=e.max*x.current.threshold||n>900&&A.x>.5*e.max?j():(A.to=0,A.v=.25*r(n,-1500,1500),w.to=0,y()&&(f(A),f(w)),p.dataset.state="idle",X())},U=t=>{if(0===t.button&&!L&&g)if(g.contains(t.target)){try{g.setPointerCapture?.(t.pointerId)}catch{}z=t.pointerId,M=!0,E=t.clientX-A.x*$(),w.to=1,I=[],p.dataset.state="dragging",X()}else M||y()||(A.v+=420,w.to=0,X())},Z=t=>{const e=W();M&&e&&t.pointerId===z&&(A.x=A.to=r((t.clientX-E)/$(),0,e.max),A.v=0,I.push([A.x,performance.now()]),I.length>8&&I.shift(),A.x>=e.max-.5?j():X())},K=t=>{const e=W();if(!e||L)return;if("Enter"===t.key||" "===t.key||"End"===t.key)return t.preventDefault(),void j();const n={ArrowRight:1,ArrowUp:1,ArrowLeft:-1,ArrowDown:-1}[t.key],o="Home"===t.key?0:void 0!==n?r(A.to+n*e.max/4,0,e.max):null;null!==o&&(t.preventDefault(),A.to=o,w.to=o>0?1:0,y()&&(f(A),f(w)),o>=e.max-.5?j():X())};g&&(g.hasAttribute("role")||g.setAttribute("role","slider"),g.hasAttribute("tabindex")||(g.tabIndex=0),g.hasAttribute("aria-label")||g.setAttribute("aria-label",k()?.textContent?.trim()||"Slide to confirm"),g.setAttribute("aria-valuemin","0"),g.setAttribute("aria-valuemax","100"),g.setAttribute("aria-valuenow","0"),b.set(g,"touch-action","none"),g.addEventListener("keydown",K));const N=t=>t.preventDefault();return p.dataset.state="idle",p.addEventListener("pointerdown",U),p.addEventListener("pointermove",Z),p.addEventListener("pointerup",J),p.addEventListener("pointercancel",J),p.addEventListener("lostpointercapture",J),p.addEventListener("dragstart",N),n(()=>D,x,()=>D?.refresh(),{confirm:j,reset:B,get confirmed(){return L}},()=>{T&&cancelAnimationFrame(T),R&&clearTimeout(R),T=R=0,g?.removeEventListener("keydown",K),p.removeEventListener("pointerdown",U),p.removeEventListener("pointermove",Z),p.removeEventListener("pointerup",J),p.removeEventListener("pointercancel",J),p.removeEventListener("lostpointercapture",J),p.removeEventListener("dragstart",N),b.restore(),delete p.dataset.state,delete p.dataset.confirmed})}var v=s;export{v as SLIDE_TO_CONFIRM_DEFAULTS,p as slideToConfirm,m as stepSpring,h as velocity};//# sourceMappingURL=chunk-2NVKPXPL.js.map
@@ -0,0 +1 @@
1
+ import{mountSurface as n,mixHex as t,handle as e,resolveColor as i}from"./chunk-S7RZP2MT.js";var r={colourByState:!0,ring:!0},o={success:["--ascii-success","#17844a","#3ccf7e"],warning:["--ascii-warning","#9a6700","#f5b83d"],error:["--ascii-error","#c93636","#ff6b6b"]},a=120,c=280,s=520,l=2*Math.PI,u=l/1050,d=n=>1-(1-n)**4,f=n=>`rgb(${255*n} ${255*n} ${255*n})`,h=n=>n*u-Math.PI/2,g=(n,t=0)=>78+5*Math.sin(n/1600*l)*(1-t);function p(n,t,e=78,i=24){n.strokeStyle=f(t),n.lineWidth=i,n.beginPath(),n.arc(a,a,e,0,l),n.stroke()}function k(n,t,e,i=0,r=1){if(p(n,(.3+(e-78)/100)*r,e,24-6*i),i>=1)return void p(n,.72*r,e,18);const o=3.4+(l-3.4)*i;n.lineCap="round";for(let c=0;c<32;c++){const s=c/32,l=.3+.7*(1-s)**1.6;n.strokeStyle=f((l+(.72-l)*i)*r),n.lineWidth=28-6*s+(18-(28-6*s))*i,n.beginPath(),n.arc(a,a,e,t-(s+1/32)*o,t-s*o),n.stroke()}}function m(n,t,e,i=800,r=0,o=!0){if("idle"===t)return void p(n,.34);if("loading"===t)return void k(n,h(e),g(e));const f=(n=>n<.5?4*n*n*n:1-(-2*n+2)**3/2)(Math.min(1,i/c)),m=Math.min(i,c),M=r+u*(m-m*m/560);o?k(n,M,g(e,f),f):f<1&&k(n,M,g(e,f),0,1-f);const b=(i-196)/s;o&&b>0&&b<1&&p(n,.5*(1-b)**2,88+24*b,16-8*b),function(n,t,e,i=30){n.strokeStyle="#fff",n.lineWidth=i,n.lineCap="round",n.lineJoin="round";const r=(t,e)=>{const i=t.slice(1).map((n,e)=>Math.hypot(n[0]-t[e][0],n[1]-t[e][1]));let r=e*i.reduce((n,t)=>n+t,0);n.beginPath(),n.moveTo(t[0][0],t[0][1]);for(let e=1;e<t.length&&r>0;e++){const o=Math.min(1,r/i[e-1]);n.lineTo(t[e-1][0]+(t[e][0]-t[e-1][0])*o,t[e-1][1]+(t[e][1]-t[e-1][1])*o),r-=i[e-1]}n.stroke()};"success"===t?r([[86,122],[110,146],[156,96]],e):"warning"===t?(n.lineWidth=i-4,r([[a,74],[a,114]],Math.min(1,e/.7)),e>.7&&(n.fillStyle="#fff",n.beginPath(),n.arc(a,152,i/2*d((e-.7)/.3),0,l),n.fill())):(r([[92,92],[148,148]],e),r([[148,92],[92,148]],e))}(n,t,d(Math.min(1,Math.max(0,(i-40)/260))),o?24:30)}function M(a,c={}){const s={current:{...r,...c}};let l="idle",u=0,f=0,g="",p="",k=-1e9,M="",b=null;const y=n=>{if(!s.current.colourByState||"idle"===l||"loading"===l)return(n=>i(s.current.ink??"--ascii-ink-strong",a,n?"#d8d6cf":"#1d1d1b"))(n);const[t,e,r]=o[l];return i(s.current.colors?.[l]??t,a,n?r:e)};b=n({host:a,look:()=>({mark:"glyph",fit:"contain",charset:" .:-=+*#%@",cellSize:5,cellAspect:.62,glyphScale:.94,font:'"Geist Mono", ui-monospace, monospace',fontWeight:600,contrast:1.1,shade:.5,...s.current.look}),ink:n=>y(n),kit:s,reducedMotion:()=>s.current.reducedMotion,resolution:()=>[240,240],onFail:()=>{b=null},onTheme:()=>{k=-1e9,M=""},paint:({pen:n,now:e,still:i,dark:r})=>{const o=e-u;m(n,l,i?380:e,i?800:o,f,s.current.ring);const a=y(r);a!==p&&(g=p||a,p=a,k=e);const c=i?1:d(Math.min(1,(e-k)/200)),h=c<1?t(g,p,c):p;return h!==M&&(M=h,b?.field.update({ink:h})),"loading"===l||o<800||c<1}});const S=n=>{const t=performance.now();"loading"===l&&"loading"!==n&&(f=h(t)),l=n,u=t,a.dataset.state=n,"error"===n&&b&&!b.still()&&"function"==typeof a.animate&&a.animate({translate:["0","-5px 0","4px 0","-2px 0","0"]},{duration:260,easing:"cubic-bezier(.16, 1, .3, 1)"}),b?.kick()};return e(()=>b,s,()=>b?.refresh(),{idle:()=>S("idle"),loading:()=>S("loading"),success:()=>S("success"),warning:()=>S("warning"),error:()=>S("error"),get state(){return l}},()=>{delete a.dataset.state})}var b=r;export{b as STATUS_ORB_DEFAULTS,m as orbFrame,M as statusOrb};//# sourceMappingURL=chunk-3473NPIN.js.map
@@ -0,0 +1 @@
1
+ import{renderMaterial as t}from"./chunk-XPXMCXYI.js";import{mountCanvas as r}from"./chunk-BR6ZNJZW.js";var e=(t,r,e,o)=>{const i=48*t+4*Math.sin(2.6*r+.08*o)+1.5*Math.sin(7*r-2*t);return Math.pow(.5+.5*Math.sin(i),10)*(.35+.55*Math.pow(Math.sin(2*r+.4),2))},o={id:"etch",name:"Etch",description:"Cut-grain lines follow a slow, sculpted current.",cellSize:12,speed:1,cursor:!1,mount:o=>r(o,(r,o,i,n,h,s)=>t(e,r,o,i,n,{ditherStrength:s.ditherStrength,fontSize:s.fontSize,chars:s.chars,lightMode:s.lightMode,color:s.ink}))};export{o as etch};//# sourceMappingURL=chunk-3A5LID2G.js.map
@@ -0,0 +1 @@
1
+ import{mountGlyphField as e}from"../field.js";var t={ascii:{mark:"glyph",charset:" .:-=+*#%@"},blocks:{mark:"glyph",charset:" ░▒▓█"},braille:{mark:"glyph",charset:" ⠁⠃⠇⡇⣇⣧⣷⣿"},dots:{mark:"dot"},lines:{mark:"glyph",charset:" -═╪╬"},cross:{mark:"glyph",charset:" ·+xX#"},diagonal:{mark:"glyph",charset:" /╱╳"},diamond:{mark:"glyph",charset:" ·◇◈◆"},mixed:{mark:"glyph",charset:" .:+/◇#@"},pixel:{mark:"pixel"},mosaic:{mark:"mosaic"},lego:{mark:"lego"},voxel:{mark:"voxel"},disco:{mark:"disco"},dither:{mark:"dither"},hex:{mark:"hex"},led:{mark:"led"},cmyk:{mark:"cmyk"},stipple:{mark:"stipple"},engraving:{mark:"engraving"},crosshatch:{mark:"crosshatch"},woodblock:{mark:"woodblock"},risograph:{mark:"risograph"},pointillism:{mark:"pointillism"}},n=e=>"string"==typeof e&&Object.prototype.hasOwnProperty.call(t,e),r=/\p{L}/u,o=null,a=new Set,s=new Set;function i(e){const{charset:t,style:r}=e??{};o=e?{...t?{charset:t}:{},...n(r)?{style:r}:{}}:null;for(const e of s)e.relook();for(const e of[...a])e(o)}var l=()=>o;function c(e){return a.add(e),()=>{a.delete(e)}}var u=12,m=new Set,h=null,d=null,p=0,f=-1e9,g=0,y=!1,v=!1,k=()=>{const e=d?.timeline?.currentTime;return"number"==typeof e?e:null};function b(e){u=Number.isFinite(e)&&e>=1?Math.floor(e):12,O()}var w=()=>u,x=()=>"undefined"!=typeof performance?performance.now():Date.now(),E=()=>"number"==typeof innerHeight?innerHeight:0;function S(e,t=e.getBoundingClientRect()){if(!1===e.isConnected)return 1/0;if("function"==typeof e.getClientRects&&0===e.getClientRects().length)return 1/0;const n=t.bottom<0?-t.bottom:t.top-E();return n>0?n:0}function C(){try{const e=d?.querySelectorAll?.("dialog:modal");return e?.length?e[e.length-1]:null}catch{return null}}var M=1e8;function A(e,t){if(e.eager)return void(e.wanted=!0);const n=E(),r=S(e.host,t);!n||r<=.5*n?e.wanted=!0:r>1*n&&(e.wanted=!1)}function P(e){let t=!1;for(const n of e)if(n?.target)for(const e of m)e.host===n.target&&(A(e,n.boundingClientRect??void 0),t=!0);t&&O()}var W=()=>O(),L=null,$=e=>{L!==e&&(L?.removeEventListener?.("close",W,!0),e?.addEventListener?.("close",W,!0),L=e)};function z(e){d!==e.doc&&(d=e.doc,m.clear(),p=g=0,f=-1e9),$(d),m.add(e);const t=function(){const e="function"==typeof IntersectionObserver?IntersectionObserver:null;if(!e)return null;if(h?.ctor!==e){h?.list.forEach(e=>e.disconnect()),h={ctor:e,list:["50% 0px","100% 0px","0px"].map(t=>new e(P,{rootMargin:t}))};for(const e of m)h.list.forEach(t=>t.observe(e.host))}return h.list}();t?.forEach(t=>t.observe(e.host)),t?A(e):e.wanted=!0,O()}function O(e=!1){if(y)v=!0;else{y=!0;try{do{v=!1;const t=x(),n=k();(e||(null===n?t-f>16||t<f:n!==f))&&(f=n??t,g=0);for(const e of m)!1===e.host.isConnected&&(e.wanted=!1);for(const e of m)e.live&&!e.wanted&&e.release();const r=[...m].filter(e=>e.live),o=C(),a=e=>!!o&&!o.contains(e.host),s=e=>S(e.host)+(a(e)?M:0),i=e=>e.eager&&!a(e),l=()=>r.filter(e=>e.live).map(e=>[e,s(e)+(i(e)?0:1e9)]).sort((e,t)=>t[1]-e[1]);for(let e=r.length-u,t=e>0?l():[];e>0;e--)t.shift()?.[0].release();const c=[...m].filter(e=>e.wanted&&!e.live).map(e=>[e,e.eager?-1:s(e)]).sort((e,t)=>e[1]-t[1]);let h=0;for(const[t,n]of c){if(!m.has(t)||t.live)continue;if(!t.eager&&g>=4&&(!e||h)){p||(p=requestAnimationFrame(()=>{p=0,O(!0)}));break}if(r.filter(e=>e.live).length>=u){const e=l()[0]?.[0];if(!e||!t.eager&&(i(e)||s(e)<=n))break;e.release()}const o=x();t.mount(),g+=x()-o,h++,t.live&&r.push(t)}}while(v)}finally{y=!1}}}var R='ui-monospace, "SF Mono", Menlo, Consolas, monospace',T=new Map;function j(e,t=R){const n=`${t}\0${e}`,r=T.get(n);if(r)return r;let o={max:1,mean:1};try{const n="undefined"==typeof document?null:Object.assign(document.createElement("canvas"),{width:48,height:48}).getContext("2d",{willReadFrequently:!0});if(n&&"function"==typeof n.getImageData){n.font=`500 36px ${t}`,n.textAlign="center",n.textBaseline="middle";const r=e=>{n.clearRect(0,0,48,48),n.fillStyle="#000",n.fillText(e,24,25);const t=n.getImageData(0,0,48,48).data;let r=0;for(let e=3;e<t.length;e+=4)r+=t[e];return r/255},a=e=>[...e].filter(e=>e.trim()).map(r),s=e=>e.reduce((e,t)=>e+t,0)/Math.max(1,e.length),i=a(e),l=a(".:-=+*#%@"),c=r("@");i.length&&c>0&&s(l)>0&&(o={max:Math.max(...i)/c,mean:s(i)/s(l)})}}catch{}return T.set(n,o),o}function F(e,t){const{max:n,mean:r}=j(e,t.font??R),o=t.glyphScale??.8,a=t.gamma??1,s=t.fontWeight??500;return n>1.15?{glyphScale:Math.max(.3,o*Math.max(.62,n**-.36)),gamma:a,fontWeight:s}:r>1.5?{glyphScale:Math.max(.3,o*r**-.25),gamma:a,fontWeight:s}:n<.85?{glyphScale:Math.min(1.6,o*Math.min(1.3,n**-.3)),gamma:a,fontWeight:n<.6?Math.max(s,700):s}:{glyphScale:o,gamma:a,fontWeight:s}}var B=new WeakMap;function q(e,t){for(const n of B.get(e)?.keys()??[])n.getAttribute("src")!==t&&(n.src=t)}function I(e){const t=B.get(e);B.delete(e),t?.forEach(e=>e())}var D=()=>"function"==typeof matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches;function X(e,t,n,r,o){const a=document.createElement("img");a.alt="",a.decoding="async",a.setAttribute("aria-hidden","true"),a.setAttribute("style",`${n};object-fit:cover${D()?"":";transition:opacity 280ms cubic-bezier(.23, 1, .32, 1)"}`),a.style.opacity="1",a.dataset.asciiPoster="",a.src=t;const s=e.style.getPropertyValue("position"),i="function"==typeof getComputedStyle&&"static"===getComputedStyle(e).position;i&&e.style.setProperty("position","relative");const l=e.style.getPropertyValue("isolation"),c=/z-index:\s*-1/.test(n)&&"function"==typeof getComputedStyle&&"auto"===getComputedStyle(e).isolation;c&&e.style.setProperty("isolation","isolate"),o?.parentElement===e?e.insertBefore(a,o):e.appendChild(a);let u=!1;const m=()=>{u||(u=!0,a.remove(),B.get(r)?.delete(a),i&&(s?e.style.setProperty("position",s):e.style.removeProperty("position")),c&&(l?e.style.setProperty("isolation",l):e.style.removeProperty("isolation")))},h=B.get(r)??new Map;return h.set(a,m),B.set(r,h),{show(e){a.style.opacity=e?"1":"0"},remove:m}}function H(e){const t=document.createElement("canvas");for(const n of e.getAttributeNames?.()??[])"width"!==n&&"height"!==n&&t.setAttribute(n,e.getAttribute(n));return t.style.cssText=e.style.cssText,Object.assign(t.dataset,e.dataset),e.replaceWith?e.replaceWith(t):e.parentElement&&(e.parentElement.insertBefore(t,e),e.remove()),t}function N(n){const{host:a,kit:i}=n;let l,c=n.canvas,u=null,d=!1,p=!1,f=!1,g=!1,y={},v={},k=n.source,b=!1,w={},x=null,E=null,S=!1,C=null,M=()=>{};const A=!n.ownPoster&&i?.current.poster?X(a,i.current.poster,n.place,i,c):null,P=()=>{if(!o||!1===i?.current.globalLook||"glyph"!==(v.mark??"glyph")&&!n.glyphs||r.test(v.charset??""))return;const e=o.style?t[o.style]:void 0,a=e?.mark??"glyph",s="glyph"===a?o.charset||(e&&"charset"in e?e.charset:void 0):void 0;return e||s?{mark:a,charset:s}:void 0},W=()=>({...n.glyphs?Object.fromEntries(Object.keys(n.glyphs()).map(e=>[e,v[e]]).filter(([,e])=>void 0!==e)):{},mark:v.mark??"glyph",charset:v.charset??" .,:-=+*#%@",glyphScale:v.glyphScale??.8,gamma:v.gamma??1,fontWeight:v.fontWeight??500}),L=e=>{if(!e.charset)return{...W(),mark:e.mark};const t=n.glyphs&&"glyph"!==(v.mark??"glyph")?n.glyphs():{};return{...t,mark:e.mark,charset:e.charset,...F(e.charset,{...v,...t})}},R=()=>{const e=P(),t=e&&`${e.mark}\0${e.charset??""}`;return t===l?null:(l=t,e?L(e):W())},T={host:a,doc:document,eager:!1===i?.current.lazy,wanted:!1,live:!1,mount(){if(p||u)return;d&&(c=n.canvas=H(c)),d=!0,v={...n.options(),...y},l=void 0;const t=R();let r;try{r=e(c,{...v,...t,...void 0===k?{}:{source:k},onError:()=>{u===r&&j()}})}catch{return void j()}u=r,T.live=!0;const o=c;let a=0;const s=()=>{u===r&&(clearTimeout(a),a=setTimeout(()=>{u===r&&c===o&&(T.release(),O())},1e3))},i=()=>clearTimeout(a);o.addEventListener?.("webglcontextlost",s),o.addEventListener?.("webglcontextrestored",i),M=()=>{clearTimeout(a),o.removeEventListener?.("webglcontextlost",s),o.removeEventListener?.("webglcontextrestored",i)},b&&r.pause(),r.ready.then(()=>{u===r&&(S=!0,A?.show(!1),x?.(),x=E=null)},()=>{}),n.onMount?.(r,c)},release(){if(!u)return;const e=u;u=null,T.live=!1,S=!1,M(),C?.clear(),C=null,w=e.settings,e.destroy(),(e=>{try{const t=e.getContext("webgl2");t&&!t.isContextLost?.()&&t.getExtension("WEBGL_lose_context")?.loseContext()}catch{}})(c),p||(c=n.canvas=H(c),d=!1),A?.show(!0),n.onRelease?.()}};function j(){f||(f=!0,B(),g||n.onFail())}function B(){p||(p=!0,T.release(),function(e){m.delete(e)&&([...m].some(t=>t.host===e.host)||h?.list.forEach(t=>t.unobserve(e.host)),!m.size&&h&&(h.list.forEach(e=>e.disconnect()),h=null),m.size||$(null),O())}(T),s.delete(q),c.remove(),f?A?.show(!0):A?.remove())}const q={relook(){const e=R();if(!e||!u)return;const t=u,r=S&&!(i?.current.reducedMotion??D());C?.clear(),C=null,r&&(t.redraw(),C=function(e,t){if(!e.width||!e.height||"undefined"==typeof document)return null;const n=document.createElement("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");if(!r||"function"!=typeof n.animate)return null;try{r.drawImage(e,0,0)}catch{return null}n.setAttribute("aria-hidden","true"),n.dataset.asciiSweep="",n.setAttribute("style",t);const o=document.createElement("span");let a,s;o.setAttribute("aria-hidden","true"),o.dataset.asciiSweep="",o.setAttribute("style",`${t};right:auto;width:2px;margin-left:-1px;opacity:0;background:var(--ascii-sweep, #f3ba32);box-shadow:0 0 10px 1px color-mix(in srgb, var(--ascii-sweep, #f3ba32) 40%, transparent)`),e.after(n,o);const i=()=>{a?.cancel(),s?.cancel(),n.remove(),o.remove()};return{clear:i,reveal(){if(!n.isConnected)return;const t={duration:200,delay:40,easing:"cubic-bezier(.23,1,.32,1)",fill:"both"};a=n.animate([{clipPath:"inset(0% 0% 0% 0%)"},{clipPath:"inset(0% 0% 0% 100%)"}],t);const r=e.clientWidth||e.getBoundingClientRect().width;s=o.animate([{transform:"translateX(0px)",opacity:.35},{opacity:.35,offset:.7},{transform:`translateX(${r}px)`,opacity:0}],t),a.onfinish=i}}}(c,n.place)),t.update(e);const o=C;o&&requestAnimationFrame(()=>requestAnimationFrame(()=>{C===o&&u===t?o.reveal():o.clear()}))}};return{field:{get canvas(){return c},get ready(){return u?u.ready:E??(E=new Promise(e=>{x=e}))},get settings(){return u?.settings??w},update(e){if(y={...y,...e},v={...v,...e},!u)return;const t=R(),n=P();u.update(n?{...e,...L(n)}:t?{...e,...t}:e)},setSource:e=>(k=e,u?u.setSource(e):Promise.resolve()),pointer(e,t){u?.pointer(e,t)},redraw(){u?.redraw()},pulse(e){u?.pulse(e)},play(){b=!1,u?.play()},pause(){b=!0,u?.pause()},resize(){u?.resize()},destroy(){B()}},get canvas(){return c},get live(){return!!u},get failed(){return f},start(){s.add(q),g=!0;try{z(T)}finally{g=!1}},destroy:B}}export{t as KIT_STYLES,F as balanceCharset,I as disposeKit,w as getFieldBudget,l as getGlobalLook,j as inkWeight,N as liveField,X as poster,b as setFieldBudget,i as setGlobalLook,q as setPosterSource,c as subscribeGlobalLook};//# sourceMappingURL=chunk-3PCKMO6I.js.map
@@ -0,0 +1 @@
1
+ import{injectStyle as e}from"./chunk-4OT66HSZ.js";import{drawBlocks as t,snapshot as n,blocksOf as r,BLOCK_W as o,BLOCK_H as s}from"./chunk-BNVRKD3V.js";import{styleKeeper as i,mountSurface as a,house as c,clamp as l,handle as u,hash as d,boxIn as f,prefersReduced as p}from"./chunk-S7RZP2MT.js";var h={input:"input",rows:'[role="option"]',hotkey:"k",manage:!0,closeOnRun:!0,highlight:!0,ai:"[data-ai]"},m=200,g=3600,y=40,v="cubic-bezier(.16, 1, .3, 1)",x=`\n:where([data-ascii-cmd-highlight]){position:absolute;left:0;top:0;z-index:-1;pointer-events:none;opacity:0;background:var(--ascii-cmd-highlight,color-mix(in oklab,currentColor 7%,transparent));transition:translate 240ms ${v},width 240ms ${v},height 240ms ${v},opacity 160ms ${v}}\n:where([data-ascii-cmd-highlight][data-on]){opacity:1}\n@media (prefers-reduced-motion:reduce){:where([data-ascii-cmd-highlight]){transition:none}}\n`;function k(k,w={}){const b={current:{...h,...w}},E=i(),$=()=>[...k.querySelectorAll(b.current.rows)],M=()=>k.querySelector(b.current.input),A=i();let L=b.current.open??!k.hasAttribute("hidden"),S=0,T=null,C=!1,O=0,H=null,R=[],W=null,D=0,P=0;const z=new WeakMap,K=()=>!!(b.current.reducedMotion??p());e("ascii-kit-command",x),"static"===getComputedStyle(k).position&&A.set(k,"position","relative"),A.set(k,"isolation","isolate");const j=document.createElement("div");j.setAttribute("aria-hidden","true"),j.dataset.asciiCmdHighlight="",b.current.highlight&&k.insertBefore(j,k.firstElementChild);const F=e=>{if(void 0===e.offsetParent)return f(k,e);let t=0,n=0;for(let r=e;r&&r!==k;r=r.offsetParent)t+=r.offsetLeft,n+=r.offsetTop;for(let r=e.parentElement;r&&r!==k;r=r.parentElement)t-=r.scrollLeft,n-=r.scrollTop;return{x:t,y:n,w:e.offsetWidth,h:e.offsetHeight}},N=e=>{const t=$()[S];if(!j.parentElement)return;if(!t||!L)return void delete j.dataset.on;const n=F(t),r=!e||void 0===j.dataset.on||K();r&&(j.style.transition="none"),j.style.translate=`${n.x}px ${n.y}px`,j.style.width=`${n.w}px`,j.style.height=`${n.h}px`,j.style.borderRadius=getComputedStyle(t).borderTopLeftRadius,j.dataset.on="",r&&(j.offsetWidth,j.style.removeProperty("transition"))};let V=null;const q=i();H=a({host:k,layer:"under",look:()=>({mark:"glyph",charset:" .:-=+*#%@",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:5,cellAspect:.62,glyphScale:.92,...b.current.look}),ink:()=>b.current.ink??"--ascii-ink-strong",kit:b,reducedMotion:()=>b.current.reducedMotion,resolution:2,onFail:()=>{H=null},paint:({pen:e,now:i,still:a,box:u})=>{if(e.setTransform(2,0,0,2,0,0),T){const n=T,r=(i-n.start)/(n.closing?m:260);if(!(r>=1||a)){const o=n.closing?1-1.02*c(r):1.04*c(r);return t(e,n.snap,n.blocks,n.order,o,(e,t)=>[(n.ox-e.x)*t*.9,(n.oy-e.y)*t*.9],n.closing?1:1-l((r-.72)/.28),.4),!0}T=null}if(!L||C)return!1;let f=!1;R=R.filter(n=>{const r=(i-n.start)/280;return(r>=.7||a)&&n.styles.restore(),r>=1||a||!k.contains(n.row)?(n.styles.restore(),!1):(f=!0,r>0&&t(e,n.snap,n.blocks,n.order,1.04*c(r),(e,t)=>[14*t,0],1-l((r-.7)/.3),.42),!0)});const p=$()[S];if(p&&!a&&p.matches(b.current.ai)){p!==W&&(W=p,D=i+160);const t=i-D,a=t>=0?t%g/1100:-1;if(a>=0&&a<1&&!R.some(e=>e.row===p))((e,t,i,a,c)=>{const l=H,u=`${t.textContent}|${i.x}|${i.y}|${i.w}`;if(V?.row!==t||V.key!==u){const e=n(t,l.box,l.canvas.clientWidth||k.offsetWidth,l.canvas.clientHeight||k.offsetHeight,2);V={row:t,key:u,snap:e,blocks:r(e,2)}}const f=i.x-y+(i.w+80)*(e=>e<.5?4*e**3:1-(-2*e+2)**3/2)(a),p=Math.floor(c/70);for(const t of V.blocks){const n=(t.x+2-f)/y;if(n<=-1||n>=1)continue;const r=1-n*n;d(t.x+p,t.y)>.35+.65*r||(e.globalAlpha=Math.min(1,1.6*r),e.drawImage(V.snap,2*t.x,2*t.y,2*o,2*s,t.x,t.y,o,s))}e.globalAlpha=1;const h=f-i.x;q.set(t,"mask-image",`linear-gradient(90deg, #000 ${h-y}px, transparent ${h-14}px, transparent ${h+14}px, #000 ${h+y}px)`)})(e,p,u(p),a,i),f=!0;else{if(q.restore(),f)return!0;P&&clearTimeout(P);const e=t>=0?g-t%g:-t;P=setTimeout(()=>{P=0,H?.kick()},Math.max(16,e))}}else W=null,q.restore();return f}}),H&&(k.dataset.gpu="");const B=(e=!0)=>{const t=$();if(S=t.length?Math.min(Math.max(0,S),t.length-1):0,N(e),!b.current.manage)return;t.forEach((e,t)=>e.setAttribute("aria-selected",String(t===S)));const n=M(),r=t[S]?.id;n&&r&&n.setAttribute("aria-activedescendant",r)},Z=()=>`inset(0 round ${getComputedStyle(k).borderTopLeftRadius||"0px"})`,G=()=>{const e=b.current.trigger,t=k.offsetWidth,n=k.offsetHeight;if(!e)return`inset(0 ${Math.max(0,t/2-40)}px ${Math.max(0,n-36)}px round 18px)`;const r=f(k,e);return`inset(${r.y}px ${t-r.x-r.w}px ${n-r.y-r.h}px ${r.x}px round ${r.h/2}px)`},I=e=>{const t=H;if(!t)return;const o=k.offsetWidth,s=k.offsetHeight,i=n(k,t.box,o,s,2),a=r(i,2),c=b.current.trigger,l=c?t.box(c):{x:o/2,y:0,w:0,h:0},u=l.x+l.w/2,d=l.y+l.h/2,f=Math.hypot(o,s)||1;T={snap:i,blocks:a,order:Float32Array.from(a,e=>Math.hypot(e.x-u,e.y-d)/f*.7+.3*e.seed),ox:u,oy:d,start:performance.now(),closing:e},t.kick()},U=e=>{if(e)for(const e of[...k.children])"CANVAS"===e.tagName&&void 0!==e.dataset.asciiKit||E.set(e,"opacity","0");else E.restore()},J=(e,t,n="none")=>"function"!=typeof k.animate?null:k.animate(e.map(e=>({clipPath:e})),{duration:t,easing:v,fill:n}),Q=()=>{O&&clearTimeout(O),O=0},X=(e=!0)=>{!L||C?(Q(),L=!0,C=!1,S=0,k.removeAttribute("hidden"),k.dataset.open="",b.current.trigger?.setAttribute("aria-expanded","true"),B(!1),(()=>{for(const e of $())z.set(e,F(e).y)})(),e&&M()?.focus({preventScroll:!0}),b.current.onOpenChange?.(!0),K()?H?.kick():(k.dataset.state="opening",J([G(),Z()],260),H&&(C=!0,U(!0),I(!1)),O=setTimeout(()=>{O=0,delete k.dataset.state,C=!1,U(!1),H?.kick()},143))):e&&M()?.focus({preventScroll:!0})},Y=()=>{if(!L)return;Q();const e=k.contains(document.activeElement),t=()=>{O=0,C=!1,L=!1,T=null,delete k.dataset.state,delete k.dataset.open,U(!1),N(!1);for(const e of R)e.styles.restore();R=[],q.restore(),V=null,k.setAttribute("hidden",""),b.current.trigger?.setAttribute("aria-expanded","false"),e&&b.current.trigger?.focus({preventScroll:!0}),H?.kick(),b.current.onOpenChange?.(!1)};if(K())return void t();C=!0,k.dataset.state="closing",H&&(I(!0),U(!0));const n=J([Z(),G()],m,"forwards"),r="function"==typeof k.animate?k.animate([{opacity:1},{opacity:1,offset:.4},{opacity:0}],{duration:m,fill:"forwards"}):null;O=setTimeout(()=>{t(),n?.cancel(),r?.cancel()},m)},_=e=>{const t=$().length;t&&(S=(Math.round(e)%t+t)%t,B(),H?.kick())},ee=(e=S)=>{const t=$()[e];if(!t||C)return;_(e),H?.field.pulse({element:t,strength:.6}),t.matches(b.current.ai)&&(W=t,D=performance.now()),t.dataset.run="",b.current.onRun?.(e,t);const n=()=>{delete t.dataset.run,b.current.closeOnRun&&Y()};K()?n():setTimeout(n,240)},te=e=>{if(!b.current.manage)return;const t=$().length;if("Escape"===e.key&&L)return e.preventDefault(),e.stopPropagation(),void Y();if(e.target!==M()&&!$().includes(e.target))return;const n="ArrowDown"===e.key?S+1:"ArrowUp"===e.key?S-1:"Home"===e.key?0:"End"===e.key?t-1:null;if(null!==n)return e.preventDefault(),void _(n);"Enter"===e.key&&(e.preventDefault(),ee())},ne=e=>{const t=e.target?.closest?.(b.current.rows);return t?$().indexOf(t):-1},re=e=>{if(!b.current.manage)return;const t=ne(e);t<0||t!==S&&_(t)},oe=e=>{if(!b.current.manage)return;const t=ne(e);t>=0&&ee(t)},se=()=>{b.current.manage&&(S=0,B(!1))},ie="function"==typeof MutationObserver?new MutationObserver(()=>{L&&(B(!1),(()=>{const e=H,t=$(),o=t.filter(e=>{const t=F(e).y,n=z.get(e);return z.set(e,t),void 0===n||Math.abs(n-t)>1});for(const e of R)t.includes(e.row)&&!o.includes(e.row)||e.styles.restore();if(R=R.filter(e=>t.includes(e.row)&&!o.includes(e.row)),!e||!e.live||e.still()||C||!L)return;const s=e.canvas.clientWidth||k.offsetWidth,a=e.canvas.clientHeight||k.offsetHeight,c=performance.now();o.forEach((t,o)=>{const l=n(t,e.box,s,a,2),u=r(l,2);if(!u.length)return;const d=Math.min(...u.map(e=>e.x)),f=Math.max(1,Math.max(...u.map(e=>e.x))-d),p=i();for(const e of[...t.children])p.set(e,"opacity","0");R.push({row:t,snap:l,blocks:u,order:Float32Array.from(u,e=>(e.x-d)/f*.72+.28*e.seed),start:c+28*o,styles:p})}),e.kick()})())}):null;ie?.observe(k,{childList:!0,subtree:!0});const ae="function"==typeof ResizeObserver?new ResizeObserver(()=>N(!1)):null;ae?.observe(k);const ce=()=>{L?Y():X(!0)},le=e=>{const t=b.current.hotkey;t&&e.key?.toLowerCase()===t.toLowerCase()&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),L?document.activeElement===M()?Y():M()?.focus():X(!0))},ue=e=>{if(!b.current.manage||!L||C)return;const t=e.target;k.contains(t)||b.current.trigger?.contains(t)||Y()};k.addEventListener("keydown",te),k.addEventListener("pointermove",re),k.addEventListener("click",oe),k.addEventListener("input",se);const de=b.current.trigger;return de?.addEventListener("click",ce),de?.setAttribute("aria-expanded",String(L)),de?.setAttribute("aria-haspopup","dialog"),document.addEventListener("keydown",le),document.addEventListener("pointerdown",ue),L?k.dataset.open="":k.setAttribute("hidden",""),B(),u(()=>H,b,()=>{B(),H?.refresh()},{open:X,close:Y,select:_,run:ee,toggle(){L?Y():X(!0)},get isOpen(){return L},get selected(){return S}},()=>{Q(),P&&clearTimeout(P),U(!1);for(const e of R)e.styles.restore();q.restore(),ie?.disconnect(),ae?.disconnect(),j.remove(),A.restore(),k.removeEventListener("keydown",te),k.removeEventListener("pointermove",re),k.removeEventListener("click",oe),k.removeEventListener("input",se),de?.removeEventListener("click",ce),document.removeEventListener("keydown",le),document.removeEventListener("pointerdown",ue),delete k.dataset.gpu,delete k.dataset.state})}var w=h;export{w as COMMAND_PALETTE_DEFAULTS,k as commandPalette};//# sourceMappingURL=chunk-4HWMQCAM.js.map
@@ -0,0 +1 @@
1
+ import{clamp as t,hash as e}from"./chunk-S7RZP2MT.js";function n(t){const e=()=>({image:t,width:t.naturalWidth,height:t.naturalHeight});return t.complete&&t.naturalWidth?Promise.resolve(e()):new Promise((n,o)=>{const a=()=>{r(),n(e())},i=()=>{r(),o(new Error(`Could not load ${t.src}`))},r=()=>{t.removeEventListener("load",a),t.removeEventListener("error",i)};t.addEventListener("load",a),t.addEventListener("error",i)})}function o(t,e=document.createElement("img")){return(t=>{try{return"undefined"!=typeof location&&new URL(t,location.href).origin!==location.origin}catch{return!1}})(t)&&!e.crossOrigin&&(e.crossOrigin="anonymous"),e.decoding="async",e.src=t,e}function a(t,e,n,o,a,i,r=.5,h=.5){if(a<=0||i<=0||!e.width||!e.height)return;const l=Math.max(a/e.width,i/e.height),c=a/l,d=i/l;t.drawImage(e.image,(e.width-c)*r,(e.height-d)*h,c,d,n,o,a,i)}function i(e,n,o=.08){const a=Math.min(1,420/Math.max(1,e.width,e.height)),i=document.createElement("canvas");i.width=Math.max(1,Math.round(e.width*a)),i.height=Math.max(1,Math.round(e.height*a));const r=i.getContext("2d",{willReadFrequently:!0});if(!r)return e;let h;r.drawImage(e.image,0,0,i.width,i.height);try{h=r.getImageData(0,0,i.width,i.height)}catch{return e}const l=h.data,c=new Uint32Array(256),d=l.length/4,s=t=>.2126*l[t]+.7152*l[t+1]+.0722*l[t+2];for(let t=0;t<l.length;t+=4)c[Math.round(s(t))]++;let u=0,f=255,g=0;for(let t=0;t<256;t++)if(g+=c[t],g>=.02*d){u=t;break}g=0;for(let t=255;t>=0;t--)if(g+=c[t],g>=.02*d){f=t;break}const m=Math.max(1,f-u);for(let e=0;e<l.length;e+=4){let a=t((s(e)-u)/m);n&&(a=1-a),l[e]=l[e+1]=l[e+2]=Math.round(255*(o+(1-o)*a)),l[e+3]=255}return r.putImageData(h,0,0),{image:i,width:i.width,height:i.height}}var r={strong:1,text:.82,meta:.55,tile:.42,icon:.62},h=new Set(["IMG","SVG","svg","VIDEO","PICTURE"]),l=t=>[...t.children].flatMap(t=>h.has(t.tagName)?[t]:[t,...l(t)]);function c(e,n,o,a){const i=document.createElement("canvas");i.width=Math.max(2,Math.round(2*n)),i.height=Math.max(2,Math.round(2*o));const c=[],d=i.getContext("2d");if(!d)return{canvas:i,rects:c};d.scale(2,2),d.fillStyle="#000",d.fillRect(0,0,n,o);const s=a(e),u=e.getBoundingClientRect(),f=u.width/(e.offsetWidth||u.width||1)||1,g=t=>{for(let n=t;n&&n!==e.parentElement;n=n.parentElement){const t=n.dataset?.paint;if(t&&void 0!==r[t])return r[t]}return parseFloat(t?getComputedStyle(t).fontWeight:"400")>=500?1:.7},m=e=>{const n=Math.round(255*t(e));return`rgb(${n} ${n} ${n})`},w=l(e),p=[e,...w].filter(t=>{const e=t.dataset?.paint;return"tile"===e||"icon"===e||!e&&h.has(t.tagName)&&!t.closest("[data-paint]")});for(const t of p){const e=a(t);if(e.w<=0||e.h<=0)continue;const n=t.dataset?.paint;d.fillStyle=m("icon"===n?r.icon:r.tile),d.beginPath(),"icon"===n||"svg"===t.tagName.toLowerCase()?d.arc(e.x+e.w/2,e.y+e.h/2,.4*Math.min(e.w,e.h),0,2*Math.PI):d.roundRect(e.x,e.y,e.w,e.h,Math.min(parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,e.h/2)),d.fill(),c.push(e)}const y=document.createTreeWalker(e,4),x=document.createRange();d.textBaseline="middle";for(let t=y.nextNode();t;t=y.nextNode()){const e=t.parentElement;if(!e||e.closest('[data-paint="none"]'))continue;const n=getComputedStyle(e);d.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,d.fillStyle=m(g(e)),d.shadowColor=d.fillStyle,d.shadowBlur=4;for(const e of t.data.matchAll(/\S+/g)){x.setStart(t,e.index),x.setEnd(t,e.index+e[0].length);const n=x.getClientRects()[0];if(!n)continue;const o={x:s.x+(n.left-u.left)/f,y:s.y+(n.top-u.top)/f,w:n.width/f,h:n.height/f};d.fillText(e[0],o.x,o.y+o.h/2),c.push(o)}}return d.shadowBlur=0,x.detach?.(),{canvas:i,rects:c}}function d(t){const n=new Set,o=[];for(const a of t)for(let t=6*Math.floor((a.y-2)/6);t<a.y+a.h+2;t+=6)for(let i=4*Math.floor((a.x-2)/4);i<a.x+a.w+2;i+=4){const a=`${i},${t}`;n.has(a)||(n.add(a),o.push({x:i,y:t,seed:e(i,t)}))}return o}function s(t,e,n,o,a,i,r=1,h=.32){for(let l=0;l<n.length;l++){const c=n[l],d=(a-o[l]*(1-h))/h;if(d<=0)continue;const s=d>=1?0:1-d;let u=c.x,f=c.y;if(s>0){const[t,e]=i(c,s);u+=t,f+=e}t.globalAlpha=r*(1-s*s),t.drawImage(e,2*c.x,2*c.y,8,12,u,f,4,6)}t.globalAlpha=1}function u(t,e){if("undefined"==typeof document||document.getElementById(t))return;const n=document.createElement("style");n.setAttribute("id",t),n.textContent=e,(document.head??document.documentElement).appendChild(n)}export{d as blocksOf,s as drawBlocks,a as drawCover,o as imageFor,n as imageReady,u as injectStyle,c as snapshot,i as toneOf};//# sourceMappingURL=chunk-4OT66HSZ.js.map
@@ -0,0 +1 @@
1
+ import{injectStyle as e,imageReady as t,imageFor as n,drawCover as a}from"./chunk-4OT66HSZ.js";import{srOnly as o,mountSurface as r,handle as i,isDark as l,clamp as s}from"./chunk-S7RZP2MT.js";var c={maxBytes:10485760,develop:900};function d(e,t,n=Math.min(2,"number"==typeof devicePixelRatio&&devicePixelRatio>0?devicePixelRatio:1)){const a=Math.max(2,Math.round(6*n)),o=Math.max(2,Math.round(1*a)),r=(e,t)=>{const a=Math.floor(e*n/t);for(let e=a;e>1;e--){const o=e*t/n;if(Math.abs(o-Math.round(o))<.01||e<a-8)return{n:e,css:Math.round(o)}}return{n:1,css:Math.round(t/n)}},i=r(e,o),l=r(t,a);return{cols:i.n,rows:l.n,w:i.css,h:l.css,cw:o/n,ch:a/n}}function p(e,t,n,a){const{cols:o,rows:r}=t,i=e.createImageData(2*o,2*r),l=i.data,{tone:s,glow:c=0,phase:d=0,near:p=null}=a,h=Math.max(1,n/t.cw),u=Math.max(1,n/t.ch),m=o-2,f=r-2,g=Math.max(0,m-1-2*h),x=Math.max(0,f-1-2*u),v=Math.PI/4*(h+u),y=.45*Math.hypot(o,r);for(let e=0;e<r;e++)for(let t=0;t<o;t++){const n=Math.max(1+h-t,0,t-(m-h)),a=Math.max(1+u-e,0,e-(f-u));let r;if(n>0&&a>0){const e=Math.hypot(n/h,a/u);r=Math.hypot(n,a)*(1-1/e)}else r=-Math.min(t-1,m-t,e-1,f-e);let i=0;if(Math.abs(r)<.5){if(i=s,c>0){const o=t>m-h,r=e>f-u,l=t<1+h,p=e<1+u,y=(e,t)=>Math.atan2(e,t)/(Math.PI/2);let M;M=!p||l||o?p&&o?g+v*y(n/h,a/u):!o||p||r?r&&o?g+v+x+v*y(a/u,n/h):r&&!l?g+2*v+x+(m-h-t):r&&l?2*g+2*v+x+v*y(n/h,a/u):l&&!p?2*g+3*v+x+(f-u-e):2*g+3*v+2*x+v*y(a/u,n/h):g+v+(e-(1+u)):t-(1+h);const b=((M-d)%9+9)%9;i=s+c*(.2+.32*Math.max(0,1-Math.abs(b-4.5)/2.2))}}else if(c>0&&r<-.5&&r>-3.5){i=c*(1-(-r-.5)/3)**1.6*(.1+.32*(p?Math.max(0,1-Math.hypot(t-p.x,e-p.y)/y):.4))}const M=Math.round(255*Math.min(1,i));for(let n=0;n<4;n++){const a=4*((2*e+(n>>1))*o*2+2*t+(1&n));l[a]=l[a+1]=l[a+2]=M,l[a+3]=255}}e.putImageData(i,0,0)}function h(h,u={}){const m={current:{...c,...u}};let f="empty",g=null,x="",v="",y="image",M=0,b=0,w=!1,k=0,C=0,E=0,L=0,R=null,S=null,z=null,$=null,U=null;const j=o("",!0),O=["left","top","width","height"],P=()=>{const e=$?.canvas;if(!e||!h.offsetWidth)return null;const t="empty"===f?d(h.offsetWidth,h.offsetHeight):null,n=t?[`${Math.round((h.offsetWidth-t.w)/2)}px`,`${Math.round((h.offsetHeight-t.h)/2)}px`,`${t.w}px`,`${t.h}px`]:["0px","0px","100%","100%"];let a=!1;return O.forEach((t,o)=>{e.style[t]!==n[o]&&(e.style[t]=n[o],a=!0)}),U=t,a?($?.field.resize(),$?.kick(),null):t},D=document.createElement("input"),I=[j,D];let B=null;const T=!h.children.length;$=r({host:h,layer:"under",look:()=>"empty"===f?{mark:"glyph",charset:" .:+*#",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:6,cellAspect:1,glyphScale:.9,...m.current.look}:{blend:"coarse",mark:"glyph",charset:" .:-=+*#%@",font:'"Geist", Arial, sans-serif',fontWeight:500,cellSize:6,cellAspect:.8,glyphScale:.8,background:l(h)?"transparent":"#0b0b0a",color:"source",saturation:1.15,contrast:1.15,levels:"auto",brightness:.08,hover:"trail",trail:{strength:.6,radius:.3},...m.current.look},ink:e=>m.current.ink??`var(--ascii-ink, ${e?"#7a7872":"#76746e"})`,kit:m,reducedMotion:()=>m.current.reducedMotion,resolution:(e,t)=>"empty"===f&&U?[2*U.cols,2*U.rows]:[Math.max(1,Math.round(e)),Math.max(1,Math.round(t))],onFail:()=>{$=null,x&&N(x)},paint:({pen:e,w:t,h:n,now:o,still:r})=>{if("empty"!==f){if(!g)return!1;const i=r?1:s((o-M)/m.current.develop),l=1-(1-i)**2;return a(e,g,0,0,t,n),"developing"===f&&l<1&&function(e,t,n,a,o){const r=Math.max(Math.hypot(a.x,a.y),Math.hypot(t-a.x,a.y),Math.hypot(a.x,n-a.y),Math.hypot(t-a.x,n-a.y)),i=Math.max(24,.22*Math.min(t,n)),l=o*(r+i),s=Math.max(0,l-i),c=e.createRadialGradient(a.x,a.y,s,a.x,a.y,Math.max(s+1,l));c.addColorStop(0,"rgb(0 0 0 / 0)"),c.addColorStop(1,"rgb(0 0 0 / 1)"),e.globalCompositeOperation="source-over",e.fillStyle=c,e.fillRect(0,0,t,n);const d=e.createRadialGradient(a.x,a.y,s,a.x,a.y,Math.max(s+1,l)),p=1-o*o;d.addColorStop(0,"rgb(255 255 255 / 0)"),d.addColorStop(.55,`rgb(255 255 255 / ${.5*p})`),d.addColorStop(1,"rgb(255 255 255 / 0)"),e.globalCompositeOperation="lighter",e.fillStyle=d,e.fillRect(0,0,t,n),e.globalCompositeOperation="source-over"}(e,t,n,z??{x:t/2,y:n/2},l),i>=1&&"developing"===f&&G(),i<1}const i=E?Math.min(64,o-E):16;E=o;const l=w?1:0;C=r?l:C+(l-C)*(1-Math.exp(-i/90)),!r&&C>.004&&(L+=i/1e3*14);const c=Math.max(4,(parseFloat(getComputedStyle(h).borderTopLeftRadius)||16)-6),d=P();if(d){const t=$.canvas.getBoundingClientRect(),n=S&&t.width?{x:(S.x-t.left)/t.width*d.cols,y:(S.y-t.top)/t.height*d.rows}:null;p(e,d,c,{tone:.3,glow:C,phase:L,near:n})}const u=!r&&(w||Math.abs(l-C)>.004);return u||(E=0),u}});const W=e=>{const t=f;f=e,h.dataset.state=e,"empty"===t!=("empty"===e)&&(P(),$?.refresh()),t!==e&&m.current.onState?.(e,"empty"===e?"":y)},G=()=>{W("done"),j.textContent=`${y} ready`,g&&m.current.onImage?.({file:R,src:x,width:g.width,height:g.height})};function N(e){B??(B=Object.assign(document.createElement("img"),{className:"ascii-drop-img",alt:""})),B.src=e,B.parentElement!==h&&(h.prepend(B),I.push(B))}const A=async(e,a=null,o=null)=>{const r=++b;let i;z=o,v&&URL.revokeObjectURL(v),v="string"==typeof e?"":URL.createObjectURL(e),x=v||e,R=a??("undefined"!=typeof File&&e instanceof File?e:null),y=R?.name??("string"==typeof e&&e.split("/").pop()?.split("?")[0]||"image"),j.textContent=`Converting ${y}`;try{i=await t(n(x))}catch{return void(r===b&&(j.textContent=`Could not load ${y}`))}if(r===b){if(g=i,!$)return N(x),W("done"),void G();M=performance.now(),W($.still()?"done":"developing"),$.field.pulse({strength:1}),$.kick(),"done"===f&&G()}},F=(e,t=null)=>{const n=t=>{j.textContent=t,m.current.onError?.(t,e)};return e.type.startsWith("image/")?e.size>m.current.maxBytes?n(`${e.name} is over ${Math.round(m.current.maxBytes/1024/1024)} MB.`):void A(e,e,t):n(`${e.name} isn’t an image.`)},H=()=>{b++,g=null,x="",R=null,v&&URL.revokeObjectURL(v),v="",B?.remove(),W("empty"),j.textContent="",$?.kick()},X=()=>D.click(),Y=e=>new Promise(t=>{const n=$?.field;if(!n||!g||"done"!==f)return void t(null);const a=document.createElement("canvas");a.width=n.canvas.width,a.height=n.canvas.height;const o=a.getContext("2d");o?(o.fillStyle=getComputedStyle(h).backgroundColor||"#000",o.fillRect(0,0,a.width,a.height),n.redraw(),o.drawImage(n.canvas,0,0),a.toBlob(n=>{if(n){const t=document.createElement("a");t.href=URL.createObjectURL(n),t.download=e??m.current.filename??`${y.replace(/\.[^.]+$/,"")}-ascii.png`,t.click(),setTimeout(()=>URL.revokeObjectURL(t.href),1e3)}t(n)},"image/png")):t(null)}),Z=()=>{E=0,$?.kick()},J=e=>{e.preventDefault(),k++,S={x:e.clientX,y:e.clientY},w||(w=!0,h.dataset.over="",Z())},q=e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),S={x:e.clientX,y:e.clientY}},K=()=>{k=Math.max(0,k-1),!k&&w&&(w=!1,S=null,delete h.dataset.over,Z())},Q=e=>{e.preventDefault(),k=0,w=!1,S=null,delete h.dataset.over;const t=h.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top};$?.field.pulse({...n,strength:1});const a=e.dataTransfer?.files?.[0];a?F(a,n):Z()},V=e=>{const t=e.target?.closest?.("[data-dropzone]")?.getAttribute("data-dropzone");"pick"===t?X():"clear"===t?H():"download"===t&&Y()},_=()=>{const e=D.files?.[0];D.value="",e&&F(e)};e("ascii-kit-dropzone",'\n:where(.ascii-drop-empty){position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:100%;min-height:inherit;padding:24px;box-sizing:border-box;text-align:center}\n:where([data-ascii-dropzone]:not([data-state="empty"])) :where(.ascii-drop-empty){display:none}\n:where(.ascii-drop-title){margin:0;font-weight:500}\n:where(.ascii-drop-hint){margin:0;font-size:14px;opacity:.65}\n:where(.ascii-drop-pick){margin-top:8px;height:34px;padding:0 14px;border:0;border-radius:999px;background:currentColor;font:inherit;font-size:14px;cursor:pointer}\n:where(.ascii-drop-pick) > span{color:Canvas}\n:where(.ascii-drop-img){position:absolute;inset:0;width:100%;height:100%;object-fit:cover}\n'),h.dataset.asciiDropzone="",D.type="file",D.accept="image/*",D.tabIndex=-1,D.hidden=!0,D.setAttribute("aria-hidden","true"),T&&I.push(function(){const e=document.createElement("div"),t=document.createElement("p"),n=document.createElement("p"),a=document.createElement("button"),o=document.createElement("span");return e.className="ascii-drop-empty",t.className="ascii-drop-title",t.textContent="Drop an image",n.className="ascii-drop-hint",n.textContent="PNG, JPG or WebP",a.type="button",a.className="ascii-drop-pick",a.dataset.dropzone="pick",o.textContent="Choose file",a.appendChild(o),e.append(t,n,a),e}());for(const e of I)h.appendChild(e);return W("empty"),h.addEventListener("dragenter",J),h.addEventListener("dragover",q),h.addEventListener("dragleave",K),h.addEventListener("drop",Q),h.addEventListener("click",V),D.addEventListener("change",_),i(()=>$,m,()=>$?.refresh(),{setImage:e=>A(e),clear:H,pick:X,download:Y,get state(){return f}},()=>{b++,v&&URL.revokeObjectURL(v),h.removeEventListener("dragenter",J),h.removeEventListener("dragover",q),h.removeEventListener("dragleave",K),h.removeEventListener("drop",Q),h.removeEventListener("click",V),D.removeEventListener("change",_),I.forEach(e=>e.remove()),delete h.dataset.asciiDropzone,delete h.dataset.state,delete h.dataset.over})}var u=c;export{u as DROPZONE_DEFAULTS,h as dropzone,p as paintRing,d as ringGrid};//# sourceMappingURL=chunk-4QHFEMFS.js.map
@@ -0,0 +1 @@
1
+ import{scenePreset as e,FIELD_GRAPHITE as t,narrow as r}from"./chunk-C3C7AYKL.js";var l=e({id:"swell",name:"Swell",description:"A fine grid that swells in slow rolling waves, quiet in the middle. Dots by default, or characters.",cellSize:10,opacity:.6,scene:"swell",mark:"dot",charset:" .:-=+*#",hover:"lantern",graphite:t,tune:()=>({scale:r()?1.5:1,contrast:.62,brightness:-.19,blend:"auto",lantern:{radius:.12,strength:.5,trail:1,follow:8},trail:{strength:.7,radius:.35}})});export{l as swell};//# sourceMappingURL=chunk-4ZQFDFEH.js.map
@@ -0,0 +1 @@
1
+ import{imageFor as e,drawCover as t,injectStyle as a,imageReady as n,toneOf as r}from"./chunk-4OT66HSZ.js";import{styleKeeper as i,clamp as o,mountSurface as c,smoothstep as s,handle as l,prefersReduced as p}from"./chunk-S7RZP2MT.js";var d=e=>"string"==typeof e?{src:e}:e;function u(u,h){const m={current:{open:0,duration:420,label:"Images",...h}},f=i(),v=m.current.images.map(d);let x=o(Math.round(m.current.open),0,Math.max(0,v.length-1)),b=0,g=0;const w=v.map((e,t)=>({x:t===x?1:0,v:0})),y=v.map(()=>null),k=v.map(()=>null);let E=null;const A=v.map(t=>{const a=document.createElement("button");a.type="button",a.className="ascii-acc-panel",a.setAttribute("aria-label",[t.title??t.alt,t.meta].filter(Boolean).join(", ")||t.src);const n=e(t.src);if(n.className="ascii-acc-photo",n.alt="",n.draggable=!1,t.focus&&n.style.setProperty("object-position",`${100*t.focus.x}% ${100*t.focus.y}%`),a.appendChild(n),t.title||t.meta){const e=document.createElement("span");e.className="ascii-acc-caption",e.setAttribute("aria-hidden","true");for(const[a,n]of[["ascii-acc-title",t.title],["ascii-acc-meta",t.meta]]){if(!n)continue;const t=document.createElement("span");t.className=a,t.textContent=n,e.appendChild(t)}a.appendChild(e)}return a});function M(e,t){const a=b?Math.min(.064,(e-b)/1e3):1/60;b=e;const n=5/(Math.max(1,m.current.duration)/1e3),r=Math.max(1,Math.ceil(240*a)),i=a/r;let o=!1;return w.forEach((e,a)=>{const c=a===x?1:0;t&&(e.x=c,e.v=0);for(let t=0;t<r&&(e.x!==c||e.v);t++)e.v+=(-n*n*(e.x-c)-2*n*e.v)*i,e.x+=e.v*i;Math.abs(e.x-c)<.001&&Math.abs(e.v)<.01?(e.x=c,e.v=0):o=!0,L(A[a],e.x)}),o||(b=0),o}function L(e,t){const a=e.style;a.setProperty("--ascii-acc-open",t.toFixed(4)),a.setProperty("--ascii-acc-photo",(E?s(.15,.75,t):.45+.55*t).toFixed(3)),a.setProperty("--ascii-acc-caption",s(.6,1,t).toFixed(3))}E=c({host:u,layer:"under",look:()=>({blend:"coarse",mark:"glyph",charset:" .:-=+*#%@",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:6,cellAspect:.62,glyphScale:.94,hover:"trail",trail:{strength:.5,radius:.25},...m.current.look}),ink:()=>m.current.ink??"--ascii-ink-strong",kit:m,reducedMotion:()=>m.current.reducedMotion,onFail:()=>{E=null,delete u.dataset.asciiField},onTheme:()=>{y.forEach((e,t)=>{k[t]=e&&E?r(e,!E.dark()):null}),E?.kick()},paint:({pen:e,still:a,now:n,box:r})=>{const i=M(n,a);return A.forEach((a,n)=>{const i=k[n],o=w[n].x,c=1-s(.45,.95,o);if(!i||c<=0)return;const l=r(a),p=parseFloat(getComputedStyle(a).borderTopLeftRadius)||0,d=1.04-.04*o;e.save(),e.beginPath(),e.roundRect(l.x,l.y,l.w,l.h,p),e.clip(),e.globalAlpha=c,t(e,i,l.x-l.w*(d-1)/2,l.y-l.h*(d-1)/2,l.w*d,l.h*d,v[n].focus?.x,v[n].focus?.y),e.restore()}),i}});const F=()=>{A.forEach((e,t)=>{e.setAttribute("aria-expanded",String(t===x)),e.tabIndex=t===x?0:-1})},S=(e,t=!1)=>{e=o(Math.round(e),0,A.length-1),t&&A[e]?.focus(),e!==x&&(x=e,F(),m.current.onChange?.(e),(()=>{if(E)return void E.kick();if(g||"function"!=typeof requestAnimationFrame)return void(g||M(performance.now(),!0));const e=t=>{g=M(t,!!(m.current.reducedMotion??p()))?requestAnimationFrame(e):0};g=requestAnimationFrame(e)})())};let C=0,T=0,P=0,j=0,q=0;const N=()=>{C&&clearTimeout(C),C=0},R=A.map((e,t)=>{const a=e=>{if("mouse"!==e.pointerType)return;const a=e.timeStamp||performance.now(),n=Math.max(1,a-P);if(j=P&&n<100?.5*j+Math.abs(e.clientX-T)/n*.5:0,T=e.clientX,P=a,q!==t&&N(),q=t,t!==x)return j<.3?(N(),void S(t)):void(C||(C=setTimeout(()=>{C=0,S(q)},90)));N()},n=()=>{N(),S(t)},r=()=>{e.matches(":focus-visible")&&S(t)},i=e=>{const a={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key],n="Home"===e.key?0:"End"===e.key?A.length-1:void 0!==a?(t+a+A.length)%A.length:null;null!==n&&(e.preventDefault(),S(n,!0))};return e.addEventListener("pointermove",a),e.addEventListener("pointerdown",n),e.addEventListener("click",n),e.addEventListener("focus",r),e.addEventListener("keydown",i),()=>{e.removeEventListener("pointermove",a),e.removeEventListener("pointerdown",n),e.removeEventListener("click",n),e.removeEventListener("focus",r),e.removeEventListener("keydown",i)}}),z=()=>{N(),P=0};u.addEventListener("pointerleave",z),a("ascii-kit-accordion",'\n:where([data-ascii-accordion]){display:flex;gap:6px}\n:where(.ascii-acc-panel){position:relative;flex:calc(1 + 3.2 * var(--ascii-acc-open, 0)) 1 0;min-width:0;margin:0;padding:0;border:0;border-radius:12px;overflow:hidden;background:transparent;color:#fff;font:inherit;text-align:left;cursor:pointer;-webkit-tap-highlight-color:transparent}\n:where(.ascii-acc-panel[aria-expanded="true"]){cursor:default}\n:where(.ascii-acc-photo){position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:var(--ascii-acc-photo, 0);scale:calc(1.04 - .04 * var(--ascii-acc-open, 0))}\n:where(.ascii-acc-caption){position:absolute;inset:auto 0 0;display:flex;color:#fff;flex-direction:column;gap:2px;padding:28px 12px 11px;background:linear-gradient(to top, rgb(0 0 0 / .62), transparent);white-space:nowrap;opacity:var(--ascii-acc-caption, 0);translate:0 calc(6px - 6px * var(--ascii-acc-caption, 0))}\n:where(.ascii-acc-title){font-size:15px;font-weight:500}\n:where(.ascii-acc-meta){font-size:14px;opacity:.8}\n'),u.dataset.asciiAccordion="",E&&(u.dataset.asciiField="");const D=u.getAttribute("role"),H=u.getAttribute("aria-label");return D||u.setAttribute("role","group"),H||u.setAttribute("aria-label",m.current.label),A.forEach((e,t)=>{L(e,w[t].x),u.appendChild(e)}),F(),A.forEach((e,t)=>{const a=e.querySelector("img");a&&n(a).then(e=>{y[t]=e,k[t]=E?r(e,!E.dark()):null,E?.kick()},()=>{})}),l(()=>E,m,e=>{H||u.setAttribute("aria-label",e.label),E?.refresh()},{select:S,get open(){return x}},()=>{R.forEach(e=>e()),N(),g&&cancelAnimationFrame(g),u.removeEventListener("pointerleave",z),A.forEach(e=>e.remove()),delete u.dataset.asciiAccordion,delete u.dataset.asciiField,D||u.removeAttribute("role"),H||u.removeAttribute("aria-label"),f.restore()})}export{u as accordion};//# sourceMappingURL=chunk-5BEBNKYM.js.map
@@ -0,0 +1 @@
1
+ import{clamp as e,hash as t,styleKeeper as r,mountSurface as o,handle as n,prefersReduced as i}from"./chunk-S7RZP2MT.js";var a={kind:"heart",icon:"svg",manage:!0,outset:40,layer:"under"},l=t=>1-(1-e(t))**3,s=e=>e>=1?1:1-Math.exp(-5*e)*Math.cos(9*e);function c(e,t,r,o,n){if(e.beginPath(),"heart"===t){const t=n/29;for(let n=0;n<=56;n++){const i=n/56*Math.PI*2,a=16*Math.sin(i)**3,l=-(13*Math.cos(i)-5*Math.cos(2*i)-2*Math.cos(3*i)-Math.cos(4*i));0===n?e.moveTo(r+a*t,o+(l-2.5)*t):e.lineTo(r+a*t,o+(l-2.5)*t)}}else{const t=.7*n,i=o-n/2,a=r-t/2,l=.12*n;e.moveTo(a,i+l),e.arcTo(a,i,a+l,i,l),e.lineTo(a+t-l,i),e.arcTo(a+t,i,a+t,i+l,l),e.lineTo(a+t,o+n/2),e.lineTo(r,o+n/2-.27*n),e.lineTo(a,o+n/2)}e.closePath()}function u(e,t,r,o,n,i){const a=e.createRadialGradient(r,o-.1*n,0,r,o,.62*n);a.addColorStop(0,"#fff"),a.addColorStop(.7,"#e6e6e6"),a.addColorStop(1,"#8c8c8c"),e.globalAlpha=i,e.fillStyle=a,e.shadowColor="#bbb",e.shadowBlur=Math.max(2,.08*n),c(e,t,r,o,n),e.fill(),e.shadowBlur=0,e.globalAlpha=1}function d(r,o,n,i,a){const d=n.x+n.w/2,h=n.y+n.h/2,f=n.h,p=1.45*f,k=s(i/.3),g=(e=>e<.5?4*e**3:1-(-2*e+2)**3/2)(e((i-.42)/.3)),b=g>0?p+(f-p)*g:.7*f+(p-.7*f)*k,M=e((i-.04)/.46);M>0&&M<1&&(r.strokeStyle=(t=>{const r=Math.round(255*e(t));return`rgb(${r} ${r} ${r})`})(.8*(1-M)**1.4),r.lineWidth=2.4-1.2*M,r.lineJoin="round",c(r,o,d,h,f*(1.2+.5*l(M))),r.stroke());r.fillStyle="#fff";for(let e=0;e<7;e++){const o=(i-.1-.05*t(e,a))/.5;if(o<=0||o>=1)continue;const n=-Math.PI/2+(e-3)/7*Math.PI*1.7+.3*(t(a+1,e)-.5),s=f*(.75+(.55+.35*t(e,a+2))*l(o)),c=1.8*(1-.6*o);r.globalAlpha=1-o*o,r.beginPath(),r.arc(d+Math.cos(n)*s*1.15,h+Math.sin(n)*s*.85,c,0,2*Math.PI),r.fill()}r.globalAlpha=1,u(r,o,d,h,b,1-e((i-.72)/.28))}function h(e,s={}){const c={current:{...a,...s}},h=r(),f=()=>e.querySelector(c.current.icon)??e,p=()=>!!(c.current.reducedMotion??i());let k="true"===e.getAttribute("aria-pressed"),g=[],b=[],M=null;M=o({host:e,outset:c.current.outset,layer:c.current.layer,look:()=>({mark:"glyph",charset:" .:-=+*#%@",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:4,cellAspect:.62,glyphScale:.92,...c.current.look}),ink:e=>c.current.ink??("heart"===c.current.kind?`var(--ascii-like, ${e?"#ff6b70":"#e5484d"})`:"--ascii-ink-strong"),kit:c,reducedMotion:()=>c.current.reducedMotion,onFail:()=>{M=null},paint:({pen:e,w:r,now:o,box:n})=>{const i=n(f()),a=c.current.kind;g=g.filter(r=>{const n=(o-r.start)/("burst"===r.kind?560:300);if(n>=1)return!1;if(n<0)return!0;if(e.save(),"burst"===r.kind)d(e,a,i,n,r.seed);else{const r=i.x+i.w/2,o=i.y+i.h/2+3*l(n),s=i.h*(1+.12*l(n));u(e,a,r,o,s,(1-n)**1.4),e.fillStyle="#000";for(let i=o-s/2;i<o+s/2;i+=3)for(let o=r-s/2;o<r+s/2;o+=2)t(o,i)<1.15*n&&e.fillRect(o,i,2,3)}return e.restore(),!0});const s=c.current.limit;if(s&&g.length){const t=n(s),o=t.y+t.h,i=e.createLinearGradient(0,o-2,0,o+8);i.addColorStop(0,"#000"),i.addColorStop(1,"rgb(0 0 0 / 0)"),e.fillStyle="#000",e.fillRect(0,0,r,o-2),e.fillStyle=i,e.fillRect(0,o-2,r,10)}return g.length>0}});const m=()=>{b.forEach(clearTimeout),b=[]},y=()=>{if(m(),h.restore(),!M||p())return;const t=performance.now(),r=f();g=g.filter(e=>"undo"!==e.kind),g.push({kind:"burst",start:t,seed:Math.floor(t)%97}),r!==e&&h.set(r,"opacity","0"),b.push(setTimeout(()=>{h.restore(),r!==e&&"function"==typeof r.animate&&r.animate({opacity:["0","1"],scale:[".7","1"]},{duration:220,easing:"cubic-bezier(.34, 1.42, .64, 1)"})},347.2)),M.kick()},S=()=>{m(),h.restore(),M&&!p()&&(g=g.filter(e=>"burst"!==e.kind),g.push({kind:"undo",start:performance.now(),seed:0}),M.kick())},T=(t=!k)=>{k=t,e.setAttribute("aria-pressed",String(k)),k?y():S()},v=()=>{c.current.manage&&(T(),c.current.onChange?.(k))};return!e.hasAttribute("aria-pressed")&&c.current.manage&&e.setAttribute("aria-pressed","false"),e.addEventListener("click",v),n(()=>M,c,()=>M?.refresh(),{burst:y,undo:S,toggle:T,get pressed(){return k}},()=>{m(),h.restore(),e.removeEventListener("click",v)})}var f=a;export{f as LIKE_BURST_DEFAULTS,d as burstFrame,h as likeBurst,s as springOut};//# sourceMappingURL=chunk-5I4IZTL5.js.map
@@ -0,0 +1 @@
1
+ import{parseColor as t}from"./chunk-ZCHGV2CV.js";import{mountCanvas as e}from"./chunk-BR6ZNJZW.js";function o(e,o,n,c,r={x:.5,y:.5},l={}){const{fontSize:s=14,chars:a=". · ○ ◎ ●",accentColor:i,color:h,rings:f=5,speed:M=1,sharpness:g=4,lightMode:p=!1}=l,m=i??(p?"#007a5e":"#00ffcc");e.clearRect(0,0,o,n),e.textBaseline="middle",e.textAlign="center";const u=o*r.x,d=n*r.y,x=1.6*Math.sqrt(u*u+d*d)+.2*Math.sqrt(o*o+n*n);let $=255,b=255,S=255;if(p&&($=55,b=55,S=55),h){const e=t(h);e&&($=e.r,b=e.g,S=e.b)}let z=0,C=255,k=204;const q=t(m);q&&(z=q.r,C=q.g,k=q.b);const y=a.replace(/ /g,"").split("");if(0===y.length)return;const R=Math.ceil(o/s),Z=Math.ceil(n/s);for(let t=0;t<Z;t++)for(let o=0;o<R;o++){const n=o*s+.5*s,r=t*s+.5*s,l=n-u,a=r-d,i=Math.sqrt(l*l+a*a)/x;let h=0;for(let t=0;t<f;t++){const e=(c*M*.38+t/f)%1,o=Math.abs(i-e),n=Math.max(0,1-o*x/(s*(12-g)));h+=Math.cos(n*Math.PI*.5)*n}if(h=Math.min(1,h),h<.02)continue;const m=h>.6;e.font=`${s}px monospace`;const q=Math.floor(h*(y.length-1)),R=y[Math.min(q,y.length-1)],Z=p?.88*h:.22*h;e.fillStyle=m?`rgba(${z},${C},${k},${Math.min(p?.95:.4,.55*h)})`:`rgba(${$},${b},${S},${Z})`,e.fillText(R,n,r)}e.textAlign="left"}var n={id:"pulse",name:"Pulse",description:"Rings of characters ripple out from the cursor.",cellSize:14,speed:1,cursor:!0,mount:t=>e(t,(t,e,n,c,r,l)=>o(t,e,n,c,r,{fontSize:l.fontSize,chars:l.chars,lightMode:l.lightMode,color:l.ink,accentColor:l.accent}))};export{n as pulse,o as renderPulseBackground};//# sourceMappingURL=chunk-5QE6UMXN.js.map
@@ -0,0 +1 @@
1
+ import{parseColor as t,hash2 as e}from"./chunk-ZCHGV2CV.js";import{mountCanvas as o}from"./chunk-BR6ZNJZW.js";function n(o,n,c,r,s={x:.5,y:.5},l={}){const{fontSize:a=14,chars:i=" . · * + ° ★",accentColor:h,color:f,speed:d=1,count:g=180,lightMode:m=!1}=l,p=h??(m?"#6b8700":"#d4ff00");o.clearRect(0,0,n,c),o.textBaseline="middle",o.textAlign="center";const M=n*(.2+.6*s.x),x=c*(.2+.6*s.y),$=.65*Math.sqrt(n*n+c*c);let u=255,S=255,b=255;if(m&&(u=55,S=55,b=55),f){const e=t(f);e&&(u=e.r,S=e.g,b=e.b)}let k=212,z=255,C=0;const y=t(p);y&&(k=y.r,z=y.g,C=y.b);const A=i.replace(/ /g,"").split("");if(0!==A.length){for(let t=0;t<g;t++){const s=e(17*t,3)*Math.PI*2,l=(r*(.15+.85*e(31*t,7))*d*.22+e(13*t,11))%1,i=M+Math.cos(s)*l*$,h=x+Math.sin(s)*l*$;if(i<-20||i>n+20||h<-20||h>c+20)continue;const f=Math.max(6,a*(.4+.9*l));o.font=`${f}px monospace`;const g=A[Math.min(A.length-1,Math.floor(l*A.length))],p=l>.72,y=m?.85*l:.2*l;o.fillStyle=p?`rgba(${k},${z},${C},${Math.min(m?.92:.32,2.2*y)})`:`rgba(${u},${S},${b},${y})`,o.fillText(g,i,h)}o.textAlign="left"}}var c={id:"stars",name:"Stars",description:"A sparse starfield that twinkles, drifts and leans toward the cursor.",cellSize:14,speed:1,cursor:!0,mount:t=>o(t,(t,e,o,c,r,s)=>n(t,e,o,c,r,{fontSize:s.fontSize,chars:s.chars,lightMode:s.lightMode,color:s.ink,accentColor:s.accent}))};export{n as renderStarsBackground,c as stars};//# sourceMappingURL=chunk-5Z2EJAUV.js.map