(self.webpackChunk=self.webpackChunk||[]).push([[5150],{5150:function(t,e,a){"use strict";a.r(e);var i=a(1197),s=a(47005),l=a(53754),n=a(78066),d=a(53913);function r(t){var e=this,a=e.getAttribute("data-id"),i=e.getAttribute("data-serverid"),s=d.ZP.getApiClient(i);e.classList.contains("playstatebutton-played")?(s.markUnplayed(s.getCurrentUserId(),a,new Date),u(e,!1)):(s.markPlayed(s.getCurrentUserId(),a,new Date),u(e,!0))}function c(t,e,a){a.ItemId===this.getAttribute("data-id")&&u(this,a.Played)}function u(t,e,a){var i=t.iconElement;i||(t.iconElement=t.querySelector(".material-icons"),i=t.iconElement),e?(t.classList.add("playstatebutton-played"),i&&(i.classList.add("playstatebutton-icon-played"),i.classList.remove("playstatebutton-icon-unplayed"))):(t.classList.remove("playstatebutton-played"),i&&(i.classList.remove("playstatebutton-icon-played"),i.classList.add("playstatebutton-icon-unplayed"))),!1!==a&&t.setAttribute("data-played",e)}function o(t,e){t.title="AudioBook"!==e&&"AudioPodcast"!==e?l.ZP.translate("Watched"):l.ZP.translate("Played");var a=t.querySelector(".button-text");a&&(a.innerHTML=t.title)}function b(t){var e,a,l;t.removeEventListener("click",r),(l=(e=t)[a="UserDataChanged"])&&(s.Events.off(i.default,a,l),e[a]=null)}function h(t){var e,a,l;b(t),t.addEventListener("click",r),e=t,a="UserDataChanged",l=c.bind(e),s.Events.on(i.default,a,l),e[a]=l}var y=Object.create(n.Z);y.createdCallback=function(){n.Z.createdCallback&&n.Z.createdCallback.call(this)},y.attachedCallback=function(){n.Z.attachedCallback&&n.Z.attachedCallback.call(this);var t=this.getAttribute("data-id"),e=this.getAttribute("data-serverid");t&&e&&(u(this,"true"===this.getAttribute("data-played"),!1),h(this),o(this,this.getAttribute("data-type")))},y.detachedCallback=function(){n.Z.detachedCallback&&n.Z.detachedCallback.call(this),b(this),this.iconElement=null},y.setItem=function(t){t?(this.setAttribute("data-id",t.Id),this.setAttribute("data-serverid",t.ServerId),u(this,t.UserData&&t.UserData.Played),h(this),o(this,t.Type)):(this.removeAttribute("data-id"),this.removeAttribute("data-serverid"),this.removeAttribute("data-played"),b(this))},document.registerElement("emby-playstatebutton",{prototype:y,extends:"button"})}}]);