katoikia-app/web-ui/web-react/node_modules/primereact/captcha/captcha.esm.min.js

2 lines
3.8 KiB
JavaScript

import t,{Component as e}from"react";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e){return o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},o(t,e)}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return a(t)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}var l,f,h,y=function(o){i(d,e);var c,a,l,f,h,y=(c=d,a=s(),function(){var t,e=u(c);if(a){var n=u(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return p(this,t)});function d(){return n(this,d),y.apply(this,arguments)}return l=d,(f=[{key:"init",value:function(){var t=this;this._instance=window.grecaptcha.render(this.targetEL,{sitekey:this.props.siteKey,theme:this.props.theme,type:this.props.type,size:this.props.size,tabindex:this.props.tabIndex,hl:this.props.language,callback:function(e){t.recaptchaCallback(e)},"expired-callback":function(){t.recaptchaExpiredCallback()}})}},{key:"reset",value:function(){null!==this._instance&&window.grecaptcha.reset(this._instance)}},{key:"getResponse",value:function(){return null===this._instance?null:window.grecaptcha.getResponse(this._instance)}},{key:"recaptchaCallback",value:function(t){this.props.onResponse&&this.props.onResponse({response:t})}},{key:"recaptchaExpiredCallback",value:function(){this.props.onExpire&&this.props.onExpire()}},{key:"addRecaptchaScript",value:function(){var t=this;if(this.recaptchaScript=null,!window.grecaptcha){var e=document.head||document.getElementsByTagName("head")[0];this.recaptchaScript=document.createElement("script"),this.recaptchaScript.src="https://www.google.com/recaptcha/api.js?render=explicit",this.recaptchaScript.async=!0,this.recaptchaScript.defer=!0,this.recaptchaScript.onload=function(){window.grecaptcha?window.grecaptcha.ready((function(){t.init()})):console.warn("Recaptcha is not loaded")},e.appendChild(this.recaptchaScript)}}},{key:"componentDidMount",value:function(){this.addRecaptchaScript(),window.grecaptcha&&this.init()}},{key:"componentWillUnmount",value:function(){this.recaptchaScript&&this.recaptchaScript.parentNode.removeChild(this.recaptchaScript)}},{key:"render",value:function(){var e=this;return t.createElement("div",{id:this.props.id,ref:function(t){return e.targetEL=t}})}}])&&r(l.prototype,f),h&&r(l,h),Object.defineProperty(l,"prototype",{writable:!1}),d}();h={id:null,siteKey:null,theme:"light",type:"image",size:"normal",tabIndex:0,language:"en",onResponse:null,onExpire:null},(f="defaultProps")in(l=y)?Object.defineProperty(l,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):l[f]=h;export{y as Captcha};