// source --> https://www.hydro21.org/wp-content/plugins/content-protector/assets/public/passster-public.min.js?ver=4.1.4 
jQuery(document).ready(function(t){function e(){switch(ps_ajax.cookie_duration_unit){case"days":default:return parseInt(ps_ajax.cookie_duration);case"hours":return new Date(new Date().getTime()+6e5*ps_ajax.cookie_duration);case"minutes":return new Date(new Date().getTime()+6e4*ps_ajax.cookie_duration)}}function a(){return location.search?location.origin.concat(location.pathname).concat(location.hash)+location.search+"&pts="+Math.floor(Date.now()/1e3):location.origin.concat(location.pathname).concat(location.hash)+"?pts="+Math.floor(Date.now()/1e3)}function s(a){t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"hash_password",hash_nonce:ps_ajax.hash_nonce,password:a},success:function(t){Cookies.set("passster",t.password,{expires:e(),sameSite:"strict"})},async:!1})}ps_ajax.link_pass&&!ps_ajax.disable_cookie&&(ps_ajax.link_pass.length<25?s(atob(ps_ajax.link_pass)):Cookies.set("passster",ps_ajax.link_pass,{expires:e(),sameSite:"strict"}),window.location.replace(ps_ajax.permalink+"?pts="+Math.floor(Date.now()/1e3))),t(".passster-submit").on("click",function(e){e.preventDefault();var r=t(this).parent().parent();t(r)[0].checkValidity()||t(r)[0].reportValidity(),ps_id=t(this).attr("data-psid"),r=t("#"+ps_id),password=t("#"+ps_id+" .passster-password").attr("data-password"),type=t("#"+ps_id+" .passster-password").attr("data-protection-type"),list=t("#"+ps_id+" .passster-password").attr("data-list"),area=t("#"+ps_id+" .passster-password").attr("data-area"),protection=t("#"+ps_id+" .passster-password").attr("data-protection"),redirect=t(this).attr("data-redirect"),input=t("#"+ps_id+" .passster-password").val(),acf=t(this).attr("data-acf"),t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"validate_input",nonce:ps_ajax.nonce,input:input,password:password,post_id:ps_ajax.post_id,type:type,list:list,area:area,protection:protection,acf:acf,redirect:redirect},beforeSend:function(){r.find(".ps-loader").css("display","block")},success:function(e){if(r.find(".ps-loader").css("display","none"),!0===e.success){if(ps_ajax.unlock_mode){ps_ajax.disable_cookie||s(input),r.find(".passster-error").hide();let c=e.content;c&&(t.each(ps_ajax.shortcodes,function(t,e){c=c.replace(t,e)}),t("#"+ps_id).replaceWith(c)),e.redirect&&window.location.replace(redirect)}else s(input),e.redirect?window.location.replace(redirect):window.location.href=a()}else r.find(".passster-error").text(e.error),r.find(".passster-error").show().fadeOut(3500),t("#"+ps_id+" .passster-password").val("")}})}),t(".recaptcha-form-v2").length>0&&grecaptcha.ready(function(){grecaptcha.render("ps-recaptcha-v2",{sitekey:ps_ajax.recaptcha_key,callback:function(s){ps_id=t(".recaptcha-v2-submit").attr("data-psid"),form=t("#"+ps_id),protection=t(".recaptcha-v2-submit").attr("data-protection"),acf=t(".recaptcha-v2-submit").attr("data-acf"),area=t("#"+ps_id).find(".recaptcha-v2-submit").attr("data-area"),redirect=t("#"+ps_id).find(".recaptcha-v2-submit").attr("data-redirect"),t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"validate_input",nonce:ps_ajax.nonce,token:s,post_id:ps_ajax.post_id,type:"recaptcha",protection:protection,captcha_id:ps_id,acf:acf,area:area,redirect:redirect},success:function(s){if(!0===s.success){if(ps_ajax.unlock_mode){ps_ajax.disable_cookie||Cookies.set("passster","recaptcha",{expires:e(),sameSite:"strict"}),form.find(".passster-error").hide();let r=s.content;r&&(t.each(ps_ajax.shortcodes,function(t,e){r=r.replace(t,e)}),t("#"+ps_id).replaceWith(r)),s.redirect&&window.location.replace(redirect)}else Cookies.set("passster","recaptcha",{expires:e(),sameSite:"strict"}),s.redirect?window.location.replace(redirect):window.location.href=a()}else form.find(".passster-error").text(s.error),form.find(".passster-error").show().fadeOut(3500)}})}})}),t(".recaptcha-form").on("submit",function(s){s.preventDefault(),ps_id=t(this).find(".passster-submit-recaptcha").attr("data-psid"),form=t("#"+ps_id),protection=t(this).find(".passster-submit-recaptcha").attr("data-protection"),acf=t(this).find(".passster-submit-recaptcha").attr("data-acf"),area=t(this).find(".passster-submit-recaptcha").attr("data-area"),redirect=t(this).find(".passster-submit-recaptcha").attr("data-redirect"),grecaptcha.ready(function(){grecaptcha.execute(ps_ajax.recaptcha_key,{action:"validate_input"}).then(function(s){form.prepend('<input type="hidden" name="token" value="'+s+'">'),form.prepend('<input type="hidden" name="action" value="validate_input">'),t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"validate_input",nonce:ps_ajax.nonce,token:s,post_id:ps_ajax.post_id,type:"recaptcha",protection:protection,captcha_id:ps_id,acf:acf,area:area,redirect:redirect},success:function(s){if(!0===s.success){if(ps_ajax.unlock_mode){ps_ajax.disable_cookie||Cookies.set("passster","recaptcha",{expires:e(),sameSite:"strict"}),form.find(".passster-error").hide();let r=s.content;r&&(t.each(ps_ajax.shortcodes,function(t,e){r=r.replace(t,e)}),form.replaceWith(r)),s.redirect&&window.location.replace(redirect)}else Cookies.set("passster","recaptcha",{expires:e(),sameSite:"strict"}),s.redirect?window.location.replace(redirect):window.location.href=a()}else form.find(".passster-error").text(s.error),form.find(".passster-error").show().fadeOut(3500)}})})})}),t(".hcaptcha-form").on("submit",function(s){s.preventDefault(),ps_id=t(this).find(".passster-submit-recaptcha").attr("data-psid"),form=t("#"+ps_id),protection=t(this).find(".passster-submit-recaptcha").attr("data-protection"),acf=t(this).find(".passster-submit-recaptcha").attr("data-acf"),area=t(this).find(".passster-submit-recaptcha").attr("data-area"),redirect=t(this).find(".passster-submit-recaptcha").attr("data-redirect"),hcaptcha.execute({async:!0}).then(({response:s,key:r})=>{t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"validate_input",nonce:ps_ajax.nonce,token:s,post_id:ps_ajax.post_id,type:"recaptcha",protection:protection,captcha_id:ps_id,acf:acf,area:area,redirect:redirect},success:function(s){if(!0===s.success){if(ps_ajax.unlock_mode){ps_ajax.disable_cookie||Cookies.set("passster","recaptcha",{expires:e(),sameSite:"strict"}),form.find(".passster-error").hide();let r=s.content;r&&(t.each(ps_ajax.shortcodes,function(t,e){r=r.replace(t,e)}),form.replaceWith(r)),s.redirect&&window.location.replace(redirect)}else Cookies.set("passster","recaptcha",{expires:e(),sameSite:"strict"}),s.redirect?window.location.replace(redirect):window.location.href=a()}else form.find(".passster-error").text(s.error),form.find(".passster-error").show().fadeOut(3500)}})}).catch(t=>{form.find(".passster-error").text(t),form.find(".passster-error").show().fadeOut(3500)})}),t(document).on("click","#ps-logout",function(){t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"handle_logout",logout_nonce:ps_ajax.logout_nonce},success:function(t){!0===t.success&&(Cookies.set("passster","",{expires:0,sameSite:"strict"}),window.location.href=a())}})})});