!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).CaptchaLoader={})}(this,(function(e){"use strict";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"custom";(n=Object.assign({},d,n)).businessSpmid||(n.businessSpmid=u()),i({type:o,event:e,msg:n})}(e,Object.assign({time:o},n)),delete l[e]}}function m(e,n){try{var o=e()}catch(e){return n(e)}return o&&o.then?o.then(void 0,n):o}var h=function(e){try{if(window._loadLogicPromise_)return Promise.resolve(window._loadLogicPromise_);return window._loadLogicPromise_=function(){try{return Promise.resolve(m((function(){return _("logic"),Promise.resolve(function(e){return new Promise((function(n,o){var r=document.createElement("script");r.src=e,r.onload=function(){n()},r.onerror=function(){o()},document.body.appendChild(r)}))}(e)).then((function(){var e=window.useCaptcha;return delete window.useCaptcha,w("logic",{result:"success"}),e}))}),(function(){throw window._loadLogicPromise_=null,w("logic",{result:"failure",url:e}),new Error("加载脚本失败")})))}catch(e){return Promise.reject(e)}}(),Promise.resolve(window._loadLogicPromise_)}catch(e){return Promise.reject(e)}},P=function(){try{if(window._loadConfigPromise_)return Promise.resolve(window._loadConfigPromise_);return window._loadConfigPromise_=function(){try{return Promise.resolve(m((function(){return _("config"),Promise.resolve(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{method:"GET",headers:{}},o=n.method,r=n.headers,t=n.data;return new Promise((function(n,i){var s=new XMLHttpRequest;for(var c in s.onreadystatechange=function(){if(4===this.readyState&&200===this.status)try{n(JSON.parse(this.response||this.responseText))}catch(e){n(this.response||this.responseText)}else 4===this.readyState&&i()},s.onerror=i,s.ontimeout=i,s.withCredentials=!0,s.open(o,e),r)s.setRequestHeader(c,r[c]);s.send(t)}))}(v)).then((function(e){return w("config",{result:"success"}),e}))}),(function(){throw window._loadConfigPromise_=null,w("config",{result:"failure"}),new Error("加载配置失败")})))}catch(e){return Promise.reject(e)}}(),Promise.resolve(window._loadConfigPromise_)}catch(e){return Promise.reject(e)}},v="//api.bilibili.com/x/web-frontend/risk/config";window._loadConfigPromise_=window._loadConfigPromise_||null,window._loadLogicPromise_=window._loadLogicPromise_||null,e.load=function(){return Promise.resolve(P()).then((function(e){var n=e.logic;return h(n)}))}}));