text: "use strict";
  
  function _classCallCheck(e, t) {
      if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
  }
  var _createClass = function() {
      function e(e, t) {
          for (var a = 0; a < t.length; a++) {
              var i = t[a];
              i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
          }
      }
      return function(t, a, i) {
          return a && e(t.prototype, a), i && e(t, i), t
      }
  }();
  ! function(e) {
      var t = function() {
          function t(e) {
              var a = this;
              _classCallCheck(this, t), this.isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i), this.isMobile && (e.autoplay = !1);
              var i = {
                  element: document.getElementsByClassName("aplayer")[0],
                  narrow: !1,
                  autoplay: !1,
                  mutex: !0,
                  showlrc: 0,
                  theme: "#b7daff",
                  loop: !0
              };
              for (var s in i) i.hasOwnProperty(s) && !e.hasOwnProperty(s) && (e[s] = i[s]);
              this.playIndex = "[object Array]" === Object.prototype.toString.call(e.music) ? 0 : -1, this.option = e, this.audios = [], this.loop = e.loop, this.secondToTime = function(e) {
                  var t = function(e) {
                          return 10 > e ? "0" + e : "" + e
                      },
                      a = parseInt(e / 60),
                      i = parseInt(e - 60 * a);
                  return t(a) + ":" + t(i)
              }, this.parseLrc = function(e) {
                  for (var t = [], a = 0; a < e.length; a++) {
                      for (var i = e[a].split("\n"), s = [], n = i.length, l = 0; n > l; l++) {
                          var o = i[l].match(/\[(\d{2}):(\d{2})\.(\d{2,3})]/g),
                              r = i[l].replace(/\[(\d{2}):(\d{2})\.(\d{2,3})]/g, "").replace(/^\s+|\s+$/g, "");
                          if (null != o)
                              for (var d = o.length, u = 0; d > u; u++) {
                                  var p = /\[(\d{2}):(\d{2})\.(\d{2,3})]/.exec(o[u]),
                                      c = 60 * p[1] + parseInt(p[2]) + parseInt(p[3]) / (2 === (p[3] + "").length ? 100 : 1e3);
                                  s.push([c, r])
                              }
                      }
                      s.sort(function(e, t) {
                          return e[0] - t[0]
                      }), t.push(s)
                  }
                  return t
              }, this.updateBar = function(e, t, i) {
                  t = t > 0 ? t : 0, t = 1 > t ? t : 1, a[e + "Bar"].style[i] = 100 * t + "%"
              }, this.updateLrc = function() {
                  var e = arguments.length <= 0 || void 0 === arguments[0] ? a.audio.currentTime : arguments[0];
                  if (a.lrcIndex > a.lrc.length - 1 || e < a.lrc[a.lrcIndex][0] || !a.lrc[a.lrcIndex + 1] || e >= a.lrc[a.lrcIndex + 1][0])
                      for (var t = 0; t < a.lrc.length; t++) e >= a.lrc[t][0] && (!a.lrc[t + 1] || e < a.lrc[t + 1][0]) && (a.lrcIndex = t, a.lrcContents.style.transform = "translateY(" + 20 * -a.lrcIndex + "px)", a.lrcContents.style.webkitTransform = "translateY(" + 20 * -a.lrcIndex + "px)", a.lrcContents.getElementsByClassName("aplayer-lrc-current")[0].classList.remove("aplayer-lrc-current"), a.lrcContents.getElementsByTagName("p")[t].classList.add("aplayer-lrc-current"))
              }, this.eventTypes = ["play", "pause", "canplay", "playing", "ended", "error"], this.event = {};
              var n = !0,
                  l = !1,
                  o = void 0;
              try {
                  for (var r, d = this.eventTypes[Symbol.iterator](); !(n = (r = d.next()).done); n = !0) {
                      var u = r.value;
                      this.event[u] = []
                  }
              } catch (p) {
                  l = !0, o = p
              } finally {
                  try {
                      !n && d["return"] && d["return"]()
                  } finally {
                      if (l) throw o
                  }
              }
              this.trigger = function(e) {
                  var t = !0,
                      i = !1,
                      s = void 0;
                  try {
                      for (var n, l = a.event[e][Symbol.iterator](); !(t = (n = l.next()).done); t = !0) {
                          var o = n.value;
                          o()
                      }
                  } catch (r) {
                      i = !0, s = r
                  } finally {
                      try {
                          !t && l["return"] && l["return"]()
                      } finally {
                          if (i) throw s
                      }
                  }
              }
          }
          return _createClass(t, [{
              key: "init",
              value: function() {
                  function t(e) {
                      for (var t = e.offsetLeft, a = e.offsetParent, i = void 0; null !== a;) t += a.offsetLeft, a = a.offsetParent;
                      return i = document.body.scrollLeft + document.documentElement.scrollLeft, t - i
                  }
  
                  function a(e) {
                      for (var t = e.offsetTop, a = e.offsetParent, i = void 0; null !== a;) t += a.offsetTop, a = a.offsetParent;
                      return i = document.body.scrollTop + document.documentElement.scrollTop, t - i
                  }
                  var i = this;
                  this.element = this.option.element, this.multiple = this.playIndex > -1, this.music = this.multiple ? this.option.music[this.playIndex] : this.option.music;
                  var s = void 0;
                  if (this.option.showlrc) {
                      var n = [];
                      if (1 === this.option.showlrc)
                          if (this.multiple)
                              for (s = 0; s < this.option.music.length; s++) n.push(this.option.music[s].lrc);
                          else n.push(this.option.music.lrc);
                      else if (2 === this.option.showlrc || this.option.showlrc === !0)
                          for (s = 0; s < this.element.getElementsByClassName("aplayer-lrc-content").length; s++) n.push(this.element.getElementsByClassName("aplayer-lrc-content")[s].innerHTML);
                      this.lrcs = this.parseLrc(n)
                  }
                  this.option.showlrc && this.element.classList.add("aplayer-withlrc");
                  var l = '\n                <div class="aplayer-pic" ' + (this.music.pic ? 'style="background-image: url("' + encodeURI(this.music.pic) + '");"' : "") + '>\n                    <div class="aplayer-button aplayer-play">\n                        <i class="demo-icon aplayer-icon-play"></i>\n                    </div>\n                </div>\n                <div class="aplayer-info">\n                    <div class="aplayer-music">\n                        <span class="aplayer-title"></span>\n                        <span class="aplayer-author"></span>\n                    </div>\n                    <div class="aplayer-lrc">\n                        <div class="aplayer-lrc-contents" style="transform: translateY(0); -webkit-transform: translateY(0);"></div>\n                    </div>\n                    <div class="aplayer-controller">\n                        <div class="aplayer-bar-wrap">\n                            <div class="aplayer-bar">\n                                <div class="aplayer-loaded" style="width: 0"></div>\n                                <div class="aplayer-played" style="width: 0; background: ' + this.option.theme + ';">\n                                    <span class="aplayer-thumb" style="border: 1px solid ' + this.option.theme + ';"></span>\n                                </div>\n                            </div>\n                        </div>\n                        <div class="aplayer-time">\n                             - <span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>\n                            <div class="aplayer-volume-wrap">\n                                <i class="demo-icon aplayer-icon-volume-down"></i>\n                                <div class="aplayer-volume-bar-wrap">\n                                    <div class="aplayer-volume-bar">\n                                        <div class="aplayer-volume" style="height: 50%; background: ' + this.option.theme + ';"></div>\n                                    </div>\n                                </div>\n                            </div>\n                            <i class="demo-icon aplayer-icon-loop' + (this.loop ? "" : " aplayer-noloop") + '"></i>' + (this.multiple ? '<i class="demo-icon aplayer-icon-menu"></i>' : "") + "\n                        </div>\n                    </div>\n                </div>";
                  if (this.multiple) {
                      for (l += '\n                <div class="aplayer-list" id="aplayer-list">\n                    <ol>', s = 0; s < this.option.music.length; s++) l += '\n                        <li>\n                            <span class="aplayer-list-cur" style="background: ' + this.option.theme + ';"></span>\n                            <span class="aplayer-list-index">' + (s + 1) + '</span>\n                            <span class="aplayer-list-title">' + this.option.music[s].title + '</span>\n                            <span class="aplayer-list-author">' +" - " + this.option.music[s].artist + '</span>\n                            <span class="aplayer-list-download"><a class="download" href='+this.option.music[s].url+' download><i class="fa fa-download" aria-hidden="true"></i></a>' + "</span>\n                        </li>";
                      l += "\n                    </ol>\n                </div>"
                  }
                  this.element.innerHTML = l, this.ptime = this.element.getElementsByClassName("aplayer-ptime")[0], this.element.getElementsByClassName("aplayer-info")[0].offsetWidth < 200 && this.element.getElementsByClassName("aplayer-time")[0].classList.add("aplayer-time-narrow"), this.element.getElementsByClassName("aplayer-bar-wrap")[0].style.marginRight = this.element.getElementsByClassName("aplayer-time")[0].offsetWidth + 5 + "px", this.option.narrow && this.element.classList.add("aplayer-narrow"), this.button = this.element.getElementsByClassName("aplayer-button")[0], this.button.addEventListener("click", function(e) {
                      i.button.classList.contains("aplayer-play") ? i.play() : i.button.classList.contains("aplayer-pause") && i.pause()
                  }), this.multiple && ! function() {
                      for (var e = i.element.getElementsByClassName("aplayer-list")[0].getElementsByTagName("li"), t = function(t) {
                              e[t].addEventListener("click", function() {
                                  var a = parseInt(e[t].getElementsByClassName("aplayer-list-index")[0].innerHTML) - 1;
                                  a !== i.playIndex && i.setMusic(a), i.play()
                              })
                          }, a = 0; a < i.option.music.length; a++) t(a)
                  }(), this.playedBar = this.element.getElementsByClassName("aplayer-played")[0], this.loadedBar = this.element.getElementsByClassName("aplayer-loaded")[0], this.thumb = this.element.getElementsByClassName("aplayer-thumb")[0], this.bar = this.element.getElementsByClassName("aplayer-bar")[0];
                  var o = void 0;
                  this.bar.addEventListener("click", function(e) {
                      var a = e || window.event;
                      o = i.bar.clientWidth;
                      var s = (a.clientX - t(i.bar)) / o;
                      i.updateBar("played", s, "width"), i.element.getElementsByClassName("aplayer-ptime")[0].innerHTML = i.secondToTime(s * i.audio.duration), i.audio.currentTime = parseFloat(i.playedBar.style.width) / 100 * i.audio.duration
                  }), this.thumb.addEventListener("mouseover", function() {
                      i.thumb.style.background = i.option.theme
                  }), this.thumb.addEventListener("mouseout", function() {
                      i.thumb.style.background = "#fff"
                  });
                  var r = function(e) {
                          var a = e || window.event,
                              s = (a.clientX - t(i.bar)) / o;
                          s = s > 0 ? s : 0, s = 1 > s ? s : 1, i.updateBar("played", s, "width"), i.option.showlrc && i.updateLrc(parseFloat(i.playedBar.style.width) / 100 * i.audio.duration), i.element.getElementsByClassName("aplayer-ptime")[0].innerHTML = i.secondToTime(s * i.audio.duration)
                      },
                      d = function h() {
                          document.removeEventListener("mouseup", h), document.removeEventListener("mousemove", r), i.audio.currentTime = parseFloat(i.playedBar.style.width) / 100 * i.audio.duration, i.playedTime = setInterval(function() {
                              i.updateBar("played", i.audio.currentTime / i.audio.duration, "width"), i.option.showlrc && i.updateLrc(), i.element.getElementsByClassName("aplayer-ptime")[0].innerHTML = i.secondToTime(i.audio.currentTime), i.trigger("playing")
                          }, 100)
                      };
                  this.thumb.addEventListener("mousedown", function() {
                      o = i.bar.clientWidth, clearInterval(i.playedTime), document.addEventListener("mousemove", r), document.addEventListener("mouseup", d)
                  }), this.volumeBar = this.element.getElementsByClassName("aplayer-volume")[0];
                  var u = this.element.getElementsByClassName("aplayer-volume-bar")[0],
                      p = this.element.getElementsByClassName("aplayer-time")[0].getElementsByTagName("i")[0],
                      c = 35;
                  this.element.getElementsByClassName("aplayer-volume-bar-wrap")[0].addEventListener("click", function(e) {
                      var t = e || window.event,
                          s = (c - t.clientY + a(u)) / c;
                      s = s > 0 ? s : 0, s = 1 > s ? s : 1, i.updateBar("volume", s, "height"), i.audio.volume = s, i.audio.muted && (i.audio.muted = !1), 1 === s ? p.className = "demo-icon aplayer-icon-volume-up" : p.className = "demo-icon aplayer-icon-volume-down"
                  }), p.addEventListener("click", function() {
                      i.audio.muted ? (i.audio.muted = !1, p.className = 1 === i.audio.volume ? "demo-icon aplayer-icon-volume-up" : "demo-icon aplayer-icon-volume-down", i.updateBar("volume", i.audio.volume, "height")) : (i.audio.muted = !0, p.className = "demo-icon aplayer-icon-volume-off", i.updateBar("volume", 0, "height"))
                  });
                  var m = this.element.getElementsByClassName("aplayer-icon-loop")[0];
                  m.addEventListener("click", function() {
                      i.loop ? (m.classList.add("aplayer-noloop"), i.loop = !1, i.audio.loop = i.multiple ? !1 : i.loop) : (m.classList.remove("aplayer-noloop"), i.loop = !0, i.audio.loop = i.multiple ? !1 : i.loop)
                  }), this.multiple && this.element.getElementsByClassName("aplayer-icon-menu")[0].addEventListener("click", function() {
                      var e = i.element.getElementsByClassName("aplayer-list")[0];
                      e.classList.contains("aplayer-list-hide") ? e.classList.remove("aplayer-list-hide") : e.classList.add("aplayer-list-hide")
                  }), this.setMusic(0), e.push(this)
              }
          }, {
              key: "setMusic",
              value: function(e) {
                  var t = this;
                  this.multiple && "undefined" != typeof e && (this.playIndex = e);
                  var a = this.playIndex;
                  if (this.music = this.multiple ? this.option.music[a] : this.option.music, this.music.pic && (this.element.getElementsByClassName("aplayer-pic")[0].style.backgroundImage = "url(" + encodeURI(this.music.pic) + ")"), this.element.getElementsByClassName("aplayer-title")[0].innerHTML = this.music.title, this.element.getElementsByClassName("aplayer-author")[0].innerHTML = " - " + this.music.artist, this.multiple && (this.element.getElementsByClassName("aplayer-list-light")[0] && this.element.getElementsByClassName("aplayer-list-light")[0].classList.remove("aplayer-list-light"), this.element.getElementsByClassName("aplayer-list")[0].getElementsByTagName("li")[a].classList.add("aplayer-list-light")), this.audio && (this.pause(), this.audio.currentTime = 0), this.multiple && !this.audios[a] || -1 === this.playIndex ? (this.audio = document.createElement("audio"), this.audio.src = this.music.url, this.audio.preload = this.isMobile ? "none" : "metadata", this.audio.addEventListener("durationchange", function() {
                          1 !== t.audio.duration && (t.element.getElementsByClassName("aplayer-dtime")[0].innerHTML = t.secondToTime(t.audio.duration))
                      }), this.audio.addEventListener("progress", function() {
                          var e = t.audio.buffered.length ? t.audio.buffered.end(t.audio.buffered.length - 1) / t.audio.duration : 0;
                          t.updateBar("loaded", e, "width")
                      }), this.audio.addEventListener("error", function() {
                          t.element.getElementsByClassName("aplayer-author")[0].innerHTML = " - Error happens ╥﹏╥", t.trigger("pause")
                      }), this.audio.addEventListener("canplay", function() {
                          t.trigger("canplay")
                      }), this.ended = !1, this.multiple ? this.audio.addEventListener("ended", function() {
                          t.playIndex < t.option.music.length - 1 ? t.setMusic(++t.playIndex) : t.loop ? t.setMusic(0) : t.loop || (t.ended = !0, t.pause(), t.trigger("ended"))
                      }) : this.audio.addEventListener("ended", function() {
                          t.loop || (t.ended = !0, t.pause(), t.trigger("ended"))
                      }), this.audio.volume = parseInt(this.element.getElementsByClassName("aplayer-volume")[0].style.height) / 100, this.audio.loop = this.multiple ? !1 : this.loop, this.multiple && (this.audios[a] = this.audio)) : (this.audio = this.audios[a], this.audio.volume = parseInt(this.element.getElementsByClassName("aplayer-volume")[0].style.height) / 100, this.audio.currentTime = 0), this.option.showlrc) {
                      this.lrc = this.multiple ? this.lrcs[a] : this.lrcs[0];
                      var i = "";
                      this.lrcContents = this.element.getElementsByClassName("aplayer-lrc-contents")[0];
                      for (var s = 0; s < this.lrc.length; s++) i += "<p>" + this.lrc[s][1] + "</p>";
                      this.lrcContents.innerHTML = i, this.lrcIndex || (this.lrcIndex = 0), this.lrcContents.getElementsByTagName("p")[0].classList.add("aplayer-lrc-current"), this.lrcContents.style.transform = "translateY(0px)", this.lrcContents.style.webkitTransform = "translateY(0px)"
                  }
                  1 !== this.audio.duration && (this.element.getElementsByClassName("aplayer-dtime")[0].innerHTML = this.audio.duration ? this.secondToTime(this.audio.duration) : "00:00"), this.option.autoplay && !this.isMobile && this.play(), this.option.autoplay = !0, this.isMobile && this.pause()
              }
          }, {
              key: "play",
              value: function() {
                  var t = this;
                  if (this.audio.paused) {
                      if (this.button.classList.remove("aplayer-play"), this.button.classList.add("aplayer-pause"), this.button.innerHTML = "", setTimeout(function() {
                              t.button.innerHTML = '<i class="demo-icon aplayer-icon-pause"></i>'
                          }, 100), this.option.mutex)
                          for (var a = 0; a < e.length; a++) this != e[a] && e[a].pause();
                      this.audio.play(), this.playedTime && clearInterval(this.playedTime), this.playedTime = setInterval(function() {
                          t.updateBar("played", t.audio.currentTime / t.audio.duration, "width"), t.option.showlrc && t.updateLrc(), t.ptime.innerHTML = t.secondToTime(t.audio.currentTime), t.trigger("playing")
                      }, 100), this.trigger("play")
                  }
              }
          }, {
              key: "pause",
              value: function() {
                  var e = this;
                  this.audio.paused && !this.ended || (this.ended = !1, this.button.classList.remove("aplayer-pause"), this.button.classList.add("aplayer-play"), this.button.innerHTML = "", setTimeout(function() {
                      e.button.innerHTML = '<i class="demo-icon aplayer-icon-play"></i>'
                  }, 100), this.audio.pause(), clearInterval(this.playedTime), this.trigger("pause"))
              }
          }, {
              key: "on",
              value: function(e, t) {
                  "function" == typeof t && this.event[e].push(t)
              }
          }]), t
      }();
      "undefined" != typeof module && "undefined" != typeof module.exports ? module.exports = t : window.APlayer = t
  }([]);
  //# sourceMappingURL=APlayer.min.js.map