(()=>{var t={525(t){const e=jQuery,o=function(){};o.prototype.setDefaultValues=function(){this.model=new Ai1wm.Import,this.stopUpload=!1},o.prototype.init=function(){const t=e("#ai1wm-import-form"),o=e("#ai1wm-import-file"),a=e("#ai1wm-drag-drop-area");o.on("change",e=>{this.setDefaultValues();const o=e.target.files.item(0);o&&(this.fileSize=o.size,this.fileSize>ai1wm_uploader.max_file_size?this.model.setStatus({type:"pro",message:ai1wm_locale.import_from_file}):this.model.checkDiskSpace(this.fileSize,()=>{try{this.onFilesAdded(o),this.onBeforeUpload(o),this.upload(o)}catch(t){this.onError(t)}})),t.trigger("reset"),e.preventDefault()}),a.on("dragenter",t=>{a.addClass("ai1wm-drag-over"),t.preventDefault()}),a.on("dragover",t=>{a.addClass("ai1wm-drag-over"),t.preventDefault()}),a.on("dragleave",t=>{a.removeClass("ai1wm-drag-over"),t.preventDefault()}),a.on("drop",e=>{this.setDefaultValues(),a.removeClass("ai1wm-drag-over");const o=e.originalEvent.dataTransfer.files.item(0);o&&(this.fileSize=o.size,this.fileSize>ai1wm_uploader.max_file_size?this.model.setStatus({type:"pro",message:ai1wm_locale.import_from_file}):this.model.checkDiskSpace(this.fileSize,()=>{try{this.onFilesAdded(o),this.onBeforeUpload(o),this.upload(o)}catch(t){this.onError(t)}})),t.trigger("reset"),e.preventDefault()})},o.prototype.c1=t=>{if("wpress"!==t.name.substr(-6))throw new Error(ai1wm_locale.invalid_archive_extension)},o.prototype.c3=()=>{if(ai1wm_compatibility.messages.length>0)throw new Error(ai1wm_compatibility.messages.join())},o.prototype.onFilesAdded=function(t){this.c1(t),this.c3(t),e(window).on("beforeunload",function(){return ai1wm_locale.stop_importing_your_website})},o.prototype.onBeforeUpload=function(t){const o=this,a=Ai1wm.Util.random(12),i=Ai1wm.Util.form("#ai1wm-import-form").concat({name:"storage",value:a}).concat({name:"archive",value:t.name}).concat({name:"file",value:1});this.model.setParams(i),e.extend(ai1wm_uploader.params,{storage:a,archive:t.name}),this.model.onStop=function(){o.xhr&&o.xhr.abort(),o.stopUpload=!0,o.model.clean()},this.model.setStatus({type:"progress",percent:"0.00"})},o.prototype.upload=function(t){const o=this;this.xhr=null;const a=new FormData;a.append("upload_file",t);for(const t in ai1wm_uploader.params)a.append(t,ai1wm_uploader.params[t]);e.ajax({url:ai1wm_uploader.url,type:"POST",data:a,cache:!1,contentType:!1,processData:!1,xhr:function(){return o.xhr=e.ajaxSettings.xhr(),o.xhr.upload&&o.xhr.upload.addEventListener("progress",function(t){const e=t.loaded/t.total*100;o.model.setStatus({type:"progress",percent:e.toFixed(2)})}),o.xhr},success:function(){o.stopUpload||o.onFileUploaded()},error:function(t,e){if(0===t.status)return void o.onError(new Error(ai1wm_locale.upload_failed_connection_lost),!0);if(413===t.status)return void o.onError(new Error(ai1wm_locale.file_too_large),!0);const a=Ai1wm.Util.json(t.responseText);if(a){const t=JSON.parse(a);if(t.errors.length>0)return void o.onError(new Error(t.errors.at(0).message),!0)}o.onError(new Error(`${ai1wm_locale.upload_failed} (${t.status}): ${t.statusText||e}`),!0)}})},o.prototype.onUploadProgress=function(t){this.model.setStatus({type:"progress",percent:t})},o.prototype.onFileUploaded=function(){this.model.start()},o.prototype.onError=function(t,e=!1){this.model.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:t.message,leftAligned:e})},t.exports=o},37(t,e,o){const a=o(595),i=jQuery,s=function(){const t=this;this.params=[],this.modal=new a,this.modal.onConfirm=function(e){t.onConfirm(e)},this.modal.onBlogs=function(e){t.onBlogs(e)},this.modal.onStop=function(e){e=(e||[]).concat({name:"ai1wm_import_cancel",value:1}),t.onStop(e)},this.modal.onDiskSpaceConfirm=function(e){t.onDiskSpaceConfirm(e)},this.modal.onDecryptPassword=function(e){t.onDecryptPassword(e)}};s.prototype.setParams=function(t){this.params=Ai1wm.Util.list(t)},s.prototype.start=function(t,e){const o=this;if(0===(e=e||0)&&this.stopImport(!1),this.isImportStopped())return;i(window).on("beforeunload",function(){return ai1wm_locale.stop_importing_your_website}),this.setStatus({type:"info",message:ai1wm_locale.preparing_to_import});let a=this.params.concat({name:"secret_key",value:ai1wm_import.secret_key});t&&(a=a.concat(Ai1wm.Util.list(t))),i.ajax({url:ai1wm_import.ajax.url,type:"POST",dataType:"json",data:a,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(){o.getStatus()}).done(function(t){t&&o.run(t)}).fail(function(i){const s=1e3*e;try{const t=Ai1wm.Util.json(i.responseText);if(t){const e=JSON.parse(t).errors.pop();if(e.message)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:e.message,nonce:Ai1wm.Util.findValueByName(a,"storage")})}}catch(t){}if(e>=5)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:ai1wm_locale.unable_to_start_the_import,nonce:Ai1wm.Util.findValueByName(a,"storage")});e++,setTimeout(o.start.bind(o,t,e),s)})},s.prototype.run=function(t,e){const o=this;e=e||0,this.isImportStopped()||i.ajax({url:ai1wm_import.ajax.url,type:"POST",dataType:"json",data:t,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(t){t&&o.run(t)}).fail(function(a){const i=1e3*e;try{const e=Ai1wm.Util.json(a.responseText);if(e){const a=JSON.parse(e).errors.pop();if(a.message)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:a.message,nonce:Ai1wm.Util.findValueByName(t,"storage")})}}catch(t){}e++,setTimeout(o.run.bind(o,t,e),i)})},s.prototype.decryptPassword=function(t,e){const o=this;if(e=e||0,this.isImportStopped())return;let a=this.params.concat({name:"secret_key",value:ai1wm_import.secret_key}).concat({name:"priority",value:75});t&&(a=a.concat(Ai1wm.Util.list(t)),this.params=this.params.concat(Ai1wm.Util.list(t))),i.ajax({url:ai1wm_import.ajax.url,type:"POST",dataType:"json",data:a,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(){o.getStatus()}).done(function(t){t&&o.run(t)}).fail(function(i){const s=1e3*e;try{const t=Ai1wm.Util.json(i.responseText);if(t){const e=JSON.parse(t).errors.pop();if(e.message)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:e.message,nonce:Ai1wm.Util.findValueByName(a,"storage")})}}catch(t){}if(e>=5)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:ai1wm_locale.unable_to_check_decryption_password,nonce:Ai1wm.Util.findValueByName(a,"storage")});e++,setTimeout(o.decryptPassword.bind(o,t,e),s)})},s.prototype.confirm=function(t,e){const o=this;if(e=e||0,this.isImportStopped())return;let a=this.params.concat({name:"secret_key",value:ai1wm_import.secret_key}).concat({name:"priority",value:150});t&&(a=a.concat(Ai1wm.Util.list(t))),i.ajax({url:ai1wm_import.ajax.url,type:"POST",dataType:"json",data:a,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(){o.getStatus()}).done(function(t){t&&o.run(t)}).fail(function(i){const s=1e3*e;try{const t=Ai1wm.Util.json(i.responseText);if(t){const e=JSON.parse(t).errors.pop();if(e.message)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:e.message,nonce:Ai1wm.Util.findValueByName(a,"storage")})}}catch(t){}if(e>=5)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:ai1wm_locale.unable_to_confirm_the_import,nonce:Ai1wm.Util.findValueByName(a,"storage")});e++,setTimeout(o.confirm.bind(o,t,e),s)})},s.prototype.checkDiskSpace=function(t,e){this.diskSpaceCallback=e;const o=parseInt(ai1wm_disk_space.free,10),a=parseInt(ai1wm_disk_space.factor,10),i=parseInt(ai1wm_disk_space.extra,10);if(o>=0){const e=t*a+i;if(e>o)return void this.setStatus({type:"disk_space_confirm",message:ai1wm_locale.out_of_disk_space.replace("%s",Ai1wm.Util.sizeFormat(e-o))})}e()},s.prototype.blogs=function(t,e){const o=this;if(e=e||0,this.isImportStopped())return;let a=this.params.concat({name:"secret_key",value:ai1wm_import.secret_key}).concat({name:"priority",value:150});t&&(a=a.concat(Ai1wm.Util.list(t))),i.ajax({url:ai1wm_import.ajax.url,type:"POST",dataType:"json",data:a,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(){o.getStatus()}).done(function(t){t&&o.run(t)}).fail(function(i){const s=1e3*e;try{const t=Ai1wm.Util.json(i.responseText);if(t){const e=JSON.parse(t).errors.pop();if(e.message)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:e.message,nonce:Ai1wm.Util.findValueByName(a,"storage")})}}catch(t){}if(e>=5)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:ai1wm_locale.unable_to_prepare_blogs_on_import,nonce:Ai1wm.Util.findValueByName(a,"storage")});e++,setTimeout(o.blogs.bind(o,t,e),s)})},s.prototype.clean=function(t,e){const o=this;0===(e=e||0)&&this.stopImport(!0),this.setStatus({type:"info",message:ai1wm_locale.please_wait_stopping_the_import});let a=this.params.concat({name:"secret_key",value:ai1wm_import.secret_key}).concat({name:"priority",value:400});t&&(a=a.concat(Ai1wm.Util.list(t))),i.ajax({url:ai1wm_import.ajax.url,type:"POST",dataType:"json",data:a,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(){i(window).off("beforeunload"),o.modal.destroy()}).fail(function(i){const s=1e3*e;try{const t=Ai1wm.Util.json(i.responseText);if(t){const e=JSON.parse(t).errors.pop();if(e.message)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:e.message,nonce:Ai1wm.Util.findValueByName(a,"storage")})}}catch(t){}if(e>=5)return o.stopImport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_import,message:ai1wm_locale.unable_to_stop_the_import,nonce:Ai1wm.Util.findValueByName(a,"storage")});e++,setTimeout(o.clean.bind(o,t,e),s)})},s.prototype.getStatus=function(){const t=this;this.isImportStopped()||(this.statusXhr=i.ajax({url:ai1wm_import.status.url,type:"GET",dataType:"json",cache:!1,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(e){if(e)switch(t.setStatus(e),e.type){case"done":case"error":return void i(window).off("beforeunload");case"confirm":case"disk_space_confirm":case"blogs":case"backup_is_encrypted":return}setTimeout(t.getStatus.bind(t),3e3)}).fail(function(){setTimeout(t.getStatus.bind(t),3e3)}))},s.prototype.setStatus=function(t){this.modal.render(t)},s.prototype.onConfirm=function(t){this.confirm(t)},s.prototype.onDecryptPassword=function(t){this.decryptPassword(t)},s.prototype.onBlogs=function(t){this.blogs(t)},s.prototype.onStop=function(t){this.clean(t)},s.prototype.onDiskSpaceConfirm=function(t){this.diskSpaceCallback(t)},s.prototype.stopImport=function(t){try{t&&this.statusXhr&&this.statusXhr.abort()}finally{this.isStopped=t}},s.prototype.isImportStopped=function(){return this.isStopped},t.exports=s},595(t){const e=jQuery,o=function(){const t=this;this.error=function(o){const a=e("
"),i=e(""),s=e(""),n=e("").html(o.message).addClass(o.leftAligned?"ai1wm-left-aligned":""),r=e(""),p=e("").addClass("ai1wm-title-red").text(o.title),l=e('').on("click",function(){t.destroy()});if(l.append(ai1wm_locale.close_import),r.append(l),s.append(p),i.append(s).append(n),o.nonce){const t=e('');t.text(ai1wm_locale.view_error_log_button),t.prop("href",ai1wm_export.storage.url+"/"+ai1wm_export.error_log.pattern.replace("%s",o.nonce)),i.append(e("").append(t))}a.append(i).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.progress=function(o){if(this.progress.progressBarMeter&&this.progress.progressBarMeter.width(o.percent+"%"),this.progress.progressBarPercent)return void this.progress.progressBarPercent.text(o.percent+"%");const a=e(""),i=e(""),s=e(""),n=e(""),r=e('');this.progress.progressBarMeter=e('').width(o.percent+"%"),this.progress.progressBarPercent=e('').text(o.percent+"%");const p=e('').on("click",function(){p.attr("disabled","disabled"),t.onStop()});p.append(' '+ai1wm_locale.stop_import),r.append(this.progress.progressBarMeter).append(this.progress.progressBarPercent),n.append(p),s.append(r),i.append(s),a.append(i).append(n),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.pro=function(o){const a=e(""),i=e(""),s=e(""),n=e('').html(o.message),r=e(""),p=e(''),l=e('').on("click",function(){t.destroy()});l.append(ai1wm_locale.close_import),r.append(l),s.append(p),i.append(s).append(n),a.append(i).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.confirm=function(o){const a=e(""),i=e(""),s=e(""),n=e('').html(o.message),r=e(''),p=e(''),l=e('').on("click",function(){l.attr("disabled","disabled"),t.onStop()}),c=e('').on("click",function(){c.attr("disabled","disabled"),t.onConfirm()});l.append(ai1wm_locale.close_import),c.append(ai1wm_locale.confirm_import+" >"),r.append(l),r.append(c),s.append(p),i.append(s).append(n),a.append(i).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.diskSpaceConfirm=function(o){const a=e(""),i=e(""),s=e(""),n=e('').html(o.message),r=e(''),p=e(''),l=e('').on("click",function(){t.destroy()}),c=e('').on("click",function(){e(this).attr("disabled","disabled"),t.onDiskSpaceConfirm()});l.append(ai1wm_locale.close_import),c.append(ai1wm_locale.confirm_disk_space),r.append(l),r.append(c),s.append(p),i.append(s).append(n),a.append(i).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.blogs=function(o){const a=e("").on("submit",function(e){e.preventDefault(),l.attr("disabled","disabled"),t.onBlogs(a.serializeArray())}),i=e(""),s=e(""),n=e("").html(o.message),r=e(""),p=e("").addClass("ai1wm-title-grey").text(o.title),l=e('');l.append(ai1wm_locale.continue_import),r.append(l),s.append(p),i.append(s).append(n),a.append(i).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.info=function(o){const a=e(""),i=e(""),s=e(""),n=e("").html(o.message),r=e(""),p=e(''),l=e("").html(ai1wm_locale.please_do_not_close_this_browser),c=e('');c.append(l),r.append(c),s.append(p),i.append(s).append(n),a.append(i).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.done=function(o){const a=e(""),i=e(""),s=e(""),n=e('').html(o.message),r=e(''),p=e("").addClass("ai1wm-title-green").text(o.title),l=e('').on("click",function(){t.destroy()});l.append(ai1wm_locale.finish_import+" >"),r.append(l),s.append(p),i.append(s).append(n),a.append(i).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.backupIsEncrypted=function(o){const a=e(""),i=e(''),s=e("").html(ai1wm_locale.backup_encrypted),n=e('').html(ai1wm_locale.backup_encrypted_message),r=e(''),p=e(''),l=e('').prop("placeholder",ai1wm_locale.enter_password).on("keyup",function(){const t=e(this),o=e("#ai1wm-backup-decrypt-password-confirmation");t.val()!==o.val()?(o.parent().addClass("ai1wm-has-error"),t.parent().addClass("ai1wm-has-error")):(t.parent().removeClass("ai1wm-has-error"),o.parent().removeClass("ai1wm-has-error"))}),c=e('').on("click",function(){return e(this).toggleClass("ai1wm-icon-eye ai1wm-icon-eye-blocked"),e(this).prev().prop("type",function(t,e){return"text"===e?"password":"text"}),!1});if(p.append(l).append(c),o.error){p.addClass("ai1wm-has-error");const t=e('').html(o.error);p.append(t)}const d=e(''),m=e('').prop("placeholder",ai1wm_locale.repeat_password).on("keyup",function(){const t=e(this),o=e("#ai1wm-backup-decrypt-password");l.val()!==t.val()?(o.parent().addClass("ai1wm-has-error"),t.parent().addClass("ai1wm-has-error")):(o.parent().removeClass("ai1wm-has-error"),t.parent().removeClass("ai1wm-has-error"))}),u=e('').on("click",function(){return e(this).toggleClass("ai1wm-icon-eye ai1wm-icon-eye-blocked"),e(this).prev().prop("type",function(t,e){return"text"===e?"password":"text"}),!1}),w=e('').html(ai1wm_locale.passwords_do_not_match);d.append(m).append(u).append(w);const f=e('').on("click",function(){const o=e("#ai1wm-backup-decrypt-password"),a=e("#ai1wm-backup-decrypt-password-confirmation");o.val().length&&o.val()===a.val()?(f.attr("disabled","disabled"),t.onDecryptPassword(r.serializeArray())):(a.parent().addClass("ai1wm-has-error"),o.parent().addClass("ai1wm-has-error"))}),h=e('').on("click",function(){h.attr("disabled","disabled"),t.onStop()});f.append(ai1wm_locale.unlock),h.append(ai1wm_locale.close_import);const _=e('');_.append(h).append(f),r.append(p).append(d),i.append(s).append(n).append(r).append(_),a.append(i),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.serverCannotDecrypt=function(o){const a=e(""),i=e(""),s=e(""),n=e("").html(o.message),r=e(''),p=e(""),l=e('').on("click",function(){l.attr("disabled","disabled"),t.onStop()});l.append(ai1wm_locale.close_import),p.append(l),s.append(r),i.append(s).append(n),a.append(i).append(p),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.overlay=e(''),this.modal=e(''),e("body").append(this.overlay).append(this.modal)};o.prototype.render=function(t){switch(e(document).trigger("ai1wm-import-status",t),t.type){case"pro":this.pro(t);break;case"error":this.error(t);break;case"confirm":this.confirm(t);break;case"disk_space_confirm":this.diskSpaceConfirm(t);break;case"blogs":this.blogs(t);break;case"progress":this.progress(t);break;case"info":this.info(t);break;case"done":this.done(t);break;case"backup_is_encrypted":this.backupIsEncrypted(t);break;case"server_cannot_decrypt":this.serverCannotDecrypt(t)}},o.prototype.destroy=function(){this.modal.hide(),this.overlay.hide(),this.progress.progressBarMeter=null,this.progress.progressBarPercent=null},t.exports=o}},e={};function o(a){var i=e[a];if(void 0!==i)return i.exports;var s=e[a]={exports:{}};return t[a](s,s.exports,o),s.exports}const a=o(37),i=o(525);jQuery(document).ready(function(t){"use strict";let e;e=Ai1wm.MultisiteExtensionUploader?new Ai1wm.MultisiteExtensionUploader:Ai1wm.UnlimitedExtensionUploader?new Ai1wm.UnlimitedExtensionUploader:Ai1wm.FileExtensionUploader?new Ai1wm.FileExtensionUploader:new Ai1wm.FileUploader,e.init(),t(".ai1wm-expandable > div.ai1wm-button-main").on("click",function(){t(this).parent().toggleClass("ai1wm-open")})}),globalThis.Ai1wm=jQuery.extend({},globalThis.Ai1wm,{FileUploader:i,Import:a})})();