"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[15605],{15605:function(t,e,a){a.r(e);var i=a(10736),r=a(9482),s=a(62014),n=a(10353),d=a(86191);function l(){var t=this,e=t.getAttribute("data-id"),a=t.getAttribute("data-serverid"),i=d.A.getApiClient(a),r=this.getAttribute("data-likes");r="true"===r||"false"!==r&&null,function(t,e,a,i,r){return e.updateFavoriteStatus(e.getCurrentUserId(),a,!r)}(0,i,e,0,"true"===this.getAttribute("data-isfavorite")).then((function(e){c(t,e.Likes,e.IsFavorite)}))}function u(t,e,a){a.ItemId===this.getAttribute("data-id")&&c(this,a.Likes,a.IsFavorite)}function c(t,e,a,i){var r=t.querySelector(".material-icons");a?(r&&(r.classList.add("favorite"),r.classList.add("ratingbutton-icon-withrating")),t.classList.add("ratingbutton-withrating")):(r&&(r.classList.add("favorite"),r.classList.remove("ratingbutton-icon-withrating")),t.classList.remove("ratingbutton-withrating")),!1!==i&&(t.setAttribute("data-isfavorite",a),t.setAttribute("data-likes",null===e?"":e)),o(t,a)}function o(t,e){t.title=e?r.Ay.translate("Favorite"):r.Ay.translate("AddToFavorites");var a=t.querySelector(".button-text");a&&(a.innerText=t.title)}function h(t){var e,a,r;t.removeEventListener("click",l),(r=(e=t)[a="UserDataChanged"])&&(s.A.off(i.default,a,r),e[a]=null)}function b(t){var e,a,r;h(t),t.addEventListener("click",l),e=t,a="UserDataChanged",r=u.bind(e),s.A.on(i.default,a,r),e[a]=r}var v=Object.create(n.A);v.createdCallback=function(){n.A.createdCallback&&n.A.createdCallback.call(this)},v.attachedCallback=function(){n.A.attachedCallback&&n.A.attachedCallback.call(this);var t=this.getAttribute("data-id"),e=this.getAttribute("data-serverid");if(t&&e){var a=this.getAttribute("data-likes");c(this,a="true"===a||"false"!==a&&null,"true"===this.getAttribute("data-isfavorite"),!1),b(this)}else o(this)},v.detachedCallback=function(){n.A.detachedCallback&&n.A.detachedCallback.call(this),h(this)},v.setItem=function(t){if(t){this.setAttribute("data-id",t.Id),this.setAttribute("data-serverid",t.ServerId);var e=t.UserData||{};c(this,e.Likes,e.IsFavorite),b(this)}else this.removeAttribute("data-id"),this.removeAttribute("data-serverid"),this.removeAttribute("data-likes"),this.removeAttribute("data-isfavorite"),h(this)},document.registerElement("emby-ratingbutton",{prototype:v,extends:"button"})}}]);