asciify-engine 1.0.75 → 1.0.77

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.d.cts CHANGED
@@ -1120,4 +1120,64 @@ interface WebcamOptions {
1120
1120
  */
1121
1121
  declare function asciifyWebcam(canvas: HTMLCanvasElement, { fontSize, style, options, liveOptions, mirror, constraints, dpr: dprOverride, }?: WebcamOptions): Promise<() => void>;
1122
1122
 
1123
- export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifyLiveVideoOptions, type AsciifySimpleOptions, type AsciifyVideoOptions, type AuroraBackgroundOptions, BACKGROUND_TYPES, type BackgroundType, CHARSETS, CHARSET_SEQUENCES, type CharsetKey, type CharsetSequenceKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type HoverShape, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type RenderMode, type SilkBackgroundOptions, type SnapshotOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type TextBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebcamOptions, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyLiveVideo, asciifyVideo, asciifyWebcam, buildTextFrame, captureSnapshot, gifToAsciiFrames, imageToAsciiFrame, mountWaveBackground, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderFrameToCanvas, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderTextBackground, renderVoidBackground, renderWaveBackground, snapshotAndDownload, videoToAsciiFrames };
1123
+ /**
1124
+ * big-text.ts — ASCII text rendering via an embedded 7×7 bitmap font.
1125
+ *
1126
+ * Each character is defined as 7 rows × 7 pixels stored as compact bit-patterns.
1127
+ * No canvas, no font files, no pixel-sampling — output is always crisp and readable.
1128
+ *
1129
+ * @example
1130
+ * ```ts
1131
+ * import { asciifyText } from 'asciify-engine';
1132
+ * console.log(asciifyText('Hello!'));
1133
+ * console.log(asciifyText('v2', { scale: 2, char: '#' }));
1134
+ * ```
1135
+ */
1136
+ interface BigTextOptions {
1137
+ /**
1138
+ * Character used for ink pixels. Any single grapheme — emoji work too.
1139
+ * @default '█'
1140
+ */
1141
+ char?: string;
1142
+ /**
1143
+ * Pixel scale factor.
1144
+ * `1` = each font pixel → 1 char (output is 7 rows tall).
1145
+ * `2` = each pixel → 2×2 chars (14 rows tall), etc.
1146
+ * @default 1
1147
+ */
1148
+ scale?: number;
1149
+ /** Foreground colour (canvas output only). @default '#d4ff00' */
1150
+ color?: string;
1151
+ /** Background colour (canvas output only). @default transparent */
1152
+ bgColor?: string;
1153
+ /** Physical character cell size in px (canvas output only). @default 10 */
1154
+ fontSize?: number;
1155
+ }
1156
+ /**
1157
+ * Convert a string to multi-line ASCII text art.
1158
+ *
1159
+ * Uses an embedded 7×7 pixel bitmap font — no font files, no install step,
1160
+ * works in every JS environment (browser, Node, Deno, Bun).
1161
+ *
1162
+ * @example
1163
+ * ```ts
1164
+ * import { asciifyText } from 'asciify-engine';
1165
+ * console.log(asciifyText('Hello!'));
1166
+ * console.log(asciifyText('v2.0', { char: '#' }));
1167
+ * console.log(asciifyText('WOW', { scale: 2, char: '▓' }));
1168
+ * ```
1169
+ */
1170
+ declare function asciifyText(text: string, options?: BigTextOptions): string;
1171
+ /**
1172
+ * Render ASCII text directly onto an HTMLCanvasElement.
1173
+ * The canvas is automatically resized to fit the output.
1174
+ *
1175
+ * @example
1176
+ * ```ts
1177
+ * import { renderTextToCanvas } from 'asciify-engine';
1178
+ * renderTextToCanvas(canvas, 'Hello!', { color: '#d4ff00', scale: 2 });
1179
+ * ```
1180
+ */
1181
+ declare function renderTextToCanvas(canvas: HTMLCanvasElement, text: string, options?: BigTextOptions): void;
1182
+
1183
+ export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifyLiveVideoOptions, type AsciifySimpleOptions, type AsciifyVideoOptions, type AuroraBackgroundOptions, BACKGROUND_TYPES, type BackgroundType, type BigTextOptions, CHARSETS, CHARSET_SEQUENCES, type CharsetKey, type CharsetSequenceKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type HoverShape, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type RenderMode, type SilkBackgroundOptions, type SnapshotOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type TextBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebcamOptions, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyLiveVideo, asciifyText, asciifyVideo, asciifyWebcam, buildTextFrame, captureSnapshot, gifToAsciiFrames, imageToAsciiFrame, mountWaveBackground, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderFrameToCanvas, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderTextBackground, renderTextToCanvas, renderVoidBackground, renderWaveBackground, snapshotAndDownload, videoToAsciiFrames };
package/dist/index.d.ts CHANGED
@@ -1120,4 +1120,64 @@ interface WebcamOptions {
1120
1120
  */
1121
1121
  declare function asciifyWebcam(canvas: HTMLCanvasElement, { fontSize, style, options, liveOptions, mirror, constraints, dpr: dprOverride, }?: WebcamOptions): Promise<() => void>;
1122
1122
 
1123
- export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifyLiveVideoOptions, type AsciifySimpleOptions, type AsciifyVideoOptions, type AuroraBackgroundOptions, BACKGROUND_TYPES, type BackgroundType, CHARSETS, CHARSET_SEQUENCES, type CharsetKey, type CharsetSequenceKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type HoverShape, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type RenderMode, type SilkBackgroundOptions, type SnapshotOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type TextBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebcamOptions, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyLiveVideo, asciifyVideo, asciifyWebcam, buildTextFrame, captureSnapshot, gifToAsciiFrames, imageToAsciiFrame, mountWaveBackground, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderFrameToCanvas, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderTextBackground, renderVoidBackground, renderWaveBackground, snapshotAndDownload, videoToAsciiFrames };
1123
+ /**
1124
+ * big-text.ts — ASCII text rendering via an embedded 7×7 bitmap font.
1125
+ *
1126
+ * Each character is defined as 7 rows × 7 pixels stored as compact bit-patterns.
1127
+ * No canvas, no font files, no pixel-sampling — output is always crisp and readable.
1128
+ *
1129
+ * @example
1130
+ * ```ts
1131
+ * import { asciifyText } from 'asciify-engine';
1132
+ * console.log(asciifyText('Hello!'));
1133
+ * console.log(asciifyText('v2', { scale: 2, char: '#' }));
1134
+ * ```
1135
+ */
1136
+ interface BigTextOptions {
1137
+ /**
1138
+ * Character used for ink pixels. Any single grapheme — emoji work too.
1139
+ * @default '█'
1140
+ */
1141
+ char?: string;
1142
+ /**
1143
+ * Pixel scale factor.
1144
+ * `1` = each font pixel → 1 char (output is 7 rows tall).
1145
+ * `2` = each pixel → 2×2 chars (14 rows tall), etc.
1146
+ * @default 1
1147
+ */
1148
+ scale?: number;
1149
+ /** Foreground colour (canvas output only). @default '#d4ff00' */
1150
+ color?: string;
1151
+ /** Background colour (canvas output only). @default transparent */
1152
+ bgColor?: string;
1153
+ /** Physical character cell size in px (canvas output only). @default 10 */
1154
+ fontSize?: number;
1155
+ }
1156
+ /**
1157
+ * Convert a string to multi-line ASCII text art.
1158
+ *
1159
+ * Uses an embedded 7×7 pixel bitmap font — no font files, no install step,
1160
+ * works in every JS environment (browser, Node, Deno, Bun).
1161
+ *
1162
+ * @example
1163
+ * ```ts
1164
+ * import { asciifyText } from 'asciify-engine';
1165
+ * console.log(asciifyText('Hello!'));
1166
+ * console.log(asciifyText('v2.0', { char: '#' }));
1167
+ * console.log(asciifyText('WOW', { scale: 2, char: '▓' }));
1168
+ * ```
1169
+ */
1170
+ declare function asciifyText(text: string, options?: BigTextOptions): string;
1171
+ /**
1172
+ * Render ASCII text directly onto an HTMLCanvasElement.
1173
+ * The canvas is automatically resized to fit the output.
1174
+ *
1175
+ * @example
1176
+ * ```ts
1177
+ * import { renderTextToCanvas } from 'asciify-engine';
1178
+ * renderTextToCanvas(canvas, 'Hello!', { color: '#d4ff00', scale: 2 });
1179
+ * ```
1180
+ */
1181
+ declare function renderTextToCanvas(canvas: HTMLCanvasElement, text: string, options?: BigTextOptions): void;
1182
+
1183
+ export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifyLiveVideoOptions, type AsciifySimpleOptions, type AsciifyVideoOptions, type AuroraBackgroundOptions, BACKGROUND_TYPES, type BackgroundType, type BigTextOptions, CHARSETS, CHARSET_SEQUENCES, type CharsetKey, type CharsetSequenceKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type HoverShape, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type RenderMode, type SilkBackgroundOptions, type SnapshotOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type TextBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebcamOptions, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyLiveVideo, asciifyText, asciifyVideo, asciifyWebcam, buildTextFrame, captureSnapshot, gifToAsciiFrames, imageToAsciiFrame, mountWaveBackground, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderFrameToCanvas, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderTextBackground, renderTextToCanvas, renderVoidBackground, renderWaveBackground, snapshotAndDownload, videoToAsciiFrames };
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",hoverShape:"circle",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,h="circle"){const f=t-o,d=e-n,g=.08+.35*l+.04*a;let u,m;if("box"===h){const t=Math.abs(f),e=Math.abs(d);u=Math.max(t,e),m=g}else u=Math.sqrt(f*f+d*d),m=g;if(u>=m)return v.scale=1,v.offsetX=0,v.offsetY=0,v.glow=0,v.colorBlend=0,v.proximity=0,v;const M=function(t){return t*t*(3-2*t)}(1-u/m)*r;let p=1,b=0,x=0,w=0,y=0;switch(s){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(d,f),e=M*M*a*.6;b=Math.cos(t)*e*i,x=Math.sin(t)*e*c,w=M*a*.4,y=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,w=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(d,f),e=M*M*a*1.2;b=Math.cos(t)*e*i,x=Math.sin(t)*e*c;break}case"glow":w=M*a*.8,y=M*a*.4;break;case"colorShift":p=1+M*a*.4,w=M*a*.2,y=M*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=M*M*a*1;b=-Math.cos(t)*e*i,x=-Math.sin(t)*e*c,w=M*a*.3;break}case"shatter":{const t=Math.atan2(d,f),e=.5*Math.sin(43.7*f+29.3*d),o=M*a*1.4*(.7+.3*e);b=Math.cos(t+e)*o*i,x=Math.sin(t+e)*o*c,p=Math.max(.1,1-M*a*.6),w=M*a*.25;break}case"trail":y=M*a*.9,w=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1+M*a*.25,w=M*a*.7,y=M*a*.65}return v.scale=p,v.offsetX=b,v.offsetY=x,v.glow=w,v.colorBlend=y,v.proximity=M,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 A=212,T=255,k=0;{const t=x.replace("#","");6===t.length&&(A=parseInt(t.slice(0,2),16),T=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,q=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)+q,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 P=s*(1-g)+(Math.max(0,1-b*u)+.5*x)*g+.15*x,F=Math.min(1,Math.max(0,P));let B=F;if(p&&F>.72){const t=Math.floor(8*z),n=S(7*o+3*t,11*e+t);n>.88&&(B=Math.min(1,F+4*(n-.88)))}const L=Math.floor(B*(l.length-1));if(" "===l[L])continue;const H=.015+.07*B;if(B>d){const e=Math.min(v?.9:.28,H*(v?14:2.8));t.fillStyle=`rgba(${A},${T},${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 A(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 T(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=A(t.getPropertyValue(e).trim());if(o)return o}const e=A(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,A=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]}}($),A=(e.chromaKeyTolerance??60)**2);let T=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<=A}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}T=t,k=e>t?e-t:255}const z=[],q=R(e.invert),P=S&&e.charset.replace(/ /g,"")||e.charset,F=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<=A}if(t){f++;continue}}r+=s,a+=l,i+=h,c+=d}}if(S&&f>F/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const g=F-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?($-T)/k*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),z=e.customText?h(R,e.customText,n,t,m,q):l(R,P,q);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 q(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 P(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?T(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=T(o.accentColor),A=parseInt(E.substring(0,2),16)||255,k=parseInt(E.substring(2,4),16)||255,z=parseInt(E.substring(4,6),16)||255,q=M>3e4?.25:M>15e3?.4:M>5e3?.6:1,P=o.hoverRadius*q;let F=0,B=s,L=0,H=c,j=0,W=0;if(w&&i){j=i.x,W=i.y;const t=.08+.35*P+.04*o.hoverStrength;F=Math.max(0,Math.floor((j-t)*s)-1),B=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 Y=o.animationStyle,O=o.animationSpeed,U="none"===Y,X=o.hoverStrength,D=o.hoverEffect,V=P,J=o.hoverShape||"circle",N=R(o.invert),_=o.colorMode,G=2*Math.PI,K=1/s,Q=1/c;let Z="",tt=-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=N?1-l:l;if(h<.02)continue;const f=U?1:b(e,o,s,c,a,Y,O);let d=1,M=0,y=0,E=0,I=0;if(w&&e>=F&&e<=B&&o>=L&&o<=H){const t=x(e*K,o*Q,j,W,v,X,g,u,D,V,J);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 T=e*g+.5*g+M,q=o*u+.5*u+y;let P;if(I>0){const t=p(i,_,A,k,z,N);P=`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 P=m(i,_,A,k,z,N);const et=Math.min(1,.00392156863*i.a*f*(1+E));if(et!==tt&&(t.globalAlpha=et,tt=et),P!==Z&&(t.fillStyle=P,Z=P),R<=3){const e=2*R;t.fillRect(T-R,q-R,e,e)}else t.beginPath(),t.arc(T,q,R,0,G),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"===D&&w,I="!@#$%^&*<>{}[]|/\\~`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",R=I.length;let T="",q=[],P=0,G=0;if(E){const t=o.hoverText??"ASCIIFY";if(P=Math.round(j*s),G=Math.round(W*c),Array.isArray(t)){T=t[((7*Math.floor(P/Math.max(1,Math.ceil(s/5)))+13*Math.floor(G/Math.max(1,Math.ceil(c/3))))%t.length+t.length)%t.length]||t[0]||"ASCIIFY"}else T=t||"ASCIIFY";q=T.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,N):r.char;if(" "===f)continue;const T=U?1:b(e,o,s,c,a,Y,O);if(T<.05)continue;let et=1,ot=0,nt=0,rt=0,at=0,it=0;if(w&&e>=F&&e<=B&&o>=L&&o<=H){const t=x(e*K,o*Q,j,W,v,X,g,u,D,V,J);et=t.scale,ot=t.offsetX,nt=t.offsetY,rt=t.glow,at=t.colorBlend,it=t.proximity}if(E&&it>0){const t=q[o-(G-Math.floor(q.length/2))];if(null!=t){const n=e-(P-Math.floor(t.length/2));if(n>=0&&n<t.length&&" "!==t[n]){const r=Math.max(0,(it-.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],rt=Math.max(rt,.9*it),at=Math.max(at,.85*it)}else{const t=43758.5453*Math.sin(43.7*e+29.3*o+17.89*Math.floor(6*a));t-Math.floor(t)<.35*it&&(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*it&&(f=I[Math.abs(Math.floor(53*t))%R])}}const ct=e*g+.5*g+ot,st=o*u+.5*u+nt;let lt;if(at>0){const t=p(r,_,A,k,z,N);lt=`rgb(${Math.min(255,t[0]+($-t[0])*at|0)},${Math.min(255,t[1]+(S-t[1])*at|0)},${Math.min(255,t[2]+(C-t[2])*at|0)})`}else lt=m(r,_,A,k,z,N);if(i){const e=h[f]??.5,o=Math.min(1,.00392156863*r.a*T*(1+rt))*e;if(o<.02)continue;o!==tt&&(t.globalAlpha=o,tt=o),lt!==Z&&(t.fillStyle=lt,Z=lt);const n=g*et,a=u*et;t.fillRect(ct-.5*n,st-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*T*(1+rt));e!==tt&&(t.globalAlpha=e,tt=e),lt!==Z&&(t.fillStyle=lt,Z=lt),1!==et?(t.translate(ct,st),t.scale(et,et),t.fillText(f,0,0),t.setTransform(y)):t.fillText(f,ct,st)}}}}t.globalAlpha=1}function F(t,e){const o=Math.min(1,2048/Math.max(t,e));return{renderW:Math.round(t*o),renderH:Math.round(e*o)}}function B(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}=F(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}=F(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);if(h.hoverStrength>0){let t=null,o=!1,n=0;const r=o=>{const n=e.getBoundingClientRect();t={x:(o.clientX-n.left)/n.width,y:(o.clientY-n.top)/n.height}},a=()=>{t=null};e.addEventListener("mousemove",r),e.addEventListener("mouseleave",a);const i=e=>{o||(f.save(),f.setTransform(b,0,0,b,0,0),P(f,v,h,u,m,e/1e3,t),f.restore(),n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{o=!0,cancelAnimationFrame(n),e.removeEventListener("mousemove",r),e.removeEventListener("mouseleave",a)}}f.save(),f.setTransform(b,0,0,b,0,0),P(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 q(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&&(P(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&&B(e,p,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight);const{renderW:n,renderH:r}=F(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),P(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:$}=F(b.videoWidth,b.videoHeight);if(p){const t=b.videoWidth/b.videoHeight,o=b.videoWidth,n=b.videoHeight,r=B(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=B(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&&(P(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 Y(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 O(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 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),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 A=w(M);A&&(E=A.r,I=A.g,R=A.b);const T=.035*d,k=n*f,z=Math.min(6,Math.max(1,h)),q=(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*T+.06*k,a=e*T*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*q(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 D(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 A=n*f;for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=e/v,a=((n*h-.5*A)%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*A),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 A=n*h,T=[];for(let t=0;t<f;t++){const e=S(17*t,31*t+7),o=S(23*t+5,11*t);T.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}=T[t];w+=Math.sin(m*e*Math.PI*2+A*r+n)*Math.cos(v*o*Math.PI*2+A*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,q=c[Math.min(c.length-1,Math.floor(z*c.length))],P=k>.82,F=u?.82*k:.14*k;t.fillStyle=P?`rgba(${C},${E},${I},${u?.92:.32})`:`rgba(${x},${y},${$},${F})`,t.fillText(q,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 A=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*A)))/.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 A=()=>{m.x+=.07*(u.x-m.x),m.y+=.07*(u.y-m.y);const t=l.getBoundingClientRect();"rain"===o?Y(d,t.width,t.height,E,x.current):"stars"===o?O(d,t.width,t.height,E,m,x.current):"pulse"===o?U(d,t.width,t.height,E,m,x.current):"noise"===o?X(d,t.width,t.height,E,m,x.current):"grid"===o?D(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(A)};return R=requestAnimationFrame(A),{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}`;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;P(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),P(g,s,i,o,n,a,l),g.restore()):P(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,q as gifToAsciiFrames,k as imageToAsciiFrame,ct as mountWaveBackground,V as renderAuroraBackground,rt as renderCircuitBackground,K as renderDnaBackground,G as renderFireBackground,P as renderFrameToCanvas,D as renderGridBackground,_ as renderMorphBackground,X as renderNoiseBackground,U as renderPulseBackground,Y as renderRainBackground,J as renderSilkBackground,O as renderStarsBackground,Q as renderTerrainBackground,ft as renderTextBackground,N 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",hoverShape:"circle",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,h="circle"){const f=t-o,d=e-n,g=.08+.35*l+.04*a;let u,m;if("box"===h){const t=Math.abs(f),e=Math.abs(d);u=Math.max(t,e),m=g}else u=Math.sqrt(f*f+d*d),m=g;if(u>=m)return v.scale=1,v.offsetX=0,v.offsetY=0,v.glow=0,v.colorBlend=0,v.proximity=0,v;const M=function(t){return t*t*(3-2*t)}(1-u/m)*r;let p=1,b=0,x=0,w=0,y=0;switch(s){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(d,f),e=M*M*a*.6;b=Math.cos(t)*e*i,x=Math.sin(t)*e*c,w=M*a*.4,y=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,w=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(d,f),e=M*M*a*1.2;b=Math.cos(t)*e*i,x=Math.sin(t)*e*c;break}case"glow":w=M*a*.8,y=M*a*.4;break;case"colorShift":p=1+M*a*.4,w=M*a*.2,y=M*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=M*M*a*1;b=-Math.cos(t)*e*i,x=-Math.sin(t)*e*c,w=M*a*.3;break}case"shatter":{const t=Math.atan2(d,f),e=.5*Math.sin(43.7*f+29.3*d),o=M*a*1.4*(.7+.3*e);b=Math.cos(t+e)*o*i,x=Math.sin(t+e)*o*c,p=Math.max(.1,1-M*a*.6),w=M*a*.25;break}case"trail":y=M*a*.9,w=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,w=M*a*.5,y=M*a*.6}return v.scale=p,v.offsetX=b,v.offsetY=x,v.glow=w,v.colorBlend=y,v.proximity=M,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 A=212,T=255,k=0;{const t=x.replace("#","");6===t.length&&(A=parseInt(t.slice(0,2),16),T=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,q=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)+q,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 P=s*(1-g)+(Math.max(0,1-b*u)+.5*x)*g+.15*x,F=Math.min(1,Math.max(0,P));let B=F;if(p&&F>.72){const t=Math.floor(8*z),n=S(7*o+3*t,11*e+t);n>.88&&(B=Math.min(1,F+4*(n-.88)))}const L=Math.floor(B*(l.length-1));if(" "===l[L])continue;const H=.015+.07*B;if(B>d){const e=Math.min(v?.9:.28,H*(v?14:2.8));t.fillStyle=`rgba(${A},${T},${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 A(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 T(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=A(t.getPropertyValue(e).trim());if(o)return o}const e=A(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,A=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]}}($),A=(e.chromaKeyTolerance??60)**2);let T=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<=A}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}T=t,k=e>t?e-t:255}const z=[],q=R(e.invert),P=S&&e.charset.replace(/ /g,"")||e.charset,F=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<=A}if(t){f++;continue}}r+=s,a+=l,i+=h,c+=d}}if(S&&f>F/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const g=F-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?($-T)/k*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),z=e.customText?h(R,e.customText,n,t,m,q):l(R,P,q);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 q(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 P(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?T(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=T(o.accentColor),A=parseInt(E.substring(0,2),16)||255,k=parseInt(E.substring(2,4),16)||255,z=parseInt(E.substring(4,6),16)||255,q=M>3e4?.25:M>15e3?.4:M>5e3?.6:1,P=o.hoverRadius*q;let F=0,B=s,L=0,H=c,j=0,W=0;if(w&&i){j=i.x,W=i.y;const t=.08+.35*P+.04*o.hoverStrength;F=Math.max(0,Math.floor((j-t)*s)-1),B=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 Y=o.animationStyle,O=o.animationSpeed,U="none"===Y,X=o.hoverStrength,D=o.hoverEffect,V=P,J=o.hoverShape||"circle",_=R(o.invert),N=o.colorMode,G=2*Math.PI,K=1/s,Q=1/c;let Z="",tt=-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=_?1-l:l;if(h<.02)continue;const f=U?1:b(e,o,s,c,a,Y,O);let d=1,M=0,y=0,E=0,I=0;if(w&&e>=F&&e<=B&&o>=L&&o<=H){const t=x(e*K,o*Q,j,W,v,X,g,u,D,V,J);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 T=e*g+.5*g+M,q=o*u+.5*u+y;let P;if(I>0){const t=p(i,N,A,k,z,_);P=`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 P=m(i,N,A,k,z,_);const et=Math.min(1,.00392156863*i.a*f*(1+E));if(et!==tt&&(t.globalAlpha=et,tt=et),P!==Z&&(t.fillStyle=P,Z=P),R<=3){const e=2*R;t.fillRect(T-R,q-R,e,e)}else t.beginPath(),t.arc(T,q,R,0,G),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"===D&&w,I="!@#$%^&*<>{}[]|/\\~`0123456789",R=I.length;let T="",q=0,G=0,et=0,ot=0,nt=0,rt=0;if(E){const t=o.hoverText??"ASCIIFY";if(G=Math.round(j*s),et=Math.round(W*c),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");T=e[((7*Math.floor(G/Math.max(1,Math.ceil(s/5)))+13*Math.floor(et/Math.max(1,Math.ceil(c/3))))%e.length+e.length)%e.length]}else T=t||"ASCIIFY";q=T.length,ot=Math.max(3,Math.min(12,Math.round(c*P*.6)));const e=Math.floor(ot/2);nt=Math.max(0,et-e),nt+ot>c&&(nt=Math.max(0,c-ot)),rt=G-Math.floor(q/2)}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,_):r.char;if(" "===f)continue;const P=U?1:b(e,o,s,c,a,Y,O);if(P<.05)continue;let at=1,it=0,ct=0,st=0,lt=0;if(w&&!E&&e>=F&&e<=B&&o>=L&&o<=H){const t=x(e*K,o*Q,j,W,v,X,g,u,D,V,J);at=t.scale,it=t.offsetX,ct=t.offsetY,st=t.glow,lt=t.colorBlend}if(E&&o>=nt&&o<nt+ot){const t=e-rt;if(t>=0&&t<q){const n=T[t],r=Math.abs(o-et)/Math.max(1,.5*ot),i=Math.abs(e-G)/Math.max(1,q),c=Math.max(r,i),s=Math.max(0,Math.min(1,1-.9*c)),l=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));f=Math.abs(l-Math.floor(l))<s?n:I[Math.abs(Math.floor(97*l))%R],st=.3+.7*s,lt=.3+.65*s}}const ht=e*g+.5*g+it,ft=o*u+.5*u+ct;let dt;if(lt>0){const t=p(r,N,A,k,z,_);dt=`rgb(${Math.min(255,t[0]+($-t[0])*lt|0)},${Math.min(255,t[1]+(S-t[1])*lt|0)},${Math.min(255,t[2]+(C-t[2])*lt|0)})`}else dt=m(r,N,A,k,z,_);if(i){const e=h[f]??.5,o=Math.min(1,.00392156863*r.a*P*(1+st))*e;if(o<.02)continue;o!==tt&&(t.globalAlpha=o,tt=o),dt!==Z&&(t.fillStyle=dt,Z=dt);const n=g*at,a=u*at;t.fillRect(ht-.5*n,ft-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*P*(1+st));e!==tt&&(t.globalAlpha=e,tt=e),dt!==Z&&(t.fillStyle=dt,Z=dt),1!==at?(t.translate(ht,ft),t.scale(at,at),t.fillText(f,0,0),t.setTransform(y)):t.fillText(f,ht,ft)}}}}t.globalAlpha=1}function F(t,e){const o=Math.min(1,2048/Math.max(t,e));return{renderW:Math.round(t*o),renderH:Math.round(e*o)}}function B(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}=F(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}=F(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);if(h.hoverStrength>0){let t=null,o=!1,n=0;const r=o=>{const n=e.getBoundingClientRect();t={x:(o.clientX-n.left)/n.width,y:(o.clientY-n.top)/n.height}},a=()=>{t=null};e.addEventListener("mousemove",r),e.addEventListener("mouseleave",a);const i=e=>{o||(f.save(),f.setTransform(b,0,0,b,0,0),P(f,v,h,u,m,e/1e3,t),f.restore(),n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{o=!0,cancelAnimationFrame(n),e.removeEventListener("mousemove",r),e.removeEventListener("mouseleave",a)}}f.save(),f.setTransform(b,0,0,b,0,0),P(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 q(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&&(P(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&&B(e,p,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight);const{renderW:n,renderH:r}=F(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),P(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:$}=F(b.videoWidth,b.videoHeight);if(p){const t=b.videoWidth/b.videoHeight,o=b.videoWidth,n=b.videoHeight,r=B(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=B(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&&(P(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 Y(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 O(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 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),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 A=w(M);A&&(E=A.r,I=A.g,R=A.b);const T=.035*d,k=n*f,z=Math.min(6,Math.max(1,h)),q=(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*T+.06*k,a=e*T*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*q(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 D(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 A=n*f;for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=e/v,a=((n*h-.5*A)%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*A),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 A=n*h,T=[];for(let t=0;t<f;t++){const e=S(17*t,31*t+7),o=S(23*t+5,11*t);T.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}=T[t];w+=Math.sin(m*e*Math.PI*2+A*r+n)*Math.cos(v*o*Math.PI*2+A*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,q=c[Math.min(c.length-1,Math.floor(z*c.length))],P=k>.82,F=u?.82*k:.14*k;t.fillStyle=P?`rgba(${C},${E},${I},${u?.92:.32})`:`rgba(${x},${y},${$},${F})`,t.fillText(q,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 _(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 A=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*A)))/.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 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=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 A=()=>{m.x+=.07*(u.x-m.x),m.y+=.07*(u.y-m.y);const t=l.getBoundingClientRect();"rain"===o?Y(d,t.width,t.height,E,x.current):"stars"===o?O(d,t.width,t.height,E,m,x.current):"pulse"===o?U(d,t.width,t.height,E,m,x.current):"noise"===o?X(d,t.width,t.height,E,m,x.current):"grid"===o?D(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?_(d,t.width,t.height,E,m,x.current):"morph"===o?N(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(A)};return R=requestAnimationFrame(A),{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}`;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;P(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),P(g,s,i,o,n,a,l),g.restore()):P(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}}var mt={A:[28,54,99,127,99,99,99],B:[126,99,99,126,99,99,126],C:[62,99,96,96,96,99,62],D:[124,102,99,99,99,102,124],E:[127,96,96,124,96,96,127],F:[127,96,96,124,96,96,96],G:[62,99,96,111,99,99,62],H:[99,99,99,127,99,99,99],I:[127,8,8,8,8,8,127],J:[63,6,6,6,102,102,60],K:[99,102,108,120,108,102,99],L:[96,96,96,96,96,96,127],M:[99,119,107,107,99,99,99],N:[99,115,107,103,99,99,99],O:[62,99,99,99,99,99,62],P:[126,99,99,126,96,96,96],Q:[62,99,99,99,107,102,61],R:[126,99,99,126,108,102,99],S:[62,99,96,62,3,99,62],T:[127,8,8,8,8,8,8],U:[99,99,99,99,99,99,62],V:[99,99,99,99,54,28,8],W:[99,99,99,107,107,54,20],X:[99,54,28,8,28,54,99],Y:[99,99,54,28,8,8,8],Z:[127,3,6,12,24,48,127],a:[0,0,60,3,62,99,61],b:[96,96,124,99,99,99,124],c:[0,0,62,96,96,96,62],d:[3,3,31,99,99,99,31],e:[0,0,62,99,127,96,62],f:[30,48,48,126,48,48,48],g:[0,0,63,99,63,3,62],h:[96,96,124,99,99,99,99],i:[8,0,24,8,8,8,28],j:[4,0,12,4,4,36,24],k:[96,96,102,108,120,108,102],l:[24,8,8,8,8,8,28],m:[0,0,92,107,107,99,99],n:[0,0,94,99,99,99,99],o:[0,0,62,99,99,99,62],p:[0,0,126,99,126,96,96],q:[0,0,63,99,63,3,3],r:[0,0,94,99,96,96,96],s:[0,0,62,96,62,3,124],t:[48,48,126,48,48,48,30],u:[0,0,99,99,99,103,59],v:[0,0,99,99,54,28,8],w:[0,0,99,99,107,54,20],x:[0,0,99,54,28,54,99],y:[0,0,99,99,63,3,62],z:[0,0,127,6,12,24,127],0:[62,99,103,107,115,99,62],1:[8,24,56,8,8,8,62],2:[62,99,3,6,24,48,127],3:[62,99,3,30,3,99,62],4:[6,14,22,38,127,6,6],5:[127,96,126,3,3,99,62],6:[62,99,96,126,99,99,62],7:[127,3,6,12,24,24,24],8:[62,99,99,62,99,99,62],9:[62,99,99,63,3,99,62]," ":[0,0,0,0,0,0,0],"!":[24,24,24,24,24,0,24],"?":[62,99,3,14,8,0,8],".":[0,0,0,0,0,24,24],",":[0,0,0,0,0,24,48],";":[0,24,24,0,24,24,48],":":[0,24,24,0,24,24,0],"-":[0,0,0,62,0,0,0],_:[0,0,0,0,0,0,127],"'":[24,24,32,0,0,0,0],'"':[54,54,36,0,0,0,0],"`":[24,8,0,0,0,0,0],")":[24,12,6,6,6,12,24],"(":[12,24,48,48,48,24,12],"[":[60,48,48,48,48,48,60],"]":[30,6,6,6,6,6,30],"{":[14,24,24,48,24,24,14],"}":[56,12,12,6,12,12,56],"/":[3,6,12,24,48,96,0],"\\":[96,48,24,12,6,3,0],"|":[8,8,8,8,8,8,8],"+":[0,8,8,62,8,8,0],"=":[0,0,62,0,62,0,0],"*":[0,42,28,127,28,42,0],"#":[36,36,127,36,127,36,36],"@":[62,99,111,107,111,96,62],"&":[24,36,24,60,74,68,58],"%":[99,38,4,8,16,50,99],$:[8,62,72,62,9,62,8],"^":[8,20,34,0,0,0,0],"~":[0,0,50,76,0,0,0],"<":[6,12,24,48,24,12,6],">":[48,24,12,6,12,24,48]},Mt=[127,65,65,65,65,65,127];function pt(t){return mt[t]??mt[t.toUpperCase()]??Mt}function bt(t,e={}){if(!t)return"";const{char:o="█",scale:n=1}=e,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,c=a,s=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const o=pt(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)s[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)s[t]+=" ".repeat(c)}return s.join("\n")}function vt(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=bt(e,o);if(!i)return;const c=i.split("\n"),s=Math.max(...c.map(t=>[...t].length));t.width=Math.ceil(s*a*.6),t.height=Math.ceil(c.length*a);const l=t.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",c.forEach((t,e)=>l.fillText(t,0,e*a))}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,bt as asciifyText,j as asciifyVideo,ut as asciifyWebcam,ht as buildTextFrame,dt as captureSnapshot,q as gifToAsciiFrames,k as imageToAsciiFrame,ct as mountWaveBackground,V as renderAuroraBackground,rt as renderCircuitBackground,K as renderDnaBackground,G as renderFireBackground,P as renderFrameToCanvas,D as renderGridBackground,N as renderMorphBackground,X as renderNoiseBackground,U as renderPulseBackground,Y as renderRainBackground,J as renderSilkBackground,O as renderStarsBackground,Q as renderTerrainBackground,ft as renderTextBackground,vt as renderTextToCanvas,_ as renderVoidBackground,I as renderWaveBackground,gt as snapshotAndDownload,z as videoToAsciiFrames};//# sourceMappingURL=index.js.map