"use strict";(self.webpackJSONPwpmdb=self.webpackJSONPwpmdb||[]).push([[879],{78879:function(e,r,t){t.r(r),t.d(r,{importFile:function(){return _},setImportTableData:function(){return l},uploadFileActions:function(){return g}});var n=t(27166),a=t(33032),u=t(4516),i=t(67821),s=t(66055),c=t(29950),p=t(38906),o=t(29942),m=t(66866),f=t(26547),l=function(e){return function(r,t){return r((0,s.m)(f.VG,e))}},_=function e(r){return function(){var t=(0,a.Z)((0,n.Z)().mark((function t(a,f){var _,d,b,g,h,k,v,w,x,y,Z;return(0,n.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return _=(0,u.FY)("import_gzipped",f()),d=(0,i.selectFromImportData)("file_size",f()),(b={chunk:r.chunk,current_query:r.current_query,import_file:r.import_filename}).import_info=JSON.stringify({import_gzipped:_}),t.prev=4,t.next=7,(0,o.op)("/import-file",b);case 7:g=t.sent,t.next=14;break;case 10:return t.prev=10,t.t0=t.catch(4),a((0,p.m7)({error_type:m.gF,error_message:t.t0.message})),t.abrupt("return",!1);case 14:if(h=g.data,k=h.table_sizes,v=h.table_rows,w=h.tables,a(l({table_sizes:k,table_rows:v,tables:w})),x=Math.ceil(d/h.num_chunks),y=x/1e3,a((0,p.gF)(y)),!(h.chunk>=h.num_chunks)){t.next=26;break}return a((0,p.v_)()),a((0,s.m)(c.sP,"import")),t.abrupt("return",a((0,p.Z6)("MIGRATE",[],"find_replace")));case 26:return Z=[{import_filename:r.import_filename,item_name:r.item_name,chunk:h.chunk,current_query:h.current_query}],t.next=29,a((0,p.Z6)("IMPORT_FILE",[{fn:e,args:Z}]));case 29:return t.abrupt("return",t.sent);case 30:case"end":return t.stop()}}),t,null,[[4,10]])})));return function(e,r){return t.apply(this,arguments)}}()},d=1024e3,b=function(e){return function(){var r=(0,a.Z)((0,n.Z)().mark((function r(t,a){var u,i,f,l;return(0,n.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t((0,s.m)(c.f7,"import")),t((0,s.m)(m.Lw)),r.prev=2,r.next=5,(0,o.op)("/prepare-upload",{});case 5:u=r.sent,r.next=12;break;case 8:return r.prev=8,r.t0=r.catch(2),t((0,p.m7)({error_type:m.gF,error_message:r.t0.message})),r.abrupt("return",!1);case 12:return i=e.name,f=window.wpmdb_strings.importing_file_to_db.replace(/%s\s?/,i),t((0,s.m)(m.V$,f)),".gz"===i.slice(-3)&&(i=e.name.slice(0,-3)),l=[{import_filename:u.data.import_file,item_name:i,chunk:0,current_query:""}],r.next=19,t((0,p.Z6)(p.p_,[{fn:_,args:l}]));case 19:return r.abrupt("return",r.sent);case 20:case"end":return r.stop()}}),r,null,[[2,8]])})));return function(e,t){return r.apply(this,arguments)}}()},g=function e(r){return function(){var t=(0,a.Z)((0,n.Z)().mark((function t(f,l){var _,g,h,k,v;return(0,n.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:_=(0,u.NR)("remote_site",l()),r="undefined"===typeof r?0:r,g=(0,i.selectFromImportData)("file",l()),h=r+d+1,k=new FileReader,0===r&&(f((0,s.m)(c.f7,"upload")),f((0,p.Wv)(Math.ceil((0,i.selectFromImportData)("file_size",l())/1e3)))),k.onloadend=function(){var t=(0,a.Z)((0,n.Z)().mark((function t(a){var u,i;return(0,n.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a.target.readyState===FileReader.DONE){t.next=2;break}return t.abrupt("return");case 2:return u={action:"wpmdb_upload_file",file_data:a.target.result,file:g.name,file_type:g.type,stage:"import",import_info:_},t.prev=3,t.next=6,(0,o.op)("/upload-file",u);case 6:t.next=12;break;case 8:return t.prev=8,t.t0=t.catch(3),f((0,p.m7)({error_type:m.gF,error_message:t.t0.message})),t.abrupt("return",!1);case 12:if(!(h<g.size)){t.next=19;break}return f((0,p.gF)(Math.ceil(1024))),t.next=16,f((0,p.Z6)(p.uk,[{fn:e,args:[h]}]));case 16:case 24:return t.abrupt("return",t.sent);case 19:return i=g.size-r,f((0,p.gF)(Math.ceil(i/1e3))),f((0,s.m)(c.sP,"upload")),t.next=24,f((0,p.Z6)(p.h8,[{fn:b,args:[g]}]));case 25:case"end":return t.stop()}}),t,null,[[3,8]])})));return function(e){return t.apply(this,arguments)}}(),v=g.slice(r,h),k.readAsDataURL(v);case 9:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()}}}]);