(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var a in o)e.o(o,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:o[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.apiFetch;var o=e.n(t);!function(e){const t={init(){e(t.ready),t.loadGoogleCharts(),t.permanentDelete()},ready(){e("#screen-meta-links, #screen-meta").prependTo("#wp-pollify-header-screen").show()},drawRegionsMap(){const e=document.getElementById("geo-chart-map"),t=JSON.parse(e.dataset.locations),o=google.visualization.arrayToDataTable(t);new google.visualization.GeoChart(e).draw(o,{colorAxis:{colors:["#91cdff","#2271b1"]},magnifyingGlass:{enable:!0,zoomFactor:15}})},loadGoogleCharts(){document.getElementById("geo-chart-map")&&(google.charts.load("current",{packages:["geochart"]}),google.charts.setOnLoadCallback(t.drawRegionsMap))},permanentDelete(){e(document).on("click",".pollify-delete-permanently",async function(t){t.preventDefault();const a=e(this).data("poll-id");try{const t=await o()({url:`${pollifyAdmin.restUrl}${a}/stats`,method:"GET"});let n=pollifyAdmin.confirmMsg+"\n\n";if(n+=`Total Votes: ${t.total_votes}\n`,n+="Unique Voters: "+(null!==t.unique_voters?t.unique_voters:"N/A (Anonymous Poll)"),!window.confirm(n))return;const r=e(this).closest("tr");await o()({url:`${pollifyAdmin.restUrl}${a}/permanent-delete`,method:"DELETE"}),r.fadeOut(300,function(){e(this).remove()})}catch(e){window.alert("Error: "+(e.message||"Unknown error"))}})}};t.init()}(jQuery)})();