"use strict";!function(){jQuery(function(p){var v=function(t){return p.get(ajaxurl,{action:"wc_plugin_framework_csv_import_suite_dismiss_notice",messageid:"wc_csv_import_suite_finished_"+t})};return wc_csv_import_suite.draw_results_chart=function(t){var e,s=[];if(wc_csv_import_suite.status_counts&&(e=p(".chart-placeholder.import-results")).length)return p.each(wc_csv_import_suite.status_counts,function(t,e){return s.push({label:wc_csv_import_suite.chart_legends[t].title,color:wc_csv_import_suite.chart_legends[t].color,data:e})}),"undefined"!==t&&s[t]&&(s[t].color="#9c5d90"),p.plot(e,s,{grid:{hoverable:!0},series:{pie:{show:!0,radius:1,innerRadius:.6,label:{show:!1}},enable_tooltip:!0,append_tooltip:wc_csv_import_suite.i18n.chart_tooltip.replace("%s","")},legend:{show:!1}})},wc_csv_import_suite.display_import_progress=function(s){var r,c,t=wc_csv_import_suite.results?Object.keys(wc_csv_import_suite.results):[],o=t?t.length:0,u=t.length?Number(t.pop()):0,n=wc_csv_import_suite.file_size,_=(wc_csv_import_suite.progress,!1),a=!1,e={action:"wc_csv_import_suite_get_progress",security:wc_csv_import_suite.progress_nonce,job_id:s},l={bar:p("#wc-csv-import-suite-progress .bar"),count:p("#wc-csv-import-suite-progress .processed-count"),percentage:p("#wc-csv-import-suite-progress .percentage"),results:p("#wc-csv-import-suite-results")};return r=setInterval(function(){if(!_)return _=!0,e.results_from=u+1,p.get(ajaxurl,e).done(function(t){var i,e;return"string"==typeof t?(i=wc_csv_import_suite.i18n.unexpected_error_message,p(".wrap h2:first").after('

'+i+"

"),clearInterval(r)):(c=t.progress||0,e=Math.round(c/n*100),t.results&&(u=Number(Object.keys(t.results).pop()),p.each(t.results,function(t,e){var s;if(!l.results.find("tr.line-"+t).length)return s=p("").text(e.status).text(),i=p("").text(e.message).text(),wc_csv_import_suite.status_counts[s]++,o++,l.results.find("li."+s+" .amount").text(wc_csv_import_suite.status_counts[s]),"skipped"!==s&&"failed"!==s||(l.results.find(".results-details > tbody").append(''+t+""+wc_csv_import_suite.chart_legends[s].label+""+i+""),a)?void 0:(l.results.find(".js-wc-csv-import-suite-results-details-link-widget").show(),a=!0)})),l.count.text(o),l.percentage.text(e+" %"),l.bar.css("width",e+"%"),wc_csv_import_suite.draw_results_chart(),_=!1,n<=c?(clearInterval(r),e=(t=wc_csv_import_suite.status_counts.failed||wc_csv_import_suite.status_counts.skipped)?"notice-warning":"notice-success",i=wc_csv_import_suite.i18n.import_complete,t&&(i+=" "+wc_csv_import_suite.i18n.skipped_or_failed_lines),p("h2:first").after('

'+i+"

"),p(".notice-dry-run p").html(wc_csv_import_suite.i18n.dry_run_complete),p(".progress-bar .js-spinner").fadeOut(),p(".js-notice-safe-to-leave-screen").remove(),v(s)):void 0)}).fail(function(t,e,s){var i=wc_csv_import_suite.i18n.unexpected_error_message;return p(".wrap h2:first").after('

'+i+"

")})},1e3)},p(".js-wc-csv-import-suite-toggle-results-details").click(function(t){return t.preventDefault(),p("#wc-csv-import-suite-results").find(".results-details").toggle(),t=p("#wc-csv-import-suite-results").find(".results-details").is(":visible"),p(this).find(".js-wc-csv-import-suite-toggle-results-details-text").text(t?wc_csv_import_suite.i18n.hide_details:wc_csv_import_suite.i18n.show_details)}),p(".js-wc-csv-import-suite-highlight-series").hover(function(){return wc_csv_import_suite.draw_results_chart(p(this).data("series"))},function(){return wc_csv_import_suite.draw_results_chart()}),p(window).resize(function(){var t;return clearTimeout(t),t=setTimeout(function(){return t=null,wc_csv_import_suite.draw_results_chart()},100)}),p("body").on("click","input.js-wc-csv-import-suite-merge",function(t){var e=p(this).is(":checked")?"show":"hide";return p("#wc-csv-import-suite-insert-non-matching").closest("tr")[e]()}),p("body").on("change","select.js-wc-csv-import-suite-delimiter",function(t){var e=p(this).val();return p(".wc-csv-import-suite-preview-container").block({message:null,overlayCSS:{opacity:.3}}),e={action:"wc_csv_import_suite_get_preview",security:wc_csv_import_suite.preview_nonce,delimiter:e,file:p(".js-wc-csv-import-suite-file").val()},p.get(ajaxurl,e,function(t){return p("#wc-csv-import-suite-preview").html(t),p(".wc-csv-import-suite-preview-container").unblock()})})})}.call(void 0);