PageSourceSearch

https://91sp91.com/usr/themes/Mirages/js/7.10.0/web-sdk-v1.1.3.js?v=20260430

js 91sp91.com collected 2026-10-07 19:43:12 UTC 46,331 bytes, 1 lines download raw bytes

1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).WebSDK=t()}(this,function(){"use strict";function e(e){var t=function(e){for(var t=String(null==e?"":e),n=[],r=0;r<t.length;r++){var o=t.charCodeAt(r);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|63&o);else if(o>=55296&&o<=56319&&r+1<t.length){var i=t.charCodeAt(r+1);if(i>=56320&&i<=57343){var s=i-56320+(o-55296<<10)+65536;n.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s),r++}else n.push(224|o>>12,128|o>>6&63,128|63&o)}else n.push(224|o>>12,128|o>>6&63,128|63&o)}return n}(String(null==e?"":e)),n=8*t.length;for(t.push(128);t.length%64!=56;)t.push(0);for(var r=0;r<8;r++)t.push(n>>>8*r&255);for(var o=function(e,t){return e<<t|e>>>32-t},i=function(e,t){return((e>>>0)+(t>>>0)&4294967295)>>>0},s=function(e,t,n,r){return i(i(e,t),i(n,r))},a=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],u=new Array(64),c=0;c<64;c++)u[c]=Math.floor(4294967296*Math.abs(Math.sin(c+1)))>>>0;for(var d=1732584193,l=4023233417,f=2562383102,h=271733878,p=0;p<t.length;p+=64){for(var v=new Array(16),_=0;_<16;_++){var g=p+4*_;v[_]=(t[g]|t[g+1]<<8|t[g+2]<<16|t[g+3]<<24)>>>0}for(var y=d,m=l,w=f,b=h,k=0;k<64;k++){var P,S;k<16?(P=m&w|~m&b,S=k):k<32?(P=b&m|~b&w,S=(5*k+1)%16):k<48?(P=m^w^b,S=(3*k+5)%16):(P=w^(m|~b),S=7*k%16);var C=b;b=w,w=m,m=i(m,o(s(y,P,u[k],v[S]),a[k])),y=C}d=i(d,y),l=i(l,m),f=i(f,w),h=i(h,b)}var E=function(e){for(var t="",n=0;n<4;n++)t+=(256+(e>>>8*n&255)).toString(16).slice(1);return t};return E(d)+E(l)+E(f)+E(h)}function t(e,t){var n=65535&e,r=65535&t;return n*r+((e>>>16&65535)*r+n*(t>>>16&65535)<<16>>>0)|0}function n(e){for(var n=String(null==e?"":e),r=2166136261,o=0;o<n.length;o++)r=t(r^=n.charCodeAt(o),16777619);for(var i=(r>>>0).toString(16);i.length<8;)i="0"+i;return i}function r(e,t){if(null===e)return"__t:null__";if("string"==typeof e)return"__t:str__:"+e;if("number"==typeof e&&isFinite(e))return"__t:num__:"+String(e);if("boolean"==typeof e)return"__t:bool__:"+(e?"1":"0");if(Array.isArray(e)){if(-1!==t.indexOf(e))return"__t:circular__";t.push(e);var n="["+e.map(function(e){return r(e,t)}).join(",")+"]";return t.splice(t.indexOf(e),1),n}if(null!==e&&"object"==typeof e){if(-1!==t.indexOf(e))return"__t:circular__";t.push(e);var o="{"+Object.keys(e).sort().map(function(n){return n+":"+r(e[n],t)}).join(",")+"}";return t.splice(t.indexOf(e),1),o}return"__t:any__:"+String(e)}function o(e){return r(e,[])}function i(t){var n=t||{},r=Object.keys(n).filter(function(e){return"event_id"!==e}).sort();if(!r.length)return e("");var i=r.map(function(t){return e(o(n[t]))}).join("");return e(i)}function s(){if("undefined"==typeof navigator)return"PC";var e=navigator.userAgent||"";return/Android/i.test(e)?"Android":/iPhone|iPad|iPod/i.test(e)?"iOS":"PC"}function a(){try{var e="undefined"!=typeof navigator?navigator:{},t="undefined"!=typeof screen?screen:{},r="undefined"!=typeof Intl&&Intl.DateTimeFormat&&Intl.DateTimeFormat().resolvedOptions().timeZone||"",o=e.language||"",i=Array.isArray(e.languages)?e.languages.join(","):"",s=t.colorDepth||"",a=t.pixelDepth||"",u=void 0!==t.width&&void 0!==t.height?t.width+"x"+t.height:"",c=void 0!==t.availWidth&&void 0!==t.availHeight?t.availWidth+"x"+t.availHeight:"",d="undefined"!=typeof window&&window.devicePixelRatio?window.devicePixelRatio:"",l=e.maxTouchPoints||0,f=e.hardwareConcurrency||"",h=e.deviceMemory||"";return"fp_"+n([e.userAgent||"",e.platform||"",e.vendor||"",o,i,r,(new Date).getTimezoneOffset(),u,c,s,a,d,l,f,h].join("||"))}catch(e){return""}}function u(e){var t=String(null==e?"":e).trim();return t&&/^\d+\.\d+\.\d+$/.test(t)?t:"1.0.0"}function c(e){var t=e||{};return{app_id:String(t.appId||""),uid:null!=t.uid?t.uid:0,channel:String(t.channel||""),sid:String(t.sid||""),client_ts:Math.floor(Date.now()/1e3),device:String(t.deviceType||"PC"),device_id:String(t.deviceId||""),device_brand:String(t.deviceBrand||""),device_model:String(t.deviceModel||""),device_fingerprint:String(t.deviceFingerprint||""),fp_ver
1sion:String(t.fpVersion||""),user_agent:"undefined"!=typeof navigator&&navigator.userAgent||"",sdk_version:String(t.sdkVersion||""),app_version:String(t.appVersion||"1.0.0")}}var d="__web_sdk_sid__",l="__web_sdk_sid_v1",f="__web_sdk_device_id__",h="__web_sdk_device_fp__",p="__web_sdk_ping__",v=18e5,_=null,g=null;function y(){try{return!("undefined"==typeof window||!window.localStorage||(window.localStorage.setItem(p,"1"),window.localStorage.removeItem(p),0))}catch(e){return!1}}function m(){var e=new Uint8Array(16);if("undefined"!=typeof crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(var t=0;t<16;t++)e[t]=Math.floor(256*Math.random());for(var n="",r=0;r<e.length;r++)n+=("0"+e[r].toString(16)).slice(-2);return n}function w(){return"undefined"!=typeof document&&"string"==typeof document.cookie}function b(e){try{var t=JSON.parse(e);if(!t||!t.sid)return null;var n=String(t.sid).trim();if(!n)return null;var r="number"==typeof t.lastBehaviorAt?t.lastBehaviorAt:"number"==typeof t.ts?t.ts:null;return null!==r&&"number"==typeof r&&isFinite(r)?{sid:n,lastBehaviorAt:r}:null}catch(e){return null}}function k(e){var t=JSON.stringify(e);if(y())try{window.localStorage.setItem(d,t)}catch(e){}!function(e){if(w())try{var t=encodeURIComponent(e),n="path=/;max-age=31536000;SameSite=Lax";"undefined"!=typeof location&&"https:"===location.protocol&&(n+=";Secure"),document.cookie=encodeURIComponent(l)+"="+t+";"+n}catch(e){}}(t)}function P(e){var t={sid:m(),lastBehaviorAt:e};return _=t,k(t),t.sid}function S(){var e=Date.now();if(!y()){var t=function(){if(!w())return null;for(var e=encodeURIComponent(l)+"=",t=document.cookie.split("; "),n=0;n<t.length;n++)if(0===t[n].indexOf(e))try{return decodeURIComponent(t[n].slice(e.length))}catch(e){return null}return null}(),n=t?b(t):null,r=_||n;return!r||e-r.lastBehaviorAt>v?P(e):(_=r={sid:r.sid,lastBehaviorAt:e},k(r),r.sid)}var o=null;try{o=window.localStorage.getItem(d)}catch(e){}var i=o?b(o):null;if(!i&&_&&(i=_),!i||e-i.lastBehaviorAt>v)return P(e);var s={sid:i.sid,lastBehaviorAt:e};return _=s,k(s),s.sid}function C(){if(!y())return g||(g=m()),Promise.resolve(g);try{var e=window.localStorage.getItem(f);if(e&&/^[0-9a-f]{32}$/.test(e))return Promise.resolve(e);var t=m();return window.localStorage.setItem(f,t),Promise.resolve(t)}catch(e){return g||(g=m()),Promise.resolve(g)}}function E(e){try{if(y()){var t=window.localStorage.getItem(h);if(t)return t}var n=e();if(n&&y())try{window.localStorage.setItem(h,n)}catch(e){}return n}catch(e){return""}}function x(e,t,n){if(n=n||{},!e)return Promise.resolve({sent:!1,ok:!1,status:0,reason:"no_endpoint"});if(!Array.isArray(t)||0===t.length)return Promise.resolve({sent:!0,ok:!0,status:200,reason:"empty_batch"});var r=JSON.stringify(t),o=!0===n.useBeacon,i=!1!==n.requireHttps,s=Number(n.timeoutMs),a=isFinite(s)&&s>0?Math.floor(s):1e4;if(!function(e,t){if(!t)return!0;var n,r=String(e||"").match(/^(https?):\/\/([^/:?#]+)/i);return!!r&&("https"===r[1].toLowerCase()||"http"===r[1].toLowerCase()&&("localhost"===(n=String(r[2]||"").toLowerCase())||"127.0.0.1"===n||"::1"===n))}(e,i))return"undefined"!=typeof console&&console.warn&&console.warn("[sdk][web] 已拒绝非 HTTPS 上报地址(localhost HTTP 除外)"),Promise.resolve({sent:!1,ok:!1,status:0,reason:"insecure_endpoint"});if(o&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon)try{var u=new Blob([r],{type:"application/json"});if(navigator.sendBeacon(e,u))return Promise.resolve({sent:!0,ok:!0,status:200,transport:"beacon",uncertain:!0})}catch(e){}return function(e,t,n){if("function"!=typeof fetch)return Promise.resolve(null);var r="undefined"!=typeof AbortController?new AbortController:null,o=r&&n>0?setTimeout(function(){r.abort()},n):null;return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0,signal:r?r.signal:void 0}).then(function(e){return o&&clearTimeout(o),{sent:!0,ok:e.ok,status:Number(e.status||0),transport:"fetch"}}).catch(function(e){return o&&clearTimeout(o),e&&"object"==typeof e&&"AbortError"===e.name?{sent:!1,ok:!1,status:0,reason:"timeout",transport:"fetch"}:null})}(e,r,a).then(function(t){return null!==t?t:function(e,t,n){return new Promise(function(r){try{if("undefined"==typeof XMLHttpRequest)return r({sent:!1,ok:!1,status:0,reason:"no_xhr"});var o=new XMLHttpRequest;o.open("POST",e,!0),o.timeout=n,o.setRequestHeader("Content-Type","application/json"),o.onreadystatechange=function(){4===o.readyState&&r({sent:!0,ok:o.status>=200&&o.status<300,status:o.status,transport:"xhr"})},o.onerror=function(){r({sent:!1,ok:!1,status:0,reason:"xhr_error"})},o.ontimeout=function(){r({sent:!1,ok:!1,status:0,reason:"timeout",transport:"xhr"})},o.send(t)}catch(e){r({sent:!1,ok:!1,status:0,reason:"xhr_exception"})}})}(e,r,a)})}var A="1.1.3",O="1.0.0",T=5e3,I=!1;function D(e){e=e||{},this.selectedBatchEndpoint="",this.remoteEndpoints=[],this.remoteProbePromise=null,this.remoteProbeKey="",this.shouldPersistOnFail=!1,this.hasBatchProbeStarted=!1,this.initialized=!1,this.initPromise=null,this.endpointReadyListeners=[],this.timeoutMs=Number(e.pingTimeoutMs)||1500}D.prototype.normalizeBatchEndpoints=function(e){return(Array.isArray(e)?e:[]).map(function(e){return String(e||"").trim()}
1).filter(Boolean).filter(function(e){return/^https:\/\//i.test(e)}).map(function(e){var t=e.match(/^(https?:\/\/[^/?#]+)/i);return(t?t[1]:e.replace(/\/+$/,""))+"/api/eventTracking/batchReport.json"})},D.prototype._withTimeout=function(e,t){return new Promise(function(n,r){var o=setTimeout(function(){r(new Error("timeout"))},t);e.then(function(e){clearTimeout(o),n(e)}).catch(function(e){clearTimeout(o),r(e)})})},D.prototype._xhrRace=function(e,t){return e.length?new Promise(function(n){var r=e.length,o=!1,i=[];function s(){for(var e=0;e<i.length;e++)try{i[e].abort()}catch(e){}}for(var a=0;a<e.length;a++)(function(e){try{var a=new XMLHttpRequest,u=null,c=!1;function d(t){c||(c=!0,u&&(clearTimeout(u),u=null),t&&!o?(o=!0,s(),n(e)):t||(r--,o||0!==r||n("")))}i.push(a),u=setTimeout(function(){d(!1)},t),a.open("POST",e,!0),a.setRequestHeader("Content-Type","application/json"),a.onreadystatechange=function(){4===a.readyState&&d(a.status>0)},a.onerror=function(){d(!1)},a.send("[]")}catch(l){r--,o||0!==r||n("")}})(e[a])}):Promise.resolve("")},D.prototype._pickFastest=function(e,t){var n=this;if("undefined"==typeof fetch)return n._xhrRace(e,t);if(!e.length)return Promise.resolve("");var r="undefined"!=typeof AbortController,o=[];function i(){if(r)for(var e=0;e<o.length;e++)try{o[e].abort()}catch(e){}}return new Promise(function(s){for(var a=e.length,u=!1,c=0;c<e.length;c++)(function(e){var c=r?new AbortController:null;c&&o.push(c);var d={method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:"[]",cache:"no-store"};c&&(d.signal=c.signal),n._withTimeout(fetch(e,d),t).then(function(t){t&&t.status>0?u||(u=!0,i(),s(e)):(a--,u||0!==a||s(""))}).catch(function(){a--,u||0!==a||s("")})})(e[c])})},D.prototype._notifyReady=function(){var e=this.selectedBatchEndpoint;this.endpointReadyListeners.forEach(function(t){try{t(e)}catch(e){}})},D.prototype._setSelectedEndpoint=function(e){var t=String(e||"");t&&t!==this.selectedBatchEndpoint&&(this.selectedBatchEndpoint=t,this._notifyReady())},D.prototype.startRemoteProbe=function(e){var t=e.join("|");if(!e.length)return Promise.resolve("");if(this.remoteProbePromise&&this.remoteProbeKey===t)return this.remoteProbePromise;this.remoteProbeKey=t,this.shouldPersistOnFail=!1;var n=this,r=this._pickFastest(e,this.timeoutMs).then(function(t){if(n.remoteProbePromise!==r)return n.selectedBatchEndpoint;if(n.remoteProbePromise=null,t)n._setSelectedEndpoint(t);else if(!n.selectedBatchEndpoint&&e.length){n.shouldPersistOnFail=!0;var o=e[Math.floor(Math.random()*e.length)];n._setSelectedEndpoint(o)}return n.selectedBatchEndpoint}).catch(function(){return n.remoteProbePromise===r&&(n.remoteProbePromise=null),n.selectedBatchEndpoint});return this.remoteProbePromise=r,r},D.prototype.refreshDomainConfig=function(e){var t=this;return e().then(function(e){var n=t.normalizeBatchEndpoints(e);return t.remoteEndpoints=n,n.length?(t.hasBatchProbeStarted=!0,t.startRemoteProbe(n)):t.selectedBatchEndpoint})},D.prototype.init=function(e){return this.initialized?Promise.resolve():(this.initPromise||(this.initialized=!0,this.initPromise=this.refreshDomainConfig(e).catch(function(){})),this.initPromise)},D.prototype.resolveEndpoint=function(e,t){if(t)return Promise.resolve(t);var n=this;return this.init(e).then(function(){return n.selectedBatchEndpoint||""})},D.prototype.onEndpointReady=function(e){if("function"!=typeof e)return function(){};this.endpointReadyListeners.push(e);var t=this;return function(){var n=t.endpointReadyListeners.indexOf(e);n>=0&&t.endpointReadyListeners.splice(n,1)}},D.prototype.consumeProbeFailurePersistSignal=function(){return!!this.shouldPersistOnFail&&(this.shouldPersistOnFail=!1,!0)},D.prototype.getEndpointState=function(){return this.selectedBatchEndpoint?"ready":this.remoteEndpoints.length>0?"probing":"unavailable"},D.prototype.getSelectedBatchEndpoint=function(){return this.selectedBatchEndpoint};var B="__web_sdk_remote_config_cache__",M=function(){var e=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,9
10,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],t=[1,2,4,8,16,32,64,128,27,54];function n(e){return 255&(e<<1^(128&e?27:0))}function r(t){return(e[t>>>24&255]<<24|e[t>>>16&255]<<16|e[t>>>8&255]<<8|e[255&t])>>>0}function o(t,r){var o,i,s,a,u,c,d,l,f,h,p,v,_=t.slice(0);for(s=[],a=0;a<16;a++)_[a]=255&(_[a]^r[a>>2]>>>24-8*(3&a));for(u=1;u<=14;u++){for(o=[],a=0;a<16;a++)o[a]=e[_[a]];for(i=[],d=0;d<4;d++)for(l=0;l<4;l++)i[d+4*l]=o[d+4*(l+d&3)];if(u<14){for(s=[],c=0;c<4;c++)h=i[4*c+1],p=i[4*c+2],v=i[4*c+3],s[4*c]=255&(n(f=i[4*c])^n(h)^h^p^v),s[4*c+1]=255&(f^n(h)^n(p)^p^v),s[4*c+2]=255&(f^h^n(p)^n(v)^v),s[4*c+3]=255&(n(f)^f^h^p^n(v));for(_=s,s=[],a=0;a<16;a++)_[a]=255&(_[a]^r[4*u+(a>>2)]>>>24-8*(3&a))}else for(_=i,a=0;a<16;a++)_[a]=255&(_[a]^r[4*u+(a>>2)]>>>24-8*(3&a))}return _}function i(e,t){var n,r,o,i=[],s=t.slice(0);for(n=0;n<16;n++)i[n]=0;for(n=0;n<128;n++){if(e[n>>3]&128>>(7&n))for(r=0;r<16;r++)i[r]^=s[r];for(o=1&s[15],r=15;r>0;r--)s[r]=255&(s[r]>>>1|s[r-1]<<7);s[0]=s[0]>>>1&255,o&&(s[0]^=225)}return i}function s(e){var t,n=e.slice(0);for(t=15;t>=12&&(n[t]=n[t]+1&255,!n[t]);t--);return n}return{decrypt:function(e,n,a){var u,c,d,l,f,h,p,v,_,g,y,m,w,b,k=[],P=[],S=[],C=[];for(u=0;u<32;u++)k[u]=e[u]||0;for(u=0;u<12;u++)P[u]=n[u]||0;if((d=a.length-16)<0)return null;for(u=0;
1u<d;u++)S[u]=a[u];for(u=0;u<16;u++)C[u]=a[d+u];for(l=function(e){var n,o,i=[];for(n=0;n<8;n++)i[n]=(e[4*n]<<24|e[4*n+1]<<16|e[4*n+2]<<8|e[4*n+3])>>>0;for(n=8;n<60;n++)o=i[n-1],n%8?n%8==4&&(o=r(o)):o=(r((o<<8|o>>>24)>>>0)^t[n/8-1]<<24)>>>0,i[n]=(i[n-8]^o)>>>0;return i}(k),f=[],u=0;u<16;u++)f[u]=0;for(h=o(f,l),p=P.slice(0),u=12;u<15;u++)p[u]=0;for(p[15]=1,v=o(p,l),_=s(p),g=[],u=0;u<d;u+=16)for(y=o(_,l),_=s(_),c=0;c<16&&u+c<d;c++)g[u+c]=S[u+c]^y[c];for(m=S.slice(0);15&m.length;)m.push(0);for(u=0;u<8;u++)m.push(0);for(w=8*d,m.push(0,0,0,0),m.push(w>>>24&255,w>>>16&255,w>>>8&255,255&w),b=function(e,t){var n,r,o=[];for(n=0;n<16;n++)o[n]=0;for(n=0;n<t.length;n+=16){for(r=0;r<16;r++)o[r]^=t[n+r]||0;o=i(o,e)}return o}(h,m),u=0;u<16;u++)if((v[u]^b[u])!==C[u])return null;return g}}}();function j(e){this.encryptedConfigText=(e=e||{}).encryptedConfig||e.configCipher||"",this.cachedConfigPromise=null,this._secondGcmKeyBase64="en1BNo0VBrN/zi+mI2LO7E9W40ehCBYwC+frBn8s3rQ="}j.prototype.setEncryptedConfig=function(e){this.encryptedConfigText!==e&&(this.encryptedConfigText=e,this.cachedConfigPromise=null)},j.prototype._tryParse=function(e){try{return JSON.parse(e)}catch(t){return e}},j.prototype._unwrap=function(e,t){t=t||3;
1for(var n=e,r=0;r<t&&"string"==typeof n;r++){var o=this._tryParse(n);if(o===n)break;n=o}return n},j.prototype._toStringArray=function(e){var t=this._unwrap(e);if(Array.isArray(t))return t.map(function(e){return String(e||"").trim()}).filter(Boolean);if("string"==typeof t&&t.trim()){var n=this._tryParse(t);return Array.isArray(n)?n.map(function(e){return String(e||"").trim()}).filter(Boolean):[t.trim()]}return[]},j.prototype._getStorage=function(){try{return"undefined"!=typeof window&&window.localStorage?window.localStorage:null}catch(e){return null}},j.prototype._readPersisted=function(){try{var e=this._getStorage();if(!e)return{};var t=e.getItem(B);if(!t)return{};var n=JSON.parse(t);return Date.now()-(n.updatedAt||0)>24e5?{}:this._mapPayload(n)}catch(e){return{}}},j.prototype._mapPayload=function(e){if(!e||"object"!=typeof e)return{};var t=e.data&&"object"==typeof e.data?e.data:e;return{batchUrls:this._toStringArray(null!=t.batchUrls?t.batchUrls:t.domainList),eventCodes:this._toStringArray(null!=t.eventCodes?t.eventCodes:t.eventList)}},j.prototype._persist=function(e){try{var t=this._getStorage();if(!t)return;t.setItem(B,JSON.stringify({batchUrls:this._toStringArray(e.batchUrls),eventCodes:this._toStringArray(e.eventCodes),updatedAt:Date.now()}))}catch(e){}},j.prototype._base64ToBytes=function(e){for(var t=String(e||"").trim().replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4?4-t.length%4:0,r=0;r<n;r++)t+="=";if("undefined"!=typeof atob&&"undefined"!=typeof Uint8Array){for(var o=atob(t),i=new Uint8Array(o.length),s=0;s<o.length;s++)i[s]=o.charCodeAt(s);return i}return new Uint8Array(0)},j.prototype._decryptAes256Gcm=function(e,t){try{var n=this._base64ToBytes(e);if(n.length<28)return Promise.reject(new Error("密文过短"));var r=this._base64ToBytes(t),o=n.slice(0,12),i=n.slice(12);if("undefined"!=typeof crypto&&crypto.subtle)return crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["decrypt"]).then(function(e){return crypto.subtle.decrypt({name:"AES-GCM",iv:o},e,i)}).then(function(e){return new Uint8Array(e)});var s,a=M.decrypt(r,o,i);if(!a)return Promise.reject(new Error("AES-GCM 认证标签校验失败"));if("undefined"!=typeof Uint8Array){s=new Uint8Array(a.length);for(var u=0;u<a.length;u++)s[u]=a[u]}else s=a;return Promise.resolve(s)}catch(e){return Promise.reject(e)}},j.prototype.fetchAndDecryptConfig=function(){if(this.cachedConfigPromise)return this.cachedConfigPromise;var e=this,t=this._readPersisted();if(!this.encryptedConfigText)return this.cachedConfigPromise=Promise.resolve(t),this.cachedConfigPromise;var n=this._decryptAes256Gcm(this.encryptedConfigText,this._secondGcmKeyBase64).then(function(t){var n;if("undefined"!=typeof TextDecoder)n=(new TextDecoder).decode(t);else{for(var r=[],o=0;o<t.length;o++)r[o]=t[o];n=String.fromCharCode.apply(null,r)}var i=e._mapPayload(JSON.parse(n));return e._persist(i),i}).catch(function(e){return"undefined"!=typeof console&&console.warn&&console.warn("[sdk][config] 解密失败:",e),t});return this.cachedConfigPromise=n,n},j.prototype.getBatchEndpoints=function(){return this.fetchAndDecryptConfig().then(function(e){return e.batchUrls||[]})},j.prototype.getEventCodes=function(){return this.fetchAndDecryptConfig().then(function(e){return Array.isArray(e.eventCodes)&&e.eventCodes.length>0?e.eventCodes:[]})}
1,j.prototype.prewarm=function(){this.fetchAndDecryptConfig().catch(function(){})},j.prototype.forceRefresh=function(){this.cachedConfigPromise=null};var R="events";function F(e,t){var n=String(e&&e.event_id||"").trim();return n?n+"|||"+String(t||""):null}function q(e){for(var t={},n=Object.keys(e),r=0;r<n.length;r++)t[n[r]]=e[n[r]];return t}function L(){this.maxSize=2e3}L.prototype.isAvailable=function(){return"undefined"!=typeof indexedDB&&"undefined"!=typeof window&&null!=window.indexedDB},L.prototype.openDb=function(){var e=this;return new Promise(function(t,n){if(!e.isAvailable())return t(null);var r=indexedDB.open("web_sdk_event_queue",3);r.onerror=function(){n(r.error||new Error("open indexedDB failed"))},r.onupgradeneeded=function(e){var t=r.result,n=e.oldVersion,o=e.target.transaction;if(!t.objectStoreNames.contains(R)){var i=t.createObjectStore(R,{keyPath:"id",autoIncrement:!0});return i.createIndex("createdAt","createdAt",{unique:!1}),void i.createIndex("pendingDedupeKey","pendingDedupeKey",{unique:!0})}if(n<2&&o){var s=o.objectStore(R);s.indexNames.contains("pendingDedupeKey")||s.createIndex("pendingDedupeKey","pendingDedupeKey",{unique:!1})}if(n<3&&o){var a=o.objectStore(R);a.indexNames.contains("pendingDedupeKey")&&a.deleteIndex("pendingDedupeKey");var u=a.getAll();u.onsuccess=function(){for(var e=u.result||[],t={},n=0;n<e.length;n++){var r=e[n],o=r.pendingDedupeKey||F(r.record,r.endpointOverride);o&&(t[o]||(t[o]=[]),t[o].push(r.id))}for(var i=Object.keys(t),s=0;s<i.length;s++){var c=t[i[s]];if(c.length>=2){c.sort(function(e,t){return e-t});for(var d=1;d<c.length;d++)a.delete(c[d])}}try{a.createIndex("pendingDedupeKey","pendingDedupeKey",{unique:!0})}catch(e){}},u.onerror=function(){try{a.createIndex("pendingDedupeKey","pendingDedupeKey",{unique:!0})}catch(e){}}}},r.onsuccess=function(){t(r.result)}})},L.prototype._txDone=function(e){return new Promise(function(t,n){e.oncomplete=function(){t()},e.onerror=function(){n(e.error||new Error("tx failed"))},e.onabort=function(){n(e.error||new Error("tx aborted"))}})},L.prototype._trimOverflow=function(e){var t=this,n=R,r=e.transaction(n,"readonly");return new Promise(function(e,t){var o=r.objectStore(n).count();o.onsuccess=function(){e(Number(o.result||0))},o.onerror=function(){t(o.error)}}).then(function(e){return t._txDone(r).then(function(){return e})}).then(function(r){if(!(r<=t.maxSize)){var o=r-t.maxSize,i=e.transaction(n,"readwrite"),s=i.objectStore(n).index("createdAt"),a=0;return new Promise(function(e,t){var r=s.openCursor();r.onerror=function(){t(r.error)},r.onsuccess=function(){var t=r.result;if(!t||a>=o)return e();i.objectStore(n).delete(t.primaryKey),a++,t.continue()}}).then(function(){return t._txDone(i)})}})},L.prototype.enqueueMany=function(e){var t=this;return e&&e.length?this.openDb().then(function(n){if(n){var r=Date.now(),o=e.map(function(e,t){var n=e&&"object"==typeof e&&"record"in e?e:{record:e},o=F(n.record,n.endpointOverride||""),i={createdAt:r+t,record:n.record,endpointOverride:n.endpointOverride||"",retryCount:0,nextRetryAt:0};return o&&(i.pendingDedupeKey=o),i});return new Promise(function(e,t){var r=n.transaction(R,"readwrite"),i=r.objectStore(R);r.oncomplete=function(){e()},r.onerror=function(){t(r.error)},r.onabort=function(){t(r.error)};var s=0;!function e(){if(!(s>=o.length)){var n=o[s++],r=i.add(n);r.onsuccess=function(){e()},r.onerror=function(n){var o=r.error;if(o&&"ConstraintError"===o.name)return n.preventDefault(),void e();t(o||new Error("add failed"))}}}()}).then(function(){return t._trimOverflow(n)}).then(function(){n.close()}).catch(function(e){throw n.close(),e})}}):Promise.resolve()},L.prototype.readOldest=function(e){return e=e||20,this.openDb().then(function(t){if(!t)return[];var n=Date.now(),r=[];return new Promise(function(o,i){var s=t.transaction(R,"readonly").objectStore(R).index("createdAt").openCursor();s.onerror=function(){i(s.error)},s.onsuccess=function(){var t=s.result;if(!t||r.length>=e)return o();var i=t.value,a=Number(i.nextRetryAt),u=isFinite(a)?Math.floor(a):0;if(u<=n){var c=q(i);c.endpointOverride=i.endpointOverride||"";var d=Number(i.retryCount);
1c.retryCount=isFinite(d)?Math.floor(d):0,c.nextRetryAt=u,r.push(c)}t.continue()}}).then(function(){return t.close(),r}).catch(function(e){throw t.close(),e})})},L.prototype.removeByIds=function(e){var t=this;return e&&e.length?this.openDb().then(function(n){if(n){for(var r=n.transaction(R,"readwrite"),o=r.objectStore(R),i=0;i<e.length;i++)o.delete(e[i]);return t._txDone(r).then(function(){n.close()}).catch(function(e){throw n.close(),e})}}):Promise.resolve()},L.prototype.updateRetryMeta=function(e,t,n){var r=this;return e&&e.length?this.openDb().then(function(o){if(!o)return{dropped:0,kept:0};for(var i=Date.now(),s=Number(t),a=isFinite(s)?Math.max(0,Math.floor(s)):0,u=Number(n),c=isFinite(u)?Math.max(0,Math.floor(u)):0,d=0,l=0,f=o.transaction(R,"readwrite"),h=f.objectStore(R),p=0;p<e.length;p++){var v=e[p],_=Number(v.retryCount),g=(isFinite(_)?Math.floor(_):0)+1;if(g>c)d++,h.delete(v.id);else{l++;var y=v.pendingDedupeKey||F(v.record,v.endpointOverride||""),m=q(v);y&&(m.pendingDedupeKey=y),m.retryCount=g,m.nextRetryAt=i+a,h.put(m)}}return r._txDone(f).then(function(){return o.close(),{dropped:d,kept:l}}).catch(function(e){throw o.close(),e})}):Promise.resolve({dropped:0,kept:0})},L.prototype.count=function(){var e=this;return this.openDb().then(function(t){if(!t)return 0;var n=t.transaction(R,"readonly");return new Promise(function(e,t){var r=n.objectStore(R).count();r.onsuccess=function(){e(Number(r.result||0))},r.onerror=function(){t(r.error)}}).then(function(r){return e._txDone(n).then(function(){return t.close(),r})}).catch(function(e){throw t.close(),e})})};var K={navigation:{navigation_key:1,navigation_name:1},appPageView:{user_type:1,page_key:1,page_name:1,referrer_page_key:9,referrer_page_name:9,current_page_key:1,current_page_name:1,page_load_time:3,recommend_trace_id:0},appInstall:{trace_id:1,attribution_flag:2},pageClick:{page_key:1,page_name:1,click_page_x:3,click_page_y:3,click_x_percent:3,click_y_percent:3,screen_width:3,screen_height:3,recommend_trace_id:0},recommendListView:{page_key:1,page_name:1,recommend_content_type:1,recommend_trace_id:0,recommend_id:1,recommend_trace_info:0,client_version:0},recommendListClick:{page_key:1,page_name:1,recommend_content_type:1,recommend_trace_id:0,recommend_id:1,recommend_trace_info:0,client_version:0},advertising:{event_type:1,advertising_key:1,advertising_name:1,advertising_id:1},videoEvent:{media_id:0,video_id:1,video_title:1,video_type_id:1,video_type_name:1,video_content_type:9,recommend_trace_id:0,video_tag_key:9,video_tag_name:9,video_duration:3,play_duration:3,play_progress:3,video_behavior_key:1,video_behavior_name:1},novelEvent:{media_id:0,novel_id:1,novel_title:1,chapter_id:0,chapter_name:0,novel_type_id:1,novel_type_name:1,recommend_trace_id:0,novel_tag_key:9,novel_tag_name:9,read_progress:3,page_no:3,novel_behavior_key:1,novel_behavior_name:1},comicEvent:{media_id:0,comic_id:1,comic_title:1,chapter_id:0,chapter_name:0,comic_type_id:1,comic_type_name:1,recommend_trace_id:0,comic_tag_key:9,comic_tag_name:9,read_progress:3,page_no:3,comic_behavior_key:1,comic_behavior_name:1},keywordSearch:{keyword:1,search_result_count:3,search_content_type:0,search_trace_id:0,search_id:0},keywordClick:{keyword:1,click_item_id:1,click_item_type_key:1,click_item_type_name:1,click_position:3,search_trace_id:0},adImpression:{page_key:1,page_name:1,ad_slot_key:1,ad_slot_name:1,ad_id:1,creative_id:0,ad_type:0},adClick:{page_key:1,page_name:1,ad_slot_key:1,ad_slot_name:1,ad_id:1,creative_id:0,ad_type:0}},V={navigation:"navigation",appPageView:"app_page_view",appInstall:"app_install",pageClick:"page_click",recommendListView:"recommend_list_view",recommendListClick:"recommend_list_click",advertising:"advertising",videoEvent:"video_event",novelEvent:"novel_event",comicEvent:"comic_event",keywordSearch:"keyword_search",keywordClick:"keyword_click",adImpression:"ad_impression",adClick:"ad_click"};function N(e,t){var n=K[e];if(!n)throw new Error("[sdk][web] 未知事件方法:"+e);var r=t||{},o={},i=[],s=[];if(Object.keys(n).forEach(function(e){var t,a=n[e],u=1&a,c=a>>1&3,d=!!(8&a),l=r[e];if(d&&null===l&&(l=""),!u||d||null!=l&&""!==l){if(u&&d&&void 0===l)i.push(e);else if(u||null!=l){(1===c?"number"==typeof(t=l)&&isFinite(t)&&t===Math.floor(t):2===c?function(e){return"number"==typeof e&&isFinite(e)}(l):function(e){return"string"==typeof e}(l))?o[e]=l:s.push(e+"(expected "+(1===c?"int":2===c?"number":"string")+")")}}else i.push(e)}),i.length||s.length){var a=new Error("[sdk][web] 事件字段校验失败:"+e);throw a.name="EventValidationError",a.eventMethod=e,a.missingFields=i.slice(),a.typeErrorFields=s.slice(),a}return o}var H=Object.keys(V).reduce(function(e,t){var n=V[t];return e[t]=function(e){return{event:n,payload:N(t,e||{})}},e},{});function U(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var r=Object.keys(n),o=0;o<r.length;o++)e[r[o]]=n[r[o]]}return e}var z="undefined"!=typeof console&&console.warn?function(e){console.warn(e)}:function(){},Q=6e4,G="__web_sdk_recent_ok_event_ids__",J=function(){var e={};function t(t){for(var n=Object.keys(e),r=0;r<n.length;r++)t-e[n[r]]>Q&&delete e[n[r]]}function n(){try{"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(G,JSON.stringify(e))}catch(e){}}if(function(){try{if("undefined"!=typeof window&&window.localStorage){var t=window.localStorage.getItem(G);if(t)for(var n=JSON.parse(t),r=Date.now(),o=Object.keys(n),i=0;i<o.length;i++)/^[0-9a-f]{32}$/.test(o[i])&&r-n[o[i]]<=Q&&(e[o[i]]=n[o[i]])}}catch(e){}}(),"undefined"!=typeof window)try{window.addEventListener("storage",function(t){try{if(t.key!==G||!t.newValue)return;for(var n=JSON.parse(t.newValue),r=Date.now(),o=Object.keys(n),i=0;i<o.length;i++){var s=n[o[i]];/^[0-9a-f]{32}$/.test(o[i])&&r-s<=Q&&(e[o[i]]=s)}}catch(e){}})}catch(e){}return{has:function(n){if(!n)return!1;var r=Date.now();t(r);var o=e[n];return void 0!==o&&r-o<=Q},set:function(r){var o=Date.now();t(o);for(var i=0;i<r.length;i++)r[i]&&(e[r[i]]=o);var s=Object.keys(e);if(s.length>500){for(var a="",u=1/0,c=0;c<s.length;c++)e[s[c]]<u&&(u=e[s[c]],a=s[c]);a&&delete e[a]}n()},reset:function(){e={},n()}}}();function W(e,t){this.opts=e,this.resolver=t,this.queue=[],this.timer=null,this.flushTail=Promise.resolve(),this.replaying=!1,this.replayTimer=null,this.hasPersistentItems=!0,this.persistentQueue=new L,this._resolveEndpoint=null,this._getEventC
1odes=null,this.startReplayTimer()}function $(e){if("undefined"==typeof window)return z("[web-sdk] 非浏览器环境(SSR/Node.js),SDK 仅支持浏览器,初始化已跳过。"),this._ssrSkipped=!0,this.options=e,this.configMgr=null,this.resolver=null,void(this.batcher=null);if(!Object.prototype.hasOwnProperty.call(e,"channel"))throw new Error('channel 为必传字段(可传空字符串 "")');this._ssrSkipped=!1;var t=U(e);t.channel=null==e.channel?"":String(e.channel),this.options=t,this.configMgr=new j(e),this.resolver=new D({pingTimeoutMs:1500}),this.batcher=new W(this.options,this.resolver);var n=this;this.batcher._resolveEndpoint=function(e){return n.resolver.resolveEndpoint(function(){return n.configMgr.getBatchEndpoints()},e)},this.batcher._getEventCodes=function(){return n.configMgr.getEventCodes()},this._unsubReady=null,this._onPageHide=null,this._onVisChange=null,this._refreshTimer=null,this._init({}),this._registerLifecycle()}W.prototype.startReplayTimer=function(){var e=this;this.replayTimer=setInterval(function(){e.replayPersistent()},T)},W.prototype._stopTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},W.prototype._settleItem=function(e,t){e.settled||(e.settled=!0,e.timeoutTimer&&(clearTimeout(e.timeoutTimer),e.timeoutTimer=null),e.resolve(t))},W.prototype._purgeSettled=function(){this.queue.length&&(this.queue=this.queue.filter(function(e){return!e.settled}))},W.prototype._toPersistentEntries=function(e){return e.map(function(e){return{record:e.record,endpointOverride:e.endpointOverride||"",retryCount:0,nextRetryAt:0}})},W.prototype._getRetryDelay=function(e){var t=Math.min(10,Math.max(0,e));return Math.min(6e4,Math.max(T,Math.floor(T*Math.pow(2,t))))},W.prototype.schedule=function(){var e=this;this._purgeSettled(),!this.timer&&this.queue.length&&(this.timer=setTimeout(function(){e.timer=null,e.flush().catch(function(){})},5e3))},W.prototype.flush=function(){var e=this,t=this.flushTail.then(function(){return e.flushOnce()});return this.flushTail=t.catch(function(){}),t},W.prototype._processFlushGroup=function(e,t,n){for(var r=this,o="__default__"===e?"":e,i=[],s=[],a=0;a<t.length;a++){var u=t[a],c=String(u.record&&u.record.event_id||"").trim();(c&&J.has(c)?s:i).push(u)}for(var d=0;d<s.length;d++)r._settleItem(s[d],{sent:!1,ok:!1,status:0,reason:"cross_batch_recent_success_deduped"});if(!i.length)return Promise.resolve();if(!r._resolveEndpoint){z("[sdk][web] _resolveEndpoint 未注入,事件无法发送");for(var l=0;l<i.length;l++)r._settleItem(i[l],{sent:!1,ok:!1,status:0,reason:"no_endpoint_resolver"});return Promise.resolve()}for(var f={},h=[],p={},v=0;v<i.length;v++){var _=i[v],g=String(_.record&&_.record.event_id||"").trim()||"__empty__:"+v;f[g]||(f[g]=!0,h.push(_.record),p[v]=!0)}return r.resolver.consumeProbeFailurePersistSignal()?r.persistentQueue.enqueueMany(r._toPersistentEntries(i)).then(function(){r.hasPersistentItems=!0;for(var e=0;e<i.length;e++)r._settleItem(i[e],{sent:!1,ok:!1,status:0,reason:"probe_all_failed"})}).catch(function(){}):r._resolveEndpoint(o).then(function(e){if(e){for(var t=[],o=0;o<h.length;o++){var s=String(h[o]&&h[o].event_id||"").trim();if(s&&J.has(s)){for(var a=0;a<i.length;a++)if(p[a]&&String(i[a].record&&i[a].record.event_id||"").trim()===s){r._settleItem(i[a],{sent:!1,ok:!1,status:0,reason:"cross_batch_recent_success_deduped"}),p[a]=!1;break}}else t.push(h[o])}if(!t.length){for(var u=0;u<i.length;u++)p[u]||r._settleItem(i[u],{sent:!1,ok:!1,status:0,reason:"batch_deduped_duplicate"});return Promise.resolve()}return x(e,t,{useBeacon:I}).then(function(e){var n=Promise.resolve();if(e&&e.ok){for(var o=[],s=0;s<t.length;s++){var a=String(t[s]&&t[s].event_id||"").trim();a&&o.push(a)}J.set(o)}else{for(var u=[],c=0;c<i.length;c++)p[c]&&u.push(i[c]);n=r.persistentQueue.enqueueMany(r._toPersistentEntries(u)).then(function(){r.hasPersistentItems=!0}).catch(function(){})}return n.then(function(){for(var t=0;t<i.length;t++)r._settleItem(i[t],p[t]?e:{sent:!1,ok:!1,status:0,reason:"batch_deduped_duplicate"})})})}if("unavailable"===r.resolver.getEndpointState())return r.persistentQueue.enqueueMany(r._toPersistentEntries(i)).then(function(){r.hasPersistentItems=!0;for(var e=0;e<i.length;e++)r._settleItem(i[e],{sent:!1,ok:!1,status:0,reason:"endpoint_unavailable"})}).catch(function(){});for(var c=0;c<i.length;c++)n.push(i[c])})},W.prototype.flushOnce=function(){var e=this;if(this._purgeSettled(),!this.queue.length)return Promise.resolve();this._stopTimer();for(var t=this.queue.splice(0,10),n={},r=0;r<t.length;r++){var o=t[r];if(!o.settled){var i=o.endpointOverride||"__default__";n[i]||(n[i]=[]),n[i].push(o)}}for(var s=[],a=Object.keys(n),u=Promise.resolve(),c=0;c<a.length;c++)(function(t){u=u.then(function(){return e._processFlushGroup(t,n[t],s)})})(a[c]);return u.then(function(){if(s.length){for(var t=Date.now(),n=[],r=[],o=0;o<s.length;o++)(s[o].timeoutAt<=t?n:r).push(s[o]);for(var i=0;i<r.length;i++)e.queue.push(r[i]);for(var a=Promise.resolve(),u=0;u<n.length;u++)(function(t){a=a.then(function(){return e.persistentQueue.enqueueMany(e._toPersistentEntries([t])).catch(function(){}).then(function(){e.hasPersistentItems=!0,e._settleItem(t,{sent:!1,ok:!1,status:0,reason:"track_timeout",transport:"queue"})})})})(n[u]);return a}}).then(function(){e.queue.length&&e.schedule()},function(t){throw e.queue.length&&e.schedule(),t})},W.prototype._processReplayGroup=function(e,t){var n=this;return n._resolveEndpoint?n._resolveEndpoint("__default__"===e?"":e).then(function(e){if(e){for(var r={},o=[],i=[],s=[],a=0;a<t.length;a++){var u=t[a],c=String(u.record&&u.record.event_id||"").trim()||"__empty__:"+u.id,d=String(u.record&&u.record.event_id||"").trim();d&&J.has(d)||r[c]?s.push(u.id):(r[c]=!0,o.push(u.record),i.push(u.id))}var l=Promise.resolve();return s.length&&(l=l.then(function(){return n.persistentQueue.removeByIds(s)})),o.length?l.then(function(){return x(e,o,{useBeacon:I})}).then(function(e){if(e&&e.ok){for(var r=[],a=0;a<o.length;a++){var u=String(o[a]&&o[a].event_id||"").trim();u&&r.push(u)}J.set(r);for(var c=[],d=0;d<i.length;d++)c.push(i[d]);for(var l=0;l<s.length;l++)c.push(s[l]);return n.persistentQueue.removeByIds(c)}for(var f=0,h=0;h<t.length;h++){var p=t[h].retryCount||0;p>f&&(f=p)}var v=n._getRetryDelay(f);return n.persistentQueue.updateRetryMeta(t,v,5)}):l}}):(z("[sdk][web] _resolveEndpoint 未注入,持久队列重试跳过"),Promise.resolve())},W.prototype.replayPersistent=function(){var e=this;return!this.hasPersistentItems||this.replaying?Promise.resolve():(this.replaying=!0,this.persistentQueue.readOldest(10).then(function(t){if(!t.length)return e.persistentQueue.count().then(function(t){0===t&&(e.hasPersistentItems=!1)});for(var n={},r=0;r<t.length;r++){var o=t[r],i=o.endpointOverride||"__default__";n[i]||(n[i]=[]),n[i].push(o)}for(var s=Object.keys(n),a=Promise.resolve(),u=0;u<s.length;u++)(function(t){a=a.then(function(){return e._processReplayGroup(t,n[t])})})(s[u]);return a}).catch(function(){}).then(function(){e.replaying=!1},function(){e.replaying=!1}))},W.prototype.track=function(e,t){var n=this;return C().then(function(r){var o=c({appId:n.opts.appId,channel:n.opts.channel,uid:n.opts.uid||"",sid:S(),deviceId:n.opts.deviceId||r,deviceType:s(),deviceBrand:"",deviceModel:"",deviceFingerprint:E(a),fpVersion:O,sdkVersion:A,appVersion:u(n.opts.appVersion)}),d=String(e.event||"").trim(),l=U(e.payload||{}),f={event:1,payload:1,event_id:1};Object.keys(e).forEach(function(t){f[t]||Object.prototype.hasOwnProperty.call(o,t)||(l[t]=e[t])});var h=function(e,t){var n=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var r=Object.keys(n),o=0;o<r.length;o++)e[r[o]]=n[r[o]]}return e}(e,t);
1return n.event_id||(n.event_id=i(n)),n}(o,{event:d,payload:l});return(n._getEventCodes?n._getEventCodes():Promise.resolve([])).then(function(e){return e&&0===e.length?(z("[sdk][web] 当前没有事件允许上报,请检查服务端配置(eventCodes 为空)"),{sent:!1,ok:!1,status:0,reason:"event_code_not_allowed",event:h.event}):e&&-1===e.indexOf(h.event)?(z('[sdk][web] 事件 "'+h.event+'" 不在服务端允许上报的列表中,已忽略'),{sent:!1,ok:!1,status:0,reason:"event_code_not_allowed",event:h.event}):new Promise(function(e,r){var o=Date.now(),i={record:h,endpointOverride:t||"",resolve:e,reject:r,settled:!1,timeoutAt:o+3e4,timeoutTimer:null};i.timeoutTimer=setTimeout(function(){i.settled||n.persistentQueue.enqueueMany(n._toPersistentEntries([i])).catch(function(){}).then(function(){n.hasPersistentItems=!0,n._settleItem(i,{sent:!1,ok:!1,status:0,reason:"track_timeout",transport:"queue"})})},3e4),n.queue.push(i),n.queue.length>=10?n.flush().catch(function(){}):n.schedule()})})})},W.prototype.stop=function(){this._stopTimer(),this.replayTimer&&(clearInterval(this.replayTimer),this.replayTimer=null);var e={sent:!1,ok:!1,status:0,reason:"stopped"},t=this;this.queue.splice(0).forEach(function(n){t._settleItem(n,e)})},W.prototype.getConfig=function(){return{batchMaxSize:10,batchIntervalMs:5e3,replayBatchSize:10,replayIntervalMs:T}},$.prototype._registerLifecycle=function(){if("undefined"!=typeof window){var e=this;this._onPageHide=function(){e.batcher.flush().catch(function(){})},this._onVisChange=function(){"undefined"!=typeof document&&"hidden"===document.visibilityState&&e.batcher.flush().catch(function(){})},window.addEventListener("pagehide",this._onPageHide),window.addEventListener("visibilitychange",this._onVisChange)}},$.prototype._init=function(e){if(this._ssrSkipped)return this._buildInitReturn();for(var t=Object.keys(e||{}),n=0;n<t.length;n++)this.options[t[n]]=e[t[n]];null==this.options.channel&&(this.options.channel=""),this.configMgr.setEncryptedConfig(this.options.encryptedConfig||this.options.configCipher||""),this.configMgr.prewarm();var r=this;return this.resolver.init(function(){return r.configMgr.getBatchEndpoints()}),this._refreshTimer&&clearInterval(this._refreshTimer),this._refreshTimer=setInterval(function(){r.refreshConfig()},12e5),this._unsubReady&&this._unsubReady(),this._unsubReady=this.resolver.onEndpointReady(function(){r.batcher.flush().catch(function(){})}),this._buildInitReturn()},$.prototype.refreshConfig=function(){var e=this;return this.configMgr.forceRefresh(),this.resolver.refreshDomainConfig(function(){return e.configMgr.getBatchEndpoints()}).catch(function(){})},$.prototype.track=function(e,t){return this._ssrSkipped?Promise.resolve({sent:!1,ok:!0,status:0,reason:"ssr_skipped"}):this.batcher.track(e,t)},$.prototype.setContext=function(e){if(this._ssrSkipped)return this.getConfig();var t=e&&"object"==typeof e?e:{};return Object.prototype.hasOwnProperty.call(t,"uid")&&(this.options.uid=null==t.uid?"":String(t.uid)),Object.prototype.hasOwnProperty.call(t,"channel")&&(this.options.channel=null==t.channel?"":String(t.channel)),this.batcher.opts=U(this.options),this.getConfig()},$.prototype.setUid=function(e){return this.setContext({uid:e})},$.prototype.getSelectedHost=function(){if(this._ssrSkipped||!this.resolver)return"";var e=this.resolver.getSelectedBatchEndpoint();if(!e)return"";var t=/^(https?:\/\/[^/]+)/.exec(e);return t?t[1]:""},$.prototype._buildInitReturn=function(){return this._ssrSkipped||!this.batcher?{selectedHost:"",version:A}:U(this.batcher.getConfig(),{selectedHost:this.getSelectedHost(),version:A})},$.prototype.getConfig=function(){if(this._ssrSkipped||!this.batcher)return U(this.options,{selectedHost:"",selectedBatchEndpoint:"",version:A});var e=U(this.options,this.batcher.getConfig(),{selectedHost:this.getSelectedHost(),selectedBatchEndpoint:this.resolver.getSelectedBatchEndpoint(),version:A});return delete e.encryptedConfig,delete e.configCipher,e},$.prototype.flush=function(){return this._ssrSkipped?Promise.resolve():this.batcher.flush()},$.prototype.refreshDomainConfig=function(){if(this._ssrSkipped)return Promise.resolve({selectedBatchEndpoint:"",selectedHost:"",version:A});var e=this;return this.resolver.refreshDomainConfig(function(){return e.configMgr.getBatchEndpoints()}).then(function(t){return{selectedBatchEndpoint:t,selectedHost:e.getSelectedHost(),version:A}})},$.prototype.stop=function(){this._ssrSkipped||(this._unsubReady&&(this._unsubReady(),this._unsubReady=null),"undefined"!=typeof window&&(this._onPageHide&&window.removeEventListener("pagehide",this._onPageHide),this._onVisChange&&window.removeEventListener("visibilitychange",this._onVisChange)),this._refreshTimer&&(clearInterval(this._refreshTimer),this._refreshTimer=null),this.batcher.stop())};var X=null,Y=[],Z=null;function ee(e){if(!X)throw new Error("请先调用 init() 初始化(参数须包含 channel)");return X}function te(e,t,n){if(n>=e.length)return Promise.resolve();if(!X||X!==t){for(var r=e.slice(n),o=r.length-1;o>=0;o--)Y.unshift(r[o]);return Promise.resolve()}var i=e[n];
1return t.track(i.event,i.endpoint).catch(function(){}).then(function(){return te(e,t,n+1)})}function ne(e,t){if(X){var n=X;return(Z||Promise.resolve()).then(function(){return n.track(e,t)})}return Y.push({event:e,endpoint:t}),Y.length>500&&Y.shift(),Promise.resolve({sent:!1,ok:!0,status:0,reason:"pre_init_cached"})}var re=ne;re.setContext=function(e){return ee().setContext(e)},re.setUid=function(e){return ee().setUid(e)},re.setChannel=function(e){return ee().setContext({channel:e})},re.notifyPageLoad=function(){P(Date.now())},re.getConfig=function(){return ee().getConfig()},re.flush=function(){return ee().flush()},re.refreshDomainConfig=function(){return ee().refreshDomainConfig()},re.stop=function(){X?(X.stop(),X=null):Y.length=0},re.version=A,re.getCommonFields=function(e){var t=X?X.getConfig():{};return C().then(function(n){var r=c({appId:t.appId,channel:t.channel,uid:t.uid,deviceId:t.deviceId||n,sid:S(),deviceType:s(),deviceBrand:"",deviceModel:"",deviceFingerprint:E(a),fpVersion:O,sdkVersion:A,appVersion:u(t.appVersion)});if(!Array.isArray(e)||!e.length)return r;for(var o={},i=0;i<e.length;i++){var d=String(e[i]||"").trim();d&&(o[d]=Object.prototype.hasOwnProperty.call(r,d)?r[d]:"")}return o})},re.getCommonField=function(e){var t=String(e||"").trim();return t?re.getCommonFields([t]).then(function(e){return e[t]}):Promise.resolve("")},re.init=function(e){if(X){var t=X;X=null,t.flush().catch(function(){}).then(function(){t.stop()})}var n=new $(e);X=n;var r,o=te(Y.splice(0),n,0).then(function(){Z===r&&(Z=null)},function(){Z===r&&(Z=null)});return Z=r=o,U(n._buildInitReturn(),{track:re.track,setContext:re.setContext,setUid:re.setUid,setChannel:re.setChannel,notifyPageLoad:re.notifyPageLoad,getCommonFields:re.getCommonFields,getCommonField:re.getCommonField})};var oe=function(){return z("[sdk][web] 非法上报:禁止直接调用 WebSDK.track({...}),请使用 WebSDK.track.videoEvent({...}) 等具名方法"),Promise.resolve({sent:!1,ok:!1,status:0,reason:"direct_track_forbidden"})};if(Object.keys(H).forEach(function(e){var t=H[e];oe[e]=function(n,r){try{return ne(t(n),r)}catch(t){if(t&&"EventValidationError"===t.name)return Promise.resolve({sent:!1,ok:!1,status:0,reason:"event_validation_failed",event:t.eventMethod||e,missingFields:t.missingFields||[],typeErrorFields:t.typeErrorFields||[]});throw t}}}),re.track="undefined"!=typeof Proxy?new Proxy(oe,{get:function(e,t){return"string"!=typeof t||t in e||!/^[a-z]/.test(t)?e[t]:function(){return z('[sdk][web] 未知上报事件 "'+t+'",该方法不存在,事件未上报'),Promise.resolve({sent:!1,ok:!1,status:0,reason:"unknown_event_method",method:t})}}}):oe,"undefined"!=typeof globalThis)try{globalThis.WebSDK=re}catch(n){}else"undefined"!=typeof window&&(window.WebSDK=re);return re});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.