var KnowledgeBaseArticle;(function(n){var t=function(){function n(){}return n}(),i=function(){function n(n,t){var i=this,u,r,f;this.jqueryElement=n;this.userHasAlreadyVoted=t.userHasAlreadyVoted;this.postVoteUrl=t.postVoteUrl;this.articleId=t.articleId;this.votingComponenent=$(this.jqueryElement).find("[data-selector='knowledge-base-article-voting']");this.upVoteBtn=$(this.jqueryElement).find("[data-selector='upvote-article']");this.downVoteBtn=$(this.jqueryElement).find("[data-selector='downvote-article']");u=$.cookie("votedKbArticles");u!==undefined&&(r=JSON.parse(u),r!==undefined&&(r.some(function(n){return n.KbArticle===i.articleId})&&(f=r.filter(function(n){return n.KbArticle===i.articleId})[0]),f!==undefined&&this.updateVotingButtons(f.Vote)));$(this.jqueryElement).on("click","[data-selector='upvote-article']",function(n){return i.registerVote(n,!0)});$(this.jqueryElement).on("click","[data-selector='downvote-article']",function(n){return i.registerVote(n,!1)});$(this.jqueryElement).on("click","[data-selector='print-kb-article']",function(){return i.print()})}return n.prototype.registerVote=function(n,t){var i=this;jQuery(n.target).hasClass("c-support-knowledgebase-detail__vote-button-active")||($(n.currentTarget).find(".fa-spin").removeClass("d-none"),$.ajax({method:"POST",dataType:"json",url:this.postVoteUrl,data:{articleId:this.articleId,isUpvote:t},complete:function(){i.updateVotingButtons(t);i.updateVotingCookie(t);$(n.currentTarget).find(".fa-spin").addClass("d-none")}}))},n.prototype.updateVotingButtons=function(n){var t="c-support-knowledgebase-detail__vote-button--active";n?(this.upVoteBtn.addClass(t),this.downVoteBtn.removeClass(t)):(this.upVoteBtn.removeClass(t),this.downVoteBtn.addClass(t))},n.prototype.updateVotingCookie=function(n){var f=this,r=new t,i=[],e=$.cookie("votedKbArticles"),u;e!==undefined&&(i=JSON.parse(e),i!==undefined&&i.some(function(n){return n.KbArticle===f.articleId})&&(r=i.filter(function(n){return n.KbArticle===f.articleId})[0]));r.KbArticle=this.articleId;r.Vote=n;u=$.inArray(r,i);u===-1?i.push(r):i[u]=r;$.cookie("votedKbArticles",JSON.stringify(i),{expires:365})},n.prototype.print=function(){window.print()},n}();n.KnowledgeBaseArticle=i})(KnowledgeBaseArticle||(KnowledgeBaseArticle={}))