var RateMyPost=function(t){function e(e){for(var n,r,o=e[0],s=e[1],a=0,u=[];a<o.length;a++)r=o[a],Object.prototype.hasOwnProperty.call(i,r)&&i[r]&&u.push(i[r][0]),i[r]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n]);for(c&&c(e);u.length;)u.shift()()}var n={},i={0:0};function r(e){if(n[e])return n[e].exports;var i=n[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=n,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r.oe=function(t){throw console.error(t),t};var o=window.webpackJsonpRateMyPost=window.webpackJsonpRateMyPost||[],s=o.push.bind(o);o.push=e,o=o.slice();for(var a=0;a<o.length;a++)e(o[a]);var c=s;return r(r.s=8)}([function(t,e){t.exports=rmp_frontend},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}t.exports=function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}},function(t,e,n){t.exports=n(7)},function(t,e,n){var i,r;
!function(o){if(void 0===(r="function"==typeof(i=o)?i.call(e,n,e,t):i)||(t.exports=r),!0,t.exports=o(),!!0){var s=window.Cookies,a=window.Cookies=o();a.noConflict=function(){return window.Cookies=s,a}}}((function(){function t(){for(var t=0,e={};t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(i){function r(){}function o(e,n,o){if("undefined"!=typeof document){"number"==typeof(o=t({path:"/"},r.defaults,o)).expires&&(o.expires=new Date(1*new Date+864e5*o.expires)),o.expires=o.expires?o.expires.toUTCString():"";try{var s=JSON.stringify(n);/^[\{\[]/.test(s)&&(n=s)}catch(t){}n=i.write?i.write(n,e):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var c in o)o[c]&&(a+="; "+c,!0!==o[c]&&(a+="="+o[c].split(";")[0]));return document.cookie=e+"="+n+a}}function s(t,n){if("undefined"!=typeof document){for(var r={},o=document.cookie?document.cookie.split("; "):[],s=0;s<o.length;s++){var a=o[s].split("="),c=a.slice(1).join("=");n||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var u=e(a[0]);if(c=(i.read||i)(c,u)||e(c),n)try{c=JSON.parse(c)}catch(t){}if(r[u]=c,t===u)break}catch(t){}}return t?r[t]:r}}return r.set=o,r.get=function(t){return s(t,!1)},r.getJSON=function(t){return s(t,!0)},r.remove=function(e,n){o(e,"",t(n,{expires:-1}))},r.defaults={},r.withConverter=n,r}((function(){}))}))},function(t,e){function n(t,e,n,i,r,o,s){try{var a=t[o](s),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(i,r)}t.exports=function(t){return function(){var e=this,i=arguments;return new Promise((function(r,o){var s=t.apply(e,i);function a(t){n(s,r,o,a,c,"next",t)}function c(t){n(s,r,o,a,c,"throw",t)}a(void 0)}))}}},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e,n){var i=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function a(t,e,n,i){var r=e&&e.prototype instanceof h?e:h,o=Object.create(r.prototype),s=new k(i||[]);return o._invoke=function(t,e,n){var i="suspendedStart";return function(r,o){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===r)throw o;return j()}for(n.method=r,n.arg=o;;){var s=n.delegate;if(s){var a=w(s,n);if(a){if(a===u)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var h=c(t,e,n);if("normal"===h.type){if(i=n.done?"completed":"suspendedYield",h.arg===u)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i="completed",n.method="throw",n.arg=h.arg)}}}(t,n,s),o}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var u={};function h(){}function l(){}function d(){}var g={};g[r]=function(){return this};var f=Object.getPrototypeOf,p=f&&f(f(x([])));p&&p!==e&&n.call(p,r)&&(g=p);var m=d.prototype=h.prototype=Object.create(g);function v(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function y(t,e){var i;this._invoke=function(r,o){function s(){return new e((function(i,s){!function i(r,o,s,a){var u=c(t[r],t,o);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){i("next",t,s,a)}),(function(t){i("throw",t,s,a)})):e.resolve(l).then((function(t){h.value=t,s(h)}),(function(t){return i("throw",t,s,a)}))}a(u.arg)}(r,o,i,s)}))}return i=i?i.then(s,s):s()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return u;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var i=c(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,u;var r=i.arg;return r?r.done?(e[t.resultName]=r.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,u):r:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,u)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function x(t){if(t){var e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(n.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return l.prototype=m.constructor=d,d.constructor=l,d[s]=l.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},v(y.prototype),y.prototype[o]=function(){return this},t.AsyncIterator=y,t.async=function(e,n,i,r,o){void 0===o&&(o=Promise);var s=new y(a(e,n,i,r),o);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},v(m),m[s]="Generator",m[r]=function(){return this},m.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},t.values=x,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function i(n,i){return s.type="throw",s.arg=t,e.next=n,i&&(e.method="next",e.arg=void 0),!!i}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var a=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),u},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),b(n),u}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;b(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:x(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},t}(t.exports);try{regeneratorRuntime=i}catch(t){Function("r","regeneratorRuntime=r")(i)}},function(t,e,n){"use strict";n.r(e),n.d(e,"re_init",(function(){return M})),n.d(e,"init_single_rate_my_post",(function(){return O}));var i=n(1),r=n.n(i),o=n(2),s=n.n(o),a=n(5),c=n.n(a),u=n(3),h=n.n(u),l=n(0),d=n.n(l),g=function(){function t(e,n){r()(this,t),this.widgetContainer=e,this.socialEnabled=d.a.social,this.ratingRequired=d.a.positiveThreshold,this.rating=n,this.ratingWidget=document.querySelector(this.widgetContainer+".js-rmp-rating-widget"),this.socialWidget=document.querySelector(this.widgetContainer+".js-rmp-social-widget"),this.events()}return s()(t,[{key:"events",value:function(){var t,e,n,i;2!=this.socialEnabled||this.rating<=this.ratingRequired||(null===(t=this.socialWidget)||void 0===t||null===(e=t.classList)||void 0===e||e.add("rmp-social-widget--visible"),null===(n=this.ratingWidget)||void 0===n||null===(i=n.classList)||void 0===i||i.add("rmp-rating-widget--hidden"))}}]),t}(),f=function(){function t(e,n){r()(this,t),this.widgetContainer=e,this.successMsg=n.successMsg,this.errorMsg=n.errorMsg,this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-feedback-msg"),this.input=document.querySelector(this.widgetContainer+".js-rmp-feedback-input"),this.button=document.querySelector(this.widgetContainer+".js-rmp-feedback-button"),this.loader=document.querySelector(this.widgetContainer+".js-rmp-feedback-loader"),this.events()}return s()(t,[{key:"events",value:function(){if(this.loader.classList.remove("rmp-feedback-widget__loader--visible"),this.errorMsg.length)return this.msgContainer.classList.add("rmp-feedback-widget__msg--alert"),void(this.msgContainer.innerHTML=this.errorMsg.join("<br />"));this.msgContainer.classList.remove("rmp-feedback-widget__msg--alert"),this.msgContainer.textContent=this.successMsg,this.input.remove(),this.button.remove()}}]),t}(),p=function(){function t(e,n,i,o,s){r()(this,t),this.widgetContainer=e,this.postID=n,this.feedback=i,this.settings=d.a,this.duration=!1,this.ratingID=s,this.token=o,this.recaptcha=d.a.grecaptcha,this.recaptchaKey=d.a.siteKey,this.data={action:"process_feedback",feedback:this.feedback,postID:this.postID,duration:this.duration,rating_id:this.ratingID,rating_token:this.token,nonce:this.settings.nonce},this.events()}var e;return s()(t,[{key:"events",value:function(){var t=this;2==this.recaptcha?Promise.resolve().then(n.t.bind(null,9,7)).then((function(e){e.ready((function(){e.execute(t.recaptchaKey,{action:"RMPfeedback"}).then((function(e){t.data.token=e,t.saveFeedback()}))}))})):this.saveFeedback()}},{key:"saveFeedback",value:(e=c()(h.a.mark((function t(){var e,n,i,r=this;return h.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new FormData,Object.keys(this.data).forEach((function(t){return e.append(t,r.data[t])})),t.next=4,fetch(this.settings.admin_ajax,{method:"POST",body:e});case 4:if((n=t.sent).ok){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,n.json();case 9:i=t.sent,new f(this.widgetContainer,i);case 11:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})}]),t}(),m=function(){function t(e,n,i,o,s){r()(this,t),this.widgetContainer=e,this.postID=n,this.feedbackEnabled=d.a.feedback,this.maxRating=d.a.positiveThreshold,this.emptyFeedbackMsg=d.a.emptyFeedback,this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-feedback-msg"),this.rating=i,this.ratingWidget=document.querySelector(this.widgetContainer+".js-rmp-rating-widget"),this.feedbackWidget=document.querySelector(this.widgetContainer+".js-rmp-feedback-widget"),this.inputContainer=document.querySelector(this.widgetContainer+".js-rmp-feedback-input"),this.submitButton=document.querySelector(this.widgetContainer+".js-rmp-feedback-button"),this.loader=document.querySelector(this.widgetContainer+".js-rmp-feedback-loader"),this.input=!1,this.token=o,this.ratingID=s,this.events()}return s()(t,[{key:"events",value:function(){var t=this;2!=this.feedbackEnabled||this.rating>this.maxRating||(this.feedbackWidget.classList.add("rmp-feedback-widget--visible"),this.ratingWidget.classList.add("rmp-rating-widget--hidden"),this.submitButton.addEventListener("click",(function(e){return t.submitButtonClicked()})))}},{key:"submitButtonClicked",value:function(){if(this.input=this.inputContainer.value,this.input.trim().length<1)return this.msgContainer.classList.add("rmp-feedback-widget__msg--alert"),void(this.msgContainer.textContent=this.emptyFeedbackMsg);this.submitButton.replaceWith(this.submitButton.cloneNode(!0)),this.submitButton=document.querySelector(this.widgetContainer+".js-rmp-feedback-button"),this.loader.classList.add("rmp-feedback-widget__loader--visible");new p(this.widgetContainer,this.postID,this.input,this.token,this.ratingID)}}]),t}(),v=n(6),y=n.n(v),w=function(){function t(){r()(this,t),this.starsToBeReplaced=document.querySelectorAll(".js-rmp-replace-half-star"),this.starsToBeRemoved=document.querySelectorAll(".js-rmp-remove-half-star"),this.testElement=document.createElement("x-test"),this.supportTest=y()(this.testElement.style.webkitBackgroundClip),this.events()}return s()(t,[{key:"events",value:function(){var t=!0;"undefined"===this.supportTest&&(t=!1),t||(this.starsToBeReplaced.forEach((function(t){t.classList.remove("rmp-icon--half-highlight"),t.classList.add("rmp-icon--full-highlight")})),this.starsToBeRemoved.forEach((function(t){t.classList.remove("rmp-icon--half-highlight")})))}}]),t}(),C=function(){function t(e,n,i){r()(this,t),this.postID=n,this.widgetContainer=e,this.avgRating=i,this.resultIcons=document.querySelectorAll(".js-rmp-results-widget--"+n+" .js-rmp-results-icon"),this.ratingIcons=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-icon"),this.hideRatings=d.a.notShowRating,this.events()}return s()(t,[{key:"events",value:function(){var t=Math.floor(this.avgRating),e=!1,n=!1,i="",r=Math.round(this.avgRating%1*10);if(r>2&&r<8&&(e=!0),r>=8&&(n=!0),r>2&&r<5&&(i="js-rmp-remove-half-star"),r>=5&&r<8&&(i="js-rmp-replace-half-star"),this.resultIcons.forEach((function(r,o){o+1<=t&&r.classList.add("rmp-icon--full-highlight"),e&&o+1==t+1&&(r.classList.add("rmp-icon--half-highlight"),r.classList.add(i)),n&&o+1==t+1&&r.classList.add("rmp-icon--full-highlight")})),2!=this.hideRatings){this.ratingIcons.forEach((function(r,o){o+1<=t&&r.classList.add("rmp-icon--full-highlight"),e&&o+1==t+1&&(r.classList.add("rmp-icon--half-highlight"),r.classList.add(i)),n&&o+1==t+1&&r.classList.add("rmp-icon--full-highlight")}));new w}}}]),t}(),b=n(4),k=n.n(b),x=function(){function t(e){r()(this,t),this.postID=e,this.existingCookie=k.a.get("rmp-rate"),this.events()}return s()(t,[{key:"events",value:function(){if(void 0!==this.existingCookie){k.a.remove("rmp-rate");var t=this.existingCookie.split(",");t.length>=20&&t.shift(),t.push(this.postID);var e=t.toString();k.a.set("rmp-rate",e,{expires:20})}else k.a.set("rmp-rate",this.postID,{expires:20})}}]),t}(),j=function(){function t(e){r()(this,t),this.commonAnalyticsTracker=y()(window.ga),this.MiAnalyticsTracker=y()(window.__gaTracker),this.rating=e,this.events()}return s()(t,[{key:"events",value:function(){return"undefined"!==this.commonAnalyticsTracker?(ga("send","event","Rate my Post","Post Rated "+this.rating+"/5"),void console.log("ga analytics tracker")):"undefined"!==this.MiAnalyticsTracker?(__gaTracker("send","event","Rate my Post","Post Rated "+this.rating+"/5"),void console.log("__gaTracker analytics tracker")):void console.log("Analytics tracker not found")}}]),t}(),L=function(){function t(e,n,i,o){r()(this,t),this.postID=e,this.widgetContainer=n,this.voteCount=i.voteCount,this.avgRating=i.avgRating,this.errorMsg=i.errorMsg,this.token=i.token,this.id=i.id,this.avgRatingContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-avg-rating, .js-rmp-results-widget--"+e+" .js-rmp-avg-rating"),this.voteCountContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-vote-count, .js-rmp-results-widget--"+e+" .js-rmp-vote-count"),this.noVotesContainer=document.querySelector(this.widgetContainer+".js-rmp-not-rated"),this.resultsTextContainer=document.querySelector(this.widgetContainer+".js-rmp-results"),this.ratingIcons=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-icon"),this.resultIcons=document.querySelectorAll(".js-rmp-results-widget--"+e+" .js-rmp-results-icon"),this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-msg"),this.tnxMsg=d.a.afterVote,this.rating=o,this.hideRatings=d.a.notShowRating,this.events()}return s()(t,[{key:"events",value:function(){var t,e,n,i,r=this;if(this.errorMsg.length)return this.msgContainer.innerHTML=this.errorMsg.join("<br />"),this.msgContainer.classList.add("rmp-rating-widget__msg--alert"),void this.ratingIcons.forEach((function(t){t.classList.remove("rmp-icon--processing-rating","rmp-icon--hovered")}));this.avgRatingContainer&&this.avgRatingContainer.forEach((function(t){t.textContent=r.avgRating})),this.voteCountContainer&&this.voteCountContainer.forEach((function(t){t.textContent=r.voteCount})),this.toneDownIcons(),this.highlightIcons(),null===(t=this.noVotesContainer)||void 0===t||null===(e=t.classList)||void 0===e||e.add("rmp-rating-widget__not-rated--hidden"),null===(n=this.resultsTextContainer)||void 0===n||null===(i=n.classList)||void 0===i||i.remove("rmp-rating-widget__results--hidden"),this.msgContainer.textContent=this.tnxMsg;new g(this.widgetContainer,this.rating),new m(this.widgetContainer,this.postID,this.rating,this.token,this.id),new x(this.postID),new j(this.rating)}},{key:"toneDownIcons",value:function(){this.ratingIcons.forEach((function(t){t.classList.remove("rmp-icon--full-highlight","rmp-icon--half-highlight","rmp-icon--processing-rating","rmp-icon--hovered","js-rmp-remove-half-star","js-rmp-replace-half-star")})),this.resultIcons.forEach((function(t){t.classList.remove("rmp-icon--full-highlight","rmp-icon--half-highlight","rmp-icon--processing-rating","js-rmp-remove-half-star","js-rmp-replace-half-star")}))}},{key:"highlightIcons",value:function(){new C(this.widgetContainer,this.postID,this.avgRating)}}]),t}(),I=function(){function t(e,n,i,o){r()(this,t),this.postID=e,this.widgetContainer=n,this.rating=i,this.duration=Math.floor(Date.now()/1e3)-o,this.settings=d.a,this.recaptcha=d.a.grecaptcha,this.recaptchaKey=d.a.siteKey,this.data={action:"process_rating",star_rating:this.rating,postID:this.postID,duration:this.duration,nonce:this.settings.nonce},this.events()}var e;return s()(t,[{key:"events",value:function(){var t=this;2==this.recaptcha?Promise.resolve().then(n.t.bind(null,9,7)).then((function(e){e.ready((function(){e.execute(t.recaptchaKey,{action:"RMPrating"}).then((function(e){t.data.token=e,t.saveRating()}))}))})):this.saveRating()}},{key:"saveRating",value:(e=c()(h.a.mark((function t(){var e,n,i,r=this;return h.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new FormData,Object.keys(this.data).forEach((function(t){return e.append(t,r.data[t])})),t.next=4,fetch(this.settings.admin_ajax,{method:"POST",body:e});case 4:if((n=t.sent).ok){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,n.json();case 9:i=t.sent,new L(this.postID,this.widgetContainer,i,this.rating);case 11:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})}]),t}(),S=function(){function t(e){r()(this,t),this.widgetContainer=e,this.ratingItems=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-item"),this.ratingTextContainer=document.querySelector(this.widgetContainer+".js-rmp-hover-text"),this.submitBtn=document.querySelector(this.widgetContainer+".js-submit-rating-btn"),this.events()}return s()(t,[{key:"events",value:function(){this.ratingItems.forEach((function(t){t.replaceWith(t.cloneNode(!0))})),this.ratingItems=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-item"),this.submitBtn.replaceWith(this.submitBtn.cloneNode(!0)),this.submitBtn=document.querySelector(this.widgetContainer+".js-submit-rating-btn"),this.ratingItems.forEach((function(t){t.style.cursor="default"})),this.submitBtn.classList.remove("rmp-rating-widget__submit-btn--visible"),this.ratingTextContainer&&(this.ratingTextContainer.textContent="")}}]),t}(),_=function(){function t(e,n){r()(this,t),this.postID=n,this.widgetContainer=e,this.existingCookie=k.a.get("rmp-rate"),this.cookiesDisabled=d.a.cookieDisable,this.tnxMsg=d.a.afterVote,this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-msg"),this.ratingWidget=document.querySelector(this.widgetContainer+".js-rmp-rating-widget"),this.events()}return s()(t,[{key:"events",value:function(){var t,e;if(2!=this.cookiesDisabled&&(void 0!==this.existingCookie&&this.existingCookie.split(",").includes(this.postID))){new S(this.widgetContainer);this.msgContainer&&(this.msgContainer.textContent=this.tnxMsg),null===(t=this.ratingWidget)||void 0===t||null===(e=t.classList)||void 0===e||e.add("rmp-rating-widget--has-rated")}}}]),t}(),E=function(){function t(){r()(this,t),this.requiresLogin=d.a.votingPriv,this.isLoggedIn=d.a.loggedIn,this.ratingWidget=document.querySelectorAll(".js-rmp-rating-widget"),this.events()}return s()(t,[{key:"events",value:function(){if(2==this.requiresLogin&&!this.isLoggedIn){new S("");this.ratingWidget.forEach((function(t){t.classList.add("rmp-rating-widget--no-privilege")}))}}}]),t}(),T=function(){function t(e){r()(this,t),this.postID=e,this.widgetContainer=".js-rmp-widgets-container--"+e+" ",this.resultsWidget=".js-rmp-results-widget--"+e,this.ratingItems=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-item"),this.ratingItemsList=document.querySelector(this.widgetContainer+".js-rmp-rating-icons-list"),this.ratingIcons=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-icon"),this.ratingTextContainer=document.querySelector(this.widgetContainer+".js-rmp-hover-text"),this.ratingText=!1,this.hoveredItemOrder=0,this.rating=0,this.supportsHover=window.matchMedia("(hover: hover)"),this.startTime=Math.floor(Date.now()/1e3),this.preventAccidental=d.a.preventAccidental,this.hoverTexts=d.a.hoverTexts,this.submitBtn=document.querySelector(this.widgetContainer+".js-submit-rating-btn"),this.saveRating=!1,this.events()}return s()(t,[{key:"events",value:function(){var t=this;this.doubleWidgetCheck(),this.ratingItems.forEach((function(e){e.style.cursor="pointer",e.addEventListener("mouseover",(function(e){return t.hoverIcons(e)})),e.addEventListener("mouseout",(function(e){return t.stopHoverIcons()})),e.addEventListener("click",(function(e){return t.ratingIconClicked(e)}))})),this.ratingItemsList.addEventListener("mouseleave",(function(e){return t.removeHoverTexts()}));new _(this.widgetContainer,this.postID),new E}},{key:"doubleWidgetCheck",value:function(){var t=document.querySelectorAll(this.widgetContainer),e=document.querySelectorAll(this.resultsWidget);(t.length>1||e.length>1)&&(t.forEach((function(t,e){e>0&&t.remove()})),e.forEach((function(t,e){e>0&&t.remove()})))}},{key:"hoverIcons",value:function(t){var e=this;this.hoveredItemOrder=parseInt(t.currentTarget.dataset.value,10),this.ratingText=t.currentTarget.dataset.descriptiveRating,this.ratingIcons.forEach((function(t,n){n<e.hoveredItemOrder?t.classList.add("rmp-icon--hovered"):t.classList.remove("rmp-icon--hovered"),e.supportsHover&&2==e.hoverTexts&&e.ratingTextContainer&&(e.ratingTextContainer.textContent=e.ratingText)}))}},{key:"stopHoverIcons",value:function(){this.ratingIcons.forEach((function(t){t.classList.remove("rmp-icon--hovered")}))}},{key:"removeHoverTexts",value:function(){this.ratingTextContainer&&(this.ratingTextContainer.textContent="")}},{key:"ratingIconClicked",value:function(t){var e=this;if(this.rating=parseInt(t.currentTarget.dataset.value,10),this.ratingIcons.forEach((function(t,n){t.classList.remove("rmp-icon--processing-rating"),n<e.rating&&t.classList.add("rmp-icon--processing-rating")})),2!=this.preventAccidental){new S(this.widgetContainer);this.saveRating=new I(this.postID,this.widgetContainer,this.rating,this.startTime)}else this.submitButtonHandler()}},{key:"submitButtonHandler",value:function(){var t=this;this.submitBtn.classList.add("rmp-rating-widget__submit-btn--visible"),this.submitBtn.addEventListener("click",(function(e){t.saveRating||(t.saveRating=new I(t.postID,t.widgetContainer,t.rating,t.startTime));new S(t.widgetContainer)}))}}]),t}(),q=function(){function t(e){r()(this,t),this.postID=e,this.widgetContainer=".js-rmp-widgets-container--"+e+" ",this.settings=d.a,this.avgRatingContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-avg-rating, .js-rmp-results-widget--"+e+" .js-rmp-avg-rating"),this.voteCountContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-vote-count, .js-rmp-results-widget--"+e+" .js-rmp-vote-count"),this.noVotesContainer=document.querySelector(this.widgetContainer+".js-rmp-not-rated"),this.resultsTextContainer=document.querySelector(this.widgetContainer+".js-rmp-results"),this.noVotesContainer=document.querySelector(this.widgetContainer+".js-rmp-not-rated"),this.resultsTextContainer=document.querySelector(this.widgetContainer+".js-rmp-results"),this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-msg"),this.data={action:"load_results",postID:this.postID,nonce:this.settings.nonce},this.events()}var e;return s()(t,[{key:"events",value:(e=c()(h.a.mark((function t(){var e,n,i,r,o,s,a=this;return h.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new FormData,Object.keys(this.data).forEach((function(t){return e.append(t,a.data[t])})),t.next=4,fetch(this.settings.admin_ajax,{method:"POST",body:e});case 4:if((n=t.sent).ok){t.next=7;break}return t.abrupt("return");case 7:return t.next=9,n.json();case 9:i=t.sent,r=i.voteCount,o=i.avgRating,s=i.errorMsg,this.loadResults(r,o,s);case 14:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"loadResults",value:function(t,e,n){if(n.length)this.msgContainer&&(this.msgContainer.textContent=n,this.msgContainer.classList.add("rmp-rating-widget__msg--alert"));else{this.avgRatingContainer&&this.avgRatingContainer.forEach((function(t){t.textContent=e})),this.voteCountContainer&&this.voteCountContainer.forEach((function(e){e.textContent=t}));var i,r,o,s,a,c,u,h;new C(this.widgetContainer,this.postID,e);if(0===e)null===(i=this.noVotesContainer)||void 0===i||null===(r=i.classList)||void 0===r||r.remove("rmp-rating-widget__not-rated--hidden"),null===(o=this.resultsTextContainer)||void 0===o||null===(s=o.classList)||void 0===s||s.add("rmp-rating-widget__results--hidden");else null===(a=this.noVotesContainer)||void 0===a||null===(c=a.classList)||void 0===c||c.add("rmp-rating-widget__not-rated--hidden"),null===(u=this.resultsTextContainer)||void 0===u||null===(h=u.classList)||void 0===h||h.remove("rmp-rating-widget__results--hidden");new w}}}]),t}(),R=function(){function t(){r()(this,t),this.ratingItems=document.querySelectorAll(".js-rmp-rating-item"),this.ratingItemsLists=document.querySelector(".js-rmp-rating-icons-list"),this.events()}return s()(t,[{key:"events",value:function(){this.ratingItems.forEach((function(t){t.replaceWith(t.cloneNode(!0))})),this.ratingItems=document.querySelectorAll(".js-rmp-rating-item"),this.ratingItems.forEach((function(t){t.style.cursor="auto"})),this.ratingItemsLists.replaceWith(this.ratingItemsLists.cloneNode(!0)),this.ratingItemsLists=document.querySelector(".js-rmp-rating-icons-list")}}]),t}();function D(){new w;var t=document.getElementsByClassName("js-rmp-rating-widget"),e=document.getElementsByClassName("js-rmp-results-widget"),n=document.getElementsByClassName("js-rmp-widgets-container");if(!(t.length<1&&e.length<1)){var i=[];Array.from(n).forEach((function(t){var e=t.dataset.postId;i.push(e)}));var r=i.filter((function(t,e){return i.indexOf(t)===e}));if(2!=d.a.ajaxLoad)r.forEach((function(t){new T(t)}));else new q(r[0]),new T(r[0])}}function M(){console.log("re-init running");new R;D()}function O(t,e){if(e)new q(t);new T(t)}"loading"!==document.readyState?D():document.addEventListener("DOMContentLoaded",D)},function(t,e){t.exports=grecaptcha}]);