asciify-engine 1.0.73 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ type ColorMode = 'grayscale' | 'fullcolor' | 'matrix' | 'accent';
|
|
|
2
2
|
type RenderMode = 'ascii' | 'dots';
|
|
3
3
|
type AnimationStyle = 'none' | 'wave' | 'pulse' | 'rain' | 'breathe' | 'sparkle' | 'glitch' | 'spiral' | 'typewriter' | 'scatter' | 'waveField' | 'ripple' | 'melt' | 'orbit' | 'cellular';
|
|
4
4
|
type ArtStyle = 'classic' | 'particles' | 'letters' | 'claudeCode' | 'art' | 'terminal' | 'box' | 'lines' | 'braille' | 'katakana' | 'musical' | 'emoji' | 'circles' | 'shadows' | 'starfield' | 'geometric' | 'pipes' | 'waves' | 'shards' | 'smoke';
|
|
5
|
-
type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail';
|
|
6
|
-
type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice' | 'gravity' | 'shatter' | 'ghost';
|
|
5
|
+
type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail' | 'glitchText';
|
|
6
|
+
type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice' | 'gravity' | 'shatter' | 'ghost' | 'glitchReveal';
|
|
7
7
|
/**
|
|
8
8
|
* Named colour palette presets — pass as `colorMode` for themed rendering.
|
|
9
9
|
* Applied as a post-process colour remap over the standard grayscale output.
|
|
@@ -129,6 +129,25 @@ interface AsciiOptions {
|
|
|
129
129
|
* Any CSS colour string. Default: `'#ffffff'`
|
|
130
130
|
*/
|
|
131
131
|
hoverColor: string;
|
|
132
|
+
/**
|
|
133
|
+
* Text string revealed by the `'glitchText'` hover effect.
|
|
134
|
+
* Characters around the cursor scramble and resolve into this text.
|
|
135
|
+
* Supports `\n` for multi-line reveals.
|
|
136
|
+
*
|
|
137
|
+
* Pass an **array** of strings to cycle through different words based on
|
|
138
|
+
* the cursor's grid region — the engine picks one via a spatial hash so
|
|
139
|
+
* each area of the canvas shows a different word.
|
|
140
|
+
*
|
|
141
|
+
* Default: `'ASCIIFY'`
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* // Single word:
|
|
145
|
+
* options: { hoverEffect: 'glitchText', hoverText: 'HELLO' }
|
|
146
|
+
*
|
|
147
|
+
* // Word pool — different text at different cursor positions:
|
|
148
|
+
* options: { hoverEffect: 'glitchText', hoverText: ['DEPLOY', 'SCALE', 'SHIP', 'BUILD'] }
|
|
149
|
+
*/
|
|
150
|
+
hoverText: string | string[];
|
|
132
151
|
/**
|
|
133
152
|
* Art style preset applied at render time.
|
|
134
153
|
* Shorthand for a specific combination of `charset`, `renderMode`, and `colorMode`.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ type ColorMode = 'grayscale' | 'fullcolor' | 'matrix' | 'accent';
|
|
|
2
2
|
type RenderMode = 'ascii' | 'dots';
|
|
3
3
|
type AnimationStyle = 'none' | 'wave' | 'pulse' | 'rain' | 'breathe' | 'sparkle' | 'glitch' | 'spiral' | 'typewriter' | 'scatter' | 'waveField' | 'ripple' | 'melt' | 'orbit' | 'cellular';
|
|
4
4
|
type ArtStyle = 'classic' | 'particles' | 'letters' | 'claudeCode' | 'art' | 'terminal' | 'box' | 'lines' | 'braille' | 'katakana' | 'musical' | 'emoji' | 'circles' | 'shadows' | 'starfield' | 'geometric' | 'pipes' | 'waves' | 'shards' | 'smoke';
|
|
5
|
-
type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail';
|
|
6
|
-
type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice' | 'gravity' | 'shatter' | 'ghost';
|
|
5
|
+
type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail' | 'glitchText';
|
|
6
|
+
type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice' | 'gravity' | 'shatter' | 'ghost' | 'glitchReveal';
|
|
7
7
|
/**
|
|
8
8
|
* Named colour palette presets — pass as `colorMode` for themed rendering.
|
|
9
9
|
* Applied as a post-process colour remap over the standard grayscale output.
|
|
@@ -129,6 +129,25 @@ interface AsciiOptions {
|
|
|
129
129
|
* Any CSS colour string. Default: `'#ffffff'`
|
|
130
130
|
*/
|
|
131
131
|
hoverColor: string;
|
|
132
|
+
/**
|
|
133
|
+
* Text string revealed by the `'glitchText'` hover effect.
|
|
134
|
+
* Characters around the cursor scramble and resolve into this text.
|
|
135
|
+
* Supports `\n` for multi-line reveals.
|
|
136
|
+
*
|
|
137
|
+
* Pass an **array** of strings to cycle through different words based on
|
|
138
|
+
* the cursor's grid region — the engine picks one via a spatial hash so
|
|
139
|
+
* each area of the canvas shows a different word.
|
|
140
|
+
*
|
|
141
|
+
* Default: `'ASCIIFY'`
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* // Single word:
|
|
145
|
+
* options: { hoverEffect: 'glitchText', hoverText: 'HELLO' }
|
|
146
|
+
*
|
|
147
|
+
* // Word pool — different text at different cursor positions:
|
|
148
|
+
* options: { hoverEffect: 'glitchText', hoverText: ['DEPLOY', 'SCALE', 'SHIP', 'BUILD'] }
|
|
149
|
+
*/
|
|
150
|
+
hoverText: string | string[];
|
|
132
151
|
/**
|
|
133
152
|
* Art style preset applied at render time.
|
|
134
153
|
* Shorthand for a specific combination of `charset`, `renderMode`, and `colorMode`.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseGIF as t,decompressFrames as e}from"gifuct-js";var o={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={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵"},r={cosmic:[n.starfield,n.circles,n.shadows],rain:[n.katakana,n.braille,n.binary],terminal:[n.pipes,n.claudeCode,n.standard],crystal:[n.shards,n.geometric,n.blocks],fluid:[n.waves,n.smoke,n.circles],pulse:[n.dense,n.standard,n.blocks],dream:[n.braille,n.shadows,n.smoke],angular:[n.geometric,n.shards,n.starfield]},a={classic:{renderMode:"ascii",charset:n.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:n.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:n.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:n.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:n.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:n.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:n.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:n.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:n.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:n.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:n.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:n.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:n.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:n.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:n.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:n.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:n.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:n.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:n.smoke,colorMode:"accent",accentColor:"#c850ff"}},i={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:n.standard,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",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60},c={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:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}}};function s(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function l(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function h(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var f=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function d(t,e,o,n){if(n<=0)return t;const r=(f[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var g=new Array(256),u=new Array(256);for(let t=0;t<256;t++)g[t]=`rgb(${t},${t},${t})`,u[t]=`rgb(0,${t},0)`;function m(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return u[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return g[e]}}}var M=[0,0,0];function p(t,e,o,n,r,a=!1){switch(e){case"fullcolor":M[0]=t.r,M[1]=t.g,M[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;M[0]=0,M[1]=e,M[2]=0;break}case"accent":M[0]=o,M[1]=n,M[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;M[0]=e,M[1]=e,M[2]=e;break}}return M}function b(t,e,o,n,r,a,i){if("none"===a)return 1;const c=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*c)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*c)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-a)**2),s=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/s*Math.PI*6-4*c)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/n*Math.PI*8-5*c+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+c)+.7);case"breathe":{const o=.3*Math.sin(2*c)+.7,n=.1*Math.sin(.1*(t+e)+c);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*c)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*c));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*c+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.atan2(s,i),h=Math.sqrt(i*i+s*s),f=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/f*Math.PI*8-3*c)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.5*c%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.sqrt(i*i+s*s)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*c)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*c)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.sqrt(i*i+s*s),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*c)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*c+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.atan2(s,i),h=Math.sqrt(i*i+s*s)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*c)+.5)}case"cellular":{const o=Math.floor(4*c),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var v={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function w(t,e,o,n,r,a,i,c,s="spotlight",l=.5){const h=t-o,f=e-n,d=h*h+f*f,g=.08+.35*l+.04*a;if(d>=g*g)return v.scale=1,v.offsetX=0,v.offsetY=0,v.glow=0,v.colorBlend=0,v.proximity=0,v;const u=function(t){return t*t*(3-2*t)}(1-Math.sqrt(d)/g)*r;let m=1,M=0,p=0,b=0,w=0;switch(s){case"spotlight":{m=1+u*a*1.8;const t=Math.atan2(f,h),e=u*u*a*.6;M=Math.cos(t)*e*i,p=Math.sin(t)*e*c,b=u*a*.4,w=u*u*a*.25;break}case"magnify":m=1+u*a*2.5,b=u*a*.15;break;case"repel":{m=1+u*a*.3;const t=Math.atan2(f,h),e=u*u*a*1.2;M=Math.cos(t)*e*i,p=Math.sin(t)*e*c;break}case"glow":b=u*a*.8,w=u*a*.4;break;case"colorShift":m=1+u*a*.4,b=u*a*.2,w=u*a*.7;break;case"attract":{const t=Math.atan2(f,h),e=u*u*a*1;M=-Math.cos(t)*e*i,p=-Math.sin(t)*e*c,b=u*a*.3;break}case"shatter":{const t=Math.atan2(f,h),e=.5*Math.sin(43.7*h+29.3*f),o=u*a*1.4*(.7+.3*e);M=Math.cos(t+e)*o*i,p=Math.sin(t+e)*o*c,m=Math.max(.1,1-u*a*.6),b=u*a*.25;break}case"trail":w=u*a*.9,b=u*a*.6,m=1+u*a*.15}return v.scale=m,v.offsetX=M,v.offsetY=p,v.glow=b,v.colorBlend=w,v.proximity=u,v}function y(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 o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function x(t){return t*t*t*(t*(6*t-15)+10)}function $(t,e,o){return t+(e-t)*o}function S(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function C(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=x(t-o),i=x(r),c=S(o,n),s=S(o+1,n),l=S(o,n+1),h=S(o+1,n+1);return $($(c,s,a),$(l,h,a),i)}function E(t,e){return(.5*C(t,e)+.25*C(2.1*t,2.1*e)+.125*C(4.3*t,4.3*e))/.875}function I(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:c=.62,lineHeightRatio:s=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:g=.55,mouseFalloff:u=2.8,speed:m=1,vortex:M=!0,sparkles:p=!0,breathe:b=!0,lightMode:v=!1}=a,w=f??(v?"#6b8700":"#d4ff00"),y=i*c,x=i*s,$=Math.ceil(e/y),C=Math.ceil(o/x),I=r.x,R=r.y;let T=212,A=255,k=0;{const t=w.replace("#","");6===t.length&&(T=parseInt(t.slice(0,2),16),A=parseInt(t.slice(2,4),16),k=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const z=n*m,P=b?.12*(.5*Math.sin(.22*z)+.5):0;for(let e=0;e<C;e++)for(let o=0;o<$;o++){const n=o/$,r=e/C,a=.045,i=.08*z,c=.06,s=.45*((.5*Math.sin(.08*o+.05*e+.6*z)+.5+(.5*Math.sin(.03*o-.07*e+.4*z)+.5)+(.5*Math.sin(.05*o+.03*e+.8*z)+.5))/3)+.35*(.5*E(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*c+1.1*z)+.5)+P,f=n-I,m=r-R,b=Math.sqrt(f*f+m*m);let w=0;if(M&&b<.35){const t=Math.atan2(m,f),e=Math.sin(4*t+2.2*z-14*b),o=Math.max(0,1-b/.35);w=e*o*o*.22}const q=s*(1-g)+(Math.max(0,1-b*u)+.5*w)*g+.15*w,B=Math.min(1,Math.max(0,q));let F=B;if(p&&B>.72){const t=Math.floor(8*z),n=S(7*o+3*t,11*e+t);n>.88&&(F=Math.min(1,B+4*(n-.88)))}const L=Math.floor(F*(l.length-1));if(" "===l[L])continue;const H=.015+.07*F;if(F>d){const e=Math.min(v?.9:.28,H*(v?14:2.8));t.fillStyle=`rgba(${T},${A},${k},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):v?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[L],o*y,e*x)}}function R(t){return"auto"!==t?t:"undefined"!=typeof window&&!window.matchMedia("(prefers-color-scheme: dark)").matches}function T(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 o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function A(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=T(t.getPropertyValue(e).trim());if(o)return o}const e=T(getComputedStyle(document.body).accentColor??"");if(e)return e}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches?"faf9f7":"0d0d0d"}function k(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,c=e.fontSize*e.charSpacing,f=e.fontSize/i*e.charSpacing,g=o||r,u=n||a,m=Math.floor(g/c),M=Math.floor(u/f);if(m<=0||M<=0)return{frame:[],cols:0,rows:0};const p=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(r/m))),b=Math.max(1,Math.min(Math.floor(2048/M),Math.floor(a/M))),v=m*p,w=M*b,{ctx:y}=function(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}(v,w);y.drawImage(t,0,0,v,w);const x=y.getImageData(0,0,v,w).data,$=e.chromaKey,S=null!=$&&!1!==$,C=!0===$,E="blue-screen"===$;let I=null,T=0;!S||C||E||(I=function(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}($),T=(e.chromaKeyTolerance??60)**2);let A=0,k=255;if(e.normalize){let t=255,e=0;for(let o=0;o<x.length;o+=4){if(S){const t=x[o],e=x[o+1],n=x[o+2];let r=!1;if(C)r=e>1.4*t&&e>1.4*n&&e>80;else if(E)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==I){const o=t-I.r,a=e-I.g,i=n-I.b;r=o*o+a*a+i*i<=T}if(r)continue}const n=.299*x[o]+.587*x[o+1]+.114*x[o+2];n<t&&(t=n),n>e&&(e=n)}A=t,k=e>t?e-t:255}const z=[],P=R(e.invert),q=S&&e.charset.replace(/ /g,"")||e.charset,B=p*b;for(let t=0;t<M;t++){const o=[];for(let n=0;n<m;n++){let r=0,a=0,i=0,c=0,f=0;for(let e=0;e<b;e++){const o=(t*b+e)*v;for(let t=0;t<p;t++){const e=4*(o+n*p+t),s=x[e],l=x[e+1],h=x[e+2],d=x[e+3];if(S){let t=!1;if(C)t=l>1.4*s&&l>1.4*h&&l>80;else if(E)t=h>1.4*s&&h>1.4*l&&h>80;else if(null!==I){const e=s-I.r,o=l-I.g,n=h-I.b;t=e*e+o*o+n*n<=T}if(t){f++;continue}}r+=s,a+=l,i+=h,c+=d}}if(S&&f>B/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const g=B-f,u=g>0?r/g:0,M=g>0?a/g:0,w=g>0?i/g:0,y=g>0?c/g:0,$=.299*u+.587*M+.114*w,R=d(s(e.normalize?($-A)/k*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),z=e.customText?h(R,e.customText,n,t,m,P):l(R,q,P);o.push({char:z,r:u,g:M,b:w,a:y,lum:R})}z.push(o)}return{frame:z,cols:m,rows:M}}async function z(t,e,o,n,r=12,a=10,i,c=0){const s=Math.min(t.duration-c,a),l=Math.ceil(s*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const g=c+a/r;if(g>c+s)break;t.currentTime=g,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=k(t,e,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function P(o,n,r,a,i){const c=t(o),s=e(c,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const l=s[0].dims.width,h=s[0].dims.height,f=c.lsd?.width||l,d=c.lsd?.height||h,g=document.createElement("canvas");g.width=f,g.height=d;const u=g.getContext("2d"),m=document.createElement("canvas");m.width=f,m.height=d;const M=m.getContext("2d"),p=[];let b=0,v=0,w=0;for(const t of s)w+=t.delay||100;const y=w/s.length,x=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let t=0;t<$;t++){const e=s[t],{dims:o,patch:c,disposalType:l}=e;3===l&&(M.clearRect(0,0,f,d),M.drawImage(g,0,0));const h=new ImageData(new Uint8ClampedArray(c.buffer),o.width,o.height),w=document.createElement("canvas");w.width=o.width,w.height=o.height;w.getContext("2d").putImageData(h,0,0),u.drawImage(w,o.left||0,o.top||0);const y=k(g,n,r,a);p.push(y.frame),b=y.cols,v=y.rows,2===l?u.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(m,0,0)),i?.((t+1)/$)}return{frames:p,cols:b,rows:v,fps:x}}function q(t,e,o,n,r,a=0,i){if("waveField"===o.animationStyle){return void I(t,n,r,a,i?{x:i.x,y:i.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?A(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const c=e.length;if(0===c)return;const s=e[0].length;t.clearRect(0,0,n,r);let h=!1;const f=Math.max(1,c>>2),d=Math.max(1,s>>2);t:for(let t=0;t<c;t+=f){const o=e[t];for(let t=0;t<s;t+=d)if(o[t].a<200){h=!0;break t}}if(!h){const e="undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches;t.fillStyle=e?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r)}const g=n/s,u=r/c,M=c*s,v=i?.intensity??1,y=!("none"!==o.animationStyle&&M>5e3)&&!!(i&&o.hoverStrength>0&&v>.005),x=o.hoverColor||"#ffffff",$=parseInt(x.slice(1,3),16)||255,S=parseInt(x.slice(3,5),16)||255,C=parseInt(x.slice(5,7),16)||255,E=A(o.accentColor),T=parseInt(E.substring(0,2),16)||255,k=parseInt(E.substring(2,4),16)||255,z=parseInt(E.substring(4,6),16)||255,P=M>3e4?.25:M>15e3?.4:M>5e3?.6:1,q=o.hoverRadius*P;let B=0,F=s,L=0,H=c,j=0,W=0;if(y&&i){j=i.x,W=i.y;const t=.08+.35*q+.04*o.hoverStrength;B=Math.max(0,Math.floor((j-t)*s)-1),F=Math.min(s,Math.ceil((j+t)*s)+1),L=Math.max(0,Math.floor((W-t)*c)-1),H=Math.min(c,Math.ceil((W+t)*c)+1)}const O=o.animationStyle,U=o.animationSpeed,D="none"===O,X=o.hoverStrength,V=o.hoverEffect,Y=q,J=R(o.invert),_=o.colorMode,N=2*Math.PI,G=1/s,K=1/c;let Q="",Z=-1;if("dots"===o.renderMode){const n=.5*Math.min(g,u)*o.dotSizeRatio;for(let o=0;o<c;o++){const r=e[o];for(let e=0;e<s;e++){const i=r[e];if(i.a<10)continue;const l=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=J?1-l:l;if(h<.02)continue;const f=D?1:b(e,o,s,c,a,O,U);let d=1,M=0,x=0,E=0,I=0;if(y&&e>=B&&e<=F&&o>=L&&o<=H){const t=w(e*G,o*K,j,W,v,X,g,u,V,Y);d=t.scale,M=t.offsetX,x=t.offsetY,E=t.glow,I=t.colorBlend}const R=n*h*f*d;if(R<.3)continue;const A=e*g+.5*g+M,P=o*u+.5*u+x;let q;if(I>0){const t=p(i,_,T,k,z,J);q=`rgb(${Math.min(255,t[0]+($-t[0])*I|0)},${Math.min(255,t[1]+(S-t[1])*I|0)},${Math.min(255,t[2]+(C-t[2])*I|0)})`}else q=m(i,_,T,k,z,J);const tt=Math.min(1,.00392156863*i.a*f*(1+E));if(tt!==Z&&(t.globalAlpha=tt,Z=tt),q!==Q&&(t.fillStyle=q,Q=q),R<=3){const e=2*R;t.fillRect(A-R,P-R,e,e)}else t.beginPath(),t.arc(A,P,R,0,N),t.fill()}}}else{const n=.55,r=.9*Math.min(g/n,u),i=r<6;if(!i){const e="emoji"===o.artStyle;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"}let h=null;const f=o.charsetFrames,d=!!f?.length,M=d?f[Math.floor(Math.max(0,a)*(o.charsetFps??2))%f.length]:o.charset;if(i){h={};const t=[...M],e=t.length;for(let o=0;o<e;o++)h[t[o]]=Math.max(.1,(o+.3)/e)}const x=i?null:t.getTransform();for(let o=0;o<c;o++){const n=e[o];for(let e=0;e<s;e++){const r=n[e];if(r.a<10)continue;const f=d&&null!=r.lum?l(r.lum,M,J):r.char;if(" "===f)continue;const E=D?1:b(e,o,s,c,a,O,U);if(E<.05)continue;let I=1,R=0,A=0,P=0,q=0;if(y&&e>=B&&e<=F&&o>=L&&o<=H){const t=w(e*G,o*K,j,W,v,X,g,u,V,Y);I=t.scale,R=t.offsetX,A=t.offsetY,P=t.glow,q=t.colorBlend}const N=e*g+.5*g+R,tt=o*u+.5*u+A;let et;if(q>0){const t=p(r,_,T,k,z,J);et=`rgb(${Math.min(255,t[0]+($-t[0])*q|0)},${Math.min(255,t[1]+(S-t[1])*q|0)},${Math.min(255,t[2]+(C-t[2])*q|0)})`}else et=m(r,_,T,k,z,J);if(i){const e=h[f]??.5,o=Math.min(1,.00392156863*r.a*E*(1+P))*e;if(o<.02)continue;o!==Z&&(t.globalAlpha=o,Z=o),et!==Q&&(t.fillStyle=et,Q=et);const n=g*I,a=u*I;t.fillRect(N-.5*n,tt-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*E*(1+P));e!==Z&&(t.globalAlpha=e,Z=e),et!==Q&&(t.fillStyle=et,Q=et),1!==I?(t.translate(N,tt),t.scale(I,I),t.fillText(f,0,0),t.setTransform(x)):t.fillText(f,N,tt)}}}}t.globalAlpha=1}function B(t,e){const o=Math.min(1,2048/Math.max(t,e));return{renderW:Math.round(t*o),renderH:Math.round(e*o)}}function F(t,e,o,n,r){const{width:a,height:i}=e.getBoundingClientRect();if(!a||!i)return{renderW:0,renderH:0,dpr:1};let c,s,l=a,h=l/o;h>i&&(h=i,l=h*o),l=Math.round(l),h=Math.round(h),n&&r?({renderW:c,renderH:s}=B(n,r)):(c=l,s=h);const f="undefined"!=typeof window&&window.devicePixelRatio||1,d=8e6,g=c*f*s*f>d?Math.sqrt(d/(c*s)):f;return t.width=Math.round(c*g),t.height=Math.round(s*g),t.style.width=l+"px",t.style.height=h+"px",{renderW:c,renderH:s,dpr:g}}async function L(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){let c;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),c=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),c=t):c=t;const s=a[n],l=o??r.fontSize??10,h={...i,...s,...r,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:g}=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}}(c),{renderW:u,renderH:m}=B(d,g),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,b=u*M*m*M>p?Math.sqrt(p/(u*m)):M;(e.width<u||e.height<m)&&(e.width=Math.round(u*b),e.height=Math.round(m*b));const{frame:v}=k(c,h,u,m);f.save(),f.setTransform(b,0,0,b,0,0),q(f,v,h,u,m),f.restore()}async function H(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){const c="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??r.fontSize??10,l={...i,...a[n],...r,fontSize:s},h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:f,fps:d}=await P(c,l,e.width,e.height);let g,u=!1,m=0,M=performance.now();const p=1e3/d,b=t=>{u||(t-M>=p&&(q(h,f[m],l,e.width,e.height),m=(m+1)%f.length,M=t),g=requestAnimationFrame(b))};return g=requestAnimationFrame(b),()=>{u=!0,cancelAnimationFrame(g)}}async function j(t,e,{fontSize:o,artStyle:n="classic",options:r={},fitTo:c,preExtract:s=!1,trim:l,onReady:h,onFrame:f}={}){const d=l?.start??0,g=l?.end,u=o??r.fontSize??10,m={...i,...a[n],...r,fontSize:u},M=e.getContext("2d");if(!M)throw new Error("asciifyVideo: could not get 2d context from canvas.");const p="string"==typeof c?document.querySelector(c):c instanceof HTMLElement?c:null;if(s){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,p&&F(e,p,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight);const{renderW:n,renderH:r}=B(o.videoWidth,o.videoHeight),a="undefined"!=typeof window&&window.devicePixelRatio||1,i=8e6,c=n*a*r*a>i?Math.sqrt(i/(n*r)):a;e.width<Math.round(n*c)&&(e.width=Math.round(n*c),e.height=Math.round(r*c));const s=void 0!==g?g-d:10,{frames:l,fps:u}=await z(o,m,n,r,void 0,s,void 0,d);let b,v=!1,w=0,y=performance.now(),x=!0;const $=1e3/u,S=t=>{v||(t-y>=$&&(M.save(),M.setTransform(c,0,0,c,0,0),q(M,l[w],m,n,r),M.restore(),w=(w+1)%l.length,y=t,x&&(x=!1,h?.(o)),f?.()),b=requestAnimationFrame(S))};return b=requestAnimationFrame(S),()=>{v=!0,cancelAnimationFrame(b)}}let b,v=!1;"string"==typeof t?(b=document.createElement("video"),b.src=t,b.muted=!0,b.loop=!0,b.playsInline=!0,b.setAttribute("playsinline",""),Object.assign(b.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(b),v=!0,await new Promise((e,o)=>{b.onloadedmetadata=()=>e(),b.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await b.play().catch(()=>{})):(b=t,b.paused&&await b.play().catch(()=>{})),d>0&&(b.currentTime=d,await new Promise(t=>{const e=()=>{b.removeEventListener("seeked",e),t()};b.addEventListener("seeked",e)}));let w=null;(d>0||void 0!==g)&&(w=()=>{(void 0!==g&&b.currentTime>=g||d>0&&b.currentTime<d)&&(b.currentTime=d)},b.addEventListener("timeupdate",w));let y=null;const{renderW:x,renderH:$}=B(b.videoWidth,b.videoHeight);if(p){const t=b.videoWidth/b.videoHeight,o=b.videoWidth,n=b.videoHeight,r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),y=new ResizeObserver(()=>{const r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),y.observe(p)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=x*t*$*t>o?Math.sqrt(o/(x*$)):t;e.width<Math.round(x*n)&&(e.width=Math.round(x*n),e.height=Math.round($*n)),M.setTransform(n,0,0,n,0,0)}let S,C=!1,E=!0;const I=()=>{if(C)return;if(S=requestAnimationFrame(I),b.readyState<2||0===e.width||0===e.height)return;if(d>0&&b.currentTime<d)return;if(void 0!==g&&b.currentTime>=g)return;const{frame:t}=k(b,m,x,$);t.length>0&&(q(M,t,m,x,$,0,null),E&&(E=!1,h?.(b)),f?.())};return S=requestAnimationFrame(I),()=>{C=!0,cancelAnimationFrame(S),y?.disconnect(),w&&b.removeEventListener("timeupdate",w),v&&(b.pause(),b.src="",document.body.removeChild(b))}}function W(t,e,o){return j(t,e,o)}function O(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:c,color:s,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,g=c??(d?"#6b8700":"#d4ff00"),u=.62*a,m=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/m);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let b=255,v=255,w=255;if(d&&(b=55,v=55,w=55),s){const t=y(s);t&&(b=t.r,v=t.g,w=t.b)}let x=212,$=255,C=0;const E=y(g);E&&(x=E.r,$=E.g,C=E.b);const I=p+f;for(let e=0;e<M;e++){if(S(17*e,3)>h)continue;const o=(.5+1.5*S(31*e,7))*l,r=S(13*e,11)*I,a=Math.floor((n*o*7+r)%I),c=e*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const s=r*m,l=S(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],g=o/f;if(o===f)t.fillStyle=`rgba(${x},${$},${C},${d?.7:.85})`;else{const e=d?.85*g:.15*g;t.fillStyle=`rgba(${b},${v},${w},${e})`}t.fillText(h,c,s)}}}function U(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" . · * + ° ★",accentColor:s,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,g=s??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),m=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,b=255,v=255;if(d&&(p=55,b=55,v=55),l){const t=y(l);t&&(p=t.r,b=t.g,v=t.b)}let w=212,x=255,$=0;const C=y(g);C&&(w=C.r,x=C.g,$=C.b);const E=c.replace(/ /g,"").split("");if(0!==E.length){for(let r=0;r<f;r++){const a=S(17*r,3)*Math.PI*2,c=(n*(.15+.85*S(31*r,7))*h*.22+S(13*r,11))%1,s=u+Math.cos(a)*c*M,l=m+Math.sin(a)*c*M;if(s<-20||s>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*c));t.font=`${f}px monospace`;const g=E[Math.min(E.length-1,Math.floor(c*E.length))],y=c>.72,C=d?.85*c:.2*c;t.fillStyle=y?`rgba(${w},${x},${$},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${b},${v},${C})`,t.fillText(g,s,l)}t.textAlign="left"}}function D(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=". · ○ ◎ ●",accentColor:s,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:g=!1}=a,u=s??(g?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const m=e*r.x,M=o*r.y,p=1.6*Math.sqrt(m*m+M*M)+.2*Math.sqrt(e*e+o*o);let b=255,v=255,w=255;if(g&&(b=55,v=55,w=55),l){const t=y(l);t&&(b=t.r,v=t.g,w=t.b)}let x=0,$=255,S=204;const C=y(u);C&&(x=C.r,$=C.g,S=C.b);const E=c.replace(/ /g,"").split("");if(0===E.length)return;const I=Math.ceil(e/i),R=Math.ceil(o/i);for(let e=0;e<R;e++)for(let o=0;o<I;o++){const r=o*i+.5*i,a=e*i+.5*i,c=r-m,s=a-M,l=Math.sqrt(c*c+s*s)/p;let u=0;for(let t=0;t<h;t++){const e=(n*f*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const y=u>.6;t.font=`${i}px monospace`;const C=Math.floor(u*(E.length-1)),I=E[Math.min(C,E.length-1)],R=g?.88*u:.22*u;t.fillStyle=y?`rgba(${x},${$},${S},${Math.min(g?.95:.4,.55*u)})`:`rgba(${b},${v},${w},${R})`,t.fillText(I,r,a)}t.textAlign="left"}function X(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" .·:;=+*#%@░▒▓",accentColor:s,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:g=.78,mouseWarp:u=.3,lightMode:m=!1}=a,M=s??(m?"#6b8700":"#d4ff00"),p=.62*i,b=1.4*i,v=Math.ceil(e/p),w=Math.ceil(o/b);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,$=255,S=255;if(m&&(x=55,$=55,S=55),l){const t=y(l);t&&(x=t.r,$=t.g,S=t.b)}let E=212,I=255,R=0;const T=y(M);T&&(E=T.r,I=T.g,R=T.b);const A=.035*d,k=n*f,z=Math.min(6,Math.max(1,h)),P=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<z;i++)o+=C(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<w;e++)for(let o=0;o<v;o++){const n=o*A+.06*k,a=e*A*1.3-.04*k,i=o/v-r.x,s=e/w-r.y,l=Math.sqrt(i*i+s*s),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*P(n+h*Math.sin(1.3*k+8*s),a+h*Math.cos(.9*k+8*i))+.5;if(f<.12)continue;const d=c[Math.floor(f*(c.length-1))];if(" "===d)continue;const M=f>g,y=m?.82*f:.13*f;t.fillStyle=M?`rgba(${E},${I},${R},${m?.92:.28})`:`rgba(${x},${$},${S},${y})`,t.fillText(d,o*p,e*b)}}function V(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:c="·-=+|/",accentColor:s,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:g=!0,lightMode:u=!1}=a,m=s??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,x=255,$=255;if(u&&(w=55,x=55,$=55),l){const t=y(l);t&&(w=t.r,x=t.g,$=t.b)}let C=212,E=255,I=0;const R=y(m);R&&(C=R.r,E=R.g,I=R.b);const T=n*f;for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=e/v,a=((n*h-.5*T)%1+1)%1,i=Math.max(0,1-a/d),s=.35*(.5*S(3*o,7*e)+.5);let l=0;if(g){const t=o/b-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=S(11*o+Math.floor(12*T),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,s+.8*i+.6*l);if(f<.04)continue;const m=c[Math.floor(f*(c.length-1))],y=i>.55,R=u?.82*f:.12*f;t.fillStyle=y?`rgba(${C},${E},${I},${u?.92:.28})`:`rgba(${w},${x},${$},${R})`,t.fillText(m,o*M,e*p)}}function Y(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" ·∙•:;+=≡≣#@",color:s,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:g=.2,lightMode:u=!1}=a,m=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,x=255,$=255;if(u&&(w=55,x=55,$=55),s){const t=y(s);t&&(w=t.r,x=t.g,$=t.b)}let C=212,E=255,I=0;const R=y(m);R&&(C=R.r,E=R.g,I=R.b);const T=n*h,A=[];for(let t=0;t<f;t++){const e=S(17*t,31*t+7),o=S(23*t+5,11*t);A.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*S(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*S(29*t,3*t)})}for(let e=0;e<v;e++){const o=e/v;for(let n=0;n<b;n++){const a=n/b,i=a-r.x,s=o-r.y,l=Math.sqrt(i*i+s*s),h=g*Math.exp(-l*l/.06),m=a+i*h,v=o+s*h;let y=0,S=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=A[t];y+=Math.sin(m*e*Math.PI*2+T*r+n)*Math.cos(v*o*Math.PI*2+T*r*.7+1.3*n)*a,S+=a}const R=y/S,k=.5+.5*Math.tanh(R*d*2.2);if(k<.12)continue;const z=(k-.12)/.88,P=c[Math.min(c.length-1,Math.floor(z*c.length))],q=k>.82,B=u?.82*k:.14*k;t.fillStyle=q?`rgba(${C},${E},${I},${u?.92:.32})`:`rgba(${w},${x},${$},${B})`,t.fillText(P,n*M,e*p)}}}function J(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:c,speed:s=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),i){const t=y(i);t&&(p=t.r,b=t.g,v=t.b)}let w=212,x=255,$=0;const C=y(d);C&&(w=C.r,x=C.g,$=C.b);const E=n*s,I=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<m;n++){const r=n/m;let a=0,i=0;for(let t=0;t<l;t++){const e=S(13*t,7*t+3),n=1.1+2.4*e,c=.9+2*S(29*t,11*t+1),s=e*Math.PI*6,l=(.2+.5*S(41*t,17*t))*(t%2==0?1:-1.3),f=Math.sin(r*n*Math.PI*2+E*l+s),d=Math.cos(o*c*Math.PI*2+E*l*.6+1.7*s),g=Math.sin(r*c*Math.PI*h+o*n*Math.PI*h+E*l*.4);a+=Math.atan2(d+.3*g,f),i+=.5*(f*d+1)}const c=a/l,s=Math.min(1,i/l);if(s<.1)continue;const d=(c+Math.PI)/(2*Math.PI),M=I[Math.floor(d*I.length)%I.length],y=s>.8,C=f?.8*s:.13*s;t.fillStyle=y?`rgba(${w},${x},${$},${f?.9:.26})`:`rgba(${p},${b},${v},${C})`,t.fillText(M,n*g,e*u)}}}function _(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:c=" ·:;=+*#%@",color:s,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:g=!1}=a,u=l??(g?"#6b8700":"#d4ff00"),m=.62*i,M=1.4*i,p=Math.ceil(e/m),b=Math.ceil(o/M),v=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,x=255,$=255;if(g&&(w=55,x=55,$=55),s){const t=y(s);t&&(w=t.r,x=t.g,$=t.b)}let C=212,E=255,I=0;const R=y(u);R&&(C=R.r,E=R.g,I=R.b);const T=n*h;for(let e=0;e<b;e++){const o=e/b;for(let n=0;n<p;n++){const a=(n/p-r.x)*v,i=o-r.y,s=Math.sqrt(a*a+i*i)/f;if(s>1){const o=S(3*n,7*e)*Math.max(0,1-3*(s-1));if(o<.62)continue;const r=o*(g?.28:.04);t.fillStyle=`rgba(${w},${x},${$},${r})`,t.fillText(c[1],n*m,e*M);continue}const l=Math.max(0,1-Math.abs(s-(.15+.12*Math.sin(1.1*T)))/.07),h=Math.pow(1-s,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(c.length-1)),b=c[Math.min(c.length-1,u)],y=l>.35||s<.08,R=g?.85*d:.18*d;t.fillStyle=y?`rgba(${C},${E},${I},${g?.95:.38})`:`rgba(${w},${x},${$},${R})`,t.fillText(b,n*m,e*M)}}}function N(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:c,accentColor:s,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),c){const t=y(c);t&&(p=t.r,b=t.g,v=t.b)}let w=212,x=255,$=0;const C=y(d);C&&(w=C.r,x=C.g,$=C.b);const E=n*l,I=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<m;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*S(o*(t+3)+7,e*(t+5)+11),a=S(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin(E*r+a)*i}const r=.5*(n/I+1);if(r<.28)continue;const a=(r-.28)/.72,c=i[Math.min(i.length-1,Math.floor(a*i.length))],s=r>.88,l=f?.82*a:.13*a;t.fillStyle=s?`rgba(${w},${x},${$},${f?.92:.28})`:`rgba(${p},${b},${v},${l})`,t.fillText(c,o*g,e*u)}}function G(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:c="#ff4500",hotColor:s="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u),p=m*M,b="__fire_heat__",v=t.canvas;let w=v[b];w&&w.length===p||(w=new Float32Array(p),v[b]=w);const x=.18*(.016*f),$=h*f*.8,S=M-1,C=n*f;for(let t=0;t<m;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*l;w[S*m+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(w[(S-1)*m+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<m;e++){const o=.4*w[(t+1)*m+e]+.25*w[(t+2)*m+Math.max(0,Math.min(m-1,e+Math.round($)))]+.175*w[(t+1)*m+Math.max(0,e-1)]+.175*w[(t+1)*m+Math.min(m-1,e+1)];E[t*m+e]=Math.max(0,o-x-.02*Math.random()*f)}for(let t=0;t<m;t++)E[(M-1)*m+t]=w[(M-1)*m+t],M>1&&(E[(M-2)*m+t]=w[(M-2)*m+t]);v[b]=E;const I=y(c)??{r:255,g:69,b:0},R=y(s)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<m;o++){const n=E[e*m+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),c=I.r+(R.r-I.r)*a|0,s=I.g+(R.g-I.g)*a|0,l=I.b+(R.b-I.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${c},${s},${l})`,t.fillText(r,o*g,e*u)}t.globalAlpha=1}function K(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:c="-=≡",color:s="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:g=!1}=r,u=.62*a,m=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/m),b=d??Math.max(1,Math.floor(e/80)),v=M/b,w=y(s)??{r:0,g:229,b:255},x=y(l)??{r:255,g:64,b:129},$=y(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const C=n*f,E=.35*v;for(let e=0;e<b;e++){const o=v*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*C,a=o+Math.sin(r)*E,s=o+Math.sin(r+Math.PI)*E,l=Math.round(a),h=Math.round(s);if(l<0||l>=M)continue;const f=S(31*e+7*n,3),d=i[Math.floor(f*i.length)],g=.5*(Math.sin(r)+1),b=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*g,t.fillStyle=`rgb(${w.r},${w.g},${w.b})`,t.fillText(d,l*u,n*m),h>=0&&h<M){const o=S(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*b,t.fillStyle=`rgb(${x.r},${x.g},${x.b})`,t.fillText(r,h*u,n*m)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=S(17*n+43*e,5),i=c[Math.floor(a*c.length)],s=.25*(g+b)+.2;t.globalAlpha=s,t.fillStyle=`rgb(${$.r},${$.g},${$.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*m)}}}}t.globalAlpha=1}function Q(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:c="#4caf50",skyColor:s="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:g=!0,lightMode:u=!1}=r,m=.62*a,M=1.4*a,p=Math.ceil(e/m),b=Math.ceil(o/M),v=y(c)??{r:76,g:175,b:80},w=y(s)??{r:26,g:35,b:126},x=y(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const $=n*h*.4,C=new Array(p);for(let t=0;t<p;t++){const e=(.5*E((t/p+$)*f*3,.5)+.5)*d;C[t]=Math.floor(e*b)}for(let e=0;e<b;e++)for(let o=0;o<p;o++){const r=b-1-C[o],a=e===r;if(!(e>=r)){if(g){const r=S(7*o+Math.floor(.3*$),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${w.r+60},${w.g+60},${w.b+80})`,t.fillText("·",o*m,e*M)}}continue}const c=(e-r)/Math.max(1,C[o]),s=i[Math.min(i.length-1,Math.floor(c*i.length))];if(" "===s&&!a)continue;const l=a?1:Math.max(0,1-4*c),h=v.r+(x.r-v.r)*l|0,f=v.g+(x.g-v.g)*l|0,d=v.b+(x.b-v.b)*l|0;t.globalAlpha=.5+.5*c,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:s,o*m,e*M)}t.globalAlpha=1}var Z=1,tt=2,et=4,ot=8,nt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[Z]:"╶",[tt]:"╴",[et]:"╵",[ot]:"╷"};function rt(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:c="#00ff88",density:s=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,g=Math.ceil(e/f),u=Math.ceil(o/d),m=y(c)??{r:0,g:255,b:136},M=y(i)??{r:255,g:255,b:255},p=(t,e)=>{if(S(17*t+1,7*e+2)>s)return 0;let o=0;return t+1<g&&S(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&S(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&S(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&S(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const b=n*l;for(let e=0;e<u;e++)for(let o=0;o<g;o++){const n=p(o,e);if(0===n)continue;const r=nt[n]??"·",a=(8*b+40*S(o,23*e))%g,i=(6*b+40*S(17*e,11*o))%u,c=(1&n||2&n)&&Math.abs(o-a)<1.5,s=(4&n||8&n)&&Math.abs(e-i)<1.5,l=c||s,h=.25+.35*S(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${m.r},${m.g},${m.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}var at=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function it(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:c,...s}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),g=window.devicePixelRatio||1,u={x:.5,y:.5},m={x:.5,y:.5},M=window.matchMedia("(prefers-color-scheme: light)"),p=()=>"light"===i||"dark"!==i&&M.matches,b=c?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 o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(c):null,v=()=>({...s,lightMode:void 0!==s.lightMode?s.lightMode:p(),baseColor:b?`rgba(${b.r},${b.g},${b.b},{a})`:s.baseColor}),w={current:v()},y=()=>{w.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...s,lightMode:void 0!==s.lightMode?s.lightMode:p(),color:c??s.color}:"fire"===o||"dna"===o?{...s,color:c??s.color}:"terrain"===o||"circuit"===o?{...s,color:c??s.color,lightMode:void 0!==s.lightMode?s.lightMode:p()}:v()};y();const x=()=>{y()};"auto"===i&&M.addEventListener("change",x);const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*g,f.height=t.height*g,d.setTransform(g,0,0,g,0,0)};$();const S=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},C=new ResizeObserver($);C.observe(l),window.addEventListener("mousemove",S);let E=0,R=0;const T=()=>{m.x+=.07*(u.x-m.x),m.y+=.07*(u.y-m.y);const t=l.getBoundingClientRect();"rain"===o?O(d,t.width,t.height,E,w.current):"stars"===o?U(d,t.width,t.height,E,m,w.current):"pulse"===o?D(d,t.width,t.height,E,m,w.current):"noise"===o?X(d,t.width,t.height,E,m,w.current):"grid"===o?V(d,t.width,t.height,E,m,w.current):"aurora"===o?Y(d,t.width,t.height,E,m,w.current):"silk"===o?J(d,t.width,t.height,E,w.current):"void"===o?_(d,t.width,t.height,E,m,w.current):"morph"===o?N(d,t.width,t.height,E,w.current):"fire"===o?G(d,t.width,t.height,E,w.current):"dna"===o?K(d,t.width,t.height,E,w.current):"terrain"===o?Q(d,t.width,t.height,E,w.current):"circuit"===o?rt(d,t.width,t.height,E,w.current):I(d,t.width,t.height,E,m,w.current),E+=.016,R=requestAnimationFrame(T)};return R=requestAnimationFrame(T),{destroy:()=>{cancelAnimationFrame(R),C.disconnect(),"auto"===i&&M.removeEventListener("change",x),window.removeEventListener("mousemove",S),f.remove(),l.style.position=h}}}var ct=it;function st(t,e={},o,n){const r={...i,...e},{frame:a,cols:c}=k(t,r,o,n);if(!a.length||0===c)return"";const s=[];for(const t of a)s.push(t.map(t=>t.char).join(""));return s.join("\n")}function lt(t,e={},o,n){const r={...i,...e},{frame:a,cols:c}=k(t,r,o,n);if(!a.length||0===c)return"";const s=[];for(const t of a){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}[0m`;s.push(e)}return s.join("\n")}function ht(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=y(n)??{r:80,g:80,b:80},i=t,c=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%c],r:a.r,g:a.g,b:a.b,a:r})))}function ft(t,e,o,n,r={},a){const{fontSize:c=10,lineHeight:s=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:g=.18,hoverColor:u="#d4ff00"}=r;q(t,ht(n,Math.max(1,Math.floor(e/c)),Math.max(1,Math.floor(o/(c*s))),l,h),{...i,hoverEffect:f,hoverStrength:d,hoverRadius:g,hoverColor:u},e,o,0,a??null)}function dt(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}async function gt(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await dt(t,{format:n,...r}),i="jpeg"===n?"jpg":n,c=document.createElement("a");c.href=URL.createObjectURL(a),c.download=`${o}.${i}`,c.click(),setTimeout(()=>URL.revokeObjectURL(c.href),1e4)}async function ut(t,{fontSize:e=10,style:o="classic",options:n={},liveOptions:r,mirror:c=!0,constraints:s={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:s}),f=document.createElement("video");f.srcObject=h,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 d={...i,...a[o],...n,fontSize:e},g=t.getContext("2d");if(!g)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&g.scale(u,u);let m=null;const M={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();m={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},b=()=>{m=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b));let v,w=!1;const y=performance.now(),x=e=>{if(!w){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,a=(e-y)/1e3,i=r?{...d,...r()}:d;i.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b));const{frame:s}=k(f,i,o,n);if(m){const t=m.x-M.x,e=m.y-M.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);M.x+=t*n,M.y+=e*n,M.intensity+=.12*(1-M.intensity)}else M.intensity*=.965,M.intensity<.003&&(M.intensity=0);const l=M.intensity>.003?{x:M.x,y:M.y,intensity:M.intensity}:null;c?(g.save(),g.scale(-1,1),g.translate(-o,0),q(g,s,i,o,n,a,l),g.restore()):q(g,s,i,o,n,a,l)}v=requestAnimationFrame(x)}};return v=requestAnimationFrame(x),()=>{w=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}export{a as ART_STYLE_PRESETS,at as BACKGROUND_TYPES,n as CHARSETS,r as CHARSET_SEQUENCES,i as DEFAULT_OPTIONS,c as HOVER_PRESETS,o as PALETTE_THEMES,it as asciiBackground,st as asciiText,lt as asciiTextAnsi,L as asciify,H as asciifyGif,W as asciifyLiveVideo,j as asciifyVideo,ut as asciifyWebcam,ht as buildTextFrame,dt as captureSnapshot,P as gifToAsciiFrames,k as imageToAsciiFrame,ct as mountWaveBackground,Y as renderAuroraBackground,rt as renderCircuitBackground,K as renderDnaBackground,G as renderFireBackground,q as renderFrameToCanvas,V as renderGridBackground,N as renderMorphBackground,X as renderNoiseBackground,D as renderPulseBackground,O as renderRainBackground,J as renderSilkBackground,U as renderStarsBackground,Q as renderTerrainBackground,ft as renderTextBackground,_ as renderVoidBackground,I as renderWaveBackground,gt as snapshotAndDownload,z as videoToAsciiFrames};//# sourceMappingURL=index.js.map
|
|
1
|
+
import{parseGIF as t,decompressFrames as e}from"gifuct-js";var o={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={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵"},r={cosmic:[n.starfield,n.circles,n.shadows],rain:[n.katakana,n.braille,n.binary],terminal:[n.pipes,n.claudeCode,n.standard],crystal:[n.shards,n.geometric,n.blocks],fluid:[n.waves,n.smoke,n.circles],pulse:[n.dense,n.standard,n.blocks],dream:[n.braille,n.shadows,n.smoke],angular:[n.geometric,n.shards,n.starfield]},a={classic:{renderMode:"ascii",charset:n.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:n.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:n.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:n.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:n.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:n.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:n.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:n.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:n.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:n.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:n.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:n.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:n.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:n.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:n.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:n.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:n.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:n.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:n.smoke,colorMode:"accent",accentColor:"#c850ff"}},i={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:n.standard,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",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60},c={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:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}};function s(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function l(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function h(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var f=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function d(t,e,o,n){if(n<=0)return t;const r=(f[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var g=new Array(256),u=new Array(256);for(let t=0;t<256;t++)g[t]=`rgb(${t},${t},${t})`,u[t]=`rgb(0,${t},0)`;function M(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return u[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return g[e]}}}var m=[0,0,0];function p(t,e,o,n,r,a=!1){switch(e){case"fullcolor":m[0]=t.r,m[1]=t.g,m[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;m[0]=0,m[1]=e,m[2]=0;break}case"accent":m[0]=o,m[1]=n,m[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;m[0]=e,m[1]=e,m[2]=e;break}}return m}function b(t,e,o,n,r,a,i){if("none"===a)return 1;const c=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*c)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*c)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-a)**2),s=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/s*Math.PI*6-4*c)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/n*Math.PI*8-5*c+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+c)+.7);case"breathe":{const o=.3*Math.sin(2*c)+.7,n=.1*Math.sin(.1*(t+e)+c);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*c)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*c));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*c+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.atan2(s,i),h=Math.sqrt(i*i+s*s),f=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/f*Math.PI*8-3*c)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.5*c%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.sqrt(i*i+s*s)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*c)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*c)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.sqrt(i*i+s*s),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*c)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*c+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.atan2(s,i),h=Math.sqrt(i*i+s*s)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*c)+.5)}case"cellular":{const o=Math.floor(4*c),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var v={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function x(t,e,o,n,r,a,i,c,s="spotlight",l=.5){const h=t-o,f=e-n,d=h*h+f*f,g=.08+.35*l+.04*a;if(d>=g*g)return v.scale=1,v.offsetX=0,v.offsetY=0,v.glow=0,v.colorBlend=0,v.proximity=0,v;const u=function(t){return t*t*(3-2*t)}(1-Math.sqrt(d)/g)*r;let M=1,m=0,p=0,b=0,x=0;switch(s){case"spotlight":{M=1+u*a*1.8;const t=Math.atan2(f,h),e=u*u*a*.6;m=Math.cos(t)*e*i,p=Math.sin(t)*e*c,b=u*a*.4,x=u*u*a*.25;break}case"magnify":M=1+u*a*2.5,b=u*a*.15;break;case"repel":{M=1+u*a*.3;const t=Math.atan2(f,h),e=u*u*a*1.2;m=Math.cos(t)*e*i,p=Math.sin(t)*e*c;break}case"glow":b=u*a*.8,x=u*a*.4;break;case"colorShift":M=1+u*a*.4,b=u*a*.2,x=u*a*.7;break;case"attract":{const t=Math.atan2(f,h),e=u*u*a*1;m=-Math.cos(t)*e*i,p=-Math.sin(t)*e*c,b=u*a*.3;break}case"shatter":{const t=Math.atan2(f,h),e=.5*Math.sin(43.7*h+29.3*f),o=u*a*1.4*(.7+.3*e);m=Math.cos(t+e)*o*i,p=Math.sin(t+e)*o*c,M=Math.max(.1,1-u*a*.6),b=u*a*.25;break}case"trail":x=u*a*.9,b=u*a*.6,M=1+u*a*.15;break;case"glitchText":M=1+u*a*.25,b=u*a*.7,x=u*a*.65}return v.scale=M,v.offsetX=m,v.offsetY=p,v.glow=b,v.colorBlend=x,v.proximity=u,v}function w(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 o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function y(t){return t*t*t*(t*(6*t-15)+10)}function $(t,e,o){return t+(e-t)*o}function S(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function C(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=y(t-o),i=y(r),c=S(o,n),s=S(o+1,n),l=S(o,n+1),h=S(o+1,n+1);return $($(c,s,a),$(l,h,a),i)}function E(t,e){return(.5*C(t,e)+.25*C(2.1*t,2.1*e)+.125*C(4.3*t,4.3*e))/.875}function I(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:c=.62,lineHeightRatio:s=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:g=.55,mouseFalloff:u=2.8,speed:M=1,vortex:m=!0,sparkles:p=!0,breathe:b=!0,lightMode:v=!1}=a,x=f??(v?"#6b8700":"#d4ff00"),w=i*c,y=i*s,$=Math.ceil(e/w),C=Math.ceil(o/y),I=r.x,R=r.y;let T=212,A=255,k=0;{const t=x.replace("#","");6===t.length&&(T=parseInt(t.slice(0,2),16),A=parseInt(t.slice(2,4),16),k=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const z=n*M,P=b?.12*(.5*Math.sin(.22*z)+.5):0;for(let e=0;e<C;e++)for(let o=0;o<$;o++){const n=o/$,r=e/C,a=.045,i=.08*z,c=.06,s=.45*((.5*Math.sin(.08*o+.05*e+.6*z)+.5+(.5*Math.sin(.03*o-.07*e+.4*z)+.5)+(.5*Math.sin(.05*o+.03*e+.8*z)+.5))/3)+.35*(.5*E(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*c+1.1*z)+.5)+P,f=n-I,M=r-R,b=Math.sqrt(f*f+M*M);let x=0;if(m&&b<.35){const t=Math.atan2(M,f),e=Math.sin(4*t+2.2*z-14*b),o=Math.max(0,1-b/.35);x=e*o*o*.22}const q=s*(1-g)+(Math.max(0,1-b*u)+.5*x)*g+.15*x,B=Math.min(1,Math.max(0,q));let F=B;if(p&&B>.72){const t=Math.floor(8*z),n=S(7*o+3*t,11*e+t);n>.88&&(F=Math.min(1,B+4*(n-.88)))}const L=Math.floor(F*(l.length-1));if(" "===l[L])continue;const H=.015+.07*F;if(F>d){const e=Math.min(v?.9:.28,H*(v?14:2.8));t.fillStyle=`rgba(${T},${A},${k},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):v?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[L],o*w,e*y)}}function R(t){return"auto"!==t?t:"undefined"!=typeof window&&!window.matchMedia("(prefers-color-scheme: dark)").matches}function T(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 o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function A(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=T(t.getPropertyValue(e).trim());if(o)return o}const e=T(getComputedStyle(document.body).accentColor??"");if(e)return e}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches?"faf9f7":"0d0d0d"}function k(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,c=e.fontSize*e.charSpacing,f=e.fontSize/i*e.charSpacing,g=o||r,u=n||a,M=Math.floor(g/c),m=Math.floor(u/f);if(M<=0||m<=0)return{frame:[],cols:0,rows:0};const p=Math.max(1,Math.min(Math.floor(2048/M),Math.floor(r/M))),b=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(a/m))),v=M*p,x=m*b,{ctx:w}=function(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}(v,x);w.drawImage(t,0,0,v,x);const y=w.getImageData(0,0,v,x).data,$=e.chromaKey,S=null!=$&&!1!==$,C=!0===$,E="blue-screen"===$;let I=null,T=0;!S||C||E||(I=function(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}($),T=(e.chromaKeyTolerance??60)**2);let A=0,k=255;if(e.normalize){let t=255,e=0;for(let o=0;o<y.length;o+=4){if(S){const t=y[o],e=y[o+1],n=y[o+2];let r=!1;if(C)r=e>1.4*t&&e>1.4*n&&e>80;else if(E)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==I){const o=t-I.r,a=e-I.g,i=n-I.b;r=o*o+a*a+i*i<=T}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}A=t,k=e>t?e-t:255}const z=[],P=R(e.invert),q=S&&e.charset.replace(/ /g,"")||e.charset,B=p*b;for(let t=0;t<m;t++){const o=[];for(let n=0;n<M;n++){let r=0,a=0,i=0,c=0,f=0;for(let e=0;e<b;e++){const o=(t*b+e)*v;for(let t=0;t<p;t++){const e=4*(o+n*p+t),s=y[e],l=y[e+1],h=y[e+2],d=y[e+3];if(S){let t=!1;if(C)t=l>1.4*s&&l>1.4*h&&l>80;else if(E)t=h>1.4*s&&h>1.4*l&&h>80;else if(null!==I){const e=s-I.r,o=l-I.g,n=h-I.b;t=e*e+o*o+n*n<=T}if(t){f++;continue}}r+=s,a+=l,i+=h,c+=d}}if(S&&f>B/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const g=B-f,u=g>0?r/g:0,m=g>0?a/g:0,x=g>0?i/g:0,w=g>0?c/g:0,$=.299*u+.587*m+.114*x,R=d(s(e.normalize?($-A)/k*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),z=e.customText?h(R,e.customText,n,t,M,P):l(R,q,P);o.push({char:z,r:u,g:m,b:x,a:w,lum:R})}z.push(o)}return{frame:z,cols:M,rows:m}}async function z(t,e,o,n,r=12,a=10,i,c=0){const s=Math.min(t.duration-c,a),l=Math.ceil(s*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const g=c+a/r;if(g>c+s)break;t.currentTime=g,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=k(t,e,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function P(o,n,r,a,i){const c=t(o),s=e(c,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const l=s[0].dims.width,h=s[0].dims.height,f=c.lsd?.width||l,d=c.lsd?.height||h,g=document.createElement("canvas");g.width=f,g.height=d;const u=g.getContext("2d"),M=document.createElement("canvas");M.width=f,M.height=d;const m=M.getContext("2d"),p=[];let b=0,v=0,x=0;for(const t of s)x+=t.delay||100;const w=x/s.length,y=Math.round(Math.min(30,Math.max(5,1e3/w))),$=Math.min(s.length,300);for(let t=0;t<$;t++){const e=s[t],{dims:o,patch:c,disposalType:l}=e;3===l&&(m.clearRect(0,0,f,d),m.drawImage(g,0,0));const h=new ImageData(new Uint8ClampedArray(c.buffer),o.width,o.height),x=document.createElement("canvas");x.width=o.width,x.height=o.height;x.getContext("2d").putImageData(h,0,0),u.drawImage(x,o.left||0,o.top||0);const w=k(g,n,r,a);p.push(w.frame),b=w.cols,v=w.rows,2===l?u.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(M,0,0)),i?.((t+1)/$)}return{frames:p,cols:b,rows:v,fps:y}}function q(t,e,o,n,r,a=0,i){if("waveField"===o.animationStyle){return void I(t,n,r,a,i?{x:i.x,y:i.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?A(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const c=e.length;if(0===c)return;const s=e[0].length;t.clearRect(0,0,n,r);let h=!1;const f=Math.max(1,c>>2),d=Math.max(1,s>>2);t:for(let t=0;t<c;t+=f){const o=e[t];for(let t=0;t<s;t+=d)if(o[t].a<200){h=!0;break t}}if(!h){const e="undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches;t.fillStyle=e?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r)}const g=n/s,u=r/c,m=c*s,v=i?.intensity??1,w=!("none"!==o.animationStyle&&m>5e3)&&!!(i&&o.hoverStrength>0&&v>.005),y=o.hoverColor||"#ffffff",$=parseInt(y.slice(1,3),16)||255,S=parseInt(y.slice(3,5),16)||255,C=parseInt(y.slice(5,7),16)||255,E=A(o.accentColor),T=parseInt(E.substring(0,2),16)||255,k=parseInt(E.substring(2,4),16)||255,z=parseInt(E.substring(4,6),16)||255,P=m>3e4?.25:m>15e3?.4:m>5e3?.6:1,q=o.hoverRadius*P;let B=0,F=s,L=0,H=c,j=0,W=0;if(w&&i){j=i.x,W=i.y;const t=.08+.35*q+.04*o.hoverStrength;B=Math.max(0,Math.floor((j-t)*s)-1),F=Math.min(s,Math.ceil((j+t)*s)+1),L=Math.max(0,Math.floor((W-t)*c)-1),H=Math.min(c,Math.ceil((W+t)*c)+1)}const O=o.animationStyle,Y=o.animationSpeed,U="none"===O,D=o.hoverStrength,X=o.hoverEffect,V=q,J=R(o.invert),N=o.colorMode,_=2*Math.PI,G=1/s,K=1/c;let Q="",Z=-1;if("dots"===o.renderMode){const n=.5*Math.min(g,u)*o.dotSizeRatio;for(let o=0;o<c;o++){const r=e[o];for(let e=0;e<s;e++){const i=r[e];if(i.a<10)continue;const l=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=J?1-l:l;if(h<.02)continue;const f=U?1:b(e,o,s,c,a,O,Y);let d=1,m=0,y=0,E=0,I=0;if(w&&e>=B&&e<=F&&o>=L&&o<=H){const t=x(e*G,o*K,j,W,v,D,g,u,X,V);d=t.scale,m=t.offsetX,y=t.offsetY,E=t.glow,I=t.colorBlend}const R=n*h*f*d;if(R<.3)continue;const A=e*g+.5*g+m,P=o*u+.5*u+y;let q;if(I>0){const t=p(i,N,T,k,z,J);q=`rgb(${Math.min(255,t[0]+($-t[0])*I|0)},${Math.min(255,t[1]+(S-t[1])*I|0)},${Math.min(255,t[2]+(C-t[2])*I|0)})`}else q=M(i,N,T,k,z,J);const tt=Math.min(1,.00392156863*i.a*f*(1+E));if(tt!==Z&&(t.globalAlpha=tt,Z=tt),q!==Q&&(t.fillStyle=q,Q=q),R<=3){const e=2*R;t.fillRect(A-R,P-R,e,e)}else t.beginPath(),t.arc(A,P,R,0,_),t.fill()}}}else{const n=.55,r=.9*Math.min(g/n,u),i=r<6;if(!i){const e="emoji"===o.artStyle;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"}let h=null;const f=o.charsetFrames,d=!!f?.length,m=d?f[Math.floor(Math.max(0,a)*(o.charsetFps??2))%f.length]:o.charset;if(i){h={};const t=[...m],e=t.length;for(let o=0;o<e;o++)h[t[o]]=Math.max(.1,(o+.3)/e)}const y=i?null:t.getTransform(),E="glitchText"===X&&w,I="!@#$%^&*<>{}[]|/\\~`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",R=I.length;let A="",P=[],q=0,_=0;if(E){const t=o.hoverText??"ASCIIFY";if(q=Math.round(j*s),_=Math.round(W*c),Array.isArray(t)){A=t[((7*Math.floor(q/Math.max(1,Math.ceil(s/5)))+13*Math.floor(_/Math.max(1,Math.ceil(c/3))))%t.length+t.length)%t.length]||t[0]||"ASCIIFY"}else A=t||"ASCIIFY";P=A.split("\n")}for(let o=0;o<c;o++){const n=e[o];for(let e=0;e<s;e++){const r=n[e];if(r.a<10)continue;let f=d&&null!=r.lum?l(r.lum,m,J):r.char;if(" "===f)continue;const A=U?1:b(e,o,s,c,a,O,Y);if(A<.05)continue;let tt=1,et=0,ot=0,nt=0,rt=0,at=0;if(w&&e>=B&&e<=F&&o>=L&&o<=H){const t=x(e*G,o*K,j,W,v,D,g,u,X,V);tt=t.scale,et=t.offsetX,ot=t.offsetY,nt=t.glow,rt=t.colorBlend,at=t.proximity}if(E&&at>0){const t=P[o-(_-Math.floor(P.length/2))];if(null!=t){const n=e-(q-Math.floor(t.length/2));if(n>=0&&n<t.length&&" "!==t[n]){const r=Math.max(0,(at-.15)/.55),i=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(10*a));f=i-Math.floor(i)<r?t[n]:I[Math.abs(Math.floor(97*i))%R],nt=Math.max(nt,.9*at),rt=Math.max(rt,.85*at)}else{const t=43758.5453*Math.sin(43.7*e+29.3*o+17.89*Math.floor(6*a));t-Math.floor(t)<.35*at&&(f=I[Math.abs(Math.floor(71*t))%R])}}else{const t=43758.5453*Math.sin(43.7*e+29.3*o+17.89*Math.floor(6*a));t-Math.floor(t)<.25*at&&(f=I[Math.abs(Math.floor(53*t))%R])}}const it=e*g+.5*g+et,ct=o*u+.5*u+ot;let st;if(rt>0){const t=p(r,N,T,k,z,J);st=`rgb(${Math.min(255,t[0]+($-t[0])*rt|0)},${Math.min(255,t[1]+(S-t[1])*rt|0)},${Math.min(255,t[2]+(C-t[2])*rt|0)})`}else st=M(r,N,T,k,z,J);if(i){const e=h[f]??.5,o=Math.min(1,.00392156863*r.a*A*(1+nt))*e;if(o<.02)continue;o!==Z&&(t.globalAlpha=o,Z=o),st!==Q&&(t.fillStyle=st,Q=st);const n=g*tt,a=u*tt;t.fillRect(it-.5*n,ct-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*A*(1+nt));e!==Z&&(t.globalAlpha=e,Z=e),st!==Q&&(t.fillStyle=st,Q=st),1!==tt?(t.translate(it,ct),t.scale(tt,tt),t.fillText(f,0,0),t.setTransform(y)):t.fillText(f,it,ct)}}}}t.globalAlpha=1}function B(t,e){const o=Math.min(1,2048/Math.max(t,e));return{renderW:Math.round(t*o),renderH:Math.round(e*o)}}function F(t,e,o,n,r){const{width:a,height:i}=e.getBoundingClientRect();if(!a||!i)return{renderW:0,renderH:0,dpr:1};let c,s,l=a,h=l/o;h>i&&(h=i,l=h*o),l=Math.round(l),h=Math.round(h),n&&r?({renderW:c,renderH:s}=B(n,r)):(c=l,s=h);const f="undefined"!=typeof window&&window.devicePixelRatio||1,d=8e6,g=c*f*s*f>d?Math.sqrt(d/(c*s)):f;return t.width=Math.round(c*g),t.height=Math.round(s*g),t.style.width=l+"px",t.style.height=h+"px",{renderW:c,renderH:s,dpr:g}}async function L(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){let c;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),c=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),c=t):c=t;const s=a[n],l=o??r.fontSize??10,h={...i,...s,...r,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:g}=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}}(c),{renderW:u,renderH:M}=B(d,g),m="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,b=u*m*M*m>p?Math.sqrt(p/(u*M)):m;(e.width<u||e.height<M)&&(e.width=Math.round(u*b),e.height=Math.round(M*b));const{frame:v}=k(c,h,u,M);f.save(),f.setTransform(b,0,0,b,0,0),q(f,v,h,u,M),f.restore()}async function H(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){const c="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??r.fontSize??10,l={...i,...a[n],...r,fontSize:s},h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:f,fps:d}=await P(c,l,e.width,e.height);let g,u=!1,M=0,m=performance.now();const p=1e3/d,b=t=>{u||(t-m>=p&&(q(h,f[M],l,e.width,e.height),M=(M+1)%f.length,m=t),g=requestAnimationFrame(b))};return g=requestAnimationFrame(b),()=>{u=!0,cancelAnimationFrame(g)}}async function j(t,e,{fontSize:o,artStyle:n="classic",options:r={},fitTo:c,preExtract:s=!1,trim:l,onReady:h,onFrame:f}={}){const d=l?.start??0,g=l?.end,u=o??r.fontSize??10,M={...i,...a[n],...r,fontSize:u},m=e.getContext("2d");if(!m)throw new Error("asciifyVideo: could not get 2d context from canvas.");const p="string"==typeof c?document.querySelector(c):c instanceof HTMLElement?c:null;if(s){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,p&&F(e,p,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight);const{renderW:n,renderH:r}=B(o.videoWidth,o.videoHeight),a="undefined"!=typeof window&&window.devicePixelRatio||1,i=8e6,c=n*a*r*a>i?Math.sqrt(i/(n*r)):a;e.width<Math.round(n*c)&&(e.width=Math.round(n*c),e.height=Math.round(r*c));const s=void 0!==g?g-d:10,{frames:l,fps:u}=await z(o,M,n,r,void 0,s,void 0,d);let b,v=!1,x=0,w=performance.now(),y=!0;const $=1e3/u,S=t=>{v||(t-w>=$&&(m.save(),m.setTransform(c,0,0,c,0,0),q(m,l[x],M,n,r),m.restore(),x=(x+1)%l.length,w=t,y&&(y=!1,h?.(o)),f?.()),b=requestAnimationFrame(S))};return b=requestAnimationFrame(S),()=>{v=!0,cancelAnimationFrame(b)}}let b,v=!1;"string"==typeof t?(b=document.createElement("video"),b.src=t,b.muted=!0,b.loop=!0,b.playsInline=!0,b.setAttribute("playsinline",""),Object.assign(b.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(b),v=!0,await new Promise((e,o)=>{b.onloadedmetadata=()=>e(),b.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await b.play().catch(()=>{})):(b=t,b.paused&&await b.play().catch(()=>{})),d>0&&(b.currentTime=d,await new Promise(t=>{const e=()=>{b.removeEventListener("seeked",e),t()};b.addEventListener("seeked",e)}));let x=null;(d>0||void 0!==g)&&(x=()=>{(void 0!==g&&b.currentTime>=g||d>0&&b.currentTime<d)&&(b.currentTime=d)},b.addEventListener("timeupdate",x));let w=null;const{renderW:y,renderH:$}=B(b.videoWidth,b.videoHeight);if(p){const t=b.videoWidth/b.videoHeight,o=b.videoWidth,n=b.videoHeight,r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),w=new ResizeObserver(()=>{const r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),w.observe(p)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=y*t*$*t>o?Math.sqrt(o/(y*$)):t;e.width<Math.round(y*n)&&(e.width=Math.round(y*n),e.height=Math.round($*n)),m.setTransform(n,0,0,n,0,0)}let S,C=!1,E=!0;const I=()=>{if(C)return;if(S=requestAnimationFrame(I),b.readyState<2||0===e.width||0===e.height)return;if(d>0&&b.currentTime<d)return;if(void 0!==g&&b.currentTime>=g)return;const{frame:t}=k(b,M,y,$);t.length>0&&(q(m,t,M,y,$,0,null),E&&(E=!1,h?.(b)),f?.())};return S=requestAnimationFrame(I),()=>{C=!0,cancelAnimationFrame(S),w?.disconnect(),x&&b.removeEventListener("timeupdate",x),v&&(b.pause(),b.src="",document.body.removeChild(b))}}function W(t,e,o){return j(t,e,o)}function O(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:c,color:s,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,g=c??(d?"#6b8700":"#d4ff00"),u=.62*a,M=1.4*a,m=Math.ceil(e/u),p=Math.ceil(o/M);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let b=255,v=255,x=255;if(d&&(b=55,v=55,x=55),s){const t=w(s);t&&(b=t.r,v=t.g,x=t.b)}let y=212,$=255,C=0;const E=w(g);E&&(y=E.r,$=E.g,C=E.b);const I=p+f;for(let e=0;e<m;e++){if(S(17*e,3)>h)continue;const o=(.5+1.5*S(31*e,7))*l,r=S(13*e,11)*I,a=Math.floor((n*o*7+r)%I),c=e*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const s=r*M,l=S(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],g=o/f;if(o===f)t.fillStyle=`rgba(${y},${$},${C},${d?.7:.85})`;else{const e=d?.85*g:.15*g;t.fillStyle=`rgba(${b},${v},${x},${e})`}t.fillText(h,c,s)}}}function Y(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" . · * + ° ★",accentColor:s,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,g=s??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),M=o*(.2+.6*r.y),m=.65*Math.sqrt(e*e+o*o);let p=255,b=255,v=255;if(d&&(p=55,b=55,v=55),l){const t=w(l);t&&(p=t.r,b=t.g,v=t.b)}let x=212,y=255,$=0;const C=w(g);C&&(x=C.r,y=C.g,$=C.b);const E=c.replace(/ /g,"").split("");if(0!==E.length){for(let r=0;r<f;r++){const a=S(17*r,3)*Math.PI*2,c=(n*(.15+.85*S(31*r,7))*h*.22+S(13*r,11))%1,s=u+Math.cos(a)*c*m,l=M+Math.sin(a)*c*m;if(s<-20||s>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*c));t.font=`${f}px monospace`;const g=E[Math.min(E.length-1,Math.floor(c*E.length))],w=c>.72,C=d?.85*c:.2*c;t.fillStyle=w?`rgba(${x},${y},${$},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${b},${v},${C})`,t.fillText(g,s,l)}t.textAlign="left"}}function U(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=". · ○ ◎ ●",accentColor:s,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:g=!1}=a,u=s??(g?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const M=e*r.x,m=o*r.y,p=1.6*Math.sqrt(M*M+m*m)+.2*Math.sqrt(e*e+o*o);let b=255,v=255,x=255;if(g&&(b=55,v=55,x=55),l){const t=w(l);t&&(b=t.r,v=t.g,x=t.b)}let y=0,$=255,S=204;const C=w(u);C&&(y=C.r,$=C.g,S=C.b);const E=c.replace(/ /g,"").split("");if(0===E.length)return;const I=Math.ceil(e/i),R=Math.ceil(o/i);for(let e=0;e<R;e++)for(let o=0;o<I;o++){const r=o*i+.5*i,a=e*i+.5*i,c=r-M,s=a-m,l=Math.sqrt(c*c+s*s)/p;let u=0;for(let t=0;t<h;t++){const e=(n*f*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const w=u>.6;t.font=`${i}px monospace`;const C=Math.floor(u*(E.length-1)),I=E[Math.min(C,E.length-1)],R=g?.88*u:.22*u;t.fillStyle=w?`rgba(${y},${$},${S},${Math.min(g?.95:.4,.55*u)})`:`rgba(${b},${v},${x},${R})`,t.fillText(I,r,a)}t.textAlign="left"}function D(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" .·:;=+*#%@░▒▓",accentColor:s,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:g=.78,mouseWarp:u=.3,lightMode:M=!1}=a,m=s??(M?"#6b8700":"#d4ff00"),p=.62*i,b=1.4*i,v=Math.ceil(e/p),x=Math.ceil(o/b);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,$=255,S=255;if(M&&(y=55,$=55,S=55),l){const t=w(l);t&&(y=t.r,$=t.g,S=t.b)}let E=212,I=255,R=0;const T=w(m);T&&(E=T.r,I=T.g,R=T.b);const A=.035*d,k=n*f,z=Math.min(6,Math.max(1,h)),P=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<z;i++)o+=C(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<x;e++)for(let o=0;o<v;o++){const n=o*A+.06*k,a=e*A*1.3-.04*k,i=o/v-r.x,s=e/x-r.y,l=Math.sqrt(i*i+s*s),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*P(n+h*Math.sin(1.3*k+8*s),a+h*Math.cos(.9*k+8*i))+.5;if(f<.12)continue;const d=c[Math.floor(f*(c.length-1))];if(" "===d)continue;const m=f>g,w=M?.82*f:.13*f;t.fillStyle=m?`rgba(${E},${I},${R},${M?.92:.28})`:`rgba(${y},${$},${S},${w})`,t.fillText(d,o*p,e*b)}}function X(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:c="·-=+|/",accentColor:s,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:g=!0,lightMode:u=!1}=a,M=s??(u?"#6b8700":"#d4ff00"),m=.62*i,p=1.4*i,b=Math.ceil(e/m),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,$=255;if(u&&(x=55,y=55,$=55),l){const t=w(l);t&&(x=t.r,y=t.g,$=t.b)}let C=212,E=255,I=0;const R=w(M);R&&(C=R.r,E=R.g,I=R.b);const T=n*f;for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=e/v,a=((n*h-.5*T)%1+1)%1,i=Math.max(0,1-a/d),s=.35*(.5*S(3*o,7*e)+.5);let l=0;if(g){const t=o/b-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=S(11*o+Math.floor(12*T),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,s+.8*i+.6*l);if(f<.04)continue;const M=c[Math.floor(f*(c.length-1))],w=i>.55,R=u?.82*f:.12*f;t.fillStyle=w?`rgba(${C},${E},${I},${u?.92:.28})`:`rgba(${x},${y},${$},${R})`,t.fillText(M,o*m,e*p)}}function V(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" ·∙•:;+=≡≣#@",color:s,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:g=.2,lightMode:u=!1}=a,M=l??(u?"#6b8700":"#d4ff00"),m=.62*i,p=1.4*i,b=Math.ceil(e/m),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,$=255;if(u&&(x=55,y=55,$=55),s){const t=w(s);t&&(x=t.r,y=t.g,$=t.b)}let C=212,E=255,I=0;const R=w(M);R&&(C=R.r,E=R.g,I=R.b);const T=n*h,A=[];for(let t=0;t<f;t++){const e=S(17*t,31*t+7),o=S(23*t+5,11*t);A.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*S(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*S(29*t,3*t)})}for(let e=0;e<v;e++){const o=e/v;for(let n=0;n<b;n++){const a=n/b,i=a-r.x,s=o-r.y,l=Math.sqrt(i*i+s*s),h=g*Math.exp(-l*l/.06),M=a+i*h,v=o+s*h;let w=0,S=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=A[t];w+=Math.sin(M*e*Math.PI*2+T*r+n)*Math.cos(v*o*Math.PI*2+T*r*.7+1.3*n)*a,S+=a}const R=w/S,k=.5+.5*Math.tanh(R*d*2.2);if(k<.12)continue;const z=(k-.12)/.88,P=c[Math.min(c.length-1,Math.floor(z*c.length))],q=k>.82,B=u?.82*k:.14*k;t.fillStyle=q?`rgba(${C},${E},${I},${u?.92:.32})`:`rgba(${x},${y},${$},${B})`,t.fillText(P,n*m,e*p)}}}function J(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:c,speed:s=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,M=Math.ceil(e/g),m=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),i){const t=w(i);t&&(p=t.r,b=t.g,v=t.b)}let x=212,y=255,$=0;const C=w(d);C&&(x=C.r,y=C.g,$=C.b);const E=n*s,I=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<m;e++){const o=e/m;for(let n=0;n<M;n++){const r=n/M;let a=0,i=0;for(let t=0;t<l;t++){const e=S(13*t,7*t+3),n=1.1+2.4*e,c=.9+2*S(29*t,11*t+1),s=e*Math.PI*6,l=(.2+.5*S(41*t,17*t))*(t%2==0?1:-1.3),f=Math.sin(r*n*Math.PI*2+E*l+s),d=Math.cos(o*c*Math.PI*2+E*l*.6+1.7*s),g=Math.sin(r*c*Math.PI*h+o*n*Math.PI*h+E*l*.4);a+=Math.atan2(d+.3*g,f),i+=.5*(f*d+1)}const c=a/l,s=Math.min(1,i/l);if(s<.1)continue;const d=(c+Math.PI)/(2*Math.PI),m=I[Math.floor(d*I.length)%I.length],w=s>.8,C=f?.8*s:.13*s;t.fillStyle=w?`rgba(${x},${y},${$},${f?.9:.26})`:`rgba(${p},${b},${v},${C})`,t.fillText(m,n*g,e*u)}}}function N(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:c=" ·:;=+*#%@",color:s,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:g=!1}=a,u=l??(g?"#6b8700":"#d4ff00"),M=.62*i,m=1.4*i,p=Math.ceil(e/M),b=Math.ceil(o/m),v=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,$=255;if(g&&(x=55,y=55,$=55),s){const t=w(s);t&&(x=t.r,y=t.g,$=t.b)}let C=212,E=255,I=0;const R=w(u);R&&(C=R.r,E=R.g,I=R.b);const T=n*h;for(let e=0;e<b;e++){const o=e/b;for(let n=0;n<p;n++){const a=(n/p-r.x)*v,i=o-r.y,s=Math.sqrt(a*a+i*i)/f;if(s>1){const o=S(3*n,7*e)*Math.max(0,1-3*(s-1));if(o<.62)continue;const r=o*(g?.28:.04);t.fillStyle=`rgba(${x},${y},${$},${r})`,t.fillText(c[1],n*M,e*m);continue}const l=Math.max(0,1-Math.abs(s-(.15+.12*Math.sin(1.1*T)))/.07),h=Math.pow(1-s,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(c.length-1)),b=c[Math.min(c.length-1,u)],w=l>.35||s<.08,R=g?.85*d:.18*d;t.fillStyle=w?`rgba(${C},${E},${I},${g?.95:.38})`:`rgba(${x},${y},${$},${R})`,t.fillText(b,n*M,e*m)}}}function _(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:c,accentColor:s,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,M=Math.ceil(e/g),m=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),c){const t=w(c);t&&(p=t.r,b=t.g,v=t.b)}let x=212,y=255,$=0;const C=w(d);C&&(x=C.r,y=C.g,$=C.b);const E=n*l,I=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<m;e++)for(let o=0;o<M;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*S(o*(t+3)+7,e*(t+5)+11),a=S(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin(E*r+a)*i}const r=.5*(n/I+1);if(r<.28)continue;const a=(r-.28)/.72,c=i[Math.min(i.length-1,Math.floor(a*i.length))],s=r>.88,l=f?.82*a:.13*a;t.fillStyle=s?`rgba(${x},${y},${$},${f?.92:.28})`:`rgba(${p},${b},${v},${l})`,t.fillText(c,o*g,e*u)}}function G(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:c="#ff4500",hotColor:s="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,g=.62*a,u=1.4*a,M=Math.ceil(e/g),m=Math.ceil(o/u),p=M*m,b="__fire_heat__",v=t.canvas;let x=v[b];x&&x.length===p||(x=new Float32Array(p),v[b]=x);const y=.18*(.016*f),$=h*f*.8,S=m-1,C=n*f;for(let t=0;t<M;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*l;x[S*M+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(x[(S-1)*M+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<m-2;t++)for(let e=0;e<M;e++){const o=.4*x[(t+1)*M+e]+.25*x[(t+2)*M+Math.max(0,Math.min(M-1,e+Math.round($)))]+.175*x[(t+1)*M+Math.max(0,e-1)]+.175*x[(t+1)*M+Math.min(M-1,e+1)];E[t*M+e]=Math.max(0,o-y-.02*Math.random()*f)}for(let t=0;t<M;t++)E[(m-1)*M+t]=x[(m-1)*M+t],m>1&&(E[(m-2)*M+t]=x[(m-2)*M+t]);v[b]=E;const I=w(c)??{r:255,g:69,b:0},R=w(s)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<m;e++)for(let o=0;o<M;o++){const n=E[e*M+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),c=I.r+(R.r-I.r)*a|0,s=I.g+(R.g-I.g)*a|0,l=I.b+(R.b-I.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${c},${s},${l})`,t.fillText(r,o*g,e*u)}t.globalAlpha=1}function K(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:c="-=≡",color:s="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:g=!1}=r,u=.62*a,M=1.4*a,m=Math.ceil(e/u),p=Math.ceil(o/M),b=d??Math.max(1,Math.floor(e/80)),v=m/b,x=w(s)??{r:0,g:229,b:255},y=w(l)??{r:255,g:64,b:129},$=w(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const C=n*f,E=.35*v;for(let e=0;e<b;e++){const o=v*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*C,a=o+Math.sin(r)*E,s=o+Math.sin(r+Math.PI)*E,l=Math.round(a),h=Math.round(s);if(l<0||l>=m)continue;const f=S(31*e+7*n,3),d=i[Math.floor(f*i.length)],g=.5*(Math.sin(r)+1),b=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*g,t.fillStyle=`rgb(${x.r},${x.g},${x.b})`,t.fillText(d,l*u,n*M),h>=0&&h<m){const o=S(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*b,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`,t.fillText(r,h*u,n*M)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=S(17*n+43*e,5),i=c[Math.floor(a*c.length)],s=.25*(g+b)+.2;t.globalAlpha=s,t.fillStyle=`rgb(${$.r},${$.g},${$.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*M)}}}}t.globalAlpha=1}function Q(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:c="#4caf50",skyColor:s="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:g=!0,lightMode:u=!1}=r,M=.62*a,m=1.4*a,p=Math.ceil(e/M),b=Math.ceil(o/m),v=w(c)??{r:76,g:175,b:80},x=w(s)??{r:26,g:35,b:126},y=w(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const $=n*h*.4,C=new Array(p);for(let t=0;t<p;t++){const e=(.5*E((t/p+$)*f*3,.5)+.5)*d;C[t]=Math.floor(e*b)}for(let e=0;e<b;e++)for(let o=0;o<p;o++){const r=b-1-C[o],a=e===r;if(!(e>=r)){if(g){const r=S(7*o+Math.floor(.3*$),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${x.r+60},${x.g+60},${x.b+80})`,t.fillText("·",o*M,e*m)}}continue}const c=(e-r)/Math.max(1,C[o]),s=i[Math.min(i.length-1,Math.floor(c*i.length))];if(" "===s&&!a)continue;const l=a?1:Math.max(0,1-4*c),h=v.r+(y.r-v.r)*l|0,f=v.g+(y.g-v.g)*l|0,d=v.b+(y.b-v.b)*l|0;t.globalAlpha=.5+.5*c,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:s,o*M,e*m)}t.globalAlpha=1}var Z=1,tt=2,et=4,ot=8,nt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[Z]:"╶",[tt]:"╴",[et]:"╵",[ot]:"╷"};function rt(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:c="#00ff88",density:s=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,g=Math.ceil(e/f),u=Math.ceil(o/d),M=w(c)??{r:0,g:255,b:136},m=w(i)??{r:255,g:255,b:255},p=(t,e)=>{if(S(17*t+1,7*e+2)>s)return 0;let o=0;return t+1<g&&S(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&S(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&S(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&S(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const b=n*l;for(let e=0;e<u;e++)for(let o=0;o<g;o++){const n=p(o,e);if(0===n)continue;const r=nt[n]??"·",a=(8*b+40*S(o,23*e))%g,i=(6*b+40*S(17*e,11*o))%u,c=(1&n||2&n)&&Math.abs(o-a)<1.5,s=(4&n||8&n)&&Math.abs(e-i)<1.5,l=c||s,h=.25+.35*S(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${m.r},${m.g},${m.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}var at=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function it(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:c,...s}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),g=window.devicePixelRatio||1,u={x:.5,y:.5},M={x:.5,y:.5},m=window.matchMedia("(prefers-color-scheme: light)"),p=()=>"light"===i||"dark"!==i&&m.matches,b=c?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 o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(c):null,v=()=>({...s,lightMode:void 0!==s.lightMode?s.lightMode:p(),baseColor:b?`rgba(${b.r},${b.g},${b.b},{a})`:s.baseColor}),x={current:v()},w=()=>{x.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...s,lightMode:void 0!==s.lightMode?s.lightMode:p(),color:c??s.color}:"fire"===o||"dna"===o?{...s,color:c??s.color}:"terrain"===o||"circuit"===o?{...s,color:c??s.color,lightMode:void 0!==s.lightMode?s.lightMode:p()}:v()};w();const y=()=>{w()};"auto"===i&&m.addEventListener("change",y);const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*g,f.height=t.height*g,d.setTransform(g,0,0,g,0,0)};$();const S=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},C=new ResizeObserver($);C.observe(l),window.addEventListener("mousemove",S);let E=0,R=0;const T=()=>{M.x+=.07*(u.x-M.x),M.y+=.07*(u.y-M.y);const t=l.getBoundingClientRect();"rain"===o?O(d,t.width,t.height,E,x.current):"stars"===o?Y(d,t.width,t.height,E,M,x.current):"pulse"===o?U(d,t.width,t.height,E,M,x.current):"noise"===o?D(d,t.width,t.height,E,M,x.current):"grid"===o?X(d,t.width,t.height,E,M,x.current):"aurora"===o?V(d,t.width,t.height,E,M,x.current):"silk"===o?J(d,t.width,t.height,E,x.current):"void"===o?N(d,t.width,t.height,E,M,x.current):"morph"===o?_(d,t.width,t.height,E,x.current):"fire"===o?G(d,t.width,t.height,E,x.current):"dna"===o?K(d,t.width,t.height,E,x.current):"terrain"===o?Q(d,t.width,t.height,E,x.current):"circuit"===o?rt(d,t.width,t.height,E,x.current):I(d,t.width,t.height,E,M,x.current),E+=.016,R=requestAnimationFrame(T)};return R=requestAnimationFrame(T),{destroy:()=>{cancelAnimationFrame(R),C.disconnect(),"auto"===i&&m.removeEventListener("change",y),window.removeEventListener("mousemove",S),f.remove(),l.style.position=h}}}var ct=it;function st(t,e={},o,n){const r={...i,...e},{frame:a,cols:c}=k(t,r,o,n);if(!a.length||0===c)return"";const s=[];for(const t of a)s.push(t.map(t=>t.char).join(""));return s.join("\n")}function lt(t,e={},o,n){const r={...i,...e},{frame:a,cols:c}=k(t,r,o,n);if(!a.length||0===c)return"";const s=[];for(const t of a){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}[0m`;s.push(e)}return s.join("\n")}function ht(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=w(n)??{r:80,g:80,b:80},i=t,c=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%c],r:a.r,g:a.g,b:a.b,a:r})))}function ft(t,e,o,n,r={},a){const{fontSize:c=10,lineHeight:s=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:g=.18,hoverColor:u="#d4ff00"}=r;q(t,ht(n,Math.max(1,Math.floor(e/c)),Math.max(1,Math.floor(o/(c*s))),l,h),{...i,hoverEffect:f,hoverStrength:d,hoverRadius:g,hoverColor:u},e,o,0,a??null)}function dt(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}async function gt(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await dt(t,{format:n,...r}),i="jpeg"===n?"jpg":n,c=document.createElement("a");c.href=URL.createObjectURL(a),c.download=`${o}.${i}`,c.click(),setTimeout(()=>URL.revokeObjectURL(c.href),1e4)}async function ut(t,{fontSize:e=10,style:o="classic",options:n={},liveOptions:r,mirror:c=!0,constraints:s={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:s}),f=document.createElement("video");f.srcObject=h,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 d={...i,...a[o],...n,fontSize:e},g=t.getContext("2d");if(!g)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&g.scale(u,u);let M=null;const m={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();M={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},b=()=>{M=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b));let v,x=!1;const w=performance.now(),y=e=>{if(!x){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,a=(e-w)/1e3,i=r?{...d,...r()}:d;i.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b));const{frame:s}=k(f,i,o,n);if(M){const t=M.x-m.x,e=M.y-m.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);m.x+=t*n,m.y+=e*n,m.intensity+=.12*(1-m.intensity)}else m.intensity*=.965,m.intensity<.003&&(m.intensity=0);const l=m.intensity>.003?{x:m.x,y:m.y,intensity:m.intensity}:null;c?(g.save(),g.scale(-1,1),g.translate(-o,0),q(g,s,i,o,n,a,l),g.restore()):q(g,s,i,o,n,a,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{x=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}export{a as ART_STYLE_PRESETS,at as BACKGROUND_TYPES,n as CHARSETS,r as CHARSET_SEQUENCES,i as DEFAULT_OPTIONS,c as HOVER_PRESETS,o as PALETTE_THEMES,it as asciiBackground,st as asciiText,lt as asciiTextAnsi,L as asciify,H as asciifyGif,W as asciifyLiveVideo,j as asciifyVideo,ut as asciifyWebcam,ht as buildTextFrame,dt as captureSnapshot,P as gifToAsciiFrames,k as imageToAsciiFrame,ct as mountWaveBackground,V as renderAuroraBackground,rt as renderCircuitBackground,K as renderDnaBackground,G as renderFireBackground,q as renderFrameToCanvas,X as renderGridBackground,_ as renderMorphBackground,D as renderNoiseBackground,U as renderPulseBackground,O as renderRainBackground,J as renderSilkBackground,Y as renderStarsBackground,Q as renderTerrainBackground,ft as renderTextBackground,N as renderVoidBackground,I as renderWaveBackground,gt as snapshotAndDownload,z as videoToAsciiFrames};//# sourceMappingURL=index.js.map
|