@applemusic-like-lyrics/core 0.0.15 → 0.1.1
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/amll-core.cjs +61 -0
- package/dist/amll-core.cjs.map +1 -0
- package/dist/amll-core.js.map +1 -1
- package/dist/bg-render/base.d.ts +108 -0
- package/dist/bg-render/eplor-renderer.d.ts +54 -0
- package/dist/utils/derivative.d.ts +2 -0
- package/dist/utils/matrix.d.ts +25 -0
- package/dist/utils/resource.d.ts +4 -0
- package/dist/utils/wa-spring.d.ts +33 -0
- package/package.json +15 -6
- package/dist/amll-core.js +0 -2
- package/dist/amll-core.mjs +0 -1313
- package/dist/amll-core.mjs.map +0 -1
- package/dist/bg-render/index.d.ts +0 -13
- package/dist/bg-render/pixi-renderer.d.ts +0 -52
- package/dist/index.d.ts +0 -4
- package/dist/interfaces.d.ts +0 -53
- package/dist/lyric/ttml.d.ts +0 -2
- package/dist/lyric-player/bottom-line.d.ts +0 -26
- package/dist/lyric-player/index.d.ts +0 -235
- package/dist/lyric-player/interlude-dots.d.ts +0 -22
- package/dist/lyric-player/lyric-line.d.ts +0 -58
- package/dist/utils/eq-set.d.ts +0 -1
- package/dist/utils/spring.d.ts +0 -26
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";var de=Object.defineProperty;var me=(o,i,e)=>i in o?de(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e;var a=(o,i,e)=>(me(o,typeof i!="symbol"?i+"":i,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const fe=require("@pixi/display"),ue=require("@pixi/app"),R=require("@pixi/filter-blur"),X=require("@pixi/filter-color-matrix"),pe=require("@pixi/core"),N=require("@pixi/sprite"),q=require("@pixi/filter-bulge-pinch"),ge=require("jss"),ye=require("jss-preset-default");class se{}class Z extends se{constructor(e){super();a(this,"observer");a(this,"flowSpeed",2);a(this,"currerntRenderScale",.75);this.canvas=e,this.observer=new ResizeObserver(()=>{const t=Math.max(1,e.clientWidth*window.devicePixelRatio*this.currerntRenderScale),s=Math.max(1,e.clientHeight*window.devicePixelRatio*this.currerntRenderScale);this.onResize(t,s)}),this.observer.observe(e)}setRenderScale(e){this.currerntRenderScale=e,this.onResize(this.canvas.clientWidth*window.devicePixelRatio*this.currerntRenderScale,this.canvas.clientHeight*window.devicePixelRatio*this.currerntRenderScale)}onResize(e,t){this.canvas.width=e,this.canvas.height=t}setFlowSpeed(e){this.flowSpeed=e}dispose(){this.observer.disconnect(),this.canvas.remove()}}function Te(o){return new Promise((i,e)=>{const t=document.createElement("img");t.onload=()=>i(t),t.onerror=e,t.src=o,t.crossOrigin="anonymous",t.decode().then(()=>i(t)).catch(e)})}function Ee(o){return new Promise((i,e)=>{const t=document.createElement("video");let s=!1,l=!1,r=!1;t.addEventListener("playing",()=>{s=!0,n()},!0),t.addEventListener("timeupdate",()=>{l=!0,n()},!0),t.addEventListener("error",h=>{r=!0,e(h)},!0);function n(){s&&l&&!r&&i(t)}t.src=o,t.playsInline=!0,t.crossOrigin="anonymous",t.autoplay=!0,t.loop=!0,t.muted=!0,t.play()})}function le(o,i=!1){return i?Ee(o):Te(o)}function re(o){return new Promise((i,e)=>{(o instanceof HTMLImageElement?o.complete:o.readyState>=3)?i(o):(o.onload=()=>i(o),o.onerror=e)})}class we extends fe.Container{constructor(){super(...arguments);a(this,"time",0)}}class be extends Z{constructor(e){super(e);a(this,"app");a(this,"curContainer");a(this,"staticMode",!1);a(this,"lastContainer",new Set);a(this,"onTick",e=>{for(const t of this.lastContainer)t.alpha=Math.max(0,t.alpha-e/60),t.alpha<=0&&(this.app.stage.removeChild(t),this.lastContainer.delete(t),t.destroy(!0));if(this.curContainer){this.curContainer.alpha=Math.min(1,this.curContainer.alpha+e/60);const[t,s,l,r]=this.curContainer.children,n=Math.max(this.app.screen.width,this.app.screen.height);t.position.set(this.app.screen.width/2,this.app.screen.height/2),s.position.set(this.app.screen.width/2.5,this.app.screen.height/2.5),l.position.set(this.app.screen.width/2,this.app.screen.height/2),r.position.set(this.app.screen.width/2,this.app.screen.height/2),t.width=n*Math.sqrt(2),t.height=t.width,s.width=n*.8,s.height=s.width,l.width=n*.5,l.height=l.width,r.width=n*.25,r.height=r.width,this.curContainer.time+=e*this.flowSpeed,t.rotation+=e/1e3*this.flowSpeed,s.rotation-=e/500*this.flowSpeed,l.rotation+=e/1e3*this.flowSpeed,r.rotation-=e/750*this.flowSpeed,l.x=this.app.screen.width/2+this.app.screen.width/4*Math.cos(this.curContainer.time/1e3*.75),l.y=this.app.screen.height/2+this.app.screen.width/4*Math.cos(this.curContainer.time/1e3*.75),r.x=this.app.screen.width/2+this.app.screen.width/4*.1+Math.cos(this.curContainer.time*.006*.75),r.y=this.app.screen.height/2+this.app.screen.width/4*.1+Math.cos(this.curContainer.time*.006*.75),this.curContainer.alpha>=1&&this.lastContainer.size===0&&this.staticMode&&this.app.ticker.stop()}});this.canvas=e,this.app=new ue.Application({view:e,resizeTo:this.canvas,powerPreference:"low-power",backgroundAlpha:1}),this.rebuildFilters(),this.app.ticker.maxFPS=30,this.app.ticker.add(this.onTick),this.app.ticker.start()}onResize(e,t){super.onResize(e,t),this.app.resize(),this.rebuildFilters()}setRenderScale(e){super.setRenderScale(e),this.rebuildFilters()}rebuildFilters(){var n;const e=Math.min(this.canvas.width,this.canvas.height),t=Math.max(this.canvas.width,this.canvas.height),s=new X.ColorMatrixFilter;s.saturate(1.2,!1);const l=new X.ColorMatrixFilter;l.brightness(.6,!1);const r=new X.ColorMatrixFilter;r.contrast(.3,!0),(n=this.app.stage.filters)==null||n.forEach(h=>{h.destroy()}),this.app.stage.filters=[],this.app.stage.filters.push(new R.BlurFilter(5,1)),this.app.stage.filters.push(new R.BlurFilter(10,1)),this.app.stage.filters.push(new R.BlurFilter(20,2)),this.app.stage.filters.push(new R.BlurFilter(40,2)),this.app.stage.filters.push(new R.BlurFilter(80,2)),e>768&&this.app.stage.filters.push(new R.BlurFilter(160,4)),e>768*2&&this.app.stage.filters.push(new R.BlurFilter(320,4)),this.app.stage.filters.push(s,l,r),this.app.stage.filters.push(new R.BlurFilter(5,1)),Math.random()>.5?(this.app.stage.filters.push(new q.BulgePinchFilter({radius:(t+e)/2,strength:1,center:[.25,1]})),this.app.stage.filters.push(new q.BulgePinchFilter({radius:(t+e)/2,strength:1,center:[.75,0]}))):(this.app.stage.filters.push(new q.BulgePinchFilter({radius:(t+e)/2,strength:1,center:[.75,1]})),this.app.stage.filters.push(new q.BulgePinchFilter({radius:(t+e)/2,strength:1,center:[.25,0]})))}setStaticMode(e=!1){this.staticMode=e,this.app.ticker.start()}setFPS(e){this.app.ticker.maxFPS=e}pause(){this.app.ticker.stop(),this.app.render()}resume(){this.app.ticker.start()}setLowFreqVolume(e){}setHasLyric(e){}async setAlbum(e,t){var m,f;if(typeof e=="string"&&e.trim().length===0)return;let s=null,l=5,r=null;for(;!((f=(m=r==null?void 0:r.baseTexture)==null?void 0:m.resource)!=null&&f.valid)&&l>0;)try{typeof e=="string"?s=await le(e,t):s=await re(e),r=pe.Texture.from(s,{resourceOptions:{autoLoad:!1}}),await r.baseTexture.resource.load()}catch(p){console.warn(`failed on loading album image, retrying (${l})`,e,p),r=null,l--}if(!r)return;const n=new we,h=new N.Sprite(r),c=new N.Sprite(r),I=new N.Sprite(r),d=new N.Sprite(r);h.anchor.set(.5,.5),c.anchor.set(.5,.5),I.anchor.set(.5,.5),d.anchor.set(.5,.5),h.rotation=Math.random()*Math.PI*2,c.rotation=Math.random()*Math.PI*2,I.rotation=Math.random()*Math.PI*2,d.rotation=Math.random()*Math.PI*2,n.addChild(h,c,I,d),this.curContainer&&this.lastContainer.add(this.curContainer),this.curContainer=n,this.app.stage.addChild(n),this.curContainer.alpha=0,this.app.ticker.start()}dispose(){super.dispose(),this.app.ticker.remove(this.onTick),this.app.destroy(!0)}getElement(){return this.canvas}}const G=`#version 300 es
|
|
2
|
+
precision highp float;
|
|
3
|
+
|
|
4
|
+
in vec2 v_coord;
|
|
5
|
+
out vec2 f_v_coord;
|
|
6
|
+
|
|
7
|
+
void main() {
|
|
8
|
+
gl_Position = vec4(v_coord, 0.0f, 1.0f);
|
|
9
|
+
f_v_coord = (vec2(v_coord.x, v_coord.y) + vec2(1.0f, 1.0f)) / 2.0f;
|
|
10
|
+
}
|
|
11
|
+
`,Se=`#version 300 es
|
|
12
|
+
precision highp float;
|
|
13
|
+
|
|
14
|
+
uniform sampler2D src;
|
|
15
|
+
in vec2 f_v_coord;
|
|
16
|
+
out vec4 fragColor;
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
vec2 coord = f_v_coord;
|
|
20
|
+
fragColor = texture(src, coord);
|
|
21
|
+
}
|
|
22
|
+
`,Le=`#version 300 es
|
|
23
|
+
precision highp float;
|
|
24
|
+
|
|
25
|
+
uniform sampler2D src;
|
|
26
|
+
uniform float lerp;
|
|
27
|
+
uniform float scale;
|
|
28
|
+
in vec2 f_v_coord;
|
|
29
|
+
out vec4 fragColor;
|
|
30
|
+
|
|
31
|
+
void main() {
|
|
32
|
+
vec2 tex_coord = f_v_coord;
|
|
33
|
+
if(scale < 1.0f) {
|
|
34
|
+
tex_coord /= scale;
|
|
35
|
+
}
|
|
36
|
+
vec4 srcColor = texture(src, tex_coord);
|
|
37
|
+
fragColor = mix(vec4(srcColor.xyz, 0.0f), srcColor, lerp);
|
|
38
|
+
}
|
|
39
|
+
`,xe=`#version 300 es
|
|
40
|
+
precision highp float;uniform float IIIlllllllIIIllIl,lIIIlllllIllIl,IIIlllIlIIllll;uniform sampler2D IlllIIlIlllIll;uniform vec2 IIlIlIIlIlIllI,IllIlllIlIIlllI;out vec4 lIIlIIIIIlIlIlllIIIIlIIl;float lIlIIllllIllIll(float IIIlIIlIIIlllIII){IIIlIIlIIIlllIII-=0.;return sin(IIIlIIlIIIlllIII);}float lIlIlllllIllIll(float IIIlIIlIIIlllIII){IIIlIIlIIIlllIII+=acos(0.);return sin(IIIlIIlIIIlllIII);}mat2 lIIllIIlIIIllIl(float IIIlIIlIIIlllIII){return mat2(lIlIlllllIllIll(IIIlIIlIIIlllIII),-lIlIIllllIllIll(IIIlIIlIIIlllIII),lIlIIllllIllIll(IIIlIIlIIIlllIII),lIlIlllllIllIll(IIIlIIlIIIlllIII));}mat2 lIIllIIlIIIlllI(float IIIlIIlIIIlllIII){return mat2(lIlIIllllIllIll(IIIlIIlIIIlllIII),-lIlIlllllIllIll(IIIlIIlIIIlllIII),lIlIlllllIllIll(IIIlIIlIIIlllIII),lIlIIllllIllIll(IIIlIIlIIIlllIII));}float IllllIIlIllII(float llIIllIllIIIllI){return fract(lIlIIllllIllIll(llIIllIllIIIllI)*43758.5453);}float llIlIIllllIII(vec2 IIIlIIlIIIlllIII){vec2 IIllIlIIlllI=floor(IIIlIIlIIIlllIII),lIlIllIIIIIlIl=fract(IIIlIIlIIIlllIII);lIlIllIIIIIlIl=lIlIllIIIIIlIl*lIlIllIIIIIlIl*(3.-2.*lIlIllIIIIIlIl);float lIlIlIlIlIlIIl=IIllIlIIlllI.x+IIllIlIIlllI.y*57.;return mix(mix(IllllIIlIllII(lIlIlIlIlIlIIl),IllllIIlIllII(lIlIlIlIlIlIIl+1.),lIlIllIIIIIlIl.x),mix(IllllIIlIllII(lIlIlIlIlIlIIl+57.),IllllIIlIllII(lIlIlIlIlIlIIl+58.),lIlIllIIIIIlIl.x),lIlIllIIIIIlIl.y);}vec2 lllIIIIIIllIlIIIlI(vec2 IlllIIlIIIIlIIII,float lIIIIlllIIIIllIlIlI,vec2 IlIlIIIIlIlllIlIII){float lIIlIllIIIlIl=llIlIIllllIII(IlllIIlIIIIlIIII*vec2(1)*3.5+.1)*4.2831*mix(.2,1.,IIIlllllllIIIllIl);IlllIIlIIIIlIIII+=vec2(-1,.5);lIIlIllIIIlIl-=lIIIIlllIIIIllIlIlI;return vec2(lIlIlllllIllIll(lIIlIllIIIlIl),lIlIIllllIllIll(lIIlIllIIIlIl));}const mat3 lIIllIIIlllIl=mat3(1.,.02,.002,.02,1.,.008,.002,.02,1.),lIIIlllIIIIll=mat3(1.022,-.02,-.002,-.02,1.028,-.008,-.002,-.02,1.022);void main(){vec2 lIIIlIIllIlIIlI=lIlIIllllIllIll(lIIIlllllIllIl*.2)*.01+.5+gl_FragCoord.xy/IIlIlIIlIlIllI.xy,lIIllIIlIIIllI=lIIIlIIllIlIIlI*.77f+IllIlllIlIIlllI;lIIllIIlIIIllI.x*=IIlIlIIlIlIllI.x/IIlIlIIlIlIllI.y;float lIIlIIlIIlIIIlII=gl_FragCoord.x/max(IIlIlIIlIlIllI.x,IIlIlIIlIlIllI.y),lIIIlIllIllIlIIl=0.f;vec3 lIIIlIlIIIlIlIIl=vec3(0);vec2 lIlIIlIlIIIllIll=lIIllIIlIIIllI;for(int IllIlIIlIIlllllIIIl=0;IllIlIIlIIlllllIIIl<8;IllIlIIlIIlllllIIIl++){bool lIlIlIIllIllIIll=IllIlIIlIIlllllIIIl%2==0;vec2 lIlllIlllIlllII=lllIIIIIIllIlIIIlI(lIIllIIlIIIllI,lIIlIIlIIlIIIlII,lIIIlIIllIlIIlI),lIllIIlIIlIIIll=lIlllIlllIlllII;float lIIlIlIIlIIlIllI=float(IllIlIIlIIlllllIIIl)/8.f;vec3 llIIlIIIIlIIlIII=texture(IlllIIlIlllIll,-lIIIlllllIllIl*.01+.8*lIIllIIlIIIllI*lIIllIIlIIIllIl(-lIIIlllllIllIl*.2)+vec2(IIIlllIlIIllll*.3*(float(lIlIlIIllIllIIll)*2.-1.)*lIIllIIlIIIlllI(lIIIlllllIllIl*.2+1.5))).xyz;lIIIlIlIIIlIlIIl+=llIIlIIIIlIIlIII;lIIIlIllIllIlIIl+=4.f*lIIlIlIIlIIlIllI*(1.f-lIIlIlIIlIIlIllI);lIIllIIlIIIllI+=.01f*lIllIIlIIlIIIll*(lIlIIllllIllIll(lIIIlllllIllIl)*4.8+.8);lIlIIlIlIIIllIll+=.05f*lIllIIlIIlIIIll;}lIIIlIlIIIlIlIIl/=lIIIlIllIllIlIIl;lIIIlIlIIIlIlIIl*=1.6f;lIIIlIlIIIlIlIIl=1.f-exp(-lIIIlIlIIIlIlIIl);lIIIlIlIIIlIlIIl=pow(lIIIlIlIIIlIlIIl,vec3(2.2));lIIIlIlIIIlIlIIl*=.8f;lIIlIIIIIlIlIlllIIIIlIIl=vec4(lIIIlIlIIIlIlIIl,1);}`,Pe=`#version 300 es
|
|
41
|
+
precision highp float;
|
|
42
|
+
|
|
43
|
+
uniform sampler2D src;
|
|
44
|
+
in vec2 f_v_coord;
|
|
45
|
+
out vec4 fragColor;
|
|
46
|
+
|
|
47
|
+
/* Gradient noise from Jorge Jimenez's presentation: */
|
|
48
|
+
/* http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare */
|
|
49
|
+
float gradientNoise(in vec2 uv) {
|
|
50
|
+
return fract(52.9829189f * fract(dot(uv, vec2(0.06711056f, 0.00583715f))));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void main() {
|
|
54
|
+
vec2 tex_coord = f_v_coord;
|
|
55
|
+
float dither = (1.0f / 255.0f) * gradientNoise(gl_FragCoord.xy) - (0.5f / 255.0f);
|
|
56
|
+
vec4 color = texture(src, tex_coord);
|
|
57
|
+
color += dither;
|
|
58
|
+
fragColor = color;
|
|
59
|
+
}
|
|
60
|
+
`,Ae="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAYUklEQVR4nH3bV89VVRcF4IX7qNgVe8WKvaIiNsCuYCKCSEg0JCYm/gTjzf4R3njhlRdeWKKi2AvYEBV7b1ixY2+ofPuZcbwxXzie5OQ9Z5+11pxzjDHnKnu/k0477bSN+++/fzvyyCPbdttt17766qu2YcOG9ttvv7U33nijffHFF23atGntgAMOaN98803bc88926RJk9pnn31W10855ZT2888/1/vrr79ur732Wjv00EPbgQce2NavX99eeOGF+nvmmWfWuD4fc8wx1ffDDz9sTz31VPv000/bRx99VL/vsssu7eCDDy57hxxySPv222/L1saNG9vatWsbX19++eXyhb9//PFH23HHHdsHH3zQLrrooorjxRdfrPbG+/jjj9u6devaX3/91aZMmdImT57cdt1114lYu5133rnfeuut28yZM9t+++3XVq9e3T7//PMa9Ljjjqu/m222WTn73HPPtR122KF99913bcsttyyQnnzyybbbbrvVm4MMAe37778vUATIkaOPPrqCe+KJJ9qPP/7Ydt9993bvvfe2lStXtvfee69ttdVW7bzzzmvbbLNN++STT9rUqVPL7jvvvNP+/PPP8o1NNn7//fcakx3XL7300moPyC222KL8ev/99ws8Y2s3xFmAIpD9H374of36669txBEIvf3224UmR1w74YQTyhlgHHTQQeU845Bfs2ZN23fffcsQRn/55Zf6jQJOP/30GvjLL78sMPbee+8y6rM2gvPea6+9yg7Htt1223bSSSe1nXbaqWwC+K677iq2qMU1yqKK0WhUAWGREruuq3GBw8dVq1ZV4Pvss08744wzSgns/fTTT+UzoigIAL53gyM95P7+++9Cj1OQz+ACwb7PHAGA3133phKyY/TVV1+t3zHEAUa8t99++1IDJwAsKFIWkFQQOFaeffbZ9u6775aTgBXskKIVhDEBSxFJCaznOoCpNdJHGlvGNRa5s8N3PiLg5JNPbt1goNfIYKeeemo74ogjKmC5yxlIY/D5559v999/f8nxrLPOqsCBwknIkxcmpISXYFesWFGqIlNKck3bGTNmFNDyltPaUBXnsMWGfKZCeQto/QQqmOnTpxegvvNVH4G7Jg4AG4P8qVM6jCN5JDc5QYZyHHrynFGdDMBhaHJG8ZAy55xzThkFisABBxBsH3/88TUmprAM7VdeeaWcNz5wjSPoPfbYowDj+FFHHVWOC9bYWEuQ0ss1zALGi+qQRxUI8XrrrbdKfbFD5r6rSXzip2uPP/541aNuyJOeDMlCAVQLBI71Cy64oAAAzOabb16VnNzlELlTiNyEsOAES1bkDQhjcJIj2kghQLsmZ+W6AkyalCZAvwFn2bJl7b777qtAyFw9ELxgfNcWKcbBqOColB1KiF9qkBkJqeoNtehDAWaLETR9eemll+oHjPhOGRgnT1Md+WAYIJwCkoJHRgDhoP7amj4ffPD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/ArpGk6UigipbxpEdWZoDEgBsWFGBrK42057D+7CFCigFA1RdQFmimtdxwzQMQpmkAZjutb9J4UyTXjRFS1kGFzp1f10hZB/muBvgLWZ2156w0seBRADmHee2sAchdgcMKY8aVyzl2pxQqE6xUkM+CBAC2MJj/CEOCswn+ZLWKCAqSotm18tl4iimfkaCQjiN5xAD5cUQ+GQBC8kwApjvIQk9OcoBBjDvREQgQGDVD5CwhMmSIPLURZJ48kfO2o9Irx+P2F5ziKOY4zSbV5Ukw9gFOMcayiKrpbPBRH2Pl2UGAq0m+U6mZBxh5WBtp/wOJEZce9OdHHAAAAABJRU5ErkJggg==",K=(()=>{const o=document.createElement("img");return o.src=Ae,o})();function ve(o,i,e){const t=o.data,s=o.width,l=o.height;let r,n,h,c,I,d,m,f,p,y,u,g,E;const L=s-1,w=l-1,T=i+1,b=i+T,S=i+1,M=i+S,x=1/(b*M),P=[],A=[],v=[],C=[],O=[],_=[];for(;e-- >0;){for(E=g=0,d=0;d<l;d++){for(r=t[E]*T,n=t[E+1]*T,h=t[E+2]*T,c=t[E+3]*T,m=1;m<=i;m++)f=E+((m>L?L:m)<<2),r+=t[f++],n+=t[f++],h+=t[f++],c+=t[f];for(I=0;I<s;I++)P[g]=r,A[g]=n,v[g]=h,C[g]=c,d===0&&(O[I]=Math.min(I+T,L)<<2,_[I]=Math.max(I-i,0)<<2),p=E+O[I],y=E+_[I],r+=t[p++]-t[y++],n+=t[p++]-t[y++],h+=t[p++]-t[y++],c+=t[p]-t[y],g++;E+=s<<2}for(I=0;I<s;I++){for(u=I,r=P[u]*S,n=A[u]*S,h=v[u]*S,c=C[u]*S,m=1;m<=i;m++)u+=m>w?0:s,r+=P[u],n+=A[u],h+=v[u],c+=C[u];for(g=I<<2,d=0;d<l;d++)t[g]=r*x+.5|0,t[g+1]=n*x+.5|0,t[g+2]=h*x+.5|0,t[g+3]=c*x+.5|0,I===0&&(O[d]=Math.min(d+S,w)*s,_[d]=Math.max(d-i,0)*s),p=I+O[d],y=I+_[d],r+=P[p]-P[y],n+=A[p]-A[y],h+=v[p]-v[y],c+=C[p]-C[y],g+=s<<2}}}function Me(o,i){const e=o.data;for(let t=0;t<e.length;t+=4){const s=e[t],l=e[t+1],r=e[t+2],n=e[t+3],h=s*.3+l*.59+r*.11;e[t]=h*(1-i)+s*i,e[t+1]=h*(1-i)+l*i,e[t+2]=h*(1-i)+r*i,e[t+3]=n}}function Re(o,i){const e=o.data;for(let t=0;t<e.length;t+=4){const s=e[t],l=e[t+1],r=e[t+2],n=e[t+3];e[t]=(s-128)*i+128,e[t+1]=(l-128)*i+128,e[t+2]=(r-128)*i+128,e[t+3]=n}}class Y{constructor(i,e,t,s="unknown"){a(this,"gl");a(this,"program");a(this,"vertexShader");a(this,"fragmentShader");a(this,"coordPos");a(this,"notFoundUniforms",new Set);this.label=s,this.gl=i,this.vertexShader=this.createShader(i.VERTEX_SHADER,e),this.fragmentShader=this.createShader(i.FRAGMENT_SHADER,t),this.program=this.createProgram();const l=i.getAttribLocation(this.program,"v_coord");if(l===-1)throw new Error(`Failed to get attribute location v_coord for "${this.label}"`);this.coordPos=l}createShader(i,e){const t=this.gl,s=t.createShader(i);if(!s)throw new Error("Failed to create shader");if(t.shaderSource(s,e),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new Error(`Failed to compile shader for type ${i} "${this.label}": ${t.getShaderInfoLog(s)}`);return s}createProgram(){const i=this.gl,e=i.createProgram();if(!e)throw new Error("Failed to create program");if(i.attachShader(e,this.vertexShader),i.attachShader(e,this.fragmentShader),i.linkProgram(e),i.validateProgram(e),!i.getProgramParameter(e,i.LINK_STATUS)){const t=i.getProgramInfoLog(e);throw i.deleteProgram(e),new Error(`Failed to link program "${this.label}": ${t}`)}return e}use(){const i=this.gl;i.useProgram(this.program),i.vertexAttribPointer(this.coordPos,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(this.coordPos)}warnUniformNotFound(i){this.notFoundUniforms.has(i)||(this.notFoundUniforms.add(i),console.warn(`Failed to get uniform location for program "${this.label}": ${i}`))}setUniform1f(i,e){const t=this.gl,s=t.getUniformLocation(this.program,i);s?t.uniform1f(s,e):this.warnUniformNotFound(i)}setUniform2f(i,e,t){const s=this.gl,l=s.getUniformLocation(this.program,i);l?s.uniform2f(l,e,t):this.warnUniformNotFound(i)}setUniform1i(i,e){const t=this.gl,s=t.getUniformLocation(this.program,i);s?t.uniform1i(s,e):this.warnUniformNotFound(i)}dispose(){const i=this.gl;i.deleteShader(this.vertexShader),i.deleteShader(this.fragmentShader),i.deleteProgram(this.program)}}class Q{constructor(i,e,t){a(this,"fb");a(this,"tex");a(this,"_size");this.gl=i,this._size=[e,t];const s=i.createFramebuffer();if(!s)throw new Error("Can't create framebuffer");const l=i.createTexture();if(!l)throw new Error("Failed to create texture");this.fb=s,this.tex=l,i.bindFramebuffer(i.FRAMEBUFFER,s),i.bindTexture(i.TEXTURE_2D,l),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,l,0),this.resize(e,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.MIRRORED_REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.MIRRORED_REPEAT)}get size(){return this._size}resize(i,e){const t=this.gl;this.bind(),t.bindTexture(t.TEXTURE_2D,this.tex),t.getExtension("EXT_color_buffer_float")?t.texImage2D(t.TEXTURE_2D,0,t.RGBA32F,i,e,0,t.RGBA,t.FLOAT,null):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i,e,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.MIRRORED_REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.MIRRORED_REPEAT)}bind(){const i=this.gl;i.bindFramebuffer(i.FRAMEBUFFER,this.fb)}active(i=this.gl.TEXTURE0){this.gl.activeTexture(i),this.gl.bindTexture(this.gl.TEXTURE_2D,this.tex)}dispose(){this.gl.deleteFramebuffer(this.fb),this.gl.deleteTexture(this.tex)}}class ${constructor(i,e,t,s){a(this,"gl");a(this,"buffer");a(this,"type");a(this,"data");a(this,"usage");a(this,"length");this.gl=i,this.type=e,this.data=t,this.usage=s;const l=i.createBuffer();if(!l)throw new Error("Failed to create buffer");this.buffer=l,this.length=t.byteLength,i.bindBuffer(e,this.buffer),i.bufferData(e,t,s)}bind(){this.gl.bindBuffer(this.type,this.buffer)}dispose(){this.gl.deleteBuffer(this.buffer)}}class De{constructor(i,e,t,s,l){a(this,"albumTexture");a(this,"alpha",0);this.gl=i,this.mainProgram=e,this.vertexBuffer=t,this.indexBuffer=s;const r=i.createTexture();if(!r)throw new Error("Failed to create texture");this.albumTexture=r,i.bindTexture(i.TEXTURE_2D,r),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,l),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.MIRRORED_REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.MIRRORED_REPEAT)}draw(i){const e=this.gl;this.mainProgram.use(),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.albumTexture),this.mainProgram.setUniform1i(i,0),e.drawArrays(e.TRIANGLE_STRIP,0,4)}dispose(){this.gl.deleteTexture(this.albumTexture)}}class Fe{constructor(i){a(this,"tex");a(this,"alpha",0);this.gl=i;const e=i.createTexture();if(!e)throw new Error("Failed to create texture");this.tex=e,K.decode().then(()=>{i.bindTexture(i.TEXTURE_2D,e),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,K),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.REPEAT)})}active(i=this.gl.TEXTURE1){this.gl.activeTexture(i),this.gl.bindTexture(this.gl.TEXTURE_2D,this.tex)}dispose(){this.gl.deleteTexture(this.tex)}}const F=class F extends Z{constructor(e){super(e);a(this,"hasLyric",!0);a(this,"hasLyricValue",1);a(this,"maxFPS",30);a(this,"lastTickTime",0);a(this,"lastFrameTime",0);a(this,"_lowFreqVolume",1);a(this,"paused",!1);a(this,"staticMode",!1);a(this,"gl",this.setupGL());a(this,"reduceImageSizeCanvas",new OffscreenCanvas(128,128));a(this,"tickHandle",0);a(this,"sprites",[]);a(this,"ampTransition",0);a(this,"playTime",0);a(this,"frameTime",0);a(this,"IllIlllIlIIlllI",[-.1,0]);a(this,"mainProgram",new Y(this.gl,G,xe,"main"));a(this,"blendProgram",new Y(this.gl,G,Le,"blend"));a(this,"copyProgram",new Y(this.gl,G,Se,"copy"));a(this,"noiseProgram",new Y(this.gl,G,Pe,"noise"));a(this,"vertexBuffer",new $(this.gl,this.gl.ARRAY_BUFFER,F.rawVertexBuffer,this.gl.STATIC_DRAW));a(this,"indexBuffer",new $(this.gl,this.gl.ELEMENT_ARRAY_BUFFER,F.rawIndexBuffer,this.gl.STATIC_DRAW));a(this,"noiseTexture",new Fe(this.gl));a(this,"fb");a(this,"historyFrameBuffer",[]);a(this,"_currentSize",[0,0]);a(this,"_targetSize",[0,0]);a(this,"renderSize",[0,0]);a(this,"pixelSize",[0,0]);this.canvas=e;const t=this.gl;t.enable(this.gl.BLEND),t.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.requestTick();const s=e.getBoundingClientRect(),l=s.width*window.devicePixelRatio*this.currerntRenderScale,r=s.height*window.devicePixelRatio*this.currerntRenderScale;this.fb=[new Q(this.gl,l,r),new Q(this.gl,l,r)];for(const n of this.fb)n.bind(),t.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA);this.historyFrameBuffer=new Array(2).fill(0).map(()=>new Q(this.gl,l,r)),this.onResize(l,r)}onTick(e){if(this.tickHandle=0,this.paused)return;const t=e-this.lastTickTime,s=e-this.lastFrameTime;if(this.lastFrameTime=e,t<1e3/this.maxFPS){this.requestTick();return}this.hasLyric&&(this.playTime+=s*this.flowSpeed*.2),this.frameTime+=s,this.onRedraw(this.playTime,s)&&this.staticMode||this.requestTick(),this.lastTickTime=e,this.ampTransition}onResize(e,t){this._targetSize=[Math.max(1,Math.round(e)),Math.max(1,Math.round(t))],this.staticMode&&this.requestTick()}checkResize(){if(this._currentSize[0]===this._targetSize[0]&&this._currentSize[1]===this._targetSize[1])return;this._currentSize=[...this._targetSize];const[e,t]=this._targetSize,s=Math.round(Math.max(e/this.currerntRenderScale,e)),l=Math.round(Math.max(t/this.currerntRenderScale,t));this.renderSize=[e,t],this.canvas.width=s,this.canvas.height=l,this.pixelSize=[s,l],this.gl.viewport(0,0,s,l);for(const r of this.fb)r.resize(e,t);for(const r of this.historyFrameBuffer)r.resize(s,l)}requestTick(){this.tickHandle||(this.tickHandle=requestAnimationFrame(e=>this.onTick(e)))}drawScreen(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}bindDefaultFrameBuffer(){this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null)}onRedraw(e,t){this.checkResize(),this.hasLyricValue=(this.hasLyricValue*19+(this.hasLyric?1:0))/20;const s=this.gl;this.vertexBuffer.bind(),this.indexBuffer.bind(),this.mainProgram.use(),this.noiseTexture.active(),this.mainProgram.setUniform1i("noisetex",1),this.mainProgram.setUniform2f("IIlIlIIlIlIllI",this.renderSize[0],this.renderSize[1]),this.mainProgram.setUniform1f("lIIIlllllIllIl",this.hasLyric?e/1e3:0),this.mainProgram.setUniform1f("IIIlllllllIIIllIl",this.hasLyricValue),this.mainProgram.setUniform1f("IIIlllIlIIllll",this.hasLyric?this._lowFreqVolume:0),this.mainProgram.setUniform2f("IllIlllIlIIlllI",this.IllIlllIlIIlllI[0],this.IllIlllIlIIlllI[1]);const[l,r]=this.fb;r.bind(),s.clearColor(0,0,0,0),s.clear(this.gl.COLOR_BUFFER_BIT);for(const c of this.sprites)l.bind(),s.clearColor(0,0,0,0),s.clear(this.gl.COLOR_BUFFER_BIT),this.mainProgram.use(),c.draw("IlllIIlIlllIll"),r.bind(),this.blendProgram.use(),l.active(),this.blendProgram.setUniform1i("src",0),this.blendProgram.setUniform1f("lerp",c.alpha),this.blendProgram.setUniform1f("scale",this.currerntRenderScale),this.drawScreen(),c.alpha=Math.min(1,c.alpha+t/200);if(this.noiseProgram.use(),this.noiseProgram.setUniform1i("src",0),l.bind(),r.active(),this.bindDefaultFrameBuffer(),this.drawScreen(),this.sprites.length>1&&this.sprites[this.sprites.length-1].alpha>=1)for(const I of this.sprites.splice(0,this.sprites.length-1))I.dispose();const n=this.sprites.length===1&&this.sprites[0].alpha>=1,h=this.hasLyric?this.hasLyricValue>1e-5:this.hasLyricValue<.99999;return n||!h}copyFrameBuffer(e,t=null){e!==t&&(e.active(this.gl.TEXTURE0),this.copyProgram.use(),t?t.bind():this.bindDefaultFrameBuffer(),this.copyProgram.setUniform1i("src",0),this.drawScreen())}setupGL(){const e=this.canvas.getContext("webgl2",{alpha:!0,depth:!1,powerPreference:"low-power"});if(!e)throw new Error("WebGL2 not supported");return this.gl=e,e.enable(e.BLEND),e.disable(e.DEPTH_TEST),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.getExtension("EXT_color_buffer_float")||console.warn("EXT_color_buffer_float not supported"),e.getExtension("EXT_float_blend")||console.warn("EXT_float_blend not supported"),e.getExtension("OES_texture_float_linear")||console.warn("OES_texture_float_linear not supported"),e}setLowFreqVolume(e){this._lowFreqVolume=e}setStaticMode(e){this.staticMode=e,this.lastFrameTime=performance.now(),this.requestTick()}setFPS(e){this.maxFPS=e}pause(){this.tickHandle&&(cancelAnimationFrame(this.tickHandle),this.tickHandle=0),this.paused=!0}resume(){this.paused=!1,this.requestTick()}async setAlbum(e,t=!1){if(typeof e=="string"&&e.trim().length===0)throw new Error("Empty album url");let s=null,l=5;for(console.log("setAlbum",e);!s&&l>0;)try{typeof e=="string"?s=await le(e,t):s=await re(e)}catch(p){console.warn(`failed on loading album resource, retrying (${l})`,{albumSource:e,error:p}),l--}if(console.log("loaded album resource",s),!s)return;const r=this.reduceImageSizeCanvas,n=r.getContext("2d");if(!n)throw new Error("Failed to create canvas context");n.clearRect(0,0,r.width,r.height);const h=10,c=s instanceof HTMLVideoElement?s.videoWidth:s.naturalWidth,I=s instanceof HTMLVideoElement?s.videoHeight:s.naturalHeight;if(c*I===0)throw new Error("Invalid image size");n.drawImage(s,0,0,c,I,0,0,r.width,r.height);const d=n.getImageData(0,0,r.width,r.height);Re(d,.8),Me(d,1.5),ve(d,h,4);const m=new De(this.gl,this.mainProgram,this.vertexBuffer,this.indexBuffer,d);this.sprites.push(m),this.playTime=Math.random()*1e5,this.lastFrameTime=performance.now(),console.info(Math.random()*1e4);const f=Number.parseInt((Math.random()*1e4).toFixed(0))%3;f===0?this.IllIlllIlIIlllI=[-1.3,-.9]:f===1?this.IllIlllIlIIlllI=[-1.1,-.9]:this.IllIlllIlIIlllI=[-1.3,-.9],this.requestTick()}setHasLyric(e){this.hasLyric=e,this.requestTick()}getElement(){return this.canvas}dispose(){super.dispose(),this.vertexBuffer.dispose(),this.indexBuffer.dispose(),this.noiseTexture.dispose();for(const e of this.sprites)e.dispose();this.copyProgram.dispose(),this.blendProgram.dispose(),this.mainProgram.dispose();for(const e of this.fb)e.dispose();for(const e of this.historyFrameBuffer)e.dispose();this.tickHandle&&(cancelAnimationFrame(this.tickHandle),this.tickHandle=0)}};a(F,"rawVertexBuffer",new Float32Array([-1,-1,1,-1,-1,1,1,1])),a(F,"rawIndexBuffer",new Uint16Array([0,1,2,1,2,3]));let j=F;class J{constructor(i,e){a(this,"element");a(this,"renderer");this.renderer=i,this.element=e,e.style.pointerEvents="none",e.style.zIndex="-1",e.style.contain="strict"}static new(i){const e=document.createElement("canvas");return new J(new i(e),e)}setRenderScale(i){this.renderer.setRenderScale(i)}setFlowSpeed(i){this.renderer.setFlowSpeed(i)}setStaticMode(i){this.renderer.setStaticMode(i)}setFPS(i){this.renderer.setFPS(i)}pause(){this.renderer.pause()}resume(){this.renderer.resume()}setLowFreqVolume(i){this.renderer.setLowFreqVolume(i)}setHasLyric(i){this.renderer.setHasLyric(i)}setAlbum(i,e){return this.renderer.setAlbum(i,e)}getElement(){return this.element}dispose(){this.renderer.dispose(),this.element.remove()}}const Be=(o,i)=>o.size===i.size&&[...o].every(e=>i.has(e));function Ce(o){return e=>(o(e+.001)-o(e-.001))/(2*.001)}function ee(o){return Ce(o)}class U{constructor(i=0){a(this,"currentPosition",0);a(this,"targetPosition",0);a(this,"currentTime",0);a(this,"params",{});a(this,"currentSolver");a(this,"getV");a(this,"getV2");a(this,"queueParams");a(this,"queuePosition");this.targetPosition=i,this.currentPosition=this.targetPosition,this.currentSolver=()=>this.targetPosition,this.getV=()=>0,this.getV2=()=>0}resetSolver(){const i=this.getV(this.currentTime);this.currentTime=0,this.currentSolver=ze(this.currentPosition,i,this.targetPosition,0,this.params),this.getV=ee(this.currentSolver),this.getV2=ee(this.getV)}arrived(){return Math.abs(this.targetPosition-this.currentPosition)<.01&&this.getV(this.currentTime)<.01&&this.getV2(this.currentTime)<.01&&this.queueParams===void 0&&this.queuePosition===void 0}setPosition(i){this.targetPosition=i,this.currentPosition=i,this.currentSolver=()=>this.targetPosition,this.getV=()=>0,this.getV2=()=>0}update(i=0){this.currentTime+=i,this.currentPosition=this.currentSolver(this.currentTime),this.queueParams&&(this.queueParams.time-=i,this.queueParams.time<=0&&this.updateParams({...this.queueParams})),this.queuePosition&&(this.queuePosition.time-=i,this.queuePosition.time<=0&&this.setTargetPosition(this.queuePosition.position)),this.arrived()&&this.setPosition(this.targetPosition)}updateParams(i,e=0){e>0?this.queueParams={...this.queuePosition??{},...i,time:e}:(this.queuePosition=void 0,this.params={...this.params,...i},this.resetSolver())}setTargetPosition(i,e=0){e>0?this.queuePosition={...this.queuePosition??{},position:i,time:e}:(this.queuePosition=void 0,this.targetPosition=i,this.resetSolver())}getCurrentPosition(){return this.currentPosition}}function ze(o,i,e,t=0,s){const l=(s==null?void 0:s.soft)??!1,r=(s==null?void 0:s.stiffness)??100,n=(s==null?void 0:s.damping)??10,h=(s==null?void 0:s.mass)??1,c=e-o;if(l||1<=n/(2*Math.sqrt(r*h))){const p=-Math.sqrt(r/h),y=-p*c-i;return u=>(u-=t,u<0?o:e-(c+u*y)*Math.E**(u*p))}const I=Math.sqrt(4*h*r-n**2),d=(n*c-2*h*i)/I,m=.5*I/h,f=-(.5*n)/h;return p=>(p-=t,p<0?o:e-(Math.cos(p*m)*c+Math.sin(p*m)*d)*Math.E**(p*f))}class ke{constructor(i){a(this,"element",document.createElement("div"));a(this,"left",0);a(this,"top",0);a(this,"delay",0);a(this,"lineSize",[0,0]);a(this,"lineTransforms",{posX:new U(0),posY:new U(0)});a(this,"lastStyle","");this.lyricPlayer=i,this.element.setAttribute("class",this.lyricPlayer.style.classes.lyricLine),this.rebuildStyle()}measureSize(){return[this.element.clientWidth,this.element.clientHeight]}show(){this.rebuildStyle()}hide(){this.rebuildStyle()}rebuildStyle(){let i=`transform:translate(${this.lineTransforms.posX.getCurrentPosition().toFixed(2)}px,${this.lineTransforms.posY.getCurrentPosition().toFixed(2)}px);`;!this.lyricPlayer.getEnableSpring()&&this.isInSight&&(i+=`transition-delay:${this.delay}ms;`),i!==this.lastStyle&&(this.lastStyle=i,this.element.setAttribute("style",i))}getElement(){return this.element}setTransform(i=this.left,e=this.top,t=!1,s=0){this.left=i,this.top=e,this.delay=s*1e3|0,t||!this.lyricPlayer.getEnableSpring()?(t&&this.element.classList.add(this.lyricPlayer.style.classes.tmpDisableTransition),this.lineTransforms.posX.setPosition(i),this.lineTransforms.posY.setPosition(e),this.lyricPlayer.getEnableSpring()?this.rebuildStyle():this.show(),t&&requestAnimationFrame(()=>{this.element.classList.remove(this.lyricPlayer.style.classes.tmpDisableTransition)})):(this.lineTransforms.posX.setTargetPosition(i,s),this.lineTransforms.posY.setTargetPosition(e,s))}update(i=0){this.lyricPlayer.getEnableSpring()&&(this.lineTransforms.posX.update(i),this.lineTransforms.posY.update(i),this.isInSight?this.show():this.hide())}get isInSight(){const i=this.lineTransforms.posX.getCurrentPosition(),e=this.lineTransforms.posY.getCurrentPosition(),t=i+this.lineSize[0],s=e+this.lineSize[1],l=this.lyricPlayer.size[0],r=this.lyricPlayer.size[1];return!(i>l||e>r||t<0||s<0)}dispose(){this.element.remove()}}function Ue(o){const e=2.5949095;return o<.5?Math.pow(2*o,2)*((e+1)*2*o-e)/2:(Math.pow(2*o-2,2)*((e+1)*(o*2-2)+e)+2)/2}const D=(o,i,e)=>Math.max(o,Math.min(i,e));class Oe{constructor(i){a(this,"element",document.createElement("div"));a(this,"dot0",document.createElement("span"));a(this,"dot1",document.createElement("span"));a(this,"dot2",document.createElement("span"));a(this,"left",0);a(this,"top",0);a(this,"scale",1);a(this,"playing",!0);a(this,"lastStyle","");a(this,"currentInterlude");a(this,"currentTime",0);a(this,"interludeTime",0);a(this,"targetBreatheDuration",1500);this.lyricPlayer=i,this.element.className=this.lyricPlayer.style.classes.interludeDots,this.element.appendChild(this.dot0),this.element.appendChild(this.dot1),this.element.appendChild(this.dot2)}getElement(){return this.element}setTransform(i=this.left,e=this.top){this.left=i,this.top=e,this.update()}setInterlude(i){this.currentInterlude=i,this.currentTime=(i==null?void 0:i[0])??0}pause(){this.playing=!1}resume(){this.playing=!0}update(i=0){if(!this.playing)return;this.currentTime+=i;let e="";if(e+=`transform:translate(${this.left.toFixed(2)}px, ${this.top.toFixed(2)}px)`,this.currentInterlude){const t=this.currentInterlude[1]-this.currentInterlude[0],s=this.currentTime-this.currentInterlude[0];if(s<=t){const l=t/Math.ceil(t/this.targetBreatheDuration);let r=1,n=1;r*=Math.sin(1.5*Math.PI-s/l*2)/20+1,s<1e3&&(r*=1-((1e3-s)/1e3)**2),s<500?n=0:s<1e3&&(n*=(s-500)/500),t-s<750&&(r*=1-Ue((750-(t-s))/750/2)),t-s<375&&(n*=D(0,(t-s)/375,1));const h=Math.max(0,t-750);r=Math.max(0,r)*.7,e+=` scale(${r})`;const c=D(.25,s*3/h*.75,1),I=D(.25,(s-h/3)*3/h*.75,1),d=D(.25,(s-h/3*2)*3/h*.75,1);this.dot0.style.opacity=`${D(0,Math.max(0,n*c),1)}`,this.dot1.style.opacity=`${D(0,Math.max(0,n*I),1)}`,this.dot2.style.opacity=`${D(0,Math.max(0,n*d),1)}`}else e+=" scale(0)",this.dot0.style.opacity="0",this.dot1.style.opacity="0",this.dot2.style.opacity="0"}else e+=" scale(0)",this.dot0.style.opacity="0",this.dot1.style.opacity="0",this.dot2.style.opacity="0";e+=";",this.lastStyle!==e&&(this.element.setAttribute("style",e),this.lastStyle=e)}dispose(){this.element.remove()}}function _e(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ne(o,i=1,e={x:0,y:0}){const[t,s]=[e.x,e.y];return[o[0]*i,o[1]*i,o[2]*i,o[3],o[4]*i,o[5]*i,o[6]*i,o[7],o[8]*i,o[9]*i,o[10]*i,o[11],o[12]-t*i+t,o[13]-s*i+s,o[14],o[15]]}function qe(o,i=4){const e=(t,s)=>t.toFixed(i);return`matrix3d(${o.map(e).join(", ")})`}function Ge(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Ye=4,Ve=.001,He=1e-7,We=10,z=11,V=1/(z-1),Xe=typeof Float32Array=="function";function ne(o,i){return 1-3*i+3*o}function ae(o,i){return 3*i-6*o}function oe(o){return 3*o}function W(o,i,e){return((ne(i,e)*o+ae(i,e))*o+oe(i))*o}function he(o,i,e){return 3*ne(i,e)*o*o+2*ae(i,e)*o+oe(i)}function Qe(o,i,e,t,s){var l,r,n=0;do r=i+(e-i)/2,l=W(r,t,s)-o,l>0?e=r:i=r;while(Math.abs(l)>He&&++n<We);return r}function je(o,i,e,t){for(var s=0;s<Ye;++s){var l=he(i,e,t);if(l===0)return i;var r=W(i,e,t)-o;i-=r/l}return i}function Ze(o){return o}var Je=function(i,e,t,s){if(!(0<=i&&i<=1&&0<=t&&t<=1))throw new Error("bezier x values must be in [0, 1] range");if(i===e&&t===s)return Ze;for(var l=Xe?new Float32Array(z):new Array(z),r=0;r<z;++r)l[r]=W(r*V,i,t);function n(h){for(var c=0,I=1,d=z-1;I!==d&&l[I]<=h;++I)c+=V;--I;var m=(h-l[I])/(l[I+1]-l[I]),f=c+m*V,p=he(f,i,t);return p>=Ve?je(h,f,i,t):p===0?f:Qe(h,c,c+V,i,t)}return function(c){return c===0?0:c===1?1:W(n(c),e,s)}};const te=Ge(Je),Ke=/^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u,H=32,ce=(o,i)=>e=>Math.min(1,Math.max(0,(e-o)/(i-o))),B=.4,$e=ce(0,B),et=ce(B,1),Ie=o=>{const i=te(.3,0,.25,1),e=te(.5,0,.3,1);return t=>t<o?i($e(t)):1-e(et(t))},tt=Ie(B);function ie(o,i=0,e="rgba(0,0,0,0.85)",t="rgba(0,0,0,0.25)"){const s=2+o+i,l=o/s,r=(1-l)/2;return[`linear-gradient(to right,${e} ${r*100}%,${t} ${(r+l)*100}%)`,s]}function it(o){const i=[];for(const l of o){const r=l.word.replace(/\s/g,"").length,n=l.word.split(" ").filter(h=>h.trim().length>0);if(n.length>1){l.word.startsWith(" ")&&i.push({word:" ",startTime:0,endTime:0});let h=0;for(const c of n){const I={word:c,startTime:l.startTime+h/r*(l.endTime-l.startTime),endTime:l.startTime+(h+c.length)/r*(l.endTime-l.startTime)};i.push(I),i.push({word:" ",startTime:0,endTime:0}),h+=c.length}l.word.endsWith(" ")||i.pop()}else i.push(l)}let e=[],t=[];const s=[];for(const l of i){const r=l.word;e.push(r),t.push(l),r.length>0&&r.trim().length===0?(e.pop(),t.pop(),t.length===1?s.push(t[0]):t.length>1&&s.push(t),s.push(l),e=[],t=[]):(!/^\s*[^\s]*\s*$/.test(e.join(""))||Ke.test(r))&&(e.pop(),t.pop(),t.length===1?s.push(t[0]):t.length>1&&s.push(t),e=[r],t=[l])}return t.length===1?s.push(t[0]):s.push(t),s}function k(o){return o.endTime-o.startTime>=1e3&&o.word.trim().length<=7&&o.word.trim().length>=1}class st extends MouseEvent{constructor(i,e){super(e.type,e),this.line=i}}class lt extends EventTarget{constructor(e,t={words:[],translatedLyric:"",romanLyric:"",startTime:0,endTime:0,isBG:!1,isDuet:!1}){super();a(this,"element",document.createElement("div"));a(this,"left",0);a(this,"top",0);a(this,"scale",1);a(this,"blur",0);a(this,"delay",0);a(this,"splittedWords",[]);a(this,"lineSize",[0,0]);a(this,"lineTransforms",{posX:new U(0),posY:new U(0),scale:new U(1)});a(this,"listenersMap",new Map);a(this,"onMouseEvent",e=>{const t=new st(this,e);for(const s of this.listenersMap.get(e.type)??[])s.call(this,t);if(!this.dispatchEvent(t)||t.defaultPrevented)return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1});a(this,"isEnabled",!1);a(this,"_hide",!0);a(this,"_prevParentEl",null);a(this,"lastStyle","");this.lyricPlayer=e,this.lyricLine=t,this._prevParentEl=e.getElement(),this.element.setAttribute("class",this.lyricPlayer.style.classes.lyricLine),this.lyricLine.isBG&&this.element.classList.add(this.lyricPlayer.style.classes.lyricBgLine),this.lyricLine.isDuet&&this.element.classList.add(this.lyricPlayer.style.classes.lyricDuetLine),this.element.appendChild(document.createElement("div")),this.element.appendChild(document.createElement("div")),this.element.appendChild(document.createElement("div"));const s=this.element.children[0],l=this.element.children[1],r=this.element.children[2];s.setAttribute("class",this.lyricPlayer.style.classes.lyricMainLine),l.setAttribute("class",this.lyricPlayer.style.classes.lyricSubLine),r.setAttribute("class",this.lyricPlayer.style.classes.lyricSubLine),this.rebuildElement(),this.rebuildStyle()}addMouseEventListener(e,t,s){if(t){const l=this.listenersMap.get(e)??new Set;l.size===0&&this.element.addEventListener(e,this.onMouseEvent,s),l.add(t),this.listenersMap.set(e,l)}}removeMouseEventListener(e,t,s){if(t){const l=this.listenersMap.get(e);l&&(l.delete(t),l.size===0&&this.element.removeEventListener(e,this.onMouseEvent,s))}}enable(e=this.lyricLine.startTime){this.isEnabled=!0,this.element.classList.add("active");const t=this.element.children[0];for(const s of this.splittedWords){for(const l of s.elementAnimations)l.currentTime=0,l.playbackRate=1,l.play();for(const l of s.maskAnimations)l.currentTime=Math.min(this.totalDuration,Math.max(0,e-this.lyricLine.startTime)),l.playbackRate=1,l.play()}t.classList.add("active")}disable(e=0){this.isEnabled=!1,this.element.classList.remove("active");const t=this.element.children[0];for(const s of this.splittedWords){for(const l of s.elementAnimations)l.id==="float-word"&&(l.playbackRate=-1,l.play());for(const l of s.maskAnimations)l.currentTime=Math.min(this.totalDuration,Math.max(0,e-this.lyricLine.startTime)),l.pause()}t.classList.remove("active")}resume(){if(this.isEnabled)for(const e of this.splittedWords)for(const t of e.maskAnimations)t.play()}pause(){if(this.isEnabled)for(const e of this.splittedWords)for(const t of e.maskAnimations)t.pause()}setMaskAnimationState(e=0){const t=e-this.lyricLine.startTime;for(const s of this.splittedWords)for(const l of s.maskAnimations)l.currentTime=Math.min(this.totalDuration,Math.max(0,t)),l.playbackRate=1,t>=0&&t<this.totalDuration?l.play():l.pause()}measureSize(){this._hide&&(this._prevParentEl&&this._prevParentEl.appendChild(this.element),this.element.style.display="",this.element.style.visibility="hidden");const e=[this.element.clientWidth,this.element.clientHeight];return this._hide&&(this._prevParentEl&&this.element.remove(),this.element.style.display="none",this.element.style.visibility=""),e}setLine(e){this.lyricLine=e,this.lyricLine.isBG?this.element.classList.add(this.lyricPlayer.style.classes.lyricBgLine):this.element.classList.remove(this.lyricPlayer.style.classes.lyricBgLine),this.lyricLine.isDuet?this.element.classList.add(this.lyricPlayer.style.classes.lyricDuetLine):this.element.classList.remove(this.lyricPlayer.style.classes.lyricDuetLine),this.rebuildElement(),this.rebuildStyle()}getLine(){return this.lyricLine}show(){this._hide=!1,this._prevParentEl&&(this._prevParentEl.appendChild(this.element),this._prevParentEl=null),this.rebuildStyle()}hide(){this._hide=!0,this.element.parentElement&&(this._prevParentEl=this.element.parentElement,this.element.remove()),this.rebuildStyle()}rebuildStyle(){if(this._hide){this.lastStyle!=="display:none;transform:translate(0,-10000px);"&&(this.lastStyle="display:none;transform:translate(0,-10000px);",this.element.setAttribute("style","display:none;transform:translate(0,-10000px);"));return}let e="";e+=`transform:translate(${this.lineTransforms.posX.getCurrentPosition().toFixed(1)}px,${this.lineTransforms.posY.getCurrentPosition().toFixed(1)}px) scale(${this.lineTransforms.scale.getCurrentPosition().toFixed(4)});`,!this.lyricPlayer.getEnableSpring()&&this.isInSight&&(e+=`transition-delay:${this.delay}ms;`),e+=`filter:blur(${Math.min(32,this.blur)}px);`,e!==this.lastStyle&&(this.lastStyle=e,this.element.setAttribute("style",e))}rebuildElement(){const e=this.element.children[0],t=this.element.children[1],s=this.element.children[2];if(this.lyricPlayer._getIsNonDynamic()){e.innerText=this.lyricLine.words.map(r=>r.word).join(""),t.innerText=this.lyricLine.translatedLyric,s.innerText=this.lyricLine.romanLyric;return}const l=it(this.lyricLine.words);e.innerHTML="",this.splittedWords=[];for(const r of l)if(Array.isArray(r)){if(r.length===0)continue;const n=r.reduce((d,m)=>(d.endTime=Math.max(d.endTime,m.endTime),d.startTime=Math.min(d.startTime,m.startTime),d.word+=m.word,d),{word:"",startTime:1/0,endTime:-1/0}),h=r.map(d=>k(d)).reduce((d,m)=>d||m,k(n)),c=document.createElement("span");c.classList.add("emphasize-wrapper");const I=[];for(const d of r){const m=document.createElement("span");if(h){m.classList.add("emphasize");const f=[];for(const y of d.word.trim().split("")){const u=document.createElement("span");u.innerText=y,f.push(u),I.push(u),m.appendChild(u)}const p={...d,mainElement:m,subElements:f,elementAnimations:[this.initFloatAnimation(n,m)],maskAnimations:[],width:0,height:0,padding:0,shouldEmphasize:h};this.splittedWords.push(p)}else m.innerText=d.word,this.splittedWords.push({...d,mainElement:m,subElements:[],elementAnimations:[this.initFloatAnimation(d,m)],maskAnimations:[],width:0,height:0,padding:0,shouldEmphasize:h});c.appendChild(m)}h&&this.splittedWords[this.splittedWords.length-1].elementAnimations.push(...this.initEmphasizeAnimation(I,n.endTime-n.startTime,n.startTime-this.lyricLine.startTime)),n.word.trimStart()!==n.word&&e.appendChild(document.createTextNode(" ")),e.appendChild(c),n.word.trimEnd()!==n.word&&e.appendChild(document.createTextNode(" "))}else if(r.word.trim().length===0)e.appendChild(document.createTextNode(" "));else{const n=k(r),h=document.createElement("span"),c={...r,mainElement:h,subElements:[],elementAnimations:[this.initFloatAnimation(r,h)],maskAnimations:[],width:0,height:0,padding:0,shouldEmphasize:n};if(n){h.classList.add("emphasize");const I=[];for(const m of r.word.trim().split("")){const f=document.createElement("span");f.innerText=m,I.push(f),h.appendChild(f)}c.subElements=I;const d=Math.abs(c.endTime-c.startTime);c.elementAnimations.push(...this.initEmphasizeAnimation(I,d,c.startTime-this.lyricLine.startTime))}else h.innerText=r.word.trim();r.word.trimStart()!==r.word&&e.appendChild(document.createTextNode(" ")),e.appendChild(h),r.word.trimEnd()!==r.word&&e.appendChild(document.createTextNode(" ")),this.splittedWords.push(c)}t.innerText=this.lyricLine.translatedLyric,s.innerText=this.lyricLine.romanLyric}initFloatAnimation(e,t){const s=e.startTime-this.lyricLine.startTime,l=Math.max(1e3,e.endTime-e.startTime);let r=.05;this.lyricLine.isBG&&(r*=2),k(e)&&l<1200&&(r=0);const n=t.animate([{transform:"translateY(0px)"},{transform:`translateY(${-r}em)`}],{duration:isFinite(l)?l:0,delay:isFinite(s)?s:0,id:"float-word",composite:"add",fill:"both",easing:"ease-out"});return n.pause(),n}initEmphasizeAnimation(e,t,s){const l=Math.max(0,s),r=Math.max(1e3,t);let n="float-and-glow";r<1200&&(n="float-only");let h=[];switch(n){case"float-and-glow":{let c=0,I=0;r>=1200&&r<2e3?(c=.7,I=.5):r>=2e3&&r<3e3?(c=.8,I=.6):(r>=3e3&&r<4e3||r>=4e3)&&(c=1,I=.8);const d=Number.isFinite(r)?Math.max(r*1.2,2e3):0,m=Ie(B);h=e.flatMap((f,p,y)=>{const u=l+r/3/y.length*p,g=[],E=new Array(H).fill(0).map((w,T)=>{const b=(T+1)/H,S=m(b),M=Math.sin(b*Math.PI*2),x=Math.max(0,b<B?S/2:S-.5)*I,P=Ne(_e(),1+S*.1*c);return{offset:b,transform:`${qe(P,4)} translate(${M*.005*c}em,${-S*.05}em)`,textShadow:`rgba(255, 255, 255, ${x}) 0 0 10px`}}),L=f.animate(E,{duration:d,delay:Number.isFinite(u)?u:0,id:`emphasize-word-float-and-glow-${f.innerText}-${p}`,iterations:1,composite:"replace",easing:"linear",fill:"both"});return L.onfinish=()=>{L.pause()},L.pause(),g.push(L),g});break}case"float-only":{h=e.flatMap((c,I,d)=>{const m=l+r/1.5/d.length*I,f=[],p=new Array(H).fill(0).map((u,g)=>{const E=(g+1)/H,L=E<B?tt(E):1;return{offset:E,transform:`translateY(${-L*.05}em)`}}),y=c.animate(p,{duration:Number.isFinite(r)?r*2:0,delay:Number.isFinite(m)?m:0,id:`emphasize-word-float-only-${c.innerText}-${I}`,iterations:1,composite:"replace",easing:"linear",fill:"both"});return y.onfinish=()=>{y.pause()},y.pause(),f.push(y),f});break}}return h}get totalDuration(){return this.lyricLine.endTime-this.lyricLine.startTime}updateMaskImage(){this._hide&&(this._prevParentEl&&this._prevParentEl.appendChild(this.element),this.element.style.display="",this.element.style.visibility="hidden");for(const e of this.splittedWords){const t=e.mainElement;t?(e.padding=parseFloat(getComputedStyle(t).paddingLeft),e.width=t.clientWidth-e.padding*2,e.height=t.clientHeight-e.padding*2):(e.width=0,e.height=0,e.padding=0)}this.lyricPlayer.supportMaskImage?this.generateWebAnimationBasedMaskImage():this.generateCalcBasedMaskImage(),this._hide&&(this._prevParentEl&&this.element.remove(),this.element.style.display="none",this.element.style.visibility="")}generateCalcBasedMaskImage(){for(const e of this.splittedWords){const t=e.mainElement;if(t){e.width=t.clientWidth,e.height=t.clientHeight;const s=e.height/2,[l,r]=ie(s/e.width),n=`${r*100}% 100%`;this.lyricPlayer.supportMaskImage?(t.style.maskImage=l,t.style.maskRepeat="no-repeat",t.style.maskOrigin="left",t.style.maskSize=n):(t.style.webkitMaskImage=l,t.style.webkitMaskRepeat="no-repeat",t.style.webkitMaskOrigin="left",t.style.webkitMaskSize=n);const h=e.width+s,c=`clamp(${-h}px,calc(${-h}px + (var(--amll-player-time) - ${e.startTime})*${h/Math.abs(e.endTime-e.startTime)}px),0px) 0px, left top`;t.style.maskPosition=c,t.style.webkitMaskPosition=c}}}generateWebAnimationBasedMaskImage(){const e=this.totalDuration;this.splittedWords.forEach((t,s)=>{const l=t.mainElement;if(l){const r=t.height/2,[n,h]=ie(r/(t.width+t.padding*2)),c=`${h*100}% 100%`;this.lyricPlayer.supportMaskImage?(l.style.maskImage=n,l.style.maskRepeat="no-repeat",l.style.maskOrigin="left",l.style.maskSize=c):(l.style.webkitMaskImage=n,l.style.webkitMaskRepeat="no-repeat",l.style.webkitMaskOrigin="left",l.style.webkitMaskSize=c);const I=this.splittedWords.slice(0,s).reduce((w,T)=>w+T.width,0)+(this.splittedWords[0]?r:0),d=-(t.width+t.padding*2+r),m=w=>Math.max(d,Math.min(0,w));let f=-I-t.width-t.padding-r,p=0;const y=[];let u=f,g=0;const E=()=>{const w=f-u,T=Math.max(0,Math.min(1,p)),b=T-g,S=Math.abs(b/w);if(f>d&&u<d){const P=Math.abs(u-d)*S,A=`${m(u)}px 0`,v={offset:g+P,maskPosition:A};y.push(v)}if(f>0&&u<0){const P=Math.abs(u)*S,A=`${m(f)}px 0`,v={offset:g+P,maskPosition:A};y.push(v)}const M=`${m(f)}px 0`,x={offset:T,maskPosition:M};y.push(x),u=f,g=T};E();let L=0;this.splittedWords.forEach((w,T)=>{{const b=w.startTime-this.lyricLine.startTime,S=b-L;p+=S/e,S>0&&E(),L=b}{const b=w.endTime-w.startTime;p+=b/e,f+=w.width,T===0&&(f+=r*1.5),T===this.splittedWords.length-1&&(f+=r*.5),b>0&&E(),L+=b}});for(const w of t.maskAnimations)w.cancel();try{const w=l.animate(y,{duration:e||1,id:`fade-word-${t.word}-${s}`,easing:"linear",fill:"both"});w.pause(),t.maskAnimations=[w]}catch(w){console.warn("应用渐变动画发生错误",y,e,w)}}})}getElement(){return this.element}setTransform(e=this.left,t=this.top,s=this.scale,l=1,r=0,n=!1,h=0){const c=Math.round(r),I=this.isInSight,d=this.lyricPlayer.getEnableSpring();this.left=e,this.top=t,this.scale=s,this.delay=h*1e3|0;const m=this.element.children[0],f=this.element.children[1],p=this.element.children[2];if(m.style.opacity=`${l}`,f.style.opacity=`${l/2}`,p.style.opacity=`${l/2}`,n||!d){if(this.blur=Math.min(32,c),n&&this.element.classList.add(this.lyricPlayer.style.classes.tmpDisableTransition),this.lineTransforms.posX.setPosition(e),this.lineTransforms.posY.setPosition(t),this.lineTransforms.scale.setPosition(s),d)this.rebuildStyle();else{const y=this.isInSight;I||y?this.show():this.hide()}n&&requestAnimationFrame(()=>{this.element.classList.remove(this.lyricPlayer.style.classes.tmpDisableTransition)})}else this.lineTransforms.posX.setTargetPosition(e,h),this.lineTransforms.posY.setTargetPosition(t,h),this.lineTransforms.scale.setTargetPosition(s),this.blur!==Math.min(32,c)&&(this.blur=Math.min(32,c),this.element.style.filter=`blur(${Math.min(32,c)}px)`)}update(e=0){this.lyricPlayer.getEnableSpring()&&(this.lineTransforms.posX.update(e),this.lineTransforms.posY.update(e),this.lineTransforms.scale.update(e),this.isInSight?this.show():this.hide())}_getDebugTargetPos(){return`[位移: ${this.left}, ${this.top}; 缩放: ${this.scale}; 延时: ${this.delay}]`}get isInSight(){const e=this.lineTransforms.posX.getCurrentPosition(),t=this.lineTransforms.posY.getCurrentPosition(),s=e+this.lineSize[0],l=t+this.lineSize[1],r=this.lyricPlayer.size[0],n=this.lyricPlayer.size[1];return!(e>r||s<0||t>n||l<0)}dispose(){this.element.remove()}}const rt=ge.create(ye());class nt extends MouseEvent{constructor(i,e,t){super(`line-${t.type}`,t),this.lineIndex=i,this.line=e}}class at extends EventTarget{constructor(){super();a(this,"element",document.createElement("div"));a(this,"currentTime",0);a(this,"lyricLines",[]);a(this,"processedLines",[]);a(this,"lyricLinesEl",[]);a(this,"lyricLinesSize",new WeakMap);a(this,"lyricLinesIndexes",new WeakMap);a(this,"hotLines",new Set);a(this,"bufferedLines",new Set);a(this,"scrollToIndex",0);a(this,"allowScroll",!0);a(this,"scrolledHandler",0);a(this,"isScrolled",!1);a(this,"invokedByScrollEvent",!1);a(this,"scrollOffset",0);a(this,"hidePassedLines",!1);a(this,"resizeObserver",new ResizeObserver(e=>{const t=e[0].contentRect;this.size[0]=t.width,this.size[1]=t.height;const s=getComputedStyle(e[0].target),l=this.element.clientWidth-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight),r=this.element.clientHeight-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom);this.innerSize[0]=l,this.innerSize[1]=r,this.rebuildStyle(),this.calcLayout(!0,!0),this.lyricLinesEl.forEach(n=>n.updateMaskImage())}));a(this,"posXSpringParams",{mass:1,damping:10,stiffness:100});a(this,"posYSpringParams",{mass:1,damping:16.5,stiffness:100});a(this,"scaleSpringParams",{mass:1,damping:20,stiffness:100});a(this,"emUnit",Math.max(Math.min(innerHeight*.05,innerWidth*.1),12));a(this,"padding",this.emUnit);a(this,"enableBlur",!0);a(this,"enableScale",!0);a(this,"interludeDots");a(this,"interludeDotsSize",[0,0]);a(this,"bottomLine");a(this,"supportPlusLighter",CSS.supports("mix-blend-mode","plus-lighter"));a(this,"supportMaskImage",CSS.supports("mask-image","none"));a(this,"disableSpring",!1);a(this,"alignAnchor","center");a(this,"alignPosition",.5);a(this,"isNonDynamic",!1);a(this,"scrollBoundary",[0,0]);a(this,"size",[0,0]);a(this,"innerSize",[0,0]);a(this,"onLineClickedHandler",e=>{const t=new nt(this.lyricLinesIndexes.get(e.line)??-1,e.line,e);this.dispatchEvent(t)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())});a(this,"style",rt.createStyleSheet({lyricPlayer:{userSelect:"none",fontSize:"var(--amll-lyric-player-font-size,max(min(6vh, 8vw), 12px))",padding:"1em",margin:"-1em",width:"100%",height:"100%",overflow:"hidden",boxSizing:"content-box",maxWidth:"100%",maxHeight:"100%",zIndex:1,color:"var(--amll-lyric-view-color,white)",mixBlendMode:"plus-lighter",contain:"strict","&:hover":{"& $lyricLine":{filter:"unset !important"}}},lyricLine:{position:"absolute",backfaceVisibility:"hidden",transformOrigin:"left",width:"var(--amll-lyric-player-width,100%)",height:"fit-content",padding:"2vh 1.05em",margin:"0 -1em",contain:"content",willChange:"filter,transform,opacity",transition:"filter 0.25s, background-color 0.25s, box-shadow 0.25s",boxSizing:"content-box",borderRadius:"8px","&:has(>*):hover":{backgroundColor:"var(--amll-lyric-view-hover-bg-color,#fff1)",boxShadow:"0 0 0 8px var(--amll-lyric-view-hover-bg-color,#fff1)"},"&:has(>*):active":{boxShadow:"0 0 0 4px var(--amll-lyric-view-hover-bg-color,#fff1)"}},"@media (max-width: 1024px)":{lyricLine:{padding:"1vh 1em"}},lyricDuetLine:{textAlign:"right",transformOrigin:"right"},lyricBgLine:{opacity:0,fontSize:"max(50%, 10px)",transition:"opacity 0.25s","&.active":{transition:"opacity 0.25s 0.25s",opacity:.4}},lyricMainLine:{transition:"opacity 0.3s 0.25s",willChange:"opacity",margin:"-1em",padding:"1em","& span":{display:"inline-block"},"& > span, span.emphasize-wrapper":{whiteSpace:"pre-wrap",willChange:"transform,display,mask-image",display:"inline-block","&.emphasize, span.emphasize":{padding:"1em",margin:"-1em","& > span":{padding:"1em",margin:"-1em"}}}},lyricSubLine:{fontSize:"max(0.5em, 10px)",transition:"opacity 0.3s 0.25s",opacity:.3},disableSpring:{"& > *":{transition:"filter 0.25s, transform 0.5s, background-color 0.25s, box-shadow 0.25s"}},interludeDots:{height:"clamp(0.5em,1vh,3em)",transformOrigin:"center",width:"fit-content",padding:"2.5% 0",position:"absolute",display:"flex",gap:"0.25em",left:"1em","& > *":{height:"clamp(0.5em,1vh,3em)",display:"inline-block",borderRadius:"50%",aspectRatio:"1 / 1",backgroundColor:"var(--amll-lyric-view-color,white)",marginRight:"4px"},"&.duet":{right:"1em",transformOrigin:"center"}},"@supports (mix-blend-mode: plus-lighter)":{lyricSubLine:{opacity:.3}},tmpDisableTransition:{transition:"none !important"}}));a(this,"_baseFontSize",parseFloat(getComputedStyle(this.element).fontSize));a(this,"isPageVisible",!0);a(this,"onPageShow",()=>{this.isPageVisible=!0,this.setCurrentTime(this.currentTime,!0)});a(this,"onPageHide",()=>{this.isPageVisible=!1});this.interludeDots=new Oe(this),this.bottomLine=new ke(this),this.element.setAttribute("class",this.style.classes.lyricPlayer),this.disableSpring&&this.element.classList.add(this.style.classes.disableSpring),this.rebuildStyle(),this.resizeObserver.observe(this.element),this.element.appendChild(this.interludeDots.getElement()),this.element.appendChild(this.bottomLine.getElement()),this.style.attach(),this.interludeDots.setTransform(0,200),window.addEventListener("pageshow",this.onPageShow),window.addEventListener("pagehide",this.onPageHide);let e=0,t="none",s=0,l=0,r=0,n=Symbol("amll-scroll"),h=0,c=0;this.element.addEventListener("touchstart",I=>{this.beginScrollHandler()&&(I.preventDefault(),e=this.scrollOffset,s=I.touches[0].screenY,h=s,l=Date.now(),r=0)}),this.element.addEventListener("touchmove",I=>{if(this.beginScrollHandler()){I.preventDefault();const d=I.touches[0].screenY,m=d-s,f=d-h,p=f>0?"down":f<0?"up":"none";t!==p?(t=p,e=this.scrollOffset,s=d,l=Date.now()):this.scrollOffset=e-m,h=d,c=Date.now(),this.limitScrollOffset(),this.calcLayout(!0)}}),this.element.addEventListener("touchend",I=>{if(this.beginScrollHandler()){I.preventDefault(),s=0;const d=Date.now();if(d-c>100)return this.endScrollHandler();const m=d-l;r=(this.scrollOffset-e)/m*1e3;let f=0;const p=Symbol("amll-scroll");n=p;const y=u=>{f||(f=u),n===p&&this.beginScrollHandler()&&(this.scrollOffset+=r*(u-f)/1e3,r*=.99,this.limitScrollOffset(),this.calcLayout(!0),Math.abs(r)>1&&!this.scrollBoundary.includes(this.scrollOffset)&&requestAnimationFrame(y),this.endScrollHandler(),f=u)};requestAnimationFrame(y),this.endScrollHandler()}}),this.element.addEventListener("wheel",I=>{this.beginScrollHandler()&&(I.deltaMode===I.DOM_DELTA_PIXEL?(this.scrollOffset+=I.deltaY,this.limitScrollOffset(),this.calcLayout(!0)):(this.scrollOffset+=I.deltaY*50,this.limitScrollOffset(),this.calcLayout(!1)),this.endScrollHandler())})}_getIsNonDynamic(){return this.isNonDynamic}setEnableSpring(e=!0){this.disableSpring=!e,e?this.element.classList.remove(this.style.classes.disableSpring):this.element.classList.add(this.style.classes.disableSpring),this.calcLayout(!0)}getEnableSpring(){return!this.disableSpring}setEnableScale(e=!0){this.enableScale=e,this.calcLayout()}getEnableScale(){return this.enableScale}get baseFontSize(){return this._baseFontSize}beginScrollHandler(){const e=this.allowScroll;return e&&(this.isScrolled=!0,this.invokedByScrollEvent=!0,clearTimeout(this.scrolledHandler),this.scrolledHandler=setTimeout(()=>{this.isScrolled=!1,this.scrollOffset=0},5e3)),e}endScrollHandler(){this.invokedByScrollEvent=!1}limitScrollOffset(){this.scrollOffset=Math.max(Math.min(this.scrollBoundary[1],this.scrollOffset),this.scrollBoundary[0])}getCurrentInterlude(){var s,l,r;if(this.bufferedLines.size>0)return;const e=this.currentTime+20,t=this.scrollToIndex;if(t===0){if((s=this.processedLines[0])!=null&&s.startTime&&this.processedLines[0].startTime>e)return[e,Math.max(e,this.processedLines[0].startTime-250),-2,this.processedLines[0].isDuet]}else if((l=this.processedLines[t])!=null&&l.endTime&&((r=this.processedLines[t+1])!=null&&r.startTime)&&this.processedLines[t+1].startTime>e&&this.processedLines[t].endTime<e)return[Math.max(this.processedLines[t].endTime,e),this.processedLines[t+1].startTime,t,this.processedLines[t+1].isDuet]}rebuildStyle(){this._baseFontSize=parseFloat(getComputedStyle(this.element).fontSize);let e="";e+="--amll-lyric-player-width:",e+=this.innerSize[0]-this.padding*2,e+="px;",e+="--amll-lyric-player-height:",e+=this.innerSize[1]-this.padding*2,e+="px;",this.element.setAttribute("style",e)}setHidePassedLines(e){this.hidePassedLines=e,this.calcLayout()}setEnableBlur(e){this.enableBlur!==e&&(this.enableBlur=e,this.calcLayout())}setLyricLines(e){for(const s of e)for(const l of s.words)l.word=l.word.replace(/\s+/g," ");this.lyricLines=e;const t=750;this.processedLines=e.filter(s=>s.words.reduce((l,r)=>l+r.word.trim().length,0)>0).map((s,l,r)=>{if(s.isBG)return{...s};if(l===0)return{...s,startTime:Math.max(s.startTime-t,0)};const n=r[l-1],h=r[l-2];if(n!=null&&n.isBG&&h){if(h.endTime<s.startTime)return{...s,startTime:Math.max(h.endTime,s.startTime-t)||s.startTime}}else if(n!=null&&n.endTime&&n.endTime<s.startTime)return{...s,startTime:Math.max(n==null?void 0:n.endTime,s.startTime-t)||s.startTime};return{...s}}),this.isNonDynamic=!0;for(const s of this.processedLines)if(s.words.length>1){this.isNonDynamic=!1;break}this.processedLines.forEach((s,l,r)=>{const n=r[l+1],h=s.words[s.words.length-1];h&&k(h)&&(n?n.startTime>s.endTime&&(s.endTime=Math.min(s.endTime+1500,n.startTime)):s.endTime=s.endTime+1500)}),this.processedLines.forEach((s,l,r)=>{if(s.isBG)return;const n=r[l+1];n!=null&&n.isBG&&(n.startTime=Math.min(n.startTime,s.startTime))}),this.lyricLinesEl.forEach(s=>{s.removeMouseEventListener("click",this.onLineClickedHandler),s.removeMouseEventListener("contextmenu",this.onLineClickedHandler),s.dispose()}),this.lyricLinesEl=this.processedLines.map(s=>{const l=new lt(this,s);return l.addMouseEventListener("click",this.onLineClickedHandler),l.addMouseEventListener("contextmenu",this.onLineClickedHandler),l}),this.lyricLinesEl.forEach((s,l)=>{this.element.appendChild(s.getElement()),this.lyricLinesIndexes.set(s,l),s.updateMaskImage()}),this.interludeDots.setInterlude(void 0),this.hotLines.clear(),this.bufferedLines.clear(),this.setLinePosXSpringParams({}),this.setLinePosYSpringParams({}),this.setLineScaleSpringParams({}),this.setCurrentTime(0,!0),this.calcLayout(!0,!0)}resetScroll(){this.isScrolled=!1,this.scrollOffset=0,this.invokedByScrollEvent=!1,clearTimeout(this.scrolledHandler),this.scrolledHandler=0}calcLayout(e=!1,t=!1){var y;t&&(this.emUnit=parseFloat(getComputedStyle(this.element).fontSize),this.lyricLinesEl.forEach(u=>{const g=u.measureSize();this.lyricLinesSize.set(u,g),u.lineSize=g}),this.interludeDotsSize[0]=this.interludeDots.getElement().clientWidth,this.interludeDotsSize[1]=this.interludeDots.getElement().clientHeight,this.bottomLine.lineSize=this.bottomLine.measureSize());const s=this.getCurrentInterlude();let l=-this.scrollOffset,r=this.scrollToIndex,n=0;s?(n=s[1]-s[0],n>=5e3&&this.lyricLinesEl[s[2]+1]&&(r=s[2]+1)):this.interludeDots.setInterlude(void 0);const h=this.enableScale?.95:1,c=this.lyricLinesEl.slice(0,r).reduce((u,g)=>{var E;return u+(g.getLine().isBG?0:((E=this.lyricLinesSize.get(g))==null?void 0:E[1])??0)},0);this.scrollBoundary[0]=-c,l-=c,l+=this.size[1]*this.alignPosition;const I=this.lyricLinesEl[r];if(I){const u=((y=this.lyricLinesSize.get(I))==null?void 0:y[1])??0;switch(this.alignAnchor){case"bottom":l-=u;break;case"center":l-=u/2;break}}const d=Math.max(...this.bufferedLines);let m=0,f=.05,p=!1;this.lyricLinesEl.forEach((u,g)=>{var S,M,x;const E=this.bufferedLines.has(g),L=E||g>=this.scrollToIndex&&g<d,w=u.getLine();w.isDuet&&this.size[0]-(((S=this.lyricLinesSize.get(u))==null?void 0:S[0])??0),!p&&n>=5e3&&(g===this.scrollToIndex&&(s==null?void 0:s[2])===-2||g===this.scrollToIndex+1)&&(p=!0,this.interludeDots.setTransform(this.padding-20,l+10),s&&this.interludeDots.setInterlude([s[0],s[1]]),l+=this.interludeDotsSize[1]+40);let T=1;!L&&g<=(s?s[2]:this.scrollToIndex)?this.hidePassedLines?T=0:this.isNonDynamic?T=.25:T=.15:E?this.isNonDynamic?T=.85:T=1:this.isNonDynamic?T=.25:T=.5,this.invokedByScrollEvent&&(this.isNonDynamic?T=.85:T=1);let b=0;this.enableBlur&&(L?b=0:(b=1,g<this.scrollToIndex?b+=Math.abs(this.scrollToIndex-g)/2:b+=Math.abs(g-Math.max(this.scrollToIndex,d)))),this.invokedByScrollEvent&&(b=0),u.setTransform(this.padding,l,L?1:h,T,b*1.5,e,m),w.isBG&&L?l+=((M=this.lyricLinesSize.get(u))==null?void 0:M[1])??0:w.isBG||(l+=((x=this.lyricLinesSize.get(u))==null?void 0:x[1])??0),l>=0&&(m+=f,f/=1.2)}),this.scrollBoundary[1]=l+this.scrollOffset-this.size[1]/2,this.bottomLine.setTransform(this.padding,l,e,m)}getCurrentTime(){return this.currentTime}getLyricLines(){return this.lyricLines}getElement(){return this.element}getBottomLineElement(){return this.bottomLine.getElement()}setAlignAnchor(e){this.alignAnchor=e}setAlignPosition(e){this.alignPosition=e}setCurrentTime(e,t=!1){if(this.currentTime=e,!this.isPageVisible||(!this._getIsNonDynamic()&&!this.supportMaskImage&&this.element.style.setProperty("--amll-player-time",`${e}`),this.isScrolled))return;const s=new Set,l=new Set,r=new Set;if(t)for(const n of this.lyricLinesEl)n.setMaskAnimationState(e);this.hotLines.forEach(n=>{const h=this.processedLines[n];if(h){if(h.isBG)return;const c=this.processedLines[n+1];if(c!=null&&c.isBG){const I=this.processedLines[n+2],d=Math.min(h.startTime,c==null?void 0:c.startTime),m=Math.min(Math.max(h.endTime,(I==null?void 0:I.startTime)??Number.MAX_VALUE),Math.max(h.endTime,c==null?void 0:c.endTime));(d>e||m<=e)&&(this.hotLines.delete(n),s.add(n),this.hotLines.delete(n+1),s.add(n+1),t&&(this.lyricLinesEl[n].disable(e),this.lyricLinesEl[n+1].disable(e)))}else(h.startTime>e||h.endTime<=e)&&(this.hotLines.delete(n),s.add(n),t&&this.lyricLinesEl[n].disable(e))}else this.hotLines.delete(n),s.add(n),t&&this.lyricLinesEl[n].disable(e)}),this.processedLines.forEach((n,h,c)=>{var I;!n.isBG&&n.startTime<=e&&n.endTime>e&&(this.hotLines.has(h)||(this.hotLines.add(h),r.add(h),t&&this.lyricLinesEl[h].enable(e),(I=c[h+1])!=null&&I.isBG&&(this.hotLines.add(h+1),r.add(h+1),t&&this.lyricLinesEl[h+1].enable(e))))}),this.bufferedLines.forEach(n=>{this.hotLines.has(n)||(l.add(n),t&&this.lyricLinesEl[n].disable(e))}),t?(this.bufferedLines.size>0?this.scrollToIndex=Math.min(...this.bufferedLines):this.scrollToIndex=this.processedLines.findIndex(n=>n.startTime>=e),this.bufferedLines.clear(),this.hotLines.forEach(n=>this.bufferedLines.add(n)),this.calcLayout(!0)):(l.size>0||r.size>0)&&(l.size===0&&r.size>0?(r.forEach(n=>{this.bufferedLines.add(n),this.lyricLinesEl[n].enable(e)}),this.scrollToIndex=Math.min(...this.bufferedLines),this.calcLayout()):r.size===0&&l.size>0?Be(l,this.bufferedLines)&&(this.bufferedLines.forEach(n=>{this.hotLines.has(n)||(this.bufferedLines.delete(n),this.lyricLinesEl[n].disable(e))}),this.calcLayout()):(r.forEach(n=>{this.bufferedLines.add(n),this.lyricLinesEl[n].enable(e)}),l.forEach(n=>{this.bufferedLines.delete(n),this.lyricLinesEl[n].disable(e)}),this.bufferedLines.size>0&&(this.scrollToIndex=Math.min(...this.bufferedLines)),this.calcLayout()))}pause(){this.interludeDots.pause();for(const e of this.lyricLinesEl)e.pause()}resume(){this.interludeDots.resume();for(const e of this.lyricLinesEl)e.resume()}update(e=0){if(!this.isPageVisible)return;const t=e/1e3;this.interludeDots.update(e),this.bottomLine.update(t),this.lyricLinesEl.forEach(s=>s.update(t))}setLinePosXSpringParams(e){this.posXSpringParams={...this.posXSpringParams,...e},this.bottomLine.lineTransforms.posX.updateParams(this.posXSpringParams),this.lyricLinesEl.forEach(t=>t.lineTransforms.posX.updateParams(this.posXSpringParams))}setLinePosYSpringParams(e){this.posYSpringParams={...this.posYSpringParams,...e},this.bottomLine.lineTransforms.posY.updateParams(this.posYSpringParams),this.lyricLinesEl.forEach(t=>t.lineTransforms.posY.updateParams(this.posYSpringParams))}setLineScaleSpringParams(e){this.scaleSpringParams={...this.scaleSpringParams,...e},this.lyricLinesEl.forEach(t=>t.lineTransforms.scale.updateParams(this.scaleSpringParams))}dispose(){this.element.remove(),this.resizeObserver.disconnect(),this.style.detach(),this.lyricLinesEl.forEach(e=>e.dispose()),window.removeEventListener("pageshow",this.onPageShow),this.bottomLine.dispose(),this.interludeDots.dispose()}}exports.AbstractBaseRenderer=se;exports.BackgroundRender=J;exports.BaseRenderer=Z;exports.EplorRenderer=j;exports.LyricPlayer=at;exports.PixiRenderer=be;
|
|
61
|
+
//# sourceMappingURL=amll-core.cjs.map
|