"use strict";(self.webpackJSONPwpmdb=self.webpackJSONPwpmdb||[]).push([[879],{78879:function(e,r,a){a.r(r),a.d(r,{importFile:function(){return c},setImportTableData:function(){return u},uploadFileActions:function(){return d}});var t=a(4516),i=a(67821),n=a(66055),m=a(29950),s=a(38906),o=a(29942),p=a(66866),l=a(26547),u=e=>(r,a)=>r((0,n.m)(l.VG,e)),c=e=>async(r,a)=>{var l,_=(0,t.FY)("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:_});try{l=await(0,o.op)("/import-file",d)}catch(b){return r((0,s.m7)({error_type:p.gF,error_message:b.message})),!1}var g=l.data,y=g.table_sizes,w=g.table_rows,h=g.tables;r(u({table_sizes:y,table_rows:w,tables:h}));var v=Math.ceil(f/g.num_chunks)/1e3;if(r((0,s.gF)(v)),g.chunk>=g.num_chunks)return r((0,s.v_)()),r((0,n.m)(m.sP,"import")),r((0,s.Z6)("MIGRATE",[],"find_replace"));var F=[{import_filename:e.import_filename,item_name:e.item_name,chunk:g.chunk,current_query:g.current_query}];return await r((0,s.Z6)("IMPORT_FILE",[{fn:c,args:F}]))},_=1024e3,f=e=>async(r,a)=>{var t;r((0,n.m)(m.f7,"import")),r((0,n.m)(p.Lw));try{t=await(0,o.op)("/prepare-upload",{})}catch(_){return r((0,s.m7)({error_type:p.gF,error_message:_.message})),!1}var i=e.name,l=window.wpmdb_strings.importing_file_to_db.replace(/%s\s?/,i);r((0,n.m)(p.V$,l)),".gz"===i.slice(-3)&&(i=e.name.slice(0,-3));var u=[{import_filename:t.data.import_file,item_name:i,chunk:0,current_query:""}];return await r((0,s.Z6)(s.p_,[{fn:c,args:u}]))},d=e=>async(r,a)=>{var l=(0,t.NR)("remote_site",a());e="undefined"===typeof e?0:e;var u=(0,i.selectFromImportData)("file",a()),c=e+_+1,g=new FileReader;0===e&&(r((0,n.m)(m.f7,"upload")),r((0,s.Wv)(Math.ceil((0,i.selectFromImportData)("file_size",a())/1e3)))),g.onloadend=async function(a){if(a.target.readyState===FileReader.DONE){var t={action:"wpmdb_upload_file",file_data:a.target.result,file:u.name,file_type:u.type,stage:"import",import_info:l};try{await(0,o.op)("/upload-file",t)}catch(_){return r((0,s.m7)({error_type:p.gF,error_message:_.message})),!1}if(c<u.size)return r((0,s.gF)(Math.ceil(1024))),await r((0,s.Z6)(s.uk,[{fn:d,args:[c]}]));var i=u.size-e;return r((0,s.gF)(Math.ceil(i/1e3))),r((0,n.m)(m.sP,"upload")),await r((0,s.Z6)(s.h8,[{fn:f,args:[u]}]))}};var y=u.slice(e,c);g.readAsDataURL(y)}}}]);