"use strict";(self.webpackJSONPwpmdb=self.webpackJSONPwpmdb||[]).push([[800],{84800:(e,r,a)=>{a.r(r),a.d(r,{importFile:()=>c,setImportTableData:()=>_,uploadFileActions:()=>d});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=>(r,a)=>r((0,n.b)(p.Tk,e)),c=e=>async(r,a)=>{var p,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{p=await(0,l.ty)("/import-file",d)}catch(k){return r((0,m.zh)({error_type:o.mN,error_message:k.message})),!1}var y=p.data,b=y.table_sizes,g=y.table_rows,h=y.tables;r(_({table_sizes:b,table_rows:g,tables:h}));var w=Math.ceil(f/y.num_chunks)/1e3;if(r((0,m.Bz)(w)),y.chunk>=y.num_chunks)return r((0,m.Ad)()),r((0,n.b)(s.kl,"import")),r((0,m.GD)("MIGRATE",[],"find_replace"));var z=[{import_filename:e.import_filename,item_name:e.item_name,chunk:y.chunk,current_query:y.current_query}];return await r((0,m.GD)("IMPORT_FILE",[{fn:c,args:z}]))},u=1024e3,f=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 _=[{import_filename:t.data.import_file,item_name:i,chunk:0,current_query:""}];return await r((0,m.GD)(m.Jt,[{fn:c,args:_}]))},d=e=>async(r,a)=>{var p=(0,t.jG)("remote_site",a());e="undefined"===typeof e?0:e;var _=(0,i.selectFromImportData)("file",a()),c=e+u+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(u){return r((0,m.zh)({error_type:o.mN,error_message:u.message})),!1}if(c<_.size)return r((0,m.Bz)(Math.ceil(1024))),await r((0,m.GD)(m.oH,[{fn:d,args:[c]}]));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:f,args:[_]}]))}};var b=_.slice(e,c);y.readAsDataURL(b)}}}]);