diff --git a/js/apbct-public-bundle.min.js b/js/apbct-public-bundle.min.js index 6005a76df..a75211562 100644 --- a/js/apbct-public-bundle.min.js +++ b/js/apbct-public-bundle.min.js @@ -1 +1 @@ -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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,c(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,c,i,l,s,d,u,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,m.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=f(n[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,c,i,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"),(i=document.createElement("strong")).append(u.phrases.trpHeading),(r=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(c=document.createElement("div")).append(" "),c.append(i),c.append(u.phrases.trpContent1),(i=document.createElement("div")).style.display="flex",i.style.gap="5px",(l=document.createElement("div")).append(u.phrases.trpContent2),i.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),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 +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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,i(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=c(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),c=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,i,c,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,m.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=_(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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"),(i=document.createElement("div")).append(" "),i.append(c),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 f62ec9d44..2495d0f51 100644 --- a/js/apbct-public-bundle_ext-protection.min.js +++ b/js/apbct-public-bundle_ext-protection.min.js @@ -1 +1 @@ -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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,c(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,c,i,l,s,d,u,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,_.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=m(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,c,i,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"),(i=document.createElement("strong")).append(u.phrases.trpHeading),(r=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(c=document.createElement("div")).append(" "),c.append(i),c.append(u.phrases.trpContent1),(i=document.createElement("div")).style.display="flex",i.style.gap="5px",(l=document.createElement("div")).append(u.phrases.trpContent2),i.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),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 +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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,i(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=c(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),c=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,i,c,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,_.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=m(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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"),(i=document.createElement("div")).append(" "),i.append(c),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 e77946094..c7c09ae4e 100644 --- a/js/apbct-public-bundle_ext-protection_gathering.min.js +++ b/js/apbct-public-bundle_ext-protection_gathering.min.js @@ -1 +1 @@ -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;et||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(r.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="";r.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=r.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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",o=0,n=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var o=_asyncToGenerator(_regenerator().m(function e(t,o){var n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:n=_createForOfIteratorHelper(c),e.p=2,n.s();case 3:if((a=n.n()).done)e.n=6;else{if((a=a.value).matches(t,o))return a=a.getForm(),e.n=4,r(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,n.e(a);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return o.apply(this,arguments)}})(),c=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var o,n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return o=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(o,{async:!0,callback:e,onErrorCallback:t})});case 3:return n=e.v,(a=void 0!==n.apbct&&+n.apbct.blocked||void 0!==n.data&&void 0!==n.data.message)&&(new ApbctShowForbidden).parseBlockMessage(n),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,o={action:"cleantalk_force_ajax_check"},n=_createForOfIteratorHelper(e.elements);try{for(n.s();!(t=n.n()).done;){var a=t.value;a.name&&(o[a.name]=a.value)}}catch(e){n.e(e)}finally{n.f()}return+ctPublic.bot_detector_enabled?o.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):o.ct_no_cookie_hidden_field=getNoCookieData(),o};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,o,n,a,c,r,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,o=new Array(t),n=0;n!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof o[0]?o[0]:(null==(a=o[0])?void 0:a.url)||""))return e.a(2,h.apply(this,o));e.n=2;break;case 2:if(o&&o[0]&&o[1]&&o[1].body){e.n=3;break}return e.a(2,h.apply(this,o));case 3:return e.n=4,m.processFetch(o);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return o[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{o[1].body=f(o[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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__"]'),r=null,i=(null!==c&&null!==c.value&&(r=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===i&&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=i,null!==r&&(n.apbct_search_form__honeypot_value=r),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,o="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(o=e.comment),o=void 0!==e.data&&void 0!==(e=e.data).message?e.message:o)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:o}})),cleantalkModal.loaded=o,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var n=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&n.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,c=n;a_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,r=this.findParentContainer(c);if(r){var i=this.getIdFromHTML(r);if(i===o){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,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{function n(){_classCallCheck(this,n)}return _createClass(n,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+n.LOG_KEY,t=n.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var o=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(o&&"string"==typeof o)try{return JSON.parse(o)}catch(e){return""}return o}o=(o=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof o?JSON.parse(o):o}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:n.botdLogicLoaded,botd_wrapper_loaded:n.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(n.botdWrapperLoaded&&n.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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 o,n,a,c,r,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")||((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"),(i=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(r=document.createElement("div")).append(" "),r.append(i),r.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)),c.append(r,i),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 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;et||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(r.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="";r.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=r.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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(c),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,r(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),c=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,c,r,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,m.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=_(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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__"]'),r=null,i=(null!==c&&null!==c.value&&(r=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===i&&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=i,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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,c=o;a_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,r=this.findParentContainer(c);if(r){var i=this.getIdFromHTML(r);if(i===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_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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,c,r,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),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(r=document.createElement("div")).append(" "),r.append(i),r.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)),c.append(r,i),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 f847bf9bc..0a443cba6 100644 --- a/js/apbct-public-bundle_full-protection.min.js +++ b/js/apbct-public-bundle_full-protection.min.js @@ -1 +1 @@ -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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,c(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,c,i,l,s,d,u,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,_.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=m(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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};+ctPublic.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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,c,i,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"),(i=document.createElement("strong")).append(u.phrases.trpHeading),(r=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(c=document.createElement("div")).append(" "),c.append(i),c.append(u.phrases.trpContent1),(i=document.createElement("div")).style.display="flex",i.style.gap="5px",(l=document.createElement("div")).append(u.phrases.trpContent2),i.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),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 +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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,c(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,c,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,_.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=m(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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};+ctPublic.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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,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"),(c=document.createElement("div")).append(" "),c.append(i),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 2703c97a4..0fc9cc71f 100644 --- a/js/apbct-public-bundle_full-protection_gathering.min.js +++ b/js/apbct-public-bundle_full-protection_gathering.min.js @@ -1 +1 @@ -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;et||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(r.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="";r.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=r.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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",o=0,n=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var o=_asyncToGenerator(_regenerator().m(function e(t,o){var n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:n=_createForOfIteratorHelper(c),e.p=2,n.s();case 3:if((a=n.n()).done)e.n=6;else{if((a=a.value).matches(t,o))return a=a.getForm(),e.n=4,r(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,n.e(a);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return o.apply(this,arguments)}})(),c=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var o,n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return o=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(o,{async:!0,callback:e,onErrorCallback:t})});case 3:return n=e.v,(a=void 0!==n.apbct&&+n.apbct.blocked||void 0!==n.data&&void 0!==n.data.message)&&(new ApbctShowForbidden).parseBlockMessage(n),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,o={action:"cleantalk_force_ajax_check"},n=_createForOfIteratorHelper(e.elements);try{for(n.s();!(t=n.n()).done;){var a=t.value;a.name&&(o[a.name]=a.value)}}catch(e){n.e(e)}finally{n.f()}return+ctPublic.bot_detector_enabled?o.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):o.ct_no_cookie_hidden_field=getNoCookieData(),o};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,o,n,a,c,r,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,o=new Array(t),n=0;n!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof o[0]?o[0]:(null==(a=o[0])?void 0:a.url)||""))return e.a(2,h.apply(this,o));e.n=2;break;case 2:if(o&&o[0]&&o[1]&&o[1].body){e.n=3;break}return e.a(2,h.apply(this,o));case 3:return e.n=4,m.processFetch(o);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return o[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{o[1].body=f(o[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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__"]'),r=null,i=(null!==c&&null!==c.value&&(r=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===i&&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=i,null!==r&&(n.apbct_search_form__honeypot_value=r),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,o="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(o=e.comment),o=void 0!==e.data&&void 0!==(e=e.data).message?e.message:o)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:o}})),cleantalkModal.loaded=o,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var n=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&n.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,c=n;a_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,r=this.findParentContainer(c);if(r){var i=this.getIdFromHTML(r);if(i===o){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,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),_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};+ctPublic.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 o;this.wrappers.forEach(function(e){o=e.querySelector("div.ct-encoded-form").dataset.encodedForm;try{var t;o&&"string"==typeof o&&(t=decodeURIComponent(o),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 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{function n(){_classCallCheck(this,n)}return _createClass(n,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+n.LOG_KEY,t=n.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var o=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(o&&"string"==typeof o)try{return JSON.parse(o)}catch(e){return""}return o}o=(o=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof o?JSON.parse(o):o}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:n.botdLogicLoaded,botd_wrapper_loaded:n.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(n.botdWrapperLoaded&&n.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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 o,n,a,c,r,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")||((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"),(i=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(r=document.createElement("div")).append(" "),r.append(i),r.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)),c.append(r,i),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 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;et||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(r.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="";r.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=r.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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(c),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,r(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),c=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,c,r,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,m.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=_(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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__"]'),r=null,i=(null!==c&&null!==c.value&&(r=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===i&&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=i,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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,c=o;a_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,r=this.findParentContainer(c);if(r){var i=this.getIdFromHTML(r);if(i===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_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};+ctPublic.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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,c,r,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),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(r=document.createElement("div")).append(" "),r.append(i),r.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)),c.append(r,i),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 763adae53..0b3932296 100644 --- a/js/apbct-public-bundle_gathering.min.js +++ b/js/apbct-public-bundle_gathering.min.js @@ -1 +1 @@ -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;et||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(r.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="";r.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=r.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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",o=0,n=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var o=_asyncToGenerator(_regenerator().m(function e(t,o){var n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:n=_createForOfIteratorHelper(c),e.p=2,n.s();case 3:if((a=n.n()).done)e.n=6;else{if((a=a.value).matches(t,o))return a=a.getForm(),e.n=4,r(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,n.e(a);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return o.apply(this,arguments)}})(),c=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var o,n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return o=i(t),m=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(o,{async:!0,callback:e,onErrorCallback:t})});case 3:return n=e.v,(a=void 0!==n.apbct&&+n.apbct.blocked||void 0!==n.data&&void 0!==n.data.message)&&(new ApbctShowForbidden).parseBlockMessage(n),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,m=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,o={action:"cleantalk_force_ajax_check"},n=_createForOfIteratorHelper(e.elements);try{for(n.s();!(t=n.n()).done;){var a=t.value;a.name&&(o[a.name]=a.value)}}catch(e){n.e(e)}finally{n.f()}return+ctPublic.bot_detector_enabled?o.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):o.ct_no_cookie_hidden_field=getNoCookieData(),o};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,o,n,a,c,r,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,o=new Array(t),n=0;n!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof o[0]?o[0]:(null==(a=o[0])?void 0:a.url)||""))return e.a(2,h.apply(this,o));e.n=2;break;case 2:if(o&&o[0]&&o[1]&&o[1].body){e.n=3;break}return e.a(2,h.apply(this,o));case 3:return e.n=4,b.processFetch(o);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return o[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{o[1].body=f(o[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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__"]'),r=null,i=(null!==c&&null!==c.value&&(r=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===i&&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=i,null!==r&&(n.apbct_search_form__honeypot_value=r),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,o="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(o=e.comment),o=void 0!==e.data&&void 0!==(e=e.data).message?e.message:o)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:o}})),cleantalkModal.loaded=o,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var n=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&n.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,c=n;a_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,r=this.findParentContainer(c);if(r){var i=this.getIdFromHTML(r);if(i===o){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,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{function n(){_classCallCheck(this,n)}return _createClass(n,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+n.LOG_KEY,t=n.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var o=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(o&&"string"==typeof o)try{return JSON.parse(o)}catch(e){return""}return o}o=(o=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof o?JSON.parse(o):o}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:n.botdLogicLoaded,botd_wrapper_loaded:n.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(n.botdWrapperLoaded&&n.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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 o,n,a,c,r,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")||((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"),(i=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(r=document.createElement("div")).append(" "),r.append(i),r.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)),c.append(r,i),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 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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,c(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),m=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,m=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,c,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,b.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=f(n[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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)},[{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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,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"),(c=document.createElement("div")).append(" "),c.append(i),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_int-protection.min.js b/js/apbct-public-bundle_int-protection.min.js index 732f6126d..0ade9e80c 100644 --- a/js/apbct-public-bundle_int-protection.min.js +++ b/js/apbct-public-bundle_int-protection.min.js @@ -1 +1 @@ -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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,c(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,c,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,m.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=f(n[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,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"),(c=document.createElement("div")).append(" "),c.append(i),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 +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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,i(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=c(t),b=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,b=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),c=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,i,c,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,m.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=_(n[1].body,f(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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"),(i=document.createElement("div")).append(" "),i.append(c),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 a80dbeaa0..ad981d2ae 100644 --- a/js/apbct-public-bundle_int-protection_gathering.min.js +++ b/js/apbct-public-bundle_int-protection_gathering.min.js @@ -1 +1 @@ -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;et||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(r.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="";r.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=r.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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",o=0,n=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var o=_asyncToGenerator(_regenerator().m(function e(t,o){var n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:n=_createForOfIteratorHelper(c),e.p=2,n.s();case 3:if((a=n.n()).done)e.n=6;else{if((a=a.value).matches(t,o))return a=a.getForm(),e.n=4,r(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,n.e(a);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return o.apply(this,arguments)}})(),c=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var o,n,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return o=i(t),m=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(o,{async:!0,callback:e,onErrorCallback:t})});case 3:return n=e.v,(a=void 0!==n.apbct&&+n.apbct.blocked||void 0!==n.data&&void 0!==n.data.message)&&(new ApbctShowForbidden).parseBlockMessage(n),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,m=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,o={action:"cleantalk_force_ajax_check"},n=_createForOfIteratorHelper(e.elements);try{for(n.s();!(t=n.n()).done;){var a=t.value;a.name&&(o[a.name]=a.value)}}catch(e){n.e(e)}finally{n.f()}return+ctPublic.bot_detector_enabled?o.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):o.ct_no_cookie_hidden_field=getNoCookieData(),o};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,o,n,a,c,r,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,o=new Array(t),n=0;n!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof o[0]?o[0]:(null==(a=o[0])?void 0:a.url)||""))return e.a(2,h.apply(this,o));e.n=2;break;case 2:if(o&&o[0]&&o[1]&&o[1].body){e.n=3;break}return e.a(2,h.apply(this,o));case 3:return e.n=4,b.processFetch(o);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return o[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{o[1].body=f(o[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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__"]'),r=null,i=(null!==c&&null!==c.value&&(r=c.value),getCleanTalkStorageDataArray()),l=apbctLocalStorage.get("bot_detector_event_token");null===i&&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=i,null!==r&&(n.apbct_search_form__honeypot_value=r),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,o="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(o=e.comment),o=void 0!==e.data&&void 0!==(e=e.data).message?e.message:o)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:o}})),cleantalkModal.loaded=o,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var n=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&n.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,c=n;a_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,r=this.findParentContainer(c);if(r){var i=this.getIdFromHTML(r);if(i===o){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,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{function n(){_classCallCheck(this,n)}return _createClass(n,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+n.LOG_KEY,t=n.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var o=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(o&&"string"==typeof o)try{return JSON.parse(o)}catch(e){return""}return o}o=(o=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof o?JSON.parse(o):o}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:n.botdLogicLoaded,botd_wrapper_loaded:n.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(n.botdWrapperLoaded&&n.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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 o,n,a,c,r,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")||((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"),(i=document.createElement("strong")).append(d.phrases.trpHeading),(c=document.createElement("div")).setAttribute("class","apbct-real-user-popup-content_row"),(r=document.createElement("div")).append(" "),r.append(i),r.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)),c.append(r,i),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 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;et||r=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=ApbctFetchProxyConfig},[{key:"findMatchingConfig",value:function(e){for(var t="string"==typeof e?e:null!=e&&"string"==typeof e.href?e.href:"",n=0,o=Object.entries(this.config);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(e){void 0!==ctPublic.force_alt_cookies&&("undefined"===ctPublic.force_alt_cookies||ctPublic.force_alt_cookies)||+ctPublic.bot_detector_enabled&&!e||(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(unescape(encodeURIComponent(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(unescape(encodeURIComponent(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.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 p(){_classCallCheck(this,p)}return _createClass(p,[{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{var n=_asyncToGenerator(_regenerator().m(function e(t,n){var o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(+ctPublic.settings__forms__check_external){e.n=1;break}return e.a(2,!1);case 1:o=_createForOfIteratorHelper(r),e.p=2,o.s();case 3:if((a=o.n()).done)e.n=6;else{if((a=a.value).matches(t,n))return a=a.getForm(),e.n=4,c(a);e.n=5}break;case 4:if(e.v)return e.a(2,!0);e.n=5;break;case 5:e.n=3;break;case 6:e.n=8;break;case 7:e.p=7,a=e.v,o.e(a);case 8:return e.p=8,o.f(),e.f(8);case 9:return e.a(2,!1)}},e,null,[[2,7,8,9]])}));return function(e,t){return n.apply(this,arguments)}})(),r=[{name:"bitrix24",matches:function(e,t){return document.querySelector(".b24-form")&&e.includes("bitrix/services/main/ajax.php?action=crm.site.form.fill")&&t[1].body instanceof FormData},getForm:function(){return document.querySelector(".b24-form form")}},{name:"sender",matches:function(e,t){return e.includes("stats.sender.net/forms")&&"string"==typeof t[1].body},getForm:function(){for(var e=document.querySelectorAll("iframe"),t=0;t{var t=_asyncToGenerator(_regenerator().m(function e(t){var n,o,a;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t){e.n=1;break}return e.a(2,!1);case 1:return n=i(t),m=!0,e.p=2,e.n=3,new Promise(function(e,t){apbct_public_sendAJAX(n,{async:!0,callback:e,onErrorCallback:t})});case 3:return o=e.v,(a=void 0!==o.apbct&&+o.apbct.blocked||void 0!==o.data&&void 0!==o.data.message)&&(new ApbctShowForbidden).parseBlockMessage(o),e.a(2,a);case 4:return e.p=4,e.a(2,!1);case 5:return e.p=5,m=!1,e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(e){return t.apply(this,arguments)}})(),i=function(e){var t,n={action:"cleantalk_force_ajax_check"},o=_createForOfIteratorHelper(e.elements);try{for(o.s();!(t=o.n()).done;){var a=t.value;a.name&&(n[a.name]=a.value)}}catch(e){o.e(e)}finally{o.f()}return+ctPublic.bot_detector_enabled?n.ct_bot_detector_event_token=apbctLocalStorage.get("bot_detector_event_token"):n.ct_no_cookie_hidden_field=getNoCookieData(),n};window.fetch=_asyncToGenerator(_regenerator().m(function e(){var t,n,o,a,r,c,i,l,s,u,d,p=arguments;return _regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:for(t=p.length,n=new Array(t),o=0;o!(!t||"string"!=typeof t)&&["google.com/recaptcha","gstatic.com/recaptcha","recaptcha.google.com","recaptcha.net","www.google.com/recaptcha","apis.google.com","paypal.com","api.paypal.com","www.paypal.com","js.stripe.com","api.stripe.com","checkout.stripe.com","api.doboard.com"].some(function(e){return t.includes(e)}))(a="string"==typeof n[0]?n[0]:(null==(a=n[0])?void 0:a.url)||""))return e.a(2,h.apply(this,n));e.n=2;break;case 2:if(n&&n[0]&&n[1]&&n[1].body){e.n=3;break}return e.a(2,h.apply(this,n));case 3:return e.n=4,b.processFetch(n);case 4:if(!0===e.v)return e.a(2,Promise.reject(new Error("Forbidden")));e.n=5;break;case 5:if(0{try{return n[0].includes(new URL(ctPublicFunctions._rest_url).pathname+"metform/")}catch(e){}})()))try{n[1].body=f(n[1].body,_(+ctPublic.bot_detector_enabled))}catch(e){}if(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,n="";if((void 0!==e.apbct&&(e=e.apbct).blocked&&(n=e.comment),n=void 0!==e.data&&void 0!==(e=e.data).message?e.message:n)&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:n}})),cleantalkModal.loaded=n,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"),t=document.querySelector("div.nex_success_message"))&&(t.style.display="none"),e.integration)&&"ElfsightForm"===e.integration)){var o=[document];try{document.querySelectorAll("iframe").forEach(function(e){try{e.contentDocument&&o.push(e.contentDocument)}catch(e){}})}catch(e){}for(var a=0,r=o;a_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)},[{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{function o(){_classCallCheck(this,o)}return _createClass(o,null,[{key:"getFrontendDataLog",value:function(){var e=("undefined"!=typeof ctPublicFunctions&&ctPublicFunctions.cookiePrefix?ctPublicFunctions.cookiePrefix:"")+o.LOG_KEY,t=o.LOG_KEY;if(void 0!==apbctLocalStorage&&apbctLocalStorage.get){var n=apbctLocalStorage.get(e)||apbctLocalStorage.get(t)||null;if(n&&"string"==typeof n)try{return JSON.parse(n)}catch(e){return""}return n}n=(n=localStorage.getItem(e))||localStorage.getItem(t)||null;try{return"string"==typeof n?JSON.parse(n):n}catch(e){return""}}},{key:"asDTO",value:function(){return{botd_logic_loaded:o.botdLogicLoaded,botd_wrapper_loaded:o.botdWrapperLoaded,frontend_data_log:"",transport_enabled:1}}},{key:"detectScripts",value:function(){if(o.botdWrapperLoaded&&o.botdLogicLoaded)return!0;for(var e=document.getElementsByTagName("script"),t=0;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,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"),(c=document.createElement("div")).append(" "),c.append(i),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/prebuild/apbct-public-bundle.js b/js/prebuild/apbct-public-bundle.js index fe7d0a1ad..9748b2dab 100644 --- a/js/prebuild/apbct-public-bundle.js +++ b/js/prebuild/apbct-public-bundle.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } + } + } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); + } + } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } + + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + return sourceSign; + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; + } + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/prebuild/apbct-public-bundle_ext-protection.js b/js/prebuild/apbct-public-bundle_ext-protection.js index 596b1cba5..8518e1712 100644 --- a/js/prebuild/apbct-public-bundle_ext-protection.js +++ b/js/prebuild/apbct-public-bundle_ext-protection.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } + } + } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; + } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); } } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); + } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + return sourceSign; + } + + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; + } + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/prebuild/apbct-public-bundle_ext-protection_gathering.js b/js/prebuild/apbct-public-bundle_ext-protection_gathering.js index 22d79abc5..0124e8837 100644 --- a/js/prebuild/apbct-public-bundle_ext-protection_gathering.js +++ b/js/prebuild/apbct-public-bundle_ext-protection_gathering.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } + } + } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; + } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); + } + } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + return sourceSign; + } + + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; + } + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/prebuild/apbct-public-bundle_full-protection.js b/js/prebuild/apbct-public-bundle_full-protection.js index 384eea4b1..6bfd6c33a 100644 --- a/js/prebuild/apbct-public-bundle_full-protection.js +++ b/js/prebuild/apbct-public-bundle_full-protection.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } + } + } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; + } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); } } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); + } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + return sourceSign; + } + + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; + } + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/prebuild/apbct-public-bundle_full-protection_gathering.js b/js/prebuild/apbct-public-bundle_full-protection_gathering.js index 76299162c..70ab6bb1b 100644 --- a/js/prebuild/apbct-public-bundle_full-protection_gathering.js +++ b/js/prebuild/apbct-public-bundle_full-protection_gathering.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } + } + } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; + } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); + } + } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + return sourceSign; + } + + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; + } + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/prebuild/apbct-public-bundle_gathering.js b/js/prebuild/apbct-public-bundle_gathering.js index d52e1c679..62d6987d4 100644 --- a/js/prebuild/apbct-public-bundle_gathering.js +++ b/js/prebuild/apbct-public-bundle_gathering.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } } } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; + } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); + } + } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); + } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } + + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + return sourceSign; + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; + } + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/prebuild/apbct-public-bundle_int-protection.js b/js/prebuild/apbct-public-bundle_int-protection.js index 2406f45f6..1eac108d8 100644 --- a/js/prebuild/apbct-public-bundle_int-protection.js +++ b/js/prebuild/apbct-public-bundle_int-protection.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } + } + } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); + } + } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } + + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + return sourceSign; + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; + } + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/prebuild/apbct-public-bundle_int-protection_gathering.js b/js/prebuild/apbct-public-bundle_int-protection_gathering.js index fe9de6cd5..d2b5e069d 100644 --- a/js/prebuild/apbct-public-bundle_int-protection_gathering.js +++ b/js/prebuild/apbct-public-bundle_int-protection_gathering.js @@ -3906,188 +3906,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } } } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; + } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); + } + } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; + } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); + } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } + + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + return sourceSign; + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; + } + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -4099,8 +4881,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -4148,13 +4929,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -4224,9 +5002,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } } diff --git a/js/src/public-1-main.js b/js/src/public-1-main.js index 466afc479..4740e6586 100644 --- a/js/src/public-1-main.js +++ b/js/src/public-1-main.js @@ -1159,188 +1159,970 @@ class ApbctHandler { } /** - * Prepare jQuery.ajaxSetup to add nocookie data to the jQuery ajax request. + * Prepare jQuery.ajaxPrefilter to add CleanTalk data to jQuery ajax requests. * Notes: - * - Do it just once, the ajaxSetup.beforeSend will be overwritten for any calls. - * - Signs of forms need to be caught will be checked during ajaxSetup.settings.data process on send. + * - ajaxSetup.beforeSend is not used: a request can supply its own beforeSend and drop the default. + * - ajaxPrefilter runs for every jQuery ajax call after options are merged, so injection is guaranteed. + * - Form signs are checked on the request data/url at send time. * - Any sign of the form HTML of the caller is insignificant in this process. * - This is the only place where we can found hard dependency on jQuery, if the form use it - the script * will work independing if jQuery is loaded by CleanTalk or not * @return {void} */ catchJqueryAjax() { - if ( typeof jQuery !== 'undefined') { - // this code run on base ajax rules - so do not work due scripts use it's own ajax object injections - if ( typeof jQuery.ajaxSetup === 'function' ) { - jQuery.ajaxSetup({ - beforeSend: function(xhr, settings) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(settings, 'ajaxSetup'); - if (sourceSign.found !== false) { - settings.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, settings.data); - } - }, - }); + if ( typeof jQuery !== 'undefined' && typeof jQuery.ajaxPrefilter === 'function' ) { + jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { + const handler = new ApbctHandler(); + const sourceSign = handler.searchSignsForJQAjaxInjection(options, originalOptions); + if (sourceSign.found !== false) { + options.data = handler.injectCleantalkDataToJQAjax( + sourceSign, + handler.getJQAjaxPayloadForInject(options, originalOptions), + options, + ); + } + }); + } + } + + /** + * jQuery.param() on URLSearchParams/FormData can collapse options.data to "". + * Sign search already falls back to originalOptions; inject must use that payload too. + * @param {object} options + * @param {object=} originalOptions + * @return {*} + */ + getJQAjaxPayloadForInject(options, originalOptions) { + const current = options && options.data; + const original = originalOptions && originalOptions.data; + if ( this.jqAjaxPayloadWasCollapsed(current, original) ) { + return original; + } + return current; + } + + /** + * @param {*} current + * @param {*} original + * @return {boolean} + */ + jqAjaxPayloadWasCollapsed(current, original) { + if ( original === null || typeof original === 'undefined' ) { + return false; + } + if ( current === original ) { + return false; + } + const currentEmpty = current === '' || current === null || typeof current === 'undefined'; + if ( !currentEmpty ) { + return false; + } + if ( typeof original === 'string' ) { + return original !== ''; + } + return this.isJQAjaxFormData(original) || + this.isJQAjaxURLSearchParams(original) || + this.isJQAjaxPlainObjectOrArray(original); + } + + /** + * Normalize jQuery ajax data to a query string for sign search. + * Objects and serializeArray are read structurally so search never calls jQuery.param. + * Also reads known sign fields from the URL (IE11 FormData cannot be enumerated). + * @param {object} ajaxObject Ajax options object. + * @return {string} + */ + getJQAjaxDataAsString(ajaxObject) { + if ( !ajaxObject || typeof ajaxObject !== 'object' ) { + return ''; + } + let fromData = ''; + if ( typeof ajaxObject.data === 'string' ) { + fromData = ajaxObject.data; + } else if ( this.isJQAjaxPlainObjectOrArray(ajaxObject.data) ) { + fromData = this.getStructuredJQAjaxSignString(ajaxObject.data); + } else if ( this.isJQAjaxURLSearchParams(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } else if ( this.isJQAjaxFormData(ajaxObject.data) ) { + fromData = this.collectKnownSignStringFromKeyValueBag(ajaxObject.data); + } + // Native IE11 FormData is write-only (no get/forEach/entries). Signs then come from the URL. + const fromUrl = this.collectKnownSignStringFromUrl(ajaxObject.url); + if ( fromData && fromUrl ) { + return fromData + '&' + fromUrl; + } + return fromData || fromUrl; + } + + /** + * Build a sign string from top-level fields without serializing the whole payload. + * @param {object|Array} data + * @return {string} + */ + getStructuredJQAjaxSignString(data) { + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return this.getSerializeArraySignString(data); + } + const parts = []; + const action = this.getPlainObjectSignField(data, 'action'); + if ( typeof action === 'string' && action !== '' ) { + parts.push('action=' + action); + } + const nonce = this.getPlainObjectSignField(data, 'ur_frontend_form_nonce'); + if ( nonce !== null ) { + parts.push('ur_frontend_form_nonce=' + nonce); + } + if ( this.plainObjectHasTwtCcSignup(data) ) { + parts.push('twt_cc_signup=1'); + } + return parts.join('&'); + } + + /** + * Read action/nonce from top-level, data[key], or nested data.key. + * @param {object} data + * @param {string} key + * @return {string|number|null} + */ + getPlainObjectSignField(data, key) { + if ( !data || typeof data !== 'object' ) { + return null; + } + if ( this.isJQAjaxScalarSignValue(data[key]) ) { + return data[key]; + } + const bracketKey = 'data[' + key + ']'; + if ( this.isJQAjaxScalarSignValue(data[bracketKey]) ) { + return data[bracketKey]; + } + if ( + data.data && + typeof data.data === 'object' && + Object.prototype.toString.call(data.data) !== '[object Array]' && + this.isJQAjaxScalarSignValue(data.data[key]) + ) { + return data.data[key]; + } + return null; + } + + /** + * @param {*} value + * @return {boolean} + */ + isJQAjaxScalarSignValue(value) { + return typeof value === 'string' || typeof value === 'number'; + } + + /** + * @param {object} data + * @param {number=} depth + * @return {boolean} + */ + plainObjectHasTwtCcSignup(data, depth) { + if ( !data || typeof data !== 'object' ) { + return false; + } + if ( typeof depth === 'undefined' ) { + depth = 0; + } + if ( depth > 2 ) { + return false; + } + for ( const key in data ) { + if ( !Object.prototype.hasOwnProperty.call(data, key) ) { + continue; } - // this code run on ANY ajax on ANY script queue status - // todo Probably move all ajaxSetup actions to ajaxPrefilter - if ( typeof jQuery.ajaxPrefilter === 'function' ) { - jQuery.ajaxPrefilter(function(options, originalOptions, jqXHR) { - const handler = new ApbctHandler(); - const sourceSign = handler.searchSignsForJQAjaxInjection(options, 'ajaxPrefilter'); - if (sourceSign.found !== false) { - if (typeof options.data === 'string') { - options.data = handler.injectCleantalkDataToJQAjaxString(sourceSign, options.data); - } - if ( - typeof options.data === 'object' && - typeof options.data.append === 'function' - ) { - options.data = handler.injectCleantalkDataToJQAjaxFormData(sourceSign, options.data); - } - } - }); + const normalizedKey = this.unwrapJQAjaxFormDataKey(key); + if ( normalizedKey === 'twt_cc_signup' || key.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + const value = data[key]; + if ( typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1 ) { + return true; + } + if ( + value && + typeof value === 'object' && + Object.prototype.toString.call(value) !== '[object Array]' + ) { + if ( this.plainObjectHasTwtCcSignup(value, depth + 1) ) { + return true; + } + } + } + return false; + } + + /** + * @param {Array} entries + * @return {string} + */ + getSerializeArraySignString(entries) { + const parts = []; + for ( let i = 0; i < entries.length; i++ ) { + const entry = entries[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + continue; + } + const value = entry.value; + const normalizedKey = this.unwrapJQAjaxFormDataKey(entry.name); + if ( this.isJQAjaxKnownSignField(normalizedKey, value) ) { + parts.push(normalizedKey + '=' + value); + } + } + return parts.join('&'); + } + + /** + * True for serializeArray payloads, including an empty array. + * @param {Array} data + * @return {boolean} + */ + isJQAjaxSerializeArray(data) { + if ( Object.prototype.toString.call(data) !== '[object Array]' ) { + return false; + } + for ( let i = 0; i < data.length; i++ ) { + const entry = data[i]; + if ( !entry || typeof entry !== 'object' || typeof entry.name !== 'string' ) { + return false; + } + } + return true; + } + + /** + * Cross-realm URLSearchParams (instanceof fails across windows). + * @param {*} data + * @return {boolean} + */ + isJQAjaxURLSearchParams(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object URLSearchParams]' ) { + return true; + } + if ( tag === '[object FormData]' ) { + return false; + } + return typeof data.sort === 'function' && typeof data.get === 'function'; + } + + /** + * Cross-realm FormData, including common polyfills. + * @param {*} data + * @return {boolean} + */ + isJQAjaxFormData(data) { + if ( !data || typeof data !== 'object' || typeof data.append !== 'function' ) { + return false; + } + if ( this.isJQAjaxPlainObjectOrArray(data) || this.isJQAjaxURLSearchParams(data) ) { + return false; + } + const tag = Object.prototype.toString.call(data); + if ( tag === '[object FormData]' ) { + return true; + } + if ( tag === '[object Headers]' || typeof data.getSetCookie === 'function' ) { + return false; + } + return typeof data.forEach === 'function' || + typeof data.get === 'function' || + typeof data.entries === 'function'; + } + + /** + * Collect only known sign fields from FormData / URLSearchParams. + * Unwrap data[action] so later action=... checks match. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + collectKnownSignStringFromKeyValueBag(bag) { + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' ) { + return; + } + const valueAsString = String(value); + const normalizedKey = unwrapKey(key); + if ( + knownKeys[normalizedKey] || + valueAsString.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + valueAsString); + } + }); + if ( collected ) { + return parts.join('&'); + } + if ( typeof bag.get !== 'function' ) { + return ''; + } + const keysToProbe = [ + 'action', + 'ur_frontend_form_nonce', + 'twt_cc_signup', + ]; + const getParts = []; + for ( let i = 0; i < keysToProbe.length; i++ ) { + const key = keysToProbe[i]; + const value = this.getFormDataScalarValue(bag, [key, 'data[' + key + ']']); + if ( value !== null ) { + getParts.push(key + '=' + value); + } + } + return getParts.join('&'); + } + + /** + * Known sign fields from a request URL query. IE11-safe (no URLSearchParams). + * @param {string} url + * @return {string} + */ + collectKnownSignStringFromUrl(url) { + if ( typeof url !== 'string' || url === '' ) { + return ''; + } + const queryIndex = url.indexOf('?'); + if ( queryIndex === -1 || queryIndex === url.length - 1 ) { + return ''; + } + const hashIndex = url.indexOf('#', queryIndex); + const query = hashIndex === -1 ? + url.slice(queryIndex + 1) : + url.slice(queryIndex + 1, hashIndex); + const knownKeys = this.getJQAjaxKnownSignKeys(); + const unwrapKey = this.unwrapJQAjaxFormDataKey; + const parts = []; + const pairs = query.split('&'); + for ( let i = 0; i < pairs.length; i++ ) { + const pair = pairs[i]; + if ( !pair ) { + continue; + } + const eq = pair.indexOf('='); + let rawKey = eq === -1 ? pair : pair.slice(0, eq); + let rawValue = eq === -1 ? '' : pair.slice(eq + 1); + try { + rawKey = decodeURIComponent(rawKey.replace(/\+/g, ' ')); + rawValue = decodeURIComponent(rawValue.replace(/\+/g, ' ')); + } catch (e) { + continue; + } + const normalizedKey = unwrapKey(rawKey); + if ( + knownKeys[normalizedKey] || + rawValue.indexOf('twt_cc_signup') !== -1 || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + parts.push(normalizedKey + '=' + rawValue); + } + } + return parts.join('&'); + } + + /** + * Walk FormData/URLSearchParams via forEach, then entries() for polyfills that only have an iterator. + * @param {FormData|URLSearchParams} bag + * @param {Function} callback + * @return {boolean} + */ + forEachJQAjaxKeyValueBag(bag, callback) { + if ( typeof bag.forEach === 'function' ) { + try { + bag.forEach(callback); + return true; + } catch (e) { + // Fall through to entries(). + } + } + if ( typeof bag.entries !== 'function' ) { + return false; + } + try { + const iterator = bag.entries(); + if ( !iterator || typeof iterator.next !== 'function' ) { + return false; } + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + callback(pair[1], pair[0]); + } + step = iterator.next(); + } + return true; + } catch (e) { + return false; + } + } + + /** + * @return {Object} + */ + getJQAjaxKnownSignKeys() { + const knownKeys = Object.create(null); + knownKeys.action = true; + knownKeys.ur_frontend_form_nonce = true; + knownKeys.twt_cc_signup = true; + return knownKeys; + } + + /** + * @param {string} normalizedKey + * @param {*} value + * @return {boolean} + */ + isJQAjaxKnownSignField(normalizedKey, value) { + if ( + normalizedKey === 'action' || + normalizedKey === 'ur_frontend_form_nonce' || + normalizedKey === 'twt_cc_signup' || + normalizedKey.indexOf('twt_cc_signup') !== -1 + ) { + return true; + } + return typeof value === 'string' && value.indexOf('twt_cc_signup') !== -1; + } + + /** + * Treat data[action] as action for WP-style payloads. + * @param {string} key + * @return {string} + */ + unwrapJQAjaxFormDataKey(key) { + if ( typeof key !== 'string' ) { + return ''; + } + if ( key.length > 6 && key.indexOf('data[') === 0 && key.charAt(key.length - 1) === ']' ) { + return key.slice(5, -1); + } + return key; + } + + /** + * @param {FormData} formData + * @param {Array.} keys + * @return {string|number|null} + */ + getFormDataScalarValue(formData, keys) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && (typeof value === 'string' || typeof value === 'number') ) { + return value; + } + } + return null; + } + + /** + * True for arrays and plain objects that jQuery.param can serialize safely. + * @param {*} data + * @return {boolean} + */ + isJQAjaxPlainObjectOrArray(data) { + if ( data === null || typeof data !== 'object' ) { + return false; + } + if ( Object.prototype.toString.call(data) === '[object Array]' ) { + return true; + } + if ( typeof jQuery !== 'undefined' && typeof jQuery.isPlainObject === 'function' ) { + return jQuery.isPlainObject(data); } + const proto = Object.getPrototypeOf(data); + return proto === Object.prototype || proto === null; } /** * Search for sign within AJAX data to do inject CleanTalk data. * @param {object} ajaxObject Ajax object. - * @param {string} catchOn Function should be catched on. + * @param {object=} originalOptions Original jQuery ajax options before merge. * @return {{found: boolean, keepUnwrapped: boolean, attachVisibleFieldsData: boolean}} */ - searchSignsForJQAjaxInjection(ajaxObject, catchOn = 'ajaxSetup') { + searchSignsForJQAjaxInjection(ajaxObject, originalOptions) { let sourceSign = { 'found': false, 'keepUnwrapped': false, 'attachVisibleFieldsData': false, }; - // on ajaxSetup - if (catchOn === 'ajaxSetup') { - // settings data is string (important!) - if ( typeof ajaxObject.data === 'string' ) { - if ( - ajaxObject.data.indexOf('action=fl_builder_subscribe_form_submit') !== -1 - ) { - sourceSign.found = 'fl_builder_subscribe_form_submit'; - } - if ( - ajaxObject.data.indexOf('twt_cc_signup') !== -1 - ) { - sourceSign.found = 'twt_cc_signup'; - } - if ( - ajaxObject.data.indexOf('action=mailpoet') !== -1 - ) { - sourceSign.found = 'action=mailpoet'; - sourceSign.attachVisibleFieldsData = true; - } + let dataString = this.getJQAjaxDataAsString(ajaxObject); + if ( !dataString && originalOptions && originalOptions !== ajaxObject ) { + dataString = this.getJQAjaxDataAsString(originalOptions); + } - if ( - ajaxObject.data.indexOf('action=user_registration') !== -1 && - ajaxObject.data.indexOf('ur_frontend_form_nonce') !== -1 - ) { - sourceSign.found = 'action=user_registration'; - } + if ( dataString.indexOf('action=fl_builder_subscribe_form_submit') !== -1 ) { + sourceSign.found = 'fl_builder_subscribe_form_submit'; + } + if ( dataString.indexOf('twt_cc_signup') !== -1 ) { + sourceSign.found = 'twt_cc_signup'; + } + if ( dataString.indexOf('action=mailpoet') !== -1 ) { + sourceSign.found = 'action=mailpoet'; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=user_registration') !== -1 && + dataString.indexOf('ur_frontend_form_nonce') !== -1 + ) { + sourceSign.found = 'action=user_registration'; + } + if ( dataString.indexOf('action=happyforms_message') !== -1 ) { + sourceSign.found = 'action=happyforms_message'; + } + if ( dataString.indexOf('action=new_activity_comment') !== -1 ) { + sourceSign.found = 'action=new_activity_comment'; + } + if ( dataString.indexOf('action=wwlc_create_user') !== -1 ) { + sourceSign.found = 'action=wwlc_create_user'; + } + if ( dataString.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 ) { + sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=drplus_signup') !== -1 ) { + sourceSign.found = 'action=drplus_signup'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=bt_cc') !== -1 ) { + sourceSign.found = 'action=bt_cc'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=wpr_form_builder_email') !== -1 ) { + sourceSign.found = 'action=wpr_form_builder_email'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=nf_ajax_submit') !== -1 ) { + sourceSign.found = 'action=nf_ajax_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( + dataString.indexOf('action=uael_register_user') !== -1 && + ctPublic.data__cookies_type === 'none' + ) { + sourceSign.found = 'action=uael_register_user'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=SQBSubmitQuizAjax') !== -1 ) { + sourceSign.found = 'action=SQBSubmitQuizAjax'; + sourceSign.keepUnwrapped = true; + } + if ( dataString.indexOf('action=user_registration_user_form_submit') !== -1 ) { + sourceSign.found = 'action=user_registration_user_form_submit'; + sourceSign.keepUnwrapped = true; + sourceSign.attachVisibleFieldsData = true; + } + if ( dataString.indexOf('action=bloom_subscribe') !== -1 ) { + sourceSign.found = 'action=bloom_subscribe'; + sourceSign.keepUnwrapped = true; + } + if ( + this.isJQAjaxFormData(ajaxObject.data) && + typeof ajaxObject.data.get === 'function' && + ajaxObject.data.get('action') === 'pafe_ajax_form_builder' + ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } else if ( dataString.indexOf('action=pafe_ajax_form_builder') !== -1 ) { + sourceSign.found = 'action=pafe_ajax_form_builder'; + sourceSign.keepUnwrapped = true; + } - if (ajaxObject.data.indexOf('action=happyforms_message') !== -1) { - sourceSign.found = 'action=happyforms_message'; - } + // woocommerce add to cart is based on URL + if ( typeof ajaxObject.url === 'string' && ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1 ) { + sourceSign.found = 'wc-ajax=add_to_cart'; + // GET/HEAD: PHP reads Get::get('ct_bot_detector_event_token'), not data[...]. + if ( this.isJQAjaxNoContentMethod(ajaxObject) ) { + sourceSign.keepUnwrapped = true; + } + } - if ( - ajaxObject.data.indexOf('action=new_activity_comment') !== -1 - ) { - sourceSign.found = 'action=new_activity_comment'; - } - if ( - ajaxObject.data.indexOf('action=wwlc_create_user') !== -1 - ) { - sourceSign.found = 'action=wwlc_create_user'; - } - if ( - ajaxObject.data.indexOf('action=WPBC_AJX_BOOKING__CREATE') !== -1 - ) { - sourceSign.found = 'action=WPBC_AJX_BOOKING__CREATE'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; - } - if ( - ajaxObject.data.indexOf('action=drplus_signup') !== -1 - ) { - sourceSign.found = 'action=drplus_signup'; - sourceSign.keepUnwrapped = true; - } - if ( - ajaxObject.data.indexOf('action=bt_cc') !== -1 - ) { - sourceSign.found = 'action=bt_cc'; - sourceSign.keepUnwrapped = true; + return sourceSign; + } + + /** + * Inject CleanTalk data into jQuery ajax payload of any supported type. + * @param {object} sourceSign + * @param {*} ajaxData + * @param {object=} ajaxOptions jQuery ajax options (traditional, processData, contentType). + * Keep URLSearchParams/objects when processData or contentType is false. + * URLSearchParams must also disable processData, or jQuery.param() later yields "". + * GET/HEAD never keep the original type: jQuery only puts string data on the URL. + * @return {*} + */ + injectCleantalkDataToJQAjax(sourceSign, ajaxData, ajaxOptions) { + const traditional = ajaxOptions && ajaxOptions.traditional; + const keepOriginalType = !this.isJQAjaxNoContentMethod(ajaxOptions) && !!(ajaxOptions && ( + ajaxOptions.processData === false || + ajaxOptions.contentType === false + )); + + if ( ajaxData === null || typeof ajaxData === 'undefined' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ''); + } + if ( typeof ajaxData === 'string' ) { + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData); + } + if ( this.isJQAjaxPlainObjectOrArray(ajaxData) ) { + if ( keepOriginalType ) { + if ( Object.prototype.toString.call(ajaxData) === '[object Array]' ) { + if ( this.isJQAjaxSerializeArray(ajaxData) ) { + return this.injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData); + } + return ajaxData; } - if ( - ajaxObject.data.indexOf('action=wpr_form_builder_email') !== -1 - ) { - sourceSign.found = 'action=wpr_form_builder_email'; - sourceSign.keepUnwrapped = true; + return this.injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData); + } + try { + if ( typeof jQuery !== 'undefined' && typeof jQuery.param === 'function' ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + jQuery.param(ajaxData, traditional), + ); } - if ( - ajaxObject.data.indexOf('action=nf_ajax_submit') !== -1 - ) { - sourceSign.found = 'action=nf_ajax_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + } catch (e) { + return ajaxData; + } + return ajaxData; + } + if ( this.isJQAjaxURLSearchParams(ajaxData) ) { + if ( keepOriginalType ) { + this.preserveJQAjaxURLSearchParamsOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxKeyValue( + sourceSign, + this.cloneURLSearchParams(ajaxData), + ); + } + return this.injectCleantalkDataToJQAjaxString(sourceSign, ajaxData.toString()); + } + if ( this.isJQAjaxFormData(ajaxData) ) { + if ( this.isJQAjaxNoContentMethod(ajaxOptions) ) { + return this.injectCleantalkDataToJQAjaxString( + sourceSign, + this.serializeJQAjaxKeyValueBag(ajaxData), + ); + } + this.preserveJQAjaxFormDataOptions(ajaxOptions); + return this.injectCleantalkDataToJQAjaxFormData( + sourceSign, + this.cloneFormData(ajaxData), + ); + } + return ajaxData; + } + + /** + * GET/HEAD have no body. Missing type is GET (jQuery default). + * @param {object=} ajaxOptions + * @return {boolean} + */ + isJQAjaxNoContentMethod(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return false; + } + const type = ajaxOptions.type || ajaxOptions.method; + if ( typeof type !== 'string' || type === '' ) { + return true; + } + const method = type.toUpperCase(); + return method === 'GET' || method === 'HEAD'; + } + + /** + * Collect CleanTalk fields to append to a key/value payload. + * @param {object} sourceSign + * @return {Array.>} + */ + getCleantalkJQAjaxFieldPairs(sourceSign) { + const pairs = []; + const wrapKey = function(key) { + return sourceSign.keepUnwrapped ? key : 'data[' + key + ']'; + }; + + if ( + +ctPublic.bot_detector_enabled && + apbctLocalStorage.get('bot_detector_event_token') + ) { + const token = this.toolGetEventToken(); + if ( token ) { + pairs.push([wrapKey('ct_bot_detector_event_token'), token]); + } + } else { + const noCookieData = getNoCookieData(); + if ( noCookieData ) { + pairs.push([wrapKey('ct_no_cookie_hidden_field'), noCookieData]); + } + } + + const browserState = apbctGetBrowserStatePair(); + if ( browserState ) { + const browserStateKey = sourceSign.keepUnwrapped ? + browserState.key : + 'data[' + browserState.key + ']'; + pairs.push([browserStateKey, browserState.value]); + } + + return pairs; + } + + /** + * jQuery.param(FormData) after the prefilter yields "". Keep the body as FormData. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxFormDataOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + ajaxOptions.contentType = false; + } + + /** + * jQuery.param(URLSearchParams) after the prefilter yields "". Keep the body as URLSearchParams. + * @param {object=} ajaxOptions + * @return {void} + */ + preserveJQAjaxURLSearchParamsOptions(ajaxOptions) { + if ( !ajaxOptions || typeof ajaxOptions !== 'object' ) { + return; + } + ajaxOptions.processData = false; + } + + /** + * Read a FormData field via get(), forEach(), or entries(). + * Native IE11 FormData is write-only and cannot be read. + * @param {FormData} formData + * @param {Array.} keys + * @return {*} + */ + getFormDataField(formData, keys) { + if ( typeof formData.get === 'function' ) { + for ( let i = 0; i < keys.length; i++ ) { + const value = formData.get(keys[i]); + if ( value !== null && typeof value !== 'undefined' ) { + return value; } - if ( - ajaxObject.data.indexOf('action=uael_register_user') !== -1 && - ctPublic.data__cookies_type === 'none' - ) { - sourceSign.found = 'action=uael_register_user'; - sourceSign.keepUnwrapped = true; + } + } + if ( typeof formData.forEach === 'function' ) { + let found = null; + formData.forEach(function(value, key) { + if ( found !== null ) { + return; } - if ( - ajaxObject.data.indexOf('action=SQBSubmitQuizAjax') !== -1 - ) { - sourceSign.found = 'action=SQBSubmitQuizAjax'; - sourceSign.keepUnwrapped = true; + for ( let i = 0; i < keys.length; i++ ) { + if ( key === keys[i] ) { + found = value; + return; + } } - if ( - ajaxObject.data.indexOf('action=user_registration_user_form_submit') !== -1 - ) { - sourceSign.found = 'action=user_registration_user_form_submit'; - sourceSign.keepUnwrapped = true; - sourceSign.attachVisibleFieldsData = true; + }); + if ( found !== null ) { + return found; + } + } + if ( typeof formData.entries === 'function' ) { + try { + const iterator = formData.entries(); + if ( iterator && typeof iterator.next === 'function' ) { + let step = iterator.next(); + while ( !step.done ) { + const pair = step.value; + if ( pair ) { + for ( let i = 0; i < keys.length; i++ ) { + if ( pair[0] === keys[i] ) { + return pair[1]; + } + } + } + step = iterator.next(); + } } + } catch (e) { + return null; + } + } + return null; + } + + /** + * Clone URLSearchParams so the caller's instance is not mutated. + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + cloneURLSearchParams(params) { + const serialized = typeof params.toString === 'function' ? params.toString() : ''; + if ( typeof params.constructor === 'function' && params.constructor !== Object ) { + try { + return new params.constructor(serialized); + } catch (e) { + // Fall through to the current-window constructor. + } + } + if ( typeof URLSearchParams === 'function' ) { + try { + return new URLSearchParams(serialized); + } catch (e) { + return params; + } + } + return params; + } + + /** + * Clone FormData when it can be enumerated (forEach or entries); otherwise reuse. + * @param {FormData} formData + * @return {FormData} + */ + cloneFormData(formData) { + try { + const clone = new FormData(); + const copied = this.forEachJQAjaxKeyValueBag(formData, function(value, key) { + clone.append(key, value); + }); + if ( copied ) { + return clone; + } + } catch (e) { + return formData; + } + return formData; + } + + /** + * Form-urlencoded string from FormData/URLSearchParams. Skip File/Blob values. + * @param {FormData|URLSearchParams} bag + * @return {string} + */ + serializeJQAjaxKeyValueBag(bag) { + const parts = []; + const collected = this.forEachJQAjaxKeyValueBag(bag, function(value, key) { + if ( typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { + return; } - // wooocommerce add to cart is based on URL - if ( typeof ajaxObject.url === 'string' ) { - if (ajaxObject.url.indexOf('wc-ajax=add_to_cart') !== -1) { - sourceSign.found = 'wc-ajax=add_to_cart'; + parts.push(encodeURIComponent(String(key)) + '=' + encodeURIComponent(String(value))); + }); + if ( collected ) { + return parts.join('&'); + } + return ''; + } + + /** + * Inject CleanTalk fields into URLSearchParams without changing the payload type. + * @param {object} sourceSign + * @param {URLSearchParams} params + * @return {URLSearchParams} + */ + injectCleantalkDataToJQAjaxKeyValue(sourceSign, params) { + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + params.append(pairs[i][0], pairs[i][1]); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( extractor ) { + const extracted = extractor.extract(params.toString()); + if ( typeof extracted === 'string' ) { + params.append('apbct_visible_fields', extracted); } } } + return params; + } - // on ajaxPrefilter - if (catchOn === 'ajaxPrefilter') { - if (typeof ajaxObject.data === 'string') { - if (ajaxObject.data.indexOf('action=bloom_subscribe') !== -1) { - sourceSign.found = 'action=bloom_subscribe'; - sourceSign.keepUnwrapped = true; + /** + * Inject CleanTalk fields into a jQuery serializeArray payload. + * @param {object} sourceSign + * @param {Array} ajaxData + * @return {Array} + */ + injectCleantalkDataToJQAjaxSerializeArray(sourceSign, ajaxData) { + const result = ajaxData.slice(); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result.push({ + name: pairs[i][0], + value: pairs[i][1], + }); + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); + if ( + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' + ) { + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.push({ + name: 'apbct_visible_fields', + value: extracted, + }); } } + } + return result; + } + /** + * Inject CleanTalk fields into a plain object without changing the payload type. + * @param {object} sourceSign + * @param {object} ajaxData + * @return {object} + */ + injectCleantalkDataToJQAjaxPlainObject(sourceSign, ajaxData) { + const result = typeof jQuery !== 'undefined' && typeof jQuery.extend === 'function' ? + jQuery.extend({}, ajaxData) : + this.clonePlainObject(ajaxData); + const pairs = this.getCleantalkJQAjaxFieldPairs(sourceSign); + for ( let i = 0; i < pairs.length; i++ ) { + result[pairs[i][0]] = pairs[i][1]; + } + if ( sourceSign.attachVisibleFieldsData ) { + const extractor = ApbctVisibleFieldsExtractor.createExtractor(sourceSign.found); if ( - typeof ajaxObject.data === 'object' && - ajaxObject.data !== null && - typeof ajaxObject.data.get === 'function' + extractor && + typeof jQuery !== 'undefined' && + typeof jQuery.param === 'function' ) { - if (ajaxObject.data.get('action') === 'pafe_ajax_form_builder') { - sourceSign.found = 'action=pafe_ajax_form_builder'; - sourceSign.keepUnwrapped = true; + const extracted = extractor.extract(jQuery.param(ajaxData)); + if ( typeof extracted === 'string' ) { + result.apbct_visible_fields = extracted; } } } + return result; + } - return sourceSign; + /** + * IE11-safe shallow copy of a plain object. + * @param {object} ajaxData + * @return {object} + */ + clonePlainObject(ajaxData) { + const result = {}; + for ( const key in ajaxData ) { + if ( Object.prototype.hasOwnProperty.call(ajaxData, key) ) { + result[key] = ajaxData[key]; + } + } + return result; } /** @@ -1352,8 +2134,7 @@ class ApbctHandler { injectCleantalkDataToJQAjaxFormData(sourceSign, ajaxDataFormData) { if ( typeof sourceSign !== 'object' || - typeof ajaxDataFormData !== 'object' || - !(ajaxDataFormData instanceof FormData) + !this.isJQAjaxFormData(ajaxDataFormData) ) { return ajaxDataFormData; } @@ -1401,13 +2182,10 @@ class ApbctHandler { if (extractor) { // Try to find form_id in FormData to find form container and // collect visible fields only inside it - let formId = null; - for (let pair of ajaxDataFormData.entries()) { - if (pair[0] === 'form_id' || pair[0] === 'data[form_id]') { - formId = pair[1]; - break; - } - } + const formId = this.getFormDataField( + ajaxDataFormData, + ['form_id', 'data[form_id]'], + ); let container = null; if (formId && typeof formId === 'string') { // Sanitize formId to prevent selector injection @@ -1477,9 +2255,9 @@ class ApbctHandler { } else { noCookieData = getNoCookieData(); if (sourceSign.keepUnwrapped) { - noCookieData = 'ct_no_cookie_hidden_field=' + noCookieData + '&'; + noCookieData = 'ct_no_cookie_hidden_field=' + encodeURIComponent(noCookieData) + '&'; } else { - noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData + '&'; + noCookieData = 'data%5Bct_no_cookie_hidden_field%5D=' + encodeURIComponent(noCookieData) + '&'; } }