(function($){const $listTable=$("#update-plugins-table,.wp-list-table.plugins");const Plugin=function(data,parent){this.data=data;this.parent=parent;this.$check=$listTable.find('.check-column [value="'+data.basename+'"]');this.$row=this.$check.closest("tr");this.$noticeContainer=null};Plugin.prototype.checkAgainLink=function(){return' '+as3cf_dbrains.strings.check_licence_again+""};Plugin.prototype.hasLicenseErrors=function(){const license=this.isAddon()?this.parent.data.license:this.data.license;return!_.isEmpty(license.errors)};Plugin.prototype.disableUpdateCheckbox=function(){if($listTable.is("#update-plugins-table")){this.$check.prop({disabled:true,checked:false})}};Plugin.prototype.enableUpdateCheckbox=function(){if($listTable.is("#update-plugins-table")){this.$check.prop({disabled:false})}};Plugin.prototype.setNotice=function(html){this.$noticeContainer.find(".as3cf-licence-notice").remove();this.$noticeContainer.append('
'+'

'+html+this.checkAgainLink()+"

"+"
")};Plugin.prototype.clearNotice=function(){const plugin=this;const $notice=this.$noticeContainer.find(".as3cf-licence-notice");$.when($notice.fadeOut()).done((function(){$notice.remove();plugin.$row.children().css("box-shadow","");plugin.$noticeContainer.find(".update-message").show()}))};Plugin.prototype.render=function(){if(this.hasLicenseErrors()){this.initNoticeContainer();this.disableUpdateCheckbox();this.$noticeContainer.find('.update-message:not(".as3cf-licence-notice")').hide();this.setNotice(this.getLicenseNotice())}else if(this.$noticeContainer){this.enableUpdateCheckbox();this.clearNotice()}if(!this.isAddon()){_.invoke(this.addons,"render")}};Plugin.prototype.initNoticeContainer=function(){if(this.$noticeContainer){return}if(!$listTable.is("#update-plugins-table")){const $noticeRow=$listTable.find('.plugin-update-tr[data-plugin="'+this.data.basename+'"]');if($noticeRow.length){this.$noticeContainer=$noticeRow.find(".plugin-update")}else{const colspan=this.$row.children().length;this.$row.after('"+''+"");this.$row.children().css("box-shadow","none");this.$noticeContainer=$listTable.find('.plugin-update-tr[data-plugin="'+this.data.basename+'"] .plugin-update')}}else{this.$noticeContainer=this.$row.find(".plugin-title")}this.$noticeContainer.on("click",".as3cf-dbrains-check-my-licence-again a",_.bind(this.checkLicenseAgain,this))};Plugin.prototype.getLicenseNotice=function(){let message="";if(this.data.update_available){message=as3cf_dbrains.strings.update_available+" "}if(this.isAddon()){return message+as3cf_dbrains.strings.requires_parent_licence.replace("%s",this.parent.data.name)}return message+_.values(this.data.license.errors).join("")};Plugin.prototype.checkLicenseAgain=function(event){const plugin=this;const $link=$(event.target);const $spinner=$('');event.preventDefault();$link.hide().after($spinner);this.ajaxCheckLicense().done((function(data){if(plugin.isAddon()){plugin.parent.data.license.errors=data.errors;plugin.parent.render()}else{plugin.data.license.errors=data.errors;plugin.render()}})).fail((function(){plugin.setNotice(as3cf_dbrains.strings.licence_check_problem)})).always((function(){$spinner.remove()}))};Plugin.prototype.ajaxCheckLicense=function(){const prefix=this.isAddon()?this.parent.data.prefix:this.data.prefix;return $.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:false,data:{action:prefix+"_check_licence",nonce:as3cf_dbrains.nonces.check_licence}})};Plugin.prototype.init=function(){this.render();if(!this.isAddon()){this.initAddons()}};Plugin.prototype.isAddon=function(){return!!this.parent};Plugin.prototype.initAddons=function(){const parent=this;this.addons=_.map(this.data.addons,(function(addonData){return new Plugin(addonData,parent)}));_.invoke(this.addons,"init")};function initialize(){_.chain(as3cf_dbrains.plugins).map((function(pluginData){return new Plugin(pluginData)})).invoke("init")}if($listTable.length){$(initialize)}})(jQuery);