!function(t,e){if("function"==typeof define&&define.amd)define([],e);else if("undefined"!=typeof exports)e();else{e(),t.unknown={}}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(){var t=function(t){"undefined"!=typeof window&&window.__BILI_X_ENGINE_SCRIPT_CACHE__&&void 0!==window.__BILI_X_ENGINE_SCRIPT_CACHE__[t]&&delete window.__BILI_X_ENGINE_SCRIPT_CACHE__[t]},e=function(e,n){if("undefined"==typeof window)return Promise.reject(new Error("window is not defined"));var i,o=e=e.replace(/^https?:\/\//,"//"),r=(i=o,"undefined"==typeof window?null:window.__BILI_X_ENGINE_SCRIPT_CACHE__&&window.__BILI_X_ENGINE_SCRIPT_CACHE__[i]||null);if(null!=r&&r.promise)return r.promise;var a=new Promise((function(t,i){var o=document.createElement("script");o.src=e,null!=n&&n.behavior&&o.setAttribute(n.behavior,""),o.onload=function(){var o=window;if(n.lib)return o[n.lib]?t(o[n.lib]):i(new Error('Failed to access library "'+n.lib+'" from '+e));t(null)},o.onerror=function(){i(new Error("Failed to load "+e)),document.head.removeChild(o)},document.head.appendChild(o)}));return function(t,e){"undefined"!=typeof window&&(window.__BILI_X_ENGINE_SCRIPT_CACHE__||(window.__BILI_X_ENGINE_SCRIPT_CACHE__={}),window.__BILI_X_ENGINE_SCRIPT_CACHE__[t]=e)}(o,{promise:a,lib:null==n?void 0:n.lib}),a.then((function(){!1===(null==n?void 0:n.cache)&&t(o)})).catch((function(){!1===(null==n?void 0:n.cache)&&t(o)})),a},n=function(t){return Promise.resolve(function(){try{return window.KvSDK?Promise.resolve(window.KvSDK):Promise.resolve(e("//s1.hdslb.com/bfs/seed/jinkela/kv-sdk/index.js",{lib:"KvSDK"}))}catch(t){return Promise.reject(t)}}()).then((function(e){return new e(t)}))};function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e":">",'"':""","'":"'","`":"`"},u.HTML_UNESCAPES={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},u.ID_CHAR_SET={number:"0123456789",letter:"abcdefghijklmnopqrstuvwxyz",special:"~`!@#$%^&*()-_+=[]{};:\"',<.>/?"},u.RE_BASE64=/^((data:.*;)?base64,)?([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,u.RE_CN_CHAR=/^[\u4e00-\u9fa5]*$/,u.RE_DB_CHAR=/^[^x00-xff]*$/,u.RE_DOMAIN=/^([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6}$/,u.RE_EMAIL=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,u.RE_ID_CARD=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$/,u.RE_ID_CARD_V1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/,u.RE_ID_CARD_V2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$/,u.RE_IPV4=/^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/,u.RE_MONTH=/^(0?[1-9]|1[0-2])$/,u.RE_MONTH_DAY=/^((0?[1-9])|((1|2)[0-9])|30|31)$/,u.RE_PHONE=/^(\+?0?86-?)?1[3456789]\d{9}$/,u.RE_PROT=/^[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]$/,u.RE_QQ=/^[1-9][0-9]{4,}$/,u.RE_TEL=/^((\d{3,4})|\d{3,4}-)?\d{7,8}?$/,u.RE_URL=/^(https?:)?(\/\/)?(((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1-6})?([-0-9a-zA-Z+&@#/%=~_|?!:,.;]*)?$/,u.RE_URL_DOMAIN=/^(https?:)?\/\/([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6}(:[0-9]{1-6})?([-0-9a-zA-Z+&@#/%=~_|?!:,.;]*)?$`/,u.RE_URL_IP=/^(https?:)?\/\/((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)(:[0-9]{1-6})?([-0-9a-zA-Z+&@#/%=~_|?!:,.;]*)?$`/,u.RE_URL_SUFFIX=/^[-0-9a-zA-Z+&@#/%=~_|?!:,.;]*$/,u.RE_UUID=/^[0-9a-zA-Z]{8}-([0-9a-zA-Z]{4}-){3}[0-9a-zA-Z]{12}$/,u.RE_ZIP_CODE=/^[1-9]\d{5}(?!\d)$/;var h,p,m,g,v=_((function(t,e){var n="number"==typeof t;return e?n:n&&!Number.isNaN(t)&&Number.isFinite(t)})),w=_((function(t){return"string"==typeof t})),b=u,y=function(t,e,n){var i="",o=0;if(!1!==(n=n||{}).encode&&(e=encodeURIComponent(e)),v(n.exMinuts)&&(o+=6e4*n.exMinuts),v(n.exDays)&&(o+=n.exDays*b.DAY_TIME),o){var r=new Date;r.setTime(r.getTime()+o),i=";expires=".concat(r.toUTCString())}var a=w(n.domain)?";domain=".concat(n.domain):"";document.cookie="".concat(t,"=").concat(e).concat(i,";path=/").concat(a)},E=(h=y)&&"object"==d(h)&&"default"in h?h.default:h;(p||(p={})).I="i",function(t){t.Off="0",t.On="1"}(m||(m={})),function(t){t[t.Goahead=0]="Goahead",t[t.Last=1]="Last",t[t.End=2]="End"}(g||(g={}));var I="bmg_af_wl",A="bmg_af_dft",C="bmg_af_switch",R="bmg_src_def_domain",S=function(){function t(t){if(this.defDomain="",this.on=!1,this.config={fr:!1,def:"",dl:[]},this.wl=[],this.defUpdated=!1,this.connectivities={},this.x=1,"undefined"!=typeof window)return this.defFallbackThreshold=(null==t?void 0:t.defFallbackThreshold)||Number(this.getLocalStorage(A,!0)||"5"),window.__BMG_AF__?(this.config=window.__BMG_AF__.config,this.defDomain=window.__BMG_AF__.defDomain,this.x=window.__BMG_AF__.x,this.on=window.__BMG_AF__.on,this):(window.__BMG_AF__=this,this.on=l(C,{decode:!1})===m.On,this.on&&(this.defDomain=l(R,{decode:!1})),this.getX(document.cookie),this.initConfig(!0),void this.syncConfig());this.defFallbackThreshold=(null==t?void 0:t.defFallbackThreshold)||5,(null==t?void 0:t.cookie)&&(this.on=l(C,{template:t.cookie,decode:!1})===m.On,this.on&&(this.defDomain=l(R,{template:t.cookie,decode:!1})),this.getX(t.cookie)),this.initConfig(!1)}return t.prototype.getX=function(t){var e="",n=l("buvid3",{template:t,decode:!1});if(n&&(e=n.substring(0,2)),e){var i=parseInt(e,16);isNaN(i)||(this.x=Math.round(i/2.56))}},t.prototype.checkWlConfig=function(e){try{var n=!0,i=JSON.parse(e);if(Array.isArray(i)&&i.length)for(var o=0;o-1&&(n.splice(r,1),n.unshift(i),o=i)}else e&&y(R,o);this.defDomain=o,this.config={fr:!1,def:o,dl:n}}}},t.prototype.getDomain=function(t,e,n){return void 0===n&&(n=".hdslb.com"),"".concat(t).concat(e).concat(n)},t.prototype.getDl=function(t,e){var n=this,i=this.x,o=e.map((function(t,e){return{n:t*Math.random(),i:e}})).filter((function(t){return t.n>0}));if(i<100||i>=0){for(var r=e.reduce((function(t,e){return t+e}),0),a=0,c=0;ac))break;if(f>=i)break;c=f}o[a].n=r}return o.sort((function(t,e){return e.n-t.n})).map((function(e){var i=e.i;return n.getDomain(t,i)}))},Object.defineProperty(t.prototype,"domainRegExp",{get:function(){return new RegExp(this.getDomain("(s|i)","\\d"))},enumerable:!1,configurable:!0}),t.prototype.recordConnectivity=function(t,e){if("undefined"!=typeof window&&window.__BMG_AF__){var n=this.config.def,i=t.match(this.domainRegExp);if(null==i?void 0:i[0]){var o=null==i?void 0:i[0];o in this.connectivities?this.connectivities[o][e?"success":"fail"]++:this.connectivities[o]={success:Number(e),fail:Number(!e),fallback:o!==n};var r=this.connectivities[o],a=r.fallback,c=r.success,f=(this.connectivities[n]||{fail:0}).fail;a&&!this.defUpdated&&c&&f>this.defFallbackThreshold&&this.updateDefDomain(o)}}},t.prototype.updateDefDomain=function(t){this.defDomain=t,this.config.def=t;var e=this.config.dl.indexOf(t);e>-1&&1!==e&&(this.config.dl.splice(e,1),this.config.dl.splice(1,0,t)),y(R,t),this.dispatchEvent("bmg-src-default-domain-change",{domain:t}),this.defUpdated=!0},t.prototype.getNext=function(t){if(!this.on)return null;if(!this.config.def)return null;var e=t.match(this.domainRegExp);if(null==e?void 0:e[0]){var n=this.config.dl,i=n.indexOf(e[0]);if(i>-1){var o=-1===t.indexOf("/bfs/");return i===n.length-1?o||-1===t.indexOf("@")?null:{src:t.split("@")[0],strategy:g.End}:{src:t.replace(this.domainRegExp,n[i+1]),strategy:i===n.length-2?o?g.End:g.Last:g.Goahead}}}return null},t.prototype.syncConfig=function(){return function(t,e,n,i){return new(n||(n=Promise))((function(o,r){function a(t){try{f(i.next(t))}catch(t){r(t)}}function c(t){try{f(i.throw(t))}catch(t){r(t)}}function f(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}f((i=i.apply(t,e||[])).next())}))}(this,void 0,void 0,(function(){var t,e,i,o,r,a,c,f=this;return function(t,e){var n,i,o,r,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function c(c){return function(f){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,c[0]&&(a=0)),a;)try{if(n=1,i&&(o=2&c[0]?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,i=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]