douxiaoyun.js/profiles/douyin-profile/Default/Cache/Cache_Data/f_00040b
2026-07-17 22:23:39 +08:00

2 lines
125 KiB
Plaintext

/*! For license information please see 62977.3173b1dd.js.LICENSE.txt */
"use strict";(self.webpackChunkdouyin_web=self.webpackChunkdouyin_web||[]).push([["62977"],{83238:function(t,e,n){n.d(e,{TncManager:function(){return ef},proxyFetch:function(){return e_},proxyXhr:function(){return eC}});var r,o,i,c,a,s,u,l,h=n(777296),d=function(t,e){return(d=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function f(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var p=function(){return(p=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n],e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function v(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&0>e.indexOf(r)&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)0>e.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function m(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function y(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=e.call(t,c)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function g(t,e,n){if(n||2==arguments.length)for(var r,o=0,i=e.length;o<i;o++)(r||!(o in e))&&(!r&&(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}var b=function(){function t(t){var e=t.tncConfig,n=t.plugins;this.tncConfig=p({region:"internal"},e),this.plugins=n}return t.prototype.updateTncConfig=function(t){this.tncConfig=t.tncConfig},t.prototype.updateUserId=function(t){this.tncConfig=p(p({},this.tncConfig),{user_id:t})},t.prototype.updateCustomHeaders=function(t){this.tncConfig=p(p({},this.tncConfig),{customHeaders:t})},t}();function _(t){return null==t||!1}var S=/[\t\n\f\r ]/g,w=[function(t,e){let n=t.replace(/\$/g,"V").replace(/\-/g,"Y").replace(/\*/g,"G").replace(/\%/g,"U");try{for(let t=0;t<3;t++)n=function(t){let{length:e}=t=String(t).replace(S,"");if(e%4==0&&(e=(t=t.replace(/==?$/,"")).length),e%4==1||/[^+a-zA-Z0-9/]/.test(t))throw Error("Invalid character: the string to be decoded is not correctly encoded.");let n=0,r,o,i="",c=-1;for(;++c<e;)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t.charAt(c)),r=n%4?64*r+o:o,n++%4&&(i+=String.fromCharCode(255&r>>(-2*n&6)));return i}(n)}catch(t){throw t}return n.slice(0,n.length-5)}("Wk$jMWFreFhTblph$Xp*NldsaEtNbHBZ%1hWWmJtd3dXb*RSZFdJelNtN$pXRXB1WkZoTlBRPT0")],C=["tnc16-alisg.byteoversea.com"],T=["tnc0-aliec2.zijieapi.com","tnc0-alisc1.zijieapi.com","8.133.123.137","8.133.123.138","8.133.123.139","8.133.123.140"];function k(t){var e,n;(null===(n=null===(e=null==navigator?void 0:navigator.serviceWorker)||void 0===e?void 0:e.controller)||void 0===n?void 0:n.state)==="activated"&&navigator.serviceWorker.controller.postMessage(t)}(r=a||(a={})).tnc_config_table="tnc_config_table",r.tnc_dynamic_routing="tnc_dynamic_routing",r.tnc_elimination="tnc_elimination",r.tnc_best_routing="tnc_best_routing";var R={dbName:"TNC_STORE_V1",dbVersion:1,tableStructures:[{name:a.tnc_config_table,storeParameters:{keyPath:["aid"]}},{name:a.tnc_dynamic_routing,storeParameters:{keyPath:["ttnet_dispatch_actions_epoch"]}},{name:a.tnc_elimination,storeParameters:{keyPath:["ttnet_dispatch_actions_epoch"]}},{name:a.tnc_best_routing,storeParameters:{keyPath:["ttnet_dispatch_actions_epoch"]}}]};function M(t){var e=t||{},n=e.aid,r=e.storeType;try{var o=r.getSync({tableName:a.tnc_config_table,key:[void 0===n?"-1":n]});return{tncSchema:null==o?void 0:o.tncSchema,tncSchemaInfo:o.tncSchemaInfo}}catch(t){return{tncSchema:void 0,tncSchemaInfo:void 0}}}function I(t){return m(this,void 0,void 0,function(){var e,n,r,o,i;return y(this,function(c){switch(c.label){case 0:r=void 0===(n=(e=t||{}).aid)?"-1":n,o=e.storeType,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,o.get({tableName:a.tnc_config_table,key:[r]})];case 2:return[2,{tncSchema:null==(i=c.sent())?void 0:i.tncSchema,tncSchemaInfo:i.tncSchemaInfo}];case 3:return c.sent(),[2,{tncSchema:void 0,tncSchemaInfo:void 0}];case 4:return[2]}})})}function U(t){return m(this,void 0,void 0,function(){var e,n,r,o,i;return y(this,function(c){switch(c.label){case 0:n=void 0===(e=t.aid)?"-1":e,r=t.tncSchema,o=t.tncSchemaInfo,i=t.storeType,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,i.put({tableName:a.tnc_config_table,value:{aid:n,tncSchema:r,tncSchemaInfo:o}})];case 2:return c.sent(),[3,4];case 3:return c.sent(),[2];case 4:return[2]}})})}function N(){try{return!!self&&self instanceof ServiceWorkerGlobalScope}catch(t){return!1}}function P(t){var e=t.tncSchemaInfo,n=t.originalTncConfig,r=t.requestQueryPayload,o=t.requestHeaders,i=t.responseHeaders;return{aid:e.aid||"-1",isCustomDefaultSchema:!!e.isCustomDefaultSchema,originalTncConfig:{aid:n.aid,device_id:n.device_id,user_id:n.user_id,region:n.region},requestQueryPayload:r,requestHeaders:o,responseHeaders:i}}var x=function(){function t(){this.events={}}return t.prototype.on=function(t,e){!this.events[t]&&(this.events[t]=[]),this.events[t].push(e)},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=this.events[t];if(!!(null==r?void 0:r.length))r.forEach(function(t){t.apply(void 0,e)})},t}(),D="tnc_update_schema",j="EVENT_TNC_SCHEMA_LOADED",E="EVENT_TNC_SCHEMA_UPDATE",q=function(){function t(t){var e=this;this.events=new x,this.status="stop",this.tncConfig=t.tncConfig,N()&&self.addEventListener("message",function(t){var n=t.data;n.action===D&&(n.payload.tncSchemaInfo.aid===e.tncConfig.aid||"-1"===n.payload.tncSchemaInfo.aid&&!e.tncConfig.aid)&&(e.tncSchema=n.payload.tncSchema,e.tncSchemaInfo=n.payload.tncSchemaInfo,e.events.emit(E,{tncSchema:e.tncSchema,tncSchemaInfo:e.tncSchemaInfo}),!function(t){m(this,void 0,void 0,function(){var e,n,r;return y(this,function(o){switch(o.label){case 0:n=void 0===(e=t.aid)?"-1":e,r=t.storeType,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,r.readDataToCache({tableName:a.tnc_config_table,key:[n]})];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})}({aid:e.tncConfig.aid,storeType:e.tncConfig.store}))})}return t.prototype.onTncSchemaLoaded=function(t){if(!!t)this.events.on(j,t)},t.prototype.onTncSchemaUpdate=function(t){if(!!t)this.events.on(E,t)},t.prototype.init=function(t){var e,n,r;return m(this,void 0,void 0,function(){var o,i,c,a,s,u,l,h,d=this;return y(this,function(u){switch(u.label){case 0:return[4,I({aid:this.tncConfig.multiInstance?this.tncConfig.aid:void 0,storeType:this.getStoreType()})];case 1:if(i=(o=u.sent()).tncSchema,c=o.tncSchemaInfo,null==t?void 0:t.notRequestTncSchema)return this.tncSchema=i,this.tncSchemaInfo=c,[2,{tncSchema:i,tncSchemaInfo:c}];(null===(e=this.tncConfig)||void 0===e?void 0:e.defaultTncSchema)&&(!i||!this.tncConfig.aid||this.tncConfig.alwaysUseDefaultTncSchema)&&(a=this.tncConfig.defaultTncSchema,s=P({tncSchemaInfo:{aid:this.tncConfig.aid,isCustomDefaultSchema:!0},originalTncConfig:this.tncConfig}),U({storeType:this.getStoreType(),aid:this.tncConfig.multiInstance?this.tncConfig.aid:void 0,tncSchema:this.tncConfig.defaultTncSchema,tncSchemaInfo:s})),u.label=2;case 2:if(u.trys.push([2,8,,9]),!(this.tncConfig.aid&&!((null===(n=this.tncConfig)||void 0===n?void 0:n.defaultTncSchema)&&this.tncConfig.alwaysUseDefaultTncSchema)))return[3,7];if("configuration request priority"!==this.tncConfig.configure_update_policy)return[3,4];return[4,O({tncConfig:this.tncConfig,send_tnc_host_arrays:null==i?void 0:i.send_tnc_host_arrays})];case 3:return a=(l=u.sent()).tncSchema,s=l.tncSchemaInfo,[3,7];case 4:if(a=i)return[3,6];return[4,O({tncConfig:this.tncConfig,send_tnc_host_arrays:null==i?void 0:i.send_tnc_host_arrays})];case 5:return a=(h=u.sent()).tncSchema,s=h.tncSchemaInfo,[3,7];case 6:O({tncConfig:this.tncConfig,send_tnc_host_arrays:null==i?void 0:i.send_tnc_host_arrays}).then(function(t){d.tncSchema=t.tncSchema,d.tncSchemaInfo=t.tncSchemaInfo}).catch(function(t){}),u.label=7;case 7:return[3,9];case 8:return u.sent(),[3,9];case 9:return a&&(this.tncSchema=a,this.tncSchemaInfo=s,this.events.emit(j,a),this.events.emit(E,{tncSchema:a,tncSchemaInfo:s})),this.tncConfig.aid&&!((null===(r=this.tncConfig)||void 0===r?void 0:r.defaultTncSchema)&&this.tncConfig.alwaysUseDefaultTncSchema)&&this.startPullTask(),[2,{tncSchema:this.tncSchema,tncSchemaInfo:this.tncSchemaInfo}]}})})},t.prototype.startPullTask=function(){var t=this,e=function(){return m(t,void 0,void 0,function(){var t,n,r,o;return y(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,O({tncConfig:this.tncConfig,send_tnc_host_arrays:null===(o=this.tncSchema)||void 0===o?void 0:o.send_tnc_host_arrays})];case 1:return n=(t=i.sent()).tncSchema,r=t.tncSchemaInfo,this.tncSchema=n,this.tncSchemaInfo=r,this.events.emit(j,n),this.events.emit(E,{tncSchema:n,tncSchemaInfo:r}),[3,3];case 2:return i.sent(),[3,3];case 3:return"pulling"===this.status&&(this.pullTaskTimer=setTimeout(e,this.getTncSchemaPullInterval())),[2]}})})};this.status="pulling",this.pullTaskTimer=setTimeout(e,this.getTncSchemaPullInterval())},t.prototype.stopPullTask=function(){this.pullTaskTimer&&clearTimeout(this.pullTaskTimer),this.status="stop"},t.prototype.updateTncConfig=function(t){this.tncConfig=t,t.defaultTncSchema&&(!this.tncSchema||!t.aid)&&(this.tncSchema=t.defaultTncSchema,this.tncSchemaInfo=P({tncSchemaInfo:{aid:this.tncConfig.aid,isCustomDefaultSchema:!0},originalTncConfig:this.tncConfig}))},t.prototype.getTncSchemaSync=function(){if("no_cache"===this.tncConfig.store.getCacheMode()){var t,e,n=void 0,r=void 0;return this.getStoreType().isSupportSync&&(n=(t=M({storeType:this.getStoreType(),aid:this.tncConfig.multiInstance?this.tncConfig.aid:void 0})).tncSchema,r=t.tncSchemaInfo),{tncSchema:n||this.tncConfig.defaultTncSchema||this.tncSchema,tncSchemaInfo:r||this.tncSchemaInfo}}var n=this.tncSchema,r=this.tncSchemaInfo;return!n&&this.getStoreType().isSupportSync&&(n=(e=M({storeType:this.getStoreType(),aid:this.tncConfig.multiInstance?this.tncConfig.aid:void 0})).tncSchema,r=e.tncSchemaInfo,this.tncSchema=n,this.tncSchemaInfo=r),{tncSchema:n||this.tncConfig.defaultTncSchema,tncSchemaInfo:r}},t.prototype.getTncSchemaAsync=function(){return m(this,void 0,void 0,function(){var t,e,n,r;return y(this,function(o){switch(o.label){case 0:if("no_cache"!==this.tncConfig.store.getCacheMode())return[3,2];return[4,I({storeType:this.getStoreType(),aid:this.tncConfig.multiInstance?this.tncConfig.aid:void 0})];case 1:return e=(t=o.sent()).tncSchema,n=t.tncSchemaInfo,[2,{tncSchema:e||this.tncConfig.defaultTncSchema,tncSchemaInfo:n}];case 2:if(e=this.tncSchema,n=this.tncSchemaInfo,e)return[3,4];return[4,I({storeType:this.getStoreType(),aid:this.tncConfig.multiInstance?this.tncConfig.aid:void 0})];case 3:e=(r=o.sent()).tncSchema,n=r.tncSchemaInfo,this.tncSchema=e,this.tncSchemaInfo=n,o.label=4;case 4:return[2,{tncSchema:e||this.tncConfig.defaultTncSchema,tncSchemaInfo:n}]}})})},t.prototype.getTncSchemaInCache=function(){if("no_cache"===this.tncConfig.store.getCacheMode())return{};var t,e=this.tncSchema,n=this.tncSchemaInfo;return!e&&(e=(t=function(t){var e=t||{},n=e.aid,r=e.storeType;try{var o=r.getFromCache({tableName:a.tnc_config_table,key:[void 0===n?"-1":n]});return{tncSchema:null==o?void 0:o.tncSchema,tncSchemaInfo:o.tncSchemaInfo}}catch(t){return{tncSchema:void 0,tncSchemaInfo:void 0}}}({storeType:this.getStoreType(),aid:this.tncConfig.multiInstance?this.tncConfig.aid:void 0})).tncSchema,n=t.tncSchemaInfo,this.tncSchema=e,this.tncSchemaInfo=n),{tncSchema:e,tncSchemaInfo:n}},t.prototype.getStoreType=function(){return this.tncConfig.store},t.prototype.getTncSchemaPullInterval=function(){var t,e,n;return(null===(t=this.tncSchema)||void 0===t?void 0:t.tnc_update_interval)?1e3*Number(this.tncSchema.tnc_update_interval):(null===(e=this.tncConfig)||void 0===e?void 0:e.alternateIntervals)?1e3*Number(null===(n=this.tncConfig)||void 0===n?void 0:n.alternateIntervals):1e4},t}();function O(t){return m(this,void 0,void 0,function(){var e,n,r,o,i,c,a,s;return y(this,function(u){switch(u.label){case 0:return e=t.tncConfig,n=t.send_tnc_host_arrays,[4,function(t){var e,n,r;return m(this,void 0,void 0,function(){var o,i,c,a,s,u,l,d,f,v,m,g,b,S,k;return y(this,function(R){switch(R.label){case 0:switch(o=t.tncConfig,i=t.send_tnc_host_arrays,c=[],(null===(e=o.customHosts)||void 0===e?void 0:e.length)&&(c=c.concat(o.customHosts)),(null==i?void 0:i.length)&&(c=Array.from(new Set(c=c.concat(i)))),o.region){case"boe":c=c.concat(w);break;case"abroad":c=c.concat(C);break;default:c=c.concat(T)}if("undefined"!=typeof window){var M,I,U,N,P;M=(M=window.navigator.userAgent).toLocaleLowerCase(),N="ipad"===(U=null==(I=/(ipad)/.exec(M)||/(ipod)/.exec(M)||/(iphone)/.exec(M)||/(windows phone)/.exec(M)||/(android)/.exec(M)||/(win)/.exec(M)||/(mac)/.exec(M)||/(linux)/.exec(M))?void 0:I[0])||"ipod"===U||"iphone"===U,a=(s={isIos:N,isAndroid:P="android"===U,isMobile:N||P||"windows phone"===U,isDesktop:"win"===U||"mac"===U||"linux"===U}).isAndroid?"android":s.isIos?"ios":s.isMobile?"h5":s.isDesktop?"pc":"web"}else a=void 0!==h&&h.release?"node":"web";u={tnc_js_sdk_version:"2.3.15.0",device_platform:a,aid:o.aid,device_id:o.device_id,user_id:o.user_id,web_service:o.web_service||""},l=new URLSearchParams,Object.entries(u).map(function(t){var e=t[0],n=t[1];!_(n)&&l.append(e,n)}),d=l.toString(),f=p({},o.customHeaders),(o.unit||o.brand)&&(f["x-env-v2"]=""+(o.unit?"unit:".concat(o.unit,";"):"")+(o.brand?"brand:".concat(o.brand,";"):"")),m={},g=function(t){var e,i;return y(this,function(c){switch(c.label){case 0:e="".concat("https:","//").concat(t,"/get_domains/v5/?").concat(d),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,new Promise(function(t,n){o.internalFetch({url:e,method:"GET",expectResponseType:"json",header:f,success:function(e){t(e)},fail:function(){n()}})})];case 2:if((null===(n=(i=c.sent()).data)||void 0===n?void 0:n.data)&&(null===(r=i.data)||void 0===r?void 0:r.message)==="success")return v=i.data.data,m=i.header,[2,"break"];return[2,"continue"];case 3:return c.sent(),[3,4];case 4:return[2]}})},b=0,S=c,R.label=1;case 1:if(!(b<S.length))return[3,4];return k=S[b],[5,g(k)];case 2:if("break"===R.sent())return[3,4];R.label=3;case 3:return b++,[3,1];case 4:if(v)return[2,{tncSchema:v,requestQueryPayload:u,requestHeaders:f,responseHeaders:m}];throw Error("TNC 拉取配置失败")}})})}({tncConfig:e,send_tnc_host_arrays:n})];case 1:return o=(r=u.sent()).tncSchema,i=r.requestQueryPayload,c=r.requestHeaders,a=r.responseHeaders,s=P({tncSchemaInfo:{aid:e.multiInstance?e.aid:void 0},originalTncConfig:e,requestQueryPayload:i,requestHeaders:c,responseHeaders:a}),k({action:D,payload:{tncSchema:o,tncSchemaInfo:s}}),[4,U({storeType:e.store,aid:e.multiInstance?e.aid:void 0,tncSchema:o,tncSchemaInfo:s})];case 2:return u.sent(),[2,{tncSchema:o,tncSchemaInfo:s}]}})})}var L=function(t){function e(e){var n=this,r=e.tncConfig,o=e.plugins;return(n=t.call(this,{tncConfig:r,plugins:o})||this).notRequestTncSchema=e.notRequestTncSchema,n.tncSchemaManager=new q({tncConfig:n.tncConfig}),n}return f(e,t),e.prototype.init=function(){return m(this,void 0,void 0,function(){var t,e,n,r=this;return y(this,function(o){switch(o.label){case 0:return this.plugins.forEach(function(t){var e;null===(e=t.init)||void 0===e||e.call(t,{tncConfig:r.tncConfig,store:r.tncConfig.store,internalFetch:r.tncConfig.internalFetch})}),this.tncSchemaManager.onTncSchemaLoaded(function(t){r.plugins.forEach(function(e){var n;null===(n=e.onTncSchemaLoaded)||void 0===n||n.call(e,{tncSchema:t})})}),this.tncSchemaManager.onTncSchemaUpdate(function(t){var e=t.tncSchema,n=t.tncSchemaInfo;r.plugins.forEach(function(t){var r;null===(r=t.onTncSchemaUpdate)||void 0===r||r.call(t,{tncSchema:e,tncSchemaInfo:n})})}),[4,this.tncSchemaManager.init({notRequestTncSchema:this.notRequestTncSchema})];case 1:if(e=(t=o.sent()).tncSchema,n=t.tncSchemaInfo,!e)return[2];return this.plugins.forEach(function(t){var o;null===(o=t.afterSchemaLoadInit)||void 0===o||o.call(t,{tncSchema:e,tncSchemaInfo:n,store:r.tncConfig.store})}),[4,function(t,e){var n,r,o,i,c,a,s,u,l;return m(this,void 0,void 0,function(){var h,d,f,p,v,m;return y(this,function(y){switch(y.label){case 0:if("not-manage"===t.swMode||!(null==window?void 0:window.navigator))return[2];if(!((null===(n=e.tnc_js_sdk_control)||void 0===n?void 0:n.pwa_enable)===1&&(!t.swMode||"use"===t.swMode)))return[3,5];if(!("serviceWorker"in window.navigator&&((null===(r=null==window?void 0:window.location)||void 0===r?void 0:r.protocol)==="https:"||(null===(o=null==window?void 0:window.location)||void 0===o?void 0:o.protocol)==="http:"&&(null===(c=null===(i=null==window?void 0:window.location)||void 0===i?void 0:i.host)||void 0===c?void 0:c.indexOf("127.0.0.1"))>-1)))return[3,4];y.label=1;case 1:return y.trys.push([1,3,,4]),f=(d=(h=t.swPath||"/sw.js").split("?"))[0],(v=new URLSearchParams(void 0===(p=d[1])?"":p)).append("tnc_cache_mode",t.store.getCacheMode()),t.multiInstance&&(v.append("tnc_multi_instance","1"),v.append("tnc_aid",t.aid||"")),t.enableLog&&v.append("tnc_enable_log","1"),(null===(a=t.swBehaviorConfig)||void 0===a?void 0:a.resourceFilterNoNavigateRequest)&&v.append("tnc_sw_resource_filter_no_navigate_request","1"),(null===(s=t.swBehaviorConfig)||void 0===s?void 0:s.allow)&&v.append("tnc_sw_resource_filter_allow",encodeURIComponent(JSON.stringify(t.swBehaviorConfig.allow))),h=f+"?"+v.toString(),[4,navigator.serviceWorker.register(h,{scope:t.swScope})];case 2:case 3:return y.sent(),[3,4];case 4:return[3,7];case 5:return[4,null===(l=null===(u=window.navigator)||void 0===u?void 0:u.serviceWorker)||void 0===l?void 0:l.getRegistration(t.swScope)];case 6:(m=y.sent())&&m.unregister(),y.label=7;case 7:return[2]}})})}(this.tncConfig,e)];case 2:return o.sent(),[2]}})})},e.prototype.destroy=function(){this.plugins.forEach(function(t){var e;null===(e=t.destroy)||void 0===e||e.call(t)}),this.tncSchemaManager.stopPullTask()},e.prototype.updateTncConfig=function(e){t.prototype.updateTncConfig.call(this,e),this.tncSchemaManager.updateTncConfig(this.tncConfig)},e.prototype.updateUserId=function(e){t.prototype.updateUserId.call(this,e),this.tncSchemaManager.updateTncConfig(this.tncConfig)},e.prototype.updateCustomHeaders=function(e){t.prototype.updateCustomHeaders.call(this,e),this.tncSchemaManager.updateTncConfig(this.tncConfig)},e}(b),A=function(){return(A=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n],e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function F(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function H(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function G(t){return null==t}function W(t){var e,n=t.dbStructure,r=t.tableName,o=t.key,i=t.value,c="web_store_".concat(n.dbName,"_").concat(n.dbVersion,"_").concat(r);if(o)return c+"_"+(Array.isArray(o)?o.join("-"):o);var a=null===(e=n.tableStructures.find(function(t){return t.name===r}))||void 0===e?void 0:e.storeParameters.keyPath;return a?c+"_"+(Array.isArray(a)?a.map(function(t){return(null==i?void 0:i[t])||""}).join("-"):(null==i?void 0:i[a])||""):c}"function"==typeof SuppressedError&&SuppressedError;var B=function(){function t(t){this.cacheObj={},this.dbStructure=t.dbStructure}return t.prototype.get=function(t){var e=W({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});return this.cacheObj[e]},t.prototype.remove=function(t){var e=W({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});delete this.cacheObj[e]},t.prototype.set=function(t){var e=W({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key,value:t.value});this.cacheObj[e]=t.value},t}(),X=function(){function t(t){this.webStoreCore=t.webStoreCore,this.cacheMode=t.cacheMode||"no_cache",("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(this.webStoreCache=new B({dbStructure:t.webStoreCore.dbStructure}))}return Object.defineProperty(t.prototype,"isSupportSync",{get:function(){return this.webStoreCore.supportSync},enumerable:!1,configurable:!0}),t.prototype.getCacheMode=function(){return this.cacheMode},t.prototype.createTransaction=function(t){return this.webStoreCore.createTransaction(t)},t.prototype.get=function(t){var e,n;return F(this,void 0,void 0,function(){var r,o;return H(this,function(i){switch(i.label){case 0:if(!t.notUseCache&&"cache_only"===this.cacheMode)return G(r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t))&&this.readDataToCache(t),[2,r];if(!(!t.notUseCache&&"cache_first"===this.cacheMode))return[3,3];if(G(r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t)))return[3,1];return[2,r];case 1:case 3:return[4,this.webStoreCore.get(t)];case 2:return o=i.sent(),this.setCache(A(A({},t),{value:o})),[2,o];case 4:return[2,i.sent()]}})})},t.prototype.delete=function(t){var e;return F(this,void 0,void 0,function(){return H(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),[2,this.webStoreCore.delete(t)]})})},t.prototype.add=function(t){var e;return F(this,void 0,void 0,function(){return H(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.add(t)]})})},t.prototype.put=function(t){var e;return F(this,void 0,void 0,function(){return H(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.put(t)]})})},t.prototype.getSync=function(t){var e,n;if(!t.notUseCache&&"cache_only"===this.cacheMode){var r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t);return G(r)&&this.readDataToCache(t),r}if(!t.notUseCache&&"cache_first"===this.cacheMode){var r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t);if(!G(r))return r;var o=this.webStoreCore.getSync(t);return this.setCache(A(A({},t),{value:o})),o}return this.webStoreCore.getSync(t)},t.prototype.deleteSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),this.webStoreCore.deleteSync(t)},t.prototype.addSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.addSync(t)},t.prototype.putSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.putSync(t)},t.prototype.getFromCache=function(t){var e;return null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t)},t.prototype.setCache=function(t){this.webStoreCache&&this.webStoreCache.set(t)},t.prototype.readDataToCache=function(t){return F(this,void 0,void 0,function(){var e;return H(this,function(n){switch(n.label){case 0:return[4,this.webStoreCore.get(t)];case 1:return!G(e=n.sent())&&this.webStoreCache&&this.webStoreCache.set(A(A({},t),{value:e})),[2,e]}})})},t}(),z=function(t,e){return(z=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function V(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function $(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}"function"==typeof SuppressedError&&SuppressedError;var Q=function(){return(Q=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n],e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function J(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function Z(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function K(t){return null==t}function Y(t){var e,n=t.dbStructure,r=t.tableName,o=t.key,i=t.value,c="web_store_".concat(n.dbName,"_").concat(n.dbVersion,"_").concat(r);if(o)return c+"_"+(Array.isArray(o)?o.join("-"):o);var a=null===(e=n.tableStructures.find(function(t){return t.name===r}))||void 0===e?void 0:e.storeParameters.keyPath;return a?c+"_"+(Array.isArray(a)?a.map(function(t){return(null==i?void 0:i[t])||""}).join("-"):(null==i?void 0:i[a])||""):c}"function"==typeof SuppressedError&&SuppressedError;var te=function(){function t(t){this.cacheObj={},this.dbStructure=t.dbStructure}return t.prototype.get=function(t){var e=Y({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});return this.cacheObj[e]},t.prototype.remove=function(t){var e=Y({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});delete this.cacheObj[e]},t.prototype.set=function(t){var e=Y({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key,value:t.value});this.cacheObj[e]=t.value},t}();function tn(t){return Array.isArray(t)}!function(){function t(t){this.webStoreCore=t.webStoreCore,this.cacheMode=t.cacheMode||"no_cache",("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(this.webStoreCache=new te({dbStructure:t.webStoreCore.dbStructure}))}Object.defineProperty(t.prototype,"isSupportSync",{get:function(){return this.webStoreCore.supportSync},enumerable:!1,configurable:!0}),t.prototype.getCacheMode=function(){return this.cacheMode},t.prototype.createTransaction=function(t){return this.webStoreCore.createTransaction(t)},t.prototype.get=function(t){var e,n;return J(this,void 0,void 0,function(){var r,o;return Z(this,function(i){switch(i.label){case 0:if(!t.notUseCache&&"cache_only"===this.cacheMode)return K(r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t))&&this.readDataToCache(t),[2,r];if(!(!t.notUseCache&&"cache_first"===this.cacheMode))return[3,3];if(K(r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t)))return[3,1];return[2,r];case 1:case 3:return[4,this.webStoreCore.get(t)];case 2:return o=i.sent(),this.setCache(Q(Q({},t),{value:o})),[2,o];case 4:return[2,i.sent()]}})})},t.prototype.delete=function(t){var e;return J(this,void 0,void 0,function(){return Z(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),[2,this.webStoreCore.delete(t)]})})},t.prototype.add=function(t){var e;return J(this,void 0,void 0,function(){return Z(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.add(t)]})})},t.prototype.put=function(t){var e;return J(this,void 0,void 0,function(){return Z(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.put(t)]})})},t.prototype.getSync=function(t){var e,n;if(!t.notUseCache&&"cache_only"===this.cacheMode){var r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t);return K(r)&&this.readDataToCache(t),r}if(!t.notUseCache&&"cache_first"===this.cacheMode){var r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t);if(!K(r))return r;var o=this.webStoreCore.getSync(t);return this.setCache(Q(Q({},t),{value:o})),o}return this.webStoreCore.getSync(t)},t.prototype.deleteSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),this.webStoreCore.deleteSync(t)},t.prototype.addSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.addSync(t)},t.prototype.putSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.putSync(t)},t.prototype.getFromCache=function(t){var e;return null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t)},t.prototype.setCache=function(t){this.webStoreCache&&this.webStoreCache.set(t)},t.prototype.readDataToCache=function(t){return J(this,void 0,void 0,function(){var e;return Z(this,function(n){switch(n.label){case 0:return[4,this.webStoreCore.get(t)];case 1:return!K(e=n.sent())&&this.webStoreCache&&this.webStoreCache.set(Q(Q({},t),{value:e})),[2,e]}})})}}();var tr=function(t){function e(e){var n=t.call(this,e)||this;return n.supportSync=!1,n.init(),n}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}z(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.init=function(){return V(this,void 0,void 0,function(){var t,e=this;return $(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,new Promise(function(t,n){var r=indexedDB.open(e.dbStructure.dbName,e.dbStructure.dbVersion);r.onsuccess=function(n){var r=n.target.result;e.db=r,t(r)},r.onerror=function(t){n(t)},r.onupgradeneeded=function(t){e.dbStructure.tableStructures.forEach(function(e){var n;null===(n=t.target.result)||void 0===n||n.createObjectStore(e.name,e.storeParameters)})}})];case 1:return[2,n.sent()];case 2:return t=n.sent(),this.initError=t,[3,3];case 3:return[2]}})})},e.prototype.getDb=function(){return V(this,void 0,void 0,function(){return $(this,function(t){switch(t.label){case 0:if(this.db)return[2,this.db];if(this.initError)return[3,2];return[4,this.init()];case 1:return[2,t.sent()];case 2:return[2]}})})},e.prototype.createTransaction=function(t){return V(this,void 0,void 0,function(){var e;return $(this,function(n){switch(n.label){case 0:return[4,this.getDb()];case 1:if(!(e=n.sent()))return[2];return[2,e.transaction(t.tableNames,t.mode)]}})})},e.prototype.get=function(t){return V(this,void 0,void 0,function(){var e,n,r;return $(this,function(o){switch(o.label){case 0:if(n=t.transaction)return[3,2];return[4,this.createTransaction({tableNames:[t.tableName],mode:"readonly"})];case 1:n=o.sent(),o.label=2;case 2:if(!(e=n))return[2];return r=e.objectStore(t.tableName).get(this.getSuitKey(t)),[2,new Promise(function(t,e){r.onsuccess=function(){t(r.result)},r.onerror=function(t){e(t)}})]}})})},e.prototype.delete=function(t){return V(this,void 0,void 0,function(){var e,n,r;return $(this,function(o){switch(o.label){case 0:if(n=t.transaction)return[3,2];return[4,this.createTransaction({tableNames:[t.tableName],mode:"readwrite"})];case 1:n=o.sent(),o.label=2;case 2:if(!(e=n))return[2];return r=e.objectStore(t.tableName).delete(this.getSuitKey(t)),[2,new Promise(function(t,e){r.onsuccess=function(){t(r.result)},r.onerror=function(t){e(t)}})]}})})},e.prototype.add=function(t){return V(this,void 0,void 0,function(){var e,n,r;return $(this,function(o){switch(o.label){case 0:if(n=t.transaction)return[3,2];return[4,this.createTransaction({tableNames:[t.tableName],mode:"readwrite"})];case 1:n=o.sent(),o.label=2;case 2:if(!(e=n))return[2];return r=e.objectStore(t.tableName).add(t.value),[2,new Promise(function(t,e){r.onsuccess=function(){t()},r.onerror=function(t){e(t)}})]}})})},e.prototype.put=function(t){return V(this,void 0,void 0,function(){var e,n,r;return $(this,function(o){switch(o.label){case 0:if(n=t.transaction)return[3,2];return[4,this.createTransaction({tableNames:[t.tableName],mode:"readwrite"})];case 1:n=o.sent(),o.label=2;case 2:if(!(e=n))return[2];return r=e.objectStore(t.tableName).put(t.value),[2,new Promise(function(t,e){r.onsuccess=function(){t()},r.onerror=function(t){e(t)}})]}})})},e.prototype.getSuitKey=function(t){if(!tn(t.key)){var e=this.dbStructure.tableStructures.find(function(e){return e.name===t.tableName});if(tn(null==e?void 0:e.storeParameters.keyPath))return[t.key]}return t.key},e}(function(){function t(t){this.dbStructure=t.dbStructure}return t.prototype.getSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.deleteSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.addSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.putSync=function(t){throw Error("WebStore: not support async operation.")},t}()),to=function(t,e){return(to=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function ti(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function tc(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}"function"==typeof SuppressedError&&SuppressedError;var ta=function(){return(ta=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n],e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function ts(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function tu(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function tl(t){return null==t}function th(t){var e,n=t.dbStructure,r=t.tableName,o=t.key,i=t.value,c="web_store_".concat(n.dbName,"_").concat(n.dbVersion,"_").concat(r);if(o)return c+"_"+(Array.isArray(o)?o.join("-"):o);var a=null===(e=n.tableStructures.find(function(t){return t.name===r}))||void 0===e?void 0:e.storeParameters.keyPath;return a?c+"_"+(Array.isArray(a)?a.map(function(t){return(null==i?void 0:i[t])||""}).join("-"):(null==i?void 0:i[a])||""):c}"function"==typeof SuppressedError&&SuppressedError;var td=function(){function t(t){this.cacheObj={},this.dbStructure=t.dbStructure}return t.prototype.get=function(t){var e=th({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});return this.cacheObj[e]},t.prototype.remove=function(t){var e=th({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});delete this.cacheObj[e]},t.prototype.set=function(t){var e=th({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key,value:t.value});this.cacheObj[e]=t.value},t}();!function(){function t(t){this.webStoreCore=t.webStoreCore,this.cacheMode=t.cacheMode||"no_cache",("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(this.webStoreCache=new td({dbStructure:t.webStoreCore.dbStructure}))}Object.defineProperty(t.prototype,"isSupportSync",{get:function(){return this.webStoreCore.supportSync},enumerable:!1,configurable:!0}),t.prototype.getCacheMode=function(){return this.cacheMode},t.prototype.createTransaction=function(t){return this.webStoreCore.createTransaction(t)},t.prototype.get=function(t){var e,n;return ts(this,void 0,void 0,function(){var r,o;return tu(this,function(i){switch(i.label){case 0:if(!t.notUseCache&&"cache_only"===this.cacheMode)return tl(r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t))&&this.readDataToCache(t),[2,r];if(!(!t.notUseCache&&"cache_first"===this.cacheMode))return[3,3];if(tl(r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t)))return[3,1];return[2,r];case 1:case 3:return[4,this.webStoreCore.get(t)];case 2:return o=i.sent(),this.setCache(ta(ta({},t),{value:o})),[2,o];case 4:return[2,i.sent()]}})})},t.prototype.delete=function(t){var e;return ts(this,void 0,void 0,function(){return tu(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),[2,this.webStoreCore.delete(t)]})})},t.prototype.add=function(t){var e;return ts(this,void 0,void 0,function(){return tu(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.add(t)]})})},t.prototype.put=function(t){var e;return ts(this,void 0,void 0,function(){return tu(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.put(t)]})})},t.prototype.getSync=function(t){var e,n;if(!t.notUseCache&&"cache_only"===this.cacheMode){var r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t);return tl(r)&&this.readDataToCache(t),r}if(!t.notUseCache&&"cache_first"===this.cacheMode){var r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t);if(!tl(r))return r;var o=this.webStoreCore.getSync(t);return this.setCache(ta(ta({},t),{value:o})),o}return this.webStoreCore.getSync(t)},t.prototype.deleteSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),this.webStoreCore.deleteSync(t)},t.prototype.addSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.addSync(t)},t.prototype.putSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.putSync(t)},t.prototype.getFromCache=function(t){var e;return null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t)},t.prototype.setCache=function(t){this.webStoreCache&&this.webStoreCache.set(t)},t.prototype.readDataToCache=function(t){return ts(this,void 0,void 0,function(){var e;return tu(this,function(n){switch(n.label){case 0:return[4,this.webStoreCore.get(t)];case 1:return!tl(e=n.sent())&&this.webStoreCache&&this.webStoreCache.set(ta(ta({},t),{value:e})),[2,e]}})})}}();var tf=function(t){function e(e){var n=t.call(this,e)||this;return n.supportSync=!0,n}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}to(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.createTransaction=function(){return ti(this,void 0,void 0,function(){return tc(this,function(t){return[2,null]})})},e.prototype.get=function(t){return ti(this,void 0,void 0,function(){return tc(this,function(e){return[2,this.getSync(t)]})})},e.prototype.delete=function(t){return ti(this,void 0,void 0,function(){return tc(this,function(e){return[2,this.deleteSync(t)]})})},e.prototype.add=function(t){return ti(this,void 0,void 0,function(){return tc(this,function(e){return[2,this.addSync(t)]})})},e.prototype.put=function(t){return ti(this,void 0,void 0,function(){return tc(this,function(e){return[2,this.putSync(t)]})})},e.prototype.getSync=function(t){var e=th({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key}),n=window.localStorage.getItem(e);if(!n)return null;try{return JSON.parse(n)}catch(t){return null}},e.prototype.deleteSync=function(t){var e=th({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});window.localStorage.removeItem(e)},e.prototype.addSync=function(t){this.putSync(t)},e.prototype.putSync=function(t){var e=th({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key,value:t.value});window.localStorage.setItem(e,JSON.stringify(t.value))},e}(function(){function t(t){this.dbStructure=t.dbStructure}return t.prototype.getSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.deleteSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.addSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.putSync=function(t){throw Error("WebStore: not support async operation.")},t}());(o=s||(s={})).tc="tc",o.dispatch="dispatch",o.web_tc="web_tc",o.web_dispatch="web_dispatch",(i=u||(u={}))[i.baseReplace=1]="baseReplace",i[i.elimination=3]="elimination",i[i.bestRouting=4]="bestRouting",i[i.dynamicRouting=5]="dynamicRouting",i[i.orderTry=101]="orderTry";var tp={ttnetUrlDispatch:function(t){var e=t.urlObj,n=t.actionConfig;if(n.action!==s.dispatch&&n.action!==s.web_dispatch||n.param.dispatch_strategy!==u.baseReplace)return{result:[],actionRan:!1};var r=n.param.strategy_info,o=new URL(e),i=null==r?void 0:r[e.host];return i&&(o.host=i),{result:[o],actionRan:!0}}};function tv(){return"undefined"!=typeof self?self:"undefined"!=typeof window||"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:void 0}function tm(){return"undefined"!=typeof wx?wx:"undefined"!=typeof tt?tt:"undefined"!=typeof swan?swan:"undefined"!=typeof my?my:void 0}function ty(t){try{return RegExp("^"+t.matchTarget.replace(/\-/g,"\\-").replace(/\./g,"\\.").replace(/\*/g,".*")+"$").test(t.host)}catch(t){return!1}}function tg(){var t=tv();return!!t.registration&&!!t.clients}function tb(t){return t===l.no_config||t===l.matched}function t_(t){var e,n,r,o,i,c,a,s,u,h,d,f,p,v,m,y,g,b,_,S=t.urlObj,w=t.actionConfig,C=t.referrer,T=t.ignore_referrer,k=l.not_matched;if(null===(n=null===(e=w.param)||void 0===e?void 0:e.host_group)||void 0===n?void 0:n.length)for(var R=0,M=w.param.host_group;R<M.length;R++){var I=M[R];if(I===S.host||"*"===I||I.includes("*")&&ty({host:S.host,matchTarget:I})){k=l.matched;break}}else k=l.no_config;var U=l.not_matched;if(null===(o=null===(r=w.param)||void 0===r?void 0:r.equal_group)||void 0===o?void 0:o.length)for(var N=0,P=w.param.equal_group;N<P.length;N++){var x=P[N];if(x===S.pathname){U=l.matched;break}}else U=l.no_config;var D=l.not_matched;if(null===(c=null===(i=null==w?void 0:w.param)||void 0===i?void 0:i.contain_group)||void 0===c?void 0:c.length)for(var j=0,E=w.param.contain_group;j<E.length;j++){var x=E[j];if(S.pathname.indexOf(x)>-1){D=l.matched;break}}else D=l.no_config;var q=l.not_matched;if(null===(s=null===(a=null==w?void 0:w.param)||void 0===a?void 0:a.prefixes_group)||void 0===s?void 0:s.length)for(var O=0,L=w.param.prefixes_group;O<L.length;O++){var x=L[O];if(S.pathname.startsWith(x)){q=l.matched;break}}else q=l.no_config;var A=l.not_matched;if(null===(h=null===(u=null==w?void 0:w.param)||void 0===u?void 0:u.pattern_group)||void 0===h?void 0:h.length)for(var F=0,H=w.param.pattern_group;F<H.length;F++){var G=H[F],W=new RegExp(G);if(W.test(S.pathname)){A=l.matched;break}}else A=l.no_config;var B=l.not_matched;if(null===(f=null===(d=null==w?void 0:w.param)||void 0===d?void 0:d.full_url_group)||void 0===f?void 0:f.length)for(var X=0,z=w.param.full_url_group;X<z.length;X++){var G=z[X],W=new RegExp(G);if(W.test(S.toString())){B=l.matched;break}}else B=l.no_config;var V=l.not_matched;if(!T&&(null===(p=null==w?void 0:w.param)||void 0===p?void 0:p.referrer_group)){if(C)for(var $=0,Q=w.param.referrer_group;$<Q.length;$++){var G=Q[$],W=new RegExp(G);if(C&&W.test(C)){V=l.matched;break}}else V=l.not_matched}else V=l.no_config;var J=l.not_matched;if(!T&&(null===(v=null==w?void 0:w.param)||void 0===v?void 0:v.referrer_host_group)){if(C)try{for(var Z=new URL(C).host,K=0,Y=w.param.referrer_host_group;K<Y.length;K++){var I=Y[K];if(I===Z||"*"===I||I.includes("*")&&ty({host:Z,matchTarget:I})){J=l.matched;break}}}catch(t){J=l.not_matched}else J=l.not_matched}else J=l.no_config;var te=l.not_matched;if(!T&&(null===(m=null==w?void 0:w.param)||void 0===m?void 0:m.referrer_prefixes_group)){if(C)try{for(var tn=new URL(C).pathname,tr=0,to=w.param.referrer_prefixes_group;tr<to.length;tr++){var x=to[tr];if(tn.startsWith(x)){te=l.matched;break}}}catch(t){te=l.not_matched}else te=l.not_matched}else te=l.no_config;var ti=l.not_matched;if(T||tg()||!(null===(y=null==w?void 0:w.param)||void 0===y?void 0:y.proxy_referrer_group))ti=l.no_config;else if(C)for(var tc=0,ta=w.param.proxy_referrer_group;tc<ta.length;tc++){var G=ta[tc],W=new RegExp(G);if(C&&W.test(C)){ti=l.matched;break}}else ti=l.not_matched;var ts=l.not_matched;if(tg()){var tu=null===(b=null===(g=tv())||void 0===g?void 0:g.registration)||void 0===b?void 0:b.scope;if(null===(_=null==w?void 0:w.param)||void 0===_?void 0:_.sw_scope_group){if(tu)for(var tl=0,th=w.param.sw_scope_group;tl<th.length;tl++){var G=th[tl],W=new RegExp(G);if(C&&W.test(C)){ts=l.matched;break}}else ts=l.not_matched}else ts=l.no_config}else ts=l.no_config;var td=[U,D,q,A].every(function(t){return t===l.no_config})||[U,D,q,A].some(function(t){return t===l.matched});return{matched:tb(k)&&td&&tb(B)&&tb(V)&&tb(J)&&tb(te)&&tb(ti)&&tb(ts),hostMatched:k,equalGroupMatched:U,containGroupMatched:D,prefixesGroupMatched:q,patternGroupMatched:A,fullUrlGroupMatched:B,referrerMatched:V,proxyReferrerGroupMatched:ti,swScopeGroupMatched:ts}}function tS(t){var e,n,r=t.urlObj,o=t.matchActionResult,i=t.referrer,c=t.processParams,a=new URL(r.toString()),s="";try{i&&(s=new URL(i).host)}catch(t){}if((null==c?void 0:c.scheme_replace)&&(a.protocol=c.scheme_replace.indexOf(":")>-1?c.scheme_replace:"".concat(c.scheme_replace,":")),(null==c?void 0:c.host_replace)&&!(c.host_replace.includes("${currentHost}")&&!s)&&(a.host=c.host_replace.replace("${currentHost}",s)),!_(null==c?void 0:c.port_replace)&&(a.port=null==c?void 0:c.port_replace),(null==c?void 0:c.drop)==1&&(a.host="127.0.0.1"),(null==c?void 0:c.path_replace)&&(a.pathname=null==c?void 0:c.path_replace),o.fullUrlGroupMatched===l.matched&&(null===(e=null==c?void 0:c.full_url_group)||void 0===e?void 0:e.length)===1&&c.replace&&!(c.replace.includes("${currentHost}")&&!s))try{a=new URL(a.toString().replace(new RegExp(c.full_url_group[0]),c.replace.replace("${currentHost}",s)))}catch(t){}if(o.patternGroupMatched===l.matched&&(null===(n=null==c?void 0:c.pattern_group)||void 0===n?void 0:n.length)===1&&c.pattern_replace)try{a.pathname=a.pathname.replace(new RegExp(c.pattern_group[0]),c.pattern_replace)}catch(t){}return a}(c=l||(l={})).no_config="no_config",c.matched="matched",c.not_matched="not_matched";var tw={ttnetUrlDispatch:function(t){var e=t.urlObj,n=t.matchActionResult,r=t.referrer,o=t.actionConfig;return o.action!==s.tc&&o.action!==s.web_tc?{result:[],actionRan:!1}:{result:[tS({urlObj:e,matchActionResult:n,referrer:r,processParams:o.param})],actionRan:!0}}};function tC(t){var e,n=t.tncSchema,r=t.storeType,o=(n||{}).ttnet_dispatch_actions_epoch;if(!!o&&!!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.bestRouting})))try{return r.getSync({tableName:a.tnc_best_routing,key:[o]})}catch(t){return}}function tT(t){var e;return m(this,void 0,void 0,function(){var n,r,o,i,c,s,l,h,d,f,p,v,m,g;return y(this,function(y){switch(y.label){case 0:if(n=t.processResults,r=t.responseStatus,o=t.tncSchema,i=t.storeType,c=(o||{}).ttnet_dispatch_actions_epoch,!o||!c)return[2];s=0,l=n,y.label=1;case 1:if(!(s<l.length))return[3,8];if(d=(h=l[s]).newHost,f=h.actionConfig,!d||f.param.dispatch_strategy!==u.bestRouting)return[2];p=f.param.strategy_info,y.label=2;case 2:return y.trys.push([2,6,,7]),[4,i.createTransaction({tableNames:[a.tnc_best_routing],mode:"readwrite"})];case 3:return v=y.sent(),[4,i.get({tableName:a.tnc_best_routing,key:[c],transaction:v,notUseCache:!0})];case 4:return m=y.sent(),g=function(t){var e,n,r=t.tncSchema,o=t.bestRoutingData,i=t.sign,c=t.host,a=t.status,s=(r||{}).ttnet_dispatch_actions_epoch,u=o||{ttnet_dispatch_actions_epoch:s,bestRouting:{}},l=u.bestRouting[i]||{};return!(null===(n=null===(e=l[c])||void 0===e?void 0:e.result)||void 0===n?void 0:n.length)&&(l[c]={result:[]}),Object.keys(l).forEach(function(t){var e,n,r,o,i=l[t];(!i||!(null===(e=i.result)||void 0===e?void 0:e.length))&&(i={result:[]}),t===c?null===(n=i.result)||void 0===n||n.unshift(a):null===(r=i.result)||void 0===r||r.unshift(0),i.result=null===(o=i.result)||void 0===o?void 0:o.slice(0,50),l[t]=i}),u.bestRouting[i]=l,u}({tncSchema:o,bestRoutingData:m,sign:f.sign,host:d,status:_(r)||(null===(e=null==p?void 0:p.error_code)||void 0===e?void 0:e.includes(r))?-1:1}),[4,i.put({tableName:a.tnc_best_routing,key:[c],value:g,transaction:v})];case 5:return y.sent(),[3,7];case 6:return y.sent(),[2];case 7:return s++,[3,1];case 8:return[2]}})})}function tk(t,e){var n,r,o=null===(r=tk.Cache[t])||void 0===r?void 0:r[e];if(o)return o;var i=Math.floor(e/10),c={x:10*i,y:Math.pow(1-t,i)},a={x:10*(i+1),y:Math.pow(1-t,i+1)},s=(e-c.x)*(a.y-c.y)/(a.x-c.x)+c.y;return tk.Cache[t]=p(((n={})[e]=s,n),tk.Cache[t]),s}tk.Cache={};var tR=function(t){var e=t.urlObj,n=t.actionConfig,r=t.ttnetDispatchActionData;if(n.action!==s.dispatch&&n.action!==s.web_dispatch||n.param.dispatch_strategy!==u.bestRouting)return{result:[],actionRan:!1};var o=function(t){var e,n=t.host,r=t.actionConfig,o=t.bestRoutingResult,i=null==r?void 0:r.param.strategy_info,c=i.target_hosts;if((null==r?void 0:r.param.dispatch_strategy)!==u.bestRouting||!i||!(null==c?void 0:c.length))return n;var a=null===(e=null==o?void 0:o.bestRouting)||void 0===e?void 0:e[r.sign],s=c.map(function(t){var e,n=null===(e=null==a?void 0:a[t])||void 0===e?void 0:e.result,r=i.coefficient;return!(null==n?void 0:n.length)||_(r)?[t,0]:[t,n.reduce(function(t,e,n){return e?t+e*tk(r,n):t},0)]}),l=[],h=-1/0;return(s.forEach(function(t){var e=t[0],n=t[1];n>h?(l=[e],h=n):n===h&&l.push(e)}),!(null==l?void 0:l.length)||(_(i.use_default_host)||i.use_default_host>0)&&l.includes(n))?n:l[0]}({host:e.host,actionConfig:n,bestRoutingResult:r}),i=new URL(e);return o&&(i.host=o),{result:[i],actionRan:!0}},tM=function(){function t(){var t=this;this.beforeProcess=function(e){var n=e.tncSchema,r=e.store;return m(t,void 0,void 0,function(){var t;return y(this,function(e){switch(e.label){case 0:if(!r.isSupportSync)return[3,1];return t=tC({tncSchema:n,storeType:r}),[3,3];case 1:return[4,function(t){var e;return m(this,void 0,void 0,function(){var n,r,o;return y(this,function(i){if(n=t.tncSchema,r=t.storeType,!(o=(n||{}).ttnet_dispatch_actions_epoch)||!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.bestRouting})))return[2];try{return[2,r.get({tableName:a.tnc_best_routing,key:[o]})]}catch(t){}return[2]})})}({tncSchema:n,storeType:r})];case 2:t=e.sent(),e.label=3;case 3:return[2,{ttnetUrlDispatchData:t}]}})})},this.beforeProcessSync=function(t){var e,n=t.tncSchema,r=t.store;return{ttnetUrlDispatchData:e=r.isSupportSync?tC({tncSchema:n,storeType:r}):void 0}},this.getTtnetUrlDispatchData=function(e){var n=e.preGetData;return m(t,void 0,void 0,function(){return y(this,function(t){return[2,n]})})},this.ttnetUrlDispatch=tR}return t.prototype.afterSchemaLoadInit=function(t){!function(t){m(this,void 0,void 0,function(){var e,n,r,o;return y(this,function(i){switch(i.label){case 0:if(e=t.tncSchema,n=t.storeType,r=t.value,!(o=(e||{}).ttnet_dispatch_actions_epoch))return[2];i.label=1;case 1:if(i.trys.push([1,5,,6]),!r)return[3,2];return n.setCache({tableName:a.tnc_best_routing,key:[o],value:r}),[2,r];case 2:return[4,n.readDataToCache({tableName:a.tnc_best_routing,key:[o]})];case 3:return[2,i.sent()];case 4:return[3,6];case 5:return i.sent(),[2];case 6:return[2]}})})}({tncSchema:t.tncSchema,storeType:t.store})},t.prototype.beforeFetch=function(t){return{needResponseStatus:t.processResults.some(function(t){var e=t.actionConfig;return(e.action===s.dispatch||e.action===s.web_dispatch)&&e.param.dispatch_strategy===u.bestRouting})}},t.prototype.afterFetchSuccess=function(t){var e=t.processResults,n=t.tncSchema,r=t.responseStatus,o=t.storeType;return m(this,void 0,void 0,function(){return y(this,function(t){return tT({processResults:e,tncSchema:n,responseStatus:r,storeType:o}),[2]})})},t.prototype.afterFetchError=function(t){var e=t.processResults,n=t.tncSchema,r=t.storeType;return m(this,void 0,void 0,function(){return y(this,function(t){return tT({processResults:e,tncSchema:n,responseStatus:null,storeType:r}),[2]})})},t}();function tI(t){var e,n=t.tncSchema,r=t.storeType,o=(n||{}).ttnet_dispatch_actions_epoch;if(!!o&&!!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.dynamicRouting})))try{return r.getSync({tableName:a.tnc_dynamic_routing,key:[o]})}catch(t){return}}function tU(t){return m(this,void 0,void 0,function(){var e,n,r,o;return y(this,function(i){if(e=t.tncSchema,n=t.storeType,r=t.value,!(o=(e||{}).ttnet_dispatch_actions_epoch))return[2];try{if(r)return n.setCache({tableName:a.tnc_dynamic_routing,key:[o],value:r}),[2,r];return[2,n.readDataToCache({tableName:a.tnc_dynamic_routing,key:[o]})]}catch(t){}return[2]})})}function tN(t){var e;return m(this,void 0,void 0,function(){var n,r,o;return y(this,function(i){if(n=t.tncSchema,r=t.storeType,!(o=(n||{}).ttnet_dispatch_actions_epoch)||!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.dynamicRouting})))return[2];try{return[2,r.get({tableName:a.tnc_dynamic_routing,key:[o]})]}catch(t){}return[2]})})}function tP(t){return m(this,void 0,void 0,function(){var e,n,r,o,i,c,s,u;return y(this,function(l){switch(l.label){case 0:if(e=t.sign,n=t.host,r=t.tncSchema,o=t.storeType,!(i=(r||{}).ttnet_dispatch_actions_epoch))return[2];l.label=1;case 1:return l.trys.push([1,5,,6]),[4,o.createTransaction({tableNames:[a.tnc_dynamic_routing],mode:"readwrite"})];case 2:return c=l.sent(),[4,o.get({tableName:a.tnc_dynamic_routing,key:[i],transaction:c,notUseCache:!0})];case 3:return s=l.sent(),u=function(t){var e=t.tncSchema,n=t.dynamicRoutingData,r=t.sign,o=t.host,i=(e||{}).ttnet_dispatch_actions_epoch,c=n||{ttnet_dispatch_actions_epoch:i,routing:{}};return o?c.routing[r]={result:o}:Reflect.deleteProperty(c.routing,r),c}({tncSchema:r,dynamicRoutingData:s,sign:e,host:n}),[4,o.put({tableName:a.tnc_dynamic_routing,key:[i],value:u,transaction:c})];case 4:return l.sent(),[2,u];case 5:return l.sent(),[2];case 6:return[2]}})})}var tx="tnc_update_dynamic_routing",tD=function(){function t(t){var e=this;this.status="stop",this.aid=t.aid,this.tncSchema=t.tncSchema,this.storeType=t.storeType,this.internalFetch=t.internalFetch,N()&&self.addEventListener("message",function(t){var n,r,o=t.data;o.action===tx&&((null===(n=o.payload.tncSchema)||void 0===n?void 0:n.ttnet_dispatch_actions_epoch)===(null===(r=e.tncSchema)||void 0===r?void 0:r.ttnet_dispatch_actions_epoch)||o.payload.aid===e.aid)&&tU({tncSchema:o.payload.tncSchema,storeType:e.storeType})})}return t.prototype.start=function(){this.status="running",this.startRoutingTask({firstDelay:3e3})},t.prototype.stop=function(){this.routingTaskTimer&&clearTimeout(this.routingTaskTimer),this.status="stop"},t.prototype.setTncSchema=function(t){var e,n=this.tncSchema;this.tncSchema=t,"running"===this.status&&(n?(null==n?void 0:n.ttnet_dispatch_actions_epoch)!==(null===(e=this.tncSchema)||void 0===e?void 0:e.ttnet_dispatch_actions_epoch)&&this.startRoutingTask():this.startRoutingTask({firstDelay:3e3}))},t.prototype.runRoutingTaskOnce=function(){var t,e,n;return m(this,void 0,void 0,function(){var r,o=this;return y(this,function(i){switch(i.label){case 0:r=null===(n=null===(e=null===(t=this.tncSchema)||void 0===t?void 0:t.ttnet_dispatch_actions)||void 0===e?void 0:e.filter(function(t){return t.param.dispatch_strategy===u.dynamicRouting}))||void 0===n?void 0:n.map(function(t){return o.routingActionTask(t)}),i.label=1;case 1:if(i.trys.push([1,6,,7]),!(null==r?void 0:r.length))return[3,3];return[4,Promise.all(r)];case 2:return i.sent(),[3,5];case 3:return[4,Promise.resolve()];case 4:i.sent(),i.label=5;case 5:return[3,7];case 6:return i.sent(),[3,7];case 7:return[2]}})})},t.prototype.startRoutingTask=function(t){var e=this;if(this.routingTaskTimer&&clearTimeout(this.routingTaskTimer),!!this.tncSchema){var n=function(){return m(e,void 0,void 0,function(){var t,e,r,o,i,c=this;return y(this,function(a){switch(a.label){case 0:t=null===(o=null===(r=null===(e=this.tncSchema)||void 0===e?void 0:e.ttnet_dispatch_actions)||void 0===r?void 0:r.filter(function(t){return t.param.dispatch_strategy===u.dynamicRouting}))||void 0===o?void 0:o.map(function(t){return c.routingActionTask(t)}),a.label=1;case 1:if(a.trys.push([1,6,,7]),!(null==t?void 0:t.length))return[3,3];return[4,Promise.all(t)];case 2:return a.sent(),[3,5];case 3:return[4,Promise.resolve()];case 4:a.sent(),a.label=5;case 5:return[3,7];case 6:return a.sent(),[3,7];case 7:return this.routingTaskTimer=setTimeout(n,(null===(i=this.tncSchema)||void 0===i?void 0:i.route_selection_trigger_interval)?1e3*this.tncSchema.route_selection_trigger_interval:18e5),[2]}})})};(null==t?void 0:t.firstDelay)?this.routingTaskTimer=setTimeout(n,t.firstDelay):n()}},t.prototype.routingActionTask=function(t){var e,n,r;return m(this,void 0,void 0,function(){var o,i,c,a,s,l,h,d,f,p,v,m=this;return y(this,function(g){switch(g.label){case 0:if(!this.tncSchema||t.param.dispatch_strategy!==u.dynamicRouting)return[2];return o=t.param.strategy_info,[4,tN({tncSchema:this.tncSchema,storeType:this.storeType})];case 1:if(i=null===(r=null===(n=null===(e=g.sent())||void 0===e?void 0:e.routing)||void 0===n?void 0:n[t.sign])||void 0===r?void 0:r.result,1!==o.working_mode)return[3,7];c=void 0,a=0,s=function(t){var e;return y(this,function(t){switch(t.label){case 0:return[4,Promise.all(o.candidates.map(function(t){return m.fetchRoutingPath({path:"".concat(t.host).concat(t.speed_path||"/ies/speed/").concat(1===t.speed_random_query?"?speed_random_query="+Math.random().toString().split(".")[1]:""),threshold:t.threshold,scheme_option:o.scheme_option,error_code:o.error_code})}))];case 1:if(t.sent().forEach(function(t,n){if(0!==t.status){var r=o.candidates[n],c=(r.host===i&&r.weight_increase_percent_if_using?t.time*((100-r.weight_increase_percent_if_using)/100)+(r.weight||0):t.time)+(r.weight||0);(!e||c<e.time)&&(e={host:r.host,time:c,candidate:r})}}),(null==e?void 0:e.host)===i)return c=null==e?void 0:e.host,[2,"break"];if(c&&(null==e?void 0:e.host)!==c)return c=i,[2,"break"];c=null==e?void 0:e.host,a++;if(!(null==e?void 0:e.candidate.consecutive_fastest)||a>=e.candidate.consecutive_fastest)return[2,"break"];return[2]}})},l=0,g.label=2;case 2:if(!(l<10))return[3,5];return[5,s(l)];case 3:if("break"===g.sent())return[3,5];g.label=4;case 4:return l++,[3,2];case 5:return[4,tP({sign:t.sign,host:c,tncSchema:this.tncSchema,storeType:this.storeType})];case 6:(h=g.sent())&&this.tncSchema&&k(d={action:tx,payload:{aid:this.aid,tncSchema:this.tncSchema,dynamicRouting:h}}),g.label=7;case 7:if(2!==o.working_mode)return[3,13];f=void 0,l=0,g.label=8;case 8:if(!(l<o.candidates.length))return[3,11];return p=o.candidates[l],[4,this.fetchRoutingPath({path:"".concat(p.host).concat(p.speed_path||"/ies/speed/").concat(1===p.speed_random_query?"?speed_random_query="+Math.random().toString().split(".")[1]:""),threshold:p.threshold,scheme_option:o.scheme_option,error_code:o.error_code})];case 9:if(1===(v=g.sent()).status)return f={host:p.host,time:v.time},[3,11];g.label=10;case 10:return l++,[3,8];case 11:return[4,tP({sign:t.sign,host:null==f?void 0:f.host,tncSchema:this.tncSchema,storeType:this.storeType})];case 12:(h=g.sent())&&k(d={action:tx,payload:{tncSchema:this.tncSchema,dynamicRouting:h}}),g.label=13;case 13:return[2]}})})},t.prototype.fetchRoutingPath=function(t){var e=t.path,n=t.threshold,r=t.scheme_option,o=t.error_code;return m(this,void 0,void 0,function(){var t;return y(this,function(i){switch(i.label){case 0:switch(r){case 2:return[3,1];case 3:return[3,3]}return[3,7];case 1:case 5:return[4,tj({internalFetch:this.internalFetch,url:"http://".concat(e),threshold:n,error_code:o})];case 2:case 6:case 8:return[2,i.sent()];case 3:case 7:return[4,tj({internalFetch:this.internalFetch,url:"https://".concat(e),threshold:n,error_code:o})];case 4:if(1!==(t=i.sent()).status)return[3,5];return[2,t]}})})},t}();function tj(t){var e=t.internalFetch,n=t.url,r=t.threshold,o=t.error_code;return m(this,void 0,void 0,function(){var t,i,c,a;return y(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=Date.now(),[4,Promise.race(g([new Promise(function(t,r){e({url:n,method:"GET",success:function(e){t({status:e.statusCode})},fail:function(){r()}})})],r?[new Promise(function(t,e){setTimeout(e,r)})]:[],!0))];case 1:if(i=s.sent(),c=Date.now()-t,!(a=null==i?void 0:i.status)||a&&(null==o?void 0:o.includes(a)))return[2,{status:0,time:0}];return[2,{status:1,time:c}];case 2:return s.sent(),[2,{status:0,time:0}];case 3:return[2]}})})}var tE=function(t){var e,n,r=t.urlObj,o=t.actionConfig,i=t.ttnetDispatchActionData;if(o.action!==s.dispatch&&o.action!==s.web_dispatch||o.param.dispatch_strategy!==u.dynamicRouting)return{result:[],actionRan:!1};var c=null===(n=null===(e=null==i?void 0:i.routing)||void 0===e?void 0:e[o.sign])||void 0===n?void 0:n.result,a=new URL(r);return c&&(a.host=c),{result:[a],actionRan:!0}},tq=function(){function t(t){var e=this;this.beforeProcess=function(t){var n=t.tncSchema,r=t.store;return m(e,void 0,void 0,function(){var t;return y(this,function(e){switch(e.label){case 0:if(!r.isSupportSync)return[3,1];return t=tI({tncSchema:n,storeType:r}),[3,3];case 1:return[4,tN({tncSchema:n,storeType:r})];case 2:t=e.sent(),e.label=3;case 3:return[2,{ttnetUrlDispatchData:t}]}})})},this.beforeProcessSync=function(t){var e,n=t.tncSchema,r=t.store;return{ttnetUrlDispatchData:e=r.isSupportSync?tI({tncSchema:n,storeType:r}):void 0}},this.getTtnetUrlDispatchData=function(t){var n=t.preGetData;return m(e,void 0,void 0,function(){return y(this,function(t){return[2,n]})})},this.ttnetUrlDispatch=tE,this.noRouting=null==t?void 0:t.noRouting}return t.prototype.init=function(t){var e,n=t.tncConfig,r=t.store,o=t.internalFetch;this.dynamicRoutingManager=new tD({aid:n.aid,storeType:r,internalFetch:o}),!this.noRouting&&(null===(e=this.dynamicRoutingManager)||void 0===e||e.start())},t.prototype.destroy=function(){var t;null===(t=this.dynamicRoutingManager)||void 0===t||t.stop()},t.prototype.afterSchemaLoadInit=function(t){tU({tncSchema:t.tncSchema,storeType:t.store})},t.prototype.onTncSchemaLoaded=function(t){var e,n=t.tncSchema;null===(e=this.dynamicRoutingManager)||void 0===e||e.setTncSchema(n)},t}();function tO(t){var e,n=t.tncSchema,r=t.storeType,o=(n||{}).ttnet_dispatch_actions_epoch;if(!!o&&!!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.elimination})))try{return r.getSync({tableName:a.tnc_elimination,key:[o]})}catch(t){return}}function tL(t){var e;return m(this,void 0,void 0,function(){var n,r,o,i,c,s,l,h,d,f,p,v,m,g,b;return y(this,function(y){switch(y.label){case 0:if(n=t.processResults,r=t.responseStatus,o=t.timeConsuming,i=t.tncSchema,c=t.storeType,s=(i||{}).ttnet_dispatch_actions_epoch,!i||!s)return[2];l=0,h=n,y.label=1;case 1:if(!(l<h.length))return[3,8];if(f=(d=h[l]).newHost,p=d.actionConfig,!f)return[2];if(p.param.dispatch_strategy!==u.elimination)return[3,7];v=p.param.strategy_info,y.label=2;case 2:return y.trys.push([2,6,,7]),[4,c.createTransaction({tableNames:[a.tnc_elimination],mode:"readwrite"})];case 3:return m=y.sent(),[4,c.get({tableName:a.tnc_elimination,key:[s],transaction:m,notUseCache:!0})];case 4:return g=y.sent(),b=function(t){var e=t.ttnet_dispatch_actions_epoch,n=t.eliminationData,r=t.sign,o=t.host,i=t.status,c=t.least_sample,a=n||{ttnet_dispatch_actions_epoch:e,elimination:{}},s=a.elimination[r]||{hosts:{}};if(!s.hosts&&(s.hosts={}),-1===i){var u=s.hosts[o]||{};u.failSamples=(u.failSamples||0)+1,u.failSamples>=(c||0)&&(u.forbidTime=Date.now()),s.hosts[o]=u}else 1===i&&(s.usingHost=o,delete s.hosts[o]);return a.elimination[r]=s,a}({ttnet_dispatch_actions_epoch:s,eliminationData:g,sign:p.sign,host:f,status:_(r)||(null===(e=null==v?void 0:v.error_code)||void 0===e?void 0:e.includes(r))||o&&(null==v?void 0:v.timeout)&&o>(null==v?void 0:v.timeout)?-1:1,least_sample:null==v?void 0:v.least_sample}),[4,c.put({tableName:a.tnc_elimination,key:[s],value:b,transaction:m})];case 5:return y.sent(),[3,7];case 6:return y.sent(),[2];case 7:return l++,[3,1];case 8:return[2]}})})}var tA=function(t){var e=t.urlObj,n=t.actionConfig,r=t.ttnetDispatchActionData;if(n.action!==s.dispatch&&n.action!==s.web_dispatch||n.param.dispatch_strategy!==u.elimination)return{result:[],actionRan:!1};var o=function(t){var e,n,r,o,i=t.host,c=t.actionConfig,a=t.eliminationResult,s=null===(n=null==c?void 0:c.param)||void 0===n?void 0:n.strategy_info;if((null==c?void 0:c.param.dispatch_strategy)!==u.elimination||!s)return i;var l=null===(r=s.target_hosts)||void 0===r?void 0:r.filter(function(t){var e,n,r=null===(n=null===(e=null==a?void 0:a.elimination[c.sign])||void 0===e?void 0:e.hosts)||void 0===n?void 0:n[t];return!r||!r.failSamples||!r.forbidTime||!(r.failSamples>=(s.least_sample||0)&&r.forbidTime+1e3*(s.forbid_duration||0)>=Date.now())&&!0});if(!(null==l?void 0:l.length)||(_(s.use_default_host)||s.use_default_host>0)&&l.includes(i))return i;var h=null===(o=null==a?void 0:a.elimination[c.sign])||void 0===o?void 0:o.usingHost;if(h&&l.includes(h))return h;if(!_(s.random_select)&&s.random_select>0){;return(e=l)[Math.floor(Math.random()*e.length)]}return l[0]}({host:e.host,actionConfig:n,eliminationResult:r}),i=new URL(e);return o&&(i.host=o),{result:[i],actionRan:!0}},tF=function(){function t(){var t=this;this.getTtnetUrlDispatchData=function(e){var n=e.preGetData;return m(t,void 0,void 0,function(){return y(this,function(t){return[2,n]})})},this.ttnetUrlDispatch=tA}return t.prototype.afterSchemaLoadInit=function(t){!function(t){m(this,void 0,void 0,function(){var e,n,r,o;return y(this,function(i){if(e=t.tncSchema,n=t.storeType,r=t.value,!(o=(e||{}).ttnet_dispatch_actions_epoch))return[2];try{if(r)return n.setCache({tableName:a.tnc_elimination,key:[o],value:r}),[2,r];return[2,n.readDataToCache({tableName:a.tnc_elimination,key:[o]})]}catch(t){}return[2]})})}({tncSchema:t.tncSchema,storeType:t.store})},t.prototype.beforeProcess=function(t){var e=t.tncSchema,n=t.store;return m(this,void 0,void 0,function(){var t;return y(this,function(r){switch(r.label){case 0:if(!n.isSupportSync)return[3,1];return t=tO({tncSchema:e,storeType:n}),[3,3];case 1:return[4,function(t){var e;return m(this,void 0,void 0,function(){var n,r,o;return y(this,function(i){if(n=t.tncSchema,r=t.storeType,!(o=(n||{}).ttnet_dispatch_actions_epoch)||!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.elimination})))return[2];try{return[2,r.get({tableName:a.tnc_elimination,key:[o]})]}catch(t){}return[2]})})}({tncSchema:e,storeType:n})];case 2:t=r.sent(),r.label=3;case 3:return[2,{ttnetUrlDispatchData:t}]}})})},t.prototype.beforeProcessSync=function(t){var e,n=t.tncSchema,r=t.store;return{ttnetUrlDispatchData:e=r.isSupportSync?tO({tncSchema:n,storeType:r}):void 0}},t.prototype.beforeFetch=function(t){return{needResponseStatus:t.processResults.some(function(t){var e=t.actionConfig;return(e.action===s.dispatch||e.action===s.web_dispatch)&&e.param.dispatch_strategy===u.elimination})}},t.prototype.afterFetchSuccess=function(t){var e=t.processResults,n=t.tncSchema,r=t.responseStatus,o=t.storeType,i=t.timeConsuming;return m(this,void 0,void 0,function(){return y(this,function(t){return tL({processResults:e,tncSchema:n,responseStatus:r,timeConsuming:i,storeType:o}),[2]})})},t.prototype.afterFetchError=function(t){var e=t.processResults,n=t.tncSchema,r=t.storeType;return m(this,void 0,void 0,function(){return y(this,function(t){return tL({processResults:e,timeConsuming:void 0,tncSchema:n,responseStatus:null,storeType:r}),[2]})})},t}(),tH={ttnetUrlDispatch:function(t){var e,n,r,o,i,c,a=t.urlObj,l=t.matchActionResult,h=t.referrer,d=t.actionConfig;if(d.action!==s.dispatch&&d.action!==s.web_dispatch||d.param.dispatch_strategy!==u.orderTry)return{result:[],actionRan:!1};return{result:(n=(e={urlObj:a,matchActionResult:l,referrer:h,actionConfig:d}).urlObj,r=e.matchActionResult,o=e.referrer,c=null==(i=e.actionConfig)?void 0:i.param.strategy_info,(null==i?void 0:i.param.dispatch_strategy)===u.orderTry&&(null==c?void 0:c.targets.length)?(0===c.use_default_host?c.targets:c.targets.sort(function(t,e){return t.host_replace&&t.host_replace!==n.host?e.host_replace&&e.host_replace!==n.host?0:1:-1})).map(function(t){return tS({urlObj:n,matchActionResult:r,referrer:o,processParams:p({full_url_group:i.param.full_url_group,pattern_group:i.param.pattern_group},t)})}):[n]),actionRan:!0}},beforeFetch:function(t){return{retryErrorResponseStatuses:function(t){for(var e,n=t.processResults,r=n.length-1;r>=0;r--){var o=n[r].actionConfig;if((o.action===s.dispatch||o.action===s.web_dispatch)&&o.param.dispatch_strategy===u.orderTry)return null===(e=o.param.strategy_info)||void 0===e?void 0:e.error_code}}({processResults:t.processResults})}}};function tG(t){var e,n=t.url,r=t.tncSchema,o={};if(!(null==r?void 0:r.web_request_control))return o;try{e=new URL(n)}catch(t){return o}if(Array.isArray(r.web_request_control.mode_change))for(var i=0,c=r.web_request_control.mode_change;i<c.length;i++){var a=c[i];if(!!a.mode){var s=void 0;if(a.host_group&&Array.isArray(a.host_group)){for(var u=0,l=a.host_group;u<l.length;u++){var h=l[u];if("*"===h||h===e.host){s=!0;break}}void 0===s&&(s=!1)}else s=!0;if(s){o.mode=a.mode;break}}}if(Array.isArray(r.web_request_control.credentials_change))for(var d=0,f=r.web_request_control.credentials_change;d<f.length;d++){var p=f[d];if(!(!p.credentials&&_(p.xhr_with_credentials))){var s=void 0;if(p.host_group&&Array.isArray(p.host_group)){for(var v=0,m=p.host_group;v<m.length;v++){var h=m[v];if("*"===h||h===e.host){s=!0;break}}void 0===s&&(s=!1)}else s=!0;if(s){o.credentials=p.credentials,o.xhr_with_credentials=1===p.xhr_with_credentials;break}}}return o}var tW={beforeFetchModifyRequest:function(t){var e=tG({url:t.newUrl,tncSchema:t.tncSchema});return{mode:e.mode,credentials:e.credentials}},beforeXhrModifyRequest:function(t){return{xhrWithCredentials:tG({url:t.newUrl,tncSchema:t.tncSchema}).xhr_with_credentials}}},tB=function(t){var e=this;this.onBeforeRequest=null==t?void 0:t.onBeforeRequest,this.onBeforeRequest&&(this.beforeFetch=function(t){var n;return null===(n=e.onBeforeRequest)||void 0===n||n.call(e,{originalUrl:t.originalUrl,dispatchedUrl:t.dispatchedUrl,sequenceNumber:t.sequenceNumber}),{}})},tX=function(t,e){return(tX=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function tz(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}tX(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function tV(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function t$(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}"function"==typeof SuppressedError&&SuppressedError;var tQ=function(){return(tQ=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n],e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function tJ(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function tZ(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function tK(t){return null==t}function tY(t){var e,n=t.dbStructure,r=t.tableName,o=t.key,i=t.value,c="web_store_".concat(n.dbName,"_").concat(n.dbVersion,"_").concat(r);if(o)return c+"_"+(Array.isArray(o)?o.join("-"):o);var a=null===(e=n.tableStructures.find(function(t){return t.name===r}))||void 0===e?void 0:e.storeParameters.keyPath;return a?c+"_"+(Array.isArray(a)?a.map(function(t){return(null==i?void 0:i[t])||""}).join("-"):(null==i?void 0:i[a])||""):c}"function"==typeof SuppressedError&&SuppressedError;var t0=function(){function t(t){this.cacheObj={},this.dbStructure=t.dbStructure}return t.prototype.get=function(t){var e=tY({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});return this.cacheObj[e]},t.prototype.remove=function(t){var e=tY({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});delete this.cacheObj[e]},t.prototype.set=function(t){var e=tY({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key,value:t.value});this.cacheObj[e]=t.value},t}();!function(){function t(t){this.webStoreCore=t.webStoreCore,this.cacheMode=t.cacheMode||"no_cache",("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(this.webStoreCache=new t0({dbStructure:t.webStoreCore.dbStructure}))}Object.defineProperty(t.prototype,"isSupportSync",{get:function(){return this.webStoreCore.supportSync},enumerable:!1,configurable:!0}),t.prototype.getCacheMode=function(){return this.cacheMode},t.prototype.createTransaction=function(t){return this.webStoreCore.createTransaction(t)},t.prototype.get=function(t){var e,n;return tJ(this,void 0,void 0,function(){var r,o;return tZ(this,function(i){switch(i.label){case 0:if(!t.notUseCache&&"cache_only"===this.cacheMode)return tK(r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t))&&this.readDataToCache(t),[2,r];if(!(!t.notUseCache&&"cache_first"===this.cacheMode))return[3,3];if(tK(r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t)))return[3,1];return[2,r];case 1:case 3:return[4,this.webStoreCore.get(t)];case 2:return o=i.sent(),this.setCache(tQ(tQ({},t),{value:o})),[2,o];case 4:return[2,i.sent()]}})})},t.prototype.delete=function(t){var e;return tJ(this,void 0,void 0,function(){return tZ(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),[2,this.webStoreCore.delete(t)]})})},t.prototype.add=function(t){var e;return tJ(this,void 0,void 0,function(){return tZ(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.add(t)]})})},t.prototype.put=function(t){var e;return tJ(this,void 0,void 0,function(){return tZ(this,function(n){return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),[2,this.webStoreCore.put(t)]})})},t.prototype.getSync=function(t){var e,n;if(!t.notUseCache&&"cache_only"===this.cacheMode){var r=null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t);return tK(r)&&this.readDataToCache(t),r}if(!t.notUseCache&&"cache_first"===this.cacheMode){var r=null===(n=this.webStoreCache)||void 0===n?void 0:n.get(t);if(!tK(r))return r;var o=this.webStoreCore.getSync(t);return this.setCache(tQ(tQ({},t),{value:o})),o}return this.webStoreCore.getSync(t)},t.prototype.deleteSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.remove(t)),this.webStoreCore.deleteSync(t)},t.prototype.addSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.addSync(t)},t.prototype.putSync=function(t){var e;return!t.notUseCache&&("cache_only"===this.cacheMode||"cache_first"===this.cacheMode)&&(null===(e=this.webStoreCache)||void 0===e||e.set(t)),this.webStoreCore.putSync(t)},t.prototype.getFromCache=function(t){var e;return null===(e=this.webStoreCache)||void 0===e?void 0:e.get(t)},t.prototype.setCache=function(t){this.webStoreCache&&this.webStoreCache.set(t)},t.prototype.readDataToCache=function(t){return tJ(this,void 0,void 0,function(){var e;return tZ(this,function(n){switch(n.label){case 0:return[4,this.webStoreCore.get(t)];case 1:return!tK(e=n.sent())&&this.webStoreCache&&this.webStoreCache.set(tQ(tQ({},t),{value:e})),[2,e]}})})}}();var t1=function(){function t(t){this.dbStructure=t.dbStructure}return t.prototype.getSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.deleteSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.addSync=function(t){throw Error("WebStore: not support async operation.")},t.prototype.putSync=function(t){throw Error("WebStore: not support async operation.")},t}();function t2(){return"undefined"!=typeof my}function t3(){return"undefined"!=typeof wx?wx:"undefined"!=typeof tt?tt:"undefined"!=typeof swan?swan:"undefined"!=typeof my?my:void 0}var t4=function(t){function e(e){var n=t.call(this,e)||this;return n.supportSync=!0,n.backbone=e.backbone,n}return tz(e,t),e.prototype.createTransaction=function(t){return tV(this,void 0,void 0,function(){return t$(this,function(t){return[2,null]})})},e.prototype.get=function(t){return tV(this,void 0,void 0,function(){var e=this;return t$(this,function(n){return[2,new Promise(function(n,r){var o,i=tY({dbStructure:e.dbStructure,tableName:t.tableName,key:t.key});null===(o=e.backbone)||void 0===o||o.getStorage({key:i,success:function(t){n(null==t?void 0:t.data)},fail:function(){n(null)},complete:function(){}})})]})})},e.prototype.getSync=function(t){var e,n,r=tY({dbStructure:this.dbStructure,tableName:t.tableName,key:t.key});if(t2()){var o=null===(e=this.backbone)||void 0===e?void 0:e.getStorageSync({key:r});return null==o?void 0:o.data}var i=null===(n=this.backbone)||void 0===n?void 0:n.getStorageSync(r);return""===i?null:i},e.prototype.add=function(t){return tV(this,void 0,void 0,function(){return t$(this,function(e){return[2,this.put(t)]})})},e.prototype.addSync=function(t){return this.putSync(t)},e.prototype.put=function(t){return tV(this,void 0,void 0,function(){var e=this;return t$(this,function(n){return[2,new Promise(function(n,r){var o,i=tY({dbStructure:e.dbStructure,tableName:null==t?void 0:t.tableName,key:null==t?void 0:t.key,value:null==t?void 0:t.value});null===(o=e.backbone)||void 0===o||o.setStorage({key:i,data:null==t?void 0:t.value,success:n,fail:r,complete:function(){}})})]})})},e.prototype.putSync=function(t){var e,n,r=tY({dbStructure:this.dbStructure,tableName:null==t?void 0:t.tableName,key:null==t?void 0:t.key,value:null==t?void 0:t.value});if(t2()){null===(e=this.backbone)||void 0===e||e.setStorageSync({key:r,data:null==t?void 0:t.value});return}null===(n=this.backbone)||void 0===n||n.setStorageSync(r,null==t?void 0:t.value)},e.prototype.delete=function(t){return tV(this,void 0,void 0,function(){var e=this;return t$(this,function(n){return[2,new Promise(function(n,r){var o,i=tY({dbStructure:e.dbStructure,tableName:null==t?void 0:t.tableName,key:null==t?void 0:t.key});null===(o=e.backbone)||void 0===o||o.removeStorage({key:i,success:n,fail:r,complete:function(){}})})]})})},e.prototype.deleteSync=function(t){var e,n=tY({dbStructure:this.dbStructure,tableName:null==t?void 0:t.tableName,key:null==t?void 0:t.key});null===(e=this.backbone)||void 0===e||e.removeStorageSync(n)},e.getSync=function(t){var e,n=null!==(e=t.backbone)&&void 0!==e?e:t3();if(t2()){var r=null==n?void 0:n.getStorageSync({key:t.key});return null==r?void 0:r.data}var o=null==n?void 0:n.getStorageSync(t.key);return""===o?null:o},e.setSync=function(t){var e,n=null!==(e=t.backbone)&&void 0!==e?e:t3();if(t2()){null==n||n.setStorageSync({key:t.key,data:null==t?void 0:t.value});return}null==n||n.setStorageSync(t.key,null==t?void 0:t.value)},e}(t1);function t5(t,e){return t+Math.floor(Math.random()*(e-t+1))}!function(t){function e(e){var n=t.call(this,e)||this;return n.supportSync=!1,n.backbone=e.backbone,n}tz(e,t),e.prototype.createTransaction=function(t){return tV(this,void 0,void 0,function(){return t$(this,function(t){return[2,null]})})},e.prototype.get=function(t){return tV(this,void 0,void 0,function(){var e=this;return t$(this,function(n){return[2,new Promise(function(n,r){var o,i=tY({dbStructure:e.dbStructure,tableName:t.tableName,key:t.key});null===(o=e.backbone)||void 0===o||o.get({key:i,default:"",success:n,fail:r,complete:function(){}})})]})})},e.prototype.add=function(t){return tV(this,void 0,void 0,function(){return t$(this,function(e){return this.put(t),[2]})})},e.prototype.put=function(t){return tV(this,void 0,void 0,function(){var e=this;return t$(this,function(n){return[2,new Promise(function(n,r){var o,i=tY({dbStructure:e.dbStructure,tableName:null==t?void 0:t.tableName,key:null==t?void 0:t.key,value:null==t?void 0:t.value});null===(o=e.backbone)||void 0===o||o.set({key:i,value:null==t?void 0:t.value,success:n,fail:r,complete:function(){}})})]})})},e.prototype.delete=function(t){return tV(this,void 0,void 0,function(){var e=this;return t$(this,function(n){return[2,new Promise(function(n,r){var o,i=tY({dbStructure:e.dbStructure,tableName:null==t?void 0:t.tableName,key:null==t?void 0:t.key});null===(o=e.backbone)||void 0===o||o.delete({key:i,success:n,fail:r,complete:function(){}})})]})})}}(t1);var t6="__tnc_random_did";function t7(){var t=parseInt(localStorage.getItem(t6)||"");return t&&!Number.isNaN(t)?t:(t=t5(1,Number.MAX_SAFE_INTEGER),localStorage.setItem(t6,t.toString()),t)}function t8(){var t=parseInt(t4.getSync({key:t6})||"");return t&&!Number.isNaN(t)?t:(t=t5(1,Number.MAX_SAFE_INTEGER),t4.setSync({key:t6,value:t.toString()}),t)}var t9=function(t){var e=t.url,n=t.method,r=t.expectResponseType,o=t.data,i=t.header,c=t.success,a=t.fail,s=t.complete;return m(void 0,void 0,void 0,function(){var t,u,l,h;return y(this,function(d){switch(d.label){case 0:return d.trys.push([0,6,7,8]),[4,fetch(e,{method:n,headers:i,body:o})];case 1:if(t=d.sent(),u={},null===(h=null==t?void 0:t.headers)||void 0===h||h.forEach(function(t,e){u[e]=t}),l=void 0,"json"!==r)return[3,5];d.label=2;case 2:return d.trys.push([2,4,,5]),[4,t.json()];case 3:return l=d.sent(),[3,5];case 4:return d.sent(),null==a||a({}),[3,5];case 5:return null==c||c({data:l,statusCode:null==t?void 0:t.status,header:u}),[3,8];case 6:return d.sent(),null==a||a({}),[3,8];case 7:return null==s||s({}),[7];case 8:return[2]}})})};function et(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function ee(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function en(t){return null==t||!1}"function"==typeof SuppressedError&&SuppressedError;var er=function(){if(null===(i=null==self?void 0:self.navigator)||void 0===i?void 0:i.userAgent){var t,e,n,r,o,i,c,a,s=(t=(t=null===(c=null==self?void 0:self.navigator)||void 0===c?void 0:c.userAgent).toLocaleLowerCase(),r="ipad"===(n=null==(e=/(ipad)/.exec(t)||/(ipod)/.exec(t)||/(iphone)/.exec(t)||/(windows phone)/.exec(t)||/(android)/.exec(t)||/(win)/.exec(t)||/(mac)/.exec(t)||/(linux)/.exec(t))?void 0:e[0])||"ipod"===n||"iphone"===n,{isIos:r,isAndroid:o="android"===n,isMobile:r||o||"windows phone"===n,isWindows:"win"===n,isMac:"mac"===n});a=s.isAndroid?"android":s.isIos?"ios":s.isMobile?"h5":s.isWindows?"windows":s.isMac?"macos":"pc"}else a=void 0!==h&&h.release?"node":"web";return a},eo=function(){function t(){this.logCache=[],this.logCachePoint=-1}return t.prototype.pushLog=function(e){this.logCachePoint=(this.logCachePoint+1)%t.MAX_CACHE_SIZE,this.logCache[this.logCachePoint]=e},t.prototype.popLog=function(){return this.logCache.pop()},t.MAX_CACHE_SIZE=1e3,t}(),ei=function(){try{return"cls_js_0.1.3.0"}catch(t){return"cls_js_0.9.9.9"}}(),ec=function(){function t(t){var e=this;this.logs=[],this.timer=null,this.cacheLogBeforeGetSchema=new eo,this.cacheLogBeforeGetSchemaPopped=!1;var n=t.clsSchemaManager,r=t.clsConfig;this.clsSchemaManager=n,this.clsConfig=r,this.clsSchemaManager.onSchemaInitLoaded(function(){e.clearCacheLogBeforeGetSchema()})}return t.prototype.init=function(){return et(this,void 0,void 0,function(){return ee(this,function(t){return this.startTimer(),[2]})})},t.prototype.updateClsConfig=function(t){this.clsConfig=t.clsConfig},t.prototype.addLog=function(t,e,n){var r;return et(this,void 0,void 0,function(){var o,i,c,a;return ee(this,function(s){switch(s.label){case 0:if(!(o=this.clsSchemaManager.getClsSchema()))return[3,3];if(this.clearCacheLogBeforeGetSchema(),(null==o?void 0:o.config_data.enable)!==1)return[3,2];if((i=Object.keys(null===(r=null==o?void 0:o.config_data)||void 0===r?void 0:r.sample)).filter(function(t){var e,n,r;null===(r=null===(n=null===(e=null==o?void 0:o.config_data)||void 0===e?void 0:e.sample)||void 0===n?void 0:n[t])||void 0===r||r.enable}),!i.includes(e))return[3,2];if(c={event_time:null!=n?n:Date.now(),log_type:e,content:JSON.stringify(t)},this.logs.push(c),!(this.logs.length>=this.getSendLogSize()))return[3,2];return a=this.logs,this.logs=[],this.restartTimer(),[4,this.sendLogs(a)];case 1:s.sent(),s.label=2;case 2:return[3,4];case 3:this.cacheLogBeforeGetSchema.pushLog({log_type:e,log_data:t,event_time:Date.now()}),s.label=4;case 4:return[2]}})})},t.prototype.sendLogs=function(t){return et(this,void 0,void 0,function(){return ee(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,function(t){var e,n,r,o;return et(this,void 0,void 0,function(){var i,c,a,s,u,l,h,d,f,p,v,m,y;return ee(this,function(g){switch(g.label){case 0:var b;return i=t.clsSchema,c=t.clsConfig,[4,(b=JSON.stringify(t.logData),(null==self?void 0:self.CompressionStream)?new Response(new Blob([b]).stream().pipeThrough(new self.CompressionStream("gzip"))).arrayBuffer():b)];case 1:switch(a=g.sent(),s=[],c.region){case"boe":s=s.concat(["cls-boe.zijieapi.com"]);break;case"abroad":s=s.concat(["cls.byteintlapi.com"]);break;default:s=s.concat(["cls.zijieapi.com"])}(null===(n=null===(e=null==i?void 0:i.config_data)||void 0===e?void 0:e.common)||void 0===n?void 0:n.report_hosts)&&(s=s.concat(null===(o=null===(r=null==i?void 0:i.config_data)||void 0===r?void 0:r.common)||void 0===o?void 0:o.report_hosts)),!(u=c.device_platform)&&(u=er()),l={aid:c.aid,device_platform:u,device_id:c.device_id,version_code:c.version_code,cls_sdk_version:ei,update_version_code:c.update_version_code,device_model:c.device_model,os_version:c.os_version,channel:c.channel,sdk_id:c.sdk_id},h=new URLSearchParams,Object.entries(l).map(function(t){var e=t[0],n=t[1];!en(n)&&h.append(e,n.toString())}),d=h.toString(),p=function(t){var e,n;return ee(this,function(r){switch(r.label){case 0:e="https://".concat(t,"/cls/log/json_collect?").concat(d),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,new Promise(function(t,n){c.internalFetch({url:e,method:"POST",expectResponseType:"json",data:a,header:{"content-type":"application/json;encoding=utf-8","content-encoding":"gzip"},success:function(e){t(e.data)},fail:function(){n()}})})];case 2:if((n=r.sent()).data&&"ok"===n.message)return f=n.data,[2,"break"];return[2,"continue"];case 3:return r.sent(),[3,4];case 4:return[2]}})},v=0,m=s,g.label=2;case 2:if(!(v<m.length))return[3,5];return y=m[v],[5,p(y)];case 3:if("break"===g.sent())return[3,5];g.label=4;case 4:return v++,[3,2];case 5:if(f)return[2,f];throw Error("CLS 上报日志失败")}})})}({clsSchema:this.clsSchemaManager.getClsSchema(),clsConfig:this.clsConfig,logData:t})];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})},t.prototype.startTimer=function(){var t=this;this.timer=setInterval(function(){t.logs.length>0&&(t.sendLogs(t.logs),t.logs=[],t.restartTimer())},this.getSendLogInterval())},t.prototype.stopTimer=function(){clearInterval(this.timer),this.timer=null},t.prototype.restartTimer=function(){this.stopTimer(),this.startTimer()},t.prototype.getSendLogInterval=function(){var t,e,n,r,o,i;return(null===(n=null===(e=null===(t=this.clsSchemaManager.getClsSchema())||void 0===t?void 0:t.config_data)||void 0===e?void 0:e.report)||void 0===n?void 0:n.interval)?1e3*Number(null===(i=null===(o=null===(r=this.clsSchemaManager.getClsSchema())||void 0===r?void 0:r.config_data)||void 0===o?void 0:o.report)||void 0===i?void 0:i.interval):1e4},t.prototype.getSendLogSize=function(){var t,e,n,r,o,i;return(null===(n=null===(e=null===(t=this.clsSchemaManager.getClsSchema())||void 0===t?void 0:t.config_data)||void 0===e?void 0:e.report)||void 0===n?void 0:n.max_log_number)?Number(null===(i=null===(o=null===(r=this.clsSchemaManager.getClsSchema())||void 0===r?void 0:r.config_data)||void 0===o?void 0:o.report)||void 0===i?void 0:i.max_log_number):32},t.prototype.clearCacheLogBeforeGetSchema=function(){return et(this,void 0,void 0,function(){var t;return ee(this,function(e){switch(e.label){case 0:if(this.cacheLogBeforeGetSchemaPopped)return[2];this.cacheLogBeforeGetSchemaPopped=!0,e.label=1;case 1:if(!(t=this.cacheLogBeforeGetSchema.popLog()))return[3,3];return[4,this.addLog(t.log_data,t.log_type,t.event_time)];case 2:return e.sent(),[3,4];case 3:return[3,5];case 4:return[3,1];case 5:return[2]}})})},t}(),ea=function(){function t(){this.events={}}return t.prototype.on=function(t,e){!this.events[t]&&(this.events[t]=[]),this.events[t].push(e)},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=this.events[t];if(!!(null==r?void 0:r.length))r.forEach(function(t){t.apply(void 0,e)})},t}(),es="EVENT_SCHEMA_INIT_LOADED",eu=function(){function t(t){this.events=new ea,this.status="stop",this.clsConfig=t.clsConfig}return t.prototype.init=function(){return et(this,void 0,void 0,function(){var t,e;return ee(this,function(e){switch(e.label){case 0:if(e.trys.push([0,3,,4]),!this.clsConfig.aid)return[3,2];return[4,el({clsConfig:this.clsConfig,clsSchema:this.clsSchema})];case 1:t=e.sent(),e.label=2;case 2:return[3,4];case 3:return e.sent(),[3,4];case 4:return t&&(this.clsSchema=t,this.events.emit(es)),this.clsConfig.aid&&this.startPullTask(),[2]}})})},t.prototype.onSchemaInitLoaded=function(t){this.events.on(es,t)},t.prototype.updateClsConfig=function(t){return et(this,void 0,void 0,function(){var e,n;return ee(this,function(n){switch(n.label){case 0:if(this.clsConfig=t.clsConfig,!this.clsSchema)return[3,5];n.label=1;case 1:if(n.trys.push([1,4,,5]),!this.clsConfig.aid)return[3,3];return e=this,[4,el({clsConfig:this.clsConfig,clsSchema:this.clsSchema})];case 2:e.clsSchema=n.sent(),n.label=3;case 3:return[3,5];case 4:return n.sent(),[3,5];case 5:return[2]}})})},t.prototype.startPullTask=function(){var t=this,e=function(){return et(t,void 0,void 0,function(){var t;return ee(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,el({clsConfig:this.clsConfig,clsSchema:this.clsSchema})];case 1:return t=n.sent(),this.updateClsSchema(t),[3,3];case 2:return n.sent(),[3,3];case 3:return"pulling"===this.status&&(this.pullTaskTimer=setTimeout(e,this.getClsSchemaPullInterval())),[2]}})})};this.status="pulling",this.pullTaskTimer=setTimeout(e,this.getClsSchemaPullInterval())},t.prototype.stopPullTask=function(){this.pullTaskTimer&&clearTimeout(this.pullTaskTimer),this.status="stop"},t.prototype.updateClsSchema=function(t){this.clsSchema=t},t.prototype.getClsSchema=function(){return this.clsSchema},t.prototype.getClsSchemaPullInterval=function(){var t,e,n,r,o,i;return(null===(n=null===(e=null===(t=this.clsSchema)||void 0===t?void 0:t.config_data)||void 0===e?void 0:e.common)||void 0===n?void 0:n.update_interval)?1e3*Number(null===(i=null===(o=null===(r=this.clsSchema)||void 0===r?void 0:r.config_data)||void 0===o?void 0:o.common)||void 0===i?void 0:i.update_interval):18e5},t}();function el(t){var e,n,r,o;return et(this,void 0,void 0,function(){var i,c,a,s,u,l,h,d,f,p,v,m;return ee(this,function(y){switch(y.label){case 0:switch(i=t.clsConfig,c=t.clsSchema,a=[],i.region){case"boe":a=a.concat(["cls-setting-boe.zijieapi.com"]);break;case"abroad":a=a.concat(["cls-setting.byteintlapi.com"]);break;default:a=a.concat(["cls-setting.zijieapi.com"])}!(s=i.device_platform)&&(s=er()),(null===(n=null===(e=null==c?void 0:c.config_data)||void 0===e?void 0:e.common)||void 0===n?void 0:n.settings_hosts)&&(a=a.concat(null===(o=null===(r=null==c?void 0:c.config_data)||void 0===r?void 0:r.common)||void 0===o?void 0:o.settings_hosts)),u={aid:i.aid,device_platform:s,device_id:i.device_id,version_code:i.version_code,cls_sdk_version:ei,update_version_code:i.update_version_code,device_model:i.device_model,os_version:i.os_version,channel:i.channel,sdk_id:i.sdk_id,sdk_version:i.sdk_version,uid:i.uid},l=new URLSearchParams,Object.entries(u).map(function(t){var e=t[0],n=t[1];!en(n)&&l.append(e,String(n))}),h=l.toString(),f=function(t){var e,n;return ee(this,function(r){switch(r.label){case 0:e="https://".concat(t,"/cls/settings/v1?").concat(h),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,new Promise(function(t,n){i.internalFetch({url:e,method:"GET",expectResponseType:"json",success:function(e){t(e.data)},fail:function(){n()}})})];case 2:if((n=r.sent()).data&&"ok"===n.msg)return d=n.data,[2,"break"];return[2,"continue"];case 3:throw r.sent(),Error("CLS 拉取配置失败");case 4:return[2]}})},p=0,v=a,y.label=1;case 1:if(!(p<v.length))return[3,4];return m=v[p],[5,f(m)];case 2:if("break"===y.sent())return[3,4];y.label=3;case 3:return p++,[3,1];case 4:if(d)return[2,d];throw Error("CLS 拉取配置失败")}})})}var eh=function(){function t(t){this.clsConfig=t.clsConfig,this.clsSchemaManager=new eu({clsConfig:this.clsConfig}),this.clsSender=new ec({clsSchemaManager:this.clsSchemaManager,clsConfig:this.clsConfig})}return t.prototype.init=function(){return et(this,void 0,void 0,function(){return ee(this,function(t){switch(t.label){case 0:return[4,Promise.all([this.clsSchemaManager.init(),this.clsSender.init()])];case 1:return t.sent(),[2]}})})},t.prototype.updateClsConfig=function(t){this.clsConfig=t.clsConfig,this.clsSchemaManager.updateClsConfig(t),this.clsSender.updateClsConfig(t)},t.prototype.reportCommonLog=function(t){return et(this,void 0,void 0,function(){var e,n;return ee(this,function(r){return e=t.data,n=t.logType,this.clsSender.addLog(e,n),[2]})})},t}(),ed=function(){function t(){this.clsInstanceCalledInit=!1,this.clsInstance=new eh({clsConfig:{}})}return t.prototype.init=function(t){var e=t.tncConfig;this.tncConfig=e,e.aid&&e.device_id&&!this.clsInstanceCalledInit&&(this.clsInstanceCalledInit=!0,this.clsInstance.updateClsConfig({clsConfig:{internalFetch:e.internalFetch,aid:e.aid,device_id:e.device_id,uid:e.user_id,region:e.region,version_code:"0"}}),this.clsInstance.init())},t.prototype.onTncSchemaUpdate=function(t){var e,n,r=t.tncSchemaInfo;!this.clsInstanceCalledInit&&this.tncConfig&&(null===(e=null==r?void 0:r.originalTncConfig)||void 0===e?void 0:e.aid)&&(null===(n=null==r?void 0:r.originalTncConfig)||void 0===n?void 0:n.device_id)&&(this.clsInstanceCalledInit=!0,this.clsInstance.updateClsConfig({clsConfig:{internalFetch:this.tncConfig.internalFetch,aid:r.originalTncConfig.aid,device_id:r.originalTncConfig.device_id,uid:r.originalTncConfig.user_id,region:r.originalTncConfig.region,version_code:"0"}}),this.clsInstance.init())},t.prototype.afterSchemaLoadInit=function(t){var e,n,r=t.tncSchemaInfo;!this.clsInstanceCalledInit&&this.tncConfig&&(null===(e=null==r?void 0:r.originalTncConfig)||void 0===e?void 0:e.aid)&&(null===(n=null==r?void 0:r.originalTncConfig)||void 0===n?void 0:n.device_id)&&(this.clsInstanceCalledInit=!0,this.clsInstance.updateClsConfig({clsConfig:{internalFetch:this.tncConfig.internalFetch,aid:r.originalTncConfig.aid,device_id:r.originalTncConfig.device_id,uid:r.originalTncConfig.user_id,region:r.originalTncConfig.region,version_code:"0"}}),this.clsInstance.init())},t.prototype.afterFetchSuccess=function(t){return m(this,void 0,void 0,function(){return y(this,function(e){return this.reportLog(t),[2]})})},t.prototype.afterFetchError=function(t){return m(this,void 0,void 0,function(){return y(this,function(e){return this.reportLog(p(p({},t),{responseStatus:-1})),[2]})})},t.prototype.reportLog=function(t){var e,n,r,o,i,c,a,s=t.original_url,u=t.request_url,l=t.referrer_url,h=t.processResults,d=t.tncSchema,f=t.tncSchemaInfo,p=t.responseStatus,v=t.requestAttemptNumber;if(!!(null==h?void 0:h.length)&&!!this.clsInstance)this.clsInstance.reportCommonLog({logType:"tnc_js_dispatch",data:{tnc_js_request_original_url:s,tnc_js_request_request_url:u,tnc_js_request_referrer_url:l,tnc_js_request_ttnet_dispatch_actions_epoch:d.ttnet_dispatch_actions_epoch,tnc_js_request_process_results:h.map(function(t){return{target_url:t.newUrl,rule_id:t.actionConfig.rule_id}}),tnc_js_request_attempt_number:v,aid:null===(e=null==f?void 0:f.requestQueryPayload)||void 0===e?void 0:e.aid,device_id:null===(n=null==f?void 0:f.requestQueryPayload)||void 0===n?void 0:n.device_id,device_platform:null===(r=null==f?void 0:f.requestQueryPayload)||void 0===r?void 0:r.device_platform,tnc_js_sdk_version:null===(o=null==f?void 0:f.requestQueryPayload)||void 0===o?void 0:o.tnc_js_sdk_version,unit:function(t){var e,n=null==t?void 0:t["x-env-v2"];if(!!n)return null===(e=n.match(/(?:;|^)unit:([^;]+)(?:;|$)/))||void 0===e?void 0:e[1]}(null==f?void 0:f.requestHeaders),brand:function(t){var e,n=null==t?void 0:t["x-env-v2"];if(!!n)return null===(e=n.match(/(?:;|^)brand:([^;]+)(?:;|$)/))||void 0===e?void 0:e[1]}(null==f?void 0:f.requestHeaders),"x-ss-etag":null===(i=null==f?void 0:f.responseHeaders)||void 0===i?void 0:i["x-ss-etag"],"x-tt-tnc-config":null===(c=null==f?void 0:f.responseHeaders)||void 0===c?void 0:c["x-tt-tnc-config"],"x-tt-tnc-abtest":null===(a=null==f?void 0:f.responseHeaders)||void 0===a?void 0:a["x-tt-tnc-abtest"],response_status:p}})},t}(),ef=function(t){function e(e){var n,r=this,o=e.tncConfig,i=o.storeType,c=o.device_id,a=v(o,["storeType","device_id"]),s=new X({webStoreCore:"localStorage"===i?new tf({dbStructure:R}):new tr({dbStructure:R}),cacheMode:o.storeCacheMode});return(r=t.call(this,{tncConfig:p(p({},a),{store:s,internalFetch:t9,device_id:null!=c?c:null===(n=t7())||void 0===n?void 0:n.toString()}),plugins:g([tp,tw,new tM,new tq,new tF,tH,tW,new tB],o.enableLog?[new ed]:[],!0)})||this).store=s,r}return f(e,t),e.prototype.updateTncConfig=function(e){var n,r;t.prototype.updateTncConfig.call(this,{tncConfig:p(p({},e.tncConfig),{store:this.store,internalFetch:t9,device_id:null!==(n=e.tncConfig.device_id)&&void 0!==n?n:null===(r=t7())||void 0===r?void 0:r.toString()})})},e}(L);function ep(t){return"[object String]"===Object.prototype.toString.call(t)}function ev(t){return ep(t)?t:t instanceof URL?t.toString():null==t?void 0:t.url}function em(t){var e;try{var n=t.url,r=t.tncSchema,o=t.referrer,i=t.ttnetUrlDispatches,c=t.ttnetUrlDispatchesData;if(!r||1!==r.ttnet_url_dispatcher_enabled||!(null===(e=r.ttnet_dispatch_actions)||void 0===e?void 0:e.length))return[{newUrl:t.url,processResults:[]}];var a=ey(r),s=eg({url:n,referrer:o});return function t(e){var n=e.step,r=e.pastProcessResults,o=e.sortedActionsList,i=e.urlObj,c=e.referrer,a=e.ttnetUrlDispatches,s=e.ttnetUrlDispatchesData;if(_(n)||n<0)return[{newUrl:i.toString(),processResults:r}];var u=o[n];if(!u)return[{newUrl:i.toString(),processResults:r}];var l=function(t){var e=t.urlObj,n=t.actionConfig,r=t.referrer,o=t.ttnetUrlDispatches,i=t.ttnetUrlDispatchesData,c=t_({urlObj:e,actionConfig:n,referrer:r}),a=[{newUrlObj:e,matched:!!c.matched,processResult:{newUrl:e.toString(),newHost:e.host,actionConfig:n}}];if(!c.matched)return a;for(var s=0;s<((null==o?void 0:o.length)||0);s++){var u=null==o?void 0:o[s];if(!!u){var l=u({ttnetDispatchActionData:i[s],urlObj:e,matchActionResult:c,referrer:r,actionConfig:n}),h=l.result;if(l.actionRan)return h.map(function(t){return{newUrlObj:t,matched:!!c.matched,processResult:{newUrl:t.toString(),newHost:t.host,actionConfig:n}}})}}return a}({urlObj:i,actionConfig:u,referrer:c,ttnetUrlDispatches:a,ttnetUrlDispatchesData:s}),h=[];return l.forEach(function(e){var i=e.newUrlObj,l=e.matched,d=e.processResult,f=g([],r,!0);l&&d&&f.push(d),l&&u.set_req_priority&&u.set_req_priority<0?h.push({newUrl:i.toString(),processResults:f}):l&&u.set_req_priority?h.push.apply(h,t({step:function(t,e,n,r){e=n(e);for(var o=0,i=t?t.length:0,c=e!=e,a=null===e,s=void 0===e;o<i;){var u=Math.floor((o+i)/2),l=n(t[u]),h=void 0!==l,d=l==l;if(c)var f=d||void 0;else f=a?d&&h&&(r||null!=l):s?d&&(r||h):null!=l&&(r?l<=e:l<e);f?o=u+1:i=u}return i}(o,{act_priority:u.set_req_priority},function(t){return t.act_priority}),pastProcessResults:f,sortedActionsList:o,urlObj:i,referrer:c,ttnetUrlDispatches:a,ttnetUrlDispatchesData:s})):h.push.apply(h,t({step:n+1,pastProcessResults:f,sortedActionsList:o,urlObj:i,referrer:c,ttnetUrlDispatches:a,ttnetUrlDispatchesData:s}))}),h}({step:0,pastProcessResults:[],sortedActionsList:a||[],urlObj:s,referrer:o,ttnetUrlDispatches:i,ttnetUrlDispatchesData:c})}catch(e){return[{newUrl:t.url,processResults:[]}]}}function ey(t){var e,n,r;return null===(r=null===(n=null===(e=null==t?void 0:t.ttnet_dispatch_actions)||void 0===e?void 0:e.filter(function(t){return!!t.act_priority}))||void 0===n?void 0:n.map(function(t){return p(p({},t),{act_priority:Number(t.act_priority),set_req_priority:_(t.set_req_priority)?t.set_req_priority:Number(t.set_req_priority)})}))||void 0===r?void 0:r.sort(function(t,e){return t.act_priority-e.act_priority})}function eg(t){var e=t.url,n=t.referrer;if(!n)return new URL(e);var r=new URL(n);return e.includes("://")?new URL(e):e.startsWith("//")?new URL(r.protocol+e):e.startsWith("/")?new URL(r.origin+e):new URL(r.origin+"/"+e)}function eb(t){return m(this,void 0,void 0,function(){var e,n,r,o,i,c;return y(this,function(a){switch(a.label){case 0:if(e=t.tncManager,n=v(t,["tncManager"]),!e.tncConfig.store.isSupportSync)return[3,1];return c=e.tncSchemaManager.getTncSchemaSync(),[3,3];case 1:return[4,e.tncSchemaManager.getTncSchemaAsync()];case 2:c=a.sent(),a.label=3;case 3:return o=(r=c).tncSchema,i=r.tncSchemaInfo,[2,function(t){var e,n,r,o;return m(this,void 0,void 0,function(){var i,c,a,s,u,l,h,d,f,v,b,_,S,w,C,T,k,R,M,I,U;return y(this,function(N){switch(N.label){case 0:if(c=void 0===(i=t._fetch)?fetch:i,a=t.tncCore,s=t.tncSchema,u=t.tncSchemaInfo,l=t.requestInput,h=t.requestInit,d=t.originalRequestParams,f=t.getReferrer,v=t.onBeforeRequestSend,b=a.plugins,_=a.tncConfig.store,S=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return null==v||v(),c.apply(void 0,t)},!(!s||!s.ttnet_url_dispatcher_enabled||!(null==b?void 0:b.length)))return[3,2];return[4,S(l,h)];case 1:case 5:case 7:case 11:return[2,N.sent()];case 2:return N.trys.push([2,4,,6]),[4,function(t,e){var n,r;return m(this,void 0,void 0,function(){var o,i,c,a,s,u,l;return y(this,function(h){switch(h.label){case 0:if(o=ev(t),i=ep(t),!o)return[2,null];if(!i)return[3,1];return c=e,[3,5];case 1:if(a=t,!((null==(s=e)?void 0:s.body)||(null===(n=null==a?void 0:a.headers)||void 0===n?void 0:n.get("Content-Type"))))return[3,3];return[4,null===(r=null==a?void 0:a.clone())||void 0===r?void 0:r.blob()];case 2:return l=h.sent(),[3,4];case 3:l=void 0,h.label=4;case 4:u=l,c={method:(null==s?void 0:s.method)||(null==a?void 0:a.method),keepalive:(null==s?void 0:s.keepalive)||(null==a?void 0:a.keepalive),mode:(null==s?void 0:s.mode)||(null==a?void 0:a.mode),redirect:(null==s?void 0:s.redirect)||(null==a?void 0:a.redirect),referrer:(null==s?void 0:s.referrer)||(null==a?void 0:a.referrer),referrerPolicy:(null==s?void 0:s.referrerPolicy)||(null==a?void 0:a.referrerPolicy),signal:(null==s?void 0:s.signal)||(null==a?void 0:a.signal),headers:(null==s?void 0:s.headers)||(null==a?void 0:a.headers),body:u,cache:(null==s?void 0:s.cache)||(null==a?void 0:a.cache),credentials:(null==s?void 0:s.credentials)||(null==a?void 0:a.credentials),integrity:(null==s?void 0:s.integrity)||(null==a?void 0:a.integrity)},h.label=5;case 5:return[2,{url:o,requestInit:c}]}})})}(l,h)];case 3:return w=N.sent(),[3,6];case 4:case 10:return N.sent(),[4,S(l,h)];case 6:if(!(!w||!w.url))return[3,8];return[4,S(l,h)];case 8:return N.trys.push([8,10,,12]),[4,Promise.all(b.map(function(t){var e;return null===(e=t.beforeProcess)||void 0===e?void 0:e.call(t,{tncSchema:s,store:_})}))];case 9:return C=N.sent().map(function(t){return null==t?void 0:t.ttnetUrlDispatchData}),[3,12];case 12:if(N.trys.push([12,16,,18]),R=null==f?void 0:f(),"[object Promise]"!==Object.prototype.toString.call(R))return[3,14];return[4,R];case 13:return k=N.sent(),[3,15];case 14:k=R,N.label=15;case 15:return T=em({url:w.url,tncSchema:s,referrer:k,ttnetUrlDispatches:b.map(function(t){return t.ttnetUrlDispatch}),ttnetUrlDispatchesData:b.map(function(t,e){return C[e]})}),[3,18];case 16:return N.sent(),[4,S(l,h)];case 17:return[2,N.sent()];case 18:M=function(i){var c,a,f,v,C,R,M,I,U,N,P,x,D,j,E,q;return y(this,function(O){switch(O.label){case 0:if(a=(c=T[i]).newUrl,!(f=c.processResults).length)return[2,"continue"];v=void 0,O.label=1;case 1:for(O.trys.push([1,2,,4]),v=w.requestInit||{},C=0;C<b.length;C++)(R=b[C]).beforeFetchModifyRequest&&((M=R.beforeFetchModifyRequest({newUrl:a,tncSchema:s,requestInit:v,processResults:f,mode:null===(e=w.requestInit)||void 0===e?void 0:e.mode,credentials:null===(n=w.requestInit)||void 0===n?void 0:n.credentials})).mode&&(v.mode=M.mode),M.credentials&&(v.credentials=M.credentials));return[3,4];case 2:return O.sent(),I={},[4,S(l,h)];case 3:return[2,(I.value=O.sent(),I)];case 4:U=void 0,O.label=5;case 5:return O.trys.push([5,6,,8]),U=b.map(function(t){var e;return null===(e=t.beforeFetch)||void 0===e?void 0:e.call(t,{processResults:f,originalUrl:null==w?void 0:w.url,dispatchedUrl:a,sequenceNumber:i})}),(null===(r=t.requestInit)||void 0===r?void 0:r.tncOnBeforeRequest)&&(null===(o=t.requestInit)||void 0===o||o.tncOnBeforeRequest({originalUrl:null==w?void 0:w.url,dispatchedUrl:a,sequenceNumber:i})),[3,8];case 6:return O.sent(),N={},[4,S(l,h)];case 7:return[2,(N.value=O.sent(),N)];case 8:P=U.some(function(t){return null==t?void 0:t.needResponseStatus}),x=U.reduce(function(t,e){var n;if(!(null===(n=null==e?void 0:e.retryErrorResponseStatuses)||void 0===n?void 0:n.length))return t;return Array.from(new Set(g(g([],t,!0),e.retryErrorResponseStatuses,!0)))},[]),j=void 0,E=Date.now(),q=0,O.label=9;case 9:return O.trys.push([9,11,,12]),[4,function(t){return m(this,void 0,void 0,function(){var e,n,r,o,i,c,a,s,u;return y(this,function(l){switch(l.label){case 0:if(e=t.url,n=t.requestInit,r=t.originalRequestParams,i=void 0===(o=t._fetch)?fetch:o,t.needHttpStatus)return[3,12];if((null==n?void 0:n.mode)!=="navigate")return[3,9];if(a=r?ev(null==r?void 0:r[0]):void 0,!(r&&a===e))return[3,2];return[4,i.apply(void 0,r)];case 1:case 3:return c=l.sent(),[3,8];case 2:return l.trys.push([2,4,,8]),[4,i(e,p(p({},n),{mode:"cors"}))];case 4:if(s=l.sent(),!r)return[3,6];return[4,i.apply(void 0,r)];case 5:return c=l.sent(),[3,7];case 6:throw s;case 7:return[3,8];case 8:return[3,11];case 9:return[4,i(e,n)];case 10:c=l.sent(),l.label=11;case 11:return[3,26];case 12:if(!(!(null==n?void 0:n.mode)||(null==n?void 0:n.mode)==="cors"))return[3,14];return[4,i(e,n)];case 13:return c=l.sent(),[3,26];case 14:if((null==n?void 0:n.mode)!=="navigate")return[3,22];l.label=15;case 15:return l.trys.push([15,17,,21]),[4,i(e,p(p({},n),{mode:"cors"}))];case 16:return c=l.sent(),[3,21];case 17:if(u=l.sent(),!r)return[3,19];return[4,i.apply(void 0,r)];case 18:return c=l.sent(),[3,20];case 19:throw u;case 20:return[3,21];case 21:return[3,26];case 22:return l.trys.push([22,24,,26]),[4,i(e,p(p({},n),{mode:"cors"}))];case 23:case 25:return c=l.sent(),[3,26];case 24:return l.sent(),[4,i(e,n)];case 26:return[2,c]}})})}({url:a,requestInit:v,originalRequestParams:d,_fetch:S,needHttpStatus:P||!!(null==x?void 0:x.length)})];case 10:return D=O.sent(),q=Date.now()-E,[3,12];case 11:return j=O.sent(),[3,12];case 12:if(!D||j){try{Promise.all(b.map(function(t){var e;return null===(e=t.afterFetchError)||void 0===e?void 0:e.call(t,{original_url:null==w?void 0:w.url,request_url:a,referrer_url:k,processResults:f,tncSchema:s,tncSchemaInfo:u,storeType:_,requestAttemptNumber:i})}))}catch(t){}if(i<T.length-1)return[2,"continue"];throw j}try{b.map(function(t){var e;return null===(e=t.afterFetchSuccess)||void 0===e?void 0:e.call(t,{original_url:null==w?void 0:w.url,request_url:a,referrer_url:k,processResults:f,tncSchema:s,tncSchemaInfo:u,responseStatus:D.status,storeType:_,timeConsuming:q,requestAttemptNumber:i})})}catch(t){}if(null==x?void 0:x.includes(D.status)){if(i<T.length-1)return[2,"continue"];throw j}return[2,{value:D}]}})},I=0,N.label=19;case 19:if(!(I<T.length))return[3,22];return[5,M(I)];case 20:if("object"==typeof(U=N.sent()))return[2,U.value];N.label=21;case 21:return I++,[3,19];case 22:return[4,S(l,h)];case 23:return[2,N.sent()]}})})}(p({tncCore:e,tncSchema:o,tncSchemaInfo:i},n))]}})})}function e_(t){var e,n,r,o,i,c=(r=void 0===(n=(e={tncManager:t.tncManager,onBeforeRequestSend:t.onBeforeRequestSend})._fetch)?window.fetch:n,o=e.tncManager,i=e.onBeforeRequestSend,new Proxy(r,{apply:function(t,e,n){var r,c,a;return i&&(c=Date.now(),a=null===(r=null==performance?void 0:performance.mark("request_start"))||void 0===r?void 0:r.startTime),eb({tncManager:o,requestInput:n[0],requestInit:n[1],_fetch:t,getReferrer:function(){return window.location.href},onBeforeRequestSend:i?function(){var t;i({tncStartTime:c,tncEndTime:Date.now(),tncDuration:(null===(t=null==performance?void 0:performance.mark("fetch_end"))||void 0===t?void 0:t.startTime)-a})}:void 0})}}));window.fetch=c}var eS=self;!function(t){function e(e){var n=t.call(this,{tncConfig:p({store:new X({webStoreCore:new tr({dbStructure:R}),cacheMode:e.cacheMode}),internalFetch:t9,swMode:"not-manage"},e.tncConfig),plugins:g(g([tp,tw,new tM,new tq({noRouting:!0}),new tF,tH,tW,new tB],e.enableLog?[new ed]:[],!0),e.appendPlugin||[],!0),notRequestTncSchema:!0})||this;return n.addedFetchListeners=[],n.init(),n.tncFetch=function(t){var e=this,n=t.normalFetch,r=t.tncServiceWorkerManager;return new Proxy(n,{apply:function(t,n,o){return m(e,void 0,void 0,function(){var e,n,i,c=this;return y(this,function(a){return n=(e=o||[])[0],[2,eb({tncManager:r,requestInput:n,requestInit:i=e[1],_fetch:t,getReferrer:function(){return m(c,void 0,void 0,function(){var t,e,r,o,c,a,s,u;return y(this,function(l){switch(l.label){case 0:t=(null==i?void 0:i.referrer)||(null===(s=n)||void 0===s?void 0:s.referrer),l.label=1;case 1:if(l.trys.push([1,6,,7]),!(!t||!(new URL(t).pathname.length>1)))return[3,5];if(e=eS.clients,!(r=null===(u=null==i?void 0:i.tncFetchEvent)||void 0===u?void 0:u.clientId))return[3,5];if(!("get"in e))return[3,3];return[4,e.get(r)];case 2:return t=(c=null==(o=l.sent())?void 0:o.url)||"",[3,5];case 3:return[4,e.matchAll({type:"window"})];case 4:(a=l.sent().filter(function(t){return t.id===r})).length>0&&(t=(c=a[0].url)||""),l.label=5;case 5:return[3,7];case 6:return l.sent(),[3,7];case 7:return[2,t]}})})}})]})})}})}({tncServiceWorkerManager:n,normalFetch:fetch}),n}f(e,t),e.prototype.destroy=function(){this.addedFetchListeners.forEach(function(t){eS.removeEventListener("fetch",t)}),this.addedFetchListeners=[],t.prototype.destroy.call(this)},e.prototype.listenFetchEvent=function(t){var e=this,n=(t||{}).fetchFilter,r=function(t){if(n&&!n(t))return;var r=e.tncSchemaManager.getTncSchemaInCache().tncSchema;if(!r||!!function(t){var e,n=t.url,r=t.schema,o=t.referrer,i=t.ignore_referrer;if(!r||1!==r.ttnet_url_dispatcher_enabled||!(null===(e=r.ttnet_dispatch_actions)||void 0===e?void 0:e.length))return!1;for(var c=ey(r),a=eg({url:n,referrer:o}),s=0,u=c||[];s<u.length;s++)if(t_({ignore_referrer:i,urlObj:a,actionConfig:u[s],referrer:o}).matched)return!0;return!1}({url:t.request.url,schema:r,ignore_referrer:!0}))t.respondWith(m(e,void 0,void 0,function(){return y(this,function(e){return fetch.isTncProxyFetch?[2,fetch(t.request,{tncFetchEvent:t})]:[2,this.tncFetch(t.request,{tncFetchEvent:t})]})}))};this.addedFetchListeners.push(r),eS.addEventListener("fetch",r)}}(L);var ew=self;function eC(t){var e=t.tncManager,n=e.plugins,r=e.tncConfig.store,o=new Proxy(window.XMLHttpRequest.prototype.open,{apply:function(t,o,i){try{var c,a=e.tncSchemaManager.getTncSchemaSync(),s=a.tncSchema,u=a.tncSchemaInfo;if(o._tnc_original_url=i[1],!s||!s.ttnet_url_dispatcher_enabled)return Reflect.apply(t,o,g([],i,!0));o._tnc_tncSchema=s,o._tnc_tncSchemaInfo=u;try{c=n.map(function(t){var e;return null===(e=t.beforeProcessSync)||void 0===e?void 0:e.call(t,{tncSchema:s,store:r})}).map(function(t){return null==t?void 0:t.ttnetUrlDispatchData})}catch(e){return Reflect.apply(t,o,g([],i,!0))}o._tnc_referrer_url=window.location.href;var l=void 0;try{l=[(l=em({url:o._tnc_original_url,tncSchema:s,referrer:o._tnc_referrer_url,ttnetUrlDispatches:n.map(function(t){return t.ttnetUrlDispatch}),ttnetUrlDispatchesData:n.map(function(t,e){return c[e]})}))[0]],o._tnc_url_process_result=l}catch(e){return Reflect.apply(t,o,g([],i,!0))}for(var h=function(e){var r=l[e],c=r.newUrl,a=r.processResults;o._tnc_request_url=c;try{for(var u=0;u<n.length;u++){var h=n[u];if(h.beforeXhrModifyRequest){var d=h.beforeXhrModifyRequest({newUrl:c,tncSchema:s});!_(d.xhrWithCredentials)&&(o.withCredentials=d.xhrWithCredentials)}}}catch(e){return{value:Reflect.apply(t,o,g([],i,!0))}}try{n.map(function(t){var n;return null===(n=t.beforeFetch)||void 0===n?void 0:n.call(t,{processResults:a,originalUrl:o._tnc_original_url,dispatchedUrl:c,sequenceNumber:e})})}catch(e){return{value:Reflect.apply(t,o,g([],i,!0))}}return i[1]=c,{value:Reflect.apply(t,o,g([],i,!0))}},d=0;d<l.length;d++){var f=h(d);if("object"==typeof f)return f.value}}catch(e){return Reflect.apply(t,o,g([],i,!0))}}});window.XMLHttpRequest.prototype.open=o;var i=new Proxy(window.XMLHttpRequest,{construct:function(t){var e=new t;return e.addEventListener("load",function(){for(var t,o=function(t){var o=e._tnc_url_process_result[t].processResults;n.map(function(n){var i;return null===(i=n.afterFetchSuccess)||void 0===i?void 0:i.call(n,{original_url:e._tnc_original_url,request_url:e._tnc_request_url,referrer_url:e._tnc_referrer_url,processResults:o,tncSchema:e._tnc_tncSchema,tncSchemaInfo:e._tnc_tncSchemaInfo,responseStatus:e.status,storeType:r,timeConsuming:void 0,requestAttemptNumber:t})})},i=0;i<(null===(t=e._tnc_url_process_result)||void 0===t?void 0:t.length);i++)o(i)}),e.addEventListener("error",function(){for(var t,o=function(t){var o=e._tnc_url_process_result[t].processResults;n.map(function(n){var i;return null===(i=n.afterFetchError)||void 0===i?void 0:i.call(n,{original_url:e._tnc_original_url,request_url:e._tnc_request_url,referrer_url:e._tnc_referrer_url,processResults:o,tncSchema:e._tnc_tncSchema,tncSchemaInfo:e._tnc_tncSchemaInfo,storeType:r,requestAttemptNumber:t})})},i=0;i<(null===(t=e._tnc_url_process_result)||void 0===t?void 0:t.length);i++)o(i)}),e}});window.XMLHttpRequest=i}!function(){function t(){this.tncInstances={}}t.prototype.proxyFetchInSw=function(){var t=this,e=new Proxy(ew.fetch,{apply:function(e,n,r){return m(t,void 0,void 0,function(){var t,n,o,i,c=this;return y(this,function(a){for(i in n=(t=r||[])[0],o=t[1],this.tncInstances){if(!!this.tncInstances[i]&&!!this.tncInstances[i].matcher({requestInput:n,requestInit:o}))return[2,eb({tncManager:this.tncInstances[i].tncManager,requestInput:n,requestInit:o,_fetch:e,getReferrer:function(){return m(c,void 0,void 0,function(){var t,e,r,i,c,a,s,u;return y(this,function(l){switch(l.label){case 0:t=(null==o?void 0:o.referrer)||(null===(s=n)||void 0===s?void 0:s.referrer),l.label=1;case 1:if(l.trys.push([1,6,,7]),!(!t||!(new URL(t).pathname.length>1)))return[3,5];if(e=ew.clients,!(r=null===(u=null==o?void 0:o.tncFetchEvent)||void 0===u?void 0:u.clientId))return[3,5];if(!("get"in e))return[3,3];return[4,e.get(r)];case 2:return t=(c=null==(i=l.sent())?void 0:i.url)||"",[3,5];case 3:return[4,e.matchAll({type:"window"})];case 4:(a=l.sent().filter(function(t){return t.id===r})).length>0&&(t=(c=a[0].url)||""),l.label=5;case 5:return[3,7];case 6:return l.sent(),[3,7];case 7:return[2,t]}})})}})]}return[2,e.apply(void 0,r)]})})}});e.isTncProxyFetch=!0,ew.fetch=e},t.prototype.addTncInstance=function(t){if(!!t.tncManager.tncConfig.aid)this.tncInstances[t.tncManager.tncConfig.aid]={matcher:t.matcher,tncManager:t.tncManager}},t.prototype.removeTncInstance=function(t){if(!!t.tncManager.tncConfig.aid)delete this.tncInstances[t.tncManager.tncConfig.aid]}}();var eT=function(t){var e=t.url,n=t.method,r=t.data,o=t.header,i=t.success,c=t.fail,a=t.complete,s=t.expectResponseType,u=tm();if(!u)throw Error("Unable to get global object");null==u||u.request({url:e,method:n,dataType:void 0===s&&"undefined"!=typeof my?"text":void 0,data:r,header:o,success:i,fail:c||function(){},complete:a||function(){}})};!function(t){function e(e){var n,r=this,o=e.tncConfig,i=o.device_id,c=o.enableLog,a=v(o,["device_id","enableLog"]),s=new X({webStoreCore:new t4({dbStructure:R,backbone:tm()}),cacheMode:o.storeCacheMode});return(r=t.call(this,{tncConfig:p(p({internalFetch:eT},a),{store:s,device_id:null!=i?i:null===(n=t8())||void 0===n?void 0:n.toString()}),plugins:g([tp,tw,new tM,new tq,new tF,tH,tW,new tB],c?[new ed]:[],!0)})||this).store=s,r}f(e,t),e.prototype.updateTncConfig=function(e){var n,r;t.prototype.updateTncConfig.call(this,{tncConfig:p(p({},e.tncConfig),{store:this.store,internalFetch:eT,device_id:null!==(n=e.tncConfig.device_id)&&void 0!==n?n:null===(r=t8())||void 0===r?void 0:r.toString()})})}}(L),tm()}}]);