PageSourceSearch

https://stackable.tech/wp-content/plugins/prosopo-procaptcha/dist/…/procaptcha/procaptcha-integration.min.js

js stackable.tech collected 2026-10-03 22:44:42 UTC 6,888 bytes, 1 lines download raw bytes

1class u{constructor(e){this.logger=e}registerWebComponent(e,t){const n=this.createWebComponentClass(e,this.logger,t);customElements.define(t.name,n)}createWebComponentClass(e,t,n){class o extends HTMLElement{constructor(){super(),this.isSetup=!1}connectedCallback(){const r=this.isSetup===!0;if(r===!0&&n.processIfReconnected===!1){t.debug("connectedCallback() is fired for the instance that was already setup, ignoring according to the component settings",{name:n.name,element:this});return}if(this.isSetup=!0,this.isDocumentReady(document.readyState,n.waitWindowLoadedInsteadOfDomLoaded)===!0){t.debug("connectedCallback() is fired, processing",{name:n.name,wasAlreadySetup:r,element:this}),this.constructElement();return}t.debug("connectedCallback() is fired, but document is not ready, delaying processing",{name:n.name,wasAlreadySetup:r,waitWindowLoadedInsteadOfDomLoaded:n.waitWindowLoadedInsteadOfDomLoaded,element:this}),this.scheduleElementConstruction()}constructScheduledElement(){t.debug("document is ready, running scheduled WebComponent construction",{name:n.name,element:this}),this.constructElement()}constructElement(){e.constructComponent(this)}isDocumentReady(r,a){return a===!0?this.isDocumentLoaded(r):this.isDocumentInteractive(r)}isDocumentLoaded(r){return r==="complete"}isDocumentInteractive(r){return["interactive","complete"].includes(r)===!0}scheduleElementConstruction(){if(n.waitWindowLoadedInsteadOfDomLoaded===!0){window.addEventListener("load",this.constructScheduledElement.bind(this));return}document.addEventListener("DOMContentLoaded",this.constructScheduledElement.bind(this))}}return o}}class d{constructor(e,t,n){this.loggerFactory=e,this.moduleLogger=t,this.webComponentRegistrar=n}connectIntegration(e){const t=this.loggerFactory.createLogger(e.name,this.moduleLogger),n=e.createWebComponent(t),o=e.getWebComponentSettings();this.webComponentRegistrar.registerWebComponent(n,o)}}var c=(s=>(s.DEBUG="DEBUG",s.WARNING="WARNING",s))(c||{});class p{constructor(e,t,n){this.module=e,this.moduleLogger=t,this.isDebugMode=n,this.debug("Debug logging is enabled")}log(e,t,n){c.DEBUG===e&&this.isDebugMode===!1||this.moduleLogger.log(this.module,e,t,n)}debug(e,t){this.log(c.DEBUG,e,t)}warning(e,t){this.log(c.WARNING,e,t)}}class g{createLogger(e,t){return new p(e,t,this.isDebugMode())}isDebugMode(){return window.localStorage.getItem("_wp_procaptcha_debug_mode")!==null}}class h{log(e,t,n,o={}){console.log(`WP Procaptcha (${e}) [${t}]: ${n}`),Object.keys(o).length!==0&&console.log(o)}debug(e,t,n){this.log(e,c.DEBUG,t,n)}warning(e,t,n){this.log(e,c.WARNING,t,n)}}function m(){const s=new g,e=new h,t=s.createLogger("web-component-registrar",e),n=new u(t);return new d(s,e,n)}class b{constructor(e){this.logger=e}constructComponent(e){const t=e.closest("form");if(t===null){this.logger.warning("Form for setting up the validation is not found.",{element:e});return}t.addEventListener("submit",this.preventSubmissionWithoutToken.bind(this,e)),e.addEventListener("_procaptcha-filled",this.setErrorElementVisibility.bind(this,e,!1)),this.logger.debug("Form validation is setup",{element:e,form:t})}preventSubmissionWithoutToken(e,t){const n=t.target,o=this.isStdCaptchaResponseInputPresent(n),i=this.isCustomCaptchaResponseIsPresent(n),r=n.classList.contains("prosopo-procaptcha__no-client-validation"),a={isStdCaptchaResponseInputPresent:o,isCustomCaptchaResponseIsPresent:i,isBypassing:r,origin:e,form:n};if(o==!0||i===!0||r===!0){this.logger.debug("Submission validation is passed",a);return}this.logger.debug("Submission validation is failed",a),t.preventDefault(),t.stopPropagation(),this.setErrorElementVisibility(e,!0)}isStdCaptchaResponseInputPresent(e){return e.querySelector('input[name="procaptcha-response"]')!==null}isCustomCaptchaResponseIsPresent(e){const t=e.querySelector("input.prosopo-procaptcha-input");return t instanceof HTMLInputElement&&t.value!==""}setErrorElementVisibility(e,t){const n=this.getErrorElement(e);if(n===null){this.logger.warning("Error element is not found.",{origin:e});return}this.setElementVisibility(n,t),this.logger.debug("Set error element visibility",{isVisible:t,origin:e,errorElement:n})}getErrorElement(e){return e.querySelector(".prosopo-procaptcha-wp-form__error")}setElementVisibility(e,t){e.style.visibility=t===!0?"visible":"hidden"}}class f{constructor(e){this.logger=e}constructComponent(e){const t=this.getProcaptchaServiceCallback();if(t===null){this.logger.warning("Procaptcha service script is not available.");return}const n=this.getCaptchaElement(e);
1if(n===null){this.logger.warning("Inner captcha container is missing.");return}const o=this.getCaptchaAttributes(e);this.logger.debug("Rendering",{captchaElement:n,captchaAttributes:o}),t(n,o)}updateRelatedFormOnSuccessfulValidation(e,t){this.logger.debug("Token received",{token:t});const n=e.closest("form"),o=this.getCustomInputForToken(e,n),i=this.getValidationElement(e);o!==null?this.setInputValue(o,t):this.logger.debug("No custom input found"),this.dispatchFilledEvent(e,t),i!==null?this.dispatchValidationFilledEvent(i):this.logger.debug("No validation element found")}getProcaptchaServiceCallback(){return window.hasOwnProperty("procaptcha")===!1||typeof window.procaptcha!="object"||typeof window.procaptcha.render!="function"?null:window.procaptcha.render}getCaptchaElement(e){return e.querySelector(".prosopo-procaptcha")}getCaptchaAttributes(e){const t=window.hasOwnProperty("procaptchaWpAttributes")===!0&&typeof window.procaptchaWpAttributes=="object"?window.procaptchaWpAttributes:{};return Object.assign(t,{callback:this.updateRelatedFormOnSuccessfulValidation.bind(this,e)})}dispatchFilledEvent(e,t){e.dispatchEvent(new CustomEvent("_prosopo-procaptcha__filled",{bubbles:!0,detail:{token:t}})),this.logger.debug("Dispatched filled event",{token:t})}getCustomInputForToken(e,t){var o;const n=t!==null?t.querySelector(".prosopo-procaptcha-input"):(o=e.parentElement)==null?void 0:o.querySelector(".prosopo-procaptcha-input");return n instanceof HTMLInputElement?n:null}getValidationElement(e){var t;return((t=e.parentElement)==null?void 0:t.querySelector(".prosopo-procaptcha-wp-form"))||null}dispatchValidationFilledEvent(e){e.dispatchEvent(new CustomEvent("_procaptcha-filled")),this.logger.debug("Dispatched validation filled event",{validationElement:e})}setInputValue(e,t){e.value=t,e.dispatchEvent(new Event("change",{bubbles:!0})),this.logger.debug("Set input value",{input:e,value:t})}}const l=m(),w={name:"form",createWebComponent:s=>new b(s),getWebComponentSettings:()=>({name:"prosopo-procaptcha-wp-form",processIfReconnected:!1,waitWindowLoadedInsteadOfDomLoaded:!1})},C={name:"widget",createWebComponent:s=>new f(s),getWebComponentSettings:()=>({name:"prosopo-procaptcha-wp-widget",processIfReconnected:!1,waitWindowLoadedInsteadOfDomLoaded:!0})};l.connectIntegration(w);l.connectIntegration(C);export{m as c};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.