(()=>{var e={1669:e=>{"use strict";e.exports=jQuery}},a={};function d(t){var n=a[t];if(void 0!==n)return n.exports;var r=a[t]={exports:{}};return e[t](r,r.exports,d),r.exports}var t=d(1669),n=d(1669);const r={inProgress:!1,init:function(){t(".edd-v3-migration-confirmation").on("change",(function(e){const a=t(this).closest(".edd-v3-migration").find("button");e.target.checked?a.removeClass("disabled").prop("disabled",!1):a.addClass("disabled").prop("disabled",!0)})),t(".edd-v3-migration").on("submit",(function(e){if(e.preventDefault(),r.inProgress)return;r.inProgress=!0;const a=t(this),d=a.find('input[name="upgrade_key"]');let n=!1;if(d.length&&d.val()&&(n=d.val()),a.find("button").removeClass("button-primary").addClass("button-secondary disabled updating-message").prop("disabled",!0),a.find("input").prop("disabled",!0),"edd-v3-migration"===a.attr("id")){t("#edd-migration-progress").removeClass("edd-hidden");const e=t("#edd-migration-progress li:not(.edd-upgrade-complete)");e.length&&!n&&(n=e.data("upgrade"))}r.processStep(n,1,a.find('input[name="_wpnonce"]').val())}))},processStep:function(e,a,d){let n={action:"edd_process_v3_upgrade",_ajax_nonce:d,upgrade_key:e,step:a};r.clearErrors(),e&&r.markUpgradeInProgress(e),t.ajax({type:"POST",data:n,url:ajaxurl,success:function(a){if(a.success){if(a.data.upgrade_completed){if(r.markUpgradeComplete(a.data.upgrade_processed),"v30_legacy_data_removed"===a.data.upgrade_processed)return void r.legacyDataRemovalComplete()}else a.data.percentage&&r.updateUpgradePercentage(a.data.upgrade_processed,a.data.percentage);a.data.next_upgrade&&"v30_legacy_data_removed"===a.data.next_upgrade&&"v30_legacy_data_removed"!==a.data.upgrade_processed?(r.inProgress=!1,r.showLegacyDataRemoval()):a.data.next_upgrade?r.processStep(a.data.next_upgrade,a.data.next_step,a.data.nonce):(r.inProgress=!1,r.stopAllSpinners())}else r.showError(e,a.data)}}).fail((e=>{}))},clearErrors:function(){t(".edd-v3-migration-error").addClass("edd-hidden").html("")},showError:function(e,a){let d=t("#edd-v3-migration");"v30_legacy_data_removed"===e&&(d=t("#edd-v3-remove-legacy-data")),d.find(".edd-v3-migration-error").html("<p>"+a+"</p>").removeClass("edd-hidden"),r.inProgress=!1,d.find("input").prop("disabled",!1),d.find("button").prop("disabled",!1).addClass("button-primary").removeClass("button-secondary disabled updating-message")},markUpgradeInProgress:function(e){const a=t("#edd-v3-migration-"+e);if(!a.length)return;const d=a.find(".dashicons");d.length&&d.removeClass("dashicons-minus").addClass("dashicons-update"),a.find(".edd-migration-percentage").removeClass("edd-hidden")},updateUpgradePercentage:function(e,a){const d=t("#edd-v3-migration-"+e);d.length&&d.find(".edd-migration-percentage-value").text(a)},markUpgradeComplete:function(e){const a=t("#edd-v3-migration-"+e);if(!a.length)return;a.addClass("edd-upgrade-complete");const d=a.find(".dashicons");d.length&&d.removeClass("dashicons-minus dashicons-update").addClass("dashicons-yes");const n=a.find(".edd-migration-status .screen-reader-text");n.length&&n.text(edd_admin_upgrade_vars.migration_complete),a.find(".edd-migration-percentage-value").text(100)},showLegacyDataRemoval:function(){t("#edd-v3-migration-button").removeClass("updating-message"),t("#edd-v3-migration-complete").removeClass("edd-hidden");const e=t("#edd-v3-remove-legacy-data");e.length&&e.removeClass("edd-hidden")},legacyDataRemovalComplete:function(){const e=t("#edd-v3-remove-legacy-data");e.length&&(e.find("form").addClass("edd-hidden"),e.find("#edd-v3-legacy-data-removal-complete").removeClass("edd-hidden"))},stopAllSpinners:function(){}};n(document).ready((function(e){r.init()}))})();