3 lines
2.5 KiB
Plaintext
Executable File
3 lines
2.5 KiB
Plaintext
Executable File
define("@wsb/guac-widget-shared/lib/components/Recaptcha/recaptcha-loader-481e2d0a.js",["exports","~/c/_rollupPluginBabelHelpers"],(function(e,t){"use strict";const s="https://www.google.com/recaptcha/api.js",o="recaptcha-script",c=()=>({siteKey:null,siteKeyRequested:!1,siteKeyCallbacks:[],scriptCallbacks:[]});function i(){window.grecaptcha.ready((()=>{const e=window.wsb.recaptcha.scriptCallbacks;for(;e.length;){e.pop()()}}))}function a(){window.wsb&&window.wsb.recaptcha||(window.wsb=window.wsb||{},window.wsb.recaptcha=c())}function n(e,t){a();const{recaptcha:s}=window.wsb;if(s.siteKey)return void t(s.siteKey);if(function(e){window.wsb.recaptcha.siteKeyCallbacks.push(e)}(t),s.siteKeyRequested)return;s.siteKeyRequested=!0;const o=new XMLHttpRequest;o.open("GET",e),o.send(),o.onreadystatechange=()=>function(e){if(4!==e.readyState||!(global._||guac.lodash).includes([200,304],e.status))return;const t=JSON.parse(e.responseText),{recaptcha:s}=window.wsb,o=s.siteKeyCallbacks;if(t.siteKey)for(s.siteKey=t.siteKey;o.length;)o.pop()(s.siteKey)}(o)}function r(e,t){let{siteKey:c}=e;var n;(a(),void 0!==window.grecaptcha&&window.grecaptcha.execute)?t():(n=t,window.wsb.recaptcha.scriptCallbacks.push(n),document.querySelector(`#${o}`)||function(e){const t=document.createElement("script");t.setAttribute("src",`${s}?render=${encodeURIComponent(e)}`),t.setAttribute("id",o),t.setAttribute("async",!0),t.setAttribute("defer",!0),t.onload=i,document.body.appendChild(t)}(c))}class p extends(global.React||guac.react).Component{constructor(){super(...arguments),t.a(this,"hideRecaptchaBadge",(()=>{const e=document.querySelector(".grecaptcha-badge");e&&e.setAttribute("hidden",!0)})),t.a(this,"loadRecaptcha",(e=>{r({siteKey:e},(()=>{this.execute=()=>{window.grecaptcha.execute(e,{action:"formSubmit"}).then(this.props.onComplete)},this.hideRecaptchaBadge()}))}))}componentDidMount(){this.execute=this.props.onComplete,this.props.formSubmitHost&&n(this.siteKeyUrl,this.loadRecaptcha)}get siteKeyUrl(){return`${this.props.formSubmitHost}${this.props.formSubmitEndpoint}`}render(){return null}}p.propTypes={onComplete:(global.PropTypes||guac["prop-types"]).func.isRequired,formSubmitHost:(global.PropTypes||guac["prop-types"]).string.isRequired,formSubmitEndpoint:(global.PropTypes||guac["prop-types"]).string},p.defaultProps={formSubmitEndpoint:"/v3/recaptcha"},e.default=p,Object.defineProperty(e,"__esModule",{value:!0})})),"undefined"!=typeof window&&(window.global=window);
|
|
//# sourceMappingURL=recaptcha-loader-481e2d0a.js.map
|