!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).biliMirror={})}(this,(function(e){"use strict";function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;let n=!1;function r(){return!1===n&&(n="undefined"!=typeof window),n}var i;const o=function(){if(r())return window}();function s(){if(r())return o.__biliMirror__=o.__biliMirror__||{},o.__biliMirror__}const a=r()&&(null===(i=document.getElementsByTagName("meta").spm_prefix)||void 0===i?void 0:i.content)||"0.0";function c(e,t,n,r=!1){e.addEventListener(t,n,r)}function u(){return Date.now()}const l=Object.prototype.toString;function d(e){return function(t){return l.call(t)===`[object ${e}]`}}const f={isNumber:d("Number"),isString:d("String"),isBoolean:d("Boolean"),isNull:d("Null"),isUndefined:d("Undefined"),isSymbol:d("Symbol"),isFunction:d("Function"),isObject:d("Object"),isArray:d("Array"),isProcess:d("process"),isWindow:d("Window")};function h(e){const t=/^[0-9a-zA-Z_-]+$/.test(e);return t||console.warn(`字符串:${e},不符合条件,任意数字,字母、下划线、中划线组成`),t}const p=(e,t=["chrome-extension"],n=!1)=>{if(0===t.length)return!1;if(null==(null==e?void 0:e.message))return!0;const[r]=e.message.split("?");if(r.includes(location.hostname))return!0;const i=(null==e?void 0:e.fileName)||"";return!(!n||i.endsWith(".js"))||t.map((e=>new RegExp(String.raw`${e}`))).some((e=>e.test(r)||e.test(i)))};function m(e){if("0"===e)return 0;if(f.isNumber(e))return e>10?10:e<=0?1:e;if(f.isString(e)&&!isNaN(e)){const t=parseInt(e);return t>10?10:t<=0?1:t}return console.warn("mirror-kv-[config] sampling rate error,pleace set 1-10"),1}function g(e){return Math.floor(10*Math.random()+1)>e}function v(){return"undefined"==typeof document||null==document.location?"":document.location.href}function b(e){if(!e)return{};const t=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],relative:t[5]+n+r}}function E(e,t,n,r=!1){if(void 0!==e&&(t in e||r)){const r=n(e[t]);"function"==typeof r&&(e[t]=r)}}const y=(e,t)=>{let n=!0;return function(...r){n&&(e.apply(this,r),n=!1,setTimeout((()=>{n=!0}),t))}},w=(e,t)=>{let n;return function(...r){clearTimeout(n),n=setTimeout((()=>{e.apply(this,r)}),t)}};function R(e){return e&&"object"==typeof e&&!Array.isArray(e)}function O(e,t){let n=Object.assign({},e);return R(e)&&R(t)&&Object.keys(t).forEach((r=>{R(t[r])?r in e?n[r]=O(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})})),n}var S="1.6.3";const _="@bilibili/bili-mirror",I=S;var T=function(e){"undefined"!=typeof window&&window.__BILI_X_ENGINE_SCRIPT_CACHE__&&void 0!==window.__BILI_X_ENGINE_SCRIPT_CACHE__[e]&&delete window.__BILI_X_ENGINE_SCRIPT_CACHE__[e]},$=function(e,t){if("undefined"==typeof window)return Promise.reject(new Error("window is not defined"));var n,r=e=e.replace(/^https?:\/\//,"//"),i=(n=r,"undefined"==typeof window?null:window.__BILI_X_ENGINE_SCRIPT_CACHE__&&window.__BILI_X_ENGINE_SCRIPT_CACHE__[n]||null);if(null!=i&&i.promise)return i.promise;var o=new Promise((function(n,r){var i=document.createElement("script");i.src=e,null!=t&&t.behavior&&i.setAttribute(t.behavior,""),i.onload=function(){var i=window;if(t.lib)return i[t.lib]?n(i[t.lib]):r(new Error('Failed to access library "'+t.lib+'" from '+e));n(null)},i.onerror=function(){r(new Error("Failed to load "+e))},document.head.appendChild(i)}));return function(e,t){"undefined"!=typeof window&&(window.__BILI_X_ENGINE_SCRIPT_CACHE__||(window.__BILI_X_ENGINE_SCRIPT_CACHE__={}),window.__BILI_X_ENGINE_SCRIPT_CACHE__[e]=t)}(r,{promise:o,lib:null==t?void 0:t.lib}),o.then((function(){!1===(null==t?void 0:t.cache)&&T(r)})).catch((function(){!1===(null==t?void 0:t.cache)&&T(r)})),o},C=function(e){return Promise.resolve(function(){try{return window.KvSDK?Promise.resolve(window.KvSDK):Promise.resolve($("//s1.hdslb.com/bfs/seed/jinkela/kv-sdk/index.js",{lib:"KvSDK"}))}catch(e){return Promise.reject(e)}}()).then((function(t){return new t(e)}))},P=function(e){return Promise.resolve(function(){try{return window.ReporterPb?Promise.resolve(window.ReporterPb):Promise.resolve($("//s1.hdslb.com/bfs/seed/jinkela/short/reporter-pb/index.js",{lib:"ReporterPb"}))}catch(e){return Promise.reject(e)}}()).then((function(t){return new t(e)}))};const N=s(),k={SPMID:"333.1333",GROUP:"bilimirror",KEY:"whitelist"};class A{constructor(){this.origin="bili",this.module="common",this.config={},this.kvOptions={},this._defaultKvConfig={retry:[],performance:1,poll:5,techpv:5,userLog:[],resourceTime:{},userLogDeep:10,track:{},filterEndJs:!1}}fetchWhiteListConfig(e,t){return new Promise(((n,r)=>{e.get(t).then((t=>{if(!t)return console.warn(`${e.storage.appKey}-没有对应配置,返回默认配置`),void n(this._defaultKvConfig);const r=JSON.parse(t);n(r)})).catch((t=>{console.warn(`${e.storage.appKey},mirror获取白名单配置失败,返回默认配置`),n(this._defaultKvConfig)}))}))}getConfig(){return t(this,void 0,void 0,(function*(){this._defaultConfigSDK=yield C(Object.assign({appKey:k.SPMID,strict:1,reporter:{ignoreAppKeyNotFound:!0}},this.kvOptions));const{SPMID:e,GROUP:t,KEY:n}=k,r=this.spmId||a,i=yield this.fetchWhiteListConfig(this._defaultConfigSDK,`${t}.${n}`);let o={};e!==r&&(this._configSDK&&delete this._configSDK,this._configSDK=yield C(Object.assign({appKey:r,strict:1,reporter:{ignoreAppKeyNotFound:!0}},this.kvOptions)),o=yield this.fetchWhiteListConfig(this._configSDK,`${t}.${n}`));const s=O(i,o);return new Promise((e=>{this.config.white=(null==s?void 0:s.white)||{},this.config["white-retry"]=(null==s?void 0:s.retry)||[],this.config["white-preformance-rate"]=s.performance?m(null==s?void 0:s.performance):1,this.config["poll-time"]=s.poll?m(null==s?void 0:s.poll):5,this.config["tech-pv"]=s.techpv?m(null==s?void 0:s.techpv):5,this.config["user-log"]=(null==s?void 0:s.userLog)||[],this.config["resource-time"]=(null==s?void 0:s.resourceTime)||{},this.config["user-log-deep"]=(null==s?void 0:s.userLogDeep)||10,this.config.track=(null==s?void 0:s.track)||{},this.config["filter-end-js"]=(null==s?void 0:s.filterEndjs)||!1,e()}))}))}bindOptions(e={}){return t(this,void 0,void 0,(function*(){return N.mirrorVersion=I,Object.keys(e).forEach((t=>{"config"!==t&&("module"===t&&"function"==typeof e[t]?this[t]=e[t]():this[t]=e[t])})),yield this.getConfig(),Promise.resolve("ok")}))}updateModule(e){this.module=e}}function D(){return N.options||(N.options=new A)}const L=r()?D():null;function j(e={}){return t(this,void 0,void 0,(function*(){if(r()){return yield L.bindOptions(e)}}))}var M,H,x,B,F=-1,U=function(e){addEventListener("pageshow",(function(t){t.persisted&&(F=t.timeStamp,e(t))}),!0)},K=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},W=function(){var e=K();return e&&e.activationStart||0},Y=function(e,t){var n=K(),r="navigate";return F>=0?r="back-forward-cache":n&&(document.prerendering||W()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},J=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries())}))}));return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(e){}},G=function(e,t,n,r){var i,o;return function(s){t.value>=0&&(s||r)&&((o=t.value-(i||0))||void 0===i)&&(i=t.value,t.delta=o,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},V=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},q=function(e){var t=function(t){"pagehide"!==t.type&&"hidden"!==document.visibilityState||e(t)};addEventListener("visibilitychange",t,!0),addEventListener("pagehide",t,!0)},X=function(e){var t=!1;return function(n){t||(e(n),t=!0)}},z=-1,Z=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},Q=function(e){"hidden"===document.visibilityState&&z>-1&&(z="visibilitychange"===e.type?e.timeStamp:0,te())},ee=function(){addEventListener("visibilitychange",Q,!0),addEventListener("prerenderingchange",Q,!0)},te=function(){removeEventListener("visibilitychange",Q,!0),removeEventListener("prerenderingchange",Q,!0)},ne=function(){return z<0&&(z=Z(),ee(),U((function(){setTimeout((function(){z=Z(),ee()}),0)}))),{get firstHiddenTime(){return z}}},re=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},ie=[1800,3e3],oe=function(e,t){t=t||{},re((function(){var n,r=ne(),i=Y("FCP"),o=J("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime=0&&H1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){ue(e,t),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,ae),removeEventListener("pointercancel",r,ae)};addEventListener("pointerup",n,ae),addEventListener("pointercancel",r,ae)}(t,e):ue(t,e)}},fe=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,de,ae)}))},he=[100,300],pe=[2500,4e3],me={},ge=[800,1800],ve=function e(t){document.prerendering?re((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},be=function(e,t){t=t||{};var n=Y("TTFB"),r=G(e,n,ge,t.reportAllChanges);ve((function(){var i=K();if(i){var o=i.responseStart;if(o<=0||o>performance.now())return;n.value=Math.max(o-W(),0),n.entries=[i],r(!0),U((function(){n=Y("TTFB",0),(r=G(e,n,ge,t.reportAllChanges))(!0)}))}}))};const Ee=e=>!!r()&&(()=>{try{return r()&&PerformanceObserver?PerformanceObserver.supportedEntryTypes||[]:null}catch(e){console.error("bili-mirror: supportList 解析异常:",e)}})().includes(e);function ye(e){window.performance.getEntriesByType&&window.addEventListener("load",(function(){const t=window.performance;t&&setTimeout((()=>{const n=t.getEntriesByType("navigation")[0],r={redirectTime:n.redirectEnd-n.redirectStart,dnsTime:n.domainLookupEnd-n.domainLookupStart,tcpTime:n.connectEnd-n.connectStart,sslTime:"https:"===location.protocol?n.connectEnd-n.secureConnectionStart:0,ttfbTime:n.responseStart-n.startTime,requestDoneTime:n.responseEnd-n.responseStart,domParseTime:n.domContentLoadedEventEnd-n.responseEnd,resourceDownloadTime:n.loadEventEnd-n.domContentLoadedEventEnd,pageTime:n.duration};e({name:"PAGETIME",data:r,value:1})}),0)}))}function we(e){/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)?(!function(e){if(!Ee("first-input"))return;const t=new PerformanceObserver((n=>{for(const r of n.getEntries()){t.disconnect();const n=r.processingStart-r.startTime;e({name:"FID",value:n,rating:n<100?"good":n>100&&n<300?"normal":"poor"})}}));t.observe({type:"first-input",buffered:!0})}((t=>{e(t)})),function(e){if(!Ee("paint"))return;const t=new PerformanceObserver((n=>{for(const r of n.getEntries())"first-contentful-paint"===r.name&&(t.disconnect(),e({name:"FCP",value:r.startTime,rating:r.startTime<1600?"good":r.startTime>1600&&r.startTime<3e3?"normal":"poor"}))}));t.observe({type:"paint",buffered:!0})}((t=>{e(t)})),function(e){if(!Ee("largest-contentful-paint"))return;const t=new PerformanceObserver((n=>{for(const r of n.getEntries())t.disconnect(),e({name:"LCP",value:r.startTime,rating:r.startTime<1600?"good":r.startTime>1600&&r.startTime<3e3?"normal":"poor"})}));t.observe({type:"largest-contentful-paint",buffered:!0})}((t=>{e(t)})),function(e){window.addEventListener("load",(function(){let{responseStart:t,navigationStart:n}=window.performance.timing,r=t-n;e({name:"TTFB",value:r,rating:r<200?"good":r>200&&r<500?"normal":"poor"})}))}((t=>{e(t)})),ye((t=>{e(t)}))):(!function(e,t){t=t||{},re((function(){var n,r=ne(),i=Y("LCP"),o=function(e){var t=e[e.length-1];t&&t.startTime{e(t)})),function(e,t){t=t||{},re((function(){var n,r=ne(),i=Y("FID"),o=function(e){e.startTime{e(t)})),function(e,t){t=t||{},oe(X((function(){var n,r=Y("CLS",0),i=0,o=[],s=function(e){e.forEach((function(e){if(!e.hadRecentInput){var t=o[0],n=o[o.length-1];i&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(i+=e.value,o.push(e)):(i=e.value,o=[e])}})),i>r.value&&(r.value=i,r.entries=o,n())},a=J("layout-shift",s);a&&(n=G(e,r,se,t.reportAllChanges),q((function(){s(a.takeRecords()),n(!0)})),U((function(){i=0,r=Y("CLS",0),n=G(e,r,se,t.reportAllChanges),V((function(){return n()}))})),setTimeout(n,0))})))}((t=>{e(t)})),oe((t=>{e(t)})),be((t=>{e(t)})),ye((t=>{e(t)})))}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Re(e,t){return e(t={exports:{}},t.exports),t.exports}var Oe=Re((function(e,t){e.exports=function(){var e=1e3,t=6e4,n=36e5,r="millisecond",i="second",o="minute",s="hour",a="day",c="week",u="month",l="quarter",d="year",f="date",h="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},v=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},b={s:v,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+v(r,2,"0")+":"+v(i,2,"0")},m:function e(t,n){if(t.date()1)return e(s[0])}else{var a=t.name;y[a]=t,i=a}return!r&&i&&(E=i),i||!r&&E},S=function(e,t){if(R(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new I(n)},_=b;_.l=O,_.i=R,_.w=function(e,t){return S(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var I=function(){function g(e){this.$L=O(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var v=g.prototype;return v.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(_.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(p);if(r){var i=r[2]-1||0,o=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)}}return new Date(t)}(e),this.init()},v.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},v.$utils=function(){return _},v.isValid=function(){return!(this.$d.toString()===h)},v.isSame=function(e,t){var n=S(e);return this.startOf(t)<=n&&n<=this.endOf(t)},v.isAfter=function(e,t){return S(e)new Promise(((e,t)=>{const n=indexedDB.open(Se,1);n.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains(_e)||t.createObjectStore(_e,{keyPath:Ie})},n.onsuccess=()=>{event.target.result.close(),e()},n.onerror=()=>{console.log("Indexed Start Error"),t()}})),add(e){const t=Oe().format("YYYY-MM-DD-HH:mm:ss:SSS")+"_"+Math.ceil(999*Math.random())+"Z",n=indexedDB.open(Se,1);n.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains(_e)||t.createObjectStore(_e,{keyPath:Ie})},n.onsuccess=n=>{const r=n.target.result;if(!r.objectStoreNames.contains(_e))return;const i=r.transaction(_e,"readwrite").objectStore(_e),o=i.count();o.onsuccess=()=>{i.put({[Ie]:`[${t}]-${e}`}),Number(o.result)<=1e5||(i.openCursor().onsuccess=e=>{const t=e.target.result;t&&t.delete()})},o.onerror=()=>{console.log("mirror indexDb count error")},r.close()},n.onerror=()=>{console.log("add Indexed Open Error")}},getAll:(e=!0)=>new Promise(((t,n)=>{let r=[];const i=indexedDB.open(Se);i.onsuccess=i=>{const o=i.target.result;if(!o.objectStoreNames.contains(_e))return void n("the store log not exists in the MIRROR_TRACK databse");const s=o.transaction(_e,"readonly").objectStore(_e);if(e)s.openCursor().onsuccess=e=>{const n=e.target.result;if(n)r.push(n.key),r.push("\r\n"),n.continue();else{const e=new Blob(r,{type:"text/plain;charset=utf-8"});t(e)}},s.openCursor().onerror=()=>{n("OpenCursor Error")};else{s.getAll().onsuccess=function(e){const n=e.target.result;t(n)}}o.close()},i.onerror=()=>{n("Indexed Open Error")}})),clearStore(){const e=indexedDB.open(Se);e.onsuccess=e=>{const t=e.target.result;if(!t.objectStoreNames.contains(_e))return void console.log(`Object store ${_e} does not exist`);t.transaction(_e,"readwrite").objectStore(_e).clear().onsuccess=function(e){console.log("All entries have been removed from the store.")},t.close()},e.onerror=function(e){console.log("Error opening db",e.target.error)}},deleteIndexedDB(){const e=indexedDB.deleteDatabase(Se);e.onsuccess=()=>{console.log("Delete Success"),Te.createIndexedDB()},e.onerror=()=>{console.log("Delete Error")}}};var $e,Ce,Pe,Ne,ke,Ae,De;!function(e){e.INIT="init",e.ERROR="error",e.UNHANDLEDREJECTION="unhandledrejection",e.RESOURCE="resource",e.PERFORMANCE="performance",e.WHITESCREEN="whiteScreen",e.BREABCRUMB="breadcrumb"}($e||($e={})),function(e){e.ERROR="error",e.CLICK="click",e.HISTORY="history",e.HASHCHANGE="hashchange",e.UNHANDLEDREJECTION="unhandledrejection",e.RESOURCE="resource",e.WHITE="white",e.CUSTOM="custom",e.SCROLL="scroll",e.API="api"}(Ce||(Ce={})),function(e){e.BEFORE="mirrorHandlerBefore",e.AFTER="mirrorHandlerAfter"}(Pe||(Pe={})),function(e){e.ERROR="error",e.OK="ok"}(Ne||(Ne={})),function(e){e.AUTO="auto",e.DEFAULT="default"}(ke||(ke={})),function(e){e.HISTORY="history",e.HASH="hash",e.DOM="dom",e.JS="js",e.PROMISE="promise",e.RESOURCE="resource",e.WHITE="white",e.SCROLL="scroll",e.API="api"}(Ae||(Ae={})),function(e){e.LOAD="info-load",e.REFRESH="info-refresh",e.PAGETABSTATUS="info-visibilitychange",e.DEVICE="info-device",e.SCROLL="info-scroll",e.APISUCCESS="request-success",e.APIERROR="request-error",e.PAGECLOSE="info-close",e.CLICK="info-click",e.HISTORY="info-history",e.HASHCHANGE="info-hashchange",e.ERROR="error-js",e.UNHANDLEDREJECTION="error-unhandledrejection",e.RESOURCE="error-resource",e.WHITE="error-white"}(De||(De={}));const Le={isExclusive:1},je={mirrorPolymer:3},Me=(e,n="before",r)=>{const i=[];let o=!1,s=0;return{start(){return new Promise((a=>t(this,void 0,void 0,(function*(){if(!o){for(o=!0;s{e(),this.repeat(e,t)}),t))}clear(){clearTimeout(this.timeID)}}let xe=null;class Be{before(e,n){return new Promise((r=>t(this,void 0,void 0,(function*(){if(L.plugins&&f.isArray(L.plugins))try{const t=L.plugins,i=yield Me(t,"before",{type:e,data:n}).start();let[o]=i.slice(-1);r(o)}catch(e){console.warn("bili-mirror:plugin function before hook error,please check"),r(!0)}else if(L.plugins&&L.plugins.mirrorHandleBefore)try{L.plugins.mirrorHandleBefore(e,n).then((e=>{r(e)}))}catch(e){console.warn("bili-mirror:plugin function before hook error,please check"),r(!0)}else r(!0)}))))}after(e,n){return new Promise((r=>t(this,void 0,void 0,(function*(){if(L.plugins&&f.isArray(L.plugins))try{const t=L.plugins;yield Me(t,"after",{type:e,data:n}).start(),r()}catch(e){console.warn("bili-mirror:plugin function after hook error,please check"),r()}else if(L.plugins&&L.plugins.mirrorHandleAfter)try{L.plugins.mirrorHandleAfter(e,n).then((()=>{r()}))}catch(e){console.warn("bili-mirror:plugin function after hook error,please check"),r()}else r()}))))}}xe||(xe=new Be);const Fe=s();const Ue=r()?Fe.breadcrumb||(Fe.breadcrumb=new class{constructor(){this.maxBreadcrumbs=10,this.stack=[],this.isSet=!1}push(e){return t(this,void 0,void 0,(function*(){(null==L?void 0:L.config["user-log-deep"])&&!this.isSet&&(this.maxBreadcrumbs=null==L?void 0:L.config["user-log-deep"],this.isSet=!0);(yield xe.before($e.BREABCRUMB,e))&&(this.immediatePush(e),c(o,"beforeunload",(()=>{this.stack.filter((e=>"error"===e.status)).length&&(this.goToReport(this.stack),window.__biliMirrorPbInstance__&&window.__biliMirrorPbInstance__.flush&&window.__biliMirrorPbInstance__.flush())})))}))}immediatePush(e){if(e.time||(e.time=u()),this.stack.length>=this.maxBreadcrumbs){this.stack.filter((e=>"error"===e.status)).length?(this.goToReport(this.stack),this.clear()):this.clear()}this.stack.push(e),this.stack.sort(((e,t)=>e.time-t.time))}shift(){return void 0!==this.stack.shift()}clear(){this.stack=[]}getStack(){return this.stack}goToReport(e){let t={};e.forEach(((e,n)=>{t[`logStep-${n}`]=e})),Ot({type:"custom",event:`${L.origin}.${L.module}.USERLOG`,msg:Object.assign({userLogInfo:Object.assign({},t)},Le)}),xe.after($e.BREABCRUMB,this.stack),this.clear()}}):null;let Ke=null;const We=s();function Ye(e){const t=(null==L?void 0:L.config["user-log"])||null;return!!t&&t.find((t=>t===e))}function Je(){return"log"!==(null==We?void 0:We.logType)}class Ge{constructor(){}handleHistory(e){const{from:t,to:n}=e,{relative:r}=b(t),{relative:i}=b(n);Je()&&et(De.HISTORY,"history跳转",{from:r||"/",to:i||"/"}),Ye(Ae.HISTORY)&&Ue.push({category:Ce.HISTORY,status:Ne.OK,time:u(),msg:{from:r||"/",to:i||"/"}})}handleHashChange(e){const{oldURL:t,newURL:n}=e,{relative:r}=b(t),{relative:i}=b(n);Je()&&et(De.HASHCHANGE,"hashChange跳转",{from:r,to:i}),Ye(Ae.HASH)&&Ue.push({category:Ce.HASHCHANGE,status:Ne.OK,time:u(),msg:{from:r,to:i}})}handleDomClick(e){const t=function(e){if(e.target.offsetParent){const t=e.target.offsetParent.tagName.toLowerCase();return"body"===t||"html"===t||void 0===t?"":e.target.outerHTML}return e.target.outerHTML}(e);t&&(Je()&&et(De.CLICK,"点击",{dom:t}),Ye(Ae.DOM)&&Ue.push({category:Ce.CLICK,status:Ne.OK,time:u(),msg:{clickDom:t}}))}handleScroll(){const e=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop;Je()&&et(De.SCROLL,"页面滚动",{top:e}),Ye(Ae.SCROLL)&&Ue.push({category:Ce.SCROLL,status:Ne.OK,time:u(),msg:{top:e}})}handleJsError(e){Je()&&et(De.ERROR,"js报错",{message:e.message}),Ye(Ae.JS)&&Ue.push({category:Ce.ERROR,status:Ne.ERROR,time:e.time||u(),msg:{message:e.message}})}handlePromiseError(e){Je()&&et(De.UNHANDLEDREJECTION,"rejection错误",{message:e.message}),Ye(Ae.PROMISE)&&Ue.push({category:Ce.UNHANDLEDREJECTION,status:Ne.ERROR,time:e.time||u(),msg:{message:e.message}})}handleResourceError(e){Je()&&et(De.RESOURCE,"resource错误",{message:e.message,name:null==e?void 0:e.name}),Ye(Ae.RESOURCE)&&Ue.push({category:Ce.RESOURCE,status:Ne.ERROR,time:e.time||u(),msg:{message:e.message,name:null==e?void 0:e.name}})}handleWhiteScreen(){Je()&&et(De.WHITE,"白屏错误",{url:location.href}),Ye(Ae.WHITE)&&Ue.push({category:Ce.WHITE,status:Ne.ERROR,time:u(),msg:{url:location.href}})}handleRequest(e){Je()&&et(Ve(e.httpCode)?De.APISUCCESS:De.APIERROR,`请求httpCode:${e.httpCode}`,{api:e.api,traceId:e.traceId,code:e.code,messgae:e.msg}),Ye(Ae.API)&&Ue.push({category:Ce.API,status:Ve(e.httpCode)?Ne.OK:Ne.ERROR,time:u(),msg:{api:e.api,traceId:e.traceId,code:e.code,messgae:e.msg}})}}function Ve(e){return e>=200&&e<300}Ke||(Ke=new Ge);let qe=v();const Xe={historyReplace(){if(!function(){const e=o.chrome,t=e&&e.app&&e.app.runtime,n="history"in o&&!!o.history.pushState&&!!o.history.replaceState;return!t&&n}())return;const e=o.onpopstate;function t(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const e=qe,t=String(n);qe=t,Ke.handleHistory({from:e,to:t})}return e.apply(this,t)}}o.onpopstate=function(...t){const n=v(),r=qe;qe=n,Ke.handleHistory({from:r,to:n}),e&&e.apply(this,t)},E(o.history,"pushState",t),E(o.history,"replaceState",t)},hashChangeeReplace(){var e,t;e=o,t="onhashchange",Object.prototype.hasOwnProperty.call(e,t)&&c(o,"hashchange",(function(e){Ke.handleHashChange(e)}))},domClickReplace(){if(!("document"in o))return;const e=y(Ke.handleDomClick,300);c(o.document,"click",(function(t){e(t)}),!0)},scrollReplace(){const e=w(Ke.handleScroll,1e3);c(o,"scroll",(function(t){e(t)}),!0)},jsErrorReplace(e){null==Ke||Ke.handleJsError(e)},promiseErrorReplace(e){null==Ke||Ke.handlePromiseError(e)},resourceErrorReplace(e){null==Ke||Ke.handleResourceError(e)},whiteErrorReplace(){null==Ke||Ke.handleWhiteScreen()},apiReplace(e){null==Ke||Ke.handleRequest(e)}},ze=s();function Ze(e){const t=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return t?decodeURIComponent(t[2]):null}function Qe(){const e=function(){const e=null==L?void 0:L.config.track,t=Ze("buvid3"),n=Ze("DedeUserID");return!(!e||0===Object.keys(e).length||!(null==e?void 0:e.mid.includes("*"))&&!(null==e?void 0:e.buvid.includes("*"))&&!(null==e?void 0:e.mid.includes(n))&&!(null==e?void 0:e.buvid.includes(t)))}(),t=function(){var e;return null===(e=null==L?void 0:L.config["user-log"])||void 0===e?void 0:e.length}();return e&&t?"all":e&&!t?"track":!e&&t?"log":"none"}function et(e,t,n){let r=`[${e}]: ${t} ${"string"==typeof n?n:JSON.stringify(n||"")}`;Te.add(r)}function tt(e){return new Promise(((n,r)=>t(this,void 0,void 0,(function*(){const t=new FormData;t.append("log",e),t.append("project",function(){const{spmId:e,origin:t,module:n}=ze.options;return`${e||a}.${t}.${n}`}());try{const e=yield fetch("https://api.bilibili.com/x/web-frontend/action-log/upload",{method:"POST",body:t,credentials:"include"});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const r=yield e.json();n(r)}catch(e){r("Failed to upload log: "+e)}}))))}function nt(){return t(this,void 0,void 0,(function*(){r()&&(ze.logType=Qe(),"none"!==Qe()&&("log"!==ze.logType&&(yield Te.createIndexedDB(),function(){let e=performance.getEntriesByType("navigation");if(e.length>0)if("reload"===e[0].type)et(De.REFRESH,"页面刷新",{url:location.href});else{et(De.LOAD,"页面载入",{url:location.href});const e=window.innerWidth,t=window.innerHeight;et(De.DEVICE,"设备信息",{ua:navigator.userAgent,window_size:`${e}*${t}`})}o.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState?et(De.PAGETABSTATUS,"选项卡被激活"):"hidden"===document.visibilityState&&et(De.PAGETABSTATUS,"选项卡被隐藏")})),o.addEventListener("beforeunload",(()=>{et(De.PAGECLOSE,"页面关闭")}))}()),Xe.historyReplace(),Xe.hashChangeeReplace(),Xe.domClickReplace(),Xe.scrollReplace()))}))}let rt=null,it=null,ot=6e4*((null==L?void 0:L.config["poll-time"])||5);const st="BILI_MIRROR_REPORT_POOL";(null==L?void 0:L.config["poll-time"])||setTimeout((()=>{ot=6e4*((null==L?void 0:L.config["poll-time"])||5)}),1e3);const at=()=>{try{let e=JSON.parse(localStorage.getItem(st)||"{}");if(!Object.keys(e).length)return;Object.entries(e).forEach((([e,t])=>{rt.tech(e,t)})),localStorage.setItem(st,"{}")}catch(e){}},ct=()=>{it||(it=new He,it.repeat(at,ot),c(o,"beforeunload",(function(){at(),ut()})))},ut=()=>{rt&&rt.flush&&rt.flush(),it&&it.clear()},lt="_BiliGreyResult",dt=()=>{const e=ft("offline-version"),t=ft("offline-name"),n=ft("offline-plat");return e?{offlineVersion:e,offlineName:t,offlinePlat:n}:{}},ft=e=>{var t;return(null===(t=document.getElementsByTagName("meta")[e])||void 0===t?void 0:t.content)||void 0},ht=(()=>{if(!r())return{};if(!o[lt])return{};const e=o[lt];var t={};Object.entries(e).forEach((([e,n])=>{t[`${lt}_${e}`]=n}));const n=dt();return Object.assign(Object.assign({},t),n)})(),pt=[];let mt=!1,gt="",vt=null;const bt=e=>{let t="";return t=e.diyevent?e.eventId||e.event:e.otherSpmId?`${e.otherSpmId}.${e.eventId}`:(null==L?void 0:L.spmId)?`${null==L?void 0:L.spmId}.${e.eventId}`:`${a}.${e.eventId}`,t};function Et(){if(pt.length&&!mt){mt=!0;const[e,t,n,r]=pt.shift();if("middleWare"===t){if(vt)return mt=!1,St(n,r),void Et();e(!0).then((e=>{var t;mt=!1,vt=e,rt!==(t=vt)&&(rt=t),_t(n,r),Et()}))}else e().then((()=>{mt=!1,t&&n&&t(n,r||void 0),Et()}))}}const yt=e=>{const t=gt?window[gt]:window.__biliMirrorPbInstance__;e=$t(e);const n=bt(e);t[e.type](n,e.msg)},wt=(e,t)=>{t&&Object.keys(t).length>0&&It(t),e=$t(e);const n=bt(e),r=gt?window[gt]:window.__biliMirrorPbInstance__,i=Object.assign(Object.assign(Object.assign({},e.msg),ht),{mirrorVersion:S,type:e.type||"custom"});r.tech(n,i)},Rt=e=>{pt.push([Tt,yt,e]),Et()},Ot=(e,t)=>{pt.push([Tt,wt,e,t]),Et()},St=(e,t)=>{var n;n=e.msg,"none"!==Qe()&&Xe.apiReplace(n),!e.msg.message&&e.msg.msg&&(e.msg.message=e.msg.msg),vt?_t(e,t):(pt.push([Tt,"middleWare",e,t]),Et())},_t=(e,t)=>{t&&void 0!==(null==t?void 0:t.isBatch)||(t=Object.assign(t||{},{isBatch:!1}));const n=((null==t?void 0:t.spmId)||a)+"."+((null==t?void 0:t.origin)||(null==L?void 0:L.origin))+"."+((null==t?void 0:t.module)||(null==L?void 0:L.module));(null==t?void 0:t.isBatch)?((e,t,n)=>{var r;const i=(null===(r=null==t?void 0:t.api)||void 0===r?void 0:r.split("?")[0])||"";try{let t=JSON.parse(localStorage.getItem(st)||"{}");t[e]||(t[e]=Object.assign(Object.assign({},n),je)),t[e][i]?t[e][i]++:t[e][i]=1,localStorage.setItem(st,JSON.stringify(t))}catch(e){}ct()})(n+(t.eventId||".DATA.successReport"),e.msg,Object.assign({type:"custom",mirrorVersion:S},ht)):vt.tech(n+(t.eventId||".ERROR.errorReport"),Object.assign(Object.assign({type:e.type||"custom",mirrorVersion:S},e.msg),ht))},It=(e={feature:{tech:!0}})=>{window.__biliMirrorPbInstance__.options=Object.assign({feature:{tech:!0}},e)},Tt=(e=!1)=>{try{return new Promise(((t,n)=>{if(r()||n("not support in server"),e){const e={feature:{tech:!0},autoPv:!1,batch:!1};if(window.ReporterPb){const n=new window.ReporterPb(Object.assign({},e));t(n)}else P(Object.assign({},e)).then((e=>{t(e)}))}else{const e=(null==L?void 0:L.pbOtherNameIns)?null==L?void 0:L.pbOtherNameIns:"";if(f.isObject(window[e])&&Object.keys(window[e]).length)gt=e,console.warn(`Is using ${e} to report,Please confirm open [tech] config`),t();else if(window.__biliMirrorPbInstance__)t();else{const e=O({feature:{tech:!0}},(null==L?void 0:L.pbOptions)||{});window.ReporterPb?(window.__biliMirrorPbInstance__=new window.ReporterPb(e),t()):P(Object.assign({},e)).then((e=>{window.__biliMirrorPbInstance__=e,t()}))}}}))}catch(e){console.error("bili-mirror:load pb-report-Error load failed:",e)}};function $t(e){e.event&&!e.eventId&&(e.eventId=e.event);return e.eventId.split(".").length<=1&&(e.eventId=`${null==L?void 0:L.origin}.${null==L?void 0:L.module}.${e.eventId}`),"appear"===e.type&&(e.type="exposure"),e}var Ct=Re((function(e,t){e.exports=function(){function e(e){return!isNaN(parseFloat(e))&&isFinite(e)}function t(e){return e.charAt(0).toUpperCase()+e.substring(1)}function n(e){return function(){return this[e]}}var r=["isConstructor","isEval","isNative","isToplevel"],i=["columnNumber","lineNumber"],o=["fileName","functionName","source"],s=["args"],a=["evalOrigin"],c=r.concat(i,o,s,a);function u(e){if(e)for(var n=0;n-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var t=e.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),r=t.match(/ (\(.+\)$)/);t=r?t.replace(r[0],""):t;var i=this.extractLocation(r?r[1]:t),o=r&&t||void 0,s=["eval",""].indexOf(i[0])>-1?void 0:i[0];return new n({functionName:o,fileName:s,lineNumber:i[1],columnNumber:i[2],source:e})}),this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter((function(e){return!e.match(o)}),this).map((function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new n({functionName:e});var t=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=e.match(t),i=r&&r[1]?r[1]:void 0,o=this.extractLocation(e.replace(t,""));return new n({functionName:i,fileName:o[0],lineNumber:o[1],columnNumber:o[2],source:e})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var t=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split("\n"),i=[],o=2,s=r.length;o/,"$2").replace(/\([^)]*\)/g,"")||void 0;o.match(/\(([^)]*)\)/)&&(t=o.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var a=void 0===t||"[arguments not available]"===t?void 0:t.split(",");return new n({functionName:s,args:a,fileName:i[0],lineNumber:i[1],columnNumber:i[2],source:e})}),this)}})}));const Nt=e=>{const t=e.target;if(null==t?void 0:t.localName){const e=function(e){return{time:u(),message:e.src||e.href||"",name:e.localName}}(t);return Object.assign(Object.assign({},e),{type:"resourceError"})}return null},kt=[],At=e=>{const t=(n=(null==e?void 0:e.message)||(null==e?void 0:e.fileName),window.btoa(decodeURIComponent(encodeURIComponent(n))));var n;return kt.some((e=>e===t))?(console.warn(`Duplicate error, not reported,${null==e?void 0:e.message}`),!1):(kt.push(t),!0)},Dt={handleError(e){var n,r,i,s,a;return t(this,void 0,void 0,(function*(){if((null==o?void 0:o.screen.width)<=100||o.screen.height<=100)return;if((null==o?void 0:o.innerWidth)<=100||o.innerHeight<=100)return;const t=e.target;try{if(!t||e.target&&!e.target.localName){const t=(e=>{var t;const n=e.target;if(!n||e.target&&!(null===(t=e.target)||void 0===t?void 0:t.localName)){let t=Pt.parse(n?e.error:e).slice(0,5),r=[];t.forEach((e=>{let{source:t}=e;const n=t?t.split(" ").join("").split("./"):"";r.push(n)}));let i=Pt.parse(n?e.error:e)[0],{fileName:o,columnNumber:s,lineNumber:a}=i;return{type:"error",time:u(),message:e.message,fileName:o,line:a,column:s,stack:JSON.stringify(r)}}return null})(e),o=null===(r=null===(n=null==L?void 0:L.config)||void 0===n?void 0:n.white)||void 0===r?void 0:r.error,s=(null===(i=null==L?void 0:L.config)||void 0===i?void 0:i["filter-end-js"])||!1;if(!p(t,o,s)){if(!At(t))return;if(!(yield xe.before($e.ERROR,t)))return;Ot({type:"error",eventId:`${L.origin}.${L.module}.ERROR.jsError`,msg:t},L.pbOptions||{}),Xe.jsErrorReplace(t),xe.after($e.ERROR,t)}}if(null==t?void 0:t.localName){let t=Nt(e);const n=null===(a=null===(s=null==L?void 0:L.config)||void 0===s?void 0:s.white)||void 0===a?void 0:a.resource;if(!p(t,n)){if(!At(t))return;if(!(yield xe.before($e.RESOURCE,t)))return;Ot({type:"error",eventId:`${L.origin}.${L.module}.ERROR.resourceError`,msg:Object.assign(Object.assign({},t),{error_type:"AssetsError",headless:""==navigator.language?"headless":"normal",webdriver:null===navigator||void 0===navigator?void 0:navigator.webdriver})},L.pbOptions||{}),Xe.resourceErrorReplace(t),xe.after($e.RESOURCE,t)}}}catch(e){console.warn("bili-mirror: handleError-Error parsing failed:",e)}}))},handleUnhandleRejection(e){var n,r,i;return t(this,void 0,void 0,(function*(){try{if((null==o?void 0:o.screen.width)<=100||o.screen.height<=100)return;if((null==o?void 0:o.innerWidth)<=100||o.innerHeight<=100)return;const t=(e=>{let t=Pt.parse(e.reason).slice(0,5),n=[];t.forEach((e=>{let{source:t}=e;const r=t?t.split(" ").join("").split("./"):"";n.push(r)}));let r=Pt.parse(e.reason)[0],{fileName:i,columnNumber:o,lineNumber:s}=r;var a;return{type:"rejectionError",time:u(),message:(a=e.reason.message||e.reason.stack,f.isString(a)?a:f.isUndefined(a)?"undefined":JSON.stringify(a)),fileName:i,line:s,column:o,stack:JSON.stringify(n)}})(e),s=null===(r=null===(n=null==L?void 0:L.config)||void 0===n?void 0:n.white)||void 0===r?void 0:r.rejection,a=(null===(i=null==L?void 0:L.config)||void 0===i?void 0:i["filter-end-js"])||!1;if(!p(t,s,a)){if(!At(t))return;if(!(yield xe.before($e.UNHANDLEDREJECTION,t)))return;Ot({type:"error",eventId:`${L.origin}.${L.module}.ERROR.rejectionError`,msg:t},L.pbOptions||{}),Xe.promiseErrorReplace(t),xe.after($e.UNHANDLEDREJECTION,t)}}catch(e){console.warn("bili-mirror: handleUnhandleRejection-Error parsing failed:",e)}}))},handlePerformance(){return t(this,void 0,void 0,(function*(){try{if(!PerformanceObserver||!(null===PerformanceObserver||void 0===PerformanceObserver?void 0:PerformanceObserver.supportedEntryTypes))return;if(g(L.config["white-preformance-rate"]))return;we((e=>t(this,void 0,void 0,(function*(){let{name:t,value:n}=e;if(!n||n<0)return;(yield xe.before($e.PERFORMANCE,e))&&(Ot({type:"performance",eventId:`${L.origin}.${L.module}.PERFORMANCE.${e.name}`,msg:"PAGETIME"===t?Object.assign({},null==e?void 0:e.data):Object.assign({},e)},L.pbOptions||{}),xe.after($e.PERFORMANCE,e))}))))}catch(e){console.warn("bili-mirror: performance-Error parsing failed:",e)}}))}};var Lt;!function(e){e.ERROR="error",e.OK="ok"}(Lt||(Lt={}));let jt=null,Mt=null;const Ht="BILI_MIRROR_RESOURCE_TIME",xt=["xmlhttprequest","fetch","img","image","link","css","video","iframe","script"],Bt={API:"xmlhttprequest,fetch",IMG:"img,image",CSS:"link,css",JS:"script",VIDEO:"video",IFRAME:"iframe"};class Ft{constructor(){this._cleanUpReportPool=()=>{jt&&jt.clear(),window.__biliMirrorPbInstance__&&window.__biliMirrorPbInstance__.flush&&window.__biliMirrorPbInstance__.flush()},this.config=L.config["resource-time"]||{},this.resourceWaitList=[],this.disablePush=!1}on(){PerformanceObserver&&(null===PerformanceObserver||void 0===PerformanceObserver?void 0:PerformanceObserver.supportedEntryTypes)&&(this._getAllData(),this._createObserver())}destroy(){Mt&&Mt.disconnect(),jt&&jt.clear()}_getAllData(){const e=performance.getEntriesByType("resource");(e||e.length)&&e.forEach((e=>{this.resourceWaitList.push(e)}))}_handlerResourceInit(){for(this.disablePush=!0;this.resourceWaitList.length;){let e=this.resourceWaitList.shift();if(!this._isCheckResource(e))continue;const t=this._computeResourceData_(e);this._addResourceReportPool(t)}this.disablePush=!1,this._startReportInterval()}_isCheckResource(e){if(!xt.includes(e.initiatorType))return!1;if(!Object.keys(this.config).length)return!1;let t=!1;for(let n in this.config){if(Bt[n].split(",").includes(e.initiatorType)){if("*"===this.config[n]){t=!0;break}if(!this.config[n])continue;if(Array.isArray(this.config[n])&&this.config[n].length)for(let r=0;r{this._clearResourceReport(),this._cleanUpReportPool()})))}_clearResourceReport(){try{let e=JSON.parse(localStorage.getItem(Ht)||"{}");Object.keys(e).length&&Ot({type:"performance",eventId:`${L.origin}.${L.module}.PERFORMANCE.RESOURCETIME`,msg:{resourceListInfo:Object.assign({},e)}}),localStorage.setItem(Ht,"")}catch(e){}}_createObserver(){Mt=new PerformanceObserver((e=>{e.getEntries().forEach((e=>{this.resourceWaitList.push(e.toJSON())})),this.disablePush||this._handlerResourceInit()})),Mt.observe({entryTypes:["resource"]})}}function Ut(e){if(r()){if(c(o,"error",(function(e){Dt.handleError(e)}),!0),c(o,"unhandledrejection",(function(e){Dt.handleUnhandleRejection(e)})),Dt.handlePerformance(),null==e?void 0:e.whiteScreen)try{!function(e){if((null==o?void 0:o.screen.width)<=10||o.screen.height<=10)return;if((null==o?void 0:o.innerWidth)<=10||o.innerHeight<=10)return;const n=e.checkNum||3,r=e.maxLoop||9,i=e.elemArry||e.checkDom||["html","body","#app"],a=e.callback||function(){},c=s();let u=0;const l=[];let d=[],f={};function h(e){return e.id?"#"+e.id:e.className&&"string"==typeof e.className?"."+e.className.split(" ").filter((e=>!!e)).join("."):e.nodeName.toLowerCase()}function p(t){const n=h(t);e.isSkeleton&&(u?d.push(n):l.push(n));let r=!1;if(!n||!i)return r;for(let e=0;e<=i.length;e++)if(i[e]&&n.match(i[e])){r=!0;break}return r}function m(){return t(this,void 0,void 0,(function*(){if(!document||!document.elementsFromPoint)return void console.warn("当前浏览器不支持elementsFromPoint方法,白屏检测跳过");if(!(yield xe.before($e.WHITESCREEN)))return;f.check_list=i;let t=!0;for(let e=1;e<=7;e+=3){const r=o.innerWidth*e/10,i=o.innerHeight/2,s=o.innerWidth/2,a=o.innerHeight*e/10,c=document.elementsFromPoint(r,i),u=document.elementsFromPoint(s,a);if(c.length>n){const e=[];f[`pointX-${r}-${i}`]||(f[`pointX-${r}-${i}`]=[]);for(let n=0;nn&&5!=e){const e=[];f[`pointY-${s}-${a}`]||(f[`pointY-${s}-${a}`]=[]);for(let n=0;n=r&&(Ot({type:"error",eventId:`${L.origin}.${L.module}.ERROR.whiteScreen`,msg:{_BiliCheckDom_Point:Object.assign({},f)}}),Xe.whiteErrorReplace()),xe.after($e.WHITESCREEN,Object.assign({},f))}))}function g(){u>=r&&c._loopTimer?(clearTimeout(c._loopTimer),c._loopTimer=null):c._loopTimer=setTimeout((()=>{u++,e.isSkeleton&&(d=[]),m()}),1e3)}e.isSkeleton?"complete"!=document.readyState&&m():"complete"===document.readyState?m():o.addEventListener("load",m)}(e.whiteScreen)}catch(e){console.error("bili-mirror: whiteScreen错误解析异常:",e)}L.config["resource-time"]&&Object.keys(L.config["resource-time"]).length&&c(o,"load",(function(){const e=new Ft;try{e.on()}catch(t){e.destroy(),console.warn("bili-mirror:resource-watch error",t)}}))}}const Kt=(e={})=>{const t=null==L?void 0:L.config["tech-pv"];if(!t)return;if(g(t))return;const n=`${L.origin}.${L.module}.TECHPV.0.0`;Ot({eventId:n,type:"custom",msg:Object.assign(Object.assign({},e),Le)})};var Wt;const Yt=s(),Jt=e=>{!function(e){const t=D();null==t||t.updateModule(e)}(e)},Gt=e=>{r()&&Rt(e)},Vt=e=>{r()&&Ot(e)},qt=e=>{r()&&It(e)},Xt=(e,t)=>{r()&&Rt({type:"pv",eventId:"0.0",msg:e,otherSpmId:t||null})},zt=e=>{r()&&h(e.key)&&Ot({type:"custom",eventId:e.eventId,diyevent:!0,msg:Object.assign(Object.assign({exclusiveFrom:(null==e?void 0:e.key)||""},e.msg),Le)})},Zt=()=>new Promise(((e,t)=>{Te.getAll().then((n=>{tt(n).then((t=>{e(t)})).catch((e=>{t(e)}))})).catch((e=>{t(e)}))})),Qt=(e,t,n)=>{et(e,t,n)},en=()=>Te.getAll(!1);function tn(e){r()&&(Yt.isInited||(Yt.isInited=!0,Yt.mirrorInitMode||(Yt.mirrorInitMode=ke.DEFAULT),j(e).then((()=>t(this,void 0,void 0,(function*(){yield Tt();(yield xe.before($e.INIT,e))&&(Ut(null==e?void 0:e.config),Kt(),nt(),xe.after($e.INIT,e),console.info("%c%s","line-height: 30px; color: #FF6699",`bili-fe-mirror:${I}`))})))).catch((e=>{console.warn(e)}))))}const nn=(e,t)=>{r()&&St(e,t)},rn=e=>{if(!r())return;if(!h(e.name))return;const t=`${L.origin}.${L.module}.PERFORMANCE.${e.name}`;Ot({type:"performance",eventId:t,msg:{name:e.name,value:e.value}})},on=(e={})=>{Kt(e)};if(r()){window.__INITIAL_MIRROR__=tn,window.__MIRROR_REPORT__={techReportPb:Vt,customReportPb:Gt,pbReportPv:Xt,changePbOptions:qt,canBatchTechReport:nn,customPerformanceQuota:rn,exclusiveBisReport:zt,changeMirrorModule:Jt,mirrorTechPvReport:on,trackLogReport:Zt,trackCustomLog:Qt,trackGetLog:en};const e=window.__MIRROR_CONFIG__,t=null===(Wt=null==e?void 0:e.config)||void 0===Wt?void 0:Wt.isAutoInit;e&&f.isObject(e)&&t&&(!Yt.mirrorInitMode&&(Yt.mirrorInitMode=ke.AUTO),tn(e))}var sn={SDK_NAME:_,SDK_VERSION:I,init:tn,install:function(e,t={}){let n=e.config.errorHandler;e.config.errorHandler=function(e,t,r){Dt.handleError(e),n&&n.apply(null,[e,t,r]),console.error(e)},tn(t)},errorBoundary:e=>{Dt.handleError(e)}};e.canBatchTechReport=nn,e.changeMirrorModule=Jt,e.changePbOptions=qt,e.customPerformanceQuota=rn,e.customReport=Gt,e.customReportPb=Gt,e.default=sn,e.exclusiveBisReport=zt,e.mirrorTechPvReport=on,e.pbReportPv=Xt,e.techReportPb=Vt,e.trackCustomLog=Qt,e.trackGetLog=en,e.trackLogReport=Zt,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=biliMirror.umd.mini.js.map