diff --git a/gulpfile.js b/gulpfile.js index cff9c5a91..7ad25355d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -67,6 +67,9 @@ function bundle_public_default() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-3*.js', ]) @@ -82,6 +85,9 @@ function bundle_public_default_with_gathering() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-2-gathering-data.js', 'js/src/public-3*.js', @@ -98,6 +104,9 @@ function bundle_public_external_protection() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-2-external-forms.js', '!js/src/public-2-gathering-data.js', @@ -115,6 +124,9 @@ function bundle_public_external_protection_with_gathering() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-2-external-forms.js', 'js/src/public-2-gathering-data.js', @@ -132,6 +144,9 @@ function bundle_public_internal_protection() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-2-internal-forms.js', 'js/src/public-3*.js', @@ -148,6 +163,9 @@ function bundle_public_internal_protection_with_gathering() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-2-internal-forms.js', 'js/src/public-2-gathering-data.js', @@ -165,6 +183,9 @@ function bundle_public_full_protection() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-2*.js', '!js/src/public-2-gathering-data.js', @@ -182,6 +203,9 @@ function bundle_public_full_protection_with_gathering() { 'js/src/common-decoder.js', 'js/src/common-cleantalk-modal.js', 'js/src/public-0*.js', + 'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js', + 'js/src/ShadowrootProtection/ApbctShadowRootConfig.js', + 'js/src/ShadowrootProtection/ApbctShadowRootProtection.js', 'js/src/public-1*.js', 'js/src/public-2*.js', 'js/src/public-3*.js', diff --git a/inc/cleantalk-integrations-by-hook.php b/inc/cleantalk-integrations-by-hook.php index 0739c8322..d5033fcaa 100755 --- a/inc/cleantalk-integrations-by-hook.php +++ b/inc/cleantalk-integrations-by-hook.php @@ -338,6 +338,11 @@ 'setting' => 'forms__registrations_test', 'ajax' => false ), + 'MailChimpShadowRoot' => array( + 'hook' => 'cleantalk_force_mailchimp_shadowroot_check', + 'setting' => 'forms__check_external', + 'ajax' => true + ), 'BloomForms' => array( 'hook' => 'bloom_subscribe', 'setting' => 'forms__contact_forms_test', diff --git a/inc/cleantalk-pluggable.php b/inc/cleantalk-pluggable.php index 23ceef5d9..24fcab4e7 100644 --- a/inc/cleantalk-pluggable.php +++ b/inc/cleantalk-pluggable.php @@ -714,6 +714,7 @@ function apbct_is_skip_request($ajax = false, $ajax_message_obj = array()) 'nasa_process_login', //Nasa login 'leaky_paywall_validate_registration', //Leaky Paywall validation request 'cleantalk_force_ajax_check', //Force ajax check has direct integration + 'cleantalk_force_mailchimp_shadowroot_check', // Mailchimp ShadowRoot has direct integration 'cscf-submitform', // CSCF has direct integration 'mailpoet', // Mailpoet has direct integration 'wpcommunity_auth_login', // WPCommunity login diff --git a/js/apbct-public-bundle.min.js b/js/apbct-public-bundle.min.js index f40264587..ff28a8002 100644 --- a/js/apbct-public-bundle.min.js +++ b/js/apbct-public-bundle.min.js @@ -1 +1 @@ -function _regenerator(){var f,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function o(e,t,n,o){var a,i,r,c,l,s,d,u,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,i=n,d=o||[],u=!1,p={p:s=0,n:0,v:f,a:_,f:_.bind(f,4),d:function(e,t){return r=e,c=0,l=f,p.n=t,m}},function(e,t,n){if(1t||i=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(r.data.forEach(function(e){e.encoded_email===i[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===i[t].href||0!==i[t].href.indexOf("mailto:")&&0!==i[t].href.indexOf("tel:"))i[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,i[t])},2e3);else{if(0===i[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==i[t].href.indexOf("tel:"))return 0;e="tel:"}var o=i[t].href.replace(e,""),a=i[t].innerHTML;i[t].innerHTML=a.replace(o,n.decoded_email),i[t].href=e+n.decoded_email,i[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";r.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}i[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=r.data[0];i.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,i)},2e3),i.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(i.innerHTML="Loading...",t&&this.load(t)),i.setAttribute("id","cleantalk-modal-content"),n.append(i),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;nMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function c(){_classCallCheck(this,c)}return _createClass(c,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.p=2,n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,n));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof n[0].includes&&n[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,n));case 7:"function"==typeof n[0].includes&&n[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,n));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof n[0].includes&&n[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&n[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),i={action:"cleantalk_force_ajax_check"},r=_createForOfIteratorHelper(a.elements);try{for(r.s();!(c=r.n()).done;)i[(l=c.value).name]=l.value}catch(e){r.e(e)}finally{r.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(i,{async:!0,callback:function(e,t,n,o){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,n));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var n={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(n.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(n.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(n.found="action=mailpoet",n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(n.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(n.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(n.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(n.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(n.found="action=drplus_signup",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(n.found="action=bt_cc",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(n.found="action=wpr_form_builder_email",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(n.found="action=nf_ajax_submit",n.keepUnwrapped=!0,n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(n.found="action=uael_register_user",n.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(n.found="wc-ajax=add_to_cart"),!1!==n.found){var o="",a="",i="";if(+ctPublic.settings__data__bot_detector_enabled?(r=(new c).toolGetEventToken())&&(o=n.keepUnwrapped?"ct_bot_detector_event_token="+r+"&":"data%5Bct_bot_detector_event_token%5D="+r+"&"):(a=getNoCookieData(),a=n.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),n.attachVisibleFieldsData){var r=!1,n=ApbctVisibleFieldsExtractor.createExtractor(n.found);if("string"==typeof(r=n?n.extract(t.data):r))try{i="apbct_visible_fields="+encodeURIComponent(r)+"&"}catch(e){}}t.data=a+o+i+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var n;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,i=t.querySelector('[name*="apbct_email_id__"]'),r=null,c=(null!==i&&null!==i.value&&(r=i.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===c&&null===i&&null===l||(e.preventDefault(),n=function(){null!==i&&i.parentNode.removeChild(i),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=c,null!==r&&(o.apbct_search_form__honeypot_value=r),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var i=o.value,r=this.findParentContainer(i);if(r){var c=this.getIdFromHTML(r);if(c===n){var l=r.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,i,r,c,l,s,d;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",u.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(c=document.createElement("strong")).append(u.phrases.trpHeading),(i=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),i.setAttribute("style","white-space: nowrap"),(r=document.createElement("div")).append(c),r.append(" "),r.append(u.phrases.trpContent1),(c=document.createElement("div")).style.display="flex",c.style.gap="5px",(l=document.createElement("div")).append(u.phrases.trpContent2),c.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",u.trpContentLink),s.setAttribute("target","_blank"),(d=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),d.setAttribute("alt","New window"),d.setAttribute("style","padding-top:3px"),s.append(d),l.append(s),c.append(l)),i.append(r,c),a.append(i),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===r[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===r[t].href||0!==r[t].href.indexOf("mailto:")&&0!==r[t].href.indexOf("tel:"))r[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r[t])},2e3);else{if(0===r[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==r[t].href.indexOf("tel:"))return 0;e="tel:"}var o=r[t].href.replace(e,""),a=r[t].innerHTML;r[t].innerHTML=a.replace(o,n.decoded_email),r[t].href=e+n.decoded_email,r[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}r[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];r.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r)},2e3),r.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(r.innerHTML="Loading...",t&&this.load(t)),r.setAttribute("id","cleantalk-modal-content"),n.append(r),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;n{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,n=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function c(){_classCallCheck(this,c)}return _createClass(c,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.prev=10,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,n));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,r=t.querySelector('[name*="apbct_email_id__"]'),i=null,c=(null!==r&&null!==r.value&&(i=r.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===c&&null===r&&null===l||(e.preventDefault(),n=function(){null!==r&&r.parentNode.removeChild(r),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=c,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var r=o.value,i=this.findParentContainer(r);if(i){var c=this.getIdFromHTML(i);if(c===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,r,i,c,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(c=document.createElement("strong")).append(d.phrases.trpHeading),(r=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),r.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(c),i.append(" "),i.append(d.phrases.trpContent1),(c=document.createElement("div")).style.display="flex",c.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),c.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),c.append(l)),r.append(i,c),a.append(r),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/apbct-public-bundle_ext-protection.min.js b/js/apbct-public-bundle_ext-protection.min.js index 6f76c17d1..96ba7b647 100644 --- a/js/apbct-public-bundle_ext-protection.min.js +++ b/js/apbct-public-bundle_ext-protection.min.js @@ -1 +1 @@ -function _regenerator(){var f,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function o(e,t,n,o){var a,i,c,r,l,s,d,u,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,i=n,d=o||[],u=!1,p={p:s=0,n:0,v:f,a:m,f:m.bind(f,4),d:function(e,t){return c=e,r=0,l=f,p.n=t,_}},function(e,t,n){if(1t||i=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(c.data.forEach(function(e){e.encoded_email===i[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===i[t].href||0!==i[t].href.indexOf("mailto:")&&0!==i[t].href.indexOf("tel:"))i[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,i[t])},2e3);else{if(0===i[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==i[t].href.indexOf("tel:"))return 0;e="tel:"}var o=i[t].href.replace(e,""),a=i[t].innerHTML;i[t].innerHTML=a.replace(o,n.decoded_email),i[t].href=e+n.decoded_email,i[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";c.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}i[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=c.data[0];i.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,i)},2e3),i.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(i.innerHTML="Loading...",t&&this.load(t)),i.setAttribute("id","cleantalk-modal-content"),n.append(i),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;nMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.p=2,n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,n));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof n[0].includes&&n[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,n));case 7:"function"==typeof n[0].includes&&n[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,n));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof n[0].includes&&n[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&n[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),i={action:"cleantalk_force_ajax_check"},c=_createForOfIteratorHelper(a.elements);try{for(c.s();!(r=c.n()).done;)i[(l=r.value).name]=l.value}catch(e){c.e(e)}finally{c.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(i,{async:!0,callback:function(e,t,n,o){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,n));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var n={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(n.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(n.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(n.found="action=mailpoet",n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(n.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(n.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(n.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(n.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(n.found="action=drplus_signup",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(n.found="action=bt_cc",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(n.found="action=wpr_form_builder_email",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(n.found="action=nf_ajax_submit",n.keepUnwrapped=!0,n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(n.found="action=uael_register_user",n.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(n.found="wc-ajax=add_to_cart"),!1!==n.found){var o="",a="",i="";if(+ctPublic.settings__data__bot_detector_enabled?(c=(new r).toolGetEventToken())&&(o=n.keepUnwrapped?"ct_bot_detector_event_token="+c+"&":"data%5Bct_bot_detector_event_token%5D="+c+"&"):(a=getNoCookieData(),a=n.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),n.attachVisibleFieldsData){var c=!1,n=ApbctVisibleFieldsExtractor.createExtractor(n.found);if("string"==typeof(c=n?n.extract(t.data):c))try{i="apbct_visible_fields="+encodeURIComponent(c)+"&"}catch(e){}}t.data=a+o+i+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var n;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,i=t.querySelector('[name*="apbct_email_id__"]'),c=null,r=(null!==i&&null!==i.value&&(c=i.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===i&&null===l||(e.preventDefault(),n=function(){null!==i&&i.parentNode.removeChild(i),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==c&&(o.apbct_search_form__honeypot_value=c),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var i=o.value,c=this.findParentContainer(i);if(c){var r=this.getIdFromHTML(c);if(r===n){var l=c.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,i,c,r,l,s,d;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",u.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(u.phrases.trpHeading),(i=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),i.setAttribute("style","white-space: nowrap"),(c=document.createElement("div")).append(r),c.append(" "),c.append(u.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(u.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",u.trpContentLink),s.setAttribute("target","_blank"),(d=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),d.setAttribute("alt","New window"),d.setAttribute("style","padding-top:3px"),s.append(d),l.append(s),r.append(l)),i.append(c,r),a.append(i),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===r[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===r[t].href||0!==r[t].href.indexOf("mailto:")&&0!==r[t].href.indexOf("tel:"))r[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r[t])},2e3);else{if(0===r[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==r[t].href.indexOf("tel:"))return 0;e="tel:"}var o=r[t].href.replace(e,""),a=r[t].innerHTML;r[t].innerHTML=a.replace(o,n.decoded_email),r[t].href=e+n.decoded_email,r[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}r[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];r.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r)},2e3),r.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(r.innerHTML="Loading...",t&&this.load(t)),r.setAttribute("id","cleantalk-modal-content"),n.append(r),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;n{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,n=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function c(){_classCallCheck(this,c)}return _createClass(c,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.prev=10,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,n));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,r=t.querySelector('[name*="apbct_email_id__"]'),i=null,c=(null!==r&&null!==r.value&&(i=r.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===c&&null===r&&null===l||(e.preventDefault(),n=function(){null!==r&&r.parentNode.removeChild(r),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=c,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var r=o.value,i=this.findParentContainer(r);if(i){var c=this.getIdFromHTML(i);if(c===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,r,i,c,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(c=document.createElement("strong")).append(d.phrases.trpHeading),(r=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),r.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(c),i.append(" "),i.append(d.phrases.trpContent1),(c=document.createElement("div")).style.display="flex",c.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),c.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),c.append(l)),r.append(i,c),a.append(r),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/apbct-public-bundle_ext-protection_gathering.min.js b/js/apbct-public-bundle_ext-protection_gathering.min.js index 0e59e8807..0f8e62776 100644 --- a/js/apbct-public-bundle_ext-protection_gathering.min.js +++ b/js/apbct-public-bundle_ext-protection_gathering.min.js @@ -1 +1 @@ -function _regenerator(){var m,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function o(e,t,n,o){var a,c,i,r,l,s,u,d,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,c=n,u=o||[],d=!1,p={p:s=0,n:0,v:m,a:_,f:_.bind(m,4),d:function(e,t){return i=e,r=0,l=m,p.n=t,f}},function(e,t,n){if(1t||c=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var o=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(o,n.decoded_email),c[t].href=e+n.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),n.append(c),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;nMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.p=2,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,n));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof n[0].includes&&n[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,n));case 7:"function"==typeof n[0].includes&&n[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,n));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof n[0].includes&&n[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&n[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),c={action:"cleantalk_force_ajax_check"},i=_createForOfIteratorHelper(a.elements);try{for(i.s();!(r=i.n()).done;)c[(l=r.value).name]=l.value}catch(e){i.e(e)}finally{i.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(c,{async:!0,callback:function(e,t,n,o){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,n));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var n={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(n.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(n.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(n.found="action=mailpoet",n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(n.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(n.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(n.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(n.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(n.found="action=drplus_signup",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(n.found="action=bt_cc",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(n.found="action=wpr_form_builder_email",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(n.found="action=nf_ajax_submit",n.keepUnwrapped=!0,n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(n.found="action=uael_register_user",n.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(n.found="wc-ajax=add_to_cart"),!1!==n.found){var o="",a="",c="";if(+ctPublic.settings__data__bot_detector_enabled?(i=(new r).toolGetEventToken())&&(o=n.keepUnwrapped?"ct_bot_detector_event_token="+i+"&":"data%5Bct_bot_detector_event_token%5D="+i+"&"):(a=getNoCookieData(),a=n.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),n.attachVisibleFieldsData){var i=!1,n=ApbctVisibleFieldsExtractor.createExtractor(n.found);if("string"==typeof(i=n?n.extract(t.data):i))try{c="apbct_visible_fields="+encodeURIComponent(i)+"&"}catch(e){}}t.data=a+o+c+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var n;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),n=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var c=o.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var n,o=0;o_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var n=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){n.data.push(Object.assign({},n.fieldData))})}},{key:"setListeners",value:function(){var o=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){o.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){o.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,n){e.addEventListener("input",function(){o.data[n].countOfKey++;var e,t=+new Date;1===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].firstKeyTimestamp=t):(e=t-o.data[n].lastKeyTimestamp,2===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var o=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(o,n.decoded_email),c[t].href=e+n.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),n.append(c),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;n{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,n=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.prev=10,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,n));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),n=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var c=o.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var n,o=0;o_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var n=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){n.data.push(Object.assign({},n.fieldData))})}},{key:"setListeners",value:function(){var o=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){o.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){o.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,n){e.addEventListener("input",function(){o.data[n].countOfKey++;var e,t=+new Date;1===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].firstKeyTimestamp=t):(e=t-o.data[n].lastKeyTimestamp,2===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/apbct-public-bundle_full-protection.min.js b/js/apbct-public-bundle_full-protection.min.js index 7c080c845..6aa42b684 100644 --- a/js/apbct-public-bundle_full-protection.min.js +++ b/js/apbct-public-bundle_full-protection.min.js @@ -1 +1 @@ -function _regenerator(){var f,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function o(e,t,n,o){var a,c,i,r,l,s,d,u,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,c=n,d=o||[],u=!1,p={p:s=0,n:0,v:f,a:m,f:m.bind(f,4),d:function(e,t){return i=e,r=0,l=f,p.n=t,_}},function(e,t,n){if(1t||c=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var o=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(o,n.decoded_email),c[t].href=e+n.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),n.append(c),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;nMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.p=2,n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,n));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof n[0].includes&&n[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,n));case 7:"function"==typeof n[0].includes&&n[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(n[1].body=u(n[1].body,d(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,n));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof n[0].includes&&n[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&n[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),c={action:"cleantalk_force_ajax_check"},i=_createForOfIteratorHelper(a.elements);try{for(i.s();!(r=i.n()).done;)c[(l=r.value).name]=l.value}catch(e){i.e(e)}finally{i.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(c,{async:!0,callback:function(e,t,n,o){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,n));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var n={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(n.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(n.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(n.found="action=mailpoet",n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(n.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(n.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(n.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(n.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(n.found="action=drplus_signup",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(n.found="action=bt_cc",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(n.found="action=wpr_form_builder_email",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(n.found="action=nf_ajax_submit",n.keepUnwrapped=!0,n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(n.found="action=uael_register_user",n.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(n.found="wc-ajax=add_to_cart"),!1!==n.found){var o="",a="",c="";if(+ctPublic.settings__data__bot_detector_enabled?(i=(new r).toolGetEventToken())&&(o=n.keepUnwrapped?"ct_bot_detector_event_token="+i+"&":"data%5Bct_bot_detector_event_token%5D="+i+"&"):(a=getNoCookieData(),a=n.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),n.attachVisibleFieldsData){var i=!1,n=ApbctVisibleFieldsExtractor.createExtractor(n.found);if("string"==typeof(i=n?n.extract(t.data):i))try{c="apbct_visible_fields="+encodeURIComponent(i)+"&"}catch(e){}}t.data=a+o+c+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var n;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),n=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var c=o.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"wrappers",[]),this.wrappers=this.findWrappers(),this.wrappers.length<1||this.checkBot()},[{key:"findWrappers",value:function(){return document.querySelectorAll("div.ct-encoded-form-wrapper")}},{key:"checkBot",value:function(){var t=this,e={post_url:document.location.href,referrer:document.referrer};1==ctPublic.settings__data__bot_detector_enabled?e.event_token=apbctLocalStorage.get("bot_detector_event_token"):e.event_javascript_data=getJavascriptClientData(),"rest"===ctPublicFunctions.data__ajax_type?apbct_public_sendREST("force_protection_check_bot",{data:e,method:"POST",callback:function(e){return t.checkBotCallback(e)}}):"admin_ajax"===ctPublicFunctions.data__ajax_type&&(e.action="apbct_force_protection_check_bot",apbct_public_sendAJAX(e,{callback:function(e){return t.checkBotCallback(e)}}))}},{key:"checkBotCallback",value:function(e){if(e.data&&e.data.status&&200!==e.data.status)console.log("ApbctForceProtection connection error occurred"),this.decodeForms();else{if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return console.log("ApbctForceProtection decodeForms error",e),void this.decodeForms()}"object"===_typeof(e)&&e.allow&&1===e.allow?(this.decodeForms(),document.dispatchEvent(new Event("apbctForceProtectionAllowed"))):this.showMessageForBot(e.message)}}},{key:"decodeForms",value:function(){var n;this.wrappers.forEach(function(e){n=e.querySelector("div.ct-encoded-form").dataset.encodedForm;try{var t;n&&"string"==typeof n&&(t=decodeURIComponent(n),e.outerHTML=atob(t))}catch(e){console.log(e)}})}},{key:"showMessageForBot",value:function(t){this.wrappers.forEach(function(e){e.querySelector("div.ct-encoded-form").dataset.encodedForm&&(e.outerHTML='
'+t+"
")})}}]))();function apbctForceProtect(){+ctPublic.settings__forms__force_protection&&void 0!==ApbctForceProtection&&new ApbctForceProtection}function ctCheckInternal(t){var e,n={},o=t.elements;for(e in o)"submit"!==o[e].type&&void 0!==o[e].value&&""!==o[e].value&&(n[o[e].name]=t.elements[e].value);n.action="ct_check_internal",apbct_public_sendAJAX(n,{url:ctPublicFunctions._ajax_url,callback:function(e){if(!0!==e.success)return alert(e.data),!1;t.origSubmit()}})}function ctProtectInternalForms(){for(var e,t="",n="",o=0;o .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,c,i,r,l,s,d;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",u.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(u.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(u.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(u.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",u.trpContentLink),s.setAttribute("target","_blank"),(d=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),d.setAttribute("alt","New window"),d.setAttribute("style","padding-top:3px"),s.append(d),l.append(s),r.append(l)),c.append(i,r),a.append(c),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(c.data.forEach(function(e){e.encoded_email===r[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===r[t].href||0!==r[t].href.indexOf("mailto:")&&0!==r[t].href.indexOf("tel:"))r[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r[t])},2e3);else{if(0===r[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==r[t].href.indexOf("tel:"))return 0;e="tel:"}var o=r[t].href.replace(e,""),a=r[t].innerHTML;r[t].innerHTML=a.replace(o,n.decoded_email),r[t].href=e+n.decoded_email,r[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";c.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}r[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=c.data[0];r.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r)},2e3),r.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(r.innerHTML="Loading...",t&&this.load(t)),r.setAttribute("id","cleantalk-modal-content"),n.append(r),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;n{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,n=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function i(){_classCallCheck(this,i)}return _createClass(i,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.prev=10,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,n));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,r=t.querySelector('[name*="apbct_email_id__"]'),c=null,i=(null!==r&&null!==r.value&&(c=r.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===i&&null===r&&null===l||(e.preventDefault(),n=function(){null!==r&&r.parentNode.removeChild(r),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=i,null!==c&&(o.apbct_search_form__honeypot_value=c),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var r=o.value,c=this.findParentContainer(r);if(c){var i=this.getIdFromHTML(c);if(i===n){var l=c.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"wrappers",[]),this.wrappers=this.findWrappers(),this.wrappers.length<1||this.checkBot()},[{key:"findWrappers",value:function(){return document.querySelectorAll("div.ct-encoded-form-wrapper")}},{key:"checkBot",value:function(){var t=this,e={post_url:document.location.href,referrer:document.referrer};1==ctPublic.settings__data__bot_detector_enabled?e.event_token=apbctLocalStorage.get("bot_detector_event_token"):e.event_javascript_data=getJavascriptClientData(),"rest"===ctPublicFunctions.data__ajax_type?apbct_public_sendREST("force_protection_check_bot",{data:e,method:"POST",callback:function(e){return t.checkBotCallback(e)}}):"admin_ajax"===ctPublicFunctions.data__ajax_type&&(e.action="apbct_force_protection_check_bot",apbct_public_sendAJAX(e,{callback:function(e){return t.checkBotCallback(e)}}))}},{key:"checkBotCallback",value:function(e){if(e.data&&e.data.status&&200!==e.data.status)console.log("ApbctForceProtection connection error occurred"),this.decodeForms();else{if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return console.log("ApbctForceProtection decodeForms error",e),void this.decodeForms()}"object"===_typeof(e)&&e.allow&&1===e.allow?(this.decodeForms(),document.dispatchEvent(new Event("apbctForceProtectionAllowed"))):this.showMessageForBot(e.message)}}},{key:"decodeForms",value:function(){var n;this.wrappers.forEach(function(e){n=e.querySelector("div.ct-encoded-form").dataset.encodedForm;try{var t;n&&"string"==typeof n&&(t=decodeURIComponent(n),e.outerHTML=atob(t))}catch(e){console.log(e)}})}},{key:"showMessageForBot",value:function(t){this.wrappers.forEach(function(e){e.querySelector("div.ct-encoded-form").dataset.encodedForm&&(e.outerHTML='
'+t+"
")})}}]))();function apbctForceProtect(){+ctPublic.settings__forms__force_protection&&void 0!==ApbctForceProtection&&new ApbctForceProtection}function ctCheckInternal(t){var e,n={},o=t.elements;for(e in o)"submit"!==o[e].type&&void 0!==o[e].value&&""!==o[e].value&&(n[o[e].name]=t.elements[e].value);n.action="ct_check_internal",apbct_public_sendAJAX(n,{url:ctPublicFunctions._ajax_url,callback:function(e){if(!0!==e.success)return alert(e.data),!1;t.origSubmit()}})}function ctProtectInternalForms(){for(var e,t="",n="",o=0;o .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,r,c,i,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(i=document.createElement("strong")).append(d.phrases.trpHeading),(r=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),r.setAttribute("style","white-space: nowrap"),(c=document.createElement("div")).append(i),c.append(" "),c.append(d.phrases.trpContent1),(i=document.createElement("div")).style.display="flex",i.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),i.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),i.append(l)),r.append(c,i),a.append(r),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/apbct-public-bundle_full-protection_gathering.min.js b/js/apbct-public-bundle_full-protection_gathering.min.js index a7f04a62a..0ed729b54 100644 --- a/js/apbct-public-bundle_full-protection_gathering.min.js +++ b/js/apbct-public-bundle_full-protection_gathering.min.js @@ -1 +1 @@ -function _regenerator(){var m,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function o(e,t,n,o){var a,c,i,r,l,s,u,d,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,c=n,u=o||[],d=!1,p={p:s=0,n:0,v:m,a:_,f:_.bind(m,4),d:function(e,t){return i=e,r=0,l=m,p.n=t,f}},function(e,t,n){if(1t||c=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var o=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(o,n.decoded_email),c[t].href=e+n.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),n.append(c),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;nMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.p=2,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,n));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof n[0].includes&&n[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,n));case 7:"function"==typeof n[0].includes&&n[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,n));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof n[0].includes&&n[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&n[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),c={action:"cleantalk_force_ajax_check"},i=_createForOfIteratorHelper(a.elements);try{for(i.s();!(r=i.n()).done;)c[(l=r.value).name]=l.value}catch(e){i.e(e)}finally{i.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(c,{async:!0,callback:function(e,t,n,o){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,n));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var n={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(n.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(n.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(n.found="action=mailpoet",n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(n.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(n.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(n.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(n.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(n.found="action=drplus_signup",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(n.found="action=bt_cc",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(n.found="action=wpr_form_builder_email",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(n.found="action=nf_ajax_submit",n.keepUnwrapped=!0,n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(n.found="action=uael_register_user",n.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(n.found="wc-ajax=add_to_cart"),!1!==n.found){var o="",a="",c="";if(+ctPublic.settings__data__bot_detector_enabled?(i=(new r).toolGetEventToken())&&(o=n.keepUnwrapped?"ct_bot_detector_event_token="+i+"&":"data%5Bct_bot_detector_event_token%5D="+i+"&"):(a=getNoCookieData(),a=n.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),n.attachVisibleFieldsData){var i=!1,n=ApbctVisibleFieldsExtractor.createExtractor(n.found);if("string"==typeof(i=n?n.extract(t.data):i))try{c="apbct_visible_fields="+encodeURIComponent(i)+"&"}catch(e){}}t.data=a+o+c+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var n;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),n=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var c=o.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"wrappers",[]),this.wrappers=this.findWrappers(),this.wrappers.length<1||this.checkBot()},[{key:"findWrappers",value:function(){return document.querySelectorAll("div.ct-encoded-form-wrapper")}},{key:"checkBot",value:function(){var t=this,e={post_url:document.location.href,referrer:document.referrer};1==ctPublic.settings__data__bot_detector_enabled?e.event_token=apbctLocalStorage.get("bot_detector_event_token"):e.event_javascript_data=getJavascriptClientData(),"rest"===ctPublicFunctions.data__ajax_type?apbct_public_sendREST("force_protection_check_bot",{data:e,method:"POST",callback:function(e){return t.checkBotCallback(e)}}):"admin_ajax"===ctPublicFunctions.data__ajax_type&&(e.action="apbct_force_protection_check_bot",apbct_public_sendAJAX(e,{callback:function(e){return t.checkBotCallback(e)}}))}},{key:"checkBotCallback",value:function(e){if(e.data&&e.data.status&&200!==e.data.status)console.log("ApbctForceProtection connection error occurred"),this.decodeForms();else{if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return console.log("ApbctForceProtection decodeForms error",e),void this.decodeForms()}"object"===_typeof(e)&&e.allow&&1===e.allow?(this.decodeForms(),document.dispatchEvent(new Event("apbctForceProtectionAllowed"))):this.showMessageForBot(e.message)}}},{key:"decodeForms",value:function(){var n;this.wrappers.forEach(function(e){n=e.querySelector("div.ct-encoded-form").dataset.encodedForm;try{var t;n&&"string"==typeof n&&(t=decodeURIComponent(n),e.outerHTML=atob(t))}catch(e){console.log(e)}})}},{key:"showMessageForBot",value:function(t){this.wrappers.forEach(function(e){e.querySelector("div.ct-encoded-form").dataset.encodedForm&&(e.outerHTML='
'+t+"
")})}}]))();function apbctForceProtect(){+ctPublic.settings__forms__force_protection&&void 0!==ApbctForceProtection&&new ApbctForceProtection}ctPublic.data__key_is_ok&&("loading"!==document.readyState?apbctForceProtect():apbct_attach_event_handler(document,"DOMContentLoaded",apbctForceProtect));var ctMouseReadInterval,ctMouseWriteDataInterval,ApbctGatheringData=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var n,o=0;o_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var n=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){n.data.push(Object.assign({},n.fieldData))})}},{key:"setListeners",value:function(){var o=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){o.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){o.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,n){e.addEventListener("input",function(){o.data[n].countOfKey++;var e,t=+new Date;1===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].firstKeyTimestamp=t):(e=t-o.data[n].lastKeyTimestamp,2===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var o=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(o,n.decoded_email),c[t].href=e+n.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),n.append(c),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;n{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,n=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.prev=10,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,n));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),n=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var c=o.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"wrappers",[]),this.wrappers=this.findWrappers(),this.wrappers.length<1||this.checkBot()},[{key:"findWrappers",value:function(){return document.querySelectorAll("div.ct-encoded-form-wrapper")}},{key:"checkBot",value:function(){var t=this,e={post_url:document.location.href,referrer:document.referrer};1==ctPublic.settings__data__bot_detector_enabled?e.event_token=apbctLocalStorage.get("bot_detector_event_token"):e.event_javascript_data=getJavascriptClientData(),"rest"===ctPublicFunctions.data__ajax_type?apbct_public_sendREST("force_protection_check_bot",{data:e,method:"POST",callback:function(e){return t.checkBotCallback(e)}}):"admin_ajax"===ctPublicFunctions.data__ajax_type&&(e.action="apbct_force_protection_check_bot",apbct_public_sendAJAX(e,{callback:function(e){return t.checkBotCallback(e)}}))}},{key:"checkBotCallback",value:function(e){if(e.data&&e.data.status&&200!==e.data.status)console.log("ApbctForceProtection connection error occurred"),this.decodeForms();else{if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return console.log("ApbctForceProtection decodeForms error",e),void this.decodeForms()}"object"===_typeof(e)&&e.allow&&1===e.allow?(this.decodeForms(),document.dispatchEvent(new Event("apbctForceProtectionAllowed"))):this.showMessageForBot(e.message)}}},{key:"decodeForms",value:function(){var n;this.wrappers.forEach(function(e){n=e.querySelector("div.ct-encoded-form").dataset.encodedForm;try{var t;n&&"string"==typeof n&&(t=decodeURIComponent(n),e.outerHTML=atob(t))}catch(e){console.log(e)}})}},{key:"showMessageForBot",value:function(t){this.wrappers.forEach(function(e){e.querySelector("div.ct-encoded-form").dataset.encodedForm&&(e.outerHTML='
'+t+"
")})}}]))();function apbctForceProtect(){+ctPublic.settings__forms__force_protection&&void 0!==ApbctForceProtection&&new ApbctForceProtection}ctPublic.data__key_is_ok&&("loading"!==document.readyState?apbctForceProtect():apbct_attach_event_handler(document,"DOMContentLoaded",apbctForceProtect));var ctMouseReadInterval,ctMouseWriteDataInterval,ApbctGatheringData=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var n,o=0;o_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var n=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){n.data.push(Object.assign({},n.fieldData))})}},{key:"setListeners",value:function(){var o=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){o.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){o.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,n){e.addEventListener("input",function(){o.data[n].countOfKey++;var e,t=+new Date;1===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].firstKeyTimestamp=t):(e=t-o.data[n].lastKeyTimestamp,2===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/apbct-public-bundle_gathering.min.js b/js/apbct-public-bundle_gathering.min.js index 5c9efc711..12b6ddad9 100644 --- a/js/apbct-public-bundle_gathering.min.js +++ b/js/apbct-public-bundle_gathering.min.js @@ -1 +1 @@ -function _regenerator(){var f,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",o=e.toStringTag||"@@toStringTag";function n(e,t,o,n){var a,c,i,r,l,s,u,d,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,c=o,u=n||[],d=!1,p={p:s=0,n:0,v:f,a:_,f:_.bind(f,4),d:function(e,t){return i=e,r=0,l=f,p.n=t,m}},function(e,t,o){if(1t||c=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var o;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(o="Object"===(o={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:o)||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o{var o,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(o=e)}),!1===o.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(o,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var n=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(n,o.decoded_email),c[t].href=e+o.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var o="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(o=e.decoded_email)}),t.innerHTML=o})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var o=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(o,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),o.append(c),this.opened=!0},confirm:function(e){var t,o=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var o in e)if(Object.hasOwn(e,o))for(var n=o.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?o||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?o||Boolean(e[t]):o||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):o}},{key:"isWithoutSelector",value:function(e,t){var o,n=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(o=a.n()).done;)n=n||e===o.value}catch(e){a.e(e)}finally{a.f()}return n}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,o=_createForOfIteratorHelper(this.elements);try{for(o.s();!(t=o.n()).done;)t.value.after(e)}catch(e){o.e(e)}finally{o.f()}}},{key:"append",value:function(e){var t,o=_createForOfIteratorHelper(this.elements);try{for(o.s();!(t=o.n()).done;)t.value.append(e)}catch(e){o.e(e)}finally{o.f()}}},{key:"fadeIn",value:function(n){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-o)/n,o=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,o=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(n){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-o)/n,o=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,o=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function n(e){for(var t in _classCallCheck(this,n),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(n,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,o="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(o=e.headers["X-WP-Nonce"]),""!==(o=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:o)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:o,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),o=0;o{function n(){for(var e=arguments.length,t=new Array(e),o=0;o{function a(){for(var e=arguments.length,t=new Array(e),o=0;oMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(n){n.addEventListener("click",function(e){var t=n.getAttribute("href"),o=apbctLocalStorage.get("bot_detector_event_token");o&&(-1===t.indexOf("?")?t+="?":t+="&",n.setAttribute("href",t+="ct_bot_detector_event_token="+o))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var o=document.createElement("input"),t=(o.setAttribute("type","hidden"),o.setAttribute("id","apbct_visible_fields_"+t),o.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),o.value=btoa(JSON.stringify(t)),e.append(o)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),o=getCleanTalkStorageDataArray(),o=JSON.stringify(o);return o="_ct_no_cookie_data_"+btoa(o),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",o),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,o;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(o="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,o+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(o="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,o+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var o="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var n in o){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return o[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,o)}})())?(e.p=2,o[1].body=d(o[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,o));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof o[0].includes&&o[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,o[1].body=d(o[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,o));case 7:"function"==typeof o[0].includes&&o[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(o[1].body=d(o[1].body,u(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,o));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof o[0].includes&&o[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&o[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),c={action:"cleantalk_force_ajax_check"},i=_createForOfIteratorHelper(a.elements);try{for(i.s();!(r=i.n()).done;)c[(l=r.value).name]=l.value}catch(e){i.e(e)}finally{i.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(c,{async:!0,callback:function(e,t,o,n){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,o));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var o={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(o.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(o.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(o.found="action=mailpoet",o.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(o.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(o.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(o.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(o.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(o.found="action=drplus_signup",o.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(o.found="action=bt_cc",o.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(o.found="action=wpr_form_builder_email",o.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(o.found="action=nf_ajax_submit",o.keepUnwrapped=!0,o.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(o.found="action=uael_register_user",o.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(o.found="wc-ajax=add_to_cart"),!1!==o.found){var n="",a="",c="";if(+ctPublic.settings__data__bot_detector_enabled?(i=(new r).toolGetEventToken())&&(n=o.keepUnwrapped?"ct_bot_detector_event_token="+i+"&":"data%5Bct_bot_detector_event_token%5D="+i+"&"):(a=getNoCookieData(),a=o.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),o.attachVisibleFieldsData){var i=!1,o=ApbctVisibleFieldsExtractor.createExtractor(o.found);if("string"==typeof(i=o?o.extract(t.data):i))try{c="apbct_visible_fields="+encodeURIComponent(i)+"&"}catch(e){}}t.data=a+n+c+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var o;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return o.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var o,n,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),o=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},n=r,null!==i&&(n.apbct_search_form__honeypot_value=i),n.ct_bot_detector_event_token=l,"string"==typeof n.apbct_pixel_url&&-1!==n.apbct_pixel_url.indexOf("%3A")&&(n.apbct_pixel_url=decodeURIComponent(n.apbct_pixel_url)),void 0!==(a=JSON.stringify(n))&&0!==a.length?ctSetAlternativeCookie(a,{callback:o,onErrorCallback:o,forceAltCookies:!0}):o())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var n=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,o){n(t)}):jQuery(document).ajaxComplete(function(e,t,o){n(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&n(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),o=this.getIdFromAjax(e);if(o){var n,a=_createForOfIteratorHelper(t);try{for(a.s();!(n=a.n()).done;){var c=n.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===o){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,o=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,o=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var o,n=0;n_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var o=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){o.data.push(Object.assign({},o.fieldData))})}},{key:"setListeners",value:function(){var n=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){n.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){n.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,o){e.addEventListener("input",function(){n.data[o].countOfKey++;var e,t=+new Date;1===n.data[o].countOfKey?(n.data[o].lastKeyTimestamp=t,n.data[o].firstKeyTimestamp=t):(e=t-n.data[o].lastKeyTimestamp,2===n.data[o].countOfKey?(n.data[o].lastKeyTimestamp=t,n.data[o].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var o,n,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((o=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(n=document.createElement("img")).setAttribute("src",d.imgPersonUrl),n.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),o.append(n),e.append(o),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(n){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),n.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),n.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),n.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),n.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),n.addEventListener("touchend",function(){var o=this;a=setTimeout(function(){var e=o.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=n.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var o,n=Object.keys(t);return Object.getOwnPropertySymbols&&(o=Object.getOwnPropertySymbols(t),e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)),n}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var o;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(o="Object"===(o={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:o)||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o{var o,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(o=e)}),!1===o.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(o,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var n=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(n,o.decoded_email),c[t].href=e+o.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var o="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(o=e.decoded_email)}),t.innerHTML=o})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var o=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(o,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),o.append(c),this.opened=!0},confirm:function(e){var t,o=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var o in e)if(Object.hasOwn(e,o))for(var n=o.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?o||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?o||Boolean(e[t]):o||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):o}},{key:"isWithoutSelector",value:function(e,t){var o,n=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(o=a.n()).done;)n=n||e===o.value}catch(e){a.e(e)}finally{a.f()}return n}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,o=_createForOfIteratorHelper(this.elements);try{for(o.s();!(t=o.n()).done;)t.value.after(e)}catch(e){o.e(e)}finally{o.f()}}},{key:"append",value:function(e){var t,o=_createForOfIteratorHelper(this.elements);try{for(o.s();!(t=o.n()).done;)t.value.append(e)}catch(e){o.e(e)}finally{o.f()}}},{key:"fadeIn",value:function(n){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-o)/n,o=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,o=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(n){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-o)/n,o=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,o=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function n(e){for(var t in _classCallCheck(this,n),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(n,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,o="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(o=e.headers["X-WP-Nonce"]),""!==(o=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:o)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:o,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),o=0;o{function n(){for(var e=arguments.length,t=new Array(e),o=0;o{function a(){for(var e=arguments.length,t=new Array(e),o=0;o{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,o=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(n){n.addEventListener("click",function(e){var t=n.getAttribute("href"),o=apbctLocalStorage.get("bot_detector_event_token");o&&(-1===t.indexOf("?")?t+="?":t+="&",n.setAttribute("href",t+="ct_bot_detector_event_token="+o))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var o=document.createElement("input"),t=(o.setAttribute("type","hidden"),o.setAttribute("id","apbct_visible_fields_"+t),o.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),o.value=btoa(JSON.stringify(t)),e.append(o)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),o=getCleanTalkStorageDataArray(),o=JSON.stringify(o);return o="_ct_no_cookie_data_"+btoa(o),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",o),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,o;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(o="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,o+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(o="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,o+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var o="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var n in o){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return o[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,o)}})())?(e.prev=10,o[1].body=d(o[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,o));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return o.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var o,n,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),o=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},n=r,null!==i&&(n.apbct_search_form__honeypot_value=i),n.ct_bot_detector_event_token=l,"string"==typeof n.apbct_pixel_url&&-1!==n.apbct_pixel_url.indexOf("%3A")&&(n.apbct_pixel_url=decodeURIComponent(n.apbct_pixel_url)),void 0!==(a=JSON.stringify(n))&&0!==a.length?ctSetAlternativeCookie(a,{callback:o,onErrorCallback:o,forceAltCookies:!0}):o())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var n=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,o){n(t)}):jQuery(document).ajaxComplete(function(e,t,o){n(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&n(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),o=this.getIdFromAjax(e);if(o){var n,a=_createForOfIteratorHelper(t);try{for(a.s();!(n=a.n()).done;){var c=n.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===o){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,o=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,o=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var o,n=0;n_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var o=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){o.data.push(Object.assign({},o.fieldData))})}},{key:"setListeners",value:function(){var n=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){n.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){n.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,o){e.addEventListener("input",function(){n.data[o].countOfKey++;var e,t=+new Date;1===n.data[o].countOfKey?(n.data[o].lastKeyTimestamp=t,n.data[o].firstKeyTimestamp=t):(e=t-n.data[o].lastKeyTimestamp,2===n.data[o].countOfKey?(n.data[o].lastKeyTimestamp=t,n.data[o].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var o,n,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((o=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(n=document.createElement("img")).setAttribute("src",d.imgPersonUrl),n.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),o.append(n),e.append(o),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(n){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),n.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),n.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),n.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),n.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),n.addEventListener("touchend",function(){var o=this;a=setTimeout(function(){var e=o.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=n.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/apbct-public-bundle_int-protection.min.js b/js/apbct-public-bundle_int-protection.min.js index d997a75dc..00e44fd65 100644 --- a/js/apbct-public-bundle_int-protection.min.js +++ b/js/apbct-public-bundle_int-protection.min.js @@ -1 +1 @@ -function _regenerator(){var f,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function o(e,t,n,o){var a,i,r,c,l,s,u,d,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,i=n,u=o||[],d=!1,p={p:s=0,n:0,v:f,a:_,f:_.bind(f,4),d:function(e,t){return r=e,c=0,l=f,p.n=t,m}},function(e,t,n){if(1t||i=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(r.data.forEach(function(e){e.encoded_email===i[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===i[t].href||0!==i[t].href.indexOf("mailto:")&&0!==i[t].href.indexOf("tel:"))i[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,i[t])},2e3);else{if(0===i[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==i[t].href.indexOf("tel:"))return 0;e="tel:"}var o=i[t].href.replace(e,""),a=i[t].innerHTML;i[t].innerHTML=a.replace(o,n.decoded_email),i[t].href=e+n.decoded_email,i[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";r.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}i[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=r.data[0];i.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,i)},2e3),i.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(i.innerHTML="Loading...",t&&this.load(t)),i.setAttribute("id","cleantalk-modal-content"),n.append(i),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;nMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function c(){_classCallCheck(this,c)}return _createClass(c,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.p=2,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,n));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof n[0].includes&&n[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,n));case 7:"function"==typeof n[0].includes&&n[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,n));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof n[0].includes&&n[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&n[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),i={action:"cleantalk_force_ajax_check"},r=_createForOfIteratorHelper(a.elements);try{for(r.s();!(c=r.n()).done;)i[(l=c.value).name]=l.value}catch(e){r.e(e)}finally{r.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(i,{async:!0,callback:function(e,t,n,o){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,n));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var n={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(n.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(n.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(n.found="action=mailpoet",n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(n.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(n.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(n.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(n.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(n.found="action=drplus_signup",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(n.found="action=bt_cc",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(n.found="action=wpr_form_builder_email",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(n.found="action=nf_ajax_submit",n.keepUnwrapped=!0,n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(n.found="action=uael_register_user",n.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(n.found="wc-ajax=add_to_cart"),!1!==n.found){var o="",a="",i="";if(+ctPublic.settings__data__bot_detector_enabled?(r=(new c).toolGetEventToken())&&(o=n.keepUnwrapped?"ct_bot_detector_event_token="+r+"&":"data%5Bct_bot_detector_event_token%5D="+r+"&"):(a=getNoCookieData(),a=n.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),n.attachVisibleFieldsData){var r=!1,n=ApbctVisibleFieldsExtractor.createExtractor(n.found);if("string"==typeof(r=n?n.extract(t.data):r))try{i="apbct_visible_fields="+encodeURIComponent(r)+"&"}catch(e){}}t.data=a+o+i+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var n;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,i=t.querySelector('[name*="apbct_email_id__"]'),r=null,c=(null!==i&&null!==i.value&&(r=i.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===c&&null===i&&null===l||(e.preventDefault(),n=function(){null!==i&&i.parentNode.removeChild(i),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=c,null!==r&&(o.apbct_search_form__honeypot_value=r),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var i=o.value,r=this.findParentContainer(i);if(r){var c=this.getIdFromHTML(r);if(c===n){var l=r.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,i,r,c,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(c=document.createElement("strong")).append(d.phrases.trpHeading),(i=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),i.setAttribute("style","white-space: nowrap"),(r=document.createElement("div")).append(c),r.append(" "),r.append(d.phrases.trpContent1),(c=document.createElement("div")).style.display="flex",c.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),c.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),c.append(l)),i.append(r,c),a.append(i),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===r[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===r[t].href||0!==r[t].href.indexOf("mailto:")&&0!==r[t].href.indexOf("tel:"))r[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r[t])},2e3);else{if(0===r[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==r[t].href.indexOf("tel:"))return 0;e="tel:"}var o=r[t].href.replace(e,""),a=r[t].innerHTML;r[t].innerHTML=a.replace(o,n.decoded_email),r[t].href=e+n.decoded_email,r[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}r[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];r.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,r)},2e3),r.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(r.innerHTML="Loading...",t&&this.load(t)),r.setAttribute("id","cleantalk-modal-content"),n.append(r),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;n{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,n=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function c(){_classCallCheck(this,c)}return _createClass(c,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.prev=10,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,n));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,r=t.querySelector('[name*="apbct_email_id__"]'),i=null,c=(null!==r&&null!==r.value&&(i=r.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===c&&null===r&&null===l||(e.preventDefault(),n=function(){null!==r&&r.parentNode.removeChild(r),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=c,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var r=o.value,i=this.findParentContainer(r);if(i){var c=this.getIdFromHTML(i);if(c===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,r,i,c,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(c=document.createElement("strong")).append(d.phrases.trpHeading),(r=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),r.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(c),i.append(" "),i.append(d.phrases.trpContent1),(c=document.createElement("div")).style.display="flex",c.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),c.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),c.append(l)),r.append(i,c),a.append(r),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/apbct-public-bundle_int-protection_gathering.min.js b/js/apbct-public-bundle_int-protection_gathering.min.js index e3e836533..1b759fb08 100644 --- a/js/apbct-public-bundle_int-protection_gathering.min.js +++ b/js/apbct-public-bundle_int-protection_gathering.min.js @@ -1 +1 @@ -function _regenerator(){var f,e="function"==typeof Symbol?Symbol:{},t=e.iterator||"@@iterator",n=e.toStringTag||"@@toStringTag";function o(e,t,n,o){var a,c,i,r,l,s,u,d,p,t=t&&t.prototype instanceof b?t:b,t=Object.create(t.prototype);return _regeneratorDefine2(t,"_invoke",(a=e,c=n,u=o||[],d=!1,p={p:s=0,n:0,v:f,a:_,f:_.bind(f,4),d:function(e,t){return i=e,r=0,l=f,p.n=t,m}},function(e,t,n){if(1t||c=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var o=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(o,n.decoded_email),c[t].href=e+n.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),n.append(c),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;nMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.p=2,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=4):e.n=4;break;case 3:return e.p=3,e.a(2,defaultFetch.apply(window,n));case 4:Array.from(document.forms).some(function(e){return e.classList.contains("wprm-user-ratings-modal-stars-container")})&&"function"==typeof n[0].includes&&n[0].includes("/wp-json/wp-recipe-maker/")?(e.p=5,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.n=7):e.n=7;break;case 6:return e.p=6,e.a(2,defaultFetch.apply(window,n));case 7:"function"==typeof n[0].includes&&n[0].includes("/wc/store/v1/cart/add-item")?(e.p=8,+ctPublic.settings__forms__wc_add_to_cart&&(n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled))),e.n=10):e.n=10;break;case 9:return e.p=9,e.a(2,defaultFetch.apply(window,n));case 10:if(!(+ctPublic.settings__forms__check_external&&"function"==typeof n[0].includes&&n[0].includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&n[1].body instanceof FormData)){e.n=11;break}a=document.querySelector(".b24-form form"),c={action:"cleantalk_force_ajax_check"},i=_createForOfIteratorHelper(a.elements);try{for(i.s();!(r=i.n()).done;)c[(l=r.value).name]=l.value}catch(e){i.e(e)}finally{i.f()}return e.n=11,new Promise(function(a,t){apbct_public_sendAJAX(c,{async:!0,callback:function(e,t,n,o){(void 0===e.apbct&&void 0===e.data||void 0!==e.apbct&&!+e.apbct.blocked)&&(p=!1),(void 0!==e.apbct&&+e.apbct.blocked||void 0!==e.data&&void 0!==e.data.message)&&(p=!0,(new ApbctShowForbidden).parseBlockMessage(e)),a(e)},onErrorCallback:function(e){console.log("AJAX error:",e),t(e)}})});case 11:if(p){e.n=12;break}return e.a(2,defaultFetch.apply(window,n));case 12:return e.a(2)}},e,null,[[8,9],[5,6],[2,3]])})))},1e3)}},{key:"catchJqueryAjax",value:function(){"undefined"!=typeof jQuery&&"function"==typeof jQuery.ajaxSetup&&jQuery.ajaxSetup({beforeSend:function(e,t){var n={found:!1,keepUnwrapped:!1,attachVisibleFieldsData:!1};if("string"==typeof t.data&&(-1!==t.data.indexOf("action=fl_builder_subscribe_form_submit")&&(n.found="fl_builder_subscribe_form_submit"),-1!==t.data.indexOf("twt_cc_signup")&&(n.found="twt_cc_signup"),-1!==t.data.indexOf("action=mailpoet")&&(n.found="action=mailpoet",n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=user_registration")&&-1!==t.data.indexOf("ur_frontend_form_nonce")&&(n.found="action=user_registration"),-1!==t.data.indexOf("action=happyforms_message")&&(n.found="action=happyforms_message"),-1!==t.data.indexOf("action=new_activity_comment")&&(n.found="action=new_activity_comment"),-1!==t.data.indexOf("action=wwlc_create_user")&&(n.found="action=wwlc_create_user"),-1!==t.data.indexOf("action=drplus_signup")&&(n.found="action=drplus_signup",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=bt_cc")&&(n.found="action=bt_cc",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=wpr_form_builder_email")&&(n.found="action=wpr_form_builder_email",n.keepUnwrapped=!0),-1!==t.data.indexOf("action=nf_ajax_submit")&&(n.found="action=nf_ajax_submit",n.keepUnwrapped=!0,n.attachVisibleFieldsData=!0),-1!==t.data.indexOf("action=uael_register_user"))&&"none"===ctPublic.data__cookies_type&&(n.found="action=uael_register_user",n.keepUnwrapped=!0),"string"==typeof t.url&&-1!==t.url.indexOf("wc-ajax=add_to_cart")&&(n.found="wc-ajax=add_to_cart"),!1!==n.found){var o="",a="",c="";if(+ctPublic.settings__data__bot_detector_enabled?(i=(new r).toolGetEventToken())&&(o=n.keepUnwrapped?"ct_bot_detector_event_token="+i+"&":"data%5Bct_bot_detector_event_token%5D="+i+"&"):(a=getNoCookieData(),a=n.keepUnwrapped?"ct_no_cookie_hidden_field="+a+"&":"data%5Bct_no_cookie_hidden_field%5D="+a+"&"),n.attachVisibleFieldsData){var i=!1,n=ApbctVisibleFieldsExtractor.createExtractor(n.found);if("string"==typeof(i=n?n.extract(t.data):i))try{c="apbct_visible_fields="+encodeURIComponent(i)+"&"}catch(e){}}t.data=a+o+c+t.data}}})}},{key:"catchWCRestRequestAsMiddleware",value:function(){window.hasOwnProperty("wp")&&window.wp.hasOwnProperty("apiFetch")&&"function"==typeof window.wp.apiFetch.use&&window.wp.apiFetch.use(function(e,t){var n;return"object"===_typeof(e)&&null!==e&&e.hasOwnProperty("data")&&void 0!==e.data&&e.hasOwnProperty("path")&&void 0!==e.path&&(e.data.hasOwnProperty("requests")&&0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),n=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var c=o.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var n,o=0;o_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var n=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){n.data.push(Object.assign({},n.fieldData))})}},{key:"setListeners",value:function(){var o=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){o.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){o.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,n){e.addEventListener("input",function(){o.data[n].countOfKey++;var e,t=+new Date;1===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].firstKeyTimestamp=t):(e=t-o.data[n].lastKeyTimestamp,2===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file +function ownKeys(t,e){var n,o=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)),o}function _objectSpread(t){for(var e=1;e=e.length?{done:!0}:{done:!1,value:e[c++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n{var n,e;if(i.data.forEach(function(e){e.encoded_email===c[t].dataset.originalString&&(n=e)}),!1===n.is_allowed)return{v:void 0};if(void 0===c[t].href||0!==c[t].href.indexOf("mailto:")&&0!==c[t].href.indexOf("tel:"))c[t].classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c[t])},2e3);else{if(0===c[t].href.indexOf("mailto:"))e="mailto:";else{if(0!==c[t].href.indexOf("tel:"))return 0;e="tel:"}var o=c[t].href.replace(e,""),a=c[t].innerHTML;c[t].innerHTML=a.replace(o,n.decoded_email),c[t].href=e+n.decoded_email,c[t].querySelectorAll("span.apbct-email-encoder").forEach(function(t){var n="";i.data.forEach(function(e){e.encoded_email===t.dataset.originalString&&(n=e.decoded_email)}),t.innerHTML=n})}c[t].removeEventListener("click",ctFillDecodedEmailHandler)})(t))&&e)return e.v}else{var n=i.data[0];c.classList.add("no-blur"),setTimeout(function(){ctProcessDecodedDataResult(n,c)},2e3),c.removeEventListener("click",ctFillDecodedEmailHandler)}}function ctProcessDecodedDataResult(e,t){t.setAttribute("title",""),t.removeAttribute("style"),ctFillDecodedEmail(t,e.decoded_email)}function ctFillDecodedEmail(e,t){e.innerHTML=e.innerHTML.replace(/.+?(
)/,t+"$1")}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelectorAll("[data-original-string]");if("undefined"!=typeof ctPublic&&(ctPublic.encodedEmailNodes=e),e.length)for(var t=0;t$1'):(c.innerHTML="Loading...",t&&this.load(t)),c.setAttribute("id","cleantalk-modal-content"),n.append(c),this.opened=!0},confirm:function(e){var t,n=1_createClass(function e(t){_classCallCheck(this,e),_defineProperty(this,"ajax_parameters",{}),_defineProperty(this,"restParameters",{}),_defineProperty(this,"selector",null),_defineProperty(this,"elements",[]),_defineProperty(this,"eventCallback",void 0),_defineProperty(this,"eventSelector",void 0),_defineProperty(this,"event",void 0),this.select(t)},[{key:"select",value:function(e){return e instanceof HTMLCollection?(this.selector=null,this.elements=[],this.elements=Array.prototype.slice.call(e)):"object"===_typeof(e)?(this.selector=null,this.elements=[],this.elements[0]=e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect(),this}},{key:"addElement",value:function(e){"object"===_typeof(e)?this.elements.push(e):"string"==typeof e?(this.selector=e,this.elements=Array.prototype.slice.call(document.querySelectorAll(e))):this.deselect()}},{key:"push",value:function(e){this.elements.push(e)}},{key:"reduce",value:function(){this.elements=this.elements.slice(0,-1)}},{key:"deselect",value:function(){this.elements=[]}},{key:"css",value:function(e,t){if(t=t||!1,"object"===_typeof(e)){for(var n in e)if(Object.hasOwn(e,n))for(var o=n.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")}),a=0;a(e=document.createElement(e).constructor,!Boolean(~[HTMLElement,HTMLUnknownElement].indexOf(e))))(t)?n||e.tagName.toLowerCase()===t.toLowerCase():t.match(/^[a-z]/)?n||Boolean(e[t]):n||(null!==this.selector?null!==document.querySelector(this.selector+t):this.isWithoutSelector(e,t)):n}},{key:"isWithoutSelector",value:function(e,t){var n,o=!1,a=_createForOfIteratorHelper(document.querySelectorAll(t));try{for(a.s();!(n=a.n()).done;)o=o||e===n.value}catch(e){a.e(e)}finally{a.f()}return o}},{key:"filter",value:function(e){this.selector=null;for(var t=this.elements.length-1;0<=t;t--)this.isElem(this.elements[t],e)||this.elements.splice(Number(t),1);return this}},{key:"parent",value:function(e){return this.select(this.elements[0].parentElement),void 0===e||this.is(e)||this.deselect(),this}},{key:"parents",value:function(e){for(this.select(this.elements[0]);null!==this.elements[this.elements.length-1].parentElement;)this.push(this.elements[this.elements.length-1].parentElement);return this.elements.splice(0,1),void 0!==e&&this.filter(e),this}},{key:"children",value:function(e){return this.select(this.elements[0].children),void 0!==e&&this.filter(e),this}},{key:"siblings",value:function(e){var t=this.elements[0];return this.parent(),this.children(e),this.elements.splice(this.elements.indexOf(t),1),this}},{key:"remove",value:function(){var e,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(e=t.n()).done;)e.value.remove()}catch(e){t.e(e)}finally{t.f()}}},{key:"after",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.after(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"append",value:function(e){var t,n=_createForOfIteratorHelper(this.elements);try{for(n.s();!(t=n.n()).done;)t.value.append(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"fadeIn",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity+(new Date-n)/o,n=+new Date,+t.style.opacity<1&&(window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16))}var t=a.value,n=(t.style.opacity=0,t.style.display="block",+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}},{key:"fadeOut",value:function(o){var a,t=_createForOfIteratorHelper(this.elements);try{for(t.s();!(a=t.n()).done;)(()=>{function e(){t.style.opacity=+t.style.opacity-(new Date-n)/o,n=+new Date,0<+t.style.opacity?window.requestAnimationFrame&&requestAnimationFrame(e)||setTimeout(e,16):t.style.display="none"}var t=a.value,n=(t.style.opacity=1,+new Date);e()})()}catch(e){t.e(e)}finally{t.f()}}}]))());function selectActualNonce(){var e="";return ctPublicFunctions.hasOwnProperty("_fresh_nonce")&&"string"==typeof ctPublicFunctions._fresh_nonce&&0{function o(e){for(var t in _classCallCheck(this,o),_defineProperty(this,"xhr",new XMLHttpRequest),_defineProperty(this,"method","POST"),_defineProperty(this,"url",""),_defineProperty(this,"async",!0),_defineProperty(this,"user",null),_defineProperty(this,"password",null),_defineProperty(this,"data",{}),_defineProperty(this,"button",null),_defineProperty(this,"spinner",null),_defineProperty(this,"progressbar",null),_defineProperty(this,"context",this),_defineProperty(this,"callback",null),_defineProperty(this,"onErrorCallback",null),_defineProperty(this,"responseType","json"),_defineProperty(this,"headers",{}),_defineProperty(this,"timeout",15e3),_defineProperty(this,"methods_to_convert_data_to_URL",["GET","HEAD"]),_defineProperty(this,"body",null),_defineProperty(this,"http_code",0),_defineProperty(this,"status_text",""),e)void 0!==this[t]&&(this[t]=e[t]);if(this.prepare(),Object.keys(this.data).length&&(this.deleteDoubleJSONEncoding(this.data),this.convertData()),!this.url)return console.log("%cXHR%c not URL provided","color: red; font-weight: bold;","color: grey; font-weight: normal;"),!1;this.xhr.open(this.method,this.url,this.async,this.user,this.password),this.setHeaders(),this.xhr.responseType=this.responseType,this.xhr.timeout=this.timeout,this.xhr.onreadystatechange=function(){this.isWpNonceError()?this.getFreshNonceAndRerunXHR(e):this.onReadyStateChange()}.bind(this),this.xhr.onload=function(){this.onLoad()}.bind(this),this.xhr.onprogress=function(e){this.onProgress(e)}.bind(this),this.xhr.onerror=function(){this.onError()}.bind(this),this.xhr.ontimeout=function(){this.onTimeout()}.bind(this),this.xhr.send(this.body)}return _createClass(o,[{key:"prepare",value:function(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.style.cursor="not-allowed"),this.spinner&&(this.spinner.style.display="inline")}},{key:"complete",value:function(){this.http_code=this.xhr.status,this.status_text=this.xhr.statusText,this.button&&(this.button.removeAttribute("disabled"),this.button.style.cursor="auto"),this.spinner&&(this.spinner.style.display="none"),this.progressbar&&this.progressbar.fadeOut("slow")}},{key:"onReadyStateChange",value:function(){null!==this.on_ready_state_change&&"function"==typeof this.on_ready_state_change&&this.on_ready_state_change()}},{key:"onProgress",value:function(e){null!==this.on_progress&&"function"==typeof this.on_progress&&this.on_progress()}},{key:"onError",value:function(){console.log("error"),this.complete(),this.error(this.http_code,this.status_text),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback(this.status_text)}},{key:"onTimeout",value:function(){this.complete(),this.error(0,"timeout"),null!==this.onErrorCallback&&"function"==typeof this.onErrorCallback&&this.onErrorCallback("Timeout")}},{key:"onLoad",value:function(){if(this.complete(),"json"===this.responseType){if(null===this.xhr.response)return this.error(this.http_code,this.status_text,"No response"),!1;if(void 0!==this.xhr.response.error)return this.error(this.http_code,this.status_text,this.xhr.response.error),!1}null!==this.callback&&"function"==typeof this.callback&&this.callback.call(this.context,this.xhr.response,this.data)}},{key:"isWpNonceError",value:function(){var e=!1,t=!1;return 4==this.xhr.readyState&&(e="object"===_typeof(this.xhr.response)&&null!==this.xhr.response&&this.xhr.response.hasOwnProperty("data")&&this.xhr.response.data.hasOwnProperty("status")&&403===this.xhr.response.data.status,t="-1"===this.xhr.response&&403===this.xhr.status),e||t}},{key:"getFreshNonceAndRerunXHR",value:function(e){var t,n="";e.hasOwnProperty("headers")&&e.headers.hasOwnProperty("X-WP-Nonce")&&(n=e.headers["X-WP-Nonce"]),""!==(n=e.hasOwnProperty("data")&&e.data.hasOwnProperty("_ajax_nonce")?e.data._ajax_nonce:n)&&((t={method:"POST"}).data={spbc_remote_call_action:"get_fresh_wpnonce",plugin_name:"antispam",nonce_prev:n,initial_request_params:e},t.notJson=!0,t.url=ctPublicFunctions.host_url,t.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n{function o(){for(var e=arguments.length,t=new Array(e),n=0;n{function a(){for(var e=arguments.length,t=new Array(e),n=0;n{return _createClass(function e(){_classCallCheck(this,e),this.config=ApbctShadowRootConfig},[{key:"findMatchingConfig",value:function(e){for(var t=0,n=Object.entries(this.config);tMath.floor((new Date).getTime()/1e3)},isSet:function(e){return null!==localStorage.getItem(e)},delete:function(e){localStorage.removeItem(e)},getCleanTalkData:function(){for(var e={},t=0;t_createClass(function e(){_classCallCheck(this,e)},[{key:"attachEventTokenToMultipageGravityForms",value:function(){document.addEventListener("gform_page_loaded",function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||"function"!=typeof setEventTokenField||"function"!=typeof botDetectorLocalStorage||setEventTokenField(botDetectorLocalStorage.get("bot_detector_event_token"))})}},{key:"attachEventTokenToWoocommerceGetRequestAddToCart",value:function(){ctPublic.wc_ajax_add_to_cart||document.querySelectorAll("a.add_to_cart_button:not(.product_type_variable):not(.wc-interactive)").forEach(function(o){o.addEventListener("click",function(e){var t=o.getAttribute("href"),n=apbctLocalStorage.get("bot_detector_event_token");n&&(-1===t.indexOf("?")?t+="?":t+="&",o.setAttribute("href",t+="ct_bot_detector_event_token="+n))})})}},{key:"restartBotDetectorEventTokenAttach",value:function(){var e,t=0_createClass(function e(){_classCallCheck(this,e)},[{key:"attachHiddenFieldsToForms",value:function(){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.settings__data__bot_detector_enabled||(ctNoCookieAttachHiddenFieldsToForms(),document.addEventListener("gform_page_loaded",ctNoCookieAttachHiddenFieldsToForms))}},{key:"attachVisibleFieldsToForm",value:function(e,t){var n=document.createElement("input"),t=(n.setAttribute("type","hidden"),n.setAttribute("id","apbct_visible_fields_"+t),n.setAttribute("name","apbct_visible_fields"),{});t[0]=this.collectVisibleFields(e),n.value=btoa(JSON.stringify(t)),e.append(n)}},{key:"attachVisibleFieldsDuringSubmit",value:function(e,t){"native"!==ctPublic.data__cookies_type&&void 0!==e.target.ctFormIndex&&this.setVisibleFieldsCookie(this.collectVisibleFields(t),e.target.ctFormIndex)}},{key:"constructNoCookieHiddenField",value:function(e){var t="hidden",e=("submit"===e&&(t="submit"),""),n=getCleanTalkStorageDataArray(),n=JSON.stringify(n);return n="_ct_no_cookie_data_"+btoa(n),(e=document.createElement("input")).setAttribute("name","ct_no_cookie_hidden_field"),e.setAttribute("value",n),e.setAttribute("type",t),e.classList.add("apbct_special_field"),e.classList.add("ct_no_cookie_hidden_field"),e}},{key:"attachNoCookieDuringSubmit",value:function(e){"none"===ctPublic.data__cookies_type&&e.target&&e.target.action&&-1!==e.target.action.toString().indexOf("mailpoet_subscription_form")&&(window.XMLHttpRequest.prototype.send=function(e){var t,n;+ctPublic.settings__data__bot_detector_enabled?(t=(new ApbctHandler).toolGetEventToken())&&(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+("data%5Bct_bot_detector_event_token%5D="+t+"&")+e)):(n="data%5Bct_no_cookie_hidden_field%5D="+getNoCookieData()+"&",defaultSend.call(this,n+e)),setTimeout(function(){window.XMLHttpRequest.prototype.send=defaultSend},0)})}},{key:"setVisibleFieldsCookie",value:function(e,t){var n="object"===_typeof(e)&&null!==e?e:{};if("native"===ctPublic.data__cookies_type)for(var o in n){if(10{function r(){_classCallCheck(this,r)}return _createClass(r,[{key:"excludeForm",value:function(e){return!!this.checkHiddenFieldsExclusions(e,"visible_fields")||!!(e.querySelector('input[name="wspsc_add_cart_submit"]')||e.querySelector('input[name="option"][value="com_vikrentcar"]')||e.querySelector('input[name="option"][value="com_vikbooking"]'))||void 0!==e.elements.apbct_visible_fields&&0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){return defaultFetch.apply(window,n)}})())?(e.prev=10,n[1].body=d(n[1].body,u(+ctPublic.settings__data__bot_detector_enabled)),e.next=17):e.next=17;break;case 14:return e.prev=14,e.t0=e.catch(10),e.abrupt("return",defaultFetch.apply(window,n));case 17:0{var t=e.value;"undefined"!=typeof ctPublic&&1==+ctPublic.settings__forms__search_test&&null!==t.getAttribute("apbct-form-sign")&&"native_search"===t.getAttribute("apbct-form-sign")&&(t.apbctSearchPrevOnsubmit=t.onsubmit,t.onsubmit=function(e){return n.searchFormHandler(e,t)})})()}catch(e){t.e(e)}finally{t.f()}}},{key:"searchFormHandler",value:function(e,t){try{var n,o,a,c=t.querySelector('[name*="apbct_email_id__"]'),i=null,r=(null!==c&&null!==c.value&&(i=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===r&&null===c&&null===l||(e.preventDefault(),n=function(){null!==c&&c.parentNode.removeChild(c),"function"==typeof t.apbctSearchPrevOnsubmit?t.apbctSearchPrevOnsubmit():HTMLFormElement.prototype.submit.call(t)},o=r,null!==i&&(o.apbct_search_form__honeypot_value=i),o.ct_bot_detector_event_token=l,"string"==typeof o.apbct_pixel_url&&-1!==o.apbct_pixel_url.indexOf("%3A")&&(o.apbct_pixel_url=decodeURIComponent(o.apbct_pixel_url)),void 0!==(a=JSON.stringify(o))&&0!==a.length?ctSetAlternativeCookie(a,{callback:n,onErrorCallback:n,forceAltCookies:!0}):n())}catch(e){console.warn("APBCT search form onsubmit handler error. "+e)}}},{key:"toolForAntiCrawlerCheckDuringBotDetector",value:function(){var e=setInterval(function(){localStorage.bot_detector_event_token&&(ctSetCookie("apbct_bot_detector_exist","1","3600"),clearInterval(e))},500)}},{key:"toolGetEventToken",value:function(){var t=localStorage.getItem("bot_detector_event_token");try{t=JSON.parse(t)}catch(e){t=!1}return!(null===t||!1===t||!t.hasOwnProperty("value")||""===t.value)&&t.value}}])})(),ApbctShowForbidden=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"prepareBlockForAjaxForms",value:function(){var o=function(e){if(e.responseText&&-1!==e.responseText.indexOf('"apbct')&&-1===e.responseText.indexOf("DOCTYPE"))try{this.parseBlockMessage(JSON.parse(e.responseText))}catch(e){console.log(e.toString())}}.bind(this);"undefined"!=typeof jQuery?"function"!=typeof jQuery(document).ajaxComplete()?jQuery(document).on("ajaxComplete",function(e,t,n){o(t)}):jQuery(document).ajaxComplete(function(e,t,n){o(t)}):"undefined"!=typeof XMLHttpRequest&&document.addEventListener("readystatechange",function(e){4===e.target.readyState&&o(e.target)})}},{key:"parseBlockMessage",value:function(e){var t="";void 0!==e.apbct&&(e=e.apbct).blocked&&(t=e.comment),(t=void 0!==e.data&&void 0!==(e=e.data).message?e.message:t)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:t}})),cleantalkModal.loaded=t,cleantalkModal.open(),1==+e.stop_script)&&(window.stop(),e.integration)&&"NEXForms"===e.integration&&((t=document.querySelector("form.submit-nex-form button.nex-submit"))&&(t.disabled=!0,t.style.opacity="0.5",t.style.cursor="not-allowed",t.style.pointerEvents="none",t.style.backgroundColor="#ccc",t.style.color="#fff"),e=document.querySelector("div.nex_success_message"))&&(e.style.display="none")}}]))(),ApbctVisibleFieldsExtractor=(()=>_createClass(function e(){_classCallCheck(this,e)},[{key:"extract",value:function(e){if(e&&"string"==typeof e){try{e=decodeURIComponent(e)}catch(e){return!1}var t=document.querySelectorAll("form"),n=this.getIdFromAjax(e);if(n){var o,a=_createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var c=o.value,i=this.findParentContainer(c);if(i){var r=this.getIdFromHTML(i);if(r===n){var l=i.querySelector("input[id^=apbct_visible_fields_]");if(null!=l&&l.value)return l.value}}}}catch(e){a.e(e)}finally{a.f()}}}return!1}},{key:"getIdFromAjax",value:function(e){return console.warn("getIdFromAjax must be implemented by child class"),null}},{key:"findParentContainer",value:function(e){return console.warn("findParentContainer must be implemented by child class"),null}},{key:"getIdFromHTML",value:function(e){return console.warn("getIdFromHTML must be implemented by child class"),null}}],[{key:"createExtractor",value:function(e){switch(e){case"action=nf_ajax_submit":return new ApbctNinjaFormsVisibleFields;case"action=mailpoet":return new ApbctMailpoetVisibleFields;default:return null}}}]))(),ApbctNinjaFormsVisibleFields=(()=>{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/"id"\s*:\s*"?(\d+)"/,/form_id\s*[:\s]*"?(\d+)"/,/nf-form-(\d+)/,/"id":(\d+)/];t{function e(){return _classCallCheck(this,e),_callSuper(this,e,arguments)}return _inherits(e,ApbctVisibleFieldsExtractor),_createClass(e,[{key:"getIdFromAjax",value:function(e){for(var t=0,n=[/form_id\s*[:\s]*"?(\d+)"/,/data\[form_id\]=(\d+)/,/form_id=(\d+)/];t_createClass(function e(){_classCallCheck(this,e)},[{key:"setSessionId",value:function(){var e;apbctSessionStorage.isSet("apbct_session_id")?apbctLocalStorage.set("apbct_page_hits",Number(apbctLocalStorage.get("apbct_page_hits"))+1):(e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),apbctSessionStorage.set("apbct_session_id",e,!1),apbctLocalStorage.set("apbct_page_hits",1),document.referrer&&new URL(document.referrer).host!==location.host&&apbctSessionStorage.set("apbct_site_referer",document.referrer,!1))}},{key:"writeReferrersToSessionStorage",value:function(){var e=apbctSessionStorage.get("apbct_session_current_page");!1!==e&&document.location.href!==e&&apbctSessionStorage.set("apbct_prev_referer",e,!1),apbctSessionStorage.set("apbct_session_current_page",document.location.href,!1)}},{key:"setCookiesType",value:function(){var e=apbctLocalStorage.get("ct_cookies_type");e&&e===ctPublic.data__cookies_type||(apbctLocalStorage.set("ct_cookies_type",ctPublic.data__cookies_type),apbctLocalStorage.delete("ct_mouse_moved"),apbctLocalStorage.delete("ct_has_scrolled"))}},{key:"startFieldsListening",value:function(){if(!apbctLocalStorage.isSet("ct_has_key_up")&&!apbctLocalStorage.get("ct_has_key_up")||!apbctLocalStorage.isSet("ct_has_input_focused")&&!apbctLocalStorage.get("ct_has_input_focused")||"native"!==ctPublic.data__cookies_type||void 0===ctGetCookie("ct_has_input_focused")||void 0===ctGetCookie("ct_has_key_up")){var e=ctGetPageForms();if(ctPublic.handled_fields=[],0_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"elementBody",document.querySelector("body")),_defineProperty(this,"collectionForms",document.forms),this.setListeners()},[{key:"setListeners",value:function(){var t=this;this.elementBody.addEventListener("click",function(e){t.checkElementInForms(e,"addClicks")}),this.elementBody.addEventListener("mouseup",function(e){"Range"==document.getSelection().type.toString()&&t.addSelected()}),this.elementBody.addEventListener("mousemove",function(e){t.checkElementInForms(e,"trackMouseMovement")})}},{key:"checkElementInForms",value:function(e,t){for(var n,o=0;o_createClass(function e(){_classCallCheck(this,e),_defineProperty(this,"fieldData",{isAutoFill:!1,isUseBuffer:!1,speedDelta:0,firstKeyTimestamp:0,lastKeyTimestamp:0,lastDelta:0,countOfKey:0}),_defineProperty(this,"fields",document.querySelectorAll("textarea[name=comment]")),_defineProperty(this,"data",[])},[{key:"gatheringFields",value:function(){var n=this;Array.prototype.slice.call(this.fields).forEach(function(e,t){n.data.push(Object.assign({},n.fieldData))})}},{key:"setListeners",value:function(){var o=this;this.fields.forEach(function(e,t){e.addEventListener("paste",function(){o.data[t].isUseBuffer=!0})}),this.fields.forEach(function(e,t){e.addEventListener("onautocomplete",function(){o.data[t].isAutoFill=!0})}),this.fields.forEach(function(e,n){e.addEventListener("input",function(){o.data[n].countOfKey++;var e,t=+new Date;1===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].firstKeyTimestamp=t):(e=t-o.data[n].lastKeyTimestamp,2===o.data[n].countOfKey?(o.data[n].lastKeyTimestamp=t,o.data[n].lastDelta=e):2 .comment-body *[class*="comment-author"]',document.querySelector(".apbct-trp .comment-author .comment-author-link")&&(e='.apbct-trp *[class*="comment-author-link"]'),0!==(e=document.querySelectorAll(e+',.apbct-trp > .wp-block-group *[class*="comment-author"],.apbct-trp *[class*="review__author"],.apbct-trp td[class*="column-author"] > strong')).length)&&(e.forEach(function(e,t){var n,o,a,c,i,r,l,s,u;e.className.indexOf("review")<0&&"undefined"==typeof pagenow&&e.parentElement.className.indexOf("group")<0&&"DIV"!=e.tagName||e.querySelector(".comment-metadata")||((n=document.createElement("div")).setAttribute("class","apbct-real-user-badge"),(o=document.createElement("img")).setAttribute("src",d.imgPersonUrl),o.setAttribute("class","apbct-real-user-popup-img"),(a=document.createElement("div")).setAttribute("class","apbct-real-user-popup"),(r=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),c.setAttribute("style","white-space: nowrap"),(i=document.createElement("div")).append(r),i.append(" "),i.append(d.phrases.trpContent1),(r=document.createElement("div")).style.display="flex",r.style.gap="5px",(l=document.createElement("div")).append(d.phrases.trpContent2),r.append(l),p&&(l=document.createElement("div"),(s=document.createElement("a")).setAttribute("href",d.trpContentLink),s.setAttribute("target","_blank"),(u=document.createElement("img")).setAttribute("src",ctAdminCommon.new_window_gif),u.setAttribute("alt","New window"),u.setAttribute("style","padding-top:3px"),s.append(u),l.append(s),r.append(l)),c.append(i,r),a.append(c),n.append(o),e.append(n),e.append(a))}),document.querySelectorAll(".apbct-real-user-badge").forEach(function(o){var a=void 0,e=(t.body.addEventListener("click",function(e){-1==e.target.className.indexOf("apbct-real-user")&&-1==e.target.parentElement.className.indexOf("apbct-real-user")&&closeAllPopupTRP()}),o.addEventListener("click",function(){var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.toggle("visible")}),o.addEventListener("mouseenter",function(){closeAllPopupTRP();var e=this.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.add("visible")}),o.addEventListener("mouseleave",function(){var t=this;a=setTimeout(function(){var e=t.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.nextElementSibling);e.addEventListener("mouseenter",function(){clearTimeout(a),e.classList.add("visible")}),e.addEventListener("mouseleave",function(){a=setTimeout(function(){e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},1e3)}),o.addEventListener("touchend",function(){var n=this;a=setTimeout(function(){var e=n.nextElementSibling,t=window.getSelection();e&&t&&e.classList.contains("apbct-real-user-popup")&&0===t.toString().length?e.classList.remove("visible"):(clearTimeout(a),document.addEventListener("selectionchange",function e(){var t=window.getSelection();t&&0===t.toString().length&&(a=setTimeout(function(){var e=o.nextElementSibling;e&&e.classList.contains("apbct-real-user-popup")&&e.classList.remove("visible")},3e3),document.removeEventListener("selectionchange",e))}))},3e3)})}))}); \ No newline at end of file diff --git a/js/prebuild/apbct-public-bundle.js b/js/prebuild/apbct-public-bundle.js index adbdd32e4..8582320c7 100644 --- a/js/prebuild/apbct-public-bundle.js +++ b/js/prebuild/apbct-public-bundle.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/prebuild/apbct-public-bundle_ext-protection.js b/js/prebuild/apbct-public-bundle_ext-protection.js index f156ffaf7..d1e037fc9 100644 --- a/js/prebuild/apbct-public-bundle_ext-protection.js +++ b/js/prebuild/apbct-public-bundle_ext-protection.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/prebuild/apbct-public-bundle_ext-protection_gathering.js b/js/prebuild/apbct-public-bundle_ext-protection_gathering.js index 9f3d2e684..d4bce6f76 100644 --- a/js/prebuild/apbct-public-bundle_ext-protection_gathering.js +++ b/js/prebuild/apbct-public-bundle_ext-protection_gathering.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/prebuild/apbct-public-bundle_full-protection.js b/js/prebuild/apbct-public-bundle_full-protection.js index 98c8e7aa7..31d41c678 100644 --- a/js/prebuild/apbct-public-bundle_full-protection.js +++ b/js/prebuild/apbct-public-bundle_full-protection.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/prebuild/apbct-public-bundle_full-protection_gathering.js b/js/prebuild/apbct-public-bundle_full-protection_gathering.js index b2275dac4..161f2228d 100644 --- a/js/prebuild/apbct-public-bundle_full-protection_gathering.js +++ b/js/prebuild/apbct-public-bundle_full-protection_gathering.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/prebuild/apbct-public-bundle_gathering.js b/js/prebuild/apbct-public-bundle_gathering.js index c88ed83b9..c3d72fc09 100644 --- a/js/prebuild/apbct-public-bundle_gathering.js +++ b/js/prebuild/apbct-public-bundle_gathering.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/prebuild/apbct-public-bundle_int-protection.js b/js/prebuild/apbct-public-bundle_int-protection.js index 59afe43c1..99cf91d2f 100644 --- a/js/prebuild/apbct-public-bundle_int-protection.js +++ b/js/prebuild/apbct-public-bundle_int-protection.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/prebuild/apbct-public-bundle_int-protection_gathering.js b/js/prebuild/apbct-public-bundle_int-protection_gathering.js index 7a7495483..dda3b581c 100644 --- a/js/prebuild/apbct-public-bundle_int-protection_gathering.js +++ b/js/prebuild/apbct-public-bundle_int-protection_gathering.js @@ -1806,6 +1806,184 @@ if (!Object.prototype.hasOwn) { }); } +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} /** * Set init params */ @@ -2993,209 +3171,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js b/js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js new file mode 100644 index 000000000..7ab87608d --- /dev/null +++ b/js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js @@ -0,0 +1,29 @@ +/** + * Callbacks for ShadowRoot integrations + */ +const ApbctShadowRootCallbacks = { + /** + * Mailchimp block callback - clears localStorage by mcforms mask + * @param {object} result + */ + mailchimpBlock: function(result) { + try { + for (let i = localStorage.length - 1; i >= 0; i--) { + const key = localStorage.key(i); + if (key && key.indexOf('mcforms') !== -1) { + localStorage.removeItem(key); + } + } + } catch (e) { + console.warn('Error clearing localStorage by mcforms mask:', e); + } + }, + + // /** + // * Next integration block callback + // * @param {object} result + // */ + // nextIntegrationBlock: function(result) { + // // Custom logic + // }, +}; \ No newline at end of file diff --git a/js/src/ShadowrootProtection/ApbctShadowRootConfig.js b/js/src/ShadowrootProtection/ApbctShadowRootConfig.js new file mode 100644 index 000000000..4155a2f90 --- /dev/null +++ b/js/src/ShadowrootProtection/ApbctShadowRootConfig.js @@ -0,0 +1,13 @@ +/** + * Config for ShadowRoot integrations + */ +const ApbctShadowRootConfig = { + 'mailchimp': { + selector: '.mcforms-wrapper', + urlPattern: 'mcf-integrations-mcmktg.mlchmpcompprduse2.iks2.a.intuit.com/gateway/receive', + externalForm: true, + action: 'cleantalk_force_mailchimp_shadowroot_check', + callbackAllow: false, + callbackBlock: ApbctShadowRootCallbacks.mailchimpBlock, + }, +}; \ No newline at end of file diff --git a/js/src/ShadowrootProtection/ApbctShadowRootProtection.js b/js/src/ShadowrootProtection/ApbctShadowRootProtection.js new file mode 100644 index 000000000..c42b9c18b --- /dev/null +++ b/js/src/ShadowrootProtection/ApbctShadowRootProtection.js @@ -0,0 +1,136 @@ +/** + * Class for handling ShadowRoot forms + */ +class ApbctShadowRootProtection { + constructor() { + this.config = ApbctShadowRootConfig; + } + + /** + * Find matching config for URL + * @param {string} url + * @return {object|null} { formKey, config } or null + */ + findMatchingConfig(url) { + for (const [formKey, config] of Object.entries(this.config)) { + // Shadowroot can send both external and internal requests + // If the form is external, then we check whether the setting is enabled. + if ( + (!config.externalForm || +ctPublic.settings__forms__check_external) && + document.querySelectorAll(config.selector).length > 0 && + url && url.includes(config.urlPattern) + ) { + return {formKey, config}; + } + } + return null; + } + + /** + * Check ShadowRoot form request via CleanTalk AJAX + * @param {string} formKey + * @param {object} config + * @param {string} bodyText + * @return {Promise} true = block, false = allow + */ + async checkRequest(formKey, config, bodyText) { + return new Promise((resolve) => { + let data = { + action: config.action, + }; + + try { + const bodyObj = JSON.parse(bodyText); + for (const [key, value] of Object.entries(bodyObj)) { + data[key] = value; + } + } catch (e) { + data.raw_body = bodyText; + } + + if (+ctPublic.settings__data__bot_detector_enabled) { + const eventToken = new ApbctHandler().toolGetEventToken(); + if (eventToken) { + data.ct_bot_detector_event_token = eventToken; + } + } else { + data.ct_no_cookie_hidden_field = getNoCookieData(); + } + + apbct_public_sendAJAX(data, { + async: true, + callback: (result) => { + // Allowed + if ( + (result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && !+result.apbct.blocked) + ) { + if (typeof config.callbackAllow === 'function') { + config.callbackAllow(result); + } + resolve(false); + return; + } + + // Blocked + if ( + (result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + new ApbctShowForbidden().parseBlockMessage(result); + if (typeof config.callbackBlock === 'function') { + config.callbackBlock(result); + } + resolve(true); + return; + } + + resolve(false); + }, + onErrorCallback: (error) => { + console.log('APBCT ShadowRoot check error:', error); + resolve(false); + }, + }); + }); + } + + /** + * Extract body text from fetch args + * @param {array} args + * @return {string} + */ + extractBodyText(args) { + let body = args[1] && args[1].body; + let bodyText = ''; + + if (body instanceof FormData) { + let obj = {}; + for (let [key, value] of body.entries()) { + obj[key] = value; + } + bodyText = JSON.stringify(obj); + } else if (typeof body === 'string') { + bodyText = body; + } + + return bodyText; + } + + /** + * Process fetch request for ShadowRoot forms + * @param {array} args - fetch arguments + * @return {Promise} true = block, false = allow, null = not matched + */ + async processFetch(args) { + const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || ''); + const match = this.findMatchingConfig(url); + + if (!match) { + return null; + } + + const bodyText = this.extractBodyText(args); + return await this.checkRequest(match.formKey, match.config, bodyText); + } +} \ No newline at end of file diff --git a/js/src/public-1-main.js b/js/src/public-1-main.js index 9071f2bb6..a331c7f2b 100644 --- a/js/src/public-1-main.js +++ b/js/src/public-1-main.js @@ -651,209 +651,187 @@ class ApbctHandler { * @return {void} */ catchFetchRequest() { - setTimeout(function() { - if ( - ( - document.forms && document.forms.length > 0 && - ( - Array.from(document.forms).some((form) => - form.classList.contains('metform-form-content')) || - Array.from(document.forms).some((form) => - form.classList.contains('wprm-user-ratings-modal-stars-container')) || - Array.from(document.forms).some((form) => { - if (form.parentElement && - form.parentElement.classList.length > 0 && - form.parentElement.classList[0].indexOf('b24-form-content') !== -1 - ) { - return true; - } - }) - ) - ) || - ( - document.querySelectorAll('button').length > 0 && - Array.from(document.querySelectorAll('button')).some((button) => { - return button.classList.contains('add_to_cart_button') || - button.classList.contains('ajax_add_to_cart') || - button.classList.contains('single_add_to_cart_button'); - }) - ) || - ( - document.links && document.links.length > 0 && - Array.from(document.links).some((link) => { - return link.classList.contains('add_to_cart_button'); - }) - ) - ) { - /** - * Select key/value pair depending on botDetectorEnabled flag - * @param {bool} botDetectorEnabled - * @return {{key: string, value: string}|false} False on empty gained data. - */ - const selectFieldsData = function(botDetectorEnabled) { - const result = { - 'key': null, - 'value': null, - }; - if (botDetectorEnabled) { - result.key = 'ct_bot_detector_event_token'; - result.value = apbctLocalStorage.get('bot_detector_event_token'); - } else { - result.key = 'ct_no_cookie_hidden_field'; - result.value = getNoCookieData(); - }; - return result.key && result.value ? result : false; - }; + const shadowRootProtection = new ApbctShadowRootProtection(); + let preventOriginalFetch = false; - /** - * - * @param {string} body Fetch request data body. - * @param {object|bool} fieldPair Key value to inject. - * @return {string} Modified body. - */ - const attachFieldsToBody = function(body, fieldPair = false) { - if (fieldPair) { - if (body instanceof FormData || typeof body.append === 'function') { - body.append(fieldPair.key, fieldPair.value); - } else { - let bodyObj = JSON.parse(body); - if (!bodyObj.hasOwnProperty(fieldPair.key)) { - bodyObj[fieldPair.key] = fieldPair.value; - body = JSON.stringify(bodyObj); - } - } + /** + * Select key/value pair depending on botDetectorEnabled flag + * @param {bool} botDetectorEnabled + * @return {{key: string, value: string}|false} False on empty gained data. + */ + const selectFieldsData = function(botDetectorEnabled) { + const result = { + 'key': null, + 'value': null, + }; + if (botDetectorEnabled) { + result.key = 'ct_bot_detector_event_token'; + result.value = apbctLocalStorage.get('bot_detector_event_token'); + } else { + result.key = 'ct_no_cookie_hidden_field'; + result.value = getNoCookieData(); + }; + return result.key && result.value ? result : false; + }; + + /** + * + * @param {string} body Fetch request data body. + * @param {object|bool} fieldPair Key value to inject. + * @return {string} Modified body. + */ + const attachFieldsToBody = function(body, fieldPair = false) { + if (fieldPair) { + if (body instanceof FormData || typeof body.append === 'function') { + body.append(fieldPair.key, fieldPair.value); + } else { + let bodyObj = JSON.parse(body); + if (!bodyObj.hasOwnProperty(fieldPair.key)) { + bodyObj[fieldPair.key] = fieldPair.value; + body = JSON.stringify(bodyObj); } - return body; - }; + } + } + return body; + }; - let preventOriginalFetch = false; + window.fetch = async function(...args) { + // Reset flag for each new request + preventOriginalFetch = false; - window.fetch = async function(...args) { - // if no data set provided - exit - if ( - !args || - !args[0] || - !args[1] || - !args[1].body - ) { - return defaultFetch.apply(window, args); - } + // if no data set provided - exit + if ( + !args || + !args[0] || + !args[1] || + !args[1].body + ) { + return defaultFetch.apply(window, args); + } - // Metform block - if ( - Array.from(document.forms).some((form) => form.classList.contains('metform-form-content')) && - typeof args[0].includes === 'function' && - (args[0].includes('/wp-json/metform/') || - (ctPublicFunctions._rest_url && (() => { - try { - return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); - } catch (e) { - return defaultFetch.apply(window, args); - } - })()) - ) - ) { - try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } catch (e) { - return defaultFetch.apply(window, args); - } - } + // === ShadowRoot forms === + const shadowRootResult = await shadowRootProtection.processFetch(args); + if (shadowRootResult === true) { + // Return a "blank" response that never completes + return new Promise(() => {}); + } - // WP Recipe Maker block - if ( - Array.from(document.forms).some( - (form) => form.classList.contains('wprm-user-ratings-modal-stars-container'), - ) && - typeof args[0].includes === 'function' && - args[0].includes('/wp-json/wp-recipe-maker/') - ) { + // === Metform === + if ( + document.querySelectorAll('form.metform-form-content').length > 0 && + typeof args[0].includes === 'function' && + (args[0].includes('/wp-json/metform/') || + (ctPublicFunctions._rest_url && (() => { try { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); + return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/'); } catch (e) { return defaultFetch.apply(window, args); } - } + })()) + ) + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // WooCommerce add to cart request, like: - // /index.php?rest_route=/wc/store/v1/cart/add-item + // === WP Recipe Maker === + if ( + document.querySelectorAll('form.wprm-user-ratings-modal-stars-container').length > 0 && + typeof args[0].includes === 'function' && + args[0].includes('/wp-json/wp-recipe-maker/') + ) { + try { + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); + } catch (e) { + return defaultFetch.apply(window, args); + } + } + + // === WooCommerce add to cart === + if ( + ( + document.querySelectorAll( + 'button.add_to_cart_button, button.ajax_add_to_cart, button.single_add_to_cart_button', + ).length > 0 || + document.querySelectorAll('a.add_to_cart_button').length > 0 + ) && + args[0].includes('/wc/store/v1/cart/add-item') + ) { + try { if ( - typeof args[0].includes === 'function' && - args[0].includes('/wc/store/v1/cart/add-item') + +ctPublic.settings__forms__wc_add_to_cart ) { - try { - if ( - +ctPublic.settings__forms__wc_add_to_cart - ) { - args[1].body = attachFieldsToBody( - args[1].body, - selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), - ); - } - } catch (e) { - return defaultFetch.apply(window, args); - } + args[1].body = attachFieldsToBody( + args[1].body, + selectFieldsData(+ctPublic.settings__data__bot_detector_enabled), + ); } + } catch (e) { + return defaultFetch.apply(window, args); + } + } - // bitrix24 EXTERNAL form - if (+ctPublic.settings__forms__check_external && - typeof args[0].includes === 'function' && - args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && - args[1].body instanceof FormData - ) { - const currentTargetForm = document.querySelector('.b24-form form'); - let data = { - action: 'cleantalk_force_ajax_check', - }; - for (const field of currentTargetForm.elements) { - data[field.name] = field.value; - } + // === Bitrix24 external form === + if ( + +ctPublic.settings__forms__check_external && + document.querySelectorAll('.b24-form').length > 0 && + args[0].includes('bitrix/services/main/ajax.php?action=crm.site.form.fill') && + args[1].body instanceof FormData + ) { + const currentTargetForm = document.querySelector('.b24-form form'); + let data = { + action: 'cleantalk_force_ajax_check', + }; + for (const field of currentTargetForm.elements) { + data[field.name] = field.value; + } - // check form request - wrap in Promise to wait for completion - await new Promise((resolve, reject) => { - apbct_public_sendAJAX( - data, - { - async: true, - callback: function( result, data, params, obj ) { - // allowed - if ((result.apbct === undefined && result.data === undefined) || - (result.apbct !== undefined && ! +result.apbct.blocked) - ) { - preventOriginalFetch = false; - } - - // blocked - if ((result.apbct !== undefined && +result.apbct.blocked) || - (result.data !== undefined && result.data.message !== undefined) - ) { - preventOriginalFetch = true; - new ApbctShowForbidden().parseBlockMessage(result); - } - - resolve(result); - }, - onErrorCallback: function( error ) { - console.log('AJAX error:', error); - reject(error); - }, - }, - ); - }); - } + // check form request - wrap in Promise to wait for completion + await new Promise((resolve, reject) => { + apbct_public_sendAJAX( + data, + { + async: true, + callback: function( result, data, params, obj ) { + // allowed + if ((result.apbct === undefined && result.data === undefined) || + (result.apbct !== undefined && ! +result.apbct.blocked) + ) { + preventOriginalFetch = false; + } - if (!preventOriginalFetch) { - return defaultFetch.apply(window, args); - } - }; + // blocked + if ((result.apbct !== undefined && +result.apbct.blocked) || + (result.data !== undefined && result.data.message !== undefined) + ) { + preventOriginalFetch = true; + new ApbctShowForbidden().parseBlockMessage(result); + } + + resolve(result); + }, + onErrorCallback: function( error ) { + console.log('AJAX error:', error); + reject(error); + }, + }, + ); + }); } - }, 1000); + + if (!preventOriginalFetch) { + return defaultFetch.apply(window, args); + } + }; } /** diff --git a/lib/Cleantalk/Antispam/Integrations/MailChimpShadowRoot.php b/lib/Cleantalk/Antispam/Integrations/MailChimpShadowRoot.php new file mode 100644 index 000000000..6d0bb6a82 --- /dev/null +++ b/lib/Cleantalk/Antispam/Integrations/MailChimpShadowRoot.php @@ -0,0 +1,74 @@ +stats['no_cookie_data_taken']) { + apbct_form__get_no_cookie_data(); + } + + $input_array = apply_filters('apbct__filter_post', $_POST); + + $data = ct_gfa_dto($input_array)->getArray(); + + // Clean message field - keep only keys containing "message", remove everything else + if (isset($data['message']) && is_array($data['message'])) { + $filtered_message = array(); + foreach ($data['message'] as $key => $value) { + if (stripos($key, 'message') !== false) { + $filtered_message[$key] = $value; + } + } + $data['message'] = !empty($filtered_message) ? implode(' ', $filtered_message) : ''; + } + + return $data; + } + + return null; + } + + public function doBlock($message) + { + die( + json_encode( + array( + 'apbct' => array( + 'blocked' => true, + 'comment' => $message, + 'stop_script' => apbct__stop_script_after_ajax_checking() + ) + ) + ) + ); + } + + /** + * Allow the request to proceed + * @return void + */ + public function allow() + { + die( + json_encode( + array( + 'apbct' => array( + 'blocked' => false, + 'allow' => true, + ) + ) + ) + ); + } +} diff --git a/tests/Antispam/IntegrationsByHook/TestMailChimpShadowRoot.php b/tests/Antispam/IntegrationsByHook/TestMailChimpShadowRoot.php new file mode 100644 index 000000000..8c97f0c14 --- /dev/null +++ b/tests/Antispam/IntegrationsByHook/TestMailChimpShadowRoot.php @@ -0,0 +1,290 @@ +integration = new MailChimpShadowRoot(); + } + + protected function tearDown(): void + { + global $apbct; + unset($apbct); + $_POST = []; + Post::getInstance()->variables = []; + parent::tearDown(); + } + + /** + * Test with valid email data + */ + public function testGetDataForCheckingWithValidEmail() + { + $_POST['email'] = 'test@example.com'; + $_POST['firstName'] = 'John'; + $_POST['lastName'] = 'Doe'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + $this->assertArrayHasKey('email', $result); + $this->assertEquals('test@example.com', $result['email']); + } + + /** + * Test with empty POST data + */ + public function testGetDataForCheckingWithEmptyPost() + { + $_POST = []; + + $result = $this->integration->getDataForChecking(null); + + $this->assertNull($result); + } + + /** + * Test with only email field + */ + public function testGetDataForCheckingWithOnlyEmail() + { + $_POST['email'] = 'subscriber@example.com'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + $this->assertArrayHasKey('email', $result); + } + + /** + * Test with special characters in data + */ + public function testGetDataForCheckingWithSpecialCharacters() + { + $_POST['email'] = 'test+tag@example.com'; + $_POST['firstName'] = "O'Brien"; + $_POST['lastName'] = 'Müller-Schmidt'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + $this->assertEquals('test+tag@example.com', $result['email']); + } + + /** + * Test with raw_body field (when JSON parsing fails on JS side) + */ + public function testGetDataForCheckingWithRawBody() + { + $_POST['raw_body'] = 'email=raw@example.com&name=Test'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with Mailchimp typical fields + */ + public function testGetDataForCheckingWithMailchimpFields() + { + $_POST['email'] = 'mailchimp@example.com'; + $_POST['FNAME'] = 'First'; + $_POST['LNAME'] = 'Last'; + $_POST['PHONE'] = '+1234567890'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + $this->assertArrayHasKey('email', $result); + } + + /** + * Test with bot detector token + */ + public function testGetDataForCheckingWithBotDetectorToken() + { + $_POST['email'] = 'bot-detector@example.com'; + $_POST['ct_bot_detector_event_token'] = 'test-token-123'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with no cookie hidden field + */ + public function testGetDataForCheckingWithNoCookieField() + { + $_POST['email'] = 'no-cookie@example.com'; + $_POST['ct_no_cookie_hidden_field'] = 'encoded-data'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with empty email + */ + public function testGetDataForCheckingWithEmptyEmail() + { + $_POST['email'] = ''; + $_POST['firstName'] = 'Test'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with invalid email format + */ + public function testGetDataForCheckingWithInvalidEmailFormat() + { + $_POST['email'] = 'not-an-email'; + $_POST['firstName'] = 'Test'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with multiple email fields (Mailchimp forms may have different field names) + */ + public function testGetDataForCheckingWithMultipleEmailFields() + { + $_POST['email'] = 'primary@example.com'; + $_POST['EMAIL'] = 'secondary@example.com'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + $this->assertArrayHasKey('email', $result); + } + + /** + * Test with whitespace in data + */ + public function testGetDataForCheckingWithWhitespace() + { + $_POST['email'] = ' whitespace@example.com '; + $_POST['firstName'] = ' John '; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with unicode characters + */ + public function testGetDataForCheckingWithUnicodeCharacters() + { + $_POST['email'] = 'unicode@example.com'; + $_POST['firstName'] = '日本語'; + $_POST['lastName'] = 'Кириллица'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with very long field values + */ + public function testGetDataForCheckingWithLongValues() + { + $_POST['email'] = 'long@example.com'; + $_POST['firstName'] = str_repeat('a', 1000); + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with numeric field values + */ + public function testGetDataForCheckingWithNumericValues() + { + $_POST['email'] = 'numeric@example.com'; + $_POST['phone'] = 1234567890; + $_POST['zip'] = 12345; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with array values in POST + */ + public function testGetDataForCheckingWithArrayValues() + { + $_POST['email'] = 'array@example.com'; + $_POST['interests'] = ['option1', 'option2']; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with no_cookie_data_taken flag already set + */ + public function testGetDataForCheckingWithNoCookieDataAlreadyTaken() + { + global $apbct; + $apbct->stats['no_cookie_data_taken'] = true; + + $_POST['email'] = 'already-taken@example.com'; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with XSS attempt in data + */ + public function testGetDataForCheckingWithXssAttempt() + { + $_POST['email'] = 'xss@example.com'; + $_POST['firstName'] = ''; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } + + /** + * Test with SQL injection attempt in data + */ + public function testGetDataForCheckingWithSqlInjectionAttempt() + { + $_POST['email'] = 'sql@example.com'; + $_POST['firstName'] = "'; DROP TABLE users; --"; + + $result = $this->integration->getDataForChecking(null); + + $this->assertIsArray($result); + } +} \ No newline at end of file