asciify-engine 1.0.115 → 1.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("gifuct-js"),e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵",ascii:" .'`^\",:;~-_+<>i!lI?/\\|()[]{}1tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",interface:" ·•-–—+=:;<>[]{}()⌘⌥⇧⌃↵↗↘◇◆◈□■",prompt:" .:;>_`/\\|{}[]()=+*#@$",data:" ·∙•◦○●◇◆◈▱▰▣█",humanist:" ·˙,:;∴∵∷∶⁚⋮⋯∼≈≋∞",mesh:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},o={cosmic:[e.starfield,e.circles,e.shadows],rain:[e.katakana,e.braille,e.binary],terminal:[e.pipes,e.claudeCode,e.standard],crystal:[e.shards,e.geometric,e.blocks],fluid:[e.waves,e.smoke,e.circles],pulse:[e.dense,e.standard,e.blocks],dream:[e.braille,e.shadows,e.smoke],angular:[e.geometric,e.shards,e.starfield],assistant:[e.interface,e.prompt,e.data],signal:[e.mesh,e.data,e.ascii],editorial:[e.humanist,e.waves,e.smoke]},n={classic:{renderMode:"ascii",charset:e.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:e.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:e.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:e.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:e.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:e.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:e.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:e.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:e.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:e.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:e.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:e.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:e.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:e.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:e.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:e.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:e.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:e.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},r={agentField:{...n.interface,charsetFrames:o.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:o.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:o.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:o.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:o.terminal,charsetFps:3,animationStyle:"rain",animationSpeed:1.1,ditherStrength:.22,hoverEffect:"glitchText",hoverStrength:.65,hoverRadius:.16,hoverColor:"#d4ff00",hoverText:["BUILD","SHIP","RUN","ASK","MODEL"],normalize:!0}},a={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"};function i(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}function s(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function c(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function l(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var h=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function d(t,e,o,n){if(n<=0)return t;const r=(h[o%4][e%4]/16-.5)*n*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,o,n,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(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return f[e]}}}var g=[0,0,0];function M(t,e,o,n,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]=o,g[1]=n,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 p(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 x(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=p(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function w(t){if(t){const e=x(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=x(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 b(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}function v(t,e,o,n,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/n*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),d=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/d*Math.PI*8-3*s)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const o=Math.floor(4*s),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var y={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function S(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const d=t-o,f=e-n,m=.08+.35*l+.04*a;let u,g;if("box"===h){const t=Math.abs(d),e=Math.abs(f);u=Math.max(t,e),g=m}else u=Math.sqrt(d*d+f*f),g=m;if(u>=g)return y.scale=1,y.offsetX=0,y.offsetY=0,y.glow=0,y.colorBlend=0,y.proximity=0,y;const M=function(t){return t*t*(3-2*t)}(1-u/g)*r;let p=1,x=0,w=0,b=0,v=0;switch(c){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(f,d),e=M*M*a*.6;x=Math.cos(t)*e*i,w=Math.sin(t)*e*s,b=M*a*.4,v=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,b=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(f,d),e=M*M*a*1.2;x=Math.cos(t)*e*i,w=Math.sin(t)*e*s;break}case"glow":b=M*a*.8,v=M*a*.4;break;case"colorShift":p=1+M*a*.4,b=M*a*.2,v=M*a*.7;break;case"attract":{const t=Math.atan2(f,d),e=M*M*a*1;x=-Math.cos(t)*e*i,w=-Math.sin(t)*e*s,b=M*a*.3;break}case"shatter":{const t=Math.atan2(f,d),e=.5*Math.sin(43.7*d+29.3*f),o=M*a*1.4*(.7+.3*e);x=Math.cos(t+e)*o*i,w=Math.sin(t+e)*o*s,p=Math.max(.1,1-M*a*.6),b=M*a*.25;break}case"trail":v=M*a*.9,b=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,b=M*a*.5,v=M*a*.6}return y.scale=p,y.offsetX=x,y.offsetY=w,y.glow=b,y.colorBlend=v,y.proximity=M,y}function $(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function C(t){return t*t*t*(t*(6*t-15)+10)}function E(t,e,o){return t+(e-t)*o}function T(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function A(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=C(t-o),i=C(r),s=T(o,n),c=T(o+1,n),l=T(o,n+1),h=T(o+1,n+1);return E(E(s,c,a),E(l,h,a),i)}function F(t,e){return(.5*A(t,e)+.25*A(2.1*t,2.1*e)+.125*A(4.3*t,4.3*e))/.875}function I(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:d,accentThreshold:f=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:x=!0,lightMode:w=!1}=a,b=d??(w?"#6b8700":"#d4ff00"),v=i*s,y=i*c,S=Math.ceil(e/v),$=Math.ceil(o/y),C=r.x,E=r.y;let A=212,I=255,R=0;{const t=b.replace("#","");6===t.length&&(A=parseInt(t.slice(0,2),16),I=parseInt(t.slice(2,4),16),R=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const k=n*g,L=x?.12*(.5*Math.sin(.22*k)+.5):0;for(let e=0;e<$;e++)for(let o=0;o<S;o++){const n=o/S,r=e/$,a=.045,i=.08*k,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*k)+.5+(.5*Math.sin(.03*o-.07*e+.4*k)+.5)+(.5*Math.sin(.05*o+.03*e+.8*k)+.5))/3)+.35*(.5*F(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*k)+.5)+L,d=n-C,g=r-E,x=Math.sqrt(d*d+g*g);let b=0;if(M&&x<.35){const t=Math.atan2(g,d),e=Math.sin(4*t+2.2*k-14*x),o=Math.max(0,1-x/.35);b=e*o*o*.22}const P=c*(1-m)+(Math.max(0,1-x*u)+.5*b)*m+.15*b,B=Math.min(1,Math.max(0,P));let z=B;if(p&&B>.72){const t=Math.floor(8*k),n=T(7*o+3*t,11*e+t);n>.88&&(z=Math.min(1,B+4*(n-.88)))}const q=Math.floor(z*(l.length-1));if(" "===l[q])continue;const H=.015+.07*z;if(z>f){const e=Math.min(w?.9:.28,H*(w?14:2.8));t.fillStyle=`rgba(${A},${I},${R},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):w?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[q],o*v,e*y)}}var R=new WeakMap,k=new WeakMap,L=null,P=null;function B(t,e){if(!L||!P){const o=i(t,e);L=o.canvas,P=o.ctx}return L.width!==t&&(L.width=t),L.height!==e&&(L.height=e),P}var z=new Map,q=new Map,H=new Map,j=new WeakMap,W=new WeakMap,D=new WeakMap;function O(t){let e=z.get(t);return e||(e=[...t],z.set(t,e)),e}function N(t,e,o){const n=o?1-t/255:t/255,r=Math.floor(n*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function U(t,e,o,n){const r=`${t}\0${e?1:0}\0${o}\0${n}`;let a=q.get(r);if(!a){const i=O(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=N(s(t,o,n),i,e);q.set(r,a)}return a}function V(t){let e=H.get(t);if(!e){const o=O(t),n=Math.max(1,o.length);e=new Map;for(let t=0;t<o.length;t++)e.has(o[t])||e.set(o[t],Math.max(.08,(t+.5)/n));H.set(t,e)}return e}function K(t,e){return"auto"!==t?t:!w(e)}function _(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function Y(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=_(t.getPropertyValue(e).trim());if(o)return o}const e=_(getComputedStyle(document.body).accentColor??"");if(e)return e}return w("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function G(t,e,o){return Math.max(e,Math.min(o,t))}function X(t,e,o){if(!t)return{x:0,y:0,width:e,height:o};const n=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===n?t*e:t,i=t=>void 0===t?void 0:"percent"===n?t*o:t,s=G(a(t.left)??0,0,e-1),c=G(a(t.right)??0,0,e-s-1),l=G(i(t.top)??0,0,o-1),h=G(i(t.bottom)??0,0,o-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,o-l-h),u=d?f:a(t.width),g=d?m:i(t.height);let M=u??e,p=g??o;if(r&&!d){const t=M/e,n=p/o,r=Math.min(t,n),a=void 0===u?n:void 0===g?t:r;M=e*a,p=o*a}M=G(M,1,d?f:e),p=G(p,1,d?m:o);const x=t.anchor??"center",w=a(t.x),b=i(t.y),v=d?s:0,y=d?l:0,S=d?f:e,$=d?m:o,C=x.endsWith("left")||"left"===x?0:x.endsWith("right")||"right"===x?S-M:(S-M)/2,E=x.startsWith("top")||"top"===x?0:x.startsWith("bottom")||"bottom"===x?$-p:($-p)/2;return{x:G(w??v+C,0,Math.max(0,e-M)),y:G(b??y+E,0,Math.max(0,o-p)),width:M,height:p}}function J(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,c=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,f=o||r,m=n||a,u=Math.floor(f/c),g=Math.floor(m/h);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=X(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(M.width/u))),x=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),w=u*p,v=g*x,y=B(w,v);y.drawImage(t,M.x,M.y,M.width,M.height,0,0,w,v);const S=y.getImageData(0,0,w,v).data,$=e.chromaKey,C=null!=$&&!1!==$,E=!0===$,T="blue-screen"===$;let A=null,F=0;!C||E||T||(A=b($),F=(e.chromaKeyTolerance??60)**2);let I=0,R=255;if(e.normalize){let t=255,e=0;for(let o=0;o<S.length;o+=4){if(C){const t=S[o],e=S[o+1],n=S[o+2];let r=!1;if(E)r=e>1.4*t&&e>1.4*n&&e>80;else if(T)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==A){const o=t-A.r,a=e-A.g,i=n-A.b;r=o*o+a*a+i*i<=F}if(r)continue}const n=.299*S[o]+.587*S[o+1]+.114*S[o+2];n<t&&(t=n),n>e&&(e=n)}I=t,R=e>t?e-t:255}const k=[],L=K(e.invert),P=C&&e.charset.replace(/ /g,"")||e.charset,z=O(P),q=e.customText?null:U(P,L,e.brightness,e.contrast),H=p*x;for(let t=0;t<g;t++){const o=[];for(let n=0;n<u;n++){let r=0,a=0,i=0,c=0,h=0;for(let e=0;e<x;e++){const o=(t*x+e)*w;for(let t=0;t<p;t++){const e=4*(o+n*p+t),s=S[e],l=S[e+1],d=S[e+2],f=S[e+3];if(C){let t=!1;if(E)t=l>1.4*s&&l>1.4*d&&l>80;else if(T)t=d>1.4*s&&d>1.4*l&&d>80;else if(null!==A){const e=s-A.r,o=l-A.g,n=d-A.b;t=e*e+o*o+n*n<=F}if(t){h++;continue}}r+=s,a+=l,i+=d,c+=f}}if(C&&h>H/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const f=H-h,m=f>0?r/f:0,g=f>0?a/f:0,M=f>0?i/f:0,b=f>0?c/f:0,v=.299*m+.587*g+.114*M,y=e.normalize?(v-I)/R*255:v,$=s(y,e.brightness,e.contrast),k=e.ditherStrength>0?d($,n,t,e.ditherStrength):$,P=e.customText?l(k,e.customText,n,t,u,L):e.ditherStrength>0?N(k,z,L):q[Math.max(0,Math.min(255,0|y))];o.push({char:P,r:m,g:g,b:M,a:b,lum:k})}k.push(o)}return{frame:k,cols:u,rows:g}}function Q(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,c=e.fontSize*e.charSpacing,l=e.fontSize/i*e.charSpacing,h=o||r,f=n||a,m=Math.floor(h/c),u=Math.floor(f/l);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=B(g,M),x=X(e.sourceCrop,r,a);p.drawImage(t,x.x,x.y,x.width,x.height,0,0,g,M);const w=p.getImageData(0,0,g,M).data,v=e.chromaKey,y=null!=v&&!1!==v,S=!0===v,$="blue-screen"===v;let C=null,E=0;!y||S||$||(C=b(v),E=(e.chromaKeyTolerance??60)**2);let T=0,A=255;if(e.normalize){let t=255,e=0;for(let o=0;o<w.length;o+=4){if(y){const t=w[o],e=w[o+1],n=w[o+2];let r=!1;if(S)r=e>1.4*t&&e>1.4*n&&e>80;else if($)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==C){const o=t-C.r,a=e-C.g,i=n-C.b;r=o*o+a*a+i*i<=E}if(r)continue}const n=.299*w[o]+.587*w[o+1]+.114*w[o+2];n<t&&(t=n),n>e&&(e=n)}T=t,A=e>t?e-t:255}const F=K(e.invert),I=y&&e.charset.replace(/ /g,"")||e.charset,R=O(I),k=e.customText?null:U(I,F,e.brightness,e.contrast),L=e.customText?O(e.customText):null,P="fullcolor"===e.colorMode?new Uint8ClampedArray(m*u*4):void 0,z=[];for(let t=0;t<u;t++){let o="";for(let n=0;n<m;n++){const r=4*(t*g+n),a=r,i=w[r],c=w[r+1],l=w[r+2],h=w[r+3];if(y){let t=!1;if(S)t=c>1.4*i&&c>1.4*l&&c>80;else if($)t=l>1.4*i&&l>1.4*c&&l>80;else if(null!==C){const e=i-C.r,o=c-C.g,n=l-C.b;t=e*e+o*o+n*n<=E}if(t){o+=" ",P&&(P[a]=0,P[a+1]=0,P[a+2]=0,P[a+3]=0);continue}}P&&(P[a]=i,P[a+1]=c,P[a+2]=l,P[a+3]=h);const f=.299*i+.587*c+.114*l,u=e.normalize?(f-T)/A*255:f,M=e.ditherStrength>0||L?s(u,e.brightness,e.contrast):u,p=e.ditherStrength>0?d(M,n,t,e.ditherStrength):M;if(L){o+=(F?1-p/255:p/255)<.12?" ":L[(t*m+n)%L.length]}else e.ditherStrength<=0?o+=k[Math.max(0,Math.min(255,0|u))]:o+=N(p,R,F)}z.push(o)}return{rows:z,cols:m,rowCount:u,colors:P}}function Z(t,e,o,n,r){if(0===e.rows.length)return;const a=t.canvas,s=Boolean(o.chromaKey)||e.rows.some(t=>t.includes(" "));s||(D.delete(t),t.clearRect(0,0,n,r),t.fillStyle=w(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const c=Y(o.accentColor),l=parseInt(c.substring(0,2),16)||255,h=parseInt(c.substring(2,4),16)||255,d=parseInt(c.substring(4,6),16)||255,f=n/e.cols,m=r/e.rowCount,u=.9*Math.min(f/.55,m),g=e.colors;if("fullcolor"===o.colorMode&&g){if(D.delete(t),t.clearRect(0,0,n,r),u<6){const{canvas:a,ctx:s}=function(t,e,o){let n=j.get(t);n||(n=i(e,o).canvas,j.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderTextFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,e.cols,e.rowCount);let c=W.get(s);c&&c.width===e.cols&&c.height===e.rowCount||(c={width:e.cols,height:e.rowCount,imageData:s.createImageData(e.cols,e.rowCount)},W.set(s,c));const l=c.imageData,h=l.data;h.fill(0);const d=V(o.charset);for(let t=0;t<e.rowCount;t++){const o=e.rows[t];for(let n=0;n<e.cols;n++){const r=o[n];if(" "===r)continue;const a=4*(t*e.cols+n),i=g[a+3];if(i<10)continue;const s=d.get(r)??.5;h[a]=g[a],h[a+1]=g[a+1],h[a+2]=g[a+2],h[a+3]=0|Math.min(255,i*s)}}return s.putImageData(l,0,0),t.imageSmoothingEnabled=!1,t.drawImage(a,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let a="";for(let o=0;o<e.rows.length;o++){const n=e.rows[o];let r=0;for(;r<e.cols;){for(;r<e.cols&&" "===n[r];)r++;if(r>=e.cols)break;const i=r,s=4*(o*e.cols+r),c=240&g[s],l=240&g[s+1],h=240&g[s+2];for(r++;r<e.cols&&" "!==n[r];){const t=4*(o*e.cols+r);if((240&g[t])!==c||(240&g[t+1])!==l||(240&g[t+2])!==h)break;r++}const d=`rgb(${c},${l},${h})`;d!==a&&(t.fillStyle=d,a=d),t.fillText(n.slice(i,r),i*f+.5*f,o*m+.5*m)}}return void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const M="matrix"===o.colorMode?"rgb(0,255,0)":"grayscale"===o.colorMode?w(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${l},${h},${d})`;t.fillStyle=M,t.globalAlpha=1;const p=D.get(t),x=s&&p&&p.cols===e.cols&&p.rowCount===e.rowCount&&p.canvasWidth===n&&p.canvasHeight===r&&p.fillStyle===M;x||t.clearRect(0,0,n,r);for(let o=0;o<e.rows.length;o++){const r=e.rows[o];x&&p.rows[o]===r||(x&&t.clearRect(0,o*m,n,m+1),0!==r.trim().length&&t.fillText(r,.5*f,o*m+.5*m))}D.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:n,canvasHeight:r,fillStyle:M}),t.globalAlpha=1}async function tt(t,e,o,n,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 o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=J(t,e,o,n);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 et(t,e,o,n,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 o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=Q(t,e,o,n);h.push(u),d=u.cols,f=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function ot(e,o,n,r,a){const i=t.parseGIF(e),s=t.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,d=i.lsd?.height||l,f=document.createElement("canvas");f.width=h,f.height=d;const m=f.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=d;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),x=[];let w=0,b=0,v=0;for(const t of s)v+=t.delay||100;const y=v/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let t=0;t<$;t++){const e=s[t],{dims:i,patch:c,disposalType:l}=e;3===l&&(g.clearRect(0,0,h,d),g.drawImage(f,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const v=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(v,0,0),m.drawImage(M,i.left||0,i.top||0);const y=J(f,o,n,r);x.push(y.frame),w=y.cols,b=y.rows,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,d),m.drawImage(u,0,0)),a?.((t+1)/$)}return{frames:x,cols:w,rows:b,fps:S}}async function nt(e,o,n,r,a){const i=t.parseGIF(e),s=t.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,d=i.lsd?.height||l,f=document.createElement("canvas");f.width=h,f.height=d;const m=f.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=d;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),x=[];let w=0,b=0,v=0;for(const t of s)v+=t.delay||100;const y=v/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let t=0;t<$;t++){const e=s[t],{dims:i,patch:c,disposalType:l}=e;3===l&&(g.clearRect(0,0,h,d),g.drawImage(f,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const v=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(v,0,0),m.drawImage(M,i.left||0,i.top||0);const y=Q(f,o,n,r);x.push(y),w=y.cols,b=y.rowCount,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,d),m.drawImage(u,0,0)),a?.((t+1)/$)}return{frames:x,cols:w,rows:b,fps:S}}function rt(t,e,o,n,r,a=0,s){if("waveField"===o.animationStyle){return void I(t,n,r,a,s?{x:s.x,y:s.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?Y(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const l=e.length;if(0===l)return;const h=e[0].length;t.clearRect(0,0,n,r);let d=!1;const f=Math.max(1,l>>2),m=Math.max(1,h>>2);t:for(let t=0;t<l;t+=f){const o=e[t];for(let t=0;t<h;t+=m)if(o[t].a<200){d=!0;break t}}const g=t.canvas,p=w(g);d||(t.fillStyle=p?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const x=n/h,b=r/l,y=l*h,$=s?.intensity??1,C=!("none"!==o.animationStyle&&y>5e3)&&!!(s&&o.hoverStrength>0&&$>.005),E=o.hoverColor||"#ffffff",T=parseInt(E.slice(1,3),16)||255,A=parseInt(E.slice(3,5),16)||255,F=parseInt(E.slice(5,7),16)||255,L=Y(o.accentColor),P=parseInt(L.substring(0,2),16)||255,B=parseInt(L.substring(2,4),16)||255,z=parseInt(L.substring(4,6),16)||255,q=y>3e4?.25:y>15e3?.4:y>5e3?.6:1,H=o.hoverRadius*q;let j=0,W=h,D=0,O=l,N=0,U=0;if(C&&s){N=s.x,U=s.y;const t=.08+.35*H+.04*o.hoverStrength;j=Math.max(0,Math.floor((N-t)*h)-1),W=Math.min(h,Math.ceil((N+t)*h)+1),D=Math.max(0,Math.floor((U-t)*l)-1),O=Math.min(l,Math.ceil((U+t)*l)+1)}const _=o.animationStyle,G=o.animationSpeed,X="none"===_,J=o.hoverStrength,Q=o.hoverEffect,Z=H,tt=o.hoverShape||"circle",et=K(o.invert,g),ot=o.colorMode,nt=2*Math.PI,rt=1/h,at=1/l;let it="",st=-1;if("dots"===o.renderMode){const n=.5*Math.min(x,b)*o.dotSizeRatio;for(let o=0;o<l;o++){const r=e[o];for(let e=0;e<h;e++){const i=r[e];if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),c=et?1-s:s;if(c<.02)continue;const d=X?1:v(e,o,h,l,a,_,G);let f=1,m=0,g=0,p=0,w=0;if(C&&e>=j&&e<=W&&o>=D&&o<=O){const t=S(e*rt,o*at,N,U,$,J,x,b,Q,Z,tt);f=t.scale,m=t.offsetX,g=t.offsetY,p=t.glow,w=t.colorBlend}const y=n*c*d*f;if(y<.3)continue;const E=e*x+.5*x+m,I=o*b+.5*b+g;let R;if(w>0){const t=M(i,ot,P,B,z,et);R=`rgb(${Math.min(255,t[0]+(T-t[0])*w|0)},${Math.min(255,t[1]+(A-t[1])*w|0)},${Math.min(255,t[2]+(F-t[2])*w|0)})`}else R=u(i,ot,P,B,z,et);const k=Math.min(1,.00392156863*i.a*d*(1+p));if(k!==st&&(t.globalAlpha=k,st=k),R!==it&&(t.fillStyle=R,it=R),y<=3){const e=2*y;t.fillRect(E-y,I-y,e,e)}else t.beginPath(),t.arc(E,I,y,0,nt),t.fill()}}}else{const s=.55,d=.9*Math.min(x/s,b),f=d<6;if(!f){const e="emoji"===o.artStyle;t.font=e?`${d}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${d}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const m=o.charsetFrames,g=!!m?.length,p=g?m[Math.floor(Math.max(0,a)*(o.charsetFps??2))%m.length]:o.charset;if(f){const{canvas:o,ctx:a}=function(t,e,o){let n=R.get(t);n||(n=i(e,o).canvas,R.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,h,l);let s=k.get(a);s&&s.width===h&&s.height===l||(s={width:h,height:l,imageData:a.createImageData(h,l)},k.set(a,s));const d=s.imageData,f=d.data;f.fill(0);const m=V(p);for(let t=0;t<l;t++){const o=e[t];for(let e=0;e<h;e++){const n=o[e],r=4*(t*h+e);if(n.a<10)continue;const a=g&&null!=n.lum?c(n.lum,p,et):n.char;if(" "===a)continue;let i,s,l,d=m.get(a)??.5,u=0,w=0;if(C&&e>=j&&e<=W&&t>=D&&t<=O){const o=S(e*rt,t*at,N,U,$,J,x,b,Q,Z,tt);d*=o.scale,u=o.glow,w=o.colorBlend}if(w>0){const t=M(n,ot,P,B,z,et);i=Math.min(255,t[0]+(T-t[0])*w|0),s=Math.min(255,t[1]+(A-t[1])*w|0),l=Math.min(255,t[2]+(F-t[2])*w|0)}else{const t=M(n,ot,P,B,z,et);i=t[0],s=t[1],l=t[2]}const v=Math.min(255,Math.max(0,n.a*d*(1+u)));f[r]=i,f[r+1]=s,f[r+2]=l,f[r+3]=v}}return a.putImageData(d,0,0),t.imageSmoothingEnabled=!1,t.drawImage(o,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}const w=f?null:t.getTransform();if(!f&&!C&&X&&!g&&"accent"===ot){t.fillStyle=`rgb(${P},${B},${z})`,t.globalAlpha=1,t.textAlign="left";for(let o=0;o<l;o++){const n=e[o];let r="";for(let t=0;t<h;t++){const e=n[t];r+=e.a<10?" ":e.char}0!==r.trim().length&&t.fillText(r,.5*x,o*b+.5*b)}return void(t.globalAlpha=1)}const y="glitchText"===Q&&C,E="!@#$%^&*<>{}[]|/\\~`0123456789",I=E.length;let L="",q=0,K=0,Y=0,nt=0,ct=0,lt=0;if(y){const t=o.hoverText??"ASCIIFY";if(K=Math.round(N*h),Y=Math.round(U*l),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");L=e[((7*Math.floor(K/Math.max(1,Math.ceil(h/5)))+13*Math.floor(Y/Math.max(1,Math.ceil(l/3))))%e.length+e.length)%e.length]}else L=t||"ASCIIFY";q=L.length,nt=Math.max(3,Math.min(12,Math.round(l*H*.6)));const e=Math.floor(nt/2);ct=Math.max(0,Y-e),ct+nt>l&&(ct=Math.max(0,l-nt)),lt=K-Math.floor(q/2)}for(let o=0;o<l;o++){const n=e[o];for(let e=0;e<h;e++){const r=n[e];if(r.a<10)continue;let i=g&&null!=r.lum?c(r.lum,p,et):r.char;if(" "===i)continue;const s=X?1:v(e,o,h,l,a,_,G);if(s<.05)continue;let d=1,f=0,m=0,R=0,k=0;if(C&&!y&&e>=j&&e<=W&&o>=D&&o<=O){const t=S(e*rt,o*at,N,U,$,J,x,b,Q,Z,tt);d=t.scale,f=t.offsetX,m=t.offsetY,R=t.glow,k=t.colorBlend}if(y&&o>=ct&&o<ct+nt){const t=e-lt;if(t>=0&&t<q){const n=L[t],r=Math.abs(o-Y)/Math.max(1,.5*nt),s=Math.abs(e-K)/Math.max(1,q),c=Math.max(r,s),l=Math.max(0,Math.min(1,1-.9*c)),h=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));i=Math.abs(h-Math.floor(h))<l?n:E[Math.abs(Math.floor(97*h))%I],R=.3+.7*l,k=.3+.65*l}}const H=e*x+.5*x+f,V=o*b+.5*b+m;let ht;if(k>0){const t=M(r,ot,P,B,z,et);ht=`rgb(${Math.min(255,t[0]+(T-t[0])*k|0)},${Math.min(255,t[1]+(A-t[1])*k|0)},${Math.min(255,t[2]+(F-t[2])*k|0)})`}else ht=u(r,ot,P,B,z,et);const dt=Math.min(1,.00392156863*r.a*s*(1+R));dt!==st&&(t.globalAlpha=dt,st=dt),ht!==it&&(t.fillStyle=ht,it=ht),1!==d?(t.translate(H,V),t.scale(d,d),t.fillText(i,0,0),t.setTransform(w)):t.fillText(i,H,V)}}}t.globalAlpha=1}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 o=at(t),n=at(o*(void 0===e.speed?1:Math.max(.001,e.speed)));return at(e.ease?e.ease(n):n)}function lt(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=ct(e,o),s=n+(a-n)*i;t.currentTime=Math.min(Math.max(n,s),Math.max(n,a-.04)),o.onUpdate?.(i,t)}function ht(t,e){return Math.abs(t.currentTime-e)<1/240?dt(t):new Promise(o=>{const n=()=>{t.removeEventListener("seeked",n),o()};t.addEventListener("seeked",n,{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?o=>{let n=!1;const r=()=>{n||(n=!0,o())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function ft(t,e={}){const o=it(e.trigger)??t;t.pause();const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:o,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:o=>lt(t,o.progress,e)});return()=>a.kill?.()}return function(t,e,o){let n=0;const r=()=>{n=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,o)},a=()=>{n||(n=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),n&&cancelAnimationFrame(n)}}(t,o,e)}function mt(t,e,o){const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>o(t.progress)});return()=>a.kill?.()}return function(t,e){let o=0;const n=()=>{o=0;const n=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=n.height+r,i=a>0?at((r-n.top)/a):0;e(i)},r=()=>{o||(o=requestAnimationFrame(n))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),o&&cancelAnimationFrame(o)}}(t,o)}function ut(t,e,o){if(!t||!e||!o.sourceCrop)return{w:t,h:e};const n=X(o.sourceCrop,t,e);return{w:Math.max(1,Math.round(n.width)),h:Math.max(1,Math.round(n.height))}}function gt(t,e,o,n){const r=n.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return e>1.4*t&&e>1.4*o&&e>80;if("blue-screen"===r)return o>1.4*t&&o>1.4*e&&o>80;const a=b(r),i=(n.chromaKeyTolerance??60)**2,s=t-a.r,c=e-a.g,l=o-a.b;return s*s+c*c+l*l<=i}function Mt(t,e,o){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const n=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!n||!r)return e;const a=X(e.sourceCrop,n,r),s=Math.min(360,Math.max(1,Math.round(a.width))),c=Math.max(1,Math.round(s*(a.height/a.width))),{ctx:l}=i(s,c);l.drawImage(t,a.x,a.y,a.width,a.height,0,0,s,c);const h=l.getImageData(0,0,s,c).data,d=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let f=s,m=c,u=-1,g=-1;for(let t=0;t<c;t++)for(let o=0;o<s;o++){const n=4*(t*s+o),r=h[n+3],a=h[n],i=h[n+1],c=h[n+2];r<=8||.2126*a+.7152*i+.0722*c<=d||gt(a,i,c,e)||(o<f&&(f=o),t<m&&(m=t),o>u&&(u=o),t>g&&(g=t))}if(u<f||g<m)return e;const M=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),p=Math.round(s*M),x=Math.round(c*M);f=Math.max(0,f-p),m=Math.max(0,m-x),u=Math.min(s-1,u+p),g=Math.min(c-1,g+x);const w=function(t,e,o,n,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,o-t.right),m=Math.min(l,n-t.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),M=h+u/2,p=d+g/2;let x=u,w=g;x/w<a?x=w*a:w=x/a;x>e.width&&(x=e.width,w=Math.max(g,Math.min(e.height,x/a)));w>e.height&&(w=e.height,x=Math.max(u,Math.min(e.width,w*a)));let b=M-x/2,v=p-w/2;return b=Math.max(i,Math.min(c-x,b)),v=Math.max(s,Math.min(l-w,v)),{left:b,top:v,right:o-(b+x),bottom:n-(v+w)}}({left:a.x+f/s*a.width,top:a.y+m/c*a.height,right:n-(a.x+(u+1)/s*a.width),bottom:r-(a.y+(g+1)/c*a.height)},{x:a.x,y:a.y,width:a.width,height:a.height},n,r,o);return{...e,sourceCrop:{unit:"pixel",...w,preserveAspect:!1}}}function pt(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 xt(t,e,o,n,r){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const a=t.currentTime,i=function(t,e,o,n){const r=!0===n?{}:n||{},a=Math.max(0,r.from??e),i=r.to??o??(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,o,n,r);let s=null;for(const o of i){await ht(t,o),await dt(t);const n=pt(Mt(t,e));n&&(s=s?{left:Math.min(s.left,n.left),top:Math.min(s.top,n.top),right:Math.min(s.right,n.right),bottom:Math.min(s.bottom,n.bottom)}:n)}return await ht(t,a),await dt(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function wt(t,e,o=2048){const n=o,r=Math.min(1,n/Math.max(t,e));return{renderW:Math.round(t*r),renderH:Math.round(e*r)}}function bt(t,e,o,n){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)?o*t:void 0}if(r.endsWith("vh")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?n*t:void 0}}function vt(t,e,o,n,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=bt(i.width,s,l,h)??s,f=bt(i.height,c,l,h)??c,m=function(t,e,o,n,r){const a=t=>{const o=bt(t,e,n,r);return o&&o>0?o:0},i=t=>{const e=bt(t,o,n,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:M,cssH:p}=function(t,e,o,n="contain"){if("fill"===n)return{cssW:t,cssH:e};let r=t,a=r/o;const i="cover"===n,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*o),"scale-down"===n&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,o,i.objectFit??"contain");let x,w;n&&r?({renderW:x,renderH:w}=wt(n,r,a)):(x=M,w=p);const b="undefined"!=typeof window&&window.devicePixelRatio||1,v=8e6,y=x*b*w*b>v?Math.sqrt(v/(x*w)):b;return t.width=Math.round(x*y),t.height=Math.round(w*y),t.style.width=`${M}px`,t.style.height=`${p}px`,{renderW:x,renderH:w,dpr:y}}async function yt(t,e,{fontSize:o,artStyle:r="classic",options:i={},fitTo:s,objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m,preExtract:u=!1,fps:g,maxRenderDimension:M=2048,trim:p,scroll:x,maxCachedFrames:w=90,onReady:b,onFrame:v}={}){const y=p?.start??0,S=p?.end,$=o??i.fontSize??10;let C={...a,...n[r],...i,fontSize:$};const E=e.getContext("2d");if(!E)throw new Error("asciifyVideo: could not get 2d context from canvas.");const T="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null,A={objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m},F=function(t,e){var o;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 n={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 n=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(n)),(o=t.style).transformOrigin||(o.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=n.width,t.style.height=n.height,t.style.objectFit=n.objectFit,t.style.objectPosition=n.objectPosition,t.style.maxWidth=n.maxWidth,t.style.maxHeight=n.maxHeight,t.style.transformOrigin=n.transformOrigin,n.scale?t.style.setProperty("scale",n.scale):t.style.removeProperty("scale")}}(e,A),I=t=>()=>{t(),F()};if(u){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,C=await xt(o,C,y,S,x);const n=ut(o.videoWidth,o.videoHeight,C);T&&vt(e,T,n.w/n.h,n.w,n.h,M,A);const{renderW:r,renderH:a}=wt(n.w,n.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;e.width<Math.round(r*c)&&(e.width=Math.round(r*c),e.height=Math.round(a*c));const l=void 0!==S?S-y:10,h=g??(x?18:void 0);if(st(C)){const{frames:t,fps:n}=await et(o,C,r,a,h,l,void 0,y),i=e=>{const o=t[e];o&&(E.save(),E.setTransform(c,0,0,c,0,0),Z(E,o,C,r,a),E.restore(),v?.())};if(x){let n=!1,r=-1;const a=!0===x?{}:x,s=mt(it(a.trigger)??T??e,a,e=>{const s=ct(e,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),n||(n=!0,b?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,b?.(o),I(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/n,M=e=>{d||(e-m>=g&&(i(f),f=(f+1)%t.length,m=e,u&&(u=!1,b?.(o))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),I(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await tt(o,C,r,a,h,l,void 0,y),m=t=>{const e=d[t];e&&(E.save(),E.setTransform(c,0,0,c,0,0),rt(E,e,C,r,a),E.restore(),v?.())};if(x){let t=!1,n=-1;const r=!0===x?{}:x,a=mt(it(r.trigger)??T??e,r,e=>{const a=ct(e,r),i=Math.max(0,Math.min(d.length-1,Math.round(a*(d.length-1))));i!==n&&(n=i,m(i),t||(t=!0,b?.(o)),r.onUpdate?.(a,o))});return m(0),t=!0,b?.(o),I(a)}let u,p=!1,w=0,$=performance.now(),F=!0;const R=1e3/f,k=t=>{p||(t-$>=R&&(m(w),w=(w+1)%d.length,$=t,F&&(F=!1,b?.(o))),u=requestAnimationFrame(k))};return u=requestAnimationFrame(k),I(()=>{p=!0,cancelAnimationFrame(u)})}let R,k=!1;"string"==typeof t?(R=document.createElement("video"),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),k=!0,await new Promise((e,o)=>{R.onloadedmetadata=()=>e(),R.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await R.play().catch(()=>{})):(R=t,R.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{R.removeEventListener("loadedmetadata",n),R.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};R.addEventListener("loadedmetadata",n),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 L=null;(y>0||void 0!==S)&&(L=()=>{(void 0!==S&&R.currentTime>=S||y>0&&R.currentTime<y)&&(R.currentTime=y)},R.addEventListener("timeupdate",L)),C=await xt(R,C,y,S,x);let P=null;const B=ut(R.videoWidth,R.videoHeight,C),{renderW:z,renderH:q}=wt(B.w,B.h,M),H=t=>"frame"===C.chromaKeyTrimMode?Mt(t,C,z/q):C;if(T){const t=B.w/B.h,o=B.w,n=B.h,r=vt(e,T,t,o,n,M,A),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),P=new ResizeObserver(()=>{const r=vt(e,T,t,o,n,M,A),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),P.observe(T)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=z*t*q*t>o?Math.sqrt(o/(z*q)):t;e.width<Math.round(z*n)&&(e.width=Math.round(z*n),e.height=Math.round(q*n)),E.setTransform(n,0,0,n,0,0)}let j,W=!1,D=!0,O=null;const N=x&&!u,U=g&&g>0?1e3/g:0;let V=0,K=-1;const _=!N&&st(C);if(N&&"ascii"===C.renderMode&&"none"===C.animationStyle&&C.hoverStrength<=0&&!C.charsetFrames?.length){const t=!0===x?{}:x,o=it(t.trigger)??T??e,n=t.from??y,r=t.to??S??R.duration,a=Math.max(n,Math.min(r,R.duration)),i=Math.max(.001,a-n),s=Math.min(60,Math.max(12,g??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(w))),f=()=>{for(;h.length>d;){const t=h.findIndex(t=>t!==u&&Math.abs(t-u)>2),e=t>=0?t:0,o=h.splice(e,1)[0];void 0!==o&&(l[o]=void 0)}},m=t=>{const e=h.indexOf(t);e>=0&&h.splice(e,1),h.push(t),f()};let u=0,M=0,p=-1,$=0,A=!1,F=!1,B=!1;const j=new Set,W=document.createElement("video");W.muted=!0,W.playsInline=!0,W.preload="auto",W.crossOrigin=R.crossOrigin||"anonymous",W.src=R.currentSrc||R.src,Object.assign(W.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(W),W.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{W.removeEventListener("loadedmetadata",n),W.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: cache video failed to load metadata."))};W.addEventListener("loadedmetadata",n),W.addEventListener("error",r),W.load()}),W.pause(),R.paused&&await R.play().catch(()=>{});const D=t=>n+i*t/Math.max(1,c-1),N=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),K=H(R),_=Q(R,K,z,q);_.rows.length>0&&(l[0]=_,m(0),Z(E,_,K,z,q),B=!0,b?.(R),v?.());const Y=t=>{if(l[t])return t;for(let e=1;e<c;e++){const o=t-e,n=t+e;if(o>=0&&l[o])return o;if(n<c&&l[n])return n}return-1},G=()=>{if(!l[u])return u;for(const t of j)if(!l[t])return t;for(let t=1;t<c;t++){const e=u-t,o=u+t;if(e>=0&&!l[e])return e;if(o<c&&!l[o])return o}return-1},X=t=>{t<0||t>=c||l[t]||(j.add(t),J())},J=async()=>{if(A||F)return;const t=G();if(!(t<0)){j.delete(t),F=!0;try{if(await ht(W,D(t)),!A){const e=H(W),o=Q(W,e,z,q);o.rows.length>0&&(l[t]=o,m(t))}}finally{F=!1,A||requestAnimationFrame(()=>{J()})}}},tt=()=>{if(A)return;const t=Y(u);if(t>=0&&t!==p){const e=l[t];e&&(Z(E,e,C,z,q),p=t,B||(B=!0,b?.(R)),v?.())}else if(t<0||p<0){const t=performance.now();if(U<=0||t-V>=U){const e=H(R),o=Q(R,e,z,q);o.rows.length>0&&(Z(E,o,e,z,q),V=t,B||(B=!0,b?.(R)),v?.())}}X(u),$=requestAnimationFrame(tt)};return O=mt(o,t,e=>{const o=function(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=ct(e,o),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(R,e,{...t,from:n,to:a});M=o?.progress??at(e),u=N(M),X(u),X(u-1),X(u+1),X(u-2),X(u+2),X(u-3),X(u+3),t.onUpdate?.(M,R)}),X(0),X(1),$=requestAnimationFrame(tt),I(()=>{A=!0,cancelAnimationFrame($),O?.(),P?.disconnect(),j.clear(),h.length=0,l.fill(void 0),W.pause(),W.src="",W.removeAttribute("src"),W.load(),W.isConnected&&W.remove(),L&&R.removeEventListener("timeupdate",L),k&&(R.pause(),R.src="",R.removeAttribute("src"),R.load(),R.isConnected&&R.remove())})}if(N){const t=!0===x?{}:x;O=ft(R,{...t,trigger:t.trigger??T??e,from:t.from??y,to:t.to??S})}const Y=t=>{if(W)return;if(j=requestAnimationFrame(Y),R.readyState<2||0===e.width||0===e.height)return;if(U>0&&t-V<U)return;if(y>0&&R.currentTime<y)return;if(void 0!==S&&R.currentTime>=S)return;if(N&&Math.abs(R.currentTime-K)<1/240)return;if(_){const e=H(R),o=Q(R,e,z,q);return void(o.rows.length>0&&(Z(E,o,e,z,q),V=t,K=R.currentTime,D&&(D=!1,b?.(R)),v?.()))}const o=H(R),{frame:n}=J(R,o,z,q);n.length>0&&(rt(E,n,C,z,q,0,null),V=t,K=R.currentTime,D&&(D=!1,b?.(R)),v?.())};return j=requestAnimationFrame(Y),I(()=>{W=!0,cancelAnimationFrame(j),O?.(),P?.disconnect(),L&&R.removeEventListener("timeupdate",L),k&&(R.pause(),R.src="",R.removeAttribute("src"),R.load(),R.isConnected&&R.remove())})}function St(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:d=14,lightMode:f=!1}=r,m=s??(f?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let x=255,w=255,b=255;if(f&&(x=55,w=55,b=55),c){const t=$(c);t&&(x=t.r,w=t.g,b=t.b)}let v=212,y=255,S=0;const C=$(m);C&&(v=C.r,y=C.g,S=C.b);const E=p+d;for(let e=0;e<M;e++){if(T(17*e,3)>h)continue;const o=(.5+1.5*T(31*e,7))*l,r=T(13*e,11)*E,a=Math.floor((n*o*7+r)%E),s=e*u;for(let o=0;o<=d;o++){const r=a-(d-o);if(r<0||r>=p)continue;const c=r*g,l=T(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/d;if(o===d)t.fillStyle=`rgba(${v},${y},${S},${f?.7:.85})`;else{const e=f?.85*m:.15*m;t.fillStyle=`rgba(${x},${w},${b},${e})`}t.fillText(h,s,c)}}}function $t(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:d=180,lightMode:f=!1}=a,m=c??(f?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,x=255,w=255;if(f&&(p=55,x=55,w=55),l){const t=$(l);t&&(p=t.r,x=t.g,w=t.b)}let b=212,v=255,y=0;const S=$(m);S&&(b=S.r,v=S.g,y=S.b);const C=s.replace(/ /g,"").split("");if(0!==C.length){for(let r=0;r<d;r++){const a=T(17*r,3)*Math.PI*2,s=(n*(.15+.85*T(31*r,7))*h*.22+T(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>o+20)continue;const d=Math.max(6,i*(.4+.9*s));t.font=`${d}px monospace`;const m=C[Math.min(C.length-1,Math.floor(s*C.length))],S=s>.72,$=f?.85*s:.2*s;t.fillStyle=S?`rgba(${b},${v},${y},${Math.min(f?.92:.32,2.2*$)})`:`rgba(${p},${x},${w},${$})`,t.fillText(m,c,l)}t.textAlign="left"}}function Ct(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:d=1,sharpness:f=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const g=e*r.x,M=o*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(e*e+o*o);let x=255,w=255,b=255;if(m&&(x=55,w=55,b=55),l){const t=$(l);t&&(x=t.r,w=t.g,b=t.b)}let v=0,y=255,S=204;const C=$(u);C&&(v=C.r,y=C.g,S=C.b);const E=s.replace(/ /g,"").split("");if(0===E.length)return;const T=Math.ceil(e/i),A=Math.ceil(o/i);for(let e=0;e<A;e++)for(let o=0;o<T;o++){const r=o*i+.5*i,a=e*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(n*d*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-f)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;t.font=`${i}px monospace`;const C=Math.floor(u*(E.length-1)),T=E[Math.min(C,E.length-1)],A=m?.88*u:.22*u;t.fillStyle=$?`rgba(${v},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${x},${w},${b},${A})`,t.fillText(T,r,a)}t.textAlign="left"}function Et(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:d=1,scale:f=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,x=1.4*i,w=Math.ceil(e/p),b=Math.ceil(o/x);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let v=255,y=255,S=255;if(g&&(v=55,y=55,S=55),l){const t=$(l);t&&(v=t.r,y=t.g,S=t.b)}let C=212,E=255,T=0;const F=$(M);F&&(C=F.r,E=F.g,T=F.b);const I=.035*f,R=n*d,k=Math.min(6,Math.max(1,h)),L=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<k;i++)o+=A(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<b;e++)for(let o=0;o<w;o++){const n=o*I+.06*R,a=e*I*1.3-.04*R,i=o/w-r.x,c=e/b-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,d=.5*L(n+h*Math.sin(1.3*R+8*c),a+h*Math.cos(.9*R+8*i))+.5;if(d<.12)continue;const f=s[Math.floor(d*(s.length-1))];if(" "===f)continue;const M=d>m,$=g?.82*d:.13*d;t.fillStyle=M?`rgba(${C},${E},${T},${g?.92:.28})`:`rgba(${v},${y},${S},${$})`,t.fillText(f,o*p,e*x)}}function Tt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:d=1,bandWidth:f=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),w=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,v=255,y=255;if(u&&(b=55,v=55,y=55),l){const t=$(l);t&&(b=t.r,v=t.g,y=t.b)}let S=212,C=255,E=0;const A=$(g);A&&(S=A.r,C=A.g,E=A.b);const F=n*d;for(let e=0;e<w;e++)for(let o=0;o<x;o++){const n=e/w,a=((n*h-.5*F)%1+1)%1,i=Math.max(0,1-a/f),c=.35*(.5*T(3*o,7*e)+.5);let l=0;if(m){const t=o/x-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=T(11*o+Math.floor(12*F),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const d=Math.min(1,c+.8*i+.6*l);if(d<.04)continue;const g=s[Math.floor(d*(s.length-1))],$=i>.55,A=u?.82*d:.12*d;t.fillStyle=$?`rgba(${S},${C},${E},${u?.92:.28})`:`rgba(${b},${v},${y},${A})`,t.fillText(g,o*M,e*p)}}function At(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:d=5,softness:f=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),w=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,v=255,y=255;if(u&&(b=55,v=55,y=55),c){const t=$(c);t&&(b=t.r,v=t.g,y=t.b)}let S=212,C=255,E=0;const A=$(g);A&&(S=A.r,C=A.g,E=A.b);const F=n*h,I=[];for(let t=0;t<d;t++){const e=T(17*t,31*t+7),o=T(23*t+5,11*t);I.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*T(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*T(29*t,3*t)})}for(let e=0;e<w;e++){const o=e/w;for(let n=0;n<x;n++){const a=n/x,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,w=o+c*h;let $=0,T=0;for(let t=0;t<d;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=I[t];$+=Math.sin(g*e*Math.PI*2+F*r+n)*Math.cos(w*o*Math.PI*2+F*r*.7+1.3*n)*a,T+=a}const A=$/T,R=.5+.5*Math.tanh(A*f*2.2);if(R<.12)continue;const k=(R-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],P=R>.82,B=u?.82*R:.14*R;t.fillStyle=P?`rgba(${S},${C},${E},${u?.92:.32})`:`rgba(${b},${v},${y},${B})`,t.fillText(L,n*M,e*p)}}}function Ft(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:d=!1}=r,f=s??(d?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,x=255,w=255;if(d&&(p=55,x=55,w=55),i){const t=$(i);t&&(p=t.r,x=t.g,w=t.b)}let b=212,v=255,y=0;const S=$(f);S&&(b=S.r,v=S.g,y=S.b);const C=n*c,E=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let t=0;t<l;t++){const e=T(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*T(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*T(41*t,17*t))*(t%2==0?1:-1.3),d=Math.sin(r*n*Math.PI*2+C*l+c),f=Math.cos(o*s*Math.PI*2+C*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+C*l*.4);a+=Math.atan2(f+.3*m,d),i+=.5*(d*f+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const f=(s+Math.PI)/(2*Math.PI),M=E[Math.floor(f*E.length)%E.length],S=c>.8,$=d?.8*c:.13*c;t.fillStyle=S?`rgba(${b},${v},${y},${d?.9:.26})`:`rgba(${p},${x},${w},${$})`,t.fillText(M,n*m,e*u)}}}function It(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:d=.38,swirl:f=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),x=Math.ceil(o/M),w=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,v=255,y=255;if(m&&(b=55,v=55,y=55),c){const t=$(c);t&&(b=t.r,v=t.g,y=t.b)}let S=212,C=255,E=0;const A=$(u);A&&(S=A.r,C=A.g,E=A.b);const F=n*h;for(let e=0;e<x;e++){const o=e/x;for(let n=0;n<p;n++){const a=(n/p-r.x)*w,i=o-r.y,c=Math.sqrt(a*a+i*i)/d;if(c>1){const o=T(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);t.fillStyle=`rgba(${b},${v},${y},${r})`,t.fillText(s[1],n*g,e*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*F)))/.07),h=Math.pow(1-c,2.2),f=Math.min(1,h+.6*l);if(f<.06)continue;const u=Math.floor(f*(s.length-1)),x=s[Math.min(s.length-1,u)],$=l>.35||c<.08,A=m?.85*f:.18*f;t.fillStyle=$?`rgba(${S},${C},${E},${m?.95:.38})`:`rgba(${b},${v},${y},${A})`,t.fillText(x,n*g,e*M)}}}function Rt(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:d=!1}=r,f=c??(d?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,x=255,w=255;if(d&&(p=55,x=55,w=55),s){const t=$(s);t&&(p=t.r,x=t.g,w=t.b)}let b=212,v=255,y=0;const S=$(f);S&&(b=S.r,v=S.g,y=S.b);const C=n*l,E=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<g;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*T(o*(t+3)+7,e*(t+5)+11),a=T(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin(C*r+a)*i}const r=.5*(n/E+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=d?.82*a:.13*a;t.fillStyle=c?`rgba(${b},${v},${y},${d?.92:.28})`:`rgba(${p},${x},${w},${l})`,t.fillText(s,o*m,e*u)}}function kt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:d=1,lightMode:f=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u),p=g*M,x="__fire_heat__",w=t.canvas;let b=w[x];b&&b.length===p||(b=new Float32Array(p),w[x]=b);const v=.18*(.016*d),y=h*d*.8,S=M-1,C=n*d;for(let t=0;t<g;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*l;b[S*g+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(b[(S-1)*g+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const o=.4*b[(t+1)*g+e]+.25*b[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*b[(t+1)*g+Math.max(0,e-1)]+.175*b[(t+1)*g+Math.min(g-1,e+1)];E[t*g+e]=Math.max(0,o-v-.02*Math.random()*d)}for(let t=0;t<g;t++)E[(M-1)*g+t]=b[(M-1)*g+t],M>1&&(E[(M-2)*g+t]=b[(M-2)*g+t]);w[x]=E;const T=$(s)??{r:255,g:69,b:0},A=$(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<g;o++){const n=E[e*g+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),s=T.r+(A.r-T.r)*a|0,c=T.g+(A.g-T.g)*a|0,l=T.b+(A.b-T.b)*a|0,h=f?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,o*m,e*u)}t.globalAlpha=1}function Lt(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:d=1,helixCount:f,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g),x=f??Math.max(1,Math.floor(e/80)),w=M/x,b=$(c)??{r:0,g:229,b:255},v=$(l)??{r:255,g:64,b:129},y=$(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const S=n*d,C=.35*w;for(let e=0;e<x;e++){const o=w*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*S,a=o+Math.sin(r)*C,c=o+Math.sin(r+Math.PI)*C,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const d=T(31*e+7*n,3),f=i[Math.floor(d*i.length)],m=.5*(Math.sin(r)+1),x=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*m,t.fillStyle=`rgb(${b.r},${b.g},${b.b})`,t.fillText(f,l*u,n*g),h>=0&&h<M){const o=T(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*x,t.fillStyle=`rgb(${v.r},${v.g},${v.b})`,t.fillText(r,h*u,n*g)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=T(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(m+x)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*g)}}}}t.globalAlpha=1}function Pt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:d=.55,heightScale:f=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),x=Math.ceil(o/M),w=$(s)??{r:76,g:175,b:80},b=$(c)??{r:26,g:35,b:126},v=$(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const y=n*h*.4,S=new Array(p);for(let t=0;t<p;t++){const e=(.5*F((t/p+y)*d*3,.5)+.5)*f;S[t]=Math.floor(e*x)}for(let e=0;e<x;e++)for(let o=0;o<p;o++){const r=x-1-S[o],a=e===r;if(!(e>=r)){if(m){const r=T(7*o+Math.floor(.3*y),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${b.r+60},${b.g+60},${b.b+80})`,t.fillText("·",o*g,e*M)}}continue}const s=(e-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=w.r+(v.r-w.r)*l|0,d=w.g+(v.g-w.g)*l|0,f=w.b+(v.b-w.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${d},${f})`,t.fillText(a?i[i.length-1]:c,o*g,e*M)}t.globalAlpha=1}var Bt=1,zt=2,qt=4,Ht=8,jt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[Bt]:"╶",[zt]:"╴",[qt]:"╵",[Ht]:"╷"};function Wt(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,d=.62*a,f=1.4*a,m=Math.ceil(e/d),u=Math.ceil(o/f),g=$(s)??{r:0,g:255,b:136},M=$(i)??{r:255,g:255,b:255},p=(t,e)=>{if(T(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<m&&T(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&T(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&T(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&T(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const x=n*l;for(let e=0;e<u;e++)for(let o=0;o<m;o++){const n=p(o,e);if(0===n)continue;const r=jt[n]??"·",a=(8*x+40*T(o,23*e))%m,i=(6*x+40*T(17*e,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(e-i)<1.5,l=s||c,h=.25+.35*T(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${g.r},${g.g},${g.b})`),t.fillText(r,o*d,e*f)}t.globalAlpha=1}function Dt(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const d=document.createElement("canvas");d.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(d.className=r),l.prepend(d);const f=d.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let t=l;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if(t)return(.299*+t[1]+.587*+t[2]+.114*+t[3])/255>=.4}t=t.parentElement}const e=document.documentElement,o=(e.getAttribute("data-theme")||"").toLowerCase();return"dark"!==o&&("light"===o||!e.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches)})(),p=s?function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(s):null,x=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),w={current:x()},b=()=>{w.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:x()};b();const v=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{b()};let S=null;"auto"===i&&(v.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const t=l.getBoundingClientRect();d.width=t.width*m,d.height=t.height*m,f.setTransform(m,0,0,m,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let T=0,A=0;const F=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const t=l.getBoundingClientRect();"rain"===o?St(f,t.width,t.height,T,w.current):"stars"===o?$t(f,t.width,t.height,T,g,w.current):"pulse"===o?Ct(f,t.width,t.height,T,g,w.current):"noise"===o?Et(f,t.width,t.height,T,g,w.current):"grid"===o?Tt(f,t.width,t.height,T,g,w.current):"aurora"===o?At(f,t.width,t.height,T,g,w.current):"silk"===o?Ft(f,t.width,t.height,T,w.current):"void"===o?It(f,t.width,t.height,T,g,w.current):"morph"===o?Rt(f,t.width,t.height,T,w.current):"fire"===o?kt(f,t.width,t.height,T,w.current):"dna"===o?Lt(f,t.width,t.height,T,w.current):"terrain"===o?Pt(f,t.width,t.height,T,w.current):"circuit"===o?Wt(f,t.width,t.height,T,w.current):I(f,t.width,t.height,T,g,w.current),T+=.016,A=requestAnimationFrame(F)};return A=requestAnimationFrame(F),{destroy:()=>{cancelAnimationFrame(A),E.disconnect(),"auto"===i&&(v.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",C),d.remove(),l.style.position=h}}}var Ot=Dt;function Nt(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=$(n)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function Ut(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}var Vt={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]},Kt=[127,65,65,65,65,65,127];function _t(t){return Vt[t]??Vt[t.toUpperCase()]??Kt}function Yt(t,e={}){if(!t)return"";const{char:o="█",scale:n=1}=e,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const o=_t(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,exports.BACKGROUND_TYPES=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"],exports.CHARSETS=e,exports.CHARSET_SEQUENCES=o,exports.DEFAULT_OPTIONS=a,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:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.LIVING_STYLE_PRESETS=r,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.asciiBackground=Dt,exports.asciiText=function(t,e={},o,n){const r={...a,...e},{frame:i,cols:s}=J(t,r,o,n);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,e={},o,n){const r={...a,...e},{frame:i,cols:s}=J(t,r,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}[0m`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,e,{fontSize:o,artStyle:r="classic",options:i={}}={}){let s;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),s=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),s=t):s=t;const c=n[r],l=o??i.fontSize??10,h={...a,...c,...i,fontSize:l},d=e.getContext("2d");if(!d)throw new Error("Could not get 2d context from canvas");const{w:f,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(s),{renderW:u,renderH:g}=wt(f,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,x=u*M*g*M>p?Math.sqrt(p/(u*g)):M;if((e.width<u||e.height<g)&&(e.width=Math.round(u*x),e.height=Math.round(g*x)),h.hoverStrength>0){const{frame:t}=J(s,h,u,g);let o=null,n=!1,r=0;const a=t=>{const n=e.getBoundingClientRect();o={x:(t.clientX-n.left)/n.width,y:(t.clientY-n.top)/n.height}},i=()=>{o=null};e.addEventListener("mousemove",a),e.addEventListener("mouseleave",i);const c=e=>{n||(d.save(),d.setTransform(x,0,0,x,0,0),rt(d,t,h,u,g,e/1e3,o),d.restore(),r=requestAnimationFrame(c))};return r=requestAnimationFrame(c),()=>{n=!0,cancelAnimationFrame(r),e.removeEventListener("mousemove",a),e.removeEventListener("mouseleave",i)}}if(d.save(),d.setTransform(x,0,0,x,0,0),st(h)){const t=Q(s,h,u,g);Z(d,t,h,u,g)}else{const{frame:t}=J(s,h,u,g);rt(d,t,h,u,g)}d.restore()},exports.asciifyGif=async function(t,e,{fontSize:o,artStyle:r="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??i.fontSize??10;let l={...a,...n[r],...i,fontSize:c};const h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");if(st(l)){const{frames:t,fps:o}=await nt(s,l,e.width,e.height);let n,r=!1,a=0,i=performance.now();const c=1e3/o,d=o=>{r||(o-i>=c&&(Z(h,t[a],l,e.width,e.height),a=(a+1)%t.length,i=o),n=requestAnimationFrame(d))};return n=requestAnimationFrame(d),()=>{r=!0,cancelAnimationFrame(n)}}const{frames:d,fps:f}=await ot(s,l,e.width,e.height);let m,u=!1,g=0,M=performance.now();const p=1e3/f,x=t=>{u||(t-M>=p&&(rt(h,d[g],l,e.width,e.height),g=(g+1)%d.length,M=t),m=requestAnimationFrame(x))};return m=requestAnimationFrame(x),()=>{u=!0,cancelAnimationFrame(m)}},exports.asciifyLiveVideo=function(t,e,o){return yt(t,e,o)},exports.asciifyText=Yt,exports.asciifyVideo=yt,exports.asciifyWebcam=async function(t,{fontSize:e=10,style:o="classic",options:r={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),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={...a,...n[o],...r,fontSize:e},m=t.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();g={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},x=()=>{g=null};f.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",x));let w,b=!1;const v=performance.now(),y=e=>{if(!b){if(d.readyState>=d.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,r=(e-v)/1e3,a=i?{...f,...i()}:f;a.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",x)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",x));const{frame:c}=J(d,a,o,n);if(g){const t=g.x-M.x,e=g.y-M.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);M.x+=t*n,M.y+=e*n,M.intensity+=.12*(1-M.intensity)}else M.intensity*=.965,M.intensity<.003&&(M.intensity=0);const l=M.intensity>.003?{x:M.x,y:M.y,intensity:M.intensity}:null;s?(m.save(),m.scale(-1,1),m.translate(-o,0),rt(m,c,a,o,n,r,l),m.restore()):rt(m,c,a,o,n,r,l)}w=requestAnimationFrame(y)}};return w=requestAnimationFrame(y),()=>{b=!0,cancelAnimationFrame(w),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",x),h.getTracks().forEach(t=>t.stop()),d.srcObject=null}},exports.buildTextFrame=Nt,exports.captureSnapshot=Ut,exports.clearAsciifyCaches=function(){z.clear(),q.clear(),H.clear(),L=null,P=null},exports.createVideoScrollScrub=ft,exports.gifToAsciiFrames=ot,exports.gifToAsciiTextFrames=nt,exports.imageToAsciiFrame=J,exports.imageToAsciiTextFrame=Q,exports.mountWaveBackground=Ot,exports.renderAuroraBackground=At,exports.renderCircuitBackground=Wt,exports.renderDnaBackground=Lt,exports.renderFireBackground=kt,exports.renderFrameToCanvas=rt,exports.renderGridBackground=Tt,exports.renderMorphBackground=Rt,exports.renderNoiseBackground=Et,exports.renderPulseBackground=Ct,exports.renderRainBackground=St,exports.renderSilkBackground=Ft,exports.renderStarsBackground=$t,exports.renderTerrainBackground=Pt,exports.renderTextBackground=function(t,e,o,n,r={},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"}=r;rt(t,Nt(n,Math.max(1,Math.floor(e/s)),Math.max(1,Math.floor(o/(s*c))),l,h),{...a,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},e,o,0,i??null)},exports.renderTextFrameToCanvas=Z,exports.renderTextToCanvas=function(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=Yt(e,o);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=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))},exports.renderVoidBackground=It,exports.renderWaveBackground=I,exports.snapshotAndDownload=async function(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await Ut(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=tt,exports.videoToAsciiTextFrames=et;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";var t=require("gifuct-js"),e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵",ascii:" .'`^\",:;~-_+<>i!lI?/\\|()[]{}1tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",interface:" ·•-–—+=:;<>[]{}()⌘⌥⇧⌃↵↗↘◇◆◈□■",prompt:" .:;>_`/\\|{}[]()=+*#@$",data:" ·∙•◦○●◇◆◈▱▰▣█",humanist:" ·˙,:;∴∵∷∶⁚⋮⋯∼≈≋∞",mesh:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},o={cosmic:[e.starfield,e.circles,e.shadows],rain:[e.katakana,e.braille,e.binary],terminal:[e.pipes,e.claudeCode,e.standard],crystal:[e.shards,e.geometric,e.blocks],fluid:[e.waves,e.smoke,e.circles],pulse:[e.dense,e.standard,e.blocks],dream:[e.braille,e.shadows,e.smoke],angular:[e.geometric,e.shards,e.starfield],assistant:[e.interface,e.prompt,e.data],signal:[e.mesh,e.data,e.ascii],editorial:[e.humanist,e.waves,e.smoke]},n={classic:{renderMode:"ascii",charset:e.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:e.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:e.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:e.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:e.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:e.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:e.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:e.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:e.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:e.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:e.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:e.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:e.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:e.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:e.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:e.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:e.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:e.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},r={agentField:{...n.interface,charsetFrames:o.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:o.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:o.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:o.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:o.terminal,charsetFps:3,animationStyle:"rain",animationSpeed:1.1,ditherStrength:.22,hoverEffect:"glitchText",hoverStrength:.65,hoverRadius:.16,hoverColor:"#d4ff00",hoverText:["BUILD","SHIP","RUN","ASK","MODEL"],normalize:!0}},a={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"};function i(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}function s(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function c(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function l(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var h=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function d(t,e,o,n){if(n<=0)return t;const r=(h[o%4][e%4]/16-.5)*n*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,o,n,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(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return f[e]}}}var g=[0,0,0];function M(t,e,o,n,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]=o,g[1]=n,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 p(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 x(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=p(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function w(t){if(t){const e=x(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=x(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 b(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}function v(t,e,o,n,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/n*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),d=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/d*Math.PI*8-3*s)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const o=Math.floor(4*s),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var y={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function S(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const d=t-o,f=e-n,m=.08+.35*l+.04*a;let u,g;if("box"===h){const t=Math.abs(d),e=Math.abs(f);u=Math.max(t,e),g=m}else u=Math.sqrt(d*d+f*f),g=m;if(u>=g)return y.scale=1,y.offsetX=0,y.offsetY=0,y.glow=0,y.colorBlend=0,y.proximity=0,y;const M=function(t){return t*t*(3-2*t)}(1-u/g)*r;let p=1,x=0,w=0,b=0,v=0;switch(c){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(f,d),e=M*M*a*.6;x=Math.cos(t)*e*i,w=Math.sin(t)*e*s,b=M*a*.4,v=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,b=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(f,d),e=M*M*a*1.2;x=Math.cos(t)*e*i,w=Math.sin(t)*e*s;break}case"glow":b=M*a*.8,v=M*a*.4;break;case"colorShift":p=1+M*a*.4,b=M*a*.2,v=M*a*.7;break;case"attract":{const t=Math.atan2(f,d),e=M*M*a*1;x=-Math.cos(t)*e*i,w=-Math.sin(t)*e*s,b=M*a*.3;break}case"shatter":{const t=Math.atan2(f,d),e=.5*Math.sin(43.7*d+29.3*f),o=M*a*1.4*(.7+.3*e);x=Math.cos(t+e)*o*i,w=Math.sin(t+e)*o*s,p=Math.max(.1,1-M*a*.6),b=M*a*.25;break}case"trail":v=M*a*.9,b=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,b=M*a*.5,v=M*a*.6}return y.scale=p,y.offsetX=x,y.offsetY=w,y.glow=b,y.colorBlend=v,y.proximity=M,y}function $(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function C(t){return t*t*t*(t*(6*t-15)+10)}function E(t,e,o){return t+(e-t)*o}function T(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function A(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=C(t-o),i=C(r),s=T(o,n),c=T(o+1,n),l=T(o,n+1),h=T(o+1,n+1);return E(E(s,c,a),E(l,h,a),i)}function F(t,e){return(.5*A(t,e)+.25*A(2.1*t,2.1*e)+.125*A(4.3*t,4.3*e))/.875}function I(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:d,accentThreshold:f=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:x=!0,lightMode:w=!1}=a,b=d??(w?"#6b8700":"#d4ff00"),v=i*s,y=i*c,S=Math.ceil(e/v),$=Math.ceil(o/y),C=r.x,E=r.y;let A=212,I=255,R=0;{const t=b.replace("#","");6===t.length&&(A=parseInt(t.slice(0,2),16),I=parseInt(t.slice(2,4),16),R=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const k=n*g,L=x?.12*(.5*Math.sin(.22*k)+.5):0;for(let e=0;e<$;e++)for(let o=0;o<S;o++){const n=o/S,r=e/$,a=.045,i=.08*k,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*k)+.5+(.5*Math.sin(.03*o-.07*e+.4*k)+.5)+(.5*Math.sin(.05*o+.03*e+.8*k)+.5))/3)+.35*(.5*F(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*k)+.5)+L,d=n-C,g=r-E,x=Math.sqrt(d*d+g*g);let b=0;if(M&&x<.35){const t=Math.atan2(g,d),e=Math.sin(4*t+2.2*k-14*x),o=Math.max(0,1-x/.35);b=e*o*o*.22}const P=c*(1-m)+(Math.max(0,1-x*u)+.5*b)*m+.15*b,B=Math.min(1,Math.max(0,P));let z=B;if(p&&B>.72){const t=Math.floor(8*k),n=T(7*o+3*t,11*e+t);n>.88&&(z=Math.min(1,B+4*(n-.88)))}const q=Math.floor(z*(l.length-1));if(" "===l[q])continue;const H=.015+.07*z;if(z>f){const e=Math.min(w?.9:.28,H*(w?14:2.8));t.fillStyle=`rgba(${A},${I},${R},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):w?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[q],o*v,e*y)}}var R=new WeakMap,k=new WeakMap,L=null,P=null;function B(t,e){if(!L||!P){const o=i(t,e);L=o.canvas,P=o.ctx}return L.width!==t&&(L.width=t),L.height!==e&&(L.height=e),P}var z=new Map,q=new Map,H=new Map,W=new WeakMap,j=new WeakMap,D=new WeakMap;function O(t){let e=z.get(t);return e||(e=[...t],z.set(t,e)),e}function N(t,e,o){const n=o?1-t/255:t/255,r=Math.floor(n*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function U(t,e,o,n){const r=`${t}\0${e?1:0}\0${o}\0${n}`;let a=q.get(r);if(!a){const i=O(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=N(s(t,o,n),i,e);q.set(r,a)}return a}function V(t){let e=H.get(t);if(!e){const o=O(t),n=Math.max(1,o.length);e=new Map;for(let t=0;t<o.length;t++)e.has(o[t])||e.set(o[t],Math.max(.08,(t+.5)/n));H.set(t,e)}return e}function K(t,e){return"auto"!==t?t:!w(e)}function _(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function Y(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=_(t.getPropertyValue(e).trim());if(o)return o}const e=_(getComputedStyle(document.body).accentColor??"");if(e)return e}return w("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function G(t,e,o){return Math.max(e,Math.min(o,t))}function X(t,e,o){if(!t)return{x:0,y:0,width:e,height:o};const n=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===n?t*e:t,i=t=>void 0===t?void 0:"percent"===n?t*o:t,s=G(a(t.left)??0,0,e-1),c=G(a(t.right)??0,0,e-s-1),l=G(i(t.top)??0,0,o-1),h=G(i(t.bottom)??0,0,o-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,o-l-h),u=d?f:a(t.width),g=d?m:i(t.height);let M=u??e,p=g??o;if(r&&!d){const t=M/e,n=p/o,r=Math.min(t,n),a=void 0===u?n:void 0===g?t:r;M=e*a,p=o*a}M=G(M,1,d?f:e),p=G(p,1,d?m:o);const x=t.anchor??"center",w=a(t.x),b=i(t.y),v=d?s:0,y=d?l:0,S=d?f:e,$=d?m:o,C=x.endsWith("left")||"left"===x?0:x.endsWith("right")||"right"===x?S-M:(S-M)/2,E=x.startsWith("top")||"top"===x?0:x.startsWith("bottom")||"bottom"===x?$-p:($-p)/2;return{x:G(w??v+C,0,Math.max(0,e-M)),y:G(b??y+E,0,Math.max(0,o-p)),width:M,height:p}}function J(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,c=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,f=o||r,m=n||a,u=Math.floor(f/c),g=Math.floor(m/h);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=X(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(M.width/u))),x=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),w=u*p,v=g*x,y=B(w,v);y.drawImage(t,M.x,M.y,M.width,M.height,0,0,w,v);const S=y.getImageData(0,0,w,v).data,$=e.chromaKey,C=null!=$&&!1!==$,E=!0===$,T="blue-screen"===$;let A=null,F=0;!C||E||T||(A=b($),F=(e.chromaKeyTolerance??60)**2);let I=0,R=255;if(e.normalize){let t=255,e=0;for(let o=0;o<S.length;o+=4){if(C){const t=S[o],e=S[o+1],n=S[o+2];let r=!1;if(E)r=e>1.4*t&&e>1.4*n&&e>80;else if(T)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==A){const o=t-A.r,a=e-A.g,i=n-A.b;r=o*o+a*a+i*i<=F}if(r)continue}const n=.299*S[o]+.587*S[o+1]+.114*S[o+2];n<t&&(t=n),n>e&&(e=n)}I=t,R=e>t?e-t:255}const k=[],L=K(e.invert),P=C&&e.charset.replace(/ /g,"")||e.charset,z=O(P),q=e.customText?null:U(P,L,e.brightness,e.contrast),H=p*x;for(let t=0;t<g;t++){const o=[];for(let n=0;n<u;n++){let r=0,a=0,i=0,c=0,h=0;for(let e=0;e<x;e++){const o=(t*x+e)*w;for(let t=0;t<p;t++){const e=4*(o+n*p+t),s=S[e],l=S[e+1],d=S[e+2],f=S[e+3];if(C){let t=!1;if(E)t=l>1.4*s&&l>1.4*d&&l>80;else if(T)t=d>1.4*s&&d>1.4*l&&d>80;else if(null!==A){const e=s-A.r,o=l-A.g,n=d-A.b;t=e*e+o*o+n*n<=F}if(t){h++;continue}}r+=s,a+=l,i+=d,c+=f}}if(C&&h>H/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const f=H-h,m=f>0?r/f:0,g=f>0?a/f:0,M=f>0?i/f:0,b=f>0?c/f:0,v=.299*m+.587*g+.114*M,y=e.normalize?(v-I)/R*255:v,$=s(y,e.brightness,e.contrast),k=e.ditherStrength>0?d($,n,t,e.ditherStrength):$,P=e.customText?l(k,e.customText,n,t,u,L):e.ditherStrength>0?N(k,z,L):q[Math.max(0,Math.min(255,0|y))];o.push({char:P,r:m,g:g,b:M,a:b,lum:k})}k.push(o)}return{frame:k,cols:u,rows:g}}function Q(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,c=e.fontSize*e.charSpacing,l=e.fontSize/i*e.charSpacing,h=o||r,f=n||a,m=Math.floor(h/c),u=Math.floor(f/l);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=B(g,M),x=X(e.sourceCrop,r,a);p.drawImage(t,x.x,x.y,x.width,x.height,0,0,g,M);const w=p.getImageData(0,0,g,M).data,v=e.chromaKey,y=null!=v&&!1!==v,S=!0===v,$="blue-screen"===v;let C=null,E=0;!y||S||$||(C=b(v),E=(e.chromaKeyTolerance??60)**2);let T=0,A=255;if(e.normalize){let t=255,e=0;for(let o=0;o<w.length;o+=4){if(y){const t=w[o],e=w[o+1],n=w[o+2];let r=!1;if(S)r=e>1.4*t&&e>1.4*n&&e>80;else if($)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==C){const o=t-C.r,a=e-C.g,i=n-C.b;r=o*o+a*a+i*i<=E}if(r)continue}const n=.299*w[o]+.587*w[o+1]+.114*w[o+2];n<t&&(t=n),n>e&&(e=n)}T=t,A=e>t?e-t:255}const F=K(e.invert),I=y&&e.charset.replace(/ /g,"")||e.charset,R=O(I),k=e.customText?null:U(I,F,e.brightness,e.contrast),L=e.customText?O(e.customText):null,P="fullcolor"===e.colorMode?new Uint8ClampedArray(m*u*4):void 0,z=[];for(let t=0;t<u;t++){let o="";for(let n=0;n<m;n++){const r=4*(t*g+n),a=r,i=w[r],c=w[r+1],l=w[r+2],h=w[r+3];if(y){let t=!1;if(S)t=c>1.4*i&&c>1.4*l&&c>80;else if($)t=l>1.4*i&&l>1.4*c&&l>80;else if(null!==C){const e=i-C.r,o=c-C.g,n=l-C.b;t=e*e+o*o+n*n<=E}if(t){o+=" ",P&&(P[a]=0,P[a+1]=0,P[a+2]=0,P[a+3]=0);continue}}P&&(P[a]=i,P[a+1]=c,P[a+2]=l,P[a+3]=h);const f=.299*i+.587*c+.114*l,u=e.normalize?(f-T)/A*255:f,M=e.ditherStrength>0||L?s(u,e.brightness,e.contrast):u,p=e.ditherStrength>0?d(M,n,t,e.ditherStrength):M;if(L){o+=(F?1-p/255:p/255)<.12?" ":L[(t*m+n)%L.length]}else e.ditherStrength<=0?o+=k[Math.max(0,Math.min(255,0|u))]:o+=N(p,R,F)}z.push(o)}return{rows:z,cols:m,rowCount:u,colors:P}}function Z(t,e,o,n,r){if(0===e.rows.length)return;const a=t.canvas,s=Boolean(o.chromaKey)||e.rows.some(t=>t.includes(" "));s||(D.delete(t),t.clearRect(0,0,n,r),t.fillStyle=w(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const c=Y(o.accentColor),l=parseInt(c.substring(0,2),16)||255,h=parseInt(c.substring(2,4),16)||255,d=parseInt(c.substring(4,6),16)||255,f=n/e.cols,m=r/e.rowCount,u=.9*Math.min(f/.55,m),g=e.colors;if("fullcolor"===o.colorMode&&g){if(D.delete(t),t.clearRect(0,0,n,r),u<6){const{canvas:a,ctx:s}=function(t,e,o){let n=W.get(t);n||(n=i(e,o).canvas,W.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderTextFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,e.cols,e.rowCount);let c=j.get(s);c&&c.width===e.cols&&c.height===e.rowCount||(c={width:e.cols,height:e.rowCount,imageData:s.createImageData(e.cols,e.rowCount)},j.set(s,c));const l=c.imageData,h=l.data;h.fill(0);const d=V(o.charset);for(let t=0;t<e.rowCount;t++){const o=e.rows[t];for(let n=0;n<e.cols;n++){const r=o[n];if(" "===r)continue;const a=4*(t*e.cols+n),i=g[a+3];if(i<10)continue;const s=d.get(r)??.5;h[a]=g[a],h[a+1]=g[a+1],h[a+2]=g[a+2],h[a+3]=0|Math.min(255,i*s)}}return s.putImageData(l,0,0),t.imageSmoothingEnabled=!1,t.drawImage(a,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let a="";for(let o=0;o<e.rows.length;o++){const n=e.rows[o];let r=0;for(;r<e.cols;){for(;r<e.cols&&" "===n[r];)r++;if(r>=e.cols)break;const i=r,s=4*(o*e.cols+r),c=240&g[s],l=240&g[s+1],h=240&g[s+2];for(r++;r<e.cols&&" "!==n[r];){const t=4*(o*e.cols+r);if((240&g[t])!==c||(240&g[t+1])!==l||(240&g[t+2])!==h)break;r++}const d=`rgb(${c},${l},${h})`;d!==a&&(t.fillStyle=d,a=d),t.fillText(n.slice(i,r),i*f+.5*f,o*m+.5*m)}}return void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const M="matrix"===o.colorMode?"rgb(0,255,0)":"grayscale"===o.colorMode?w(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${l},${h},${d})`;t.fillStyle=M,t.globalAlpha=1;const p=D.get(t),x=s&&p&&p.cols===e.cols&&p.rowCount===e.rowCount&&p.canvasWidth===n&&p.canvasHeight===r&&p.fillStyle===M;x||t.clearRect(0,0,n,r);for(let o=0;o<e.rows.length;o++){const r=e.rows[o];x&&p.rows[o]===r||(x&&t.clearRect(0,o*m,n,m+1),0!==r.trim().length&&t.fillText(r,.5*f,o*m+.5*m))}D.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:n,canvasHeight:r,fillStyle:M}),t.globalAlpha=1}async function tt(t,e,o,n,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 o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=J(t,e,o,n);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 et(t,e,o,n,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 o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=Q(t,e,o,n);h.push(u),d=u.cols,f=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function ot(e,o,n,r,a){const i=t.parseGIF(e),s=t.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,d=i.lsd?.height||l,f=document.createElement("canvas");f.width=h,f.height=d;const m=f.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=d;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),x=[];let w=0,b=0,v=0;for(const t of s)v+=t.delay||100;const y=v/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let t=0;t<$;t++){const e=s[t],{dims:i,patch:c,disposalType:l}=e;3===l&&(g.clearRect(0,0,h,d),g.drawImage(f,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const v=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(v,0,0),m.drawImage(M,i.left||0,i.top||0);const y=J(f,o,n,r);x.push(y.frame),w=y.cols,b=y.rows,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,d),m.drawImage(u,0,0)),a?.((t+1)/$)}return{frames:x,cols:w,rows:b,fps:S}}async function nt(e,o,n,r,a){const i=t.parseGIF(e),s=t.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,d=i.lsd?.height||l,f=document.createElement("canvas");f.width=h,f.height=d;const m=f.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=d;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),x=[];let w=0,b=0,v=0;for(const t of s)v+=t.delay||100;const y=v/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let t=0;t<$;t++){const e=s[t],{dims:i,patch:c,disposalType:l}=e;3===l&&(g.clearRect(0,0,h,d),g.drawImage(f,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const v=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(v,0,0),m.drawImage(M,i.left||0,i.top||0);const y=Q(f,o,n,r);x.push(y),w=y.cols,b=y.rowCount,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,d),m.drawImage(u,0,0)),a?.((t+1)/$)}return{frames:x,cols:w,rows:b,fps:S}}function rt(t,e,o,n,r,a=0,s){if("waveField"===o.animationStyle){return void I(t,n,r,a,s?{x:s.x,y:s.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?Y(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const l=e.length;if(0===l)return;const h=e[0].length;t.clearRect(0,0,n,r);let d=!1;const f=Math.max(1,l>>2),m=Math.max(1,h>>2);t:for(let t=0;t<l;t+=f){const o=e[t];for(let t=0;t<h;t+=m)if(o[t].a<200){d=!0;break t}}const g=t.canvas,p=w(g);d||(t.fillStyle=p?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const x=n/h,b=r/l,y=l*h,$=s?.intensity??1,C=!("none"!==o.animationStyle&&y>5e3)&&!!(s&&o.hoverStrength>0&&$>.005),E=o.hoverColor||"#ffffff",T=parseInt(E.slice(1,3),16)||255,A=parseInt(E.slice(3,5),16)||255,F=parseInt(E.slice(5,7),16)||255,L=Y(o.accentColor),P=parseInt(L.substring(0,2),16)||255,B=parseInt(L.substring(2,4),16)||255,z=parseInt(L.substring(4,6),16)||255,q=y>3e4?.25:y>15e3?.4:y>5e3?.6:1,H=o.hoverRadius*q;let W=0,j=h,D=0,O=l,N=0,U=0;if(C&&s){N=s.x,U=s.y;const t=.08+.35*H+.04*o.hoverStrength;W=Math.max(0,Math.floor((N-t)*h)-1),j=Math.min(h,Math.ceil((N+t)*h)+1),D=Math.max(0,Math.floor((U-t)*l)-1),O=Math.min(l,Math.ceil((U+t)*l)+1)}const _=o.animationStyle,G=o.animationSpeed,X="none"===_,J=o.hoverStrength,Q=o.hoverEffect,Z=H,tt=o.hoverShape||"circle",et=K(o.invert,g),ot=o.colorMode,nt=2*Math.PI,rt=1/h,at=1/l;let it="",st=-1;if("dots"===o.renderMode){const n=.5*Math.min(x,b)*o.dotSizeRatio;for(let o=0;o<l;o++){const r=e[o];for(let e=0;e<h;e++){const i=r[e];if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),c=et?1-s:s;if(c<.02)continue;const d=X?1:v(e,o,h,l,a,_,G);let f=1,m=0,g=0,p=0,w=0;if(C&&e>=W&&e<=j&&o>=D&&o<=O){const t=S(e*rt,o*at,N,U,$,J,x,b,Q,Z,tt);f=t.scale,m=t.offsetX,g=t.offsetY,p=t.glow,w=t.colorBlend}const y=n*c*d*f;if(y<.3)continue;const E=e*x+.5*x+m,I=o*b+.5*b+g;let R;if(w>0){const t=M(i,ot,P,B,z,et);R=`rgb(${Math.min(255,t[0]+(T-t[0])*w|0)},${Math.min(255,t[1]+(A-t[1])*w|0)},${Math.min(255,t[2]+(F-t[2])*w|0)})`}else R=u(i,ot,P,B,z,et);const k=Math.min(1,.00392156863*i.a*d*(1+p));if(k!==st&&(t.globalAlpha=k,st=k),R!==it&&(t.fillStyle=R,it=R),y<=3){const e=2*y;t.fillRect(E-y,I-y,e,e)}else t.beginPath(),t.arc(E,I,y,0,nt),t.fill()}}}else{const s=.55,d=.9*Math.min(x/s,b),f=d<6;if(!f){const e="emoji"===o.artStyle;t.font=e?`${d}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${d}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const m=o.charsetFrames,g=!!m?.length,p=g?m[Math.floor(Math.max(0,a)*(o.charsetFps??2))%m.length]:o.charset;if(f){const{canvas:o,ctx:a}=function(t,e,o){let n=R.get(t);n||(n=i(e,o).canvas,R.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,h,l);let s=k.get(a);s&&s.width===h&&s.height===l||(s={width:h,height:l,imageData:a.createImageData(h,l)},k.set(a,s));const d=s.imageData,f=d.data;f.fill(0);const m=V(p);for(let t=0;t<l;t++){const o=e[t];for(let e=0;e<h;e++){const n=o[e],r=4*(t*h+e);if(n.a<10)continue;const a=g&&null!=n.lum?c(n.lum,p,et):n.char;if(" "===a)continue;let i,s,l,d=m.get(a)??.5,u=0,w=0;if(C&&e>=W&&e<=j&&t>=D&&t<=O){const o=S(e*rt,t*at,N,U,$,J,x,b,Q,Z,tt);d*=o.scale,u=o.glow,w=o.colorBlend}if(w>0){const t=M(n,ot,P,B,z,et);i=Math.min(255,t[0]+(T-t[0])*w|0),s=Math.min(255,t[1]+(A-t[1])*w|0),l=Math.min(255,t[2]+(F-t[2])*w|0)}else{const t=M(n,ot,P,B,z,et);i=t[0],s=t[1],l=t[2]}const v=Math.min(255,Math.max(0,n.a*d*(1+u)));f[r]=i,f[r+1]=s,f[r+2]=l,f[r+3]=v}}return a.putImageData(d,0,0),t.imageSmoothingEnabled=!1,t.drawImage(o,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}const w=f?null:t.getTransform();if(!f&&!C&&X&&!g&&"accent"===ot){t.fillStyle=`rgb(${P},${B},${z})`,t.globalAlpha=1,t.textAlign="left";for(let o=0;o<l;o++){const n=e[o];let r="";for(let t=0;t<h;t++){const e=n[t];r+=e.a<10?" ":e.char}0!==r.trim().length&&t.fillText(r,.5*x,o*b+.5*b)}return void(t.globalAlpha=1)}const y="glitchText"===Q&&C,E="!@#$%^&*<>{}[]|/\\~`0123456789",I=E.length;let L="",q=0,K=0,Y=0,nt=0,ct=0,lt=0;if(y){const t=o.hoverText??"ASCIIFY";if(K=Math.round(N*h),Y=Math.round(U*l),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");L=e[((7*Math.floor(K/Math.max(1,Math.ceil(h/5)))+13*Math.floor(Y/Math.max(1,Math.ceil(l/3))))%e.length+e.length)%e.length]}else L=t||"ASCIIFY";q=L.length,nt=Math.max(3,Math.min(12,Math.round(l*H*.6)));const e=Math.floor(nt/2);ct=Math.max(0,Y-e),ct+nt>l&&(ct=Math.max(0,l-nt)),lt=K-Math.floor(q/2)}for(let o=0;o<l;o++){const n=e[o];for(let e=0;e<h;e++){const r=n[e];if(r.a<10)continue;let i=g&&null!=r.lum?c(r.lum,p,et):r.char;if(" "===i)continue;const s=X?1:v(e,o,h,l,a,_,G);if(s<.05)continue;let d=1,f=0,m=0,R=0,k=0;if(C&&!y&&e>=W&&e<=j&&o>=D&&o<=O){const t=S(e*rt,o*at,N,U,$,J,x,b,Q,Z,tt);d=t.scale,f=t.offsetX,m=t.offsetY,R=t.glow,k=t.colorBlend}if(y&&o>=ct&&o<ct+nt){const t=e-lt;if(t>=0&&t<q){const n=L[t],r=Math.abs(o-Y)/Math.max(1,.5*nt),s=Math.abs(e-K)/Math.max(1,q),c=Math.max(r,s),l=Math.max(0,Math.min(1,1-.9*c)),h=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));i=Math.abs(h-Math.floor(h))<l?n:E[Math.abs(Math.floor(97*h))%I],R=.3+.7*l,k=.3+.65*l}}const H=e*x+.5*x+f,V=o*b+.5*b+m;let ht;if(k>0){const t=M(r,ot,P,B,z,et);ht=`rgb(${Math.min(255,t[0]+(T-t[0])*k|0)},${Math.min(255,t[1]+(A-t[1])*k|0)},${Math.min(255,t[2]+(F-t[2])*k|0)})`}else ht=u(r,ot,P,B,z,et);const dt=Math.min(1,.00392156863*r.a*s*(1+R));dt!==st&&(t.globalAlpha=dt,st=dt),ht!==it&&(t.fillStyle=ht,it=ht),1!==d?(t.translate(H,V),t.scale(d,d),t.fillText(i,0,0),t.setTransform(w)):t.fillText(i,H,V)}}}t.globalAlpha=1}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 o=at(t),n=at(o*(void 0===e.speed?1:Math.max(.001,e.speed)));return at(e.ease?e.ease(n):n)}function lt(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=ct(e,o),s=n+(a-n)*i;t.currentTime=Math.min(Math.max(n,s),Math.max(n,a-.04)),o.onUpdate?.(i,t)}function ht(t,e){return Math.abs(t.currentTime-e)<1/240?dt(t):new Promise(o=>{const n=()=>{t.removeEventListener("seeked",n),o()};t.addEventListener("seeked",n,{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?o=>{let n=!1;const r=()=>{n||(n=!0,o())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function ft(t,e={}){const o=it(e.trigger)??t;t.pause();const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:o,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:o=>lt(t,o.progress,e)});return()=>a.kill?.()}return function(t,e,o){let n=0;const r=()=>{n=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,o)},a=()=>{n||(n=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),n&&cancelAnimationFrame(n)}}(t,o,e)}function mt(t,e,o){const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>o(t.progress)});return()=>a.kill?.()}return function(t,e){let o=0;const n=()=>{o=0;const n=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=n.height+r,i=a>0?at((r-n.top)/a):0;e(i)},r=()=>{o||(o=requestAnimationFrame(n))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),o&&cancelAnimationFrame(o)}}(t,o)}function ut(t,e,o){if(!t||!e||!o.sourceCrop)return{w:t,h:e};const n=X(o.sourceCrop,t,e);return{w:Math.max(1,Math.round(n.width)),h:Math.max(1,Math.round(n.height))}}function gt(t,e,o,n){const r=n.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return e>1.4*t&&e>1.4*o&&e>80;if("blue-screen"===r)return o>1.4*t&&o>1.4*e&&o>80;const a=b(r),i=(n.chromaKeyTolerance??60)**2,s=t-a.r,c=e-a.g,l=o-a.b;return s*s+c*c+l*l<=i}function Mt(t,e,o){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const n=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!n||!r)return e;const a=X(e.sourceCrop,n,r),s=Math.min(360,Math.max(1,Math.round(a.width))),c=Math.max(1,Math.round(s*(a.height/a.width))),{ctx:l}=i(s,c);l.drawImage(t,a.x,a.y,a.width,a.height,0,0,s,c);const h=l.getImageData(0,0,s,c).data,d=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let f=s,m=c,u=-1,g=-1;for(let t=0;t<c;t++)for(let o=0;o<s;o++){const n=4*(t*s+o),r=h[n+3],a=h[n],i=h[n+1],c=h[n+2];r<=8||.2126*a+.7152*i+.0722*c<=d||gt(a,i,c,e)||(o<f&&(f=o),t<m&&(m=t),o>u&&(u=o),t>g&&(g=t))}if(u<f||g<m)return e;const M=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),p=Math.round(s*M),x=Math.round(c*M);f=Math.max(0,f-p),m=Math.max(0,m-x),u=Math.min(s-1,u+p),g=Math.min(c-1,g+x);const w=function(t,e,o,n,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,o-t.right),m=Math.min(l,n-t.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),M=h+u/2,p=d+g/2;let x=u,w=g;x/w<a?x=w*a:w=x/a;x>e.width&&(x=e.width,w=Math.max(g,Math.min(e.height,x/a)));w>e.height&&(w=e.height,x=Math.max(u,Math.min(e.width,w*a)));let b=M-x/2,v=p-w/2;return b=Math.max(i,Math.min(c-x,b)),v=Math.max(s,Math.min(l-w,v)),{left:b,top:v,right:o-(b+x),bottom:n-(v+w)}}({left:a.x+f/s*a.width,top:a.y+m/c*a.height,right:n-(a.x+(u+1)/s*a.width),bottom:r-(a.y+(g+1)/c*a.height)},{x:a.x,y:a.y,width:a.width,height:a.height},n,r,o);return{...e,sourceCrop:{unit:"pixel",...w,preserveAspect:!1}}}function pt(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 xt(t,e,o,n,r){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const a=t.currentTime,i=function(t,e,o,n){const r=!0===n?{}:n||{},a=Math.max(0,r.from??e),i=r.to??o??(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,o,n,r);let s=null;for(const o of i){await ht(t,o),await dt(t);const n=pt(Mt(t,e));n&&(s=s?{left:Math.min(s.left,n.left),top:Math.min(s.top,n.top),right:Math.min(s.right,n.right),bottom:Math.min(s.bottom,n.bottom)}:n)}return await ht(t,a),await dt(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function wt(t,e,o=2048){return bt({sourceWidth:t,sourceHeight:e,maxRenderDimension:o})}function bt({sourceWidth:t,sourceHeight:e,cssWidth:o=0,cssHeight:n=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,o,n),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 vt(t,e,o,n){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)?o*t:void 0}if(r.endsWith("vh")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?n*t:void 0}}function yt(t,e,o,n,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=vt(i.width,s,l,h)??s,f=vt(i.height,c,l,h)??c,m=function(t,e,o,n,r){const a=t=>{const o=vt(t,e,n,r);return o&&o>0?o:0},i=t=>{const e=vt(t,o,n,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:M,cssH:p}=function(t,e,o,n="contain"){if("fill"===n)return{cssW:t,cssH:e};let r=t,a=r/o;const i="cover"===n,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*o),"scale-down"===n&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,o,i.objectFit??"contain"),x="undefined"!=typeof window&&window.devicePixelRatio||1;let w,b;n&&r?({renderW:w,renderH:b}=bt({sourceWidth:n,sourceHeight:r,cssWidth:M,cssHeight:p,maxRenderDimension:a})):(w=M,b=p);const v=8e6,y=w*x*b*x>v?Math.sqrt(v/(w*b)):x;return t.width=Math.round(w*y),t.height=Math.round(b*y),t.style.width=`${M}px`,t.style.height=`${p}px`,{renderW:w,renderH:b,dpr:y}}async function St(t,e,{fontSize:o,artStyle:r="classic",options:i={},fitTo:s,objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m,preExtract:u=!1,fps:g,maxRenderDimension:M=2048,trim:p,scroll:x,maxCachedFrames:w=90,onReady:b,onFrame:v}={}){const y=p?.start??0,S=p?.end,$=o??i.fontSize??10;let C={...a,...n[r],...i,fontSize:$};const E=e.getContext("2d");if(!E)throw new Error("asciifyVideo: could not get 2d context from canvas.");const T="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null,A={objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m},F=function(t,e){var o;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 n={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 n=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(n)),(o=t.style).transformOrigin||(o.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=n.width,t.style.height=n.height,t.style.objectFit=n.objectFit,t.style.objectPosition=n.objectPosition,t.style.maxWidth=n.maxWidth,t.style.maxHeight=n.maxHeight,t.style.transformOrigin=n.transformOrigin,n.scale?t.style.setProperty("scale",n.scale):t.style.removeProperty("scale")}}(e,A),I=t=>()=>{t(),F()};if(u){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,C=await xt(o,C,y,S,x);const n=ut(o.videoWidth,o.videoHeight,C);T&&yt(e,T,n.w/n.h,n.w,n.h,M,A);const{renderW:r,renderH:a}=wt(n.w,n.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;e.width<Math.round(r*c)&&(e.width=Math.round(r*c),e.height=Math.round(a*c));const l=void 0!==S?S-y:10,h=g??(x?18:void 0);if(st(C)){const{frames:t,fps:n}=await et(o,C,r,a,h,l,void 0,y),i=e=>{const o=t[e];o&&(E.save(),E.setTransform(c,0,0,c,0,0),Z(E,o,C,r,a),E.restore(),v?.())};if(x){let n=!1,r=-1;const a=!0===x?{}:x,s=mt(it(a.trigger)??T??e,a,e=>{const s=ct(e,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),n||(n=!0,b?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,b?.(o),I(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/n,M=e=>{d||(e-m>=g&&(i(f),f=(f+1)%t.length,m=e,u&&(u=!1,b?.(o))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),I(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await tt(o,C,r,a,h,l,void 0,y),m=t=>{const e=d[t];e&&(E.save(),E.setTransform(c,0,0,c,0,0),rt(E,e,C,r,a),E.restore(),v?.())};if(x){let t=!1,n=-1;const r=!0===x?{}:x,a=mt(it(r.trigger)??T??e,r,e=>{const a=ct(e,r),i=Math.max(0,Math.min(d.length-1,Math.round(a*(d.length-1))));i!==n&&(n=i,m(i),t||(t=!0,b?.(o)),r.onUpdate?.(a,o))});return m(0),t=!0,b?.(o),I(a)}let u,p=!1,w=0,$=performance.now(),F=!0;const R=1e3/f,k=t=>{p||(t-$>=R&&(m(w),w=(w+1)%d.length,$=t,F&&(F=!1,b?.(o))),u=requestAnimationFrame(k))};return u=requestAnimationFrame(k),I(()=>{p=!0,cancelAnimationFrame(u)})}let R,k=!1;"string"==typeof t?(R=document.createElement("video"),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),k=!0,await new Promise((e,o)=>{R.onloadedmetadata=()=>e(),R.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await R.play().catch(()=>{})):(R=t,R.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{R.removeEventListener("loadedmetadata",n),R.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};R.addEventListener("loadedmetadata",n),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 L=null;(y>0||void 0!==S)&&(L=()=>{(void 0!==S&&R.currentTime>=S||y>0&&R.currentTime<y)&&(R.currentTime=y)},R.addEventListener("timeupdate",L)),C=await xt(R,C,y,S,x);let P=null;const B=ut(R.videoWidth,R.videoHeight,C),{renderW:z,renderH:q}=wt(B.w,B.h,M),H=t=>"frame"===C.chromaKeyTrimMode?Mt(t,C,z/q):C;if(T){const t=B.w/B.h,o=B.w,n=B.h,r=yt(e,T,t,o,n,M,A),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),P=new ResizeObserver(()=>{const r=yt(e,T,t,o,n,M,A),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),P.observe(T)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=z*t*q*t>o?Math.sqrt(o/(z*q)):t;e.width<Math.round(z*n)&&(e.width=Math.round(z*n),e.height=Math.round(q*n)),E.setTransform(n,0,0,n,0,0)}let W,j=!1,D=!0,O=null;const N=x&&!u,U=g&&g>0?1e3/g:0;let V=0,K=-1;const _=!N&&st(C);if(N&&"ascii"===C.renderMode&&"none"===C.animationStyle&&C.hoverStrength<=0&&!C.charsetFrames?.length){const t=!0===x?{}:x,o=it(t.trigger)??T??e,n=t.from??y,r=t.to??S??R.duration,a=Math.max(n,Math.min(r,R.duration)),i=Math.max(.001,a-n),s=Math.min(60,Math.max(12,g??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(w))),f=()=>{for(;h.length>d;){const t=h.findIndex(t=>t!==u&&Math.abs(t-u)>2),e=t>=0?t:0,o=h.splice(e,1)[0];void 0!==o&&(l[o]=void 0)}},m=t=>{const e=h.indexOf(t);e>=0&&h.splice(e,1),h.push(t),f()};let u=0,M=0,p=-1,$=0,A=!1,F=!1,B=!1;const W=new Set,j=document.createElement("video");j.muted=!0,j.playsInline=!0,j.preload="auto",j.crossOrigin=R.crossOrigin||"anonymous",j.src=R.currentSrc||R.src,Object.assign(j.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(j),j.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{j.removeEventListener("loadedmetadata",n),j.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: cache video failed to load metadata."))};j.addEventListener("loadedmetadata",n),j.addEventListener("error",r),j.load()}),j.pause(),R.paused&&await R.play().catch(()=>{});const D=t=>n+i*t/Math.max(1,c-1),N=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),K=H(R),_=Q(R,K,z,q);_.rows.length>0&&(l[0]=_,m(0),Z(E,_,K,z,q),B=!0,b?.(R),v?.());const Y=t=>{if(l[t])return t;for(let e=1;e<c;e++){const o=t-e,n=t+e;if(o>=0&&l[o])return o;if(n<c&&l[n])return n}return-1},G=()=>{if(!l[u])return u;for(const t of W)if(!l[t])return t;for(let t=1;t<c;t++){const e=u-t,o=u+t;if(e>=0&&!l[e])return e;if(o<c&&!l[o])return o}return-1},X=t=>{t<0||t>=c||l[t]||(W.add(t),J())},J=async()=>{if(A||F)return;const t=G();if(!(t<0)){W.delete(t),F=!0;try{if(await ht(j,D(t)),!A){const e=H(j),o=Q(j,e,z,q);o.rows.length>0&&(l[t]=o,m(t))}}finally{F=!1,A||requestAnimationFrame(()=>{J()})}}},tt=()=>{if(A)return;const t=Y(u);if(t>=0&&t!==p){const e=l[t];e&&(Z(E,e,C,z,q),p=t,B||(B=!0,b?.(R)),v?.())}else if(t<0||p<0){const t=performance.now();if(U<=0||t-V>=U){const e=H(R),o=Q(R,e,z,q);o.rows.length>0&&(Z(E,o,e,z,q),V=t,B||(B=!0,b?.(R)),v?.())}}X(u),$=requestAnimationFrame(tt)};return O=mt(o,t,e=>{const o=function(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=ct(e,o),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(R,e,{...t,from:n,to:a});M=o?.progress??at(e),u=N(M),X(u),X(u-1),X(u+1),X(u-2),X(u+2),X(u-3),X(u+3),t.onUpdate?.(M,R)}),X(0),X(1),$=requestAnimationFrame(tt),I(()=>{A=!0,cancelAnimationFrame($),O?.(),P?.disconnect(),W.clear(),h.length=0,l.fill(void 0),j.pause(),j.src="",j.removeAttribute("src"),j.load(),j.isConnected&&j.remove(),L&&R.removeEventListener("timeupdate",L),k&&(R.pause(),R.src="",R.removeAttribute("src"),R.load(),R.isConnected&&R.remove())})}if(N){const t=!0===x?{}:x;O=ft(R,{...t,trigger:t.trigger??T??e,from:t.from??y,to:t.to??S})}const Y=t=>{if(j)return;if(W=requestAnimationFrame(Y),R.readyState<2||0===e.width||0===e.height)return;if(U>0&&t-V<U)return;if(y>0&&R.currentTime<y)return;if(void 0!==S&&R.currentTime>=S)return;if(N&&Math.abs(R.currentTime-K)<1/240)return;if(_){const e=H(R),o=Q(R,e,z,q);return void(o.rows.length>0&&(Z(E,o,e,z,q),V=t,K=R.currentTime,D&&(D=!1,b?.(R)),v?.()))}const o=H(R),{frame:n}=J(R,o,z,q);n.length>0&&(rt(E,n,C,z,q,0,null),V=t,K=R.currentTime,D&&(D=!1,b?.(R)),v?.())};return W=requestAnimationFrame(Y),I(()=>{j=!0,cancelAnimationFrame(W),O?.(),P?.disconnect(),L&&R.removeEventListener("timeupdate",L),k&&(R.pause(),R.src="",R.removeAttribute("src"),R.load(),R.isConnected&&R.remove())})}function $t(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:d=14,lightMode:f=!1}=r,m=s??(f?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let x=255,w=255,b=255;if(f&&(x=55,w=55,b=55),c){const t=$(c);t&&(x=t.r,w=t.g,b=t.b)}let v=212,y=255,S=0;const C=$(m);C&&(v=C.r,y=C.g,S=C.b);const E=p+d;for(let e=0;e<M;e++){if(T(17*e,3)>h)continue;const o=(.5+1.5*T(31*e,7))*l,r=T(13*e,11)*E,a=Math.floor((n*o*7+r)%E),s=e*u;for(let o=0;o<=d;o++){const r=a-(d-o);if(r<0||r>=p)continue;const c=r*g,l=T(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/d;if(o===d)t.fillStyle=`rgba(${v},${y},${S},${f?.7:.85})`;else{const e=f?.85*m:.15*m;t.fillStyle=`rgba(${x},${w},${b},${e})`}t.fillText(h,s,c)}}}function Ct(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:d=180,lightMode:f=!1}=a,m=c??(f?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,x=255,w=255;if(f&&(p=55,x=55,w=55),l){const t=$(l);t&&(p=t.r,x=t.g,w=t.b)}let b=212,v=255,y=0;const S=$(m);S&&(b=S.r,v=S.g,y=S.b);const C=s.replace(/ /g,"").split("");if(0!==C.length){for(let r=0;r<d;r++){const a=T(17*r,3)*Math.PI*2,s=(n*(.15+.85*T(31*r,7))*h*.22+T(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>o+20)continue;const d=Math.max(6,i*(.4+.9*s));t.font=`${d}px monospace`;const m=C[Math.min(C.length-1,Math.floor(s*C.length))],S=s>.72,$=f?.85*s:.2*s;t.fillStyle=S?`rgba(${b},${v},${y},${Math.min(f?.92:.32,2.2*$)})`:`rgba(${p},${x},${w},${$})`,t.fillText(m,c,l)}t.textAlign="left"}}function Et(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:d=1,sharpness:f=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const g=e*r.x,M=o*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(e*e+o*o);let x=255,w=255,b=255;if(m&&(x=55,w=55,b=55),l){const t=$(l);t&&(x=t.r,w=t.g,b=t.b)}let v=0,y=255,S=204;const C=$(u);C&&(v=C.r,y=C.g,S=C.b);const E=s.replace(/ /g,"").split("");if(0===E.length)return;const T=Math.ceil(e/i),A=Math.ceil(o/i);for(let e=0;e<A;e++)for(let o=0;o<T;o++){const r=o*i+.5*i,a=e*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(n*d*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-f)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;t.font=`${i}px monospace`;const C=Math.floor(u*(E.length-1)),T=E[Math.min(C,E.length-1)],A=m?.88*u:.22*u;t.fillStyle=$?`rgba(${v},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${x},${w},${b},${A})`,t.fillText(T,r,a)}t.textAlign="left"}function Tt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:d=1,scale:f=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,x=1.4*i,w=Math.ceil(e/p),b=Math.ceil(o/x);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let v=255,y=255,S=255;if(g&&(v=55,y=55,S=55),l){const t=$(l);t&&(v=t.r,y=t.g,S=t.b)}let C=212,E=255,T=0;const F=$(M);F&&(C=F.r,E=F.g,T=F.b);const I=.035*f,R=n*d,k=Math.min(6,Math.max(1,h)),L=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<k;i++)o+=A(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<b;e++)for(let o=0;o<w;o++){const n=o*I+.06*R,a=e*I*1.3-.04*R,i=o/w-r.x,c=e/b-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,d=.5*L(n+h*Math.sin(1.3*R+8*c),a+h*Math.cos(.9*R+8*i))+.5;if(d<.12)continue;const f=s[Math.floor(d*(s.length-1))];if(" "===f)continue;const M=d>m,$=g?.82*d:.13*d;t.fillStyle=M?`rgba(${C},${E},${T},${g?.92:.28})`:`rgba(${v},${y},${S},${$})`,t.fillText(f,o*p,e*x)}}function At(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:d=1,bandWidth:f=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),w=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,v=255,y=255;if(u&&(b=55,v=55,y=55),l){const t=$(l);t&&(b=t.r,v=t.g,y=t.b)}let S=212,C=255,E=0;const A=$(g);A&&(S=A.r,C=A.g,E=A.b);const F=n*d;for(let e=0;e<w;e++)for(let o=0;o<x;o++){const n=e/w,a=((n*h-.5*F)%1+1)%1,i=Math.max(0,1-a/f),c=.35*(.5*T(3*o,7*e)+.5);let l=0;if(m){const t=o/x-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=T(11*o+Math.floor(12*F),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const d=Math.min(1,c+.8*i+.6*l);if(d<.04)continue;const g=s[Math.floor(d*(s.length-1))],$=i>.55,A=u?.82*d:.12*d;t.fillStyle=$?`rgba(${S},${C},${E},${u?.92:.28})`:`rgba(${b},${v},${y},${A})`,t.fillText(g,o*M,e*p)}}function Ft(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:d=5,softness:f=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),w=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,v=255,y=255;if(u&&(b=55,v=55,y=55),c){const t=$(c);t&&(b=t.r,v=t.g,y=t.b)}let S=212,C=255,E=0;const A=$(g);A&&(S=A.r,C=A.g,E=A.b);const F=n*h,I=[];for(let t=0;t<d;t++){const e=T(17*t,31*t+7),o=T(23*t+5,11*t);I.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*T(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*T(29*t,3*t)})}for(let e=0;e<w;e++){const o=e/w;for(let n=0;n<x;n++){const a=n/x,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,w=o+c*h;let $=0,T=0;for(let t=0;t<d;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=I[t];$+=Math.sin(g*e*Math.PI*2+F*r+n)*Math.cos(w*o*Math.PI*2+F*r*.7+1.3*n)*a,T+=a}const A=$/T,R=.5+.5*Math.tanh(A*f*2.2);if(R<.12)continue;const k=(R-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],P=R>.82,B=u?.82*R:.14*R;t.fillStyle=P?`rgba(${S},${C},${E},${u?.92:.32})`:`rgba(${b},${v},${y},${B})`,t.fillText(L,n*M,e*p)}}}function It(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:d=!1}=r,f=s??(d?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,x=255,w=255;if(d&&(p=55,x=55,w=55),i){const t=$(i);t&&(p=t.r,x=t.g,w=t.b)}let b=212,v=255,y=0;const S=$(f);S&&(b=S.r,v=S.g,y=S.b);const C=n*c,E=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let t=0;t<l;t++){const e=T(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*T(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*T(41*t,17*t))*(t%2==0?1:-1.3),d=Math.sin(r*n*Math.PI*2+C*l+c),f=Math.cos(o*s*Math.PI*2+C*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+C*l*.4);a+=Math.atan2(f+.3*m,d),i+=.5*(d*f+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const f=(s+Math.PI)/(2*Math.PI),M=E[Math.floor(f*E.length)%E.length],S=c>.8,$=d?.8*c:.13*c;t.fillStyle=S?`rgba(${b},${v},${y},${d?.9:.26})`:`rgba(${p},${x},${w},${$})`,t.fillText(M,n*m,e*u)}}}function Rt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:d=.38,swirl:f=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),x=Math.ceil(o/M),w=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,v=255,y=255;if(m&&(b=55,v=55,y=55),c){const t=$(c);t&&(b=t.r,v=t.g,y=t.b)}let S=212,C=255,E=0;const A=$(u);A&&(S=A.r,C=A.g,E=A.b);const F=n*h;for(let e=0;e<x;e++){const o=e/x;for(let n=0;n<p;n++){const a=(n/p-r.x)*w,i=o-r.y,c=Math.sqrt(a*a+i*i)/d;if(c>1){const o=T(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);t.fillStyle=`rgba(${b},${v},${y},${r})`,t.fillText(s[1],n*g,e*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*F)))/.07),h=Math.pow(1-c,2.2),f=Math.min(1,h+.6*l);if(f<.06)continue;const u=Math.floor(f*(s.length-1)),x=s[Math.min(s.length-1,u)],$=l>.35||c<.08,A=m?.85*f:.18*f;t.fillStyle=$?`rgba(${S},${C},${E},${m?.95:.38})`:`rgba(${b},${v},${y},${A})`,t.fillText(x,n*g,e*M)}}}function kt(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:d=!1}=r,f=c??(d?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,x=255,w=255;if(d&&(p=55,x=55,w=55),s){const t=$(s);t&&(p=t.r,x=t.g,w=t.b)}let b=212,v=255,y=0;const S=$(f);S&&(b=S.r,v=S.g,y=S.b);const C=n*l,E=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<g;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*T(o*(t+3)+7,e*(t+5)+11),a=T(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin(C*r+a)*i}const r=.5*(n/E+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=d?.82*a:.13*a;t.fillStyle=c?`rgba(${b},${v},${y},${d?.92:.28})`:`rgba(${p},${x},${w},${l})`,t.fillText(s,o*m,e*u)}}function Lt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:d=1,lightMode:f=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u),p=g*M,x="__fire_heat__",w=t.canvas;let b=w[x];b&&b.length===p||(b=new Float32Array(p),w[x]=b);const v=.18*(.016*d),y=h*d*.8,S=M-1,C=n*d;for(let t=0;t<g;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*l;b[S*g+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(b[(S-1)*g+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const o=.4*b[(t+1)*g+e]+.25*b[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*b[(t+1)*g+Math.max(0,e-1)]+.175*b[(t+1)*g+Math.min(g-1,e+1)];E[t*g+e]=Math.max(0,o-v-.02*Math.random()*d)}for(let t=0;t<g;t++)E[(M-1)*g+t]=b[(M-1)*g+t],M>1&&(E[(M-2)*g+t]=b[(M-2)*g+t]);w[x]=E;const T=$(s)??{r:255,g:69,b:0},A=$(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<g;o++){const n=E[e*g+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),s=T.r+(A.r-T.r)*a|0,c=T.g+(A.g-T.g)*a|0,l=T.b+(A.b-T.b)*a|0,h=f?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,o*m,e*u)}t.globalAlpha=1}function Pt(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:d=1,helixCount:f,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g),x=f??Math.max(1,Math.floor(e/80)),w=M/x,b=$(c)??{r:0,g:229,b:255},v=$(l)??{r:255,g:64,b:129},y=$(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const S=n*d,C=.35*w;for(let e=0;e<x;e++){const o=w*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*S,a=o+Math.sin(r)*C,c=o+Math.sin(r+Math.PI)*C,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const d=T(31*e+7*n,3),f=i[Math.floor(d*i.length)],m=.5*(Math.sin(r)+1),x=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*m,t.fillStyle=`rgb(${b.r},${b.g},${b.b})`,t.fillText(f,l*u,n*g),h>=0&&h<M){const o=T(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*x,t.fillStyle=`rgb(${v.r},${v.g},${v.b})`,t.fillText(r,h*u,n*g)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=T(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(m+x)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*g)}}}}t.globalAlpha=1}function Bt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:d=.55,heightScale:f=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),x=Math.ceil(o/M),w=$(s)??{r:76,g:175,b:80},b=$(c)??{r:26,g:35,b:126},v=$(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const y=n*h*.4,S=new Array(p);for(let t=0;t<p;t++){const e=(.5*F((t/p+y)*d*3,.5)+.5)*f;S[t]=Math.floor(e*x)}for(let e=0;e<x;e++)for(let o=0;o<p;o++){const r=x-1-S[o],a=e===r;if(!(e>=r)){if(m){const r=T(7*o+Math.floor(.3*y),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${b.r+60},${b.g+60},${b.b+80})`,t.fillText("·",o*g,e*M)}}continue}const s=(e-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=w.r+(v.r-w.r)*l|0,d=w.g+(v.g-w.g)*l|0,f=w.b+(v.b-w.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${d},${f})`,t.fillText(a?i[i.length-1]:c,o*g,e*M)}t.globalAlpha=1}var zt=1,qt=2,Ht=4,Wt=8,jt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[zt]:"╶",[qt]:"╴",[Ht]:"╵",[Wt]:"╷"};function Dt(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,d=.62*a,f=1.4*a,m=Math.ceil(e/d),u=Math.ceil(o/f),g=$(s)??{r:0,g:255,b:136},M=$(i)??{r:255,g:255,b:255},p=(t,e)=>{if(T(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<m&&T(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&T(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&T(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&T(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const x=n*l;for(let e=0;e<u;e++)for(let o=0;o<m;o++){const n=p(o,e);if(0===n)continue;const r=jt[n]??"·",a=(8*x+40*T(o,23*e))%m,i=(6*x+40*T(17*e,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(e-i)<1.5,l=s||c,h=.25+.35*T(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${g.r},${g.g},${g.b})`),t.fillText(r,o*d,e*f)}t.globalAlpha=1}function Ot(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const d=document.createElement("canvas");d.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(d.className=r),l.prepend(d);const f=d.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let t=l;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if(t)return(.299*+t[1]+.587*+t[2]+.114*+t[3])/255>=.4}t=t.parentElement}const e=document.documentElement,o=(e.getAttribute("data-theme")||"").toLowerCase();return"dark"!==o&&("light"===o||!e.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches)})(),p=s?function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(s):null,x=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),w={current:x()},b=()=>{w.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:x()};b();const v=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{b()};let S=null;"auto"===i&&(v.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const t=l.getBoundingClientRect();d.width=t.width*m,d.height=t.height*m,f.setTransform(m,0,0,m,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let T=0,A=0;const F=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const t=l.getBoundingClientRect();"rain"===o?$t(f,t.width,t.height,T,w.current):"stars"===o?Ct(f,t.width,t.height,T,g,w.current):"pulse"===o?Et(f,t.width,t.height,T,g,w.current):"noise"===o?Tt(f,t.width,t.height,T,g,w.current):"grid"===o?At(f,t.width,t.height,T,g,w.current):"aurora"===o?Ft(f,t.width,t.height,T,g,w.current):"silk"===o?It(f,t.width,t.height,T,w.current):"void"===o?Rt(f,t.width,t.height,T,g,w.current):"morph"===o?kt(f,t.width,t.height,T,w.current):"fire"===o?Lt(f,t.width,t.height,T,w.current):"dna"===o?Pt(f,t.width,t.height,T,w.current):"terrain"===o?Bt(f,t.width,t.height,T,w.current):"circuit"===o?Dt(f,t.width,t.height,T,w.current):I(f,t.width,t.height,T,g,w.current),T+=.016,A=requestAnimationFrame(F)};return A=requestAnimationFrame(F),{destroy:()=>{cancelAnimationFrame(A),E.disconnect(),"auto"===i&&(v.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",C),d.remove(),l.style.position=h}}}var Nt=Ot;function Ut(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=$(n)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function Vt(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}var Kt={A:[28,54,99,127,99,99,99],B:[126,99,99,126,99,99,126],C:[62,99,96,96,96,99,62],D:[124,102,99,99,99,102,124],E:[127,96,96,124,96,96,127],F:[127,96,96,124,96,96,96],G:[62,99,96,111,99,99,62],H:[99,99,99,127,99,99,99],I:[127,8,8,8,8,8,127],J:[63,6,6,6,102,102,60],K:[99,102,108,120,108,102,99],L:[96,96,96,96,96,96,127],M:[99,119,107,107,99,99,99],N:[99,115,107,103,99,99,99],O:[62,99,99,99,99,99,62],P:[126,99,99,126,96,96,96],Q:[62,99,99,99,107,102,61],R:[126,99,99,126,108,102,99],S:[62,99,96,62,3,99,62],T:[127,8,8,8,8,8,8],U:[99,99,99,99,99,99,62],V:[99,99,99,99,54,28,8],W:[99,99,99,107,107,54,20],X:[99,54,28,8,28,54,99],Y:[99,99,54,28,8,8,8],Z:[127,3,6,12,24,48,127],a:[0,0,60,3,62,99,61],b:[96,96,124,99,99,99,124],c:[0,0,62,96,96,96,62],d:[3,3,31,99,99,99,31],e:[0,0,62,99,127,96,62],f:[30,48,48,126,48,48,48],g:[0,0,63,99,63,3,62],h:[96,96,124,99,99,99,99],i:[8,0,24,8,8,8,28],j:[4,0,12,4,4,36,24],k:[96,96,102,108,120,108,102],l:[24,8,8,8,8,8,28],m:[0,0,92,107,107,99,99],n:[0,0,94,99,99,99,99],o:[0,0,62,99,99,99,62],p:[0,0,126,99,126,96,96],q:[0,0,63,99,63,3,3],r:[0,0,94,99,96,96,96],s:[0,0,62,96,62,3,124],t:[48,48,126,48,48,48,30],u:[0,0,99,99,99,103,59],v:[0,0,99,99,54,28,8],w:[0,0,99,99,107,54,20],x:[0,0,99,54,28,54,99],y:[0,0,99,99,63,3,62],z:[0,0,127,6,12,24,127],0:[62,99,103,107,115,99,62],1:[8,24,56,8,8,8,62],2:[62,99,3,6,24,48,127],3:[62,99,3,30,3,99,62],4:[6,14,22,38,127,6,6],5:[127,96,126,3,3,99,62],6:[62,99,96,126,99,99,62],7:[127,3,6,12,24,24,24],8:[62,99,99,62,99,99,62],9:[62,99,99,63,3,99,62]," ":[0,0,0,0,0,0,0],"!":[24,24,24,24,24,0,24],"?":[62,99,3,14,8,0,8],".":[0,0,0,0,0,24,24],",":[0,0,0,0,0,24,48],";":[0,24,24,0,24,24,48],":":[0,24,24,0,24,24,0],"-":[0,0,0,62,0,0,0],_:[0,0,0,0,0,0,127],"'":[24,24,32,0,0,0,0],'"':[54,54,36,0,0,0,0],"`":[24,8,0,0,0,0,0],")":[24,12,6,6,6,12,24],"(":[12,24,48,48,48,24,12],"[":[60,48,48,48,48,48,60],"]":[30,6,6,6,6,6,30],"{":[14,24,24,48,24,24,14],"}":[56,12,12,6,12,12,56],"/":[3,6,12,24,48,96,0],"\\":[96,48,24,12,6,3,0],"|":[8,8,8,8,8,8,8],"+":[0,8,8,62,8,8,0],"=":[0,0,62,0,62,0,0],"*":[0,42,28,127,28,42,0],"#":[36,36,127,36,127,36,36],"@":[62,99,111,107,111,96,62],"&":[24,36,24,60,74,68,58],"%":[99,38,4,8,16,50,99],$:[8,62,72,62,9,62,8],"^":[8,20,34,0,0,0,0],"~":[0,0,50,76,0,0,0],"<":[6,12,24,48,24,12,6],">":[48,24,12,6,12,24,48]},_t=[127,65,65,65,65,65,127];function Yt(t){return Kt[t]??Kt[t.toUpperCase()]??_t}function Gt(t,e={}){if(!t)return"";const{char:o="█",scale:n=1}=e,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const o=Yt(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,exports.BACKGROUND_TYPES=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"],exports.CHARSETS=e,exports.CHARSET_SEQUENCES=o,exports.DEFAULT_OPTIONS=a,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:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.LIVING_STYLE_PRESETS=r,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.asciiBackground=Ot,exports.asciiText=function(t,e={},o,n){const r={...a,...e},{frame:i,cols:s}=J(t,r,o,n);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,e={},o,n){const r={...a,...e},{frame:i,cols:s}=J(t,r,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}[0m`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,e,{fontSize:o,artStyle:r="classic",options:i={}}={}){let s;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),s=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),s=t):s=t;const c=n[r],l=o??i.fontSize??10,h={...a,...c,...i,fontSize:l},d=e.getContext("2d");if(!d)throw new Error("Could not get 2d context from canvas");const{w:f,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(s),{renderW:u,renderH:g}=wt(f,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,x=u*M*g*M>p?Math.sqrt(p/(u*g)):M;if((e.width<u||e.height<g)&&(e.width=Math.round(u*x),e.height=Math.round(g*x)),h.hoverStrength>0){const{frame:t}=J(s,h,u,g);let o=null,n=!1,r=0;const a=t=>{const n=e.getBoundingClientRect();o={x:(t.clientX-n.left)/n.width,y:(t.clientY-n.top)/n.height}},i=()=>{o=null};e.addEventListener("mousemove",a),e.addEventListener("mouseleave",i);const c=e=>{n||(d.save(),d.setTransform(x,0,0,x,0,0),rt(d,t,h,u,g,e/1e3,o),d.restore(),r=requestAnimationFrame(c))};return r=requestAnimationFrame(c),()=>{n=!0,cancelAnimationFrame(r),e.removeEventListener("mousemove",a),e.removeEventListener("mouseleave",i)}}if(d.save(),d.setTransform(x,0,0,x,0,0),st(h)){const t=Q(s,h,u,g);Z(d,t,h,u,g)}else{const{frame:t}=J(s,h,u,g);rt(d,t,h,u,g)}d.restore()},exports.asciifyGif=async function(t,e,{fontSize:o,artStyle:r="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??i.fontSize??10;let l={...a,...n[r],...i,fontSize:c};const h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");if(st(l)){const{frames:t,fps:o}=await nt(s,l,e.width,e.height);let n,r=!1,a=0,i=performance.now();const c=1e3/o,d=o=>{r||(o-i>=c&&(Z(h,t[a],l,e.width,e.height),a=(a+1)%t.length,i=o),n=requestAnimationFrame(d))};return n=requestAnimationFrame(d),()=>{r=!0,cancelAnimationFrame(n)}}const{frames:d,fps:f}=await ot(s,l,e.width,e.height);let m,u=!1,g=0,M=performance.now();const p=1e3/f,x=t=>{u||(t-M>=p&&(rt(h,d[g],l,e.width,e.height),g=(g+1)%d.length,M=t),m=requestAnimationFrame(x))};return m=requestAnimationFrame(x),()=>{u=!0,cancelAnimationFrame(m)}},exports.asciifyLiveVideo=function(t,e,o){return St(t,e,o)},exports.asciifyText=Gt,exports.asciifyVideo=St,exports.asciifyWebcam=async function(t,{fontSize:e=10,style:o="classic",options:r={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),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={...a,...n[o],...r,fontSize:e},m=t.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();g={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},x=()=>{g=null};f.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",x));let w,b=!1;const v=performance.now(),y=e=>{if(!b){if(d.readyState>=d.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,r=(e-v)/1e3,a=i?{...f,...i()}:f;a.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",x)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",x));const{frame:c}=J(d,a,o,n);if(g){const t=g.x-M.x,e=g.y-M.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);M.x+=t*n,M.y+=e*n,M.intensity+=.12*(1-M.intensity)}else M.intensity*=.965,M.intensity<.003&&(M.intensity=0);const l=M.intensity>.003?{x:M.x,y:M.y,intensity:M.intensity}:null;s?(m.save(),m.scale(-1,1),m.translate(-o,0),rt(m,c,a,o,n,r,l),m.restore()):rt(m,c,a,o,n,r,l)}w=requestAnimationFrame(y)}};return w=requestAnimationFrame(y),()=>{b=!0,cancelAnimationFrame(w),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",x),h.getTracks().forEach(t=>t.stop()),d.srcObject=null}},exports.buildTextFrame=Ut,exports.captureSnapshot=Vt,exports.clearAsciifyCaches=function(){z.clear(),q.clear(),H.clear(),L=null,P=null},exports.computeCanvasRenderSize=bt,exports.createVideoScrollScrub=ft,exports.gifToAsciiFrames=ot,exports.gifToAsciiTextFrames=nt,exports.imageToAsciiFrame=J,exports.imageToAsciiTextFrame=Q,exports.mountWaveBackground=Nt,exports.renderAuroraBackground=Ft,exports.renderCircuitBackground=Dt,exports.renderDnaBackground=Pt,exports.renderFireBackground=Lt,exports.renderFrameToCanvas=rt,exports.renderGridBackground=At,exports.renderMorphBackground=kt,exports.renderNoiseBackground=Tt,exports.renderPulseBackground=Et,exports.renderRainBackground=$t,exports.renderSilkBackground=It,exports.renderStarsBackground=Ct,exports.renderTerrainBackground=Bt,exports.renderTextBackground=function(t,e,o,n,r={},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"}=r;rt(t,Ut(n,Math.max(1,Math.floor(e/s)),Math.max(1,Math.floor(o/(s*c))),l,h),{...a,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},e,o,0,i??null)},exports.renderTextFrameToCanvas=Z,exports.renderTextToCanvas=function(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=Gt(e,o);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=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))},exports.renderVoidBackground=Rt,exports.renderWaveBackground=I,exports.snapshotAndDownload=async function(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await Vt(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=tt,exports.videoToAsciiTextFrames=et;//# sourceMappingURL=index.cjs.map
|