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