"use strict";var Mt=require("./style.css");const t=require("vue");var V=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var L={exports:{}};(function(e,a){(function(i,o){e.exports=o()})(V,function(){if(typeof window=="object"&&!(document.querySelectorAll===void 0||window.pageYOffset===void 0||history.pushState===void 0)){var i=function(r,d){return r.nodeName==="HTML"?-d:r.getBoundingClientRect().top+d},o=function(r){return r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1},l=function(r,d,u,h){return u>h?d:r+(d-r)*o(u/h)},n=function(r,d,u,h){d=d||500,h=h||window;var m=h.scrollTop||window.pageYOffset;if(typeof r=="number")var w=parseInt(r);else var w=i(r,m);var $=Date.now(),_=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(y){window.setTimeout(y,15)},B=function(){var y=Date.now()-$;h!==window?h.scrollTop=l(m,w,y,d):window.scroll(0,l(m,w,y,d)),y>d?typeof u=="function"&&u(r):_(B)};B()},s=function(r){if(!r.defaultPrevented){r.preventDefault(),location.hash!==this.hash&&window.history.pushState(null,null,this.hash);var d=document.getElementById(this.hash.substring(1));if(!d)return;n(d,500,function(u){location.replace("#"+u.id)})}};return document.addEventListener("DOMContentLoaded",function(){for(var r=document.querySelectorAll('a[href^="#"]:not([href="#"])'),d,u=r.length;d=r[--u];)d.addEventListener("click",s,!1)}),n}})})(L);var M=L.exports;const T=b(M),v=/mobile/i.test(window.navigator.userAgent),c={isMobile:v,eventsName:{moveStart:v?"touchstart":"mousedown",moving:v?"touchmove":"mousemove",moveEnd:v?"touchend":"mouseup"},storage:{set:(e,a)=>{localStorage.setItem(e,a)},get:e=>{localStorage.getItem(e)}},secondToTime:e=>{const a=n=>n<10?"0"+n:""+n,i=Math.floor(e/3600),o=Math.floor((e-i*3600)/60),l=Math.floor(e-i*3600-o*60);return(i>0?[i,o,l]:[o,l]).map(a).join(":")},randomOrder:e=>{function a(i){for(let o=i.length-1;o>=0;o--){const l=Math.floor(Math.random()*(o+1)),n=i[l];i[l]=i[o],i[o]=n}return i}return a([...Array(e)].map(function(i,o){return o}))},parse(e){if(e){e=e.replace(/([^\]^\n])\[/g,(o,l)=>l+` [`);let a=e.split(` `),i=[];for(let o=0;o/g,"").replace(/^\s+|\s+$/g,"");if(l)for(let s=0;so[1]),i.sort((o,l)=>o[0]-l[0]),i}else return[]}},C={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 31"},R=t.createElementVNode("path",{d:"M15.552 15.168q.448.32.448.832 0 .448-.448.768L1.856 25.28q-.768.512-1.312.192T0 24.192V7.744q0-.96.544-1.28t1.312.192z"},null,-1),q=[R];function x(e,a){return t.openBlock(),t.createElementBlock("svg",C,[...q])}const O={render:x},z={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 17 32"},A=t.createElementVNode("path",{d:"M14.08 4.8q2.88 0 2.88 2.048v18.24q0 2.112-2.88 2.112t-2.88-2.112V6.848q0-2.048 2.88-2.048m-11.2 0q2.88 0 2.88 2.048v18.24q0 2.112-2.88 2.112T0 25.088V6.848Q0 4.8 2.88 4.8"},null,-1),I=[A];function D(e,a){return t.openBlock(),t.createElementBlock("svg",z,[...I])}const F={render:D},H={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 28 32"},U=t.createElementVNode("path",{d:"M13.728 6.272v19.456q0 .448-.352.8t-.8.32-.8-.32l-5.952-5.952H1.152q-.48 0-.8-.352t-.352-.8v-6.848q0-.48.352-.8t.8-.352h4.672l5.952-5.952q.32-.32.8-.32t.8.32.352.8M20.576 16q0 1.344-.768 2.528t-2.016 1.664q-.16.096-.448.096-.448 0-.8-.32t-.32-.832q0-.384.192-.64t.544-.448.608-.384.512-.64.192-1.024-.192-1.024-.512-.64-.608-.384-.544-.448-.192-.64q0-.48.32-.832t.8-.32q.288 0 .448.096 1.248.48 2.016 1.664T20.576 16m4.576 0q0 2.72-1.536 5.056t-4 3.36q-.256.096-.448.096-.48 0-.832-.352t-.32-.8q0-.704.672-1.056 1.024-.512 1.376-.8 1.312-.96 2.048-2.4T22.848 16t-.736-3.104-2.048-2.4q-.352-.288-1.376-.8-.672-.352-.672-1.056 0-.448.32-.8t.8-.352q.224 0 .48.096 2.496 1.056 4 3.36T25.152 16m4.576 0q0 4.096-2.272 7.552t-6.048 5.056q-.224.096-.448.096-.48 0-.832-.352t-.32-.8q0-.64.704-1.056l.384-.192q.256-.128.416-.192.8-.448 1.44-.896 2.208-1.632 3.456-4.064T27.424 16t-1.216-5.152-3.456-4.064q-.64-.448-1.44-.896-.128-.096-.416-.192t-.384-.192q-.704-.416-.704-1.056 0-.448.32-.8t.832-.352q.224 0 .448.096 3.776 1.632 6.048 5.056T29.728 16"},null,-1),P=[U];function j(e,a){return t.openBlock(),t.createElementBlock("svg",H,[...P])}const Y={render:j},W={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 28 32"},X=t.createElementVNode("path",{d:"M13.728 6.272v19.456q0 .448-.352.8t-.8.32-.8-.32l-5.952-5.952H1.152q-.48 0-.8-.352t-.352-.8v-6.848q0-.48.352-.8t.8-.352h4.672l5.952-5.952q.32-.32.8-.32t.8.32.352.8M20.576 16q0 1.344-.768 2.528t-2.016 1.664q-.16.096-.448.096-.448 0-.8-.32t-.32-.832q0-.384.192-.64t.544-.448.608-.384.512-.64.192-1.024-.192-1.024-.512-.64-.608-.384-.544-.448-.192-.64q0-.48.32-.832t.8-.32q.288 0 .448.096 1.248.48 2.016 1.664T20.576 16"},null,-1),J=[X];function G(e,a){return t.openBlock(),t.createElementBlock("svg",W,[...J])}const Q={render:G},K={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 28 32"},Z=t.createElementVNode("path",{d:"M13.728 6.272v19.456q0 .448-.352.8t-.8.32-.8-.32l-5.952-5.952H1.152q-.48 0-.8-.352t-.352-.8v-6.848q0-.48.352-.8t.8-.352h4.672l5.952-5.952q.32-.32.8-.32t.8.32.352.8"},null,-1),ee=[Z];function te(e,a){return t.openBlock(),t.createElementBlock("svg",K,[...ee])}const ae={render:te},ie={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},oe=t.createElementVNode("path",{d:"m22.667 4 7 6-7 6 7 6-7 6v-4h-3.653l-3.76-3.76 2.827-2.827L20.668 20h2v-8h-2l-12 12h-6v-4h4.347l12-12h3.653V4zm-20 4h6l3.76 3.76L9.6 14.587 7.013 12H2.666z"},null,-1),re=[oe];function se(e,a){return t.openBlock(),t.createElementBlock("svg",ie,[...re])}const le={render:se},ne={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},de=t.createElementVNode("path",{d:"M.622 18.334h19.54v7.55l11.052-9.412-11.052-9.413v7.549H.622z"},null,-1),he=[de];function ce(e,a){return t.openBlock(),t.createElementBlock("svg",ne,[...he])}const ue={render:ce},pe={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 22 32"},me=t.createElementVNode("path",{d:"M20.8 14.4q.704 0 1.152.48T22.4 16t-.48 1.12-1.12.48H1.6q-.64 0-1.12-.48T0 16t.448-1.12T1.6 14.4zM1.6 11.2q-.64 0-1.12-.48T0 9.6t.448-1.12T1.6 8h19.2q.704 0 1.152.48T22.4 9.6t-.48 1.12-1.12.48zm19.2 9.6q.704 0 1.152.48t.448 1.12-.48 1.12-1.12.48H1.6q-.64 0-1.12-.48T0 22.4t.448-1.12T1.6 20.8z"},null,-1),ye=[me];function ve(e,a){return t.openBlock(),t.createElementBlock("svg",pe,[...ye])}const fe={render:ve},ge={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 29 32"},we=t.createElementVNode("path",{d:"M9.333 9.333h13.333v4L27.999 8l-5.333-5.333v4h-16v8h2.667zm13.334 13.334H9.334v-4L4.001 24l5.333 5.333v-4h16v-8h-2.667v5.333z"},null,-1),Se=[we];function Ee(e,a){return t.openBlock(),t.createElementBlock("svg",ge,[...Se])}const Be={render:Ee},Te={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 33 32"},ke=t.createElementVNode("path",{d:"M9.333 9.333h13.333v4L27.999 8l-5.333-5.333v4h-16v8h2.667zm13.334 13.334H9.334v-4L4.001 24l5.333 5.333v-4h16v-8h-2.667v5.333zM17.333 20v-8H16l-2.667 1.333v1.333h2v5.333z"},null,-1),Le=[ke];function Ne(e,a){return t.openBlock(),t.createElementBlock("svg",Te,[...Le])}const $e={render:Ne},_e={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 29 32"},Ve=t.createElementVNode("path",{d:"m2.667 7.027 1.707-1.693 22.293 22.293-1.693 1.707-4-4H9.334v4l-5.333-5.333 5.333-5.333v4h8.973l-8.973-8.973v.973H6.667v-3.64zm20 10.306h2.667v5.573l-2.667-2.667v-2.907zm0-10.666v-4L28 8l-5.333 5.333v-4H11.76L9.093 6.666z"},null,-1),be=[Ve];function Me(e,a){return t.openBlock(),t.createElementBlock("svg",_e,[...be])}const Ce={render:Me},Re={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},qe=t.createElementVNode("path",{d:"M4 16C4 9.4 9.4 4 16 4s12 5.4 12 12c0 1.2-.8 2-2 2s-2-.8-2-2c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8c1.2 0 2 .8 2 2s-.8 2-2 2C9.4 28 4 22.6 4 16"},null,-1),xe=[qe];function Oe(e,a){return t.openBlock(),t.createElementBlock("svg",Re,[...xe])}const ze={render:Oe},Ae={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},Ie=t.createElementVNode("path",{d:"M22 16 11.895 5.4 10 7.387 18.211 16 10 24.612l1.895 1.988 8.211-8.613z"},null,-1),De=[Ie];function Fe(e,a){return t.openBlock(),t.createElementBlock("svg",Ae,[...De])}const He={render:Fe},Ue={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},Pe=t.createElementVNode("path",{d:"M25.468 6.947a1 1 0 0 0-1.03.057L18 11.384V7.831a1.001 1.001 0 0 0-1.562-.827l-12 8.164a1 1 0 0 0 0 1.654l12 8.168A.999.999 0 0 0 18 24.164v-3.556l6.438 4.382A.999.999 0 0 0 26 24.164V7.831c0-.371-.205-.71-.532-.884"},null,-1),je=[Pe];function Ye(e,a){return t.openBlock(),t.createElementBlock("svg",Ue,[...je])}const We={render:Ye},Xe={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},Je=t.createElementVNode("path",{d:"M26.667 5.333H5.333a2.667 2.667 0 0 0-2.666 2.666v16.002a2.667 2.667 0 0 0 2.666 2.666h21.335a2.667 2.667 0 0 0 2.666-2.666V7.999a2.667 2.667 0 0 0-2.666-2.666zM5.333 16h5.333v2.667H5.333zm13.334 8H5.334v-2.667h13.333zm8 0h-5.333v-2.667h5.333zm0-5.333H13.334V16h13.333z"},null,-1),Ge=[Je];function Qe(e,a){return t.openBlock(),t.createElementBlock("svg",Xe,[...Ge])}const Ke={render:Qe},N={__name:"Icon",props:{type:{type:String}},setup(e){const a={play:O,pause:F,volumeUp:Y,volumeDown:Q,volumeOff:ae,orderRandom:le,orderList:ue,menu:fe,loopAll:Be,loopOne:$e,loopNone:Ce,loading:ze,right:He,skip:We,lrc:Ke};return(i,o)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(a[e.type])))}},g=(e,a)=>{const i=e.__vccOpts||e;for(const[o,l]of a)i[o]=l;return i},Ze={props:["aplayer"],computed:{ol(){return this.$refs.ol}},methods:{showList(){setTimeout(()=>{this.ol.scrollTop=this.aplayer.index*33},0)},switchList(e){e!==this.aplayer.index?(this.$emit("switchList",e),this.$emit("play")):this.$emit("toggle")}}},et=["onClick"],tt={class:"aplayer-list-index"},at={class:"aplayer-list-title"},it={class:"aplayer-list-author"};function ot(e,a,i,o,l,n){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["aplayer-list",{"aplayer-list-hide":!i.aplayer.listFolded}]),style:t.normalizeStyle({"max-height":`${i.aplayer.listMaxHeight}px`})},[t.createElementVNode("ol",{style:t.normalizeStyle({"max-height":`${i.aplayer.listMaxHeight}px`}),ref:"ol"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.aplayer.audio,(s,r)=>(t.openBlock(),t.createElementBlock("li",{class:t.normalizeClass({"aplayer-list-light":r===i.aplayer.index}),onClick:d=>n.switchList(r)},[t.createElementVNode("span",{class:"aplayer-list-cur",style:t.normalizeStyle({background:`${i.aplayer.coverColor[i.aplayer.index]||s.theme||i.aplayer.theme}`})},null,4),t.createElementVNode("span",tt,t.toDisplayString(r+1),1),t.createElementVNode("span",at,t.toDisplayString(s.name),1),t.createElementVNode("span",it,t.toDisplayString(s.artist?s.artist:""),1)],10,et))),256))],4)],6)}const rt=g(Ze,[["render",ot]]),st={props:["aplayer"],computed:{transformStyle(){return{transform:`translateY(-${this.aplayer.lyricIndex*16}px)`,webkitTransform:`translateY(-${this.aplayer.lyricIndex*16}px)`}}}},lt={class:"aplayer-lrc"};function nt(e,a,i,o,l,n){return t.openBlock(),t.createElementBlock("div",lt,[t.createElementVNode("div",{class:"aplayer-lrc-contents",style:t.normalizeStyle(n.transformStyle)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.aplayer.lyrics[i.aplayer.index],(s,r)=>(t.openBlock(),t.createElementBlock("p",{class:t.normalizeClass({"aplayer-lrc-current":r===i.aplayer.lyricIndex})},t.toDisplayString(s[1]),3))),256))],4)])}const dt=g(st,[["render",nt]]),S=["one","all","none"],E=["list","random"],ht={components:{utils:c,Icon:N},props:["aplayer","audioStatus","styleStatus"],data(){return{aplayerThumbShowStatus:!1,volumeBarShowStatus:!1}},computed:{aplayerBar(){return this.$refs.aplayerBar},volumeBar(){return this.$refs.volumeBar},switchVolumeIcon(){return this.aplayer.muted||this.aplayer.volume<=0?"volumeOff":this.aplayer.volume>=.95?"volumeUp":"volumeDown"},audio(){return this.aplayer.audio[this.aplayer.index]},duration(){return c.secondToTime(this.audioStatus.duration)},playedTime:{get(){return c.secondToTime(this.audioStatus.playedTime)},set(e){this.$emit("playedTime",e)}},disableTimeUpdate:{get(){return this.audioStatus.disableTimeUpdate},set(e){this.$emit("disableTimeUpdate",e)}}},methods:{loopButtonClick(){let e=S.indexOf(this.aplayer.loop);e=(e+1)%S.length,this.$emit("setLoop",S[e])},orderButtonClick(){let e=E.indexOf(this.aplayer.order);e=(e+1)%E.length,this.$emit("setOrder",E[e])},aplayerBarMoving(e){let a=((e.clientX||e.changedTouches[0].clientX)-this.aplayerBar.getBoundingClientRect().left)/this.aplayerBar.clientWidth;a=Math.max(a,0),a=Math.min(a,1),this.playedTime=a*this.audioStatus.duration,this.$emit("updateLyric")},aplayerBarMoveEnd(e){document.removeEventListener(c.eventsName.moveEnd,this.aplayerBarMoveEnd),document.removeEventListener(c.eventsName.moving,this.aplayerBarMoving);let a=((e.clientX||e.changedTouches[0].clientX)-this.aplayerBar.getBoundingClientRect().left)/this.aplayerBar.clientWidth;a=Math.max(a,0),a=Math.min(a,1),this.$emit("seek",a*this.audioStatus.duration),this.disableTimeUpdate=!1},aplayerBarMoveStart(){this.disableTimeUpdate=!0,document.addEventListener(c.eventsName.moving,this.aplayerBarMoving),document.addEventListener(c.eventsName.moveEnd,this.aplayerBarMoveEnd)},volumeBarMoving(e){let a=1-((e.clientY||e.changedTouches[0].clientY)-this.volumeBar.getBoundingClientRect().top)/this.volumeBar.clientHeight;a=Math.max(a,0),a=Math.min(a,1),this.$emit("setVolume",a)},volumeBarMoveEnd(e){this.volumeBarShowStatus=!1,document.removeEventListener(c.eventsName.moveEnd,this.volumeBarMoveEnd),document.removeEventListener(c.eventsName.moving,this.volumeBarMoving);let a=1-((e.clientY||e.changedTouches[0].clientY)-this.volumeBar.getBoundingClientRect().top)/this.volumeBar.clientHeight;a=Math.max(a,0),a=Math.min(a,1),this.$emit("setVolume",a,!0)},volumeBarMoveStart(){this.volumeBarShowStatus=!0,document.addEventListener(c.eventsName.moving,this.volumeBarMoving),document.addEventListener(c.eventsName.moveEnd,this.volumeBarMoveEnd)}},mounted(){this.aplayerBar.parentNode.addEventListener(c.eventsName.moveStart,this.aplayerBarMoveStart),this.volumeBar.parentNode.addEventListener(c.eventsName.moveStart,this.volumeBarMoveStart)},beforeUnmount(){this.aplayerBar.parentNode.removeEventListener(c.eventsName.moveStart,this.aplayerBarMoveStart),this.volumeBar.parentNode.removeEventListener(c.eventsName.moveStart,this.volumeBarMoveStart)}},ct={class:"aplayer-controller"},ut={class:"aplayer-bar",ref:"aplayerBar"},pt={class:"aplayer-loading-icon"},mt={class:"aplayer-time-inner"},yt={class:"aplayer-ptime"},vt={class:"aplayer-dtime"},ft={class:"aplayer-volume-bar-wrap"},gt={class:"aplayer-volume-bar",ref:"volumeBar"};function wt(e,a,i,o,l,n){var r,d,u;const s=t.resolveComponent("Icon");return t.openBlock(),t.createElementBlock("div",ct,[t.createElementVNode("div",{class:"aplayer-bar-wrap",onMouseover:a[0]||(a[0]=h=>l.aplayerThumbShowStatus=!0),onMouseout:a[1]||(a[1]=h=>l.aplayerThumbShowStatus=!1)},[t.createElementVNode("div",ut,[t.createElementVNode("div",{class:"aplayer-loaded",style:t.normalizeStyle({width:`${i.audioStatus.duration?i.audioStatus.loadedTime/i.audioStatus.duration*100:0}%`})},null,4),t.createElementVNode("div",{class:"aplayer-played",style:t.normalizeStyle({width:`${i.audioStatus.duration?i.audioStatus.playedTime/i.audioStatus.duration*100:0}%`,background:`${i.aplayer.coverColor[i.aplayer.index]||((r=n.audio)==null?void 0:r.theme)||i.aplayer.theme}`})},[t.withDirectives(t.createElementVNode("span",{class:"aplayer-thumb",style:t.normalizeStyle({background:`${i.aplayer.coverColor[i.aplayer.index]||((d=n.audio)==null?void 0:d.theme)||i.aplayer.theme}`})},[t.createElementVNode("span",pt,[t.createVNode(s,{type:"loading"})])],4),[[t.vShow,l.aplayerThumbShowStatus]])],4)],512)],32),t.createElementVNode("div",{class:t.normalizeClass({"aplayer-time":!0,"aplayer-time-narrow":i.styleStatus.timeNarrow})},[t.createElementVNode("span",mt,[t.createElementVNode("span",yt,t.toDisplayString(n.playedTime),1),t.createTextVNode(" / "),t.createElementVNode("span",vt,t.toDisplayString(n.duration),1)]),t.createElementVNode("span",{class:"aplayer-icon aplayer-icon-back",onClick:a[2]||(a[2]=h=>e.$emit("skipBack"))},[t.createVNode(s,{type:"skip"})]),t.createElementVNode("span",{class:"aplayer-icon aplayer-icon-play",onClick:a[3]||(a[3]=h=>e.$emit("toggle"))},[t.withDirectives(t.createVNode(s,{type:"play"},null,512),[[t.vShow,!i.audioStatus.playStatus]]),t.withDirectives(t.createVNode(s,{type:"pause"},null,512),[[t.vShow,i.audioStatus.playStatus]])]),t.createElementVNode("span",{class:"aplayer-icon aplayer-icon-forward",onClick:a[4]||(a[4]=h=>e.$emit("skipForward"))},[t.createVNode(s,{type:"skip"})]),t.createElementVNode("div",{class:t.normalizeClass(["aplayer-volume-wrap",{"aplayer-volume-bar-wrap-active":l.volumeBarShowStatus}])},[t.createElementVNode("button",{type:"button",class:"aplayer-icon aplayer-icon-volume-down",onClick:a[5]||(a[5]=h=>e.$emit("mute"))},[t.createVNode(s,{type:n.switchVolumeIcon},null,8,["type"])]),t.createElementVNode("div",ft,[t.createElementVNode("div",gt,[t.createElementVNode("div",{class:"aplayer-volume",style:t.normalizeStyle({height:`${i.aplayer.muted?0:i.aplayer.volume*100}%`,background:`${i.aplayer.coverColor[i.aplayer.index]||((u=n.audio)==null?void 0:u.theme)||i.aplayer.theme}`})},null,4)],512)])],2),t.createElementVNode("button",{type:"button",class:"aplayer-icon aplayer-icon-order",onClick:a[6]||(a[6]=(...h)=>n.orderButtonClick&&n.orderButtonClick(...h))},[t.withDirectives(t.createVNode(s,{type:"orderList"},null,512),[[t.vShow,i.aplayer.order==="list"]]),t.withDirectives(t.createVNode(s,{type:"orderRandom"},null,512),[[t.vShow,i.aplayer.order==="random"]])]),t.createElementVNode("button",{type:"button",class:"aplayer-icon aplayer-icon-loop",onClick:a[7]||(a[7]=(...h)=>n.loopButtonClick&&n.loopButtonClick(...h))},[t.withDirectives(t.createVNode(s,{type:"loopOne"},null,512),[[t.vShow,i.aplayer.loop==="one"]]),t.withDirectives(t.createVNode(s,{type:"loopAll"},null,512),[[t.vShow,i.aplayer.loop==="all"]]),t.withDirectives(t.createVNode(s,{type:"loopNone"},null,512),[[t.vShow,i.aplayer.loop==="none"]])]),t.createElementVNode("button",{type:"button",class:"aplayer-icon aplayer-icon-menu",onClick:a[8]||(a[8]=h=>e.$emit("toggleList"))},[t.createVNode(s,{type:"menu"})]),t.createElementVNode("button",{type:"button",class:t.normalizeClass({"aplayer-icon":!0,"aplayer-icon-lrc":!0,"aplayer-icon-lrc-inactivity":!i.aplayer.lyricShow}),onClick:a[9]||(a[9]=h=>e.$emit("toggleLrc"))},[t.createVNode(s,{type:"lrc"})],2)],2)])}const St=g(ht,[["render",wt]]);let p=null;const k=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","interruptbegin","interruptend","loadeddata","loadedmetadata","loadstart","mozaudioavailable","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],Et={name:"APlayer",components:{smoothScroll:T,utils:c,Icon:N,List:rt,Lyric:dt,Controller:St},props:{audio:{type:Array,default:[]},mode:{type:String,default:"normal"},autoplay:{type:Boolean,default:!1},mutex:{type:Boolean,default:!0},preload:{type:String,default:"metadata"},theme:{type:String,default:"#B7DAFF"},autoSwitch:{type:Boolean,default:!0},loop:{type:String,default:"all"},order:{type:String,default:"list"},muted:{type:Boolean,default:!1},volume:{type:Number,default:.7,validator(e){return e>=0&&e<=1}},lrcType:{type:Number,default:1},lrcShow:{type:Boolean,default:!0},listFolded:{type:Boolean,default:!1},listMaxHeight:{type:Number,default:250},noticeSwitch:{type:Boolean,default:!0},storageName:{type:String,default:"aplayer-setting"}},data(){return{aplayer:{index:0,audio:[],randomOrder:[],mode:this.mode,autoplay:this.autoplay,mutex:this.mutex,preload:this.preload,theme:this.theme,autoSwitch:this.autoSwitch,coverColor:[],loop:this.loop,order:this.order,muted:this.muted,volume:this.volume,lyricType:this.lrcType,lyricShow:this.lrcShow,lyricIndex:0,lyrics:[],listFolded:this.listFolded,listMaxHeight:this.listMaxHeight,noticeSwitch:this.noticeSwitch,noticeText:"",noticeOpacity:0,storageName:this.storageName,storage:{}},audioStatus:{duration:0,loadedTime:0,playedTime:0,playStatus:!1,waitingStatus:!1,disableTimeUpdate:!1},styleStatus:{isMobile:/mobile/i.test(window.navigator.userAgent),narrow:!1,timeNarrow:!1,mini:!0},destroyComponent:!1}},computed:{audioRef(){return this.$refs.audio},coverStyle(){let e=this.aplayer.audio[this.aplayer.index];return e!=null&&e.cover?{"background-image":`url(${e.cover})`,"background-color":`${this.aplayer.coverColor[this.aplayer.index]||(e==null?void 0:e.theme)||this.aplayer.theme}`}:{"background-color":`${this.aplayer.coverColor[this.aplayer.index]||(e==null?void 0:e.theme)||this.aplayer.theme}`}}},methods:{getStorage(e){return this.aplayer.storage[e]},setStorage(e,a){this.aplayer.storage[e]=a,localStorage.setItem(this.aplayer.storageName,JSON.stringify(this.aplayer.storage))},setAudio(e){this.hls&&(this.hls.destroy(),this.hls=null);let a=e.type;(!a||a==="auto")&&(a=/m3u8(#|\?|$)/i.exec(e.url)?"hls":"normal"),a==="hls"?Hls.isSupported()?(this.hls=new Hls,this.hls.loadSource(e.url),this.hls.attachMedia(this.audioRef)):this.audioRef.canPlayType("application/x-mpegURL")||this.audioRef.canPlayType("application/vnd.apple.mpegURL")?this.audioRef.src=e.url:this.setNotice("Error: HLS is not supported."):a==="normal"&&(this.audioRef.src=e.url)},prevIndex(){let e=this.aplayer.index;if(this.aplayer.audio.length>1){if(this.aplayer.order==="list")return e-1<0?this.aplayer.audio.length-1:e-1;if(this.aplayer.order==="random"){let a=this.aplayer.randomOrder.indexOf(e);return a===0?this.aplayer.randomOrder[this.aplayer.randomOrder.length-1]:this.aplayer.randomOrder[a-1]}}else return 0},nextIndex(){let e=this.aplayer.index;if(this.aplayer.audio.length>1){if(this.aplayer.order==="list")return(e+1)%this.aplayer.audio.length;if(this.aplayer.order==="random"){let a=this.aplayer.randomOrder.indexOf(e);return a===this.aplayer.randomOrder.length-1?this.aplayer.randomOrder[0]:this.aplayer.randomOrder[a+1]}}else return 0},coverColor(){var a;let e=!this.aplayer.coverColor[this.aplayer.index];if(this.aplayer.autoSwitch&&e)try{this.colorThief||(this.colorThief=new ColorThief),this.colorThief.getColorAsync((a=this.aplayer.audio[this.aplayer.index])==null?void 0:a.cover,([i,o,l])=>this.aplayer.coverColor[this.aplayer.index]=`rgb(${i}, ${o}, ${l})`)}catch{this.aplayer.autoSwitch=!1,this.setNotice("The color-thief is required to support self-adapting theme.")}},switchStyle(){this.$refs.switch&&(this.$refs.switch.style.display="none",setTimeout(()=>{this.$refs.switch&&(this.$refs.switch.style.display="block")},100))},loadedTime(){return this.audioRef.buffered.length?this.audioRef.buffered.end(this.audioRef.buffered.length-1):0},playedTime(e){this.audioStatus.playedTime=e},disableTimeUpdate(e){this.audioStatus.disableTimeUpdate=e},async loadLyric(e,a){try{let i=await fetch(this.aplayer.audio[a].lrc);i.ok||i.status===304?e=c.parse(await i.text()):this.setNotice("LRC file request fails: status "+i.status)}catch(i){console.warn(i)}finally{this.aplayer.lyrics[a]=e,this.updateLyric()}},switchLyric(e){if(this.aplayer.lyrics[e])return;let a=[[0,"Not available"]];this.aplayer.lyricType===1?(this.aplayer.lyrics[e]=[[0,"Loading"]],this.loadLyric(a,e)):this.aplayer.lyricType===2&&(this.aplayer.audio[e].lrc&&(a=c.parse(this.aplayer.audio[e].lrc)),this.aplayer.lyrics[e]=a,this.updateLyric())},updateLyric(){let e=this.aplayer.lyrics[this.aplayer.index];if(e)for(let a=0;a=i[0]&&(!o||this.audioStatus.playedTime{this.audioRef.addEventListener(e,a=>this.$emit(e,a))}),this.audioRef.addEventListener("play",()=>this.audioStatus.playStatus=!0),this.audioRef.addEventListener("pause",()=>this.audioStatus.playStatus=!1),this.audioRef.addEventListener("timeupdate",this.timeupdate),this.audioRef.addEventListener("durationchange",this.durationchange),this.audioRef.addEventListener("loadedmetadata",this.loadedmetadata),this.audioRef.addEventListener("canplay",this.canplay),this.audioRef.addEventListener("progress",this.progress),this.audioRef.addEventListener("error",this.error),this.audioRef.addEventListener("ended",this.ended),this.audioRef.addEventListener("waiting",this.waiting),this.audioRef.addEventListener("playing",this.playing),window.addEventListener("resize",this.resize),this.addList(this.audio,!0),this.aplayer.autoplay&&this.play(),this.$emit("init")},play(){this.switchStyle(),this.audioStatus.playStatus=!0,this.$nextTick(()=>{this.audioStatus.playStatus=!0,this.aplayer.mutex&&(p&&p!==this&&p.pause(),p=this);const e=this.audioRef.play();e&&e.catch(a=>{console.warn(a),a.name==="NotAllowedError"&&(this.audioStatus.playStatus=!1)})})},pause(){this.switchStyle(),this.audioStatus.playStatus=!1,this.audioRef.pause()},toggle(){this.audioStatus.playStatus?this.pause():this.play()},seek(e){e=Math.max(e,0),e=Math.min(e,this.audioStatus.duration),this.audioStatus.playedTime=e,this.audioRef.currentTime=e},mute(){this.aplayer.muted=!this.aplayer.muted,this.audioRef.muted=!this.audioRef.muted},setVolume(e,a=!1){e=parseFloat(e),isNaN(e)||(e=Math.max(e,0),e=Math.min(e,1),this.aplayer.volume=e,this.audioRef.volume=e,a&&this.setStorage("volume",e),this.aplayer.muted&&this.mute())},setTheme(e,a=this.aplayer.index){e&&(this.aplayer.coverColor[a]?this.aplayer.coverColor[a]=e:this.aplayer.audio[a]&&(this.aplayer.audio[a].theme=e))},setMode(e="normal"){e!="normal"&&e!="fixed"&&e!="mini"||(this.aplayer.mode=e,setTimeout(()=>{this.resize()},0))},setLoop(e){e!="one"&&e!="all"&&e!="none"||(this.aplayer.audio.length<=1&&e==="one"&&(e="all"),this.aplayer.loop=e)},setOrder(e){e!="list"&&e!="random"||(this.aplayer.order=e)},setNotice(e,a=2e3,i=.8){if(!this.aplayer.noticeSwitch||this.aplayer.mode==="mini"||this.aplayer.mode==="fixed"&&this.styleStatus.mini){console.warn(e);return}this.aplayer.noticeText=e,this.aplayer.noticeOpacity=i,this.noticeTimeout&&clearTimeout(this.noticeTimeout),this.$emit("noticeshow"),a&&(this.noticeTimeout=setTimeout(()=>{this.aplayer.noticeOpacity=0,this.$emit("noticehide")},a))},skipBack(){this.switchList(this.prevIndex())},skipForward(){this.switchList(this.nextIndex())},destroy(){this.destroyComponent=!0,this.$emit("destroy")},showLrc(){this.$emit("lrcshow"),this.aplayer.lyricShow=!0},hideLrc(){this.$emit("lrchide"),this.aplayer.lyricShow=!1},toggleLrc(){this.aplayer.lyricShow?this.hideLrc():this.showLrc()},showList(){this.$emit("listshow"),this.aplayer.mode!=="mini"&&this.$refs.list.showList(),this.aplayer.listFolded=!0},hideList(){this.$emit("listhide"),this.aplayer.listFolded=!1},toggleList(){this.aplayer.listFolded?this.hideList():this.showList()},addList(e,a=!1){this.$emit("listadd",e),Object.prototype.toString.call(e)!=="[object Array]"&&(e=[e]),e.map(o=>(o.name=o.name||o.title||"Audio Name",o.artist=o.artist||o.author||"Audio Artist",o.cover=o.cover||o.pic,o.type=o.type||"normal",o));const i=this.aplayer.audio.length===0;if(a&&(this.aplayer.audio=[]),this.aplayer.audio=this.aplayer.audio.concat(e),this.aplayer.randomOrder=c.randomOrder(this.aplayer.audio.length),i){let o=0;this.aplayer.order==="random"&&(o=this.aplayer.randomOrder[0]),this.switchList(o)}},removeList(e){this.$emit("listremove",nextIndex),this.aplayer.coverColor.splice(e,1),this.aplayer.randomOrder.splice(this.aplayer.randomOrder.indexOf(this.aplayer.audio.length-1),1),this.aplayer.audio[e]&&(this.aplayer.audio.length>1?(this.aplayer.audio.splice(e,1),e===this.aplayer.index&&(this.aplayer.audio[e]?this.switchList(e):this.switchList(e-1)),this.aplayer.index>e&&this.aplayer.index--):this.clearList()),this.aplayer.lyrics.splice(e,1)},switchList(e){this.$emit("listswitch",e),typeof e<"u"&&this.aplayer.audio[e]&&(this.aplayer.index=e,this.coverColor(),this.aplayer.mode!=="mini"&&T(e*33,500,null,this.$refs.list.ol),this.setAudio(this.aplayer.audio[e]),this.switchLyric(e),this.audioStatus.duration=0,this.audioStatus.playedTime=0)},clearList(){this.$emit("listclear"),this.pause(),this.audioRef.src="",this.aplayer.audio=[],this.aplayer.randomOrder=[],this.aplayer.coverColor=[],this.aplayer.lyrics=[],this.aplayer.index=0,this.aplayer.lyricIndex=0,this.audioStatus.duration=0,this.audioStatus.loadedTime=0,this.audioStatus.playedTime=0,this.audioStatus.playStatus=!1,this.audioStatus.waitingStatus=!1,this.audioStatus.disableTimeUpdate=!1},timeupdate(){this.audioStatus.disableTimeUpdate||(this.audioStatus.playedTime=this.audioRef.currentTime),this.updateLyric()},durationchange(){this.audioStatus.duration=this.audioRef.duration},loadedmetadata(){this.seek(0),this.audioStatus.playStatus&&this.audioRef.play()},canplay(){this.audioStatus.loadedTime=this.loadedTime()},progress(){this.audioStatus.loadedTime=this.loadedTime()},error(){if(this.aplayer.audio.length>1){let e=this.audioStatus.playStatus;this.setNotice("An audio error has occurred, player will skip forward in 2 seconds."),this.skipForwardTimeout&&clearTimeout(this.skipForwardTimeout),this.skipForwardTimeout=setTimeout(()=>{this.skipForward(),e&&this.play()},2e3)}else this.aplayer.audio.length===1&&this.setNotice("An audio error has occurred.")},ended(){let e=this.aplayer.index;this.aplayer.loop==="none"?(this.skipForward(),this.aplayer.order==="list"?e{this.audioRef.removeEventListener(e,a=>this.$emit(e,a))}),this.audioRef.removeEventListener("play",()=>this.audioStatus.playStatus=!0),this.audioRef.removeEventListener("pause",()=>this.audioStatus.playStatus=!1),this.audioRef.removeEventListener("timeupdate",this.timeupdate),this.audioRef.removeEventListener("durationchange",this.durationchange),this.audioRef.removeEventListener("loadedmetadata",this.loadedmetadata),this.audioRef.removeEventListener("canplay",this.canplay),this.audioRef.removeEventListener("progress",this.progress),this.audioRef.removeEventListener("error",this.error),this.audioRef.removeEventListener("ended",this.ended),this.audioRef.removeEventListener("waiting",this.waiting),this.audioRef.removeEventListener("playing",this.playing),window.removeEventListener("resize",this.resize)}},Bt=Et,Tt={ref:"switch"},kt={class:"aplayer-info",ref:"info"},Lt={class:"aplayer-music"},Nt={class:"aplayer-title"},$t={class:"aplayer-author"},_t={class:"aplayer-icon"},Vt={ref:"audio"};function bt(e,a,i,o,l,n){const s=t.resolveComponent("List"),r=t.resolveComponent("Icon"),d=t.resolveComponent("Lyric"),u=t.resolveComponent("Controller");return e.destroyComponent?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["aplayer",{"aplayer-narrow":e.styleStatus.narrow,"aplayer-fixed":e.aplayer.mode==="fixed","aplayer-mini":e.aplayer.mode==="mini"||e.aplayer.mode==="fixed"&&e.styleStatus.mini,"aplayer-loading":e.audioStatus.playStatus&&e.audioStatus.waitingStatus,"aplayer-withlist":e.aplayer.audio.length>1,"aplayer-withlrc":e.aplayer.mode==="normal"&&e.aplayer.lyricShow,"aplayer-mobile":e.styleStatus.isMobile}]),ref:"aplayer"},[e.aplayer.mode==="fixed"?(t.openBlock(),t.createBlock(s,{key:0,aplayer:e.aplayer,onPlay:e.play,onToggle:e.toggle,onSwitchList:e.switchList,ref:"list"},null,8,["aplayer","onPlay","onToggle","onSwitchList"])):t.createCommentVNode("",!0),t.createElementVNode("div",{class:"aplayer-body",style:t.normalizeStyle({width:`${e.aplayer.mode==="fixed"?"calc(100% - 18px)":"100%"}`})},[t.createElementVNode("div",{class:"aplayer-pic",style:t.normalizeStyle(e.coverStyle),onClick:a[0]||(a[0]=(...h)=>e.toggle&&e.toggle(...h))},[t.createElementVNode("div",{class:t.normalizeClass(["aplayer-button",{"aplayer-play":!e.audioStatus.playStatus,"aplayer-pause":e.audioStatus.playStatus}])},[t.createElementVNode("div",Tt,[t.withDirectives(t.createVNode(r,{type:"play"},null,512),[[t.vShow,!e.audioStatus.playStatus]]),t.withDirectives(t.createVNode(r,{type:"pause"},null,512),[[t.vShow,e.audioStatus.playStatus]])],512)],2)],4),t.createElementVNode("div",kt,[t.createElementVNode("div",Lt,[t.createElementVNode("span",Nt,t.toDisplayString(e.aplayer.audio[e.aplayer.index]?e.aplayer.audio[e.aplayer.index].name:"No Audio"),1),t.createElementVNode("span",$t,t.toDisplayString(e.aplayer.audio[e.aplayer.index]?" - "+e.aplayer.audio[e.aplayer.index].artist:""),1)]),e.aplayer.mode==="normal"?t.withDirectives((t.openBlock(),t.createBlock(d,{key:0,aplayer:e.aplayer,ref:"lyric"},null,8,["aplayer"])),[[t.vShow,e.aplayer.lyricShow]]):t.createCommentVNode("",!0),t.createVNode(u,{aplayer:e.aplayer,audioStatus:e.audioStatus,styleStatus:e.styleStatus,onPlayedTime:e.playedTime,onDisableTimeUpdate:e.disableTimeUpdate,onToggle:e.toggle,onSkipBack:e.skipBack,onSkipForward:e.skipForward,onSeek:e.seek,onMute:e.mute,onSetLoop:e.setLoop,onSetOrder:e.setOrder,onToggleList:e.toggleList,onToggleLrc:e.toggleLrc,onSetVolume:e.setVolume},null,8,["aplayer","audioStatus","styleStatus","onPlayedTime","onDisableTimeUpdate","onToggle","onSkipBack","onSkipForward","onSeek","onMute","onSetLoop","onSetOrder","onToggleList","onToggleLrc","onSetVolume"])],512),t.createElementVNode("div",{class:"aplayer-notice",style:t.normalizeStyle({opacity:e.aplayer.noticeOpacity})},t.toDisplayString(e.aplayer.noticeText),5),t.createElementVNode("div",{class:"aplayer-miniswitcher",onClick:a[1]||(a[1]=h=>e.styleStatus.mini=!e.styleStatus.mini)},[t.createElementVNode("button",_t,[t.createVNode(r,{type:"right"})])])],4),e.aplayer.mode==="normal"?(t.openBlock(),t.createBlock(s,{key:1,aplayer:e.aplayer,onPlay:e.play,onToggle:e.toggle,onSwitchList:e.switchList,ref:"list"},null,8,["aplayer","onPlay","onToggle","onSwitchList"])):t.createCommentVNode("",!0),e.aplayer.mode==="fixed"?t.withDirectives((t.openBlock(),t.createBlock(d,{key:2,aplayer:e.aplayer,ref:"lyric"},null,8,["aplayer"])),[[t.vShow,e.aplayer.lyricShow]]):t.createCommentVNode("",!0),t.createElementVNode("audio",Vt,null,512)],2))}const f=g(Bt,[["render",bt]]);f.install=e=>{e.component(f.name,f)};module.exports=f; //# sourceMappingURL=vue-aplayer.cjs.map