"use strict";!function(u,c){u(document).ready(function(){if(u(".wq-force-action-subscribe").length){!function(){if("undefined"!=typeof Cookies){var e=Cookies.get("wp_quiz_subscribe_email"),i=Cookies.get("wp_quiz_subscribe_username");e&&u('.wq-subscribe-form input[name="email"]').val(e),i&&u('.wq-subscribe-form input[name="username"]').val(i)}}(),u(document).on("submit.captureEmail",".wq-subscribe-form",function(e){return function(e){e.preventDefault();var i=u(e.currentTarget),r=i.closest(".wq-force-action-container"),t=i.closest(".wq-quiz"),s=i.find(".wq-error");c.helpers.showLoading(r),s.html("");var n=i.serializeObject();if(n.play_data_id=i.attr("data-tracking-id"),n.quiz_id=t.attr("data-quiz-id"),n.current_url=window.location.href,!n.username||!n.email)return s.html(c.i18n.emptyNameEmail),void c.helpers.hideLoading(r);var o=c.restUrl+"wp-quiz/v2/subscribe",a=c.helpers.getRequest({url:o,method:"POST",data:n});a.done(function(e){console.log(e),c.helpers.hideLoading(r),"undefined"!=typeof Cookies&&(Cookies.set("wp_quiz_subscribe_email",n.email,{expires:7}),Cookies.set("wp_quiz_subscribe_username",n.username,{expires:7})),t.trigger("wp_quiz_complete_force_action")}),a.fail(function(e){c.helpers.hideLoading(r),s.html(e.responseJSON.message)})}(e)})}})}(jQuery,wpQuiz);