asciify-engine 4.20.0 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/{animation-presets-ZujFF3i8.d.ts → animation-presets-CEdD0FMM.d.cts} +42 -28
- package/dist/{animation-presets-DhswE0D_.d.cts → animation-presets-KnEWoJ_q.d.ts} +42 -28
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +4 -4
- package/dist/core.d.ts +4 -4
- package/dist/core.js +1 -1
- package/dist/field.cjs +1 -1
- package/dist/field.d.cts +3 -1
- package/dist/field.d.ts +3 -1
- package/dist/field.js +1 -1
- package/dist/hover-guide-CAfsLjFZ.d.cts +190 -0
- package/dist/hover-guide-CAfsLjFZ.d.ts +190 -0
- package/dist/hover.cjs +1 -1
- package/dist/hover.d.cts +14 -7
- package/dist/hover.d.ts +14 -7
- package/dist/hover.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{model-9SbRVqqI.d.cts → model-BHIQYYk-.d.ts} +11 -2
- package/dist/{model-DXHhQhxP.d.ts → model-BzgEEqzP.d.cts} +11 -2
- package/dist/studio.cjs +1 -1
- package/dist/studio.d.cts +4 -5
- package/dist/studio.d.ts +4 -5
- package/dist/studio.js +1 -1
- package/dist/{types-CM4452nD.d.ts → types-C9lka3yC.d.ts} +2 -2
- package/dist/{types-FkqhgDYx.d.cts → types-DOl5f2x3.d.cts} +2 -2
- package/package.json +1 -1
- package/skills/asciify-engine/SKILL.md +3 -3
- package/skills/asciify-engine/references/design-matching.md +2 -1
- package/skills/asciify-engine/references/glyph-field.md +1 -1
- package/skills/asciify-engine/references/hero-finish.md +3 -0
- package/skills/asciify-engine/references/looks.md +55 -55
- package/skills/asciify-engine/references/studio-effects.md +73 -24
- package/skills/asciify-engine/references/studio-workspace.md +6 -7
- package/skills/asciify-engine/references/upgrading.md +6 -0
- package/dist/hover-catalog-D85jh6dR.d.cts +0 -173
- package/dist/hover-catalog-D85jh6dR.d.ts +0 -173
package/README.md
CHANGED
|
@@ -646,6 +646,20 @@ const field = mountGlyphField(canvas, {
|
|
|
646
646
|
|
|
647
647
|
It needs WebGL2 on a GPU: `isGlyphFieldSupported()` is false without it or on software WebGL, and slow devices step down to 1× pixels and then still ambient motion. Keep a poster or the `/studio` renderer as the fallback. A still field stops drawing once its wake settles. Measured in Playwright Chromium on an Apple M4 Pro at 1440 × 900 and device pixel ratio 2, a full-viewport field held 120 fps (9 ms 95th-percentile frame) under continuous pointer movement; measure your own targets. See the [field guide](skills/asciify-engine/references/glyph-field.md) and [brand field example](examples/glyph-field.ts). It is a separate entry: the root, `/core`, `/hover` and `/studio` never load it.
|
|
648
648
|
|
|
649
|
+
## 4.22: photo-aware motion and finish
|
|
650
|
+
|
|
651
|
+
- A new set of still-image motions read the photo's own light, form, highlights, detail and estimated depth: `relight`, `sheen` (specular sweep), `glow` (highlight bloom), `shimmer` (glints), `parallax`, `push`, `focus`, `mist`, `current` (drift) and `develop`.
|
|
652
|
+
- Retired motions keep working through `DEPRECATED_STUDIO_MOTIONS`: caustics → sheen, grain → shimmer, trace → relight, tidal/weave/breeze → current, reform/print/unfold → develop.
|
|
653
|
+
- Optical finish: bloom is a wide soft glow around highlights, and grain is fine film grain weighted to the midtones.
|
|
654
|
+
- Animation presets are re-paired with the new motions, plus a new Depth study.
|
|
655
|
+
|
|
656
|
+
## 4.21: premium hovers that know the subject
|
|
657
|
+
|
|
658
|
+
- Six new hovers: `loupe`, `reveal`, `repel`, `tilt`, `haze` and `bleed`; `scatter`, `elastic` and `ripple` are refined, and `rake` is deprecated (it plays `silk`).
|
|
659
|
+
- Every hover takes `decay` (how long it lingers) and `scope: 'all' | 'subject' | 'outside'`: the subject comes from transparency, a drawn mask or an even plain ground, with a feathered edge; a busy full-bleed photo acts as `all`.
|
|
660
|
+
- Hovers ease in, settle when the pointer stops, follow touch drags and stay off under reduced motion.
|
|
661
|
+
- `mountHover` now runs on the GPU in Chrome (a reserved word in its shader forced the 2D fallback).
|
|
662
|
+
|
|
649
663
|
## 4.20: sharper presets, 61 looks, twelve backgrounds
|
|
650
664
|
|
|
651
665
|
- Studio presets `ascii` (Signature ASCII) and `night` (Night signal) are retuned: finer 4px cells, brighter inks, lifted midtones and a faint glow.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AmbientMotion, S as SurfaceHover } from './hover-
|
|
1
|
+
import { A as AmbientMotion, S as SurfaceHover } from './hover-guide-CAfsLjFZ.cjs';
|
|
2
2
|
|
|
3
3
|
interface StudioAnimationPreset {
|
|
4
4
|
readonly id: string;
|
|
@@ -19,11 +19,11 @@ interface StudioAnimationPreset {
|
|
|
19
19
|
declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
20
20
|
readonly id: "quiet-light";
|
|
21
21
|
readonly label: "Quiet light";
|
|
22
|
-
readonly description: "
|
|
22
|
+
readonly description: "A key light circles the subject’s own relief, with a soft magnifying wake.";
|
|
23
23
|
readonly motion: {
|
|
24
24
|
readonly type: "relight";
|
|
25
25
|
readonly speed: 0.6;
|
|
26
|
-
readonly amount: 0.
|
|
26
|
+
readonly amount: 0.8;
|
|
27
27
|
};
|
|
28
28
|
readonly hover: {
|
|
29
29
|
readonly effect: "lens";
|
|
@@ -32,26 +32,26 @@ declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
|
32
32
|
};
|
|
33
33
|
}, {
|
|
34
34
|
readonly id: "living-paper";
|
|
35
|
-
readonly label: "
|
|
36
|
-
readonly description: "A
|
|
35
|
+
readonly label: "Memory";
|
|
36
|
+
readonly description: "A slow push toward the subject; the image leans toward your cursor.";
|
|
37
37
|
readonly motion: {
|
|
38
|
-
readonly type: "
|
|
39
|
-
readonly speed: 0.
|
|
40
|
-
readonly amount: 0.
|
|
38
|
+
readonly type: "push";
|
|
39
|
+
readonly speed: 0.5;
|
|
40
|
+
readonly amount: 0.8;
|
|
41
41
|
};
|
|
42
42
|
readonly hover: {
|
|
43
|
-
readonly effect: "
|
|
44
|
-
readonly radius: 0.
|
|
45
|
-
readonly strength: 0.
|
|
43
|
+
readonly effect: "tilt";
|
|
44
|
+
readonly radius: 0.5;
|
|
45
|
+
readonly strength: 0.45;
|
|
46
46
|
};
|
|
47
47
|
}, {
|
|
48
48
|
readonly id: "silver-grain";
|
|
49
|
-
readonly label: "Silver
|
|
50
|
-
readonly description: "
|
|
49
|
+
readonly label: "Silver light";
|
|
50
|
+
readonly description: "Sparse glints on bright detail, with a fluid character trail.";
|
|
51
51
|
readonly motion: {
|
|
52
52
|
readonly type: "shimmer";
|
|
53
|
-
readonly speed: 0.
|
|
54
|
-
readonly amount: 0.
|
|
53
|
+
readonly speed: 0.6;
|
|
54
|
+
readonly amount: 0.9;
|
|
55
55
|
};
|
|
56
56
|
readonly hover: {
|
|
57
57
|
readonly effect: "trail";
|
|
@@ -60,26 +60,26 @@ declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
|
60
60
|
};
|
|
61
61
|
}, {
|
|
62
62
|
readonly id: "ripple-study";
|
|
63
|
-
readonly label: "
|
|
64
|
-
readonly description: "
|
|
63
|
+
readonly label: "Still water";
|
|
64
|
+
readonly description: "Smooth water and sky drift like a cinemagraph; your stroke sends out rings.";
|
|
65
65
|
readonly motion: {
|
|
66
|
-
readonly type: "
|
|
66
|
+
readonly type: "current";
|
|
67
67
|
readonly speed: 0.6;
|
|
68
|
-
readonly amount: 0.
|
|
68
|
+
readonly amount: 0.8;
|
|
69
69
|
};
|
|
70
70
|
readonly hover: {
|
|
71
71
|
readonly effect: "ripple";
|
|
72
72
|
readonly radius: 0.45;
|
|
73
|
-
readonly strength: 0.
|
|
73
|
+
readonly strength: 0.7;
|
|
74
74
|
};
|
|
75
75
|
}, {
|
|
76
76
|
readonly id: "unfolding-print";
|
|
77
|
-
readonly label: "
|
|
78
|
-
readonly description: "
|
|
77
|
+
readonly label: "Darkroom";
|
|
78
|
+
readonly description: "The print develops from its highlights; your cursor dissolves a soft path.";
|
|
79
79
|
readonly motion: {
|
|
80
|
-
readonly type: "
|
|
80
|
+
readonly type: "develop";
|
|
81
81
|
readonly speed: 0.7;
|
|
82
|
-
readonly amount:
|
|
82
|
+
readonly amount: 1;
|
|
83
83
|
};
|
|
84
84
|
readonly hover: {
|
|
85
85
|
readonly effect: "dissolve";
|
|
@@ -88,18 +88,32 @@ declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
|
88
88
|
};
|
|
89
89
|
}, {
|
|
90
90
|
readonly id: "silk-flow";
|
|
91
|
-
readonly label: "
|
|
92
|
-
readonly description: "
|
|
91
|
+
readonly label: "Morning mist";
|
|
92
|
+
readonly description: "Mist drifts through the distance; directional folds follow your hand.";
|
|
93
93
|
readonly motion: {
|
|
94
|
-
readonly type: "
|
|
94
|
+
readonly type: "mist";
|
|
95
95
|
readonly speed: 0.6;
|
|
96
|
-
readonly amount:
|
|
96
|
+
readonly amount: 1;
|
|
97
97
|
};
|
|
98
98
|
readonly hover: {
|
|
99
99
|
readonly effect: "silk";
|
|
100
100
|
readonly radius: 0.4;
|
|
101
101
|
readonly strength: 0.5;
|
|
102
102
|
};
|
|
103
|
+
}, {
|
|
104
|
+
readonly id: "depth-study";
|
|
105
|
+
readonly label: "Depth study";
|
|
106
|
+
readonly description: "A slow parallax drift from the photo’s own depth, with a loupe under your cursor.";
|
|
107
|
+
readonly motion: {
|
|
108
|
+
readonly type: "parallax";
|
|
109
|
+
readonly speed: 0.6;
|
|
110
|
+
readonly amount: 0.9;
|
|
111
|
+
};
|
|
112
|
+
readonly hover: {
|
|
113
|
+
readonly effect: "loupe";
|
|
114
|
+
readonly radius: 0.35;
|
|
115
|
+
readonly strength: 0.55;
|
|
116
|
+
};
|
|
103
117
|
}];
|
|
104
118
|
|
|
105
119
|
export { STUDIO_ANIMATION_PRESETS as S, type StudioAnimationPreset as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AmbientMotion, S as SurfaceHover } from './hover-
|
|
1
|
+
import { A as AmbientMotion, S as SurfaceHover } from './hover-guide-CAfsLjFZ.js';
|
|
2
2
|
|
|
3
3
|
interface StudioAnimationPreset {
|
|
4
4
|
readonly id: string;
|
|
@@ -19,11 +19,11 @@ interface StudioAnimationPreset {
|
|
|
19
19
|
declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
20
20
|
readonly id: "quiet-light";
|
|
21
21
|
readonly label: "Quiet light";
|
|
22
|
-
readonly description: "
|
|
22
|
+
readonly description: "A key light circles the subject’s own relief, with a soft magnifying wake.";
|
|
23
23
|
readonly motion: {
|
|
24
24
|
readonly type: "relight";
|
|
25
25
|
readonly speed: 0.6;
|
|
26
|
-
readonly amount: 0.
|
|
26
|
+
readonly amount: 0.8;
|
|
27
27
|
};
|
|
28
28
|
readonly hover: {
|
|
29
29
|
readonly effect: "lens";
|
|
@@ -32,26 +32,26 @@ declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
|
32
32
|
};
|
|
33
33
|
}, {
|
|
34
34
|
readonly id: "living-paper";
|
|
35
|
-
readonly label: "
|
|
36
|
-
readonly description: "A
|
|
35
|
+
readonly label: "Memory";
|
|
36
|
+
readonly description: "A slow push toward the subject; the image leans toward your cursor.";
|
|
37
37
|
readonly motion: {
|
|
38
|
-
readonly type: "
|
|
39
|
-
readonly speed: 0.
|
|
40
|
-
readonly amount: 0.
|
|
38
|
+
readonly type: "push";
|
|
39
|
+
readonly speed: 0.5;
|
|
40
|
+
readonly amount: 0.8;
|
|
41
41
|
};
|
|
42
42
|
readonly hover: {
|
|
43
|
-
readonly effect: "
|
|
44
|
-
readonly radius: 0.
|
|
45
|
-
readonly strength: 0.
|
|
43
|
+
readonly effect: "tilt";
|
|
44
|
+
readonly radius: 0.5;
|
|
45
|
+
readonly strength: 0.45;
|
|
46
46
|
};
|
|
47
47
|
}, {
|
|
48
48
|
readonly id: "silver-grain";
|
|
49
|
-
readonly label: "Silver
|
|
50
|
-
readonly description: "
|
|
49
|
+
readonly label: "Silver light";
|
|
50
|
+
readonly description: "Sparse glints on bright detail, with a fluid character trail.";
|
|
51
51
|
readonly motion: {
|
|
52
52
|
readonly type: "shimmer";
|
|
53
|
-
readonly speed: 0.
|
|
54
|
-
readonly amount: 0.
|
|
53
|
+
readonly speed: 0.6;
|
|
54
|
+
readonly amount: 0.9;
|
|
55
55
|
};
|
|
56
56
|
readonly hover: {
|
|
57
57
|
readonly effect: "trail";
|
|
@@ -60,26 +60,26 @@ declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
|
60
60
|
};
|
|
61
61
|
}, {
|
|
62
62
|
readonly id: "ripple-study";
|
|
63
|
-
readonly label: "
|
|
64
|
-
readonly description: "
|
|
63
|
+
readonly label: "Still water";
|
|
64
|
+
readonly description: "Smooth water and sky drift like a cinemagraph; your stroke sends out rings.";
|
|
65
65
|
readonly motion: {
|
|
66
|
-
readonly type: "
|
|
66
|
+
readonly type: "current";
|
|
67
67
|
readonly speed: 0.6;
|
|
68
|
-
readonly amount: 0.
|
|
68
|
+
readonly amount: 0.8;
|
|
69
69
|
};
|
|
70
70
|
readonly hover: {
|
|
71
71
|
readonly effect: "ripple";
|
|
72
72
|
readonly radius: 0.45;
|
|
73
|
-
readonly strength: 0.
|
|
73
|
+
readonly strength: 0.7;
|
|
74
74
|
};
|
|
75
75
|
}, {
|
|
76
76
|
readonly id: "unfolding-print";
|
|
77
|
-
readonly label: "
|
|
78
|
-
readonly description: "
|
|
77
|
+
readonly label: "Darkroom";
|
|
78
|
+
readonly description: "The print develops from its highlights; your cursor dissolves a soft path.";
|
|
79
79
|
readonly motion: {
|
|
80
|
-
readonly type: "
|
|
80
|
+
readonly type: "develop";
|
|
81
81
|
readonly speed: 0.7;
|
|
82
|
-
readonly amount:
|
|
82
|
+
readonly amount: 1;
|
|
83
83
|
};
|
|
84
84
|
readonly hover: {
|
|
85
85
|
readonly effect: "dissolve";
|
|
@@ -88,18 +88,32 @@ declare const STUDIO_ANIMATION_PRESETS: readonly [{
|
|
|
88
88
|
};
|
|
89
89
|
}, {
|
|
90
90
|
readonly id: "silk-flow";
|
|
91
|
-
readonly label: "
|
|
92
|
-
readonly description: "
|
|
91
|
+
readonly label: "Morning mist";
|
|
92
|
+
readonly description: "Mist drifts through the distance; directional folds follow your hand.";
|
|
93
93
|
readonly motion: {
|
|
94
|
-
readonly type: "
|
|
94
|
+
readonly type: "mist";
|
|
95
95
|
readonly speed: 0.6;
|
|
96
|
-
readonly amount:
|
|
96
|
+
readonly amount: 1;
|
|
97
97
|
};
|
|
98
98
|
readonly hover: {
|
|
99
99
|
readonly effect: "silk";
|
|
100
100
|
readonly radius: 0.4;
|
|
101
101
|
readonly strength: 0.5;
|
|
102
102
|
};
|
|
103
|
+
}, {
|
|
104
|
+
readonly id: "depth-study";
|
|
105
|
+
readonly label: "Depth study";
|
|
106
|
+
readonly description: "A slow parallax drift from the photo’s own depth, with a loupe under your cursor.";
|
|
107
|
+
readonly motion: {
|
|
108
|
+
readonly type: "parallax";
|
|
109
|
+
readonly speed: 0.6;
|
|
110
|
+
readonly amount: 0.9;
|
|
111
|
+
};
|
|
112
|
+
readonly hover: {
|
|
113
|
+
readonly effect: "loupe";
|
|
114
|
+
readonly radius: 0.35;
|
|
115
|
+
readonly strength: 0.55;
|
|
116
|
+
};
|
|
103
117
|
}];
|
|
104
118
|
|
|
105
119
|
export { STUDIO_ANIMATION_PRESETS as S, type StudioAnimationPreset as a };
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t={standard:{label:"Classic ASCII",chars:" .:-=+*#%@"},asciify:{label:"Asciify",chars:" .:-=+YCIFSA#@"},minimal:{label:"Minimal",chars:" .:+"},detailed:{label:"Detailed",chars:" .,:;-~=+*xX#%@"},letters:{label:"Letters",chars:" .liLTYCFSAWM"},technical:{label:"Technical",chars:" ._:;+/>=][{}*$#@"},blocks:{label:"Tonal blocks",chars:" ░▒▓█"},braille:{label:"Braille",chars:" ⠁⠃⠇⡇⣇⣧⣷⣿"}},e={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:t.standard.chars,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",fineDither:!1,customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},n=[{value:"none",mode:"none",group:"Still",label:"Off",description:"Keep the image still. Hover stays available."},{value:"caustics",mode:"caustics",group:"Light and texture",label:"Caustics",description:"Soft ribbons of light travel across a stationary character grid."},{value:"current",mode:"current",group:"Flow and depth",label:"Slow Current",description:"A gentle flow through the image, with steady edges."},{value:"reform",mode:"reform",group:"Rebuild",label:"Reveal & Reform",description:"Disperse, gather, then hold the complete image."},{value:"sheen",mode:"sheen",group:"Light and texture",label:"Sheen",description:"A broad diagonal light sweep; characters stay anchored."},{value:"tidal",mode:"tidal",group:"Flow and depth",label:"Tidal Rings",description:"Concentric currents travel outward, with protected edges."},{value:"grain",mode:"grain",group:"Light and texture",label:"Living Grain",description:"Slow, individually phased tonal changes on a stationary grid."},{value:"parallax",mode:"parallax",group:"Flow and depth",label:"Parallax",description:"A shallow, continuous drift through the image, with the edges held in place."},{value:"weave",mode:"weave",group:"Flow and depth",label:"Woven Flow",description:"Interlaced bands move in opposing directions, like a flexible printed fabric."},{value:"print",mode:"print",group:"Rebuild",label:"Print Shift",description:"Staggered rows lift, soften and register back into the image."},{value:"trace",mode:"trace",group:"Light and texture",label:"Contour Light",description:"Light follows the source image’s tonal contours; every character stays anchored."},{value:"relight",mode:"relight",group:"Light and texture",label:"Relight",description:"A slow orbit of light models the image’s midtones, while the character grid stays fixed."},{value:"shimmer",mode:"shimmer",group:"Light and texture",label:"Shimmer",description:"Small highlights glint at different moments. Shadows stay quiet and the image stays in place."},{value:"breeze",mode:"breeze",group:"Flow and depth",label:"Breeze",description:"A traveling bend gently sways the image, like a print suspended in moving air."},{value:"unfold",mode:"unfold",group:"Rebuild",label:"Unfold",description:"Narrow panels turn, soften and return to a complete image, with a readable hold between cycles."}];var o=t=>Math.max(0,Math.min(1,t)),r=(t,e,n)=>{const r=o((n-t)/(e-t));return r*r*(3-2*r)},a=(t,e)=>{const n=(.06711056*t+.00583715*e)%1*52.9829189;return n-Math.floor(n)};function i(t,e,n,i,s,c=.5){if(s[0]=s[1]=s[2]=0,s[3]=1,"none"===t)return s;const l=i*Math.PI/6,h=r(0,.12,Math.min(e,1-e,n,1-n));if("caustics"===t){const t=Math.sin(9*e+5*n+l)+Math.sin(8*n-3*e-l),o=Math.pow(Math.max(0,1-.72*Math.abs(t)),3);s[2]=(.22*o-.045)*h}else if("current"===t)s[0]=Math.sin(9*n+l)*Math.cos(7*e-l)*10*h,s[1]=Math.cos(8*e+l)*Math.sin(6*n-l)*7*h;else if("sheen"===t)s[2]=.2*Math.pow(.5+.5*Math.cos(5*e+3*n-l),8)-.025;else if("tidal"===t){const t=e-.5,o=n-.5,r=Math.hypot(t,o),a=Math.sin(22*r-l)*h;s[0]=t*a*9,s[1]=o*a*9,s[2]=.035*a}else if("grain"===t){const t=a(Math.floor(160*e),Math.floor(100*n))*Math.PI*2;s[2]=.07*Math.sin(l+t)}else if("parallax"===t){const t=.45+.55*Math.max(0,1-1.4*Math.hypot(e-.5,n-.5));s[0]=12*Math.sin(l)*t*h,s[1]=6*(Math.cos(l)-1)*t*h}else if("weave"===t)s[0]=Math.sin(n*Math.PI*6+l)*Math.sin(l)*8*h,s[1]=Math.sin(e*Math.PI*6-l)*Math.sin(l)*6*h;else if("print"===t){const t=Math.floor(24*n),e=((i+3*a(t,3))%12+12)%12,o=r(1,2.5,e)*(1-r(3.5,5,e));s[0]=Math.sin(2.4*t)*o*9*h,s[1]=5*-o*h,s[2]=.22*-o,s[3]=1-.45*o}else if("trace"===t){const t=.5+.5*Math.cos(l);s[2]=.22*Math.pow(Math.max(0,1-Math.abs(o(c)-t)/.16),3)-.015}else if("relight"===t){const t=n-.5,r=1.3*((e-.5)*Math.cos(l)+t*Math.sin(l));s[2]=.3*r*(.25+3*o(c)*(1-o(c)))*h}else if("shimmer"===t){const t=a(Math.floor(160*e),Math.floor(100*n))*Math.PI*2,o=Math.pow(.5+.5*Math.cos(l+t),10);s[2]=.28*(o-.1762)*r(.35,.9,c)}else if("breeze"===t){const t=Math.sin(l-4*n),o=.35+.65*(1-n);s[0]=10*t*o*h,s[1]=2.5*Math.sin(2*l-4*n+3*e)*o*h,s[2]=.035*Math.cos(l-4*n)*h}else if("unfold"===t){const t=Math.floor(12*e),n=12*e-t-.5,o=((i-.11*t)%12+12)%12,a=r(1,3,o)*(1-r(5,7,o));s[0]=-n*a*24*h,s[1]=Math.sin(1.7*t)*a*3*h,s[2]=.12*-a,s[3]=1-.65*a}else if("reform"===t){const t=(i%12+12)%12,o=a(Math.floor(160*e),Math.floor(100*n)),c=.65*e+.2*n+.15*o+.08*Math.sin(8*e-5*n),d=r(1.8+1.2*c,3.8+1.2*c,t)*(1-r(5+1.7*c,7.2+1.7*c,t));s[0]=Math.sin(9*n+l)*d*(1-d)*24*h,s[1]=-d*(1-d)*(8+12*o)*h,s[2]=.45*-d,s[3]=1-.9*d}return s}function s(t,e){const n=document.createElement("canvas");n.width=t,n.height=e;const o=n.getContext("2d",{willReadFrequently:!0});return{canvas:n,ctx:o}}function c(t,e,n){let o=t+255*e;return o=259*(255*n+255)/(255*(259-255*n))*(o-128)+128,Math.max(0,Math.min(255,o))}function l(t,e,n,o,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(o*r+n)%i.length]}var h=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function d(t,e,n,o){if(o<=0)return t;const r=(h[n%4][e%4]/16-.5)*o*128;return Math.max(0,Math.min(255,t+r))}var f=new Array(256),m=new Array(256);for(let t=0;t<256;t++)f[t]=`rgb(${t},${t},${t})`,m[t]=`rgb(0,${t},0)`;function u(t,e,n,o,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return m[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${n},${o},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return f[e]}}}var g=[0,0,0];function p(t,e,n,o,r,a=!1){switch(e){case"fullcolor":g[0]=t.r,g[1]=t.g,g[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;g[0]=0,g[1]=e,g[2]=0;break}case"accent":g[0]=n,g[1]=o,g[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;g[0]=e,g[1]=e,g[2]=e;break}}return g}function M(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function v(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=M(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function w(t){if(t){const e=v(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=v(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function x(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");n.fillStyle=t,n.fillRect(0,0,1,1);const o=n.getImageData(0,0,1,1).data;return{r:o[0],g:o[1],b:o[2]}}function y(t){return t*t*(3-2*t)}var b={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function S(t,e,n,o,r,a,i,s,c="spotlight",l=.5,h="circle",d=[],f=1){const m=(t-n)*Math.max(1,f),u=(e-o)*Math.max(1,1/f),g=.08+.35*l+.04*a;let p,M;if("box"===h){const t=Math.abs(m),e=Math.abs(u);p=Math.max(t,e),M=g}else p=Math.sqrt(m*m+u*u),M=g;if(p>=M&&("trail"!==c||0===d.length))return b.scale=1,b.offsetX=0,b.offsetY=0,b.glow=0,b.colorBlend=0,b.proximity=0,b;const v=y(Math.max(0,1-p/M))*r;let w=1,x=0,S=0,E=0,T=0;switch(c){case"spotlight":{w=1+v*a*1.8;const t=Math.atan2(u,m),e=v*v*a*.6;x=Math.cos(t)*e*i,S=Math.sin(t)*e*s,E=v*a*.4,T=v*v*a*.25;break}case"magnify":w=1+v*a*.85,E=v*a*.15;break;case"repel":{w=1;const t=Math.atan2(u,m),e=v*v*a*1.8;x=Math.cos(t)*e*i,S=Math.sin(t)*e*s;break}case"glow":E=v*a*.8,T=v*a*.4;break;case"colorShift":w=1,E=v*a*.12,T=v*a;break;case"attract":{const t=Math.atan2(u,m),e=v*v*a*1;x=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,S=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,E=v*a*.3;break}case"shatter":{const t=Math.atan2(u,m),e=.5*Math.sin(43.7*m+29.3*u),n=v*a*1.4*(.7+.3*e);x=Math.cos(t+e)*n*i,S=Math.sin(t+e)*n*s,w=Math.max(.1,1-v*a*.6),E=v*a*.25;break}case"trail":{let n=v,o=-u*v,r=m*v;for(const a of d){const i=(t-a.x)*Math.max(1,f),s=(e-a.y)*Math.max(1,1/f),c=Math.hypot(i,s)/g;if(c>=1)continue;const l=y(1-c)*a.intensity;n=Math.max(n,l),o+=(.35*a.vx-2*s)*l*.35,r+=(.35*a.vy+2*i)*l*.35}x=Math.tanh(2*o)*a*i*3,S=Math.tanh(2*r)*a*s*3,T=n*a*.65,E=n*a*.35,w=1+n*a*.08,b.proximity=n;break}case"glitchText":w=1,E=v*a*.5,T=v*a*.6}return b.scale=w,b.offsetX=x,b.offsetY=S,b.glow=E,b.colorBlend=T,"trail"!==c&&(b.proximity=v),b}function E(t,e,{continuous:n=!1,interactive:o=!1}={}){const r=t.parentElement??t;let a=null,i=0,s=!1,c=!0,l=!0,h=-1/0;const d=window.matchMedia("(prefers-reduced-motion: reduce)"),f=()=>{l=!0,s||!c||document.hidden||i||(i=requestAnimationFrame(m))},m=t=>{if(i=0,s||!c||document.hidden)return;const o=!d.matches&&(n||t-h<1500);(l||o)&&(e(t,d.matches?null:a),l=!1),o&&(i=requestAnimationFrame(m))},u=e=>{if("touch"===e.pointerType)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const o=(e.clientX-n.left)/n.width,r=(e.clientY-n.top)/n.height;a=o>=0&&o<=1&&r>=0&&r<=1?{x:o,y:r}:null,h=performance.now(),f()},g=()=>{a=null,h=performance.now(),f()},p=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):f()},M="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{c=t.isIntersecting,c?f():i&&(cancelAnimationFrame(i),i=0)});return M?.observe(t),o&&(r.addEventListener("pointermove",u),r.addEventListener("pointerleave",g)),document.addEventListener("visibilitychange",p),d.addEventListener("change",f),f(),{wake:f,stop:()=>{s=!0,cancelAnimationFrame(i),M?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",p),d.removeEventListener("change",f)}}}var T=null,C=null;function A(t,e){if(!T||!C){const n=s(t,e);T=n.canvas,C=n.ctx}return T.width!==t&&(T.width=t),T.height!==e&&(T.height=e),C}var F=new Map,L=new Map,R=new WeakMap;function I(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function k(t){let e=F.get(t);return e||(e=I(t),F.set(t,e)),e}function H(t){return I(t)}function W(t,e,n){const o=n?1-t/255:t/255,r=Math.floor(o*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function P(t,e,n,o){const r=`${t}\0${e?1:0}\0${n}\0${o}`;let a=L.get(r);if(!a){const i=k(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=W(c(t,n,o),i,e);L.set(r,a)}return a}function $(t,e){return"auto"!==t?t:!w(e)}function j(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const n=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return n?[n[1],n[2],n[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function z(t){const e=t||"auto";if("auto"!==e)return j(e)??"ffffff";if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const n=j(t.getPropertyValue(e).trim());if(n)return n}const e=j(getComputedStyle(document.body).accentColor??"");if(e)return e}return w("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function O(t,e,n){return Math.max(e,Math.min(n,t))}function V(t,e,n){if(!t)return{x:0,y:0,width:e,height:n};const o=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===o?t*e:t,i=t=>void 0===t?void 0:"percent"===o?t*n:t,s=O(a(t.left)??0,0,e-1),c=O(a(t.right)??0,0,e-s-1),l=O(i(t.top)??0,0,n-1),h=O(i(t.bottom)??0,0,n-l-1),d=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,f=Math.max(1,e-s-c),m=Math.max(1,n-l-h),u=d?f:a(t.width),g=d?m:i(t.height);let p=u??e,M=g??n;if(r&&!d){const t=p/e,o=M/n,r=Math.min(t,o),a=void 0===u?o:void 0===g?t:r;p=e*a,M=n*a}p=O(p,1,d?f:e),M=O(M,1,d?m:n);const v=t.anchor??"center",w=a(t.x),x=i(t.y),y=d?s:0,b=d?l:0,S=d?f:e,E=d?m:n,T=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-p:(S-p)/2,C=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?E-M:(E-M)/2;return{x:O(w??y+T,0,Math.max(0,e-p)),y:O(x??b+C,0,Math.max(0,n-M)),width:p,height:M}}function q(t,e,n,o){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,s=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,f=n||r,m=o||a,u=Math.floor(f/s),g=Math.floor(m/h);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const p=V(e.sourceCrop,r,a),M=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(p.width/u))),v=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(p.height/g))),w=u*M,y=g*v,b=A(w,y),S=b.globalCompositeOperation;b.globalCompositeOperation="copy";try{b.drawImage(t,p.x,p.y,p.width,p.height,0,0,w,y)}finally{b.globalCompositeOperation=S}const E=b.getImageData(0,0,w,y).data,T=e.chromaKey,C=null!=T&&!1!==T,F=!0===T,L="blue-screen"===T;let R=null,I=0;!C||F||L||(R=x(T),I=(e.chromaKeyTolerance??60)**2);let H=0,j=255;if(e.normalize){let t=255,e=0;for(let n=0;n<E.length;n+=4){if(C){const t=E[n],e=E[n+1],o=E[n+2];let r=!1;if(F)r=e>1.4*t&&e>1.4*o&&e>80;else if(L)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==R){const n=t-R.r,a=e-R.g,i=o-R.b;r=n*n+a*a+i*i<=I}if(r)continue}const o=.299*E[n]+.587*E[n+1]+.114*E[n+2];o<t&&(t=o),o>e&&(e=o)}H=t,j=e>t?e-t:255}const z=[],O=$(e.invert),q=C&&e.charset.replace(/ /g,"")||e.charset,B=k(q),D=e.customText?null:P(q,O,e.brightness,e.contrast),U=M*v;for(let t=0;t<g;t++){const n=[];for(let o=0;o<u;o++){let r=0,a=0,i=0,s=0,h=0;for(let e=0;e<v;e++){const n=(t*v+e)*w;for(let t=0;t<M;t++){const e=4*(n+o*M+t),c=E[e],l=E[e+1],d=E[e+2],f=E[e+3];if(C){let t=!1;if(F)t=l>1.4*c&&l>1.4*d&&l>80;else if(L)t=d>1.4*c&&d>1.4*l&&d>80;else if(null!==R){const e=c-R.r,n=l-R.g,o=d-R.b;t=e*e+n*n+o*o<=I}if(t){h++;continue}}r+=c,a+=l,i+=d,s+=f}}if(C&&h>U/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const f=U-h,m=f>0?r/f:0,g=f>0?a/f:0,p=f>0?i/f:0,x=f>0?s/f:0,y=.299*m+.587*g+.114*p,b=e.normalize?(y-H)/j*255:y,S=c(b,e.brightness,e.contrast),T=e.ditherStrength>0?d(S,o,t,e.ditherStrength):S,A=e.customText?l(T,e.customText,o,t,u,O):e.ditherStrength>0?W(T,B,O):D[Math.max(0,Math.min(255,0|b))];n.push({char:A,r:m,g:g,b:p,a:x,lum:T})}z.push(n)}return{frame:z,cols:u,rows:g}}function B(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,l=e.fontSize/i*e.charSpacing,h=n||r,f=o||a,m=Math.floor(h/s),u=Math.floor(f/l);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,p=u,M=A(g,p),v=V(e.sourceCrop,r,a),w=M.globalCompositeOperation;M.globalCompositeOperation="copy";try{M.drawImage(t,v.x,v.y,v.width,v.height,0,0,g,p)}finally{M.globalCompositeOperation=w}const y=M.getImageData(0,0,g,p).data,b=e.chromaKey,S=null!=b&&!1!==b,E=!0===b,T="blue-screen"===b;let C=null,F=0;!S||E||T||(C=x(b),F=(e.chromaKeyTolerance??60)**2);let L=0,R=255;if(e.normalize){let t=255,e=0;for(let n=0;n<y.length;n+=4){if(S){const t=y[n],e=y[n+1],o=y[n+2];let r=!1;if(E)r=e>1.4*t&&e>1.4*o&&e>80;else if(T)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==C){const n=t-C.r,a=e-C.g,i=o-C.b;r=n*n+a*a+i*i<=F}if(r)continue}const o=.299*y[n]+.587*y[n+1]+.114*y[n+2];o<t&&(t=o),o>e&&(e=o)}L=t,R=e>t?e-t:255}const I=$(e.invert),H=S&&e.charset.replace(/ /g,"")||e.charset,j=k(H),z=e.customText?null:P(H,I,e.brightness,e.contrast),O=e.customText?k(e.customText):null,q="fullcolor"===e.colorMode?new Uint8ClampedArray(m*u*4):void 0,B=[];for(let t=0;t<u;t++){let n="";for(let o=0;o<m;o++){const r=4*(t*g+o),a=r,i=y[r],s=y[r+1],l=y[r+2],h=y[r+3];if(S){let t=!1;if(E)t=s>1.4*i&&s>1.4*l&&s>80;else if(T)t=l>1.4*i&&l>1.4*s&&l>80;else if(null!==C){const e=i-C.r,n=s-C.g,o=l-C.b;t=e*e+n*n+o*o<=F}if(t){n+=" ",q&&(q[a]=0,q[a+1]=0,q[a+2]=0,q[a+3]=0);continue}}q&&(q[a]=i,q[a+1]=s,q[a+2]=l,q[a+3]=h);const f=.299*i+.587*s+.114*l,u=e.normalize?(f-L)/R*255:f,p=e.ditherStrength>0||O?c(u,e.brightness,e.contrast):u,M=e.ditherStrength>0?d(p,o,t,e.ditherStrength):p;if(O){n+=(I?1-M/255:M/255)<.12?" ":O[(t*m+o)%O.length]}else e.ditherStrength<=0?n+=z[Math.max(0,Math.min(255,0|u))]:n+=W(M,j,I)}B.push(n)}return{rows:B,cols:m,rowCount:u,colors:q}}function D(t,e,n,o,r){if(0===e.rows.length)return;const a=t.canvas,i=Boolean(n.chromaKey)||e.rows.some(t=>t.includes(" "));i||(R.delete(t),t.clearRect(0,0,o,r),t.fillStyle=w(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,r));const s=z(n.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),d=o/e.cols,f=r/e.rowCount,m=.9*Math.min(d/.55,f),u=e.colors;if("fullcolor"===n.colorMode&&u){R.delete(t),t.clearRect(0,0,o,r),t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let n="";for(let o=0;o<e.rows.length;o++){const r=H(e.rows[o]);let a=0;for(;a<e.cols;){for(;a<e.cols&&" "===r[a];)a++;if(a>=e.cols)break;const i=a,s=4*(o*e.cols+a),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(a++;a<e.cols&&" "!==r[a];){const t=4*(o*e.cols+a);if((240&u[t])!==c||(240&u[t+1])!==l||(240&u[t+2])!==h)break;a++}const m=`rgb(${c},${l},${h})`;m!==n&&(t.fillStyle=m,n=m),t.fillText(r.slice(i,a).join(""),i*d+.5*d,o*f+.5*f)}}return void(t.globalAlpha=1)}t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const g="matrix"===n.colorMode?"rgb(0,255,0)":"grayscale"===n.colorMode?w(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;t.fillStyle=g,t.globalAlpha=1;const p=R.get(t),M=i&&p&&p.cols===e.cols&&p.rowCount===e.rowCount&&p.canvasWidth===o&&p.canvasHeight===r&&p.fillStyle===g;M||t.clearRect(0,0,o,r);for(let n=0;n<e.rows.length;n++){const r=e.rows[n];M&&p.rows[n]===r||(M&&t.clearRect(0,n*f,o,f+1),0!==r.trim().length&&t.fillText(r,.5*d,n*f+.5*f))}R.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:o,canvasHeight:r,fillStyle:g}),t.globalAlpha=1}async function U(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=q(t,e,n,o);h.push(u.frame),d=u.cols,f=u.rows,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function N(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=B(t,e,n,o);h.push(u),d=u.cols,f=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function K(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const p=g.getContext("2d"),M=document.createElement("canvas"),v=M.getContext("2d"),w=[];let x=0,y=0,b=0;for(const t of c)b+=t.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),T=Math.min(c.length,300);for(let t=0;t<T;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(M,i.left||0,i.top||0);const b=q(m,e,n,o);w.push(b.frame),x=b.cols,y=b.rows,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((t+1)/T)}return{frames:w,cols:x,rows:y,fps:E}}var Y=new WeakMap,_=new WeakMap,G=new WeakMap;function X(t,e,n,o,r,a=0,i){if(!e.length||!e[0].length||o<=0||r<=0)return;let s=null;if(n.hoverStrength>0){let e=Y.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},Y.set(t,e)),s=function(t,e,n){const o=t.time<0?1/60:Math.max(0,Math.min(.1,(n-t.time)/1e3));t.time=n;const r=t.intensity<.003,a=t.x,i=t.y;if(e){r&&(t.x=e.x,t.y=e.y);const n=1-Math.exp(-o/.055);t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n}t.intensity+=((e?.intensity??(e?1:0))-t.intensity)*(1-Math.exp(-o/(e?.09:.18)));const s=Math.exp(-o/.22);for(const e of t.points)e.intensity*=s;for(;t.points.length&&t.points[0].intensity<.01;)t.points.shift();return e&&!r&&n-t.emittedAt>=24&&Math.hypot(t.x-a,t.y-i)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-a)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(t.y-i)/Math.max(o,.001)))}),t.points.length>12&&t.points.shift(),t.emittedAt=n),!e&&t.intensity<.003&&!t.points.length?(t.intensity=0,null):{x:t.x,y:t.y,intensity:t.intensity,trail:t.points}}(e,i??null,performance.now())}else Y.delete(t);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return G.delete(t),void J(t,e,n,o,r,a,s);const c=_.get(t);if(c?.frame!==e)return _.set(t,{frame:e,since:performance.now()}),G.delete(t),void J(t,e,n,o,r,a,s);if(performance.now()-c.since<100)return void J(t,e,n,o,r,a,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void J(t,e,n,o,r,a,s);if(!s||(s.intensity??0)<.003)return void J(t,e,n,o,r,a,null);const h=w(t.canvas),d={...n,accentColor:"#"+z(n.accentColor)},f=JSON.stringify([d,o,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=G.get(t);if(!m||m.frame!==e||m.key!==f){const n=m?.canvas??document.createElement("canvas");n.width=Math.ceil(o*l.a),n.height=Math.ceil(r*l.d);const a=n.getContext("2d");a.setTransform(l.a,0,0,l.d,0,0),J(a,e,d,o,r,0,null,void 0,h),m={frame:e,key:f,canvas:n},G.set(t,m)}if(t.clearRect(0,0,o,r),t.drawImage(m.canvas,0,0,o,r),!s||(s.intensity??0)<.003)return;const u=e.length,g=e[0].length,p=.08+.35*n.hoverRadius+.04*n.hoverStrength,M="trail"===n.hoverEffect?[s,...s.trail??[]]:[s];let v=1,x=1,y=0,b=0;for(const t of M)v=Math.min(v,t.x-p),y=Math.max(y,t.x+p),x=Math.min(x,t.y-p),b=Math.max(b,t.y+p);if("glitchText"===n.hoverEffect){const t=n.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));v=Math.min(v,s.x-e/g),y=Math.max(y,s.x+e/g)}const S=Math.ceil(5+4*n.hoverStrength),E={x:Math.max(0,Math.floor(v*g)-S),y:Math.max(0,Math.floor(x*u)-S),right:Math.min(g,Math.ceil(y*g)+S),bottom:Math.min(u,Math.ceil(b*u)+S)};t.save(),t.beginPath(),t.rect(E.x*o/g,E.y*r/u,(E.right-E.x)*o/g,(E.bottom-E.y)*r/u),t.clip(),J(t,e,d,o,r,a,s,E,h),t.restore()}function J(t,e,o,r,a,s=0,c,l,h){const d=e.length;if(0===d)return;const f=e[0].length;t.clearRect(0,0,r,a);let m=!1;const g=Math.max(1,d>>2),M=Math.max(1,f>>2);t:for(let t=0;t<d;t+=g){const n=e[t];for(let t=0;t<f;t+=M)if(n[t].a<200){m=!0;break t}}const v=t.canvas,x=h??w(v);m||(t.fillStyle=x?"#0a0a0a":"#faf9f7",t.fillRect(0,0,r,a));const y=r/f,b=a/d,E=c?.intensity??1,T=!!(c&&o.hoverStrength>0&&E>.005),C="#"+(j(o.hoverColor||"#ffffff")??"ffffff"),A=parseInt(C.slice(1,3),16),F=parseInt(C.slice(3,5),16),L=parseInt(C.slice(5,7),16),R=z(o.accentColor),I=parseInt(R.substring(0,2),16),H=parseInt(R.substring(2,4),16),P=parseInt(R.substring(4,6),16),O=o.hoverRadius;let V=0,q=f,B=0,D=d,U=0,N=0;if(T&&c){U=c.x,N=c.y;const t=.08+.35*O+.04*o.hoverStrength;V=Math.max(0,Math.floor((U-t)*f)-1),q=Math.min(f,Math.ceil((U+t)*f)+1),B=Math.max(0,Math.floor((N-t)*d)-1),D=Math.min(d,Math.ceil((N+t)*d)+1)}if(T&&"trail"===o.hoverEffect)for(const t of c?.trail??[]){const e=.08+.35*O+.04*o.hoverStrength;V=Math.min(V,Math.max(0,Math.floor((t.x-e)*f)-1)),q=Math.max(q,Math.min(f,Math.ceil((t.x+e)*f)+1)),B=Math.min(B,Math.max(0,Math.floor((t.y-e)*d)-1)),D=Math.max(D,Math.min(d,Math.ceil((t.y+e)*d)+1))}const K=o.animationStyle,Y=o.animationSpeed,_=(G=K,n.find(t=>t.value===G||t.mode===G)?.mode??"none");var G;const X="none"===_,J=[0,0,0,1],Q=o.hoverStrength,Z=o.hoverEffect,tt=O,et=o.hoverShape||"circle",nt=$(o.invert,v),ot=o.colorMode,rt=2*Math.PI,at=1/f,it=1/d;let st="",ct=-1;if("dots"===o.renderMode){const n=.5*Math.min(y,b)*o.dotSizeRatio;for(let o=l?.y??0;o<(l?.bottom??d);o++){const h=e[o];for(let e=l?.x??0;e<(l?.right??f);e++){const l=h[e];if(l.a<10)continue;const m=.00392156863*(.299*l.r+.587*l.g+.114*l.b),g=nt?1-m:m;if(g<.02)continue;X||i(_,e/f,o/d,s*Y,J,(.299*l.r+.587*l.g+.114*l.b)/255);const M=Math.max(0,Math.min(1,(1+J[2])*J[3]));let v=1,w=0,x=0,C=0,R=0;if(T&&e>=V&&e<=q&&o>=B&&o<=D){const t=S(e*at,o*it,U,N,E,Q,y,b,Z,tt,et,c?.trail,r/a);v=t.scale,w=t.offsetX,x=t.offsetY,C=t.glow,R=t.colorBlend}const k=n*g*M*v;if(k<.3)continue;const W=e*y+.5*y+w+J[0],$=o*b+.5*b+x+J[1];let j;if(R>0){const t=p(l,ot,I,H,P,nt);j=`rgb(${Math.min(255,t[0]+(A-t[0])*R|0)},${Math.min(255,t[1]+(F-t[1])*R|0)},${Math.min(255,t[2]+(L-t[2])*R|0)})`}else j=u(l,ot,I,H,P,nt);const z=Math.min(1,.00392156863*l.a*M*(1+C));if(z!==ct&&(t.globalAlpha=z,ct=z),j!==st&&(t.fillStyle=j,st=j),k<=3){const e=2*k;t.fillRect(W-k,$-k,e,e)}else t.beginPath(),t.arc(W,$,k,0,rt),t.fill()}}}else{const n=.55,h=.9*Math.min(y/n,b);{const e=/\p{Extended_Pictographic}/u.test(o.customText||o.charset);t.font=e?`${h}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${h}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const m=o.charsetFrames,g=!!m?.length,M=g?m[Math.floor(Math.max(0,s)*(o.charsetFps??2))%m.length]:o.charset,v=t.getTransform();if(!T&&X&&!g&&"accent"===ot&&!l&&o.hoverStrength<=0&&!/\p{Extended_Pictographic}/u.test(o.customText||o.charset)&&"letterSpacing"in t&&/^[\x20-\x7e]*$/.test(o.customText||o.charset)&&e.every(t=>t.every(t=>t.a<10||255===t.a&&1===t.char.length&&/^[\x20-\x7e]$/.test(t.char)))){const n=t.letterSpacing;t.letterSpacing="0px";const o=t.measureText("M").width;t.letterSpacing=y-o+"px",t.fillStyle=`rgb(${I},${H},${P})`,t.globalAlpha=1,t.textAlign="left";for(let n=0;n<d;n++){const r=e[n];let a="";for(let t=0;t<f;t++){const e=r[t];a+=e.a<10?" ":e.char}0!==a.trim().length&&t.fillText(a,.5*(y-o),n*b+.5*b)}return t.letterSpacing=n,t.textAlign="center",void(t.globalAlpha=1)}const w="glitchText"===Z&&T,x="!@#$%^&*<>{}[]|/\\~`0123456789",C=x.length;let R="",$=0,j=0,z=0,K=0,G=0,rt=0;if(w){const t=o.hoverText??"ASCIIFY";if(j=Math.round(U*f),z=Math.round(N*d),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");R=e[((7*Math.floor(j/Math.max(1,Math.ceil(f/5)))+13*Math.floor(z/Math.max(1,Math.ceil(d/3))))%e.length+e.length)%e.length]}else R=t||"ASCIIFY";$=R.length,K=Math.max(3,Math.min(12,Math.round(d*O*.6)));const e=Math.floor(K/2);G=Math.max(0,z-e),G+K>d&&(G=Math.max(0,d-K)),rt=j-Math.floor($/2)}for(let n=l?.y??0;n<(l?.bottom??d);n++){const o=e[n];for(let h=l?.x??0;h<(l?.right??f);h++){const l=o[h];if(l.a<10)continue;let m=g&&null!=l.lum?W(l.lum,k(M),nt):l.char;if(" "===m)continue;X||i(_,h/f,n/d,s*Y,J,(.299*l.r+.587*l.g+.114*l.b)/255);const O=Math.max(0,Math.min(1,(1+J[2])*J[3]));if(O<.05)continue;let lt=1,ht=0,dt=0,ft=0,mt=0;if(T&&!w&&h>=V&&h<=q&&n>=B&&n<=D){const t=S(h*at,n*it,U,N,E,Q,y,b,Z,tt,et,c?.trail,r/a);if(lt=t.scale,ht=t.offsetX,dt=t.offsetY,ft=t.glow,mt=t.colorBlend,"trail"===Z&&t.proximity>0){const o=Math.max(0,Math.min(f-1,Math.round(h-t.offsetX/y))),r=e[Math.max(0,Math.min(d-1,Math.round(n-t.offsetY/b)))][o],a=r.lum??.299*r.r+.587*r.g+.114*r.b;m=W(Math.min(255,a+t.proximity*Q*65),k(M),nt)}}if(w&&n>=G&&n<G+K){const t=h-rt;if(t>=0&&t<$){const e=R[t],o=Math.abs(n-z)/Math.max(1,.5*K),r=Math.abs(h-j)/Math.max(1,$),a=Math.max(o,r),i=Math.max(0,Math.min(1,1-.9*a)),c=43758.5453*Math.sin(127.1*h+311.7*n+43758.5453*Math.floor(12*s));m=Math.abs(c-Math.floor(c))<i?e:x[Math.abs(Math.floor(97*c))%C],ft=.3+.7*i,mt=.3+.65*i}}const ut=h*y+.5*y+ht+J[0],gt=n*b+.5*b+dt+J[1];let pt;if(mt>0){const t=p(l,ot,I,H,P,nt);pt=`rgb(${Math.min(255,t[0]+(A-t[0])*mt|0)},${Math.min(255,t[1]+(F-t[1])*mt|0)},${Math.min(255,t[2]+(L-t[2])*mt|0)})`}else pt=u(l,ot,I,H,P,nt);const Mt=Math.min(1,.00392156863*l.a*O*(1+ft));Mt!==ct&&(t.globalAlpha=Mt,ct=Mt),pt!==st&&(t.fillStyle=pt,st=pt),1!==lt?(t.translate(ut,gt),t.scale(lt,lt),t.fillText(m,0,0),t.setTransform(v)):t.fillText(m,ut,gt)}}}t.globalAlpha=1}function Q(t="classic"){if("classic"!==t)throw new RangeError(`Art preset "${String(t)}" was removed in 4.1. Use a StudioStyle with asciify-engine/studio, or supply options.charset directly.`);return{artStyle:"classic"}}function Z(t){return Math.max(0,Math.min(1,t))}function tt(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function et(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function nt(t,e={}){const n=Z(t),o=Z(n*(void 0===e.speed?1:Math.max(.001,e.speed)));return Z(e.ease?e.ease(o):o)}function ot(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const o=n.from??0,r=n.to??t.duration,a=Math.max(o,Math.min(r,t.duration)),i=nt(e,n),s=o+(a-o)*i;t.currentTime=Math.min(Math.max(o,s),Math.max(o,a-.04)),n.onUpdate?.(i,t)}function rt(t,e){return Math.abs(t.currentTime-e)<1/240?at(t):new Promise(n=>{const o=()=>{t.removeEventListener("seeked",o),n()};t.addEventListener("seeked",o,{once:!0});const r=t.fastSeek;r?r.call(t,e):t.currentTime=e})}function at(t){const e=t.requestVideoFrameCallback;return new Promise(e?n=>{let o=!1;const r=()=>{o||(o=!0,n())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function it(t,e={}){const n=tt(e.trigger)??t;t.pause();const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:n,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:n=>ot(t,n.progress,e)});return()=>a.kill?.()}return function(t,e,n){let o=0;const r=()=>{o=0;const r=e.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?Z((a-r.top)/i):0;ot(t,s,n)},a=()=>{o||(o=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),o&&cancelAnimationFrame(o)}}(t,n,e)}function st(t,e,n){const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>n(t.progress)});return()=>a.kill?.()}return function(t,e){let n=0;const o=()=>{n=0;const o=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=o.height+r,i=a>0?Z((r-o.top)/a):0;e(i)},r=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),n&&cancelAnimationFrame(n)}}(t,n)}function ct(t,e,n){if(!t||!e||!n.sourceCrop)return{w:t,h:e};const o=V(n.sourceCrop,t,e);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function lt(t,e,n,o){const r=o.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return e>1.4*t&&e>1.4*n&&e>80;if("blue-screen"===r)return n>1.4*t&&n>1.4*e&&n>80;const a=x(r),i=(o.chromaKeyTolerance??60)**2,s=t-a.r,c=e-a.g,l=n-a.b;return s*s+c*c+l*l<=i}function ht(t,e,n){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const o=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!o||!r)return e;const a=V(e.sourceCrop,o,r),i=Math.min(360,Math.max(1,Math.round(a.width))),c=Math.max(1,Math.round(i*(a.height/a.width))),{ctx:l}=s(i,c);l.drawImage(t,a.x,a.y,a.width,a.height,0,0,i,c);const h=l.getImageData(0,0,i,c).data,d=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let f=i,m=c,u=-1,g=-1;for(let t=0;t<c;t++)for(let n=0;n<i;n++){const o=4*(t*i+n),r=h[o+3],a=h[o],s=h[o+1],c=h[o+2];r<=8||.2126*a+.7152*s+.0722*c<=d||lt(a,s,c,e)||(n<f&&(f=n),t<m&&(m=t),n>u&&(u=n),t>g&&(g=t))}if(u<f||g<m)return e;const p=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),M=Math.round(i*p),v=Math.round(c*p);f=Math.max(0,f-M),m=Math.max(0,m-v),u=Math.min(i-1,u+M),g=Math.min(c-1,g+v);const w=function(t,e,n,o,r){const a=r&&Number.isFinite(r)&&r>0?r:null;if(!a)return t;const i=e.x,s=e.y,c=e.x+e.width,l=e.y+e.height,h=Math.max(i,t.left),d=Math.max(s,t.top),f=Math.min(c,n-t.right),m=Math.min(l,o-t.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),p=h+u/2,M=d+g/2;let v=u,w=g;v/w<a?v=w*a:w=v/a;v>e.width&&(v=e.width,w=Math.max(g,Math.min(e.height,v/a)));w>e.height&&(w=e.height,v=Math.max(u,Math.min(e.width,w*a)));let x=p-v/2,y=M-w/2;return x=Math.max(i,Math.min(c-v,x)),y=Math.max(s,Math.min(l-w,y)),{left:x,top:y,right:n-(x+v),bottom:o-(y+w)}}({left:a.x+f/i*a.width,top:a.y+m/c*a.height,right:o-(a.x+(u+1)/i*a.width),bottom:r-(a.y+(g+1)/c*a.height)},{x:a.x,y:a.y,width:a.width,height:a.height},o,r,n);return{...e,sourceCrop:{unit:"pixel",...w,preserveAspect:!1}}}function dt(t){const e=t.sourceCrop;return e&&"pixel"===e.unit?void 0===e.left||void 0===e.top||void 0===e.right||void 0===e.bottom?null:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}:null}async function ft(t,e,n,o,r){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const a=t.currentTime,i=function(t,e,n,o){const r=!0===o?{}:o||{},a=Math.max(0,r.from??e),i=r.to??n??(Number.isFinite(t.duration)?t.duration:a),s=Math.max(a,i-.04),c=Math.max(0,s-a),l=c>.1?[a,a+.25*c,a+.5*c,a+.75*c,s]:[a];return Array.from(new Set(l.map(t=>Math.max(0,Number(t.toFixed(3))))))}(t,n,o,r);let s=null;for(const n of i){await rt(t,n),await at(t);const o=dt(ht(t,e));o&&(s=s?{left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.min(s.right,o.right),bottom:Math.min(s.bottom,o.bottom)}:o)}return await rt(t,a),await at(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function mt(t,e,n=2048){return ut({sourceWidth:t,sourceHeight:e,maxRenderDimension:n})}function ut({sourceWidth:t,sourceHeight:e,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:r=2048}){const a=Math.max(1,t),i=Math.max(1,e),s=a/i,c=Math.max(1,r),l=Math.min(1,c/Math.max(a,i)),h=Math.max(a,i)*l,d=Math.max(0,n,o),f=Math.min(c,Math.max(h,d));return s>=1?{renderW:Math.round(f),renderH:Math.round(f/s)}:{renderW:Math.round(f*s),renderH:Math.round(f)}}function gt(t,e,n,o){if(void 0===t)return;if("number"==typeof t)return t;const r=t.trim();if(r.endsWith("%")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?e*t:void 0}if(r.endsWith("px")){const t=Number.parseFloat(r);return Number.isFinite(t)?t:void 0}if(r.endsWith("vw")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?n*t:void 0}if(r.endsWith("vh")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?o*t:void 0}}function pt(t,e,n,o,r,a=2048,i={}){const{width:s,height:c}=e.getBoundingClientRect();if(!s||!c)return{renderW:0,renderH:0,dpr:1};const l="undefined"!=typeof window?window.innerWidth:s,h="undefined"!=typeof window?window.innerHeight:c,d=gt(i.width,s,l,h)??s,f=gt(i.height,c,l,h)??c,m=function(t,e,n,o,r){const a=t=>{const n=gt(t,e,o,r);return n&&n>0?n:0},i=t=>{const e=gt(t,n,o,r);return e&&e>0?e:0};return void 0===t?{x:0,y:0}:"number"==typeof t||"string"==typeof t?{x:a(t),y:i(t)}:{x:a(t.x),y:i(t.y)}}(i.bleed,s,c,l,h),u=d+2*m.x,g=f+2*m.y,{cssW:p,cssH:M}=function(t,e,n,o="contain"){if("fill"===o)return{cssW:t,cssH:e};let r=t,a=r/n;const i="cover"===o,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*n),"scale-down"===o&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,n,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let w,x;o&&r?({renderW:w,renderH:x}=ut({sourceWidth:o,sourceHeight:r,cssWidth:p,cssHeight:M,maxRenderDimension:a})):(w=p,x=M);const y=8e6,b=w*v*x*v>y?Math.sqrt(y/(w*x)):v;return t.width=Math.round(w*b),t.height=Math.round(x*b),t.style.width=`${p}px`,t.style.height=`${M}px`,{renderW:w,renderH:x,dpr:b}}async function Mt(t,n,{fontSize:o,artStyle:r="classic",options:a={},fitTo:i,objectFit:s,objectPosition:c,scale:l,width:h,height:d,bleed:f,preExtract:m=!1,fps:u,maxRenderDimension:g=2048,trim:p,scroll:M,maxCachedFrames:v=90,onReady:w,onFrame:x}={}){const y=p?.start??0,b=p?.end,S=o??a.fontSize??10;let T={...e,...Q(r),artStyle:r,...a,fontSize:S};const C=n.getContext("2d");if(!C)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof i?document.querySelector(i):i instanceof HTMLElement?i:null,F={objectFit:s,objectPosition:c,scale:l,width:h,height:d,bleed:f},L=function(t,e){var n;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height||void 0!==t.bleed}(e))return()=>{};const o={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0===e.scale&&void 0===e.bleed||(t.style.maxWidth="none",t.style.maxHeight="none"),void 0!==e.scale){const o=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(o)),(n=t.style).transformOrigin||(n.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=o.width,t.style.height=o.height,t.style.objectFit=o.objectFit,t.style.objectPosition=o.objectPosition,t.style.maxWidth=o.maxWidth,t.style.maxHeight=o.maxHeight,t.style.transformOrigin=o.transformOrigin,o.scale?t.style.setProperty("scale",o.scale):t.style.removeProperty("scale")}}(n,F),R=t=>()=>{t(),L()};if(m){let e;"string"==typeof t?(e=document.createElement("video"),e.crossOrigin="anonymous",e.src=t,e.readyState<2&&await new Promise((n,o)=>{e.onloadeddata=()=>n(),e.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))})):e=t,T=await ft(e,T,y,b,M);const o=ct(e.videoWidth,e.videoHeight,T);A&&pt(n,A,o.w/o.h,o.w,o.h,g,F);const{renderW:r,renderH:a}=mt(o.w,o.h,g),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;n.width===Math.round(r*c)&&n.height===Math.round(a*c)||(n.width=Math.round(r*c),n.height=Math.round(a*c));const l=void 0!==b?b-y:10,h=u??(M?18:void 0);if(et(T)){const{frames:t,fps:o}=await N(e,T,r,a,h,l,void 0,y),i=e=>{const n=t[e];n&&(C.save(),C.setTransform(c,0,0,c,0,0),D(C,n,T,r,a),C.restore(),x?.())};if(M){let o=!1,r=-1;const a=!0===M?{}:M,s=st(tt(a.trigger)??A??n,a,n=>{const s=nt(n,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),o||(o=!0,w?.(e)),a.onUpdate?.(s,e))});return i(0),o=!0,w?.(e),R(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/o,p=n=>{d||(n-m>=g&&(i(f),f=(f+1)%t.length,m=n,u&&(u=!1,w?.(e))),s=requestAnimationFrame(p))};return s=requestAnimationFrame(p),R(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await U(e,T,r,a,h,l,void 0,y);if(!d.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const p=performance.now(),v=E(n,(t,e)=>{M||(m=Math.floor((t-p)*f/1e3)%d.length),C.save(),C.setTransform(c,0,0,c,0,0),X(C,d[m],T,r,a,(t-p)/1e3,e),C.restore(),x?.()},{continuous:!M||"none"!==T.animationStyle||!!T.charsetFrames?.length,interactive:T.hoverStrength>0});let S;if(M){const t=!0===M?{}:M;S=st(tt(t.trigger)??A??n,t,n=>{m=Math.max(0,Math.min(d.length-1,Math.round(nt(n,t)*(d.length-1)))),v.wake(),t.onUpdate?.(n,e)})}return w?.(e),R(()=>{v.stop(),S?.()})}let I,k=!1;"string"==typeof t?(I=document.createElement("video"),I.crossOrigin="anonymous",I.src=t,I.muted=!0,I.loop=!0,I.playsInline=!0,I.setAttribute("playsinline",""),Object.assign(I.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(I),k=!0,await new Promise((e,n)=>{I.onloadedmetadata=()=>e(),I.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))}),await I.play().catch(()=>{})):(I=t,I.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{I.removeEventListener("loadedmetadata",o),I.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};I.addEventListener("loadedmetadata",o),I.addEventListener("error",r),I.load()}),I.paused&&await I.play().catch(()=>{})),y>0&&(I.currentTime=y,await new Promise(t=>{const e=()=>{I.removeEventListener("seeked",e),t()};I.addEventListener("seeked",e)}),await at(I));let H=null;(y>0||void 0!==b)&&(H=()=>{(void 0!==b&&I.currentTime>=b||y>0&&I.currentTime<y)&&(I.currentTime=y)},I.addEventListener("timeupdate",H)),T=await ft(I,T,y,b,M);let W=null;const P=ct(I.videoWidth,I.videoHeight,T);let{renderW:$,renderH:j}=mt(P.w,P.h,g);const z=t=>"frame"===T.chromaKeyTrimMode?ht(t,T,$/j):T;if(A){const t=P.w/P.h,e=P.w,o=P.h,r=pt(n,A,t,e,o,g,F);$=r.renderW,j=r.renderH;const a=n.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),W=new ResizeObserver(()=>{const r=pt(n,A,t,e,o,g,F);$=r.renderW,j=r.renderH;const a=n.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),W.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,e=8e6,o=$*t*j*t>e?Math.sqrt(e/($*j)):t;n.width===Math.round($*o)&&n.height===Math.round(j*o)||(n.width=Math.round($*o),n.height=Math.round(j*o)),C.setTransform(o,0,0,o,0,0)}let O=!0,V=null;const K=M&&!m,Y=u&&u>0?1e3/u:0;let _=0;const G=!K&&et(T);if(K&&"ascii"===T.renderMode&&"none"===T.animationStyle&&T.hoverStrength<=0&&!T.charsetFrames?.length){const t=!0===M?{}:M,e=tt(t.trigger)??A??n,o=t.from??y,r=t.to??b??I.duration,a=Math.max(o,Math.min(r,I.duration)),i=Math.max(.001,a-o),s=Math.min(60,Math.max(12,u??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(v))),f=()=>{for(;h.length>d;){const t=h.findIndex(t=>t!==g&&Math.abs(t-g)>2),e=t>=0?t:0,n=h.splice(e,1)[0];void 0!==n&&(l[n]=void 0)}},m=t=>{const e=h.indexOf(t);e>=0&&h.splice(e,1),h.push(t),f()};let g=0,p=0,S=-1,E=0,F=!1,L=!1,P=!1;const O=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=I.crossOrigin||"anonymous",q.src=I.currentSrc||I.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{q.removeEventListener("loadedmetadata",o),q.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",o),q.addEventListener("error",r),q.load()}),q.pause(),I.paused&&await I.play().catch(()=>{});const U=t=>o+i*t/Math.max(1,c-1),N=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),K=z(I),G=B(I,K,$,j);G.rows.length>0&&(l[0]=G,m(0),D(C,G,K,$,j),P=!0,w?.(I),x?.());const X=t=>{if(l[t])return t;for(let e=1;e<c;e++){const n=t-e,o=t+e;if(n>=0&&l[n])return n;if(o<c&&l[o])return o}return-1},J=()=>{if(!l[g])return g;for(const t of O)if(!l[t])return t;for(let t=1;t<c;t++){const e=g-t,n=g+t;if(e>=0&&!l[e])return e;if(n<c&&!l[n])return n}return-1},Q=t=>{t<0||t>=c||l[t]||(O.add(t),et())},et=async()=>{if(F||L)return;const t=J();if(!(t<0)){O.delete(t),L=!0;try{if(await rt(q,U(t)),!F){const e=z(q),n=B(q,e,$,j);n.rows.length>0&&(l[t]=n,m(t))}}finally{L=!1,F||requestAnimationFrame(()=>{et()})}}},ot=()=>{if(F)return;const t=X(g);if(t>=0&&t!==S){const e=l[t];e&&(D(C,e,T,$,j),S=t,P||(P=!0,w?.(I)),x?.())}else if(t<0||S<0){const t=performance.now();if(Y<=0||t-_>=Y){const e=z(I),n=B(I,e,$,j);n.rows.length>0&&(D(C,n,e,$,j),_=t,P||(P=!0,w?.(I)),x?.())}}Q(g),E=requestAnimationFrame(ot)};return V=st(e,t,e=>{const n=function(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const o=n.from??0,r=n.to??t.duration,a=Math.max(o,Math.min(r,t.duration)),i=nt(e,n),s=o+(a-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,a-.04))}}(I,e,{...t,from:o,to:a});p=n?.progress??Z(e),g=N(p),Q(g),Q(g-1),Q(g+1),Q(g-2),Q(g+2),Q(g-3),Q(g+3),t.onUpdate?.(p,I)}),Q(0),Q(1),E=requestAnimationFrame(ot),R(()=>{F=!0,cancelAnimationFrame(E),V?.(),W?.disconnect(),O.clear(),h.length=0,l.fill(void 0),q.pause(),q.src="",q.removeAttribute("src"),q.load(),q.isConnected&&q.remove(),H&&I.removeEventListener("timeupdate",H),k&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}if(K){const t=!0===M?{}:M;V=it(I,{...t,trigger:t.trigger??A??n,from:t.from??y,to:t.to??b})}let J=-1,ot=0,lt=-1,dt=0;const ut="function"==typeof I.requestVideoFrameCallback,gt=()=>{dt=I.requestVideoFrameCallback(()=>{ot++,gt()})};ut&>();let Mt=0,vt=0,wt=null;const xt=E(n,(t,e)=>{if(I.readyState<2||0===n.width||0===n.height)return;if(Y>0&&t-_<Y&&!e)return;if(y>0&&I.currentTime<y)return;if(void 0!==b&&I.currentTime>=b)return;const o=(ut?ot!==lt:I.currentTime!==J)||Mt!==$||vt!==j;if(o||!(T.hoverStrength<=0)||"none"!==T.animationStyle||T.charsetFrames?.length){if(G){const t=z(I),e=B(I,t,$,j);D(C,e,t,$,j)}else!o&&wt||(wt=q(I,z(I),$,j).frame),X(C,wt,T,$,j,t/1e3,e);J=I.currentTime,lt=ot,Mt=$,vt=j,_=t,O&&(O=!1,w?.(I)),x?.()}},{continuous:!0,interactive:T.hoverStrength>0});return R(()=>{xt.stop(),dt&&I.cancelVideoFrameCallback(dt),V?.(),W?.disconnect(),H&&I.removeEventListener("timeupdate",H),k&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}function vt(t,e,n,o="#505050",r=100){if(!t||e<=0||n<=0)return[];const a=function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return n?{r:+n[1],g:+n[2],b:+n[3]}:null}(o)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:n},(t,n)=>Array.from({length:e},(t,o)=>({char:i[(n*e+o)%s],r:a.r,g:a.g,b:a.b,a:r})))}var wt=new WeakMap;function xt(t,{format:e="png",quality:n=.92,scale:o=1}={}){return new Promise((r,a)=>{let i=t;if(1!==o){const e=document.createElement("canvas");e.width=Math.round(t.width*o),e.height=Math.round(t.height*o);const n=e.getContext("2d");if(!n)return void a(new Error("captureSnapshot: could not get 2d context"));n.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}`,n)})}var yt={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]},bt=[127,65,65,65,65,65,127];function St(t){return yt[t]??yt[t.toUpperCase()]??bt}function Et(t,e={}){if(!t)return"";const{char:n="█",scale:o=1}=e,r=[...n][0]??"█",a=Math.max(1,Math.floor(o)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const n=St(t[e]);for(let t=0;t<7;t++){const e=n[t];let o="";for(let t=6;t>=0;t--)o+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=o}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}var Tt=["ascii","blocks","braille","dots","lines","cross","diagonal","diamond","mixed","pixel","mosaic","lego","voxel","disco","dither","hex","led","cmyk","stipple","engraving","crosshatch","woodblock","risograph","pointillism"];exports.CHARACTER_SETS=t,exports.DEFAULT_OPTIONS=e,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.PALETTE_THEMES={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"}},exports.STUDIO_STYLES=Tt,exports.asciiText=function(t,n={},o,r){const a={...e,...n},{frame:i,cols:s}=q(t,a,o,r);if(!i.length||0===s)return"";const c=[];for(const t of i)c.push(t.map(t=>t.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(t,n={},o,r){const a={...e,...n},{frame:i,cols:s}=q(t,a,o,r);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const n of t)" "===n.char||n.a<10?e+=" ":e+=`[38;2;${n.r};${n.g};${n.b}m${n.char}[0m`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,n,{fontSize:o,artStyle:r="classic",options:a={}}={}){let i;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((n,o)=>{e.onload=()=>n(),e.onerror=()=>o(new Error(`Failed to load image: ${t}`)),e.src=t}),i=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=()=>n(new Error("Image failed to load"))}),i=t):i=t;const s=Q(r),c=o??a.fontSize??10,l={...e,...s,artStyle:r,...a,fontSize:c},h=n.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{w:d,h:f}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(i),{renderW:m,renderH:u}=mt(d,f),g="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,M=m*g*u*g>p?Math.sqrt(p/(m*u)):g;n.width===Math.round(m*M)&&n.height===Math.round(u*M)||(n.width=Math.round(m*M),n.height=Math.round(u*M));const{frame:v}=q(i,l,m,u),w=(t,e)=>{h.save(),h.setTransform(M,0,0,M,0,0),X(h,v,l,m,u,t/1e3,e),h.restore()};return w(0,null),E(n,w,{continuous:"none"!==l.animationStyle||!!l.charsetFrames?.length,interactive:l.hoverStrength>0}).stop},exports.asciifyGif=async function(t,n,{fontSize:o,artStyle:r="classic",options:a={}}={}){const i="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??a.fontSize??10;let c={...e,...Q(r),artStyle:r,...a,fontSize:s};const l=n.getContext("2d");if(!l)throw new Error("Could not get 2d context from canvas");const{frames:h,fps:d}=await K(i,c,n.width,n.height);if(!h.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const f=performance.now();let m=-1;return E(n,(t,e)=>{const o=Math.floor((t-f)*d/1e3)%h.length;o===m&&!e&&c.hoverStrength<=0&&"none"===c.animationStyle&&!c.charsetFrames?.length||(X(l,h[o],c,n.width,n.height,(t-f)/1e3,e),m=o)},{continuous:!0,interactive:c.hoverStrength>0}).stop},exports.asciifyLiveVideo=function(t,e,n){return Mt(t,e,n)},exports.asciifyText=Et,exports.asciifyVideo=Mt,exports.asciifyWebcam=async function(t,{fontSize:n=10,style:o="classic",options:r={},liveOptions:a,mirror:i=!0,constraints:s={facingMode:"user"},dpr:c}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const l=Q(o),h=await navigator.mediaDevices.getUserMedia({video:s}),d=document.createElement("video");d.srcObject=h,d.muted=!0,d.playsInline=!0,await new Promise((t,e)=>{d.onloadedmetadata=()=>t(),d.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),d.play().catch(e)});const f={...e,...l,...r,fontSize:n},m=t.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=c??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const p=e=>{const n=t.getBoundingClientRect();g={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},M=()=>{g=null};f.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",M));let v,w=!1;const x=performance.now(),y=e=>{if(!w){if(d.readyState>=d.HAVE_CURRENT_DATA){const n=t.width/u,o=t.height/u,r=(e-x)/1e3,s=a?{...f,...a()}:f;s.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",M)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",M));const{frame:c}=q(d,s,n,o),l=g&&i?{x:1-g.x,y:g.y}:g;i?(m.save(),m.scale(-1,1),m.translate(-n,0),X(m,c,s,n,o,r,l),m.restore()):X(m,c,s,n,o,r,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{w=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",M),h.getTracks().forEach(t=>t.stop()),d.srcObject=null}},exports.buildTextFrame=vt,exports.captureSnapshot=xt,exports.clearAsciifyCaches=function(){F.clear(),L.clear(),Y=new WeakMap,G=new WeakMap,_=new WeakMap,T=null,C=null},exports.computeCanvasRenderSize=ut,exports.createVideoScrollScrub=it,exports.gifToAsciiFrames=K,exports.gifToAsciiTextFrames=async function(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const p=g.getContext("2d"),M=document.createElement("canvas"),v=M.getContext("2d"),w=[];let x=0,y=0,b=0;for(const t of c)b+=t.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),T=Math.min(c.length,300);for(let t=0;t<T;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(M,i.left||0,i.top||0);const b=B(m,e,n,o);w.push(b),x=b.cols,y=b.rowCount,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((t+1)/T)}return{frames:w,cols:x,rows:y,fps:E}},exports.imageToAsciiFrame=q,exports.imageToAsciiTextFrame=B,exports.renderFrameToCanvas=X,exports.renderTextBackground=function(t,n,o,r,a={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:d="spotlight",hoverStrength:f=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=a,g=Math.max(1,Math.floor(n/s)),p=Math.max(1,Math.floor(o/(s*c))),M=JSON.stringify([r,g,p,l,h]);let v=wt.get(t);v&&v.key===M||(v={key:M,frame:vt(r,g,p,l,h)},wt.set(t,v)),X(t,v.frame,{...e,fontSize:s,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},n,o,0,i??null)},exports.renderTextFrameToCanvas=D,exports.renderTextToCanvas=function(t,e,n={}){const{color:o="#d4ff00",bgColor:r,fontSize:a=10}=n,i=Et(e,n);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.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=o,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))},exports.snapshotAndDownload=async function(t,e={}){const{filename:n="asciify-snapshot",format:o="png",...r}=e,a=await xt(t,{format:o,...r}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=U,exports.videoToAsciiTextFrames=N;//# sourceMappingURL=core.cjs.map
|
|
1
|
+
"use strict";var t={standard:{label:"Classic ASCII",chars:" .:-=+*#%@"},asciify:{label:"Asciify",chars:" .:-=+YCIFSA#@"},minimal:{label:"Minimal",chars:" .:+"},detailed:{label:"Detailed",chars:" .,:;-~=+*xX#%@"},letters:{label:"Letters",chars:" .liLTYCFSAWM"},technical:{label:"Technical",chars:" ._:;+/>=][{}*$#@"},blocks:{label:"Tonal blocks",chars:" ░▒▓█"},braille:{label:"Braille",chars:" ⠁⠃⠇⡇⣇⣧⣷⣿"}},e={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:t.standard.chars,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",fineDither:!1,customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},n={caustics:"sheen",grain:"shimmer",trace:"relight",tidal:"current",weave:"current",breeze:"current",reform:"develop",print:"develop",unfold:"develop"},o=[{value:"none",mode:"none",group:"Still",label:"Off",description:"Keep the image still. Hover stays available."},{value:"relight",mode:"relight",group:"Light",label:"Relight",description:"A key light circles the subject and models its own relief, like moving a lamp around a sculpture."},{value:"sheen",mode:"sheen",group:"Light",label:"Specular sweep",description:"One slow pass of light glances across the highlights and follows their form, then rests."},{value:"glow",mode:"glow",group:"Light",label:"Highlight bloom",description:"The brightest areas breathe a soft halo into their surroundings. Shadows stay deep."},{value:"shimmer",mode:"shimmer",group:"Light",label:"Glints",description:"Sparse glints on bright fine detail, like light on water, metal or an eye. Everything else holds still."},{value:"parallax",mode:"parallax",group:"Depth",label:"Parallax",description:"A slow camera drift: the subject moves against its background, read from the photo’s own depth cues."},{value:"push",mode:"push",group:"Depth",label:"Slow push",description:"A gentle push toward the subject and back, with nearer areas moving slightly more."},{value:"focus",mode:"focus",group:"Depth",label:"Focus pull",description:"Focus racks from the subject to the background and back; the characters soften out of focus."},{value:"mist",mode:"mist",group:"Atmosphere",label:"Mist",description:"Soft mist drifts through the distance and plain areas, leaving the subject clear."},{value:"current",mode:"current",group:"Atmosphere",label:"Drift",description:"Sky, water and smooth grounds flow slowly, like a cinemagraph; detailed areas hold still."},{value:"develop",mode:"develop",group:"Reveal",label:"Develop",description:"The image holds, fades, then develops back in from its highlights to its shadows, like a print in the tray."}];var r=t=>Math.max(0,Math.min(1,t)),a=(t,e,n)=>{const o=r((n-t)/(e-t));return o*o*(3-2*o)},i=(t,e)=>{const n=(.06711056*t+.00583715*e)%1*52.9829189;return n-Math.floor(n)};function s(t,e,n,o,s,c=.5,l,h=0){if(s[0]=s[1]=s[2]=0,s[3]=1,"none"===t)return s;c=r(c);const d=l?l[h]:c,f=l?l[h+1]:.5+.5*r(1-2*Math.hypot(e-.5,n-.55)),m=l?l[h+2]:a(.55,1,c)**2,u=l?l[h+3]:.5,g=l?l[h+4]:0,p=l?l[h+5]:0,M=o*Math.PI/6,v=(o%12+12)%12,w=a(0,.12,Math.min(e,1-e,n,1-n));if("relight"===t){const t=M+.6,o=Math.cos(t),r=Math.sin(t),i=Math.max(-1,Math.min(1,g*o+p*r))+.35*(o*(e-.5)+r*(n-.5));s[2]=.2*i*(.3+.7*a(.04,.3,d)*(1-.6*a(.82,1,c)))}else if("sheen"===t){const t=1.9*a(0,8,v)-.35,o=(.75*e+.45*n)/1.2+.05*(.75*g+.45*p),r=Math.exp(-(((o-t)/.12)**2));s[2]=r*a(.3,.8,d)*(1-.5*a(.9,1,c))*.45}else if("glow"===t){const t=.5-.5*Math.cos(M),e=1-.8*t;s[2]=.2*a(e-.3,e+.02,m)*Math.sqrt(m)*(1-.65*c)+.05*t*a(.6,.95,c)}else if("shimmer"===t){const t=i(Math.floor(160*e),Math.floor(100*n))*Math.PI*2,o=Math.pow(.5+.5*Math.cos(2*M+t),28);s[2]=o*a(.5,.88,c)*(.35+.65*a(.1,.55,u))*.42}else if("parallax"===t){const t=f-.45;s[0]=16*t*Math.sin(M)*w,s[1]=7*t*Math.sin(2*M)*w}else if("push"===t){const t=.045*(.5-.5*Math.cos(M))*(.7+.6*f)*960,o=l?l[h+6]:.5,r=l?l[h+7]:.5;s[0]=(e-o)*t,s[1]=(n-r)*t}else if("focus"===t){const t=Math.sin(M),e=t*t*a(.15,.6,t>=0?1-f:f);s[2]=(d-c)*e*.9}else if("mist"===t){const t=Math.pow(1-f,1.5)*(1-.6*u),o=.5*Math.sin(4.1*e-M+.9*Math.sin(3.3*n+M))+.3*Math.sin(7.3*e+2.1*n-2*M+1.1*Math.sin(2.7*e-5.1*n+M))+.2*Math.sin(5.7*n-1.9*e+M);s[2]=a(-.3,.9,o)*t*.16*(1-.55*c)}else if("current"===t){const t=(1-.4*u)*(1-.8*f)*w,o=t=>14*n-t+1.5*Math.sin(3*e+t);s[0]=7*(Math.sin(o(M))-Math.sin(o(0))+.43*(Math.sin(5*e-3*n+M)-Math.sin(5*e-3*n)))*t,s[1]=2*(Math.sin(11*e+M)-Math.sin(11*e))*t,s[2]=.03*(Math.cos(o(M))-Math.cos(o(0)))*t}else if("develop"===t){const t=a(7,8.5,v),o=r((v-8.5)/3.5),l=v<8.5?1-t:a(0,1,(1.45*o-(1-c)+.06*(i(Math.floor(160*e),Math.floor(100*n))-.5))/.3);s[2]=.3*-(1-l),s[3]=1-.9*(1-l)}return s}function c(t,e,n,o,r){if(!(r<1))for(let a=0;a<2;a++){for(let a=0;a<o;a++){let o=0;const i=a*n;for(let e=-r;e<=r;e++)o+=t[i+Math.max(0,Math.min(n-1,e))];for(let a=0;a<n;a++)e[i+a]=o/(2*r+1),o+=t[i+Math.min(n-1,a+r+1)]-t[i+Math.max(0,a-r)]}for(let a=0;a<n;a++){let i=0;for(let t=-r;t<=r;t++)i+=e[Math.max(0,Math.min(o-1,t))*n+a];for(let s=0;s<o;s++)t[s*n+a]=i/(2*r+1),i+=e[Math.min(o-1,s+r+1)*n+a]-e[Math.max(0,s-r)*n+a]}}}var l=(t,e,n)=>{const o=Math.max(0,Math.min(1,(n-t)/(e-t)));return o*o*(3-2*o)};function h(t,e,n=256){let o=0;for(let e=0;e<t.length;e++)t[e]>o&&(o=t[e]);if(o<=0)return 0;const r=new Uint32Array(n);for(let e=0;e<t.length;e++)r[Math.min(n-1,Math.floor(t[e]/o*n))]++;let a=0;const i=t.length*e;for(let t=0;t<n;t++)if(a+=r[t],a>=i)return(t+1)/n*o;return o}function d(t,e,n,o){const r=e*n,a=o?.length===8*r?o:new Float32Array(8*r);if(!r)return a;const i=Math.min(e,n),s=new Float32Array(r),d=new Float32Array(r),f=new Float32Array(r),m=new Float32Array(r),u=new Float32Array(r),g=new Float32Array(r),p=new Float32Array(r);for(let e=0;e<r;e++){const n=t[4*e+3]/255;s[e]=(.299*t[4*e]+.587*t[4*e+1]+.114*t[4*e+2])/255*n}d.set(s),c(d,p,e,n,Math.max(1,Math.round(.012*i))),f.set(s),c(f,p,e,n,Math.max(1,Math.round(.03*i)));for(let t=0;t<r;t++){m[t]=Math.abs(s[t]-d[t]);const e=Math.max(0,s[t]-.55)/.45;u[t]=e*e}c(m,p,e,n,Math.max(1,Math.round(.02*i)));const M=1/Math.max(.02,h(m,.95));c(u,p,e,n,Math.max(1,Math.round(.05*i)));const v=1/Math.max(.03,h(u,.98)),w=function(t,e,n){const o=e*n,r={width:e,height:n,subject:new Float32Array(o),depth:new Float32Array(o),key:"none"},{subject:a,depth:i}=r;let s=0;for(let e=0;e<o;e++)t[4*e+3]<250&&s++;const l=e=>(.2126*t[4*e]+.7152*t[4*e+1]+.0722*t[4*e+2])/255;let h="none",d=0;if(s>.01*o)h="alpha";else{let t=0,o=0,r=0;const a=Math.max(1,Math.round(.03*Math.min(e,n)));for(let i=0;i<n;i++)for(let s=0;s<e;s++){if(s>=a&&i>=a&&s<e-a&&i<n-a)continue;const c=l(i*e+s);t+=c,o+=c*c,r++}d=t/Math.max(1,r),Math.sqrt(Math.max(0,o/Math.max(1,r)-d*d))<.07&&(h="ground")}for(let e=0;e<o;e++){const n=t[4*e+3]/255,o=l(e);let r=1;if("alpha"===h)r=n;else if("ground"===h){const t=Math.max(0,Math.min(1,(Math.abs(o-d)-.035)/.12));r=t*t*(3-2*t)}a[e]=1*r,i[e]=o*n}r.key=h;const f=new Float32Array(o);return c(a,f,e,n,Math.max(1,Math.round(.02*Math.min(e,n)))),c(i,f,e,n,Math.max(1,Math.round(.035*Math.min(e,n)))),r}(t,e,n);let x=0,y=0,b=0;for(let t=0;t<n;t++)for(let o=0;o<e;o++){const r=t*e+o,a=(o+.5)/e,i=(t+.5)/n,c=.55*Math.min(1,m[r]*M)+.3*(1-Math.min(1,1.6*Math.hypot(1.3*(a-.5),i-.55)))+.15*l(.2,1,i);g[r]="none"===w.key?c:.75*w.subject[r]+.25*c;const h=g[r]*g[r]*(.25+s[r]);x+=a*h,y+=i*h,b+=h}c(g,p,e,n,Math.max(1,Math.round(.06*i)));const S=h(g,.05),E=h(g,.95),T=Math.max(.05,E-S);x=b>0?Math.max(.3,Math.min(.7,x/b)):.5,y=b>0?Math.max(.3,Math.min(.7,y/b)):.5;const A=1/Math.max(.004,h((()=>{const t=new Float32Array(r);for(let o=0;o<n;o++)for(let r=0;r<e;r++){t[o*e+r]=Math.hypot(f[o*e+Math.min(e-1,r+1)]-f[o*e+Math.max(0,r-1)],f[Math.min(n-1,o+1)*e+r]-f[Math.max(0,o-1)*e+r])}return t})(),.97));for(let t=0;t<n;t++)for(let o=0;o<e;o++){const r=t*e+o,i=8*r,s=(f[t*e+Math.min(e-1,o+1)]-f[t*e+Math.max(0,o-1)])*A,c=(f[Math.min(n-1,t+1)*e+o]-f[Math.max(0,t-1)*e+o])*A;a[i]=f[r],a[i+1]=Math.max(0,Math.min(1,(g[r]-S)/T)),a[i+2]=Math.min(1,u[r]*v),a[i+3]=Math.min(1,m[r]*M),a[i+4]=Math.max(-1,Math.min(1,-s)),a[i+5]=Math.max(-1,Math.min(1,-c)),a[i+6]=x,a[i+7]=y}return a}var f=new WeakMap;function m(t,e){const n=document.createElement("canvas");n.width=t,n.height=e;const o=n.getContext("2d",{willReadFrequently:!0});return{canvas:n,ctx:o}}function u(t,e,n){let o=t+255*e;return o=259*(255*n+255)/(255*(259-255*n))*(o-128)+128,Math.max(0,Math.min(255,o))}function g(t,e,n,o,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(o*r+n)%i.length]}var p=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function M(t,e,n,o){if(o<=0)return t;const r=(p[n%4][e%4]/16-.5)*o*128;return Math.max(0,Math.min(255,t+r))}var v=new Array(256),w=new Array(256);for(let t=0;t<256;t++)v[t]=`rgb(${t},${t},${t})`,w[t]=`rgb(0,${t},0)`;function x(t,e,n,o,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return w[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${n},${o},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return v[e]}}}var y=[0,0,0];function b(t,e,n,o,r,a=!1){switch(e){case"fullcolor":y[0]=t.r,y[1]=t.g,y[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;y[0]=0,y[1]=e,y[2]=0;break}case"accent":y[0]=n,y[1]=o,y[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;y[0]=e,y[1]=e,y[2]=e;break}}return y}function S(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function E(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=S(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function T(t){if(t){const e=E(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=E(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function A(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");n.fillStyle=t,n.fillRect(0,0,1,1);const o=n.getImageData(0,0,1,1).data;return{r:o[0],g:o[1],b:o[2]}}function C(t){return t*t*(3-2*t)}var F={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function k(t,e,n,o,r,a,i,s,c="spotlight",l=.5,h="circle",d=[],f=1){const m=(t-n)*Math.max(1,f),u=(e-o)*Math.max(1,1/f),g=.08+.35*l+.04*a;let p,M;if("box"===h){const t=Math.abs(m),e=Math.abs(u);p=Math.max(t,e),M=g}else p=Math.sqrt(m*m+u*u),M=g;if(p>=M&&("trail"!==c||0===d.length))return F.scale=1,F.offsetX=0,F.offsetY=0,F.glow=0,F.colorBlend=0,F.proximity=0,F;const v=C(Math.max(0,1-p/M))*r;let w=1,x=0,y=0,b=0,S=0;switch(c){case"spotlight":{w=1+v*a*1.8;const t=Math.atan2(u,m),e=v*v*a*.6;x=Math.cos(t)*e*i,y=Math.sin(t)*e*s,b=v*a*.4,S=v*v*a*.25;break}case"magnify":w=1+v*a*.85,b=v*a*.15;break;case"repel":{w=1;const t=Math.atan2(u,m),e=v*v*a*1.8;x=Math.cos(t)*e*i,y=Math.sin(t)*e*s;break}case"glow":b=v*a*.8,S=v*a*.4;break;case"colorShift":w=1,b=v*a*.12,S=v*a;break;case"attract":{const t=Math.atan2(u,m),e=v*v*a*1;x=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,y=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,b=v*a*.3;break}case"shatter":{const t=Math.atan2(u,m),e=.5*Math.sin(43.7*m+29.3*u),n=v*a*1.4*(.7+.3*e);x=Math.cos(t+e)*n*i,y=Math.sin(t+e)*n*s,w=Math.max(.1,1-v*a*.6),b=v*a*.25;break}case"trail":{let n=v,o=-u*v,r=m*v;for(const a of d){const i=(t-a.x)*Math.max(1,f),s=(e-a.y)*Math.max(1,1/f),c=Math.hypot(i,s)/g;if(c>=1)continue;const l=C(1-c)*a.intensity;n=Math.max(n,l),o+=(.35*a.vx-2*s)*l*.35,r+=(.35*a.vy+2*i)*l*.35}x=Math.tanh(2*o)*a*i*3,y=Math.tanh(2*r)*a*s*3,S=n*a*.65,b=n*a*.35,w=1+n*a*.08,F.proximity=n;break}case"glitchText":w=1,b=v*a*.5,S=v*a*.6}return F.scale=w,F.offsetX=x,F.offsetY=y,F.glow=b,F.colorBlend=S,"trail"!==c&&(F.proximity=v),F}function L(t,e,{continuous:n=!1,interactive:o=!1}={}){const r=t.parentElement??t;let a=null,i=0,s=!1,c=!0,l=!0,h=-1/0;const d=window.matchMedia("(prefers-reduced-motion: reduce)"),f=()=>{l=!0,s||!c||document.hidden||i||(i=requestAnimationFrame(m))},m=t=>{if(i=0,s||!c||document.hidden)return;const o=!d.matches&&(n||t-h<1500);(l||o)&&(e(t,d.matches?null:a),l=!1),o&&(i=requestAnimationFrame(m))},u=e=>{if("touch"===e.pointerType)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const o=(e.clientX-n.left)/n.width,r=(e.clientY-n.top)/n.height;a=o>=0&&o<=1&&r>=0&&r<=1?{x:o,y:r}:null,h=performance.now(),f()},g=()=>{a=null,h=performance.now(),f()},p=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):f()},M="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{c=t.isIntersecting,c?f():i&&(cancelAnimationFrame(i),i=0)});return M?.observe(t),o&&(r.addEventListener("pointermove",u),r.addEventListener("pointerleave",g)),document.addEventListener("visibilitychange",p),d.addEventListener("change",f),f(),{wake:f,stop:()=>{s=!0,cancelAnimationFrame(i),M?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",p),d.removeEventListener("change",f)}}}var R=null,I=null;function H(t,e){if(!R||!I){const n=m(t,e);R=n.canvas,I=n.ctx}return R.width!==t&&(R.width=t),R.height!==e&&(R.height=e),I}var W=new Map,$=new Map,j=new WeakMap;function P(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function O(t){let e=W.get(t);return e||(e=P(t),W.set(t,e)),e}function z(t){return P(t)}function D(t,e,n){const o=n?1-t/255:t/255,r=Math.floor(o*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function q(t,e,n,o){const r=`${t}\0${e?1:0}\0${n}\0${o}`;let a=$.get(r);if(!a){const i=O(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=D(u(t,n,o),i,e);$.set(r,a)}return a}function V(t,e){return"auto"!==t?t:!T(e)}function U(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const n=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return n?[n[1],n[2],n[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function B(t){const e=t||"auto";if("auto"!==e)return U(e)??"ffffff";if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const n=U(t.getPropertyValue(e).trim());if(n)return n}const e=U(getComputedStyle(document.body).accentColor??"");if(e)return e}return T("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function N(t,e,n){return Math.max(e,Math.min(n,t))}function K(t,e,n){if(!t)return{x:0,y:0,width:e,height:n};const o=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===o?t*e:t,i=t=>void 0===t?void 0:"percent"===o?t*n:t,s=N(a(t.left)??0,0,e-1),c=N(a(t.right)??0,0,e-s-1),l=N(i(t.top)??0,0,n-1),h=N(i(t.bottom)??0,0,n-l-1),d=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,f=Math.max(1,e-s-c),m=Math.max(1,n-l-h),u=d?f:a(t.width),g=d?m:i(t.height);let p=u??e,M=g??n;if(r&&!d){const t=p/e,o=M/n,r=Math.min(t,o),a=void 0===u?o:void 0===g?t:r;p=e*a,M=n*a}p=N(p,1,d?f:e),M=N(M,1,d?m:n);const v=t.anchor??"center",w=a(t.x),x=i(t.y),y=d?s:0,b=d?l:0,S=d?f:e,E=d?m:n,T=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-p:(S-p)/2,A=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?E-M:(E-M)/2;return{x:N(w??y+T,0,Math.max(0,e-p)),y:N(x??b+A,0,Math.max(0,n-M)),width:p,height:M}}function Y(t,e,n,o){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,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=n||r,h=o||a,d=Math.floor(l/s),f=Math.floor(h/c);if(d<=0||f<=0)return{frame:[],cols:0,rows:0};const m=K(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/d),Math.floor(m.width/d))),v=Math.max(1,Math.min(Math.floor(2048/f),Math.floor(m.height/f))),w=d*p,x=f*v,y=H(w,x),b=y.globalCompositeOperation;y.globalCompositeOperation="copy";try{y.drawImage(t,m.x,m.y,m.width,m.height,0,0,w,x)}finally{y.globalCompositeOperation=b}const S=y.getImageData(0,0,w,x).data,E=e.chromaKey,T=null!=E&&!1!==E,C=!0===E,F="blue-screen"===E;let k=null,L=0;!T||C||F||(k=A(E),L=(e.chromaKeyTolerance??60)**2);let R=0,I=255;if(e.normalize){let t=255,e=0;for(let n=0;n<S.length;n+=4){if(T){const t=S[n],e=S[n+1],o=S[n+2];let r=!1;if(C)r=e>1.4*t&&e>1.4*o&&e>80;else if(F)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==k){const n=t-k.r,a=e-k.g,i=o-k.b;r=n*n+a*a+i*i<=L}if(r)continue}const o=.299*S[n]+.587*S[n+1]+.114*S[n+2];o<t&&(t=o),o>e&&(e=o)}R=t,I=e>t?e-t:255}const W=[],$=V(e.invert),j=T&&e.charset.replace(/ /g,"")||e.charset,P=O(j),z=e.customText?null:q(j,$,e.brightness,e.contrast),U=p*v;for(let t=0;t<f;t++){const n=[];for(let o=0;o<d;o++){let r=0,a=0,i=0,s=0,c=0;for(let e=0;e<v;e++){const n=(t*v+e)*w;for(let t=0;t<p;t++){const e=4*(n+o*p+t),l=S[e],h=S[e+1],d=S[e+2],f=S[e+3];if(T){let t=!1;if(C)t=h>1.4*l&&h>1.4*d&&h>80;else if(F)t=d>1.4*l&&d>1.4*h&&d>80;else if(null!==k){const e=l-k.r,n=h-k.g,o=d-k.b;t=e*e+n*n+o*o<=L}if(t){c++;continue}}r+=l,a+=h,i+=d,s+=f}}if(T&&c>U/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const l=U-c,h=l>0?r/l:0,f=l>0?a/l:0,m=l>0?i/l:0,x=l>0?s/l:0,y=.299*h+.587*f+.114*m,b=e.normalize?(y-R)/I*255:y,E=u(b,e.brightness,e.contrast),A=e.ditherStrength>0?M(E,o,t,e.ditherStrength):E,H=e.customText?g(A,e.customText,o,t,d,$):e.ditherStrength>0?D(A,P,$):z[Math.max(0,Math.min(255,0|b))];n.push({char:H,r:h,g:f,b:m,a:x,lum:A})}W.push(n)}return{frame:W,cols:d,rows:f}}function _(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=n||r,h=o||a,d=Math.floor(l/s),f=Math.floor(h/c);if(d<=0||f<=0)return{rows:[],cols:0,rowCount:0};const m=d,g=f,p=H(m,g),v=K(e.sourceCrop,r,a),w=p.globalCompositeOperation;p.globalCompositeOperation="copy";try{p.drawImage(t,v.x,v.y,v.width,v.height,0,0,m,g)}finally{p.globalCompositeOperation=w}const x=p.getImageData(0,0,m,g).data,y=e.chromaKey,b=null!=y&&!1!==y,S=!0===y,E="blue-screen"===y;let T=null,C=0;!b||S||E||(T=A(y),C=(e.chromaKeyTolerance??60)**2);let F=0,k=255;if(e.normalize){let t=255,e=0;for(let n=0;n<x.length;n+=4){if(b){const t=x[n],e=x[n+1],o=x[n+2];let r=!1;if(S)r=e>1.4*t&&e>1.4*o&&e>80;else if(E)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==T){const n=t-T.r,a=e-T.g,i=o-T.b;r=n*n+a*a+i*i<=C}if(r)continue}const o=.299*x[n]+.587*x[n+1]+.114*x[n+2];o<t&&(t=o),o>e&&(e=o)}F=t,k=e>t?e-t:255}const L=V(e.invert),R=b&&e.charset.replace(/ /g,"")||e.charset,I=O(R),W=e.customText?null:q(R,L,e.brightness,e.contrast),$=e.customText?O(e.customText):null,j="fullcolor"===e.colorMode?new Uint8ClampedArray(d*f*4):void 0,P=[];for(let t=0;t<f;t++){let n="";for(let o=0;o<d;o++){const r=4*(t*m+o),a=r,i=x[r],s=x[r+1],c=x[r+2],l=x[r+3];if(b){let t=!1;if(S)t=s>1.4*i&&s>1.4*c&&s>80;else if(E)t=c>1.4*i&&c>1.4*s&&c>80;else if(null!==T){const e=i-T.r,n=s-T.g,o=c-T.b;t=e*e+n*n+o*o<=C}if(t){n+=" ",j&&(j[a]=0,j[a+1]=0,j[a+2]=0,j[a+3]=0);continue}}j&&(j[a]=i,j[a+1]=s,j[a+2]=c,j[a+3]=l);const h=.299*i+.587*s+.114*c,f=e.normalize?(h-F)/k*255:h,g=e.ditherStrength>0||$?u(f,e.brightness,e.contrast):f,p=e.ditherStrength>0?M(g,o,t,e.ditherStrength):g;if($){n+=(L?1-p/255:p/255)<.12?" ":$[(t*d+o)%$.length]}else e.ditherStrength<=0?n+=W[Math.max(0,Math.min(255,0|f))]:n+=D(p,I,L)}P.push(n)}return{rows:P,cols:d,rowCount:f,colors:j}}function G(t,e,n,o,r){if(0===e.rows.length)return;const a=t.canvas,i=Boolean(n.chromaKey)||e.rows.some(t=>t.includes(" "));i||(j.delete(t),t.clearRect(0,0,o,r),t.fillStyle=T(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,r));const s=B(n.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),d=o/e.cols,f=r/e.rowCount,m=.9*Math.min(d/.55,f),u=e.colors;if("fullcolor"===n.colorMode&&u){j.delete(t),t.clearRect(0,0,o,r),t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let n="";for(let o=0;o<e.rows.length;o++){const r=z(e.rows[o]);let a=0;for(;a<e.cols;){for(;a<e.cols&&" "===r[a];)a++;if(a>=e.cols)break;const i=a,s=4*(o*e.cols+a),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(a++;a<e.cols&&" "!==r[a];){const t=4*(o*e.cols+a);if((240&u[t])!==c||(240&u[t+1])!==l||(240&u[t+2])!==h)break;a++}const m=`rgb(${c},${l},${h})`;m!==n&&(t.fillStyle=m,n=m),t.fillText(r.slice(i,a).join(""),i*d+.5*d,o*f+.5*f)}}return void(t.globalAlpha=1)}t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const g="matrix"===n.colorMode?"rgb(0,255,0)":"grayscale"===n.colorMode?T(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;t.fillStyle=g,t.globalAlpha=1;const p=j.get(t),M=i&&p&&p.cols===e.cols&&p.rowCount===e.rowCount&&p.canvasWidth===o&&p.canvasHeight===r&&p.fillStyle===g;M||t.clearRect(0,0,o,r);for(let n=0;n<e.rows.length;n++){const r=e.rows[n];M&&p.rows[n]===r||(M&&t.clearRect(0,n*f,o,f+1),0!==r.trim().length&&t.fillText(r,.5*d,n*f+.5*f))}j.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:o,canvasHeight:r,fillStyle:g}),t.globalAlpha=1}async function X(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=Y(t,e,n,o);h.push(u.frame),d=u.cols,f=u.rows,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function J(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=_(t,e,n,o);h.push(u),d=u.cols,f=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function Q(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const p=g.getContext("2d"),M=document.createElement("canvas"),v=M.getContext("2d"),w=[];let x=0,y=0,b=0;for(const t of c)b+=t.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),T=Math.min(c.length,300);for(let t=0;t<T;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(M,i.left||0,i.top||0);const b=Y(m,e,n,o);w.push(b.frame),x=b.cols,y=b.rows,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((t+1)/T)}return{frames:w,cols:x,rows:y,fps:E}}var Z=new WeakMap,tt=new WeakMap,et=new WeakMap;function nt(t,e,n,o,r,a=0,i){if(!e.length||!e[0].length||o<=0||r<=0)return;let s=null;if(n.hoverStrength>0){let e=Z.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},Z.set(t,e)),s=function(t,e,n){const o=t.time<0?1/60:Math.max(0,Math.min(.1,(n-t.time)/1e3));t.time=n;const r=t.intensity<.003,a=t.x,i=t.y;if(e){r&&(t.x=e.x,t.y=e.y);const n=1-Math.exp(-o/.055);t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n}t.intensity+=((e?.intensity??(e?1:0))-t.intensity)*(1-Math.exp(-o/(e?.09:.18)));const s=Math.exp(-o/.22);for(const e of t.points)e.intensity*=s;for(;t.points.length&&t.points[0].intensity<.01;)t.points.shift();return e&&!r&&n-t.emittedAt>=24&&Math.hypot(t.x-a,t.y-i)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-a)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(t.y-i)/Math.max(o,.001)))}),t.points.length>12&&t.points.shift(),t.emittedAt=n),!e&&t.intensity<.003&&!t.points.length?(t.intensity=0,null):{x:t.x,y:t.y,intensity:t.intensity,trail:t.points}}(e,i??null,performance.now())}else Z.delete(t);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return et.delete(t),void ot(t,e,n,o,r,a,s);const c=tt.get(t);if(c?.frame!==e)return tt.set(t,{frame:e,since:performance.now()}),et.delete(t),void ot(t,e,n,o,r,a,s);if(performance.now()-c.since<100)return void ot(t,e,n,o,r,a,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void ot(t,e,n,o,r,a,s);if(!s||(s.intensity??0)<.003)return void ot(t,e,n,o,r,a,null);const h=T(t.canvas),d={...n,accentColor:"#"+B(n.accentColor)},f=JSON.stringify([d,o,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=et.get(t);if(!m||m.frame!==e||m.key!==f){const n=m?.canvas??document.createElement("canvas");n.width=Math.ceil(o*l.a),n.height=Math.ceil(r*l.d);const a=n.getContext("2d");a.setTransform(l.a,0,0,l.d,0,0),ot(a,e,d,o,r,0,null,void 0,h),m={frame:e,key:f,canvas:n},et.set(t,m)}if(t.clearRect(0,0,o,r),t.drawImage(m.canvas,0,0,o,r),!s||(s.intensity??0)<.003)return;const u=e.length,g=e[0].length,p=.08+.35*n.hoverRadius+.04*n.hoverStrength,M="trail"===n.hoverEffect?[s,...s.trail??[]]:[s];let v=1,w=1,x=0,y=0;for(const t of M)v=Math.min(v,t.x-p),x=Math.max(x,t.x+p),w=Math.min(w,t.y-p),y=Math.max(y,t.y+p);if("glitchText"===n.hoverEffect){const t=n.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));v=Math.min(v,s.x-e/g),x=Math.max(x,s.x+e/g)}const b=Math.ceil(5+4*n.hoverStrength),S={x:Math.max(0,Math.floor(v*g)-b),y:Math.max(0,Math.floor(w*u)-b),right:Math.min(g,Math.ceil(x*g)+b),bottom:Math.min(u,Math.ceil(y*u)+b)};t.save(),t.beginPath(),t.rect(S.x*o/g,S.y*r/u,(S.right-S.x)*o/g,(S.bottom-S.y)*r/u),t.clip(),ot(t,e,d,o,r,a,s,S,h),t.restore()}function ot(t,e,r,a,i,c=0,l,h,m){const u=e.length;if(0===u)return;const g=e[0].length;t.clearRect(0,0,a,i);let p=!1;const M=Math.max(1,u>>2),v=Math.max(1,g>>2);t:for(let t=0;t<u;t+=M){const n=e[t];for(let t=0;t<g;t+=v)if(n[t].a<200){p=!0;break t}}const w=t.canvas,y=m??T(w);p||(t.fillStyle=y?"#0a0a0a":"#faf9f7",t.fillRect(0,0,a,i));const S=a/g,E=i/u,A=l?.intensity??1,C=!!(l&&r.hoverStrength>0&&A>.005),F="#"+(U(r.hoverColor||"#ffffff")??"ffffff"),L=parseInt(F.slice(1,3),16),R=parseInt(F.slice(3,5),16),I=parseInt(F.slice(5,7),16),H=B(r.accentColor),W=parseInt(H.substring(0,2),16),$=parseInt(H.substring(2,4),16),j=parseInt(H.substring(4,6),16),P=r.hoverRadius;let z=0,q=g,N=0,K=u,Y=0,_=0;if(C&&l){Y=l.x,_=l.y;const t=.08+.35*P+.04*r.hoverStrength;z=Math.max(0,Math.floor((Y-t)*g)-1),q=Math.min(g,Math.ceil((Y+t)*g)+1),N=Math.max(0,Math.floor((_-t)*u)-1),K=Math.min(u,Math.ceil((_+t)*u)+1)}if(C&&"trail"===r.hoverEffect)for(const t of l?.trail??[]){const e=.08+.35*P+.04*r.hoverStrength;z=Math.min(z,Math.max(0,Math.floor((t.x-e)*g)-1)),q=Math.max(q,Math.min(g,Math.ceil((t.x+e)*g)+1)),N=Math.min(N,Math.max(0,Math.floor((t.y-e)*u)-1)),K=Math.max(K,Math.min(u,Math.ceil((t.y+e)*u)+1))}const G=r.animationStyle,X=r.animationSpeed,J=function(t){const e=t&&Object.prototype.hasOwnProperty.call(n,t)?n[t]:t;return o.find(t=>t.value===e||t.mode===e)?.mode??"none"}(G),Q="none"===J,Z=[0,0,0,1],tt=Q?void 0:function(t){const e=f.get(t);if(e)return e;const n=t.length,o=t[0]?.length??0,r=new Uint8ClampedArray(o*n*4);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const a=t[e][n],i=4*(e*o+n);r[i]=a.r,r[i+1]=a.g,r[i+2]=a.b,r[i+3]=a.a}const a=d(r,o,n);return f.set(t,a),a}(e),et=r.hoverStrength,nt=r.hoverEffect,ot=P,rt=r.hoverShape||"circle",at=V(r.invert,w),it=r.colorMode,st=2*Math.PI,ct=1/g,lt=1/u;let ht="",dt=-1;if("dots"===r.renderMode){const n=.5*Math.min(S,E)*r.dotSizeRatio;for(let o=h?.y??0;o<(h?.bottom??u);o++){const r=e[o];for(let e=h?.x??0;e<(h?.right??g);e++){const h=r[e];if(h.a<10)continue;const d=.00392156863*(.299*h.r+.587*h.g+.114*h.b),f=at?1-d:d;if(f<.02)continue;Q||s(J,e/g,o/u,c*X,Z,(.299*h.r+.587*h.g+.114*h.b)/255,tt,8*(o*g+e));const m=Math.max(0,Math.min(1,(1+Z[2])*Z[3]));let p=1,M=0,v=0,w=0,y=0;if(C&&e>=z&&e<=q&&o>=N&&o<=K){const t=k(e*ct,o*lt,Y,_,A,et,S,E,nt,ot,rt,l?.trail,a/i);p=t.scale,M=t.offsetX,v=t.offsetY,w=t.glow,y=t.colorBlend}const T=n*f*m*p;if(T<.3)continue;const F=e*S+.5*S+M+Z[0],H=o*E+.5*E+v+Z[1];let P;if(y>0){const t=b(h,it,W,$,j,at);P=`rgb(${Math.min(255,t[0]+(L-t[0])*y|0)},${Math.min(255,t[1]+(R-t[1])*y|0)},${Math.min(255,t[2]+(I-t[2])*y|0)})`}else P=x(h,it,W,$,j,at);const O=Math.min(1,.00392156863*h.a*m*(1+w));if(O!==dt&&(t.globalAlpha=O,dt=O),P!==ht&&(t.fillStyle=P,ht=P),T<=3){const e=2*T;t.fillRect(F-T,H-T,e,e)}else t.beginPath(),t.arc(F,H,T,0,st),t.fill()}}}else{const n=.55,o=.9*Math.min(S/n,E);{const e=/\p{Extended_Pictographic}/u.test(r.customText||r.charset);t.font=e?`${o}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${o}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const d=r.charsetFrames,f=!!d?.length,m=f?d[Math.floor(Math.max(0,c)*(r.charsetFps??2))%d.length]:r.charset,p=t.getTransform();if(!C&&Q&&!f&&"accent"===it&&!h&&r.hoverStrength<=0&&!/\p{Extended_Pictographic}/u.test(r.customText||r.charset)&&"letterSpacing"in t&&/^[\x20-\x7e]*$/.test(r.customText||r.charset)&&e.every(t=>t.every(t=>t.a<10||255===t.a&&1===t.char.length&&/^[\x20-\x7e]$/.test(t.char)))){const n=t.letterSpacing;t.letterSpacing="0px";const o=t.measureText("M").width;t.letterSpacing=S-o+"px",t.fillStyle=`rgb(${W},${$},${j})`,t.globalAlpha=1,t.textAlign="left";for(let n=0;n<u;n++){const r=e[n];let a="";for(let t=0;t<g;t++){const e=r[t];a+=e.a<10?" ":e.char}0!==a.trim().length&&t.fillText(a,.5*(S-o),n*E+.5*E)}return t.letterSpacing=n,t.textAlign="center",void(t.globalAlpha=1)}const M="glitchText"===nt&&C,v="!@#$%^&*<>{}[]|/\\~`0123456789",w=v.length;let y="",T=0,F=0,H=0,V=0,U=0,B=0;if(M){const t=r.hoverText??"ASCIIFY";if(F=Math.round(Y*g),H=Math.round(_*u),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");y=e[((7*Math.floor(F/Math.max(1,Math.ceil(g/5)))+13*Math.floor(H/Math.max(1,Math.ceil(u/3))))%e.length+e.length)%e.length]}else y=t||"ASCIIFY";T=y.length,V=Math.max(3,Math.min(12,Math.round(u*P*.6)));const e=Math.floor(V/2);U=Math.max(0,H-e),U+V>u&&(U=Math.max(0,u-V)),B=F-Math.floor(T/2)}for(let n=h?.y??0;n<(h?.bottom??u);n++){const o=e[n];for(let r=h?.x??0;r<(h?.right??g);r++){const h=o[r];if(h.a<10)continue;let d=f&&null!=h.lum?D(h.lum,O(m),at):h.char;if(" "===d)continue;Q||s(J,r/g,n/u,c*X,Z,(.299*h.r+.587*h.g+.114*h.b)/255,tt,8*(n*g+r));const P=Math.max(0,Math.min(1,(1+Z[2])*Z[3]));if(P<.05)continue;let G=1,st=0,ft=0,mt=0,ut=0;if(C&&!M&&r>=z&&r<=q&&n>=N&&n<=K){const t=k(r*ct,n*lt,Y,_,A,et,S,E,nt,ot,rt,l?.trail,a/i);if(G=t.scale,st=t.offsetX,ft=t.offsetY,mt=t.glow,ut=t.colorBlend,"trail"===nt&&t.proximity>0){const o=Math.max(0,Math.min(g-1,Math.round(r-t.offsetX/S))),a=e[Math.max(0,Math.min(u-1,Math.round(n-t.offsetY/E)))][o],i=a.lum??.299*a.r+.587*a.g+.114*a.b;d=D(Math.min(255,i+t.proximity*et*65),O(m),at)}}if(M&&n>=U&&n<U+V){const t=r-B;if(t>=0&&t<T){const e=y[t],o=Math.abs(n-H)/Math.max(1,.5*V),a=Math.abs(r-F)/Math.max(1,T),i=Math.max(o,a),s=Math.max(0,Math.min(1,1-.9*i)),l=43758.5453*Math.sin(127.1*r+311.7*n+43758.5453*Math.floor(12*c));d=Math.abs(l-Math.floor(l))<s?e:v[Math.abs(Math.floor(97*l))%w],mt=.3+.7*s,ut=.3+.65*s}}const gt=r*S+.5*S+st+Z[0],pt=n*E+.5*E+ft+Z[1];let Mt;if(ut>0){const t=b(h,it,W,$,j,at);Mt=`rgb(${Math.min(255,t[0]+(L-t[0])*ut|0)},${Math.min(255,t[1]+(R-t[1])*ut|0)},${Math.min(255,t[2]+(I-t[2])*ut|0)})`}else Mt=x(h,it,W,$,j,at);const vt=Math.min(1,.00392156863*h.a*P*(1+mt));vt!==dt&&(t.globalAlpha=vt,dt=vt),Mt!==ht&&(t.fillStyle=Mt,ht=Mt),1!==G?(t.translate(gt,pt),t.scale(G,G),t.fillText(d,0,0),t.setTransform(p)):t.fillText(d,gt,pt)}}}t.globalAlpha=1}function rt(t="classic"){if("classic"!==t)throw new RangeError(`Art preset "${String(t)}" was removed in 4.1. Use a StudioStyle with asciify-engine/studio, or supply options.charset directly.`);return{artStyle:"classic"}}function at(t){return Math.max(0,Math.min(1,t))}function it(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function st(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function ct(t,e={}){const n=at(t),o=at(n*(void 0===e.speed?1:Math.max(.001,e.speed)));return at(e.ease?e.ease(o):o)}function lt(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const o=n.from??0,r=n.to??t.duration,a=Math.max(o,Math.min(r,t.duration)),i=ct(e,n),s=o+(a-o)*i;t.currentTime=Math.min(Math.max(o,s),Math.max(o,a-.04)),n.onUpdate?.(i,t)}function ht(t,e){return Math.abs(t.currentTime-e)<1/240?dt(t):new Promise(n=>{const o=()=>{t.removeEventListener("seeked",o),n()};t.addEventListener("seeked",o,{once:!0});const r=t.fastSeek;r?r.call(t,e):t.currentTime=e})}function dt(t){const e=t.requestVideoFrameCallback;return new Promise(e?n=>{let o=!1;const r=()=>{o||(o=!0,n())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function ft(t,e={}){const n=it(e.trigger)??t;t.pause();const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:n,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:n=>lt(t,n.progress,e)});return()=>a.kill?.()}return function(t,e,n){let o=0;const r=()=>{o=0;const r=e.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?at((a-r.top)/i):0;lt(t,s,n)},a=()=>{o||(o=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),o&&cancelAnimationFrame(o)}}(t,n,e)}function mt(t,e,n){const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>n(t.progress)});return()=>a.kill?.()}return function(t,e){let n=0;const o=()=>{n=0;const o=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=o.height+r,i=a>0?at((r-o.top)/a):0;e(i)},r=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),n&&cancelAnimationFrame(n)}}(t,n)}function ut(t,e,n){if(!t||!e||!n.sourceCrop)return{w:t,h:e};const o=K(n.sourceCrop,t,e);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function gt(t,e,n,o){const r=o.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return e>1.4*t&&e>1.4*n&&e>80;if("blue-screen"===r)return n>1.4*t&&n>1.4*e&&n>80;const a=A(r),i=(o.chromaKeyTolerance??60)**2,s=t-a.r,c=e-a.g,l=n-a.b;return s*s+c*c+l*l<=i}function pt(t,e,n){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const o=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!o||!r)return e;const a=K(e.sourceCrop,o,r),i=Math.min(360,Math.max(1,Math.round(a.width))),s=Math.max(1,Math.round(i*(a.height/a.width))),{ctx:c}=m(i,s);c.drawImage(t,a.x,a.y,a.width,a.height,0,0,i,s);const l=c.getImageData(0,0,i,s).data,h=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let d=i,f=s,u=-1,g=-1;for(let t=0;t<s;t++)for(let n=0;n<i;n++){const o=4*(t*i+n),r=l[o+3],a=l[o],s=l[o+1],c=l[o+2];r<=8||.2126*a+.7152*s+.0722*c<=h||gt(a,s,c,e)||(n<d&&(d=n),t<f&&(f=t),n>u&&(u=n),t>g&&(g=t))}if(u<d||g<f)return e;const p=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),M=Math.round(i*p),v=Math.round(s*p);d=Math.max(0,d-M),f=Math.max(0,f-v),u=Math.min(i-1,u+M),g=Math.min(s-1,g+v);const w=function(t,e,n,o,r){const a=r&&Number.isFinite(r)&&r>0?r:null;if(!a)return t;const i=e.x,s=e.y,c=e.x+e.width,l=e.y+e.height,h=Math.max(i,t.left),d=Math.max(s,t.top),f=Math.min(c,n-t.right),m=Math.min(l,o-t.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),p=h+u/2,M=d+g/2;let v=u,w=g;v/w<a?v=w*a:w=v/a;v>e.width&&(v=e.width,w=Math.max(g,Math.min(e.height,v/a)));w>e.height&&(w=e.height,v=Math.max(u,Math.min(e.width,w*a)));let x=p-v/2,y=M-w/2;return x=Math.max(i,Math.min(c-v,x)),y=Math.max(s,Math.min(l-w,y)),{left:x,top:y,right:n-(x+v),bottom:o-(y+w)}}({left:a.x+d/i*a.width,top:a.y+f/s*a.height,right:o-(a.x+(u+1)/i*a.width),bottom:r-(a.y+(g+1)/s*a.height)},{x:a.x,y:a.y,width:a.width,height:a.height},o,r,n);return{...e,sourceCrop:{unit:"pixel",...w,preserveAspect:!1}}}function Mt(t){const e=t.sourceCrop;return e&&"pixel"===e.unit?void 0===e.left||void 0===e.top||void 0===e.right||void 0===e.bottom?null:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}:null}async function vt(t,e,n,o,r){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const a=t.currentTime,i=function(t,e,n,o){const r=!0===o?{}:o||{},a=Math.max(0,r.from??e),i=r.to??n??(Number.isFinite(t.duration)?t.duration:a),s=Math.max(a,i-.04),c=Math.max(0,s-a),l=c>.1?[a,a+.25*c,a+.5*c,a+.75*c,s]:[a];return Array.from(new Set(l.map(t=>Math.max(0,Number(t.toFixed(3))))))}(t,n,o,r);let s=null;for(const n of i){await ht(t,n),await dt(t);const o=Mt(pt(t,e));o&&(s=s?{left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.min(s.right,o.right),bottom:Math.min(s.bottom,o.bottom)}:o)}return await ht(t,a),await dt(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function wt(t,e,n=2048){return xt({sourceWidth:t,sourceHeight:e,maxRenderDimension:n})}function xt({sourceWidth:t,sourceHeight:e,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:r=2048}){const a=Math.max(1,t),i=Math.max(1,e),s=a/i,c=Math.max(1,r),l=Math.min(1,c/Math.max(a,i)),h=Math.max(a,i)*l,d=Math.max(0,n,o),f=Math.min(c,Math.max(h,d));return s>=1?{renderW:Math.round(f),renderH:Math.round(f/s)}:{renderW:Math.round(f*s),renderH:Math.round(f)}}function yt(t,e,n,o){if(void 0===t)return;if("number"==typeof t)return t;const r=t.trim();if(r.endsWith("%")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?e*t:void 0}if(r.endsWith("px")){const t=Number.parseFloat(r);return Number.isFinite(t)?t:void 0}if(r.endsWith("vw")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?n*t:void 0}if(r.endsWith("vh")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?o*t:void 0}}function bt(t,e,n,o,r,a=2048,i={}){const{width:s,height:c}=e.getBoundingClientRect();if(!s||!c)return{renderW:0,renderH:0,dpr:1};const l="undefined"!=typeof window?window.innerWidth:s,h="undefined"!=typeof window?window.innerHeight:c,d=yt(i.width,s,l,h)??s,f=yt(i.height,c,l,h)??c,m=function(t,e,n,o,r){const a=t=>{const n=yt(t,e,o,r);return n&&n>0?n:0},i=t=>{const e=yt(t,n,o,r);return e&&e>0?e:0};return void 0===t?{x:0,y:0}:"number"==typeof t||"string"==typeof t?{x:a(t),y:i(t)}:{x:a(t.x),y:i(t.y)}}(i.bleed,s,c,l,h),u=d+2*m.x,g=f+2*m.y,{cssW:p,cssH:M}=function(t,e,n,o="contain"){if("fill"===o)return{cssW:t,cssH:e};let r=t,a=r/n;const i="cover"===o,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*n),"scale-down"===o&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,n,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let w,x;o&&r?({renderW:w,renderH:x}=xt({sourceWidth:o,sourceHeight:r,cssWidth:p,cssHeight:M,maxRenderDimension:a})):(w=p,x=M);const y=8e6,b=w*v*x*v>y?Math.sqrt(y/(w*x)):v;return t.width=Math.round(w*b),t.height=Math.round(x*b),t.style.width=`${p}px`,t.style.height=`${M}px`,{renderW:w,renderH:x,dpr:b}}async function St(t,n,{fontSize:o,artStyle:r="classic",options:a={},fitTo:i,objectFit:s,objectPosition:c,scale:l,width:h,height:d,bleed:f,preExtract:m=!1,fps:u,maxRenderDimension:g=2048,trim:p,scroll:M,maxCachedFrames:v=90,onReady:w,onFrame:x}={}){const y=p?.start??0,b=p?.end,S=o??a.fontSize??10;let E={...e,...rt(r),artStyle:r,...a,fontSize:S};const T=n.getContext("2d");if(!T)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof i?document.querySelector(i):i instanceof HTMLElement?i:null,C={objectFit:s,objectPosition:c,scale:l,width:h,height:d,bleed:f},F=function(t,e){var n;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height||void 0!==t.bleed}(e))return()=>{};const o={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0===e.scale&&void 0===e.bleed||(t.style.maxWidth="none",t.style.maxHeight="none"),void 0!==e.scale){const o=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(o)),(n=t.style).transformOrigin||(n.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=o.width,t.style.height=o.height,t.style.objectFit=o.objectFit,t.style.objectPosition=o.objectPosition,t.style.maxWidth=o.maxWidth,t.style.maxHeight=o.maxHeight,t.style.transformOrigin=o.transformOrigin,o.scale?t.style.setProperty("scale",o.scale):t.style.removeProperty("scale")}}(n,C),k=t=>()=>{t(),F()};if(m){let e;"string"==typeof t?(e=document.createElement("video"),e.crossOrigin="anonymous",e.src=t,e.readyState<2&&await new Promise((n,o)=>{e.onloadeddata=()=>n(),e.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))})):e=t,E=await vt(e,E,y,b,M);const o=ut(e.videoWidth,e.videoHeight,E);A&&bt(n,A,o.w/o.h,o.w,o.h,g,C);const{renderW:r,renderH:a}=wt(o.w,o.h,g),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;n.width===Math.round(r*c)&&n.height===Math.round(a*c)||(n.width=Math.round(r*c),n.height=Math.round(a*c));const l=void 0!==b?b-y:10,h=u??(M?18:void 0);if(st(E)){const{frames:t,fps:o}=await J(e,E,r,a,h,l,void 0,y),i=e=>{const n=t[e];n&&(T.save(),T.setTransform(c,0,0,c,0,0),G(T,n,E,r,a),T.restore(),x?.())};if(M){let o=!1,r=-1;const a=!0===M?{}:M,s=mt(it(a.trigger)??A??n,a,n=>{const s=ct(n,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),o||(o=!0,w?.(e)),a.onUpdate?.(s,e))});return i(0),o=!0,w?.(e),k(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/o,p=n=>{d||(n-m>=g&&(i(f),f=(f+1)%t.length,m=n,u&&(u=!1,w?.(e))),s=requestAnimationFrame(p))};return s=requestAnimationFrame(p),k(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await X(e,E,r,a,h,l,void 0,y);if(!d.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const p=performance.now(),v=L(n,(t,e)=>{M||(m=Math.floor((t-p)*f/1e3)%d.length),T.save(),T.setTransform(c,0,0,c,0,0),nt(T,d[m],E,r,a,(t-p)/1e3,e),T.restore(),x?.()},{continuous:!M||"none"!==E.animationStyle||!!E.charsetFrames?.length,interactive:E.hoverStrength>0});let S;if(M){const t=!0===M?{}:M;S=mt(it(t.trigger)??A??n,t,n=>{m=Math.max(0,Math.min(d.length-1,Math.round(ct(n,t)*(d.length-1)))),v.wake(),t.onUpdate?.(n,e)})}return w?.(e),k(()=>{v.stop(),S?.()})}let R,I=!1;"string"==typeof t?(R=document.createElement("video"),R.crossOrigin="anonymous",R.src=t,R.muted=!0,R.loop=!0,R.playsInline=!0,R.setAttribute("playsinline",""),Object.assign(R.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(R),I=!0,await new Promise((e,n)=>{R.onloadedmetadata=()=>e(),R.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))}),await R.play().catch(()=>{})):(R=t,R.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{R.removeEventListener("loadedmetadata",o),R.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};R.addEventListener("loadedmetadata",o),R.addEventListener("error",r),R.load()}),R.paused&&await R.play().catch(()=>{})),y>0&&(R.currentTime=y,await new Promise(t=>{const e=()=>{R.removeEventListener("seeked",e),t()};R.addEventListener("seeked",e)}),await dt(R));let H=null;(y>0||void 0!==b)&&(H=()=>{(void 0!==b&&R.currentTime>=b||y>0&&R.currentTime<y)&&(R.currentTime=y)},R.addEventListener("timeupdate",H)),E=await vt(R,E,y,b,M);let W=null;const $=ut(R.videoWidth,R.videoHeight,E);let{renderW:j,renderH:P}=wt($.w,$.h,g);const O=t=>"frame"===E.chromaKeyTrimMode?pt(t,E,j/P):E;if(A){const t=$.w/$.h,e=$.w,o=$.h,r=bt(n,A,t,e,o,g,C);j=r.renderW,P=r.renderH;const a=n.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),W=new ResizeObserver(()=>{const r=bt(n,A,t,e,o,g,C);j=r.renderW,P=r.renderH;const a=n.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),W.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,e=8e6,o=j*t*P*t>e?Math.sqrt(e/(j*P)):t;n.width===Math.round(j*o)&&n.height===Math.round(P*o)||(n.width=Math.round(j*o),n.height=Math.round(P*o)),T.setTransform(o,0,0,o,0,0)}let z=!0,D=null;const q=M&&!m,V=u&&u>0?1e3/u:0;let U=0;const B=!q&&st(E);if(q&&"ascii"===E.renderMode&&"none"===E.animationStyle&&E.hoverStrength<=0&&!E.charsetFrames?.length){const t=!0===M?{}:M,e=it(t.trigger)??A??n,o=t.from??y,r=t.to??b??R.duration,a=Math.max(o,Math.min(r,R.duration)),i=Math.max(.001,a-o),s=Math.min(60,Math.max(12,u??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(v))),f=()=>{for(;h.length>d;){const t=h.findIndex(t=>t!==g&&Math.abs(t-g)>2),e=t>=0?t:0,n=h.splice(e,1)[0];void 0!==n&&(l[n]=void 0)}},m=t=>{const e=h.indexOf(t);e>=0&&h.splice(e,1),h.push(t),f()};let g=0,p=0,S=-1,C=0,F=!1,L=!1,$=!1;const z=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=R.crossOrigin||"anonymous",q.src=R.currentSrc||R.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{q.removeEventListener("loadedmetadata",o),q.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",o),q.addEventListener("error",r),q.load()}),q.pause(),R.paused&&await R.play().catch(()=>{});const B=t=>o+i*t/Math.max(1,c-1),N=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),K=O(R),Y=_(R,K,j,P);Y.rows.length>0&&(l[0]=Y,m(0),G(T,Y,K,j,P),$=!0,w?.(R),x?.());const X=t=>{if(l[t])return t;for(let e=1;e<c;e++){const n=t-e,o=t+e;if(n>=0&&l[n])return n;if(o<c&&l[o])return o}return-1},J=()=>{if(!l[g])return g;for(const t of z)if(!l[t])return t;for(let t=1;t<c;t++){const e=g-t,n=g+t;if(e>=0&&!l[e])return e;if(n<c&&!l[n])return n}return-1},Q=t=>{t<0||t>=c||l[t]||(z.add(t),Z())},Z=async()=>{if(F||L)return;const t=J();if(!(t<0)){z.delete(t),L=!0;try{if(await ht(q,B(t)),!F){const e=O(q),n=_(q,e,j,P);n.rows.length>0&&(l[t]=n,m(t))}}finally{L=!1,F||requestAnimationFrame(()=>{Z()})}}},tt=()=>{if(F)return;const t=X(g);if(t>=0&&t!==S){const e=l[t];e&&(G(T,e,E,j,P),S=t,$||($=!0,w?.(R)),x?.())}else if(t<0||S<0){const t=performance.now();if(V<=0||t-U>=V){const e=O(R),n=_(R,e,j,P);n.rows.length>0&&(G(T,n,e,j,P),U=t,$||($=!0,w?.(R)),x?.())}}Q(g),C=requestAnimationFrame(tt)};return D=mt(e,t,e=>{const n=function(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const o=n.from??0,r=n.to??t.duration,a=Math.max(o,Math.min(r,t.duration)),i=ct(e,n),s=o+(a-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,a-.04))}}(R,e,{...t,from:o,to:a});p=n?.progress??at(e),g=N(p),Q(g),Q(g-1),Q(g+1),Q(g-2),Q(g+2),Q(g-3),Q(g+3),t.onUpdate?.(p,R)}),Q(0),Q(1),C=requestAnimationFrame(tt),k(()=>{F=!0,cancelAnimationFrame(C),D?.(),W?.disconnect(),z.clear(),h.length=0,l.fill(void 0),q.pause(),q.src="",q.removeAttribute("src"),q.load(),q.isConnected&&q.remove(),H&&R.removeEventListener("timeupdate",H),I&&(R.pause(),R.src="",R.removeAttribute("src"),R.load(),R.isConnected&&R.remove())})}if(q){const t=!0===M?{}:M;D=ft(R,{...t,trigger:t.trigger??A??n,from:t.from??y,to:t.to??b})}let N=-1,K=0,Q=-1,Z=0;const tt="function"==typeof R.requestVideoFrameCallback,et=()=>{Z=R.requestVideoFrameCallback(()=>{K++,et()})};tt&&et();let ot=0,lt=0,gt=null;const Mt=L(n,(t,e)=>{if(R.readyState<2||0===n.width||0===n.height)return;if(V>0&&t-U<V&&!e)return;if(y>0&&R.currentTime<y)return;if(void 0!==b&&R.currentTime>=b)return;const o=(tt?K!==Q:R.currentTime!==N)||ot!==j||lt!==P;if(o||!(E.hoverStrength<=0)||"none"!==E.animationStyle||E.charsetFrames?.length){if(B){const t=O(R),e=_(R,t,j,P);G(T,e,t,j,P)}else!o&>||(gt=Y(R,O(R),j,P).frame),nt(T,gt,E,j,P,t/1e3,e);N=R.currentTime,Q=K,ot=j,lt=P,U=t,z&&(z=!1,w?.(R)),x?.()}},{continuous:!0,interactive:E.hoverStrength>0});return k(()=>{Mt.stop(),Z&&R.cancelVideoFrameCallback(Z),D?.(),W?.disconnect(),H&&R.removeEventListener("timeupdate",H),I&&(R.pause(),R.src="",R.removeAttribute("src"),R.load(),R.isConnected&&R.remove())})}function Et(t,e,n,o="#505050",r=100){if(!t||e<=0||n<=0)return[];const a=function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return n?{r:+n[1],g:+n[2],b:+n[3]}:null}(o)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:n},(t,n)=>Array.from({length:e},(t,o)=>({char:i[(n*e+o)%s],r:a.r,g:a.g,b:a.b,a:r})))}var Tt=new WeakMap;function At(t,{format:e="png",quality:n=.92,scale:o=1}={}){return new Promise((r,a)=>{let i=t;if(1!==o){const e=document.createElement("canvas");e.width=Math.round(t.width*o),e.height=Math.round(t.height*o);const n=e.getContext("2d");if(!n)return void a(new Error("captureSnapshot: could not get 2d context"));n.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}`,n)})}var Ct={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]},Ft=[127,65,65,65,65,65,127];function kt(t){return Ct[t]??Ct[t.toUpperCase()]??Ft}function Lt(t,e={}){if(!t)return"";const{char:n="█",scale:o=1}=e,r=[...n][0]??"█",a=Math.max(1,Math.floor(o)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const n=kt(t[e]);for(let t=0;t<7;t++){const e=n[t];let o="";for(let t=6;t>=0;t--)o+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=o}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}var Rt=["ascii","blocks","braille","dots","lines","cross","diagonal","diamond","mixed","pixel","mosaic","lego","voxel","disco","dither","hex","led","cmyk","stipple","engraving","crosshatch","woodblock","risograph","pointillism"];exports.CHARACTER_SETS=t,exports.DEFAULT_OPTIONS=e,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.PALETTE_THEMES={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"}},exports.STUDIO_STYLES=Rt,exports.asciiText=function(t,n={},o,r){const a={...e,...n},{frame:i,cols:s}=Y(t,a,o,r);if(!i.length||0===s)return"";const c=[];for(const t of i)c.push(t.map(t=>t.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(t,n={},o,r){const a={...e,...n},{frame:i,cols:s}=Y(t,a,o,r);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const n of t)" "===n.char||n.a<10?e+=" ":e+=`[38;2;${n.r};${n.g};${n.b}m${n.char}[0m`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,n,{fontSize:o,artStyle:r="classic",options:a={}}={}){let i;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((n,o)=>{e.onload=()=>n(),e.onerror=()=>o(new Error(`Failed to load image: ${t}`)),e.src=t}),i=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=()=>n(new Error("Image failed to load"))}),i=t):i=t;const s=rt(r),c=o??a.fontSize??10,l={...e,...s,artStyle:r,...a,fontSize:c},h=n.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{w:d,h:f}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(i),{renderW:m,renderH:u}=wt(d,f),g="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,M=m*g*u*g>p?Math.sqrt(p/(m*u)):g;n.width===Math.round(m*M)&&n.height===Math.round(u*M)||(n.width=Math.round(m*M),n.height=Math.round(u*M));const{frame:v}=Y(i,l,m,u),w=(t,e)=>{h.save(),h.setTransform(M,0,0,M,0,0),nt(h,v,l,m,u,t/1e3,e),h.restore()};return w(0,null),L(n,w,{continuous:"none"!==l.animationStyle||!!l.charsetFrames?.length,interactive:l.hoverStrength>0}).stop},exports.asciifyGif=async function(t,n,{fontSize:o,artStyle:r="classic",options:a={}}={}){const i="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??a.fontSize??10;let c={...e,...rt(r),artStyle:r,...a,fontSize:s};const l=n.getContext("2d");if(!l)throw new Error("Could not get 2d context from canvas");const{frames:h,fps:d}=await Q(i,c,n.width,n.height);if(!h.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const f=performance.now();let m=-1;return L(n,(t,e)=>{const o=Math.floor((t-f)*d/1e3)%h.length;o===m&&!e&&c.hoverStrength<=0&&"none"===c.animationStyle&&!c.charsetFrames?.length||(nt(l,h[o],c,n.width,n.height,(t-f)/1e3,e),m=o)},{continuous:!0,interactive:c.hoverStrength>0}).stop},exports.asciifyLiveVideo=function(t,e,n){return St(t,e,n)},exports.asciifyText=Lt,exports.asciifyVideo=St,exports.asciifyWebcam=async function(t,{fontSize:n=10,style:o="classic",options:r={},liveOptions:a,mirror:i=!0,constraints:s={facingMode:"user"},dpr:c}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const l=rt(o),h=await navigator.mediaDevices.getUserMedia({video:s}),d=document.createElement("video");d.srcObject=h,d.muted=!0,d.playsInline=!0,await new Promise((t,e)=>{d.onloadedmetadata=()=>t(),d.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),d.play().catch(e)});const f={...e,...l,...r,fontSize:n},m=t.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=c??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const p=e=>{const n=t.getBoundingClientRect();g={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},M=()=>{g=null};f.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",M));let v,w=!1;const x=performance.now(),y=e=>{if(!w){if(d.readyState>=d.HAVE_CURRENT_DATA){const n=t.width/u,o=t.height/u,r=(e-x)/1e3,s=a?{...f,...a()}:f;s.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",M)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",M));const{frame:c}=Y(d,s,n,o),l=g&&i?{x:1-g.x,y:g.y}:g;i?(m.save(),m.scale(-1,1),m.translate(-n,0),nt(m,c,s,n,o,r,l),m.restore()):nt(m,c,s,n,o,r,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{w=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",M),h.getTracks().forEach(t=>t.stop()),d.srcObject=null}},exports.buildTextFrame=Et,exports.captureSnapshot=At,exports.clearAsciifyCaches=function(){W.clear(),$.clear(),Z=new WeakMap,et=new WeakMap,tt=new WeakMap,R=null,I=null},exports.computeCanvasRenderSize=xt,exports.createVideoScrollScrub=ft,exports.gifToAsciiFrames=Q,exports.gifToAsciiTextFrames=async function(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const p=g.getContext("2d"),M=document.createElement("canvas"),v=M.getContext("2d"),w=[];let x=0,y=0,b=0;for(const t of c)b+=t.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),T=Math.min(c.length,300);for(let t=0;t<T;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(M,i.left||0,i.top||0);const b=_(m,e,n,o);w.push(b),x=b.cols,y=b.rowCount,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((t+1)/T)}return{frames:w,cols:x,rows:y,fps:E}},exports.imageToAsciiFrame=Y,exports.imageToAsciiTextFrame=_,exports.renderFrameToCanvas=nt,exports.renderTextBackground=function(t,n,o,r,a={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:d="spotlight",hoverStrength:f=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=a,g=Math.max(1,Math.floor(n/s)),p=Math.max(1,Math.floor(o/(s*c))),M=JSON.stringify([r,g,p,l,h]);let v=Tt.get(t);v&&v.key===M||(v={key:M,frame:Et(r,g,p,l,h)},Tt.set(t,v)),nt(t,v.frame,{...e,fontSize:s,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},n,o,0,i??null)},exports.renderTextFrameToCanvas=G,exports.renderTextToCanvas=function(t,e,n={}){const{color:o="#d4ff00",bgColor:r,fontSize:a=10}=n,i=Lt(e,n);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.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=o,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))},exports.snapshotAndDownload=async function(t,e={}){const{filename:n="asciify-snapshot",format:o="png",...r}=e,a=await At(t,{format:o,...r}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=X,exports.videoToAsciiTextFrames=J;//# sourceMappingURL=core.cjs.map
|