"use strict";(self.webpackJSONPwpmdb=self.webpackJSONPwpmdb||[]).push([[800],{84800(e,r,a){a.d(r,{uploadFileActions:()=>f});var t=a(57524),i=a(56675),n=a(1626),s=a(95222),m=a(58728),l=a(33782),o=a(48346),p=a(92232),_=e=>async(r,a)=>{var c,u=(0,t.vg)("import_gzipped",a()),f=(0,i.selectFromImportData)("file_size",a()),d={chunk:e.chunk,current_query:e.current_query,import_file:e.import_filename};d.import_info=JSON.stringify({import_gzipped:u});try{c=await(0,l.ty)("/import-file",d)}catch(v){return r((0,m.zh)({error_type:o.mN,error_message:v.message})),!1}var y,b=c.data,g=b.table_sizes,h=b.table_rows,w=b.tables;r((y={table_sizes:g,table_rows:h,tables:w},(e,r)=>e((0,n.b)(p.Tk,y))));var z=Math.ceil(f/b.num_chunks)/1e3;if(r((0,m.Bz)(z)),b.chunk>=b.num_chunks)return r((0,m.Ad)()),r((0,n.b)(s.kl,"import")),r((0,m.GD)("MIGRATE",[],"find_replace"));var k=[{import_filename:e.import_filename,item_name:e.item_name,chunk:b.chunk,current_query:b.current_query}];return await r((0,m.GD)("IMPORT_FILE",[{fn:_,args:k}]))},c=1024e3,u=e=>async(r,a)=>{var t;r((0,n.b)(s.Ad,"import")),r((0,n.b)(o.XY));try{t=await(0,l.ty)("/prepare-upload",{})}catch(u){return r((0,m.zh)({error_type:o.mN,error_message:u.message})),!1}var i=e.name,p=window.wpmdb_strings.importing_file_to_db.replace(/%s\s?/,i);r((0,n.b)(o.ks,p)),".gz"===i.slice(-3)&&(i=e.name.slice(0,-3));var c=[{import_filename:t.data.import_file,item_name:i,chunk:0,current_query:""}];return await r((0,m.GD)(m.Jt,[{fn:_,args:c}]))},f=e=>async(r,a)=>{var p=(0,t.jG)("remote_site",a());e="undefined"===typeof e?0:e;var _=(0,i.selectFromImportData)("file",a()),d=e+c+1,y=new FileReader;0===e&&(r((0,n.b)(s.Ad,"upload")),r((0,m.oE)(Math.ceil((0,i.selectFromImportData)("file_size",a())/1e3)))),y.onloadend=async function(a){if(a.target.readyState===FileReader.DONE){var t={action:"wpmdb_upload_file",file_data:a.target.result,file:_.name,file_type:_.type,stage:"import",import_info:p};try{await(0,l.ty)("/upload-file",t)}catch(c){return r((0,m.zh)({error_type:o.mN,error_message:c.message})),!1}if(d<_.size)return r((0,m.Bz)(Math.ceil(1024))),await r((0,m.GD)(m.oH,[{fn:f,args:[d]}]));var i=_.size-e;return r((0,m.Bz)(Math.ceil(i/1e3))),r((0,n.b)(s.kl,"upload")),await r((0,m.GD)(m.fU,[{fn:u,args:[_]}]))}};var b=_.slice(e,d);y.readAsDataURL(b)}}}]);